Java Vault Connector

Connect Hashicorp's Vault with your Java application.



Current version: 0.7.1 (2018-03-17)

Tested up to: Vault 0.11.5


Features


Maven Artifact

<dependency>
    <groupId>de.stklcode.jvault</groupId>
    <artifactId>connector</artifactId>
    <version>0.7.1</version>
</dependency>

Usage Examples

Initialization


// Instantiate using builder pattern style factory
VaultConnector vault = VaultConnectorFactory.httpFactory()
    .withHost("127.0.0.1")
    .withPort(8200)
    .withTLS()
    .build();

// Initialization from environment variables
VaultConnector vault = VaultConnectorFactory.httpFactory()
    .fromEnv()
    .build();
    

Authentication


// Authenticate with token
vault.authToken("01234567-89ab-cdef-0123-456789abcdef");

// Authenticate with username and password
vault.authUserPass("username", "p4ssw0rd");

// Authenticate with AppRole (secret optional)
vault.authAppRole("01234567-89ab-cdef-0123-456789abcdef",
                  "fedcba98-7654-3210-fedc-ba9876543210");
    

Secret Read & Write


// Retrieve secret value
String secret = vault.readSecret("some/secret/key").getValue();


// Retrieve complex secret
Map<String, Object> secret = vault.readSecret("my/secret").getData();
    

Token and Role Creation


// Create token using TokenBuilder
Token token = new TokenBuilder().withId("token id")
                                .withDisplayName("test token")
                                .withPolicies("pol1", "pol2")
                                .build();
vault.createToken(token);

/// Create AppRole credentials
vault.createAppRole("testrole", policyList);
AppRoleSecretResponse secret = vault.createAppRoleSecret("testrole");
    

Download

Latest version: connector-0.7.1.jar (sha256, asc), source (sha256, asc)

Older releases: archive (changelog)


PGP Fingerprint:

D48D 78BD 52BF BB26 6B48 923E BFBC 48FA D733 3A31


License

This project is licensed under Apache License 2.0

by Stefan Kalscheuer, 2016-2018 (legal notice)