Package io.vertx.config.vault.client
Class SlimVaultClient
- java.lang.Object
-
- io.vertx.config.vault.client.SlimVaultClient
-
public class SlimVaultClient extends Object
A very simple Vault client - does not intend to be complete.- Author:
- Clement Escoffier
-
-
Field Summary
Fields Modifier and Type Field Description static String
TOKEN_HEADER
-
Constructor Summary
Constructors Constructor Description SlimVaultClient(Vertx vertx, JsonObject configuration)
Creates an instance ofSlimVaultClient
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Closes the client.Future<Auth>
createToken(TokenRequest tokenRequest)
void
createToken(TokenRequest tokenRequest, Completable<Auth> resultHandler)
Creates a new token.Future<Void>
delete(String path)
void
delete(String path, Completable<Void> resultHandler)
Deletes a secret from `path`.String
getToken()
Future<List<String>>
list(String path)
void
list(String path, Completable<List<String>> resultHandler)
Lists secrets from path (children).Future<Auth>
loginWithAppRole(String roleId, String secretId)
void
loginWithAppRole(String roleId, String secretId, Completable<Auth> resultHandler)
Logs in against the `AppRole` backend.Future<Auth>
loginWithCert()
void
loginWithCert(Completable<Auth> resultHandler)
Logs in against the `Cert` backend.Future<Auth>
loginWithUserCredentials(String username, String password)
void
loginWithUserCredentials(String username, String password, Completable<Auth> resultHandler)
Logs in against the `userpass` backend.Future<Lookup>
lookupSelf()
void
lookupSelf(Completable<Lookup> resultHandler)
Looks up for the current token metadata.Future<Secret>
read(String path)
void
read(String path, Completable<Secret> responseHandler)
Reads a secret from `path`.Future<Auth>
renewSelf(long leaseDurationInSecond)
void
renewSelf(long leaseDurationInSecond, Completable<Auth> resultHandler)
Renews the current token.SlimVaultClient
setToken(String token)
Sets the token.Future<Secret>
write(String path, JsonObject secrets)
void
write(String path, JsonObject secrets, Completable<Secret> resultHandler)
Write a secret to `path`.
-
-
-
Field Detail
-
TOKEN_HEADER
public static final String TOKEN_HEADER
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
SlimVaultClient
public SlimVaultClient(Vertx vertx, JsonObject configuration)
Creates an instance ofSlimVaultClient
.- Parameters:
vertx
- the vert.x instanceconfiguration
- 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 pathresponseHandler
- the callback invoked with the result
-
write
public Future<Secret> write(String path, JsonObject secrets)
-
write
public void write(String path, JsonObject secrets, Completable<Secret> resultHandler)
Write a secret to `path`.- Parameters:
path
- the pathresultHandler
- the callback invoked with the result
-
list
public void list(String path, Completable<List<String>> resultHandler)
Lists secrets from path (children).- Parameters:
path
- the pathresultHandler
- the callback invoked with the result
-
delete
public void delete(String path, Completable<Void> resultHandler)
Deletes a secret from `path`.- Parameters:
path
- the pathresultHandler
- the callback invoked with the result
-
createToken
public Future<Auth> createToken(TokenRequest tokenRequest)
-
createToken
public void createToken(TokenRequest tokenRequest, Completable<Auth> resultHandler)
Creates a new token.- Parameters:
tokenRequest
- the token requestresultHandler
- 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 idsecretId
- the secret idresultHandler
- 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 usernamepassword
- the passwordresultHandler
- the callback invoked with the result
-
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 void renewSelf(long leaseDurationInSecond, Completable<Auth> resultHandler)
Renews the current token.- Parameters:
leaseDurationInSecond
- the extension in secondresultHandler
- 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.
-
setToken
public SlimVaultClient setToken(String token)
Sets the token.- Parameters:
token
- the new token- Returns:
- the current
SlimVaultClient
-
-