public class HTTPVaultConnector extends Object implements VaultConnector
Constructor and Description |
---|
HTTPVaultConnector(String baseURL)
Create connector using full URL.
|
HTTPVaultConnector(String hostname,
boolean useTLS)
Create connector using hostname and schema.
|
HTTPVaultConnector(String hostname,
boolean useTLS,
Integer port)
Create connector using hostname, schema and port.
|
HTTPVaultConnector(String hostname,
boolean useTLS,
Integer port,
String prefix)
Create connector using hostname, schema, port and path.
|
HTTPVaultConnector(String hostname,
boolean useTLS,
Integer port,
String prefix,
SSLContext sslContext)
Create connector using hostname, schema, port, path and trusted certificate.
|
HTTPVaultConnector(String baseURL,
SSLContext sslContext)
Create connector using full URL and trusted certificate.
|
Modifier and Type | Method and Description |
---|---|
AuthResponse |
authAppId(String appID,
String userID)
Authorize to Vault using AppID method.
|
AuthResponse |
authAppRole(String roleID,
String secretID)
Authorize to Vault using AppRole method.
|
TokenResponse |
authToken(String token)
Authorize to Vault using token.
|
AuthResponse |
authUserPass(String username,
String password)
Authorize to Vault using username and password.
|
boolean |
createAppRole(AppRole role)
Register a new AppRole role from given metamodel.
|
AppRoleSecretResponse |
createAppRoleSecret(String roleName,
AppRoleSecret secret)
Register new AppRole secret with custom ID.
|
AuthResponse |
createToken(Token token)
Create a new token.
|
AuthResponse |
createToken(Token token,
boolean orphan)
Create a new token.
|
AuthResponse |
createToken(Token token,
String role)
Create a new token for specific role.
|
boolean |
deleteAppRole(String roleName)
Delete AppRole role from Vault.
|
boolean |
deleteSecret(String key)
Delete secret from Vault.
|
boolean |
destroyAppRoleSecret(String roleName,
String secretID)
Destroy an AppRole secret.
|
String |
getAppRoleID(String roleName)
Retrieve ID for an AppRole role.
|
List<AuthBackend> |
getAuthBackends()
Get all availale authentication backends.
|
boolean |
init()
Verify that vault connection is initialized.
|
boolean |
isAuthorized()
Get authorization status
|
List<String> |
listAppRoles()
List existing (accessible) AppRole roles.
|
List<String> |
listAppRoleSecretss(String roleName)
List existing (accessible) secret IDs for AppRole role.
|
List<String> |
listSecrets(String path)
List available secrets from Vault.
|
AppRoleResponse |
lookupAppRole(String roleName)
Lookup an AppRole role.
|
AppRoleSecretResponse |
lookupAppRoleSecret(String roleName,
String secretID)
Lookup an AppRole secret.
|
TokenResponse |
lookupToken(String token)
Lookup token information.
|
SecretResponse |
readSecret(String key)
Retrieve secret form Vault.
|
boolean |
registerAppId(String appID,
String policy,
String displayName)
Register new App-ID with policy.
|
boolean |
registerUserId(String appID,
String userID)
Register User-ID with App-ID
|
SecretResponse |
renew(String leaseID,
Integer increment)
Renew lease with given ID.
|
void |
resetAuth()
Reset authorization information.
|
boolean |
revoke(String leaseID)
Revoke given lease immediately.
|
boolean |
seal()
Seal vault.
|
SealResponse |
sealStatus()
Retrieve status of vault seal.
|
boolean |
setAppRoleID(String roleName,
String roleID)
Set custom ID for an AppRole role.
|
SealResponse |
unseal(String key,
Boolean reset)
Unseal vault.
|
boolean |
writeSecret(String key,
String value)
Write secret to Vault.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
authAppRole, createAppRole, createAppRole, createAppRole, createAppRole, createAppRoleSecret, createAppRoleSecret, registerAppUserId, renew, unseal
public HTTPVaultConnector(String hostname, boolean useTLS)
hostname
- The hostnameuseTLS
- If TRUE, use HTTPS, otherwise HTTPpublic HTTPVaultConnector(String hostname, boolean useTLS, Integer port)
hostname
- The hostnameuseTLS
- If TRUE, use HTTPS, otherwise HTTPport
- The portpublic HTTPVaultConnector(String hostname, boolean useTLS, Integer port, String prefix)
hostname
- The hostnameuseTLS
- If TRUE, use HTTPS, otherwise HTTPport
- The portprefix
- HTTP API prefix (default: /v1/)public HTTPVaultConnector(String hostname, boolean useTLS, Integer port, String prefix, SSLContext sslContext)
hostname
- The hostnameuseTLS
- If TRUE, use HTTPS, otherwise HTTPport
- The portprefix
- HTTP API prefix (default: /v1/)sslContext
- Custom SSL Contextpublic HTTPVaultConnector(String baseURL)
baseURL
- The URLpublic HTTPVaultConnector(String baseURL, SSLContext sslContext)
baseURL
- The URLpublic void resetAuth()
VaultConnector
resetAuth
in interface VaultConnector
public SealResponse sealStatus()
VaultConnector
sealStatus
in interface VaultConnector
public boolean seal()
VaultConnector
seal
in interface VaultConnector
public SealResponse unseal(String key, Boolean reset)
VaultConnector
unseal
in interface VaultConnector
key
- A single master share keyreset
- Discard previously provided keys (optional)public boolean isAuthorized()
VaultConnector
isAuthorized
in interface VaultConnector
public boolean init()
VaultConnector
init
in interface VaultConnector
public List<AuthBackend> getAuthBackends() throws VaultConnectorException
VaultConnector
getAuthBackends
in interface VaultConnector
VaultConnectorException
- on errorpublic TokenResponse authToken(String token) throws VaultConnectorException
VaultConnector
authToken
in interface VaultConnector
token
- The tokenVaultConnectorException
- on errorpublic AuthResponse authUserPass(String username, String password) throws VaultConnectorException
VaultConnector
authUserPass
in interface VaultConnector
username
- The usernamepassword
- The passwordVaultConnectorException
- on errorpublic AuthResponse authAppId(String appID, String userID) throws VaultConnectorException
VaultConnector
authAppId
in interface VaultConnector
appID
- The App IDuserID
- The User IDVaultConnectorException
- on errorpublic AuthResponse authAppRole(String roleID, String secretID) throws VaultConnectorException
VaultConnector
authAppRole
in interface VaultConnector
roleID
- The role IDsecretID
- The secret IDVaultConnectorException
- on errorpublic boolean registerAppId(String appID, String policy, String displayName) throws VaultConnectorException
VaultConnector
registerAppId
in interface VaultConnector
appID
- The unique App-IDpolicy
- The policy to associate withdisplayName
- Arbitrary name to displayVaultConnectorException
- on errorpublic boolean registerUserId(String appID, String userID) throws VaultConnectorException
VaultConnector
registerUserId
in interface VaultConnector
appID
- The App-IDuserID
- The User-IDVaultConnectorException
- on errorpublic boolean createAppRole(AppRole role) throws VaultConnectorException
VaultConnector
createAppRole
in interface VaultConnector
role
- The roleVaultConnectorException
- on errorpublic AppRoleResponse lookupAppRole(String roleName) throws VaultConnectorException
VaultConnector
lookupAppRole
in interface VaultConnector
roleName
- The role nameVaultConnectorException
- on errorpublic boolean deleteAppRole(String roleName) throws VaultConnectorException
VaultConnector
deleteAppRole
in interface VaultConnector
roleName
- The role anmeVaultConnectorException
- on errorpublic String getAppRoleID(String roleName) throws VaultConnectorException
VaultConnector
getAppRoleID
in interface VaultConnector
roleName
- The role nameVaultConnectorException
- on errorpublic boolean setAppRoleID(String roleName, String roleID) throws VaultConnectorException
VaultConnector
setAppRoleID
in interface VaultConnector
roleName
- The role nameroleID
- The role IDVaultConnectorException
- on errorpublic AppRoleSecretResponse createAppRoleSecret(String roleName, AppRoleSecret secret) throws VaultConnectorException
VaultConnector
createAppRoleSecret
in interface VaultConnector
roleName
- The role namesecret
- The secret meta objectVaultConnectorException
- on errorpublic AppRoleSecretResponse lookupAppRoleSecret(String roleName, String secretID) throws VaultConnectorException
VaultConnector
lookupAppRoleSecret
in interface VaultConnector
roleName
- The role namesecretID
- The secret IDVaultConnectorException
- on errorpublic boolean destroyAppRoleSecret(String roleName, String secretID) throws VaultConnectorException
VaultConnector
destroyAppRoleSecret
in interface VaultConnector
roleName
- The role namesecretID
- The secret meta objectVaultConnectorException
- on errorpublic List<String> listAppRoles() throws VaultConnectorException
VaultConnector
listAppRoles
in interface VaultConnector
VaultConnectorException
- on errorpublic List<String> listAppRoleSecretss(String roleName) throws VaultConnectorException
VaultConnector
listAppRoleSecretss
in interface VaultConnector
roleName
- The role nameVaultConnectorException
- on errorpublic SecretResponse readSecret(String key) throws VaultConnectorException
VaultConnector
readSecret
in interface VaultConnector
key
- Secret identifierVaultConnectorException
- on errorpublic List<String> listSecrets(String path) throws VaultConnectorException
VaultConnector
listSecrets
in interface VaultConnector
path
- Root path to searchVaultConnectorException
- on errorpublic boolean writeSecret(String key, String value) throws VaultConnectorException
VaultConnector
writeSecret
in interface VaultConnector
key
- Secret pathvalue
- Secret valueVaultConnectorException
- on errorpublic boolean deleteSecret(String key) throws VaultConnectorException
VaultConnector
deleteSecret
in interface VaultConnector
key
- Secret pathVaultConnectorException
- on errorpublic boolean revoke(String leaseID) throws VaultConnectorException
VaultConnector
revoke
in interface VaultConnector
leaseID
- the lease IDVaultConnectorException
- on errorpublic SecretResponse renew(String leaseID, Integer increment) throws VaultConnectorException
VaultConnector
renew
in interface VaultConnector
leaseID
- the lase IDincrement
- number of seconds to extend lease timeVaultConnectorException
public AuthResponse createToken(Token token) throws VaultConnectorException
VaultConnector
createToken
in interface VaultConnector
token
- the tokenVaultConnectorException
- on errorpublic AuthResponse createToken(Token token, boolean orphan) throws VaultConnectorException
VaultConnector
createToken
in interface VaultConnector
token
- the tokenorphan
- create orphan tokenVaultConnectorException
- on errorpublic AuthResponse createToken(Token token, String role) throws VaultConnectorException
VaultConnector
createToken
in interface VaultConnector
token
- the tokenrole
- the role nameVaultConnectorException
- on errorpublic TokenResponse lookupToken(String token) throws VaultConnectorException
VaultConnector
lookupToken
in interface VaultConnector
token
- the tokenVaultConnectorException
- on errorCopyright © 2016. All rights reserved.