JavaDoc fixes

Added various JavaDoc blocks for public methods in model classes and some minor style corrections.
This commit is contained in:
2017-08-02 17:05:24 +02:00
parent d7365dcaf1
commit 259747afae
30 changed files with 473 additions and 50 deletions

View File

@@ -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;
}

View File

@@ -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

View File

@@ -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;
}

View File

@@ -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))

View File

@@ -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;
}

View File

@@ -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

View File

@@ -50,6 +50,9 @@ public final class AppRoleResponse extends VaultDataResponse {
}
}
/**
* @return The role
*/
public AppRole getRole() {
return role;
}

View File

@@ -50,6 +50,9 @@ public final class AppRoleSecretResponse extends VaultDataResponse {
}
}
/**
* @return The secret
*/
public AppRoleSecret getSecret() {
return secret;
}

View File

@@ -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;
}

View File

@@ -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<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;
}

View File

@@ -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;
}

View File

@@ -30,6 +30,9 @@ public final class HelpResponse implements VaultResponse {
@JsonProperty("help")
private String help;
/**
* @return Help text
*/
public String getHelp() {
return help;
}

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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<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;
}

View File

@@ -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

View File

@@ -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<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;
}

View File

@@ -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<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;
}

View File

@@ -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;
}

View File

@@ -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;
}