Class SlimVaultClient


  • public class SlimVaultClient
    extends Object
    A very simple Vault client - does not intend to be complete.
    Author:
    Clement Escoffier
    • Constructor Detail

      • SlimVaultClient

        public SlimVaultClient​(Vertx vertx,
                               JsonObject configuration)
        Creates an instance of SlimVaultClient.
        Parameters:
        vertx - the vert.x instance
        configuration - the configuration. This configuration can contain the underlying Web Client configuration.
    • Method Detail

      • close

        public void close()
        Closes the client.
      • read

        public void read​(String path,
                         Completable<Secret> responseHandler)
        Reads a secret from `path`.
        Parameters:
        path - the path
        responseHandler - the callback invoked with the result
      • write

        public void write​(String path,
                          JsonObject secrets,
                          Completable<Secret> resultHandler)
        Write a secret to `path`.
        Parameters:
        path - the path
        resultHandler - the callback invoked with the result
      • list

        public void list​(String path,
                         Completable<List<String>> resultHandler)
        Lists secrets from path (children).
        Parameters:
        path - the path
        resultHandler - the callback invoked with the result
      • delete

        public void delete​(String path,
                           Completable<Void> resultHandler)
        Deletes a secret from `path`.
        Parameters:
        path - the path
        resultHandler - the callback invoked with the result
      • createToken

        public void createToken​(TokenRequest tokenRequest,
                                Completable<Auth> resultHandler)
        Creates a new token.
        Parameters:
        tokenRequest - the token request
        resultHandler - the callback invoked with the result.
      • loginWithAppRole

        public void loginWithAppRole​(String roleId,
                                     String secretId,
                                     Completable<Auth> resultHandler)
        Logs in against the `AppRole` backend.
        Parameters:
        roleId - the role id
        secretId - the secret id
        resultHandler - the callback invoked with the result
      • loginWithUserCredentials

        public Future<Auth> loginWithUserCredentials​(String username,
                                                     String password)
      • loginWithUserCredentials

        public void loginWithUserCredentials​(String username,
                                             String password,
                                             Completable<Auth> resultHandler)
        Logs in against the `userpass` backend.
        Parameters:
        username - the username
        password - the password
        resultHandler - the callback invoked with the result
      • loginWithCert

        public Future<Auth> loginWithCert()
      • loginWithCert

        public void loginWithCert​(Completable<Auth> resultHandler)
        Logs in against the `Cert` backend. Certificates are configured directly on the client instance.
        Parameters:
        resultHandler - the callback invoked with the result
      • renewSelf

        public Future<Auth> renewSelf​(long leaseDurationInSecond)
      • renewSelf

        public void renewSelf​(long leaseDurationInSecond,
                              Completable<Auth> resultHandler)
        Renews the current token.
        Parameters:
        leaseDurationInSecond - the extension in second
        resultHandler - the callback invoked with the result
      • lookupSelf

        public void lookupSelf​(Completable<Lookup> resultHandler)
        Looks up for the current token metadata.
        Parameters:
        resultHandler - the callback invoked with the result
      • getToken

        public String getToken()
        Returns:
        the current token.