JavaDoc fixes
Added various JavaDoc blocks for public methods in model classes and some minor style corrections.
This commit is contained in:
parent
d7365dcaf1
commit
259747afae
@ -130,6 +130,8 @@ public class HTTPVaultConnector implements VaultConnector {
|
||||
* @param port The port
|
||||
* @param prefix HTTP API prefix (default: /v1/)
|
||||
* @param sslContext Custom SSL Context
|
||||
* @param numberOfRetries Number of retries on 5xx errors
|
||||
* @param timeout Timeout for HTTP requests (milliseconds)
|
||||
*/
|
||||
public HTTPVaultConnector(final String hostname, final boolean useTLS, final Integer port, final String prefix, final SSLContext sslContext, final int numberOfRetries, final Integer timeout) {
|
||||
this(((useTLS) ? "https" : "http") +
|
||||
@ -165,7 +167,7 @@ public class HTTPVaultConnector implements VaultConnector {
|
||||
*
|
||||
* @param baseURL The URL
|
||||
* @param sslContext Custom SSL Context
|
||||
* @param numberOfRetries number of retries on 5xx errors
|
||||
* @param numberOfRetries Number of retries on 5xx errors
|
||||
*/
|
||||
public HTTPVaultConnector(final String baseURL, final SSLContext sslContext, final int numberOfRetries) {
|
||||
this(baseURL, sslContext, numberOfRetries, null);
|
||||
@ -176,7 +178,8 @@ public class HTTPVaultConnector implements VaultConnector {
|
||||
*
|
||||
* @param baseURL The URL
|
||||
* @param sslContext Custom SSL Context
|
||||
* @param numberOfRetries number of retries on 5xx errors
|
||||
* @param numberOfRetries Number of retries on 5xx errors
|
||||
* @param timeout Timeout for HTTP requests (milliseconds)
|
||||
*/
|
||||
public HTTPVaultConnector(final String baseURL, final SSLContext sslContext, final int numberOfRetries, final Integer timeout) {
|
||||
this.baseURL = baseURL;
|
||||
@ -294,7 +297,7 @@ public class HTTPVaultConnector implements VaultConnector {
|
||||
}
|
||||
|
||||
/**
|
||||
* Query authorization request to given backend
|
||||
* Query authorization request to given backend.
|
||||
*
|
||||
* @param path The path to request
|
||||
* @param payload Payload (credentials)
|
||||
@ -537,6 +540,7 @@ public class HTTPVaultConnector implements VaultConnector {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void write(final String key, final Map<String, Object> data) throws VaultConnectorException {
|
||||
if (!isAuthorized())
|
||||
throw new AuthorizationRequiredException();
|
||||
@ -738,6 +742,7 @@ public class HTTPVaultConnector implements VaultConnector {
|
||||
* @param payload Map of payload values (will be converted to JSON)
|
||||
* @return HTTP response
|
||||
* @throws VaultConnectorException on connection error
|
||||
* @throws URISyntaxException on invalid URI syntax
|
||||
*/
|
||||
private String requestGet(final String path, final Map<String, String> payload) throws VaultConnectorException, URISyntaxException {
|
||||
/* Add parameters to URI */
|
||||
|
@ -324,7 +324,7 @@ public interface VaultConnector extends AutoCloseable {
|
||||
List<String> listAppRoleSecretss(final String roleName) throws VaultConnectorException;
|
||||
|
||||
/**
|
||||
* Register User-ID with App-ID
|
||||
* Register User-ID with App-ID.
|
||||
*
|
||||
* @param appID The App-ID
|
||||
* @param userID The User-ID
|
||||
@ -352,7 +352,7 @@ public interface VaultConnector extends AutoCloseable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get authorization status
|
||||
* Get authorization status.
|
||||
*
|
||||
* @return TRUE, if successfully authorized
|
||||
*/
|
||||
@ -543,7 +543,7 @@ public interface VaultConnector extends AutoCloseable {
|
||||
TokenResponse lookupToken(final String token) throws VaultConnectorException;
|
||||
|
||||
/**
|
||||
* Read credentials for MySQL backend at default mount point
|
||||
* Read credentials for MySQL backend at default mount point.
|
||||
*
|
||||
* @param role the role name
|
||||
* @return the credentials response
|
||||
@ -555,7 +555,7 @@ public interface VaultConnector extends AutoCloseable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Read credentials for PostgreSQL backend at default mount point
|
||||
* Read credentials for PostgreSQL backend at default mount point.
|
||||
*
|
||||
* @param role the role name
|
||||
* @return the credentials response
|
||||
@ -567,7 +567,7 @@ public interface VaultConnector extends AutoCloseable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Read credentials for MSSQL backend at default mount point
|
||||
* Read credentials for MSSQL backend at default mount point.
|
||||
*
|
||||
* @param role the role name
|
||||
* @return the credentials response
|
||||
@ -579,7 +579,7 @@ public interface VaultConnector extends AutoCloseable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Read credentials for MSSQL backend at default mount point
|
||||
* Read credentials for MSSQL backend at default mount point.
|
||||
*
|
||||
* @param role the role name
|
||||
* @return the credentials response
|
||||
|
@ -23,17 +23,36 @@ package de.stklcode.jvault.connector.exception;
|
||||
* @since 0.1
|
||||
*/
|
||||
public class ConnectionException extends VaultConnectorException {
|
||||
/**
|
||||
* Constructs a new empty exception.
|
||||
*/
|
||||
public ConnectionException() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new exception with the specified detail message.
|
||||
*
|
||||
* @param message the detail message
|
||||
*/
|
||||
public ConnectionException(final String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new exception with the specified cause.
|
||||
*
|
||||
* @param cause the cause
|
||||
*/
|
||||
public ConnectionException(final Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new exception with the specified detail message and cause.
|
||||
*
|
||||
* @param message the detail message
|
||||
* @param cause the cause
|
||||
*/
|
||||
public ConnectionException(final String message, final Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
@ -23,17 +23,36 @@ package de.stklcode.jvault.connector.exception;
|
||||
* @since 0.1
|
||||
*/
|
||||
public class InvalidRequestException extends VaultConnectorException {
|
||||
/**
|
||||
* Constructs a new empty exception.
|
||||
*/
|
||||
public InvalidRequestException() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new exception with the specified detail message.
|
||||
*
|
||||
* @param message the detail message
|
||||
*/
|
||||
public InvalidRequestException(final String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new exception with the specified cause.
|
||||
*
|
||||
* @param cause the cause
|
||||
*/
|
||||
public InvalidRequestException(final Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new exception with the specified detail message and cause.
|
||||
*
|
||||
* @param message the detail message
|
||||
* @param cause the cause
|
||||
*/
|
||||
public InvalidRequestException(final String message, final Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
@ -27,35 +27,76 @@ public final class InvalidResponseException extends VaultConnectorException {
|
||||
private Integer statusCode;
|
||||
private String response;
|
||||
|
||||
/**
|
||||
* Constructs a new empty exception.
|
||||
*/
|
||||
public InvalidResponseException() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new exception with the specified detail message.
|
||||
*
|
||||
* @param message the detail message
|
||||
*/
|
||||
public InvalidResponseException(final String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new exception with the specified cause.
|
||||
*
|
||||
* @param cause the cause
|
||||
*/
|
||||
public InvalidResponseException(final Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new exception with the specified detail message and cause.
|
||||
*
|
||||
* @param message the detail message
|
||||
* @param cause the cause
|
||||
*/
|
||||
public InvalidResponseException(final String message, final Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify the HTTP status code. Can be retrieved by {@link #getStatusCode()} later.
|
||||
*
|
||||
* @param statusCode the status code
|
||||
* @return self
|
||||
*/
|
||||
public InvalidResponseException withStatusCode(final Integer statusCode) {
|
||||
this.statusCode = statusCode;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify the response string. Can be retrieved by {@link #getResponse()} later.
|
||||
*
|
||||
* @param response response text
|
||||
* @return self
|
||||
*/
|
||||
public InvalidResponseException withResponse(final String response) {
|
||||
this.response = response;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the HTTP status code.
|
||||
*
|
||||
* @return the status code or {@code null} if none specified.
|
||||
*/
|
||||
public Integer getStatusCode() {
|
||||
return statusCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the response text.
|
||||
*
|
||||
* @return the response text or {@code null} if none specified.
|
||||
*/
|
||||
public String getResponse() {
|
||||
return response;
|
||||
}
|
||||
|
@ -23,18 +23,37 @@ package de.stklcode.jvault.connector.exception;
|
||||
* @since 0.1
|
||||
*/
|
||||
public class PermissionDeniedException extends VaultConnectorException {
|
||||
/**
|
||||
* Constructs a new empty exception.
|
||||
*/
|
||||
public PermissionDeniedException() {
|
||||
super("Permission denied");
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new exception with the specified detail message.
|
||||
*
|
||||
* @param message the detail message
|
||||
*/
|
||||
public PermissionDeniedException(final String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new exception with the specified cause.
|
||||
*
|
||||
* @param cause the cause
|
||||
*/
|
||||
public PermissionDeniedException(final Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new exception with the specified detail message and cause.
|
||||
*
|
||||
* @param message the detail message
|
||||
* @param cause the cause
|
||||
*/
|
||||
public PermissionDeniedException(final String message, final Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
@ -23,17 +23,36 @@ package de.stklcode.jvault.connector.exception;
|
||||
* @since 0.4.0
|
||||
*/
|
||||
public class TlsException extends VaultConnectorException {
|
||||
/**
|
||||
* Constructs a new empty exception.
|
||||
*/
|
||||
public TlsException() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new exception with the specified detail message.
|
||||
*
|
||||
* @param message the detail message
|
||||
*/
|
||||
public TlsException(final String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new exception with the specified cause.
|
||||
*
|
||||
* @param cause the cause
|
||||
*/
|
||||
public TlsException(final Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new exception with the specified detail message and cause.
|
||||
*
|
||||
* @param message the detail message
|
||||
* @param cause the cause
|
||||
*/
|
||||
public TlsException(final String message, final Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
@ -23,17 +23,36 @@ package de.stklcode.jvault.connector.exception;
|
||||
* @since 0.1
|
||||
*/
|
||||
public abstract class VaultConnectorException extends Exception {
|
||||
/**
|
||||
* Constructs a new empty exception.
|
||||
*/
|
||||
public VaultConnectorException() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new exception with the specified detail message.
|
||||
*
|
||||
* @param message the detail message
|
||||
*/
|
||||
public VaultConnectorException(final String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new exception with the specified cause.
|
||||
*
|
||||
* @param cause the cause
|
||||
*/
|
||||
public VaultConnectorException(final Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new exception with the specified detail message and cause.
|
||||
*
|
||||
* @param message the detail message
|
||||
* @param cause the cause
|
||||
*/
|
||||
public VaultConnectorException(final String message, final Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ public final class HTTPVaultConnectorFactory extends VaultConnectorFactory {
|
||||
}
|
||||
|
||||
/**
|
||||
* Set hostname (default: 127.0.0.1)
|
||||
* Set hostname (default: 127.0.0.1).
|
||||
*
|
||||
* @param host Hostname or IP address
|
||||
* @return self
|
||||
@ -88,7 +88,7 @@ public final class HTTPVaultConnectorFactory extends VaultConnectorFactory {
|
||||
}
|
||||
|
||||
/**
|
||||
* Set port (default: 8200)
|
||||
* Set port (default: 8200).
|
||||
*
|
||||
* @param port Vault TCP port
|
||||
* @return self
|
||||
@ -99,7 +99,7 @@ public final class HTTPVaultConnectorFactory extends VaultConnectorFactory {
|
||||
}
|
||||
|
||||
/**
|
||||
* Set TLS usage (default: TRUE)
|
||||
* Set TLS usage (default: TRUE).
|
||||
*
|
||||
* @param useTLS use TLS or not
|
||||
* @return self
|
||||
@ -110,7 +110,7 @@ public final class HTTPVaultConnectorFactory extends VaultConnectorFactory {
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience Method for TLS usage (enabled by default)
|
||||
* Convenience Method for TLS usage (enabled by default).
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
@ -119,7 +119,7 @@ public final class HTTPVaultConnectorFactory extends VaultConnectorFactory {
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience Method for NOT using TLS
|
||||
* Convenience Method for NOT using TLS.
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
@ -172,7 +172,7 @@ public final class HTTPVaultConnectorFactory extends VaultConnectorFactory {
|
||||
* @return self
|
||||
* @since 0.6.0
|
||||
*/
|
||||
public HTTPVaultConnectorFactory withToken(final String token) throws VaultConnectorException {
|
||||
public HTTPVaultConnectorFactory withToken(final String token) {
|
||||
this.token = token;
|
||||
return this;
|
||||
}
|
||||
@ -181,6 +181,7 @@ public final class HTTPVaultConnectorFactory extends VaultConnectorFactory {
|
||||
* Build connector based on the {@code }VAULT_ADDR} and {@code VAULT_CACERT} (optional) environment variables.
|
||||
*
|
||||
* @return self
|
||||
* @throws VaultConnectorException if Vault address from environment variables is malformed
|
||||
* @since 0.6.0
|
||||
*/
|
||||
public HTTPVaultConnectorFactory fromEnv() throws VaultConnectorException {
|
||||
|
@ -28,7 +28,7 @@ import de.stklcode.jvault.connector.exception.VaultConnectorException;
|
||||
*/
|
||||
public abstract class VaultConnectorFactory {
|
||||
/**
|
||||
* Get Factory implementation for HTTP Vault Connector
|
||||
* Get Factory implementation for HTTP Vault Connector.
|
||||
*
|
||||
* @return HTTP Connector Factory
|
||||
*/
|
||||
@ -47,6 +47,7 @@ public abstract class VaultConnectorFactory {
|
||||
* Build connector and authenticate with token set in factory or from environment.
|
||||
*
|
||||
* @return Authenticated Vault connector instance.
|
||||
* @throws VaultConnectorException if authentication failed
|
||||
* @since 0.6.0
|
||||
*/
|
||||
public abstract VaultConnector buildAndAuth() throws VaultConnectorException;
|
||||
|
@ -64,10 +64,27 @@ public final class AppRole {
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
private Integer period;
|
||||
|
||||
/**
|
||||
* Construct empty {@link AppRole} object.
|
||||
*/
|
||||
public AppRole() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct complete {@link AppRole} object.
|
||||
*
|
||||
* @param name Role name (required)
|
||||
* @param id Role ID (optional)
|
||||
* @param bindSecretId Bind secret ID (optional)
|
||||
* @param boundCidrList Whitelist of subnets in CIDR notation (optional)
|
||||
* @param policies List of policies (optional)
|
||||
* @param secretIdNumUses Maximum number of uses per secret (optional)
|
||||
* @param secretIdTtl Maximum TTL in seconds for secrets (optional)
|
||||
* @param tokenTtl Token TTL in seconds (optional)
|
||||
* @param tokenMaxTtl Maximum token TTL in seconds, including renewals (optional)
|
||||
* @param period Duration in seconds, if set the token is a periodic token (optional)
|
||||
*/
|
||||
public AppRole(final String name, final String id, final Boolean bindSecretId, final List<String> boundCidrList,
|
||||
final List<String> policies, final Integer secretIdNumUses, final Integer secretIdTtl,
|
||||
final Integer tokenTtl, final Integer tokenMaxTtl, final Integer period) {
|
||||
@ -83,27 +100,45 @@ public final class AppRole {
|
||||
this.period = period;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the role name
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the role ID
|
||||
*/
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bind secret ID
|
||||
*/
|
||||
public Boolean getBindSecretId() {
|
||||
return bindSecretId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list of bound CIDR subnets
|
||||
*/
|
||||
public List<String> getBoundCidrList() {
|
||||
return boundCidrList;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param boundCidrList list of subnets in CIDR notation to bind role to
|
||||
*/
|
||||
@JsonSetter("bound_cidr_list")
|
||||
public void setBoundCidrList(final List<String> boundCidrList) {
|
||||
this.boundCidrList = boundCidrList;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list of subnets in CIDR notation as comma-separated {@link String}
|
||||
*/
|
||||
@JsonGetter("bound_cidr_list")
|
||||
@JsonInclude(JsonInclude.Include.NON_EMPTY)
|
||||
public String getBoundCidrListString() {
|
||||
@ -112,15 +147,24 @@ public final class AppRole {
|
||||
return String.join(",", boundCidrList);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list of policies
|
||||
*/
|
||||
public List<String> getPolicies() {
|
||||
return policies;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param policies list of policies
|
||||
*/
|
||||
@JsonSetter("policies")
|
||||
public void setPolicies(final List<String> policies) {
|
||||
this.policies = policies;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list of policies as comma-separated {@link String}
|
||||
*/
|
||||
@JsonGetter("policies")
|
||||
@JsonInclude(JsonInclude.Include.NON_EMPTY)
|
||||
public String getPoliciesString() {
|
||||
@ -129,22 +173,37 @@ public final class AppRole {
|
||||
return String.join(",", policies);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return maximum number of uses per secret
|
||||
*/
|
||||
public Integer getSecretIdNumUses() {
|
||||
return secretIdNumUses;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return maximum TTL in seconds for secrets
|
||||
*/
|
||||
public Integer getSecretIdTtl() {
|
||||
return secretIdTtl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return token TTL in seconds
|
||||
*/
|
||||
public Integer getTokenTtl() {
|
||||
return tokenTtl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return maximum token TTL in seconds, including renewals
|
||||
*/
|
||||
public Integer getTokenMaxTtl() {
|
||||
return tokenMaxTtl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return duration in seconds, if specified
|
||||
*/
|
||||
public Integer getPeriod() {
|
||||
return period;
|
||||
}
|
||||
|
@ -37,12 +37,17 @@ public final class AppRoleBuilder {
|
||||
private Integer tokenMaxTtl;
|
||||
private Integer period;
|
||||
|
||||
/**
|
||||
* Construct {@link AppRoleBuilder} with only the role name set.
|
||||
*
|
||||
* @param name Role name
|
||||
*/
|
||||
public AppRoleBuilder(final String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add custom role ID (optional)
|
||||
* Add custom role ID. (optional)
|
||||
*
|
||||
* @param id the ID
|
||||
* @return self
|
||||
@ -53,7 +58,7 @@ public final class AppRoleBuilder {
|
||||
}
|
||||
|
||||
/**
|
||||
* Set if role is bound to secret ID
|
||||
* Set if role is bound to secret ID.
|
||||
*
|
||||
* @param bindSecretId the display name
|
||||
* @return self
|
||||
@ -108,7 +113,7 @@ public final class AppRoleBuilder {
|
||||
}
|
||||
|
||||
/**
|
||||
* Add given policies
|
||||
* Add given policies.
|
||||
*
|
||||
* @param policies the policies
|
||||
* @return self
|
||||
|
@ -58,41 +58,73 @@ public final class AppRoleSecret {
|
||||
@JsonProperty(value = "secret_id_ttl", access = JsonProperty.Access.WRITE_ONLY)
|
||||
private Integer ttl;
|
||||
|
||||
/**
|
||||
* Construct empty {@link AppRoleSecret} object.
|
||||
*/
|
||||
public AppRoleSecret() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct {@link AppRoleSecret} with secret ID.
|
||||
*
|
||||
* @param id Secret ID
|
||||
*/
|
||||
public AppRoleSecret(final String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct {@link AppRoleSecret} with ID and metadata.
|
||||
*
|
||||
* @param id Secret ID
|
||||
* @param metadata Secret metadata
|
||||
* @param cidrList List of subnets in CIDR notation, the role is bound to
|
||||
*/
|
||||
public AppRoleSecret(final String id, final Map<String, Object> metadata, final List<String> cidrList) {
|
||||
this.id = id;
|
||||
this.metadata = metadata;
|
||||
this.cidrList = cidrList;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Secret ID
|
||||
*/
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Secret accessor
|
||||
*/
|
||||
public String getAccessor() {
|
||||
return accessor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Secret metadata
|
||||
*/
|
||||
public Map<String, Object> getMetadata() {
|
||||
return metadata;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return List of bound subnets in CIDR notation
|
||||
*/
|
||||
public List<String> getCidrList() {
|
||||
return cidrList;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param cidrList List of subnets in CIDR notation
|
||||
*/
|
||||
@JsonSetter("cidr_list")
|
||||
public void setCidrList(final List<String> cidrList) {
|
||||
this.cidrList = cidrList;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return List of bound subnets in CIDR notation as comma-separated {@link String}
|
||||
*/
|
||||
@JsonGetter("cidr_list")
|
||||
public String getCidrListString() {
|
||||
if (cidrList == null || cidrList.isEmpty())
|
||||
@ -100,22 +132,37 @@ public final class AppRoleSecret {
|
||||
return String.join(",", cidrList);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Creation time
|
||||
*/
|
||||
public String getCreationTime() {
|
||||
return creationTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Expiration time
|
||||
*/
|
||||
public String getExpirationTime() {
|
||||
return expirationTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Time of last update
|
||||
*/
|
||||
public String getLastUpdatedTime() {
|
||||
return lastUpdatedTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Number of uses
|
||||
*/
|
||||
public Integer getNumUses() {
|
||||
return numUses;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Time-to-live
|
||||
*/
|
||||
public Integer getTtl() {
|
||||
return ttl;
|
||||
}
|
||||
|
@ -31,10 +31,21 @@ public enum AuthBackend {
|
||||
|
||||
private final String type;
|
||||
|
||||
/**
|
||||
* Construct {@link AuthBackend} of given type.
|
||||
*
|
||||
* @param type Backend type
|
||||
*/
|
||||
AuthBackend(final String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve {@link AuthBackend} value for given type string.
|
||||
*
|
||||
* @param type Type string
|
||||
* @return Auth backend value
|
||||
*/
|
||||
public static AuthBackend forType(final String type) {
|
||||
for (AuthBackend v : values())
|
||||
if (v.type.equalsIgnoreCase(type))
|
||||
|
@ -67,6 +67,19 @@ public final class Token {
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
private Boolean renewable;
|
||||
|
||||
/**
|
||||
* Construct complete {@link Token} object.
|
||||
*
|
||||
* @param id Token ID (optional)
|
||||
* @param displayName Token display name (optional)
|
||||
* @param noParent Token has no parent (optional)
|
||||
* @param noDefaultPolicy Do not add default policy (optional)
|
||||
* @param ttl Token TTL in seconds (optional)
|
||||
* @param numUses Number of uses (optional)
|
||||
* @param policies List of policies (optional)
|
||||
* @param meta Metadata (optional)
|
||||
* @param renewable Is the token renewable (optional)
|
||||
*/
|
||||
public Token(final String id, final String displayName, final Boolean noParent, final Boolean noDefaultPolicy,
|
||||
final Integer ttl, final Integer numUses, final List<String> policies, final Map<String, String> meta,
|
||||
final Boolean renewable) {
|
||||
@ -81,38 +94,65 @@ public final class Token {
|
||||
this.renewable = renewable;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Token ID
|
||||
*/
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Token display name
|
||||
*/
|
||||
public String getDisplayName() {
|
||||
return displayName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Token has no parent
|
||||
*/
|
||||
public Boolean getNoParent() {
|
||||
return noParent;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Token has no default policy
|
||||
*/
|
||||
public Boolean getNoDefaultPolicy() {
|
||||
return noDefaultPolicy;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Time-to-live in seconds
|
||||
*/
|
||||
public Integer getTtl() {
|
||||
return ttl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Number of uses
|
||||
*/
|
||||
public Integer getNumUses() {
|
||||
return numUses;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return List of policies
|
||||
*/
|
||||
public List<String> getPolicies() {
|
||||
return policies;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Metadata
|
||||
*/
|
||||
public Map<String, String> getMeta() {
|
||||
return meta;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Token is renewable
|
||||
*/
|
||||
public Boolean isRenewable() {
|
||||
return renewable;
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ public final class TokenBuilder {
|
||||
private Boolean renewable;
|
||||
|
||||
/**
|
||||
* Add token ID (optional)
|
||||
* Add token ID. (optional)
|
||||
*
|
||||
* @param id the ID
|
||||
* @return self
|
||||
@ -49,7 +49,7 @@ public final class TokenBuilder {
|
||||
}
|
||||
|
||||
/**
|
||||
* Add display name
|
||||
* Add display name.
|
||||
*
|
||||
* @param displayName the display name
|
||||
* @return self
|
||||
@ -61,6 +61,7 @@ public final class TokenBuilder {
|
||||
|
||||
/**
|
||||
* Set desired time to live.
|
||||
*
|
||||
* @param ttl the ttl
|
||||
* @return self
|
||||
*/
|
||||
@ -71,6 +72,7 @@ public final class TokenBuilder {
|
||||
|
||||
/**
|
||||
* Set desired number of uses.
|
||||
*
|
||||
* @param numUses the number of uses
|
||||
* @return self
|
||||
*/
|
||||
@ -80,7 +82,7 @@ public final class TokenBuilder {
|
||||
}
|
||||
|
||||
/**
|
||||
* Set TRUE if the token should be created without parent
|
||||
* Set TRUE if the token should be created without parent.
|
||||
*
|
||||
* @param noParent if TRUE, token is created as orphan
|
||||
* @return self
|
||||
@ -142,7 +144,7 @@ public final class TokenBuilder {
|
||||
}
|
||||
|
||||
/**
|
||||
* Add given policies
|
||||
* Add given policies.
|
||||
*
|
||||
* @param policies the policies
|
||||
* @return self
|
||||
@ -153,7 +155,7 @@ public final class TokenBuilder {
|
||||
}
|
||||
|
||||
/**
|
||||
* Add given policies
|
||||
* Add given policies.
|
||||
*
|
||||
* @param policies the policies
|
||||
* @return self
|
||||
|
@ -50,6 +50,9 @@ public final class AppRoleResponse extends VaultDataResponse {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The role
|
||||
*/
|
||||
public AppRole getRole() {
|
||||
return role;
|
||||
}
|
||||
|
@ -50,6 +50,9 @@ public final class AppRoleSecretResponse extends VaultDataResponse {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The secret
|
||||
*/
|
||||
public AppRoleSecret getSecret() {
|
||||
return secret;
|
||||
}
|
||||
|
@ -35,6 +35,9 @@ import java.util.Map;
|
||||
public final class AuthMethodsResponse extends VaultDataResponse {
|
||||
private Map<String, AuthMethod> supportedMethods;
|
||||
|
||||
/**
|
||||
* Construct empty {@link AuthMethodsResponse} object.
|
||||
*/
|
||||
public AuthMethodsResponse() {
|
||||
this.supportedMethods = new HashMap<>();
|
||||
}
|
||||
@ -51,6 +54,9 @@ public final class AuthMethodsResponse extends VaultDataResponse {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Supported authentication methods
|
||||
*/
|
||||
public Map<String, AuthMethod> getSupportedMethods() {
|
||||
return supportedMethods;
|
||||
}
|
||||
|
@ -37,6 +37,12 @@ public final class AuthResponse extends VaultDataResponse {
|
||||
|
||||
private AuthData auth;
|
||||
|
||||
/**
|
||||
* Set authentication data. The input will be mapped to the {@link AuthData} model.
|
||||
*
|
||||
* @param auth Raw authentication data
|
||||
* @throws InvalidResponseException on mapping errors
|
||||
*/
|
||||
@JsonProperty("auth")
|
||||
public void setAuth(final Map<String, Object> auth) throws InvalidResponseException {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
@ -53,10 +59,16 @@ public final class AuthResponse extends VaultDataResponse {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Raw data
|
||||
*/
|
||||
public Map<String, Object> getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Authentication data
|
||||
*/
|
||||
public AuthData getAuth() {
|
||||
return auth;
|
||||
}
|
||||
|
@ -32,6 +32,9 @@ public final class ErrorResponse implements VaultResponse {
|
||||
@JsonProperty("errors")
|
||||
private List<String> errors;
|
||||
|
||||
/**
|
||||
* @return List of errors
|
||||
*/
|
||||
public List<String > getErrors() {
|
||||
return errors;
|
||||
}
|
||||
|
@ -30,6 +30,9 @@ public final class HelpResponse implements VaultResponse {
|
||||
@JsonProperty("help")
|
||||
private String help;
|
||||
|
||||
/**
|
||||
* @return Help text
|
||||
*/
|
||||
public String getHelp() {
|
||||
return help;
|
||||
}
|
||||
|
@ -35,6 +35,9 @@ public final class RawDataResponse extends VaultDataResponse {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Raw data {@link Map}
|
||||
*/
|
||||
public Map<String, Object> getData() {
|
||||
return data;
|
||||
}
|
||||
|
@ -39,18 +39,30 @@ public final class SealResponse implements VaultResponse {
|
||||
@JsonProperty("progress")
|
||||
private Integer progress;
|
||||
|
||||
/**
|
||||
* @return Seal status
|
||||
*/
|
||||
public boolean isSealed() {
|
||||
return sealed;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Required threshold of secret shares
|
||||
*/
|
||||
public Integer getThreshold() {
|
||||
return threshold;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Number of secret shares
|
||||
*/
|
||||
public Integer getNumberOfShares() {
|
||||
return numberOfShares;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Current unseal progress (remaining required shares)
|
||||
*/
|
||||
public Integer getProgress() {
|
||||
return progress;
|
||||
}
|
||||
|
@ -33,16 +33,24 @@ import java.util.Map;
|
||||
public final class SecretListResponse extends VaultDataResponse {
|
||||
private List<String> keys;
|
||||
|
||||
/**
|
||||
* Set data. Extracts list of keys from raw response data.
|
||||
*
|
||||
* @param data Raw data
|
||||
* @throws InvalidResponseException on parsing errors
|
||||
*/
|
||||
@JsonProperty("data")
|
||||
public void setData(final Map<String, Object> data) throws InvalidResponseException {
|
||||
try {
|
||||
this.keys = (List<String>)data.get("keys");
|
||||
}
|
||||
catch (ClassCastException e) {
|
||||
this.keys = (List<String>) data.get("keys");
|
||||
} catch (ClassCastException e) {
|
||||
throw new InvalidResponseException("Keys could not be parsed from data.", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return List of secret keys
|
||||
*/
|
||||
public List<String> getKeys() {
|
||||
return keys;
|
||||
}
|
||||
|
@ -79,7 +79,7 @@ public class SecretResponse extends VaultDataResponse {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get response parsed as JSON
|
||||
* Get response parsed as JSON.
|
||||
*
|
||||
* @param type Class to parse response
|
||||
* @param <T> Class to parse response
|
||||
@ -94,7 +94,7 @@ public class SecretResponse extends VaultDataResponse {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get response parsed as JSON
|
||||
* Get response parsed as JSON.
|
||||
*
|
||||
* @param key the key
|
||||
* @param type Class to parse response
|
||||
|
@ -38,6 +38,12 @@ public final class TokenResponse extends VaultDataResponse {
|
||||
@JsonProperty("auth")
|
||||
private Boolean auth;
|
||||
|
||||
/**
|
||||
* Set data. Parses response data map to {@link TokenData}.
|
||||
*
|
||||
* @param data Raw response data
|
||||
* @throws InvalidResponseException on parsing errors
|
||||
*/
|
||||
@Override
|
||||
public void setData(final Map<String, Object> data) throws InvalidResponseException {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
@ -49,6 +55,9 @@ public final class TokenResponse extends VaultDataResponse {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Token data
|
||||
*/
|
||||
public TokenData getData() {
|
||||
return data;
|
||||
}
|
||||
|
@ -41,21 +41,39 @@ public abstract class VaultDataResponse implements VaultResponse {
|
||||
@JsonProperty("warnings")
|
||||
private List<String> warnings;
|
||||
|
||||
/**
|
||||
* Set data. To be implemented in the specific subclasses, as data can be of arbitrary structure.
|
||||
*
|
||||
* @param data Raw response data
|
||||
* @throws InvalidResponseException on parsing errors
|
||||
*/
|
||||
@JsonProperty("data")
|
||||
public abstract void setData(final Map<String, Object> data) throws InvalidResponseException;
|
||||
|
||||
/**
|
||||
* @return Lease ID
|
||||
*/
|
||||
public final String getLeaseId() {
|
||||
return leaseId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Lease is renewable
|
||||
*/
|
||||
public final boolean isRenewable() {
|
||||
return renewable;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Lease duration
|
||||
*/
|
||||
public final Integer getLeaseDuration() {
|
||||
return leaseDuration;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return List of warnings
|
||||
*/
|
||||
public final List<String> getWarnings() {
|
||||
return warnings;
|
||||
}
|
||||
|
@ -48,26 +48,44 @@ public final class AuthData {
|
||||
@JsonProperty("renewable")
|
||||
private boolean renewable;
|
||||
|
||||
/**
|
||||
* @return Client token
|
||||
*/
|
||||
public String getClientToken() {
|
||||
return clientToken;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Token accessor
|
||||
*/
|
||||
public String getAccessor() {
|
||||
return accessor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return List of policies
|
||||
*/
|
||||
public List<String> getPolicies() {
|
||||
return policies;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Metadata
|
||||
*/
|
||||
public Map<String, Object> getMetadata() {
|
||||
return metadata;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Lease duration
|
||||
*/
|
||||
public Integer getLeaseDuration() {
|
||||
return leaseDuration;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Lease is renewable
|
||||
*/
|
||||
public boolean isRenewable() {
|
||||
return renewable;
|
||||
}
|
||||
|
@ -43,28 +43,46 @@ public final class AuthMethod {
|
||||
@JsonProperty("local")
|
||||
private boolean local;
|
||||
|
||||
/**
|
||||
* @param type Backend type, passed to {@link AuthBackend#forType(String)}
|
||||
*/
|
||||
@JsonSetter("type")
|
||||
public void setType(final String type) {
|
||||
this.rawType = type;
|
||||
this.type = AuthBackend.forType(type);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Backend type
|
||||
*/
|
||||
public AuthBackend getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Raw backend type string
|
||||
*/
|
||||
public String getRawType() {
|
||||
return rawType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Description
|
||||
*/
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Configuration data
|
||||
*/
|
||||
public Map<String, String> getConfig() {
|
||||
return config;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Is local backend
|
||||
*/
|
||||
public boolean isLocal() {
|
||||
return local;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user