Class Auth

java.lang.Object
codes.grow.packages.vault.Auth

public final class Auth extends Object
Logins, token self-service and token renewal: client.auth().

 AuthInfo info = client.auth().login(new AppRoleAuth(roleId, secretId));
 TokenInfo self = client.auth().lookupSelf();
 
  • Method Details

    • login

      public AuthInfo login(AuthMethod method)
      Logs in with an auth method and uses the new token for this client. Failed logins raise AuthenticationException.
      Parameters:
      method - auth method
      Returns:
      the auth info
    • login

      public AuthInfo login(AuthMethod method, LoginOptions options)
      Logs in with options (keep the current token, automatic renewal).
      Parameters:
      method - auth method
      options - login options
      Returns:
      the auth info
    • loginAsync

      public CompletableFuture<AuthInfo> loginAsync(AuthMethod method)
      Asynchronous login(AuthMethod).
      Parameters:
      method - auth method
      Returns:
      a future with the auth info
    • loginAsync

      public CompletableFuture<AuthInfo> loginAsync(AuthMethod method, LoginOptions options)
      Parameters:
      method - auth method
      options - login options
      Returns:
      a future with the auth info
    • lookupSelf

      public TokenInfo lookupSelf()
      Properties of the client token: GET auth/token/lookup-self.
      Returns:
      the token info
    • lookupSelfAsync

      public CompletableFuture<TokenInfo> lookupSelfAsync()
      Asynchronous lookupSelf().
      Returns:
      a future with the token info
    • renewSelf

      public AuthInfo renewSelf()
      Renews the client token with the server default increment.
      Returns:
      the new auth info (leaseDuration = granted TTL)
    • renewSelf

      public AuthInfo renewSelf(Duration increment)
      Renews the client token: POST auth/token/renew-self. The granted TTL may be capped by the maximum TTL. Non-renewable tokens raise ValidationException.
      Parameters:
      increment - requested TTL, may be null
      Returns:
      the new auth info
    • renewSelfAsync

      public CompletableFuture<AuthInfo> renewSelfAsync(Duration increment)
      Asynchronous renewSelf(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

      public CompletableFuture<Void> revokeSelfAsync()
      Asynchronous revokeSelf().
      Returns:
      a future completed when the token is revoked
    • createToken

      public AuthInfo createToken(CreateTokenOptions options)
      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

      public CompletableFuture<AuthInfo> createTokenAsync(CreateTokenOptions o)
      Parameters:
      o - token options
      Returns:
      a future with the auth info
    • startRenewer

      public TokenRenewer startRenewer(RenewalOptions options)
      Starts a TokenRenewer for the current client token (reads its TTL with lookupSelf()). Stopped by client.close().
      Parameters:
      options - renewal options
      Returns:
      the running renewer
    • startRenewerAsync

      public CompletableFuture<TokenRenewer> startRenewerAsync(RenewalOptions options)
      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.