Package codes.grow.packages.vault
Class Auth
java.lang.Object
codes.grow.packages.vault.Auth
Logins, token self-service and token renewal:
client.auth().
AuthInfo info = client.auth().login(new AppRoleAuth(roleId, secretId));
TokenInfo self = client.auth().lookupSelf();
-
Method Summary
Modifier and TypeMethodDescriptionintReturns the number of active renewers.createToken(CreateTokenOptions options) Creates a child (or orphan) token:POST auth/token/create[/<role>].AsynchronouscreateToken(CreateTokenOptions).login(AuthMethod method) Logs in with an auth method and uses the new token for this client.login(AuthMethod method, LoginOptions options) Logs in with options (keep the current token, automatic renewal).loginAsync(AuthMethod method) Asynchronouslogin(AuthMethod).loginAsync(AuthMethod method, LoginOptions options) Asynchronouslogin(AuthMethod, LoginOptions).Properties of the client token:GET auth/token/lookup-self.AsynchronouslookupSelf().Renews the client token with the server default increment.Renews the client token:POST auth/token/renew-self.renewSelfAsync(Duration increment) AsynchronousrenewSelf(Duration).voidRevokes the client token (POST auth/token/revoke-self), stops the renewers and forgets the token.AsynchronousrevokeSelf().startRenewer(RenewalOptions options) Starts aTokenRenewerfor the current client token (reads its TTL withlookupSelf()).startRenewerAsync(RenewalOptions options) AsynchronousstartRenewer(RenewalOptions).voidStops every renewer started through this API.
-
Method Details
-
login
Logs in with an auth method and uses the new token for this client. Failed logins raiseAuthenticationException.- Parameters:
method- auth method- Returns:
- the auth info
-
login
Logs in with options (keep the current token, automatic renewal).- Parameters:
method- auth methodoptions- login options- Returns:
- the auth info
-
loginAsync
Asynchronouslogin(AuthMethod).- Parameters:
method- auth method- Returns:
- a future with the auth info
-
loginAsync
Asynchronouslogin(AuthMethod, LoginOptions).- Parameters:
method- auth methodoptions- login options- Returns:
- a future with the auth info
-
lookupSelf
Properties of the client token:GET auth/token/lookup-self.- Returns:
- the token info
-
lookupSelfAsync
AsynchronouslookupSelf().- Returns:
- a future with the token info
-
renewSelf
Renews the client token with the server default increment.- Returns:
- the new auth info (
leaseDuration= granted TTL)
-
renewSelf
Renews the client token:POST auth/token/renew-self. The granted TTL may be capped by the maximum TTL. Non-renewable tokens raiseValidationException.- Parameters:
increment- requested TTL, may be null- Returns:
- the new auth info
-
renewSelfAsync
AsynchronousrenewSelf(Duration).- Parameters:
increment- requested TTL, may be null- Returns:
- a future with the new auth info
-
revokeSelf
public void revokeSelf()Revokes the client token (POST auth/token/revoke-self), stops the renewers and forgets the token. -
revokeSelfAsync
AsynchronousrevokeSelf().- Returns:
- a future completed when the token is revoked
-
createToken
Creates a child (or orphan) token:POST auth/token/create[/<role>].- Parameters:
options- token options- Returns:
- the auth info of the new token (the client keeps its own token)
-
createTokenAsync
AsynchronouscreateToken(CreateTokenOptions).- Parameters:
o- token options- Returns:
- a future with the auth info
-
startRenewer
Starts aTokenRenewerfor the current client token (reads its TTL withlookupSelf()). Stopped byclient.close().- Parameters:
options- renewal options- Returns:
- the running renewer
-
startRenewerAsync
AsynchronousstartRenewer(RenewalOptions).- Parameters:
options- renewal options- Returns:
- a future with the running renewer
-
activeRenewers
public int activeRenewers()Returns the number of active renewers.- Returns:
- the count
-
stopRenewers
public void stopRenewers()Stops every renewer started through this API. Idempotent.
-