public class Auth
extends java.lang.Object
The implementing class for operations on Vault's /v1/auth/* REST endpoints.
This class is not intended to be constructed directly. Rather, it is meant to used by way of Vault
in a DSL-style builder pattern. See the Javadoc comments of each public method for usage examples.
| Constructor and Description |
|---|
Auth(VaultConfig config) |
| Modifier and Type | Method and Description |
|---|---|
AuthResponse |
loginByAppID(java.lang.String path,
java.lang.String appId,
java.lang.String userId)
Basic login operation to authenticate to an app-id backend.
|
AuthResponse |
loginByUsernamePassword(java.lang.String path,
java.lang.String password)
Basic login operation to authenticate to a Username & Password backend.
|
AuthResponse |
renewSelf()
Renews the lease associated with the calling token.
|
AuthResponse |
renewSelf(long increment)
Renews the lease associated with the calling token.
|
public Auth(VaultConfig config)
public AuthResponse loginByAppID(java.lang.String path, java.lang.String appId, java.lang.String userId) throws VaultException
Basic login operation to authenticate to an app-id backend. Example usage:
final AuthResponse response = vault.auth().loginByAppID("app-id/login", "app_id", "user_id"); final String token = response.getAuthClientToken());
path - The path on which the authentication is performed (e.g. auth/app-id/login)appId - The app-id used for authenticationuserId - The user-id used for authenticationVaultExceptionpublic AuthResponse loginByUsernamePassword(java.lang.String path, java.lang.String password) throws VaultException
Basic login operation to authenticate to a Username & Password backend. Example usage:
final AuthResponse response = vault.auth().loginByUsernamePassword("userpass/login/test", "password"); final String token = response.getAuthClientToken());
path - The path on which the authentication is performed (e.g. auth/userpass/login/username)password - The password used for authenticationVaultExceptionpublic AuthResponse renewSelf() throws VaultException
Renews the lease associated with the calling token. This version of the method tells Vault to use the default lifespan for the new lease.
VaultExceptionpublic AuthResponse renewSelf(long increment) throws VaultException
Renews the lease associated with the calling token. This version of the method accepts a parameter to explicitly declare how long the new lease period should be (in seconds). The Vault documentation suggests that this value may be ignored, however.
increment - The number of seconds requested for the new lease lifespanVaultException