update AppRole model and builder to current API
Add missing JSON fields and remove unprefixed, already deprecated fields
This commit is contained in:
@ -226,7 +226,7 @@ public interface VaultConnector extends AutoCloseable, Serializable {
|
||||
*/
|
||||
default boolean createAppRole(final String roleName, final List<String> policies, final String roleID)
|
||||
throws VaultConnectorException {
|
||||
return createAppRole(new AppRoleBuilder(roleName).withPolicies(policies).withId(roleID).build());
|
||||
return createAppRole(new AppRoleBuilder(roleName).withTokenPolicies(policies).withId(roleID).build());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -50,12 +50,8 @@ public final class AppRole {
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
private Boolean bindSecretId;
|
||||
|
||||
private List<String> boundCidrList;
|
||||
|
||||
private List<String> secretIdBoundCidrs;
|
||||
|
||||
private List<String> policies;
|
||||
|
||||
@JsonProperty("secret_id_num_uses")
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
private Integer secretIdNumUses;
|
||||
@ -64,6 +60,10 @@ public final class AppRole {
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
private Integer secretIdTtl;
|
||||
|
||||
@JsonProperty("enable_local_secret_ids")
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
private Boolean enableLocalSecretIds;
|
||||
|
||||
@JsonProperty("token_ttl")
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
private Integer tokenTtl;
|
||||
@ -72,9 +72,31 @@ public final class AppRole {
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
private Integer tokenMaxTtl;
|
||||
|
||||
@JsonProperty("period")
|
||||
private List<String> tokenPolicies;
|
||||
|
||||
@JsonProperty("token_bound_cidrs")
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
private Integer period;
|
||||
private List<String> tokenBoundCidrs;
|
||||
|
||||
@JsonProperty("token_explicit_max_ttl")
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
private Integer tokenExplicitMaxTtl;
|
||||
|
||||
@JsonProperty("token_no_default_policy")
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
private Boolean tokenNoDefaultPolicy;
|
||||
|
||||
@JsonProperty("token_num_uses")
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
private Integer tokenNumUses;
|
||||
|
||||
@JsonProperty("token_period")
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
private Integer tokenPeriod;
|
||||
|
||||
@JsonProperty("token_type")
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
private String tokenType;
|
||||
|
||||
/**
|
||||
* Construct empty {@link AppRole} object.
|
||||
@ -83,66 +105,49 @@ public final class AppRole {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct complete {@link AppRole} object.
|
||||
*
|
||||
* @param name Role name (required)
|
||||
* @param id Role ID (optional)
|
||||
* @param bindSecretId Bind secret ID (optional)
|
||||
* @param secretIdBoundCidrs 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> secretIdBoundCidrs,
|
||||
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;
|
||||
this.secretIdBoundCidrs = secretIdBoundCidrs;
|
||||
this.policies = policies;
|
||||
this.secretIdNumUses = secretIdNumUses;
|
||||
this.secretIdTtl = secretIdTtl;
|
||||
this.tokenTtl = tokenTtl;
|
||||
this.tokenMaxTtl = tokenMaxTtl;
|
||||
this.period = period;
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct complete {@link AppRole} object.
|
||||
* <p>
|
||||
* This constructor is used for transition from {@code bound_cidr_list} to {@code secret_id_bound_cidrs} only.
|
||||
*
|
||||
* @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 secretIdBoundCidrs 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)
|
||||
* @param name Role name (required)
|
||||
* @param id Role ID (optional)
|
||||
* @param bindSecretId Bind secret ID (optional)
|
||||
* @param secretIdBoundCidrs Whitelist of subnets in CIDR notation (optional)
|
||||
* @param secretIdNumUses Maximum number of uses per secret (optional)
|
||||
* @param secretIdTtl Maximum TTL in seconds for secrets (optional)
|
||||
* @param enableLocalSecretIds Enable local secret IDs (optional)
|
||||
* @param tokenTtl Token TTL in seconds (optional)
|
||||
* @param tokenMaxTtl Maximum token TTL in seconds, including renewals (optional)
|
||||
* @param tokenPolicies List of token policies (optional)
|
||||
* @param tokenBoundCidrs Whitelist of subnets in CIDR notation for associated tokens (optional)
|
||||
* @param tokenExplicitMaxTtl Explicit maximum TTL for associated tokens (optional)
|
||||
* @param tokenNoDefaultPolicy Enable or disable default policy for associated tokens (optional)
|
||||
* @param tokenNumUses Number of uses for tokens (optional)
|
||||
* @param tokenPeriod Duration in seconds, if set the token is a periodic token (optional)
|
||||
* @param tokenType Token type (optional)
|
||||
*/
|
||||
AppRole(final String name, final String id, final Boolean bindSecretId, final List<String> boundCidrList,
|
||||
final List<String> secretIdBoundCidrs, final List<String> policies, final Integer secretIdNumUses,
|
||||
final Integer secretIdTtl, final Integer tokenTtl, final Integer tokenMaxTtl, final Integer period) {
|
||||
AppRole(final String name, final String id, final Boolean bindSecretId, final List<String> secretIdBoundCidrs,
|
||||
final Integer secretIdNumUses, final Integer secretIdTtl, final Boolean enableLocalSecretIds,
|
||||
final Integer tokenTtl, final Integer tokenMaxTtl, final List<String> tokenPolicies,
|
||||
final List<String> tokenBoundCidrs, final Integer tokenExplicitMaxTtl, final Boolean tokenNoDefaultPolicy,
|
||||
final Integer tokenNumUses, final Integer tokenPeriod, final String tokenType) {
|
||||
this.name = name;
|
||||
this.id = id;
|
||||
this.bindSecretId = bindSecretId;
|
||||
this.boundCidrList = boundCidrList;
|
||||
this.secretIdBoundCidrs = secretIdBoundCidrs;
|
||||
this.policies = policies;
|
||||
this.tokenPolicies = tokenPolicies;
|
||||
this.secretIdNumUses = secretIdNumUses;
|
||||
this.secretIdTtl = secretIdTtl;
|
||||
this.enableLocalSecretIds = enableLocalSecretIds;
|
||||
this.tokenTtl = tokenTtl;
|
||||
this.tokenMaxTtl = tokenMaxTtl;
|
||||
this.period = period;
|
||||
this.tokenBoundCidrs = tokenBoundCidrs;
|
||||
this.tokenExplicitMaxTtl = tokenExplicitMaxTtl;
|
||||
this.tokenNoDefaultPolicy = tokenNoDefaultPolicy;
|
||||
this.tokenNumUses = tokenNumUses;
|
||||
this.tokenPeriod = tokenPeriod;
|
||||
this.tokenType = tokenType;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -167,41 +172,38 @@ public final class AppRole {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list of bound CIDR subnets
|
||||
* @deprecated Use {@link #getSecretIdBoundCidrs()} instead, as this parameter is deprecated in Vault.
|
||||
* @return list of bound CIDR subnets of assiciated tokens
|
||||
* @since 0.9
|
||||
*/
|
||||
@Deprecated
|
||||
public List<String> getBoundCidrList() {
|
||||
return boundCidrList;
|
||||
public List<String> getTokenBoundCidrs() {
|
||||
return tokenBoundCidrs;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param boundCidrList list of subnets in CIDR notation to bind role to
|
||||
* @deprecated Use {@link #setSecretIdBoundCidrs(List)} instead, as this parameter is deprecated in Vault.
|
||||
* @since 0.9
|
||||
*/
|
||||
@Deprecated
|
||||
@JsonSetter("bound_cidr_list")
|
||||
public void setBoundCidrList(final List<String> boundCidrList) {
|
||||
this.boundCidrList = boundCidrList;
|
||||
@JsonSetter("token_bound_cidrs")
|
||||
public void setBoundCidrs(final List<String> boundCidrList) {
|
||||
this.tokenBoundCidrs = boundCidrList;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list of subnets in CIDR notation as comma-separated {@link String}
|
||||
* @deprecated Use {@link #getSecretIdBoundCidrsString()} instead, as this parameter is deprecated in Vault.
|
||||
* @since 0.9
|
||||
*/
|
||||
@Deprecated
|
||||
@JsonGetter("bound_cidr_list")
|
||||
@JsonGetter("token_bound_cidrs")
|
||||
@JsonInclude(JsonInclude.Include.NON_EMPTY)
|
||||
public String getBoundCidrListString() {
|
||||
if (boundCidrList == null || boundCidrList.isEmpty()) {
|
||||
public String getTokenBoundCidrsString() {
|
||||
if (tokenBoundCidrs == null || tokenBoundCidrs.isEmpty()) {
|
||||
return "";
|
||||
}
|
||||
return String.join(",", boundCidrList);
|
||||
return String.join(",", tokenBoundCidrs);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list of bound CIDR subnets
|
||||
* @since 0.8 replaces {@link #getBoundCidrList()}
|
||||
* @since 0.8 replaces {@code getBoundCidrList()}
|
||||
*/
|
||||
public List<String> getSecretIdBoundCidrs() {
|
||||
return secretIdBoundCidrs;
|
||||
@ -209,7 +211,7 @@ public final class AppRole {
|
||||
|
||||
/**
|
||||
* @param secretIdBoundCidrs List of subnets in CIDR notation to bind secrets of this role to.
|
||||
* @since 0.8 replaces {@link #setBoundCidrList(List)}
|
||||
* @since 0.8 replaces {@code setBoundCidrList(List)}
|
||||
*/
|
||||
@JsonSetter("secret_id_bound_cidrs")
|
||||
public void setSecretIdBoundCidrs(final List<String> secretIdBoundCidrs) {
|
||||
@ -218,7 +220,7 @@ public final class AppRole {
|
||||
|
||||
/**
|
||||
* @return List of subnets in CIDR notation as comma-separated {@link String}
|
||||
* @since 0.8 replaces {@link #getBoundCidrListString()} ()}
|
||||
* @since 0.8 replaces {@code getBoundCidrListString()} ()}
|
||||
*/
|
||||
@JsonGetter("secret_id_bound_cidrs")
|
||||
@JsonInclude(JsonInclude.Include.NON_EMPTY)
|
||||
@ -230,30 +232,63 @@ public final class AppRole {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list of policies
|
||||
* @return list of token policies
|
||||
* @since 0.9
|
||||
*/
|
||||
public List<String> getTokenPolicies() {
|
||||
return tokenPolicies;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list of token policies
|
||||
* @deprecated Use {@link #getTokenPolicies()} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
@JsonIgnore
|
||||
public List<String> getPolicies() {
|
||||
return policies;
|
||||
return getTokenPolicies();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param tokenPolicies list of token policies
|
||||
* @since 0.9
|
||||
*/
|
||||
@JsonSetter("token_policies")
|
||||
public void setTokenPolicies(final List<String> tokenPolicies) {
|
||||
this.tokenPolicies = tokenPolicies;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param policies list of policies
|
||||
* @deprecated Use {@link #setTokenPolicies(List)} instead.
|
||||
*/
|
||||
@JsonSetter("policies")
|
||||
@Deprecated
|
||||
@JsonIgnore
|
||||
public void setPolicies(final List<String> policies) {
|
||||
this.policies = policies;
|
||||
setTokenPolicies(policies);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list of policies as comma-separated {@link String}
|
||||
* @since 0.9
|
||||
*/
|
||||
@JsonGetter("policies")
|
||||
@JsonGetter("token_policies")
|
||||
@JsonInclude(JsonInclude.Include.NON_EMPTY)
|
||||
public String getPoliciesString() {
|
||||
if (policies == null || policies.isEmpty()) {
|
||||
public String getTokenPoliciesString() {
|
||||
if (tokenPolicies == null || tokenPolicies.isEmpty()) {
|
||||
return "";
|
||||
}
|
||||
return String.join(",", policies);
|
||||
return String.join(",", tokenPolicies);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list of policies as comma-separated {@link String}
|
||||
* @deprecated Use {@link #getTokenPoliciesString()} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
@JsonIgnore
|
||||
public String getPoliciesString() {
|
||||
return getTokenPoliciesString();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -270,6 +305,14 @@ public final class AppRole {
|
||||
return secretIdTtl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Enable local secret IDs?
|
||||
* @since 0.9
|
||||
*/
|
||||
public Boolean getEnableLocalSecretIds() {
|
||||
return enableLocalSecretIds;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return token TTL in seconds
|
||||
*/
|
||||
@ -285,9 +328,52 @@ public final class AppRole {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return duration in seconds, if specified
|
||||
* @return explicit maximum token TTL in seconds, including renewals
|
||||
* @since 0.9
|
||||
*/
|
||||
public Integer getTokenExplicitMaxTtl() {
|
||||
return tokenExplicitMaxTtl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return enable default policy for token?
|
||||
* @since 0.9
|
||||
*/
|
||||
public Boolean getTokenNoDefaultPolicy() {
|
||||
return tokenNoDefaultPolicy;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return number of uses for token
|
||||
* @since 0.9
|
||||
*/
|
||||
public Integer getTokenNumUses() {
|
||||
return tokenNumUses;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return duration in seconds, if specified
|
||||
* @since 0.9
|
||||
*/
|
||||
public Integer getTokenPeriod() {
|
||||
return tokenPeriod;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return duration in seconds, if specified
|
||||
* @deprecated Use {@link #getTokenPeriod()} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
@JsonIgnore
|
||||
public Integer getPeriod() {
|
||||
return period;
|
||||
return getTokenPeriod();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return duration in seconds, if specified
|
||||
* @since 0.9
|
||||
*/
|
||||
public String getTokenType() {
|
||||
return tokenType;
|
||||
}
|
||||
}
|
||||
|
@ -29,14 +29,19 @@ public final class AppRoleBuilder {
|
||||
private String name;
|
||||
private String id;
|
||||
private Boolean bindSecretId;
|
||||
private List<String> boundCidrList;
|
||||
private List<String> secretIdBoundCidrs;
|
||||
private List<String> policies;
|
||||
private List<String> tokenPolicies;
|
||||
private Integer secretIdNumUses;
|
||||
private Integer secretIdTtl;
|
||||
private Boolean enableLocalSecretIds;
|
||||
private Integer tokenTtl;
|
||||
private Integer tokenMaxTtl;
|
||||
private Integer period;
|
||||
private List<String> tokenBoundCidrs;
|
||||
private Integer tokenExplicitMaxTtl;
|
||||
private Boolean tokenNoDefaultPolicy;
|
||||
private Integer tokenNumUses;
|
||||
private Integer tokenPeriod;
|
||||
private Token.Type tokenType;
|
||||
|
||||
/**
|
||||
* Construct {@link AppRoleBuilder} with only the role name set.
|
||||
@ -89,47 +94,48 @@ public final class AppRoleBuilder {
|
||||
return withBindSecretID(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set bound CIDR blocks.
|
||||
*
|
||||
* @param boundCidrList List of CIDR blocks which can perform login
|
||||
* @return self
|
||||
* @deprecated Use {@link #withSecretIdBoundCidrs(List)} instead, as this parameter is deprecated in Vault.
|
||||
*/
|
||||
@Deprecated
|
||||
public AppRoleBuilder withBoundCidrList(final List<String> boundCidrList) {
|
||||
this.boundCidrList = boundCidrList;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set bound CIDR blocks.
|
||||
*
|
||||
* @param secretIdBoundCidrs List of CIDR blocks which can perform login
|
||||
* @return self
|
||||
* @since 0.8 replaces {@link #withBoundCidrList(List)}
|
||||
* @since 0.8 replaces {@code withBoundCidrList(List)}
|
||||
*/
|
||||
public AppRoleBuilder withSecretIdBoundCidrs(final List<String> secretIdBoundCidrs) {
|
||||
this.secretIdBoundCidrs = secretIdBoundCidrs;
|
||||
if (this.secretIdBoundCidrs == null) {
|
||||
this.secretIdBoundCidrs = new ArrayList<>();
|
||||
}
|
||||
this.secretIdBoundCidrs.addAll(secretIdBoundCidrs);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a CIDR block to list of bound blocks.
|
||||
* Add a CIDR block to list of bound blocks for secret.
|
||||
*
|
||||
* @param cidrBlock the CIDR block
|
||||
* @param secretBoundCidr the CIDR block
|
||||
* @return self
|
||||
* @since 0.9
|
||||
*/
|
||||
public AppRoleBuilder withCidrBlock(final String cidrBlock) {
|
||||
if (boundCidrList == null) {
|
||||
boundCidrList = new ArrayList<>();
|
||||
}
|
||||
boundCidrList.add(cidrBlock);
|
||||
|
||||
public AppRoleBuilder withSecretBoundCidr(final String secretBoundCidr) {
|
||||
if (secretIdBoundCidrs == null) {
|
||||
secretIdBoundCidrs = new ArrayList<>();
|
||||
}
|
||||
secretIdBoundCidrs.add(cidrBlock);
|
||||
secretIdBoundCidrs.add(secretBoundCidr);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add given policies.
|
||||
*
|
||||
* @param tokenPolicies the token policies
|
||||
* @return self
|
||||
* @since 0.9
|
||||
*/
|
||||
public AppRoleBuilder withTokenPolicies(final List<String> tokenPolicies) {
|
||||
if (this.tokenPolicies == null) {
|
||||
this.tokenPolicies = new ArrayList<>();
|
||||
}
|
||||
this.tokenPolicies.addAll(tokenPolicies);
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -138,12 +144,25 @@ public final class AppRoleBuilder {
|
||||
*
|
||||
* @param policies the policies
|
||||
* @return self
|
||||
* @deprecated Use {@link #withTokenPolicies(List)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public AppRoleBuilder withPolicies(final List<String> policies) {
|
||||
if (this.policies == null) {
|
||||
this.policies = new ArrayList<>();
|
||||
return withTokenPolicies(policies);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a single policy.
|
||||
*
|
||||
* @param tokenPolicy the token policy
|
||||
* @return self
|
||||
* @since 0.9
|
||||
*/
|
||||
public AppRoleBuilder withTokenPolicy(final String tokenPolicy) {
|
||||
if (this.tokenPolicies == null) {
|
||||
this.tokenPolicies = new ArrayList<>();
|
||||
}
|
||||
this.policies.addAll(policies);
|
||||
tokenPolicies.add(tokenPolicy);
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -152,13 +171,11 @@ public final class AppRoleBuilder {
|
||||
*
|
||||
* @param policy the policy
|
||||
* @return self
|
||||
* @deprecated Use {@link #withTokenPolicy(String)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public AppRoleBuilder withPolicy(final String policy) {
|
||||
if (this.policies == null) {
|
||||
this.policies = new ArrayList<>();
|
||||
}
|
||||
policies.add(policy);
|
||||
return this;
|
||||
return withTokenPolicy(policy);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -183,6 +200,18 @@ public final class AppRoleBuilder {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable or disable local secret IDs.
|
||||
*
|
||||
* @param enableLocalSecretIds Enable local secret IDs?
|
||||
* @return self
|
||||
* @since 0.9
|
||||
*/
|
||||
public AppRoleBuilder withEnableLocalSecretIds(final Boolean enableLocalSecretIds) {
|
||||
this.enableLocalSecretIds = enableLocalSecretIds;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set default token TTL in seconds.
|
||||
*
|
||||
@ -205,17 +234,106 @@ public final class AppRoleBuilder {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set bound CIDR blocks for associated tokens.
|
||||
*
|
||||
* @param tokenBoundCidrs List of CIDR blocks which can perform login
|
||||
* @return self
|
||||
* @since 0.9
|
||||
*/
|
||||
public AppRoleBuilder withTokenBoundCidrs(final List<String> tokenBoundCidrs) {
|
||||
if (this.tokenBoundCidrs == null) {
|
||||
this.tokenBoundCidrs = new ArrayList<>();
|
||||
}
|
||||
this.tokenBoundCidrs.addAll(tokenBoundCidrs);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a CIDR block to list of bound blocks for token.
|
||||
*
|
||||
* @param tokenBoundCidr the CIDR block
|
||||
* @return self
|
||||
* @since 0.9
|
||||
*/
|
||||
public AppRoleBuilder withTokenBoundCidr(final String tokenBoundCidr) {
|
||||
if (tokenBoundCidrs == null) {
|
||||
tokenBoundCidrs = new ArrayList<>();
|
||||
}
|
||||
tokenBoundCidrs.add(tokenBoundCidr);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set explicit maximum token TTL in seconds.
|
||||
*
|
||||
* @param tokenExplicitMaxTtl the TTL
|
||||
* @return self
|
||||
*/
|
||||
public AppRoleBuilder withTokenExplicitMaxTtl(final Integer tokenExplicitMaxTtl) {
|
||||
this.tokenExplicitMaxTtl = tokenExplicitMaxTtl;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable or disable default policy for generated token.
|
||||
*
|
||||
* @param tokenNoDefaultPolicy Enable default policy for token?
|
||||
* @return self
|
||||
* @since 0.9
|
||||
*/
|
||||
public AppRoleBuilder withTokenNoDefaultPolicy(final Boolean tokenNoDefaultPolicy) {
|
||||
this.tokenNoDefaultPolicy = tokenNoDefaultPolicy;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set number of uses for generated tokens.
|
||||
*
|
||||
* @param tokenNumUses number of uses for tokens
|
||||
* @return self
|
||||
* @since 0.9
|
||||
*/
|
||||
public AppRoleBuilder withTokenNumUses(final Integer tokenNumUses) {
|
||||
this.tokenNumUses = tokenNumUses;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set renewal period for generated token in seconds.
|
||||
*
|
||||
* @param tokenPeriod period in seconds
|
||||
* @return self
|
||||
* @since 0.9
|
||||
*/
|
||||
public AppRoleBuilder wit0hTokenPeriod(final Integer tokenPeriod) {
|
||||
this.tokenPeriod = tokenPeriod;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set renewal period for generated token in seconds.
|
||||
*
|
||||
* @param period period in seconds
|
||||
* @return self
|
||||
* @deprecated Use {@link #wit0hTokenPeriod(Integer)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public AppRoleBuilder withPeriod(final Integer period) {
|
||||
this.period = period;
|
||||
return this;
|
||||
return wit0hTokenPeriod(period);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set type of generated token.
|
||||
*
|
||||
* @param tokenType token type
|
||||
* @return self
|
||||
* @since 0.9
|
||||
*/
|
||||
public AppRoleBuilder withTokenType(final Token.Type tokenType) {
|
||||
this.tokenType = tokenType;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the AppRole role based on given parameters.
|
||||
@ -223,16 +341,23 @@ public final class AppRoleBuilder {
|
||||
* @return the role
|
||||
*/
|
||||
public AppRole build() {
|
||||
return new AppRole(name,
|
||||
return new AppRole(
|
||||
name,
|
||||
id,
|
||||
bindSecretId,
|
||||
boundCidrList,
|
||||
secretIdBoundCidrs,
|
||||
policies,
|
||||
secretIdNumUses,
|
||||
secretIdTtl,
|
||||
enableLocalSecretIds,
|
||||
tokenTtl,
|
||||
tokenMaxTtl,
|
||||
period);
|
||||
tokenPolicies,
|
||||
tokenBoundCidrs,
|
||||
tokenExplicitMaxTtl,
|
||||
tokenNoDefaultPolicy,
|
||||
tokenNumUses,
|
||||
tokenPeriod,
|
||||
tokenType != null ? tokenType.value() : null
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user