diff --git a/src/main/java/de/stklcode/jvault/connector/HTTPVaultConnector.java b/src/main/java/de/stklcode/jvault/connector/HTTPVaultConnector.java index 20ce73f..a0accbd 100644 --- a/src/main/java/de/stklcode/jvault/connector/HTTPVaultConnector.java +++ b/src/main/java/de/stklcode/jvault/connector/HTTPVaultConnector.java @@ -125,11 +125,13 @@ public class HTTPVaultConnector implements VaultConnector { /** * Create connector using hostname, schema, port, path and trusted certificate. * - * @param hostname The hostname - * @param useTLS If TRUE, use HTTPS, otherwise HTTP - * @param port The port - * @param prefix HTTP API prefix (default: /v1/) - * @param sslContext Custom SSL Context + * @param hostname The hostname + * @param useTLS If TRUE, use HTTPS, otherwise HTTP + * @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 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 payload) throws VaultConnectorException, URISyntaxException { /* Add parameters to URI */ diff --git a/src/main/java/de/stklcode/jvault/connector/VaultConnector.java b/src/main/java/de/stklcode/jvault/connector/VaultConnector.java index d18616e..1e5cf18 100644 --- a/src/main/java/de/stklcode/jvault/connector/VaultConnector.java +++ b/src/main/java/de/stklcode/jvault/connector/VaultConnector.java @@ -324,7 +324,7 @@ public interface VaultConnector extends AutoCloseable { List 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 diff --git a/src/main/java/de/stklcode/jvault/connector/exception/ConnectionException.java b/src/main/java/de/stklcode/jvault/connector/exception/ConnectionException.java index 612f1e9..6a0c9ac 100644 --- a/src/main/java/de/stklcode/jvault/connector/exception/ConnectionException.java +++ b/src/main/java/de/stklcode/jvault/connector/exception/ConnectionException.java @@ -19,21 +19,40 @@ package de.stklcode.jvault.connector.exception; /** * Exception thrown on problems with connection to Vault backend. * - * @author Stefan Kalscheuer - * @since 0.1 + * @author Stefan Kalscheuer + * @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); } diff --git a/src/main/java/de/stklcode/jvault/connector/exception/InvalidRequestException.java b/src/main/java/de/stklcode/jvault/connector/exception/InvalidRequestException.java index 6222f98..0b601ef 100644 --- a/src/main/java/de/stklcode/jvault/connector/exception/InvalidRequestException.java +++ b/src/main/java/de/stklcode/jvault/connector/exception/InvalidRequestException.java @@ -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); } diff --git a/src/main/java/de/stklcode/jvault/connector/exception/InvalidResponseException.java b/src/main/java/de/stklcode/jvault/connector/exception/InvalidResponseException.java index 803f1fb..7eec2dc 100644 --- a/src/main/java/de/stklcode/jvault/connector/exception/InvalidResponseException.java +++ b/src/main/java/de/stklcode/jvault/connector/exception/InvalidResponseException.java @@ -20,42 +20,83 @@ package de.stklcode.jvault.connector.exception; * Exception thrown when response from vault returned with erroneous status code or payload could not be parsed * to entity class. * - * @author Stefan Kalscheuer - * @since 0.1 + * @author Stefan Kalscheuer + * @since 0.1 */ 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; } diff --git a/src/main/java/de/stklcode/jvault/connector/exception/PermissionDeniedException.java b/src/main/java/de/stklcode/jvault/connector/exception/PermissionDeniedException.java index 82140d6..0a97c8f 100644 --- a/src/main/java/de/stklcode/jvault/connector/exception/PermissionDeniedException.java +++ b/src/main/java/de/stklcode/jvault/connector/exception/PermissionDeniedException.java @@ -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); } diff --git a/src/main/java/de/stklcode/jvault/connector/exception/TlsException.java b/src/main/java/de/stklcode/jvault/connector/exception/TlsException.java index 53ebefd..4b1435d 100644 --- a/src/main/java/de/stklcode/jvault/connector/exception/TlsException.java +++ b/src/main/java/de/stklcode/jvault/connector/exception/TlsException.java @@ -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); } diff --git a/src/main/java/de/stklcode/jvault/connector/exception/VaultConnectorException.java b/src/main/java/de/stklcode/jvault/connector/exception/VaultConnectorException.java index f4ca582..5b67ab3 100644 --- a/src/main/java/de/stklcode/jvault/connector/exception/VaultConnectorException.java +++ b/src/main/java/de/stklcode/jvault/connector/exception/VaultConnectorException.java @@ -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); } diff --git a/src/main/java/de/stklcode/jvault/connector/factory/HTTPVaultConnectorFactory.java b/src/main/java/de/stklcode/jvault/connector/factory/HTTPVaultConnectorFactory.java index 56e2328..46c43a7 100644 --- a/src/main/java/de/stklcode/jvault/connector/factory/HTTPVaultConnectorFactory.java +++ b/src/main/java/de/stklcode/jvault/connector/factory/HTTPVaultConnectorFactory.java @@ -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 { diff --git a/src/main/java/de/stklcode/jvault/connector/factory/VaultConnectorFactory.java b/src/main/java/de/stklcode/jvault/connector/factory/VaultConnectorFactory.java index 9d3ffd7..14a1f51 100644 --- a/src/main/java/de/stklcode/jvault/connector/factory/VaultConnectorFactory.java +++ b/src/main/java/de/stklcode/jvault/connector/factory/VaultConnectorFactory.java @@ -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; diff --git a/src/main/java/de/stklcode/jvault/connector/model/AppRole.java b/src/main/java/de/stklcode/jvault/connector/model/AppRole.java index 04b95e1..70bbcca 100644 --- a/src/main/java/de/stklcode/jvault/connector/model/AppRole.java +++ b/src/main/java/de/stklcode/jvault/connector/model/AppRole.java @@ -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 boundCidrList, final List 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 getBoundCidrList() { return boundCidrList; } + /** + * @param boundCidrList list of subnets in CIDR notation to bind role to + */ @JsonSetter("bound_cidr_list") public void setBoundCidrList(final List 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 getPolicies() { return policies; } + /** + * @param policies list of policies + */ @JsonSetter("policies") public void setPolicies(final List 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; } diff --git a/src/main/java/de/stklcode/jvault/connector/model/AppRoleBuilder.java b/src/main/java/de/stklcode/jvault/connector/model/AppRoleBuilder.java index fa71760..5d0771a 100644 --- a/src/main/java/de/stklcode/jvault/connector/model/AppRoleBuilder.java +++ b/src/main/java/de/stklcode/jvault/connector/model/AppRoleBuilder.java @@ -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 diff --git a/src/main/java/de/stklcode/jvault/connector/model/AppRoleSecret.java b/src/main/java/de/stklcode/jvault/connector/model/AppRoleSecret.java index 9eee0e2..464833f 100644 --- a/src/main/java/de/stklcode/jvault/connector/model/AppRoleSecret.java +++ b/src/main/java/de/stklcode/jvault/connector/model/AppRoleSecret.java @@ -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 metadata, final List 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 getMetadata() { return metadata; } + /** + * @return List of bound subnets in CIDR notation + */ public List getCidrList() { return cidrList; } + /** + * @param cidrList List of subnets in CIDR notation + */ @JsonSetter("cidr_list") public void setCidrList(final List 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; } diff --git a/src/main/java/de/stklcode/jvault/connector/model/AuthBackend.java b/src/main/java/de/stklcode/jvault/connector/model/AuthBackend.java index 160bdbe..afd6318 100644 --- a/src/main/java/de/stklcode/jvault/connector/model/AuthBackend.java +++ b/src/main/java/de/stklcode/jvault/connector/model/AuthBackend.java @@ -19,8 +19,8 @@ package de.stklcode.jvault.connector.model; /** * Currently supported authentication backends. * - * @author Stefan Kalscheuer - * @since 0.1 + * @author Stefan Kalscheuer + * @since 0.1 */ public enum AuthBackend { TOKEN("token"), @@ -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)) diff --git a/src/main/java/de/stklcode/jvault/connector/model/Token.java b/src/main/java/de/stklcode/jvault/connector/model/Token.java index e672ba1..075ed0e 100644 --- a/src/main/java/de/stklcode/jvault/connector/model/Token.java +++ b/src/main/java/de/stklcode/jvault/connector/model/Token.java @@ -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 policies, final Map 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 getPolicies() { return policies; } + /** + * @return Metadata + */ public Map getMeta() { return meta; } + /** + * @return Token is renewable + */ public Boolean isRenewable() { return renewable; } diff --git a/src/main/java/de/stklcode/jvault/connector/model/TokenBuilder.java b/src/main/java/de/stklcode/jvault/connector/model/TokenBuilder.java index 3ed5380..b7cfc56 100644 --- a/src/main/java/de/stklcode/jvault/connector/model/TokenBuilder.java +++ b/src/main/java/de/stklcode/jvault/connector/model/TokenBuilder.java @@ -23,7 +23,7 @@ import java.util.*; /** * A builder for vault tokens. * - * @author Stefan Kalscheuer + * @author Stefan Kalscheuer * @since 0.4.0 */ public final class TokenBuilder { @@ -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 diff --git a/src/main/java/de/stklcode/jvault/connector/model/response/AppRoleResponse.java b/src/main/java/de/stklcode/jvault/connector/model/response/AppRoleResponse.java index 899b556..6f869dc 100644 --- a/src/main/java/de/stklcode/jvault/connector/model/response/AppRoleResponse.java +++ b/src/main/java/de/stklcode/jvault/connector/model/response/AppRoleResponse.java @@ -50,6 +50,9 @@ public final class AppRoleResponse extends VaultDataResponse { } } + /** + * @return The role + */ public AppRole getRole() { return role; } diff --git a/src/main/java/de/stklcode/jvault/connector/model/response/AppRoleSecretResponse.java b/src/main/java/de/stklcode/jvault/connector/model/response/AppRoleSecretResponse.java index 24d0066..e875a42 100644 --- a/src/main/java/de/stklcode/jvault/connector/model/response/AppRoleSecretResponse.java +++ b/src/main/java/de/stklcode/jvault/connector/model/response/AppRoleSecretResponse.java @@ -50,6 +50,9 @@ public final class AppRoleSecretResponse extends VaultDataResponse { } } + /** + * @return The secret + */ public AppRoleSecret getSecret() { return secret; } diff --git a/src/main/java/de/stklcode/jvault/connector/model/response/AuthMethodsResponse.java b/src/main/java/de/stklcode/jvault/connector/model/response/AuthMethodsResponse.java index 88532d4..3d1fc5e 100644 --- a/src/main/java/de/stklcode/jvault/connector/model/response/AuthMethodsResponse.java +++ b/src/main/java/de/stklcode/jvault/connector/model/response/AuthMethodsResponse.java @@ -35,6 +35,9 @@ import java.util.Map; public final class AuthMethodsResponse extends VaultDataResponse { private Map 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 getSupportedMethods() { return supportedMethods; } diff --git a/src/main/java/de/stklcode/jvault/connector/model/response/AuthResponse.java b/src/main/java/de/stklcode/jvault/connector/model/response/AuthResponse.java index 8afcb76..9e3927d 100644 --- a/src/main/java/de/stklcode/jvault/connector/model/response/AuthResponse.java +++ b/src/main/java/de/stklcode/jvault/connector/model/response/AuthResponse.java @@ -28,8 +28,8 @@ import java.util.Map; /** * Vault response for authentication providing auth info in {@link AuthData} field. * - * @author Stefan Kalscheuer - * @since 0.1 + * @author Stefan Kalscheuer + * @since 0.1 */ @JsonIgnoreProperties(ignoreUnknown = true) public final class AuthResponse extends VaultDataResponse { @@ -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 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 getData() { return data; } + /** + * @return Authentication data + */ public AuthData getAuth() { return auth; } diff --git a/src/main/java/de/stklcode/jvault/connector/model/response/ErrorResponse.java b/src/main/java/de/stklcode/jvault/connector/model/response/ErrorResponse.java index e86a6c4..5cbdc2f 100644 --- a/src/main/java/de/stklcode/jvault/connector/model/response/ErrorResponse.java +++ b/src/main/java/de/stklcode/jvault/connector/model/response/ErrorResponse.java @@ -32,6 +32,9 @@ public final class ErrorResponse implements VaultResponse { @JsonProperty("errors") private List errors; + /** + * @return List of errors + */ public List getErrors() { return errors; } diff --git a/src/main/java/de/stklcode/jvault/connector/model/response/HelpResponse.java b/src/main/java/de/stklcode/jvault/connector/model/response/HelpResponse.java index 78c69b9..990a87f 100644 --- a/src/main/java/de/stklcode/jvault/connector/model/response/HelpResponse.java +++ b/src/main/java/de/stklcode/jvault/connector/model/response/HelpResponse.java @@ -30,6 +30,9 @@ public final class HelpResponse implements VaultResponse { @JsonProperty("help") private String help; + /** + * @return Help text + */ public String getHelp() { return help; } diff --git a/src/main/java/de/stklcode/jvault/connector/model/response/RawDataResponse.java b/src/main/java/de/stklcode/jvault/connector/model/response/RawDataResponse.java index 0aadfe0..2aff502 100644 --- a/src/main/java/de/stklcode/jvault/connector/model/response/RawDataResponse.java +++ b/src/main/java/de/stklcode/jvault/connector/model/response/RawDataResponse.java @@ -35,6 +35,9 @@ public final class RawDataResponse extends VaultDataResponse { this.data = data; } + /** + * @return Raw data {@link Map} + */ public Map getData() { return data; } diff --git a/src/main/java/de/stklcode/jvault/connector/model/response/SealResponse.java b/src/main/java/de/stklcode/jvault/connector/model/response/SealResponse.java index 8a479bc..773027a 100644 --- a/src/main/java/de/stklcode/jvault/connector/model/response/SealResponse.java +++ b/src/main/java/de/stklcode/jvault/connector/model/response/SealResponse.java @@ -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; } diff --git a/src/main/java/de/stklcode/jvault/connector/model/response/SecretListResponse.java b/src/main/java/de/stklcode/jvault/connector/model/response/SecretListResponse.java index 40c309b..ea93ad2 100644 --- a/src/main/java/de/stklcode/jvault/connector/model/response/SecretListResponse.java +++ b/src/main/java/de/stklcode/jvault/connector/model/response/SecretListResponse.java @@ -26,23 +26,31 @@ import java.util.Map; /** * Vault response for secret list request. * - * @author Stefan Kalscheuer - * @since 0.1 + * @author Stefan Kalscheuer + * @since 0.1 */ @JsonIgnoreProperties(ignoreUnknown = true) public final class SecretListResponse extends VaultDataResponse { private List 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 data) throws InvalidResponseException { try { - this.keys = (List)data.get("keys"); - } - catch (ClassCastException e) { + this.keys = (List) data.get("keys"); + } catch (ClassCastException e) { throw new InvalidResponseException("Keys could not be parsed from data.", e); } } + /** + * @return List of secret keys + */ public List getKeys() { return keys; } diff --git a/src/main/java/de/stklcode/jvault/connector/model/response/SecretResponse.java b/src/main/java/de/stklcode/jvault/connector/model/response/SecretResponse.java index c3d8ef5..003c785 100644 --- a/src/main/java/de/stklcode/jvault/connector/model/response/SecretResponse.java +++ b/src/main/java/de/stklcode/jvault/connector/model/response/SecretResponse.java @@ -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 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 diff --git a/src/main/java/de/stklcode/jvault/connector/model/response/TokenResponse.java b/src/main/java/de/stklcode/jvault/connector/model/response/TokenResponse.java index 0221082..536c5b7 100644 --- a/src/main/java/de/stklcode/jvault/connector/model/response/TokenResponse.java +++ b/src/main/java/de/stklcode/jvault/connector/model/response/TokenResponse.java @@ -28,8 +28,8 @@ import java.util.Map; /** * Vault response from token lookup providing Token information in {@link TokenData} field. * - * @author Stefan Kalscheuer - * @since 0.1 + * @author Stefan Kalscheuer + * @since 0.1 */ @JsonIgnoreProperties(ignoreUnknown = true) public final class TokenResponse extends VaultDataResponse { @@ -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 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; } diff --git a/src/main/java/de/stklcode/jvault/connector/model/response/VaultDataResponse.java b/src/main/java/de/stklcode/jvault/connector/model/response/VaultDataResponse.java index 2054e33..a84010f 100644 --- a/src/main/java/de/stklcode/jvault/connector/model/response/VaultDataResponse.java +++ b/src/main/java/de/stklcode/jvault/connector/model/response/VaultDataResponse.java @@ -25,8 +25,8 @@ import java.util.Map; /** * Abstract Vault response with default payload fields. * - * @author Stefan Kalscheuer - * @since 0.1 + * @author Stefan Kalscheuer + * @since 0.1 */ public abstract class VaultDataResponse implements VaultResponse { @JsonProperty("lease_id") @@ -41,21 +41,39 @@ public abstract class VaultDataResponse implements VaultResponse { @JsonProperty("warnings") private List 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 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 getWarnings() { return warnings; } diff --git a/src/main/java/de/stklcode/jvault/connector/model/response/embedded/AuthData.java b/src/main/java/de/stklcode/jvault/connector/model/response/embedded/AuthData.java index d3421c6..9a7bed2 100644 --- a/src/main/java/de/stklcode/jvault/connector/model/response/embedded/AuthData.java +++ b/src/main/java/de/stklcode/jvault/connector/model/response/embedded/AuthData.java @@ -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 getPolicies() { return policies; } + /** + * @return Metadata + */ public Map getMetadata() { return metadata; } + /** + * @return Lease duration + */ public Integer getLeaseDuration() { return leaseDuration; } + /** + * @return Lease is renewable + */ public boolean isRenewable() { return renewable; } diff --git a/src/main/java/de/stklcode/jvault/connector/model/response/embedded/AuthMethod.java b/src/main/java/de/stklcode/jvault/connector/model/response/embedded/AuthMethod.java index 65c6f56..c79aaa7 100644 --- a/src/main/java/de/stklcode/jvault/connector/model/response/embedded/AuthMethod.java +++ b/src/main/java/de/stklcode/jvault/connector/model/response/embedded/AuthMethod.java @@ -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 getConfig() { return config; } + /** + * @return Is local backend + */ public boolean isLocal() { return local; }