Model classes and various method parameters declared final.
As the model classes are not designed for inheritance, they are now explicitly declared final. Same for various input parameters, as thes should be immutable in most methods.
This commit is contained in:
@@ -28,7 +28,7 @@ import java.util.List;
|
||||
* @since 0.4.0
|
||||
*/
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class AppRole {
|
||||
public final class AppRole {
|
||||
@JsonProperty("role_name")
|
||||
private String name;
|
||||
|
||||
@@ -68,7 +68,9 @@ public class AppRole {
|
||||
|
||||
}
|
||||
|
||||
public AppRole(String name, String id, Boolean bindSecretId, List<String> boundCidrList, List<String> policies, Integer secretIdNumUses, Integer secretIdTtl, Integer tokenTtl, Integer tokenMaxTtl, Integer period) {
|
||||
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) {
|
||||
this.name = name;
|
||||
this.id = id;
|
||||
this.bindSecretId = bindSecretId;
|
||||
@@ -98,7 +100,7 @@ public class AppRole {
|
||||
}
|
||||
|
||||
@JsonSetter("bound_cidr_list")
|
||||
public void setBoundCidrList(List<String> boundCidrList) {
|
||||
public void setBoundCidrList(final List<String> boundCidrList) {
|
||||
this.boundCidrList = boundCidrList;
|
||||
}
|
||||
|
||||
@@ -115,7 +117,7 @@ public class AppRole {
|
||||
}
|
||||
|
||||
@JsonSetter("policies")
|
||||
public void setPolicies(List<String> policies) {
|
||||
public void setPolicies(final List<String> policies) {
|
||||
this.policies = policies;
|
||||
}
|
||||
|
||||
|
@@ -25,7 +25,7 @@ import java.util.List;
|
||||
* @author Stefan Kalscheuer
|
||||
* @since 0.4.0
|
||||
*/
|
||||
public class AppRoleBuilder {
|
||||
public final class AppRoleBuilder {
|
||||
private String name;
|
||||
private String id;
|
||||
private Boolean bindSecretId;
|
||||
@@ -37,7 +37,7 @@ public class AppRoleBuilder {
|
||||
private Integer tokenMaxTtl;
|
||||
private Integer period;
|
||||
|
||||
public AppRoleBuilder(String name) {
|
||||
public AppRoleBuilder(final String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
@@ -29,7 +29,7 @@ import java.util.Map;
|
||||
* @since 0.4.0
|
||||
*/
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class AppRoleSecret {
|
||||
public final class AppRoleSecret {
|
||||
@JsonProperty("secret_id")
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
private String id;
|
||||
@@ -62,11 +62,11 @@ public class AppRoleSecret {
|
||||
|
||||
}
|
||||
|
||||
public AppRoleSecret(String id) {
|
||||
public AppRoleSecret(final String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public AppRoleSecret(String id, Map<String, Object> metadata, List<String> cidrList) {
|
||||
public AppRoleSecret(final String id, final Map<String, Object> metadata, final List<String> cidrList) {
|
||||
this.id = id;
|
||||
this.metadata = metadata;
|
||||
this.cidrList = cidrList;
|
||||
@@ -89,7 +89,7 @@ public class AppRoleSecret {
|
||||
}
|
||||
|
||||
@JsonSetter("cidr_list")
|
||||
public void setCidrList(List<String> cidrList) {
|
||||
public void setCidrList(final List<String> cidrList) {
|
||||
this.cidrList = cidrList;
|
||||
}
|
||||
|
||||
|
@@ -31,11 +31,11 @@ public enum AuthBackend {
|
||||
|
||||
private final String type;
|
||||
|
||||
AuthBackend(String type) {
|
||||
AuthBackend(final String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public static AuthBackend forType(String type) {
|
||||
public static AuthBackend forType(final String type) {
|
||||
for (AuthBackend v : values())
|
||||
if (v.type.equalsIgnoreCase(type))
|
||||
return v;
|
||||
|
@@ -30,7 +30,7 @@ import java.util.Map;
|
||||
* @since 0.4.0
|
||||
*/
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class Token {
|
||||
public final class Token {
|
||||
@JsonProperty("id")
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
private String id;
|
||||
@@ -67,7 +67,9 @@ public class Token {
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
private Boolean renewable;
|
||||
|
||||
public Token(String id, String displayName, Boolean noParent, Boolean noDefaultPolicy, Integer ttl, Integer numUses, List<String> policies, Map<String, String> meta, Boolean renewable) {
|
||||
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) {
|
||||
this.id = id;
|
||||
this.displayName = displayName;
|
||||
this.ttl = ttl;
|
||||
|
@@ -26,7 +26,7 @@ import java.util.*;
|
||||
* @author Stefan Kalscheuer
|
||||
* @since 0.4.0
|
||||
*/
|
||||
public class TokenBuilder {
|
||||
public final class TokenBuilder {
|
||||
private String id;
|
||||
private String displayName;
|
||||
private Boolean noParent;
|
||||
|
@@ -33,11 +33,11 @@ import java.util.stream.Collectors;
|
||||
* @since 0.4.0
|
||||
*/
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class AppRoleResponse extends VaultDataResponse {
|
||||
public final class AppRoleResponse extends VaultDataResponse {
|
||||
private AppRole role;
|
||||
|
||||
@Override
|
||||
public void setData(Map<String, Object> data) throws InvalidResponseException {
|
||||
public void setData(final Map<String, Object> data) throws InvalidResponseException {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
try {
|
||||
/* null empty strings on list objects */
|
||||
|
@@ -33,11 +33,11 @@ import java.util.Map;
|
||||
* @since 0.4.0
|
||||
*/
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class AppRoleSecretResponse extends VaultDataResponse {
|
||||
public final class AppRoleSecretResponse extends VaultDataResponse {
|
||||
private AppRoleSecret secret;
|
||||
|
||||
@Override
|
||||
public void setData(Map<String, Object> data) throws InvalidResponseException {
|
||||
public void setData(final Map<String, Object> data) throws InvalidResponseException {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
try {
|
||||
/* null empty strings on list objects */
|
||||
|
@@ -32,7 +32,7 @@ import java.util.Map;
|
||||
* @since 0.1
|
||||
*/
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class AuthMethodsResponse extends VaultDataResponse {
|
||||
public final class AuthMethodsResponse extends VaultDataResponse {
|
||||
private Map<String, AuthMethod> supportedMethods;
|
||||
|
||||
public AuthMethodsResponse() {
|
||||
@@ -40,7 +40,7 @@ public class AuthMethodsResponse extends VaultDataResponse {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setData(Map<String, Object> data) throws InvalidResponseException {
|
||||
public void setData(final Map<String, Object> data) throws InvalidResponseException {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
for (String path : data.keySet()) {
|
||||
try {
|
||||
|
@@ -32,13 +32,13 @@ import java.util.Map;
|
||||
* @since 0.1
|
||||
*/
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class AuthResponse extends VaultDataResponse {
|
||||
public final class AuthResponse extends VaultDataResponse {
|
||||
private Map<String, Object> data;
|
||||
|
||||
private AuthData auth;
|
||||
|
||||
@JsonProperty("auth")
|
||||
public void setAuth(Map<String, Object> auth) throws InvalidResponseException {
|
||||
public void setAuth(final Map<String, Object> auth) throws InvalidResponseException {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
try {
|
||||
this.auth = mapper.readValue(mapper.writeValueAsString(auth), AuthData.class);
|
||||
@@ -49,7 +49,7 @@ public class AuthResponse extends VaultDataResponse {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setData(Map<String, Object> data) {
|
||||
public void setData(final Map<String, Object> data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
|
@@ -32,7 +32,7 @@ import java.util.Map;
|
||||
* @since 0.5.0
|
||||
*/
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class CredentialsResponse extends SecretResponse {
|
||||
public final class CredentialsResponse extends SecretResponse {
|
||||
|
||||
public String getUsername() {
|
||||
if (get("username") != null)
|
||||
|
@@ -28,7 +28,7 @@ import java.util.List;
|
||||
* @since 0.1
|
||||
*/
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class ErrorResponse implements VaultResponse {
|
||||
public final class ErrorResponse implements VaultResponse {
|
||||
@JsonProperty("errors")
|
||||
private List<String> errors;
|
||||
|
||||
|
@@ -26,7 +26,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
* @since 0.1
|
||||
*/
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class HelpResponse implements VaultResponse {
|
||||
public final class HelpResponse implements VaultResponse {
|
||||
@JsonProperty("help")
|
||||
private String help;
|
||||
|
||||
|
@@ -27,11 +27,11 @@ import java.util.Map;
|
||||
* @since 0.4.0
|
||||
*/
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class RawDataResponse extends VaultDataResponse {
|
||||
public final class RawDataResponse extends VaultDataResponse {
|
||||
private Map<String, Object> data;
|
||||
|
||||
@Override
|
||||
public void setData(Map<String, Object> data) {
|
||||
public void setData(final Map<String, Object> data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
|
@@ -26,7 +26,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
* @since 0.1
|
||||
*/
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class SealResponse implements VaultResponse {
|
||||
public final class SealResponse implements VaultResponse {
|
||||
@JsonProperty("sealed")
|
||||
private boolean sealed;
|
||||
|
||||
|
@@ -30,11 +30,11 @@ import java.util.Map;
|
||||
* @since 0.1
|
||||
*/
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class SecretListResponse extends VaultDataResponse {
|
||||
public final class SecretListResponse extends VaultDataResponse {
|
||||
private List<String> keys;
|
||||
|
||||
@JsonProperty("data")
|
||||
public void setData(Map<String, Object> data) throws InvalidResponseException {
|
||||
public void setData(final Map<String, Object> data) throws InvalidResponseException {
|
||||
try {
|
||||
this.keys = (List<String>)data.get("keys");
|
||||
}
|
||||
|
@@ -35,7 +35,7 @@ public class SecretResponse extends VaultDataResponse {
|
||||
private Map<String, Object> data;
|
||||
|
||||
@Override
|
||||
public void setData(Map<String, Object> data) throws InvalidResponseException {
|
||||
public final void setData(final Map<String, Object> data) throws InvalidResponseException {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ public class SecretResponse extends VaultDataResponse {
|
||||
* @return data map
|
||||
* @since 0.4.0
|
||||
*/
|
||||
public Map<String, Object> getData() {
|
||||
public final Map<String, Object> getData() {
|
||||
if (data == null)
|
||||
return new HashMap<>();
|
||||
return data;
|
||||
@@ -58,7 +58,7 @@ public class SecretResponse extends VaultDataResponse {
|
||||
* @return the value or NULL if absent
|
||||
* @since 0.4.0
|
||||
*/
|
||||
public Object get(String key) {
|
||||
public final Object get(final String key) {
|
||||
if (data == null)
|
||||
return null;
|
||||
return getData().get(key);
|
||||
@@ -72,7 +72,7 @@ public class SecretResponse extends VaultDataResponse {
|
||||
* @deprecated Deprecated artifact, will be removed at latest at v1.0.0
|
||||
*/
|
||||
@Deprecated
|
||||
public String getValue() {
|
||||
public final String getValue() {
|
||||
if (get("value") == null)
|
||||
return null;
|
||||
return get("value").toString();
|
||||
@@ -89,7 +89,7 @@ public class SecretResponse extends VaultDataResponse {
|
||||
* @deprecated Deprecated artifact, will be removed at latest at v1.0.0
|
||||
*/
|
||||
@Deprecated
|
||||
public <T> T getValue(Class<T> type) throws InvalidResponseException {
|
||||
public final <T> T getValue(final Class<T> type) throws InvalidResponseException {
|
||||
return get("value", type);
|
||||
}
|
||||
|
||||
@@ -103,11 +103,11 @@ public class SecretResponse extends VaultDataResponse {
|
||||
* @throws InvalidResponseException on parsing error
|
||||
* @since 0.4.0
|
||||
*/
|
||||
public <T> T get(String key, Class<T> type) throws InvalidResponseException {
|
||||
public final <T> T get(final String key, final Class<T> type) throws InvalidResponseException {
|
||||
try {
|
||||
return new ObjectMapper().readValue(get(key).toString(), type);
|
||||
} catch (IOException e) {
|
||||
throw new InvalidResponseException("Unable to parse response payload: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -32,14 +32,14 @@ import java.util.Map;
|
||||
* @since 0.1
|
||||
*/
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class TokenResponse extends VaultDataResponse {
|
||||
public final class TokenResponse extends VaultDataResponse {
|
||||
private TokenData data;
|
||||
|
||||
@JsonProperty("auth")
|
||||
private Boolean auth;
|
||||
|
||||
@Override
|
||||
public void setData(Map<String, Object> data) throws InvalidResponseException {
|
||||
public void setData(final Map<String, Object> data) throws InvalidResponseException {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
try {
|
||||
this.data = mapper.readValue(mapper.writeValueAsString(data), TokenData.class);
|
||||
|
@@ -42,21 +42,21 @@ public abstract class VaultDataResponse implements VaultResponse {
|
||||
private List<String> warnings;
|
||||
|
||||
@JsonProperty("data")
|
||||
public abstract void setData(Map<String, Object> data) throws InvalidResponseException;
|
||||
public abstract void setData(final Map<String, Object> data) throws InvalidResponseException;
|
||||
|
||||
public String getLeaseId() {
|
||||
public final String getLeaseId() {
|
||||
return leaseId;
|
||||
}
|
||||
|
||||
public boolean isRenewable() {
|
||||
public final boolean isRenewable() {
|
||||
return renewable;
|
||||
}
|
||||
|
||||
public Integer getLeaseDuration() {
|
||||
public final Integer getLeaseDuration() {
|
||||
return leaseDuration;
|
||||
}
|
||||
|
||||
public List<String> getWarnings() {
|
||||
public final List<String> getWarnings() {
|
||||
return warnings;
|
||||
}
|
||||
}
|
||||
|
@@ -29,7 +29,7 @@ import java.util.Map;
|
||||
* @since 0.1
|
||||
*/
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class AuthData {
|
||||
public final class AuthData {
|
||||
@JsonProperty("client_token")
|
||||
private String clientToken;
|
||||
|
||||
|
@@ -30,7 +30,7 @@ import java.util.Map;
|
||||
* @since 0.1
|
||||
*/
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class AuthMethod {
|
||||
public final class AuthMethod {
|
||||
private AuthBackend type;
|
||||
private String rawType;
|
||||
|
||||
@@ -44,7 +44,7 @@ public class AuthMethod {
|
||||
private boolean local;
|
||||
|
||||
@JsonSetter("type")
|
||||
public void setType(String type) {
|
||||
public void setType(final String type) {
|
||||
this.rawType = type;
|
||||
this.type = AuthBackend.forType(type);
|
||||
}
|
||||
|
@@ -26,7 +26,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
* @since 0.1
|
||||
*/
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class TokenData {
|
||||
public final class TokenData {
|
||||
@JsonProperty("accessor")
|
||||
private String accessor;
|
||||
|
||||
|
Reference in New Issue
Block a user