Skip to content

Commit

Permalink
model: extend AuthMethod model and embedded config (#72)
Browse files Browse the repository at this point in the history
Introduce MountConfig and UserLockoutConfig models and add some missing
fields to AuthMethod.
  • Loading branch information
stklcode committed Dec 3, 2023
1 parent 2dff893 commit 6caac86
Show file tree
Hide file tree
Showing 6 changed files with 435 additions and 13 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* Remove redundant `java.base` requirement from _module-info.java_ (#69)
* Close Java HTTP Client when running on Java 21 or later (#70)
* Add MFA requirements tu `AuthResponse` (#71)
* Extend `AuthMethod` data model (#72)

### Dependencies
* Updated Jackson to 2.16.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,26 +34,41 @@
*/
@JsonIgnoreProperties(ignoreUnknown = true)
public final class AuthMethod implements Serializable {
private static final long serialVersionUID = -2718660627880077335L;
private static final long serialVersionUID = -439987082190917691L;

private AuthBackend type;
private String rawType;

@JsonProperty("accessor")
private String accessor;

@JsonProperty("deprecation_status")
private String deprecationStatus;

@JsonProperty("description")
private String description;

@JsonProperty("config")
private Map<String, String> config;
private MountConfig config;

@JsonProperty("external_entropy_access")
private boolean externalEntropyAccess;

@JsonProperty("local")
private boolean local;

@JsonProperty("options")
private Map<String, String> options;

@JsonProperty("plugin_version")
private String pluginVersion;

@JsonProperty("running_plugin_version")
private String runningPluginVersion;

@JsonProperty("running_sha256")
private String runningSha256;

@JsonProperty("seal_wrap")
private boolean sealWrap;

Expand Down Expand Up @@ -91,6 +106,14 @@ public String getAccessor() {
return accessor;
}

/**
* @return Deprecation status
* @since 1.2
*/
public String getDeprecationStatus() {
return deprecationStatus;
}

/**
* @return Description
*/
Expand All @@ -100,8 +123,10 @@ public String getDescription() {

/**
* @return Configuration data
* @since 0.2
* @since 1.2 Returns {@link MountConfig} instead of {@link Map}
*/
public Map<String, String> getConfig() {
public MountConfig getConfig() {
return config;
}

Expand All @@ -120,6 +145,38 @@ public boolean isLocal() {
return local;
}

/**
* @return Options
* @since 1.2
*/
public Map<String, String> getOptions() {
return options;
}

/**
* @return Plugin version
* @since 1.2
*/
public String getPluginVersion() {
return pluginVersion;
}

/**
* @return Running plugin version
* @since 1.2
*/
public String getRunningPluginVersion() {
return runningPluginVersion;
}

/**
* @return Running SHA256
* @since 1.2
*/
public String getRunningSha256() {
return runningSha256;
}

/**
* @return Seal wrapping enabled
* @since 1.1
Expand Down Expand Up @@ -150,13 +207,19 @@ public boolean equals(Object o) {
sealWrap == that.sealWrap &&
Objects.equals(rawType, that.rawType) &&
Objects.equals(accessor, that.accessor) &&
Objects.equals(deprecationStatus, that.deprecationStatus) &&
Objects.equals(description, that.description) &&
Objects.equals(config, that.config) &&
Objects.equals(options, that.options) &&
Objects.equals(pluginVersion, that.pluginVersion) &&
Objects.equals(runningPluginVersion, that.runningPluginVersion) &&
Objects.equals(runningSha256, that.runningSha256) &&
Objects.equals(uuid, that.uuid);
}

@Override
public int hashCode() {
return Objects.hash(type, rawType, accessor, description, config, externalEntropyAccess, local, sealWrap, uuid);
return Objects.hash(type, rawType, accessor, deprecationStatus, description, config, externalEntropyAccess,
local, options, pluginVersion, runningPluginVersion, runningSha256, sealWrap, uuid);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
package de.stklcode.jvault.connector.model.response.embedded;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;

import java.io.Serializable;
import java.util.List;
import java.util.Objects;

/**
* Embedded mount config output.
*
* @author Stefan Kalscheuer
* @since 1.2
*/
@JsonIgnoreProperties(ignoreUnknown = true)
public class MountConfig implements Serializable {
private static final long serialVersionUID = -8653909672663717792L;

@JsonProperty("default_lease_ttl")
private Integer defaultLeaseTtl;

@JsonProperty("max_lease_ttl")
private Integer maxLeaseTtl;

@JsonProperty("force_no_cache")
private Boolean forceNoCache;

@JsonProperty("token_type")
private String tokenType;

@JsonProperty("audit_non_hmac_request_keys")
private List<String> auditNonHmacRequestKeys;

@JsonProperty("audit_non_hmac_response_keys")
private List<String> auditNonHmacResponseKeys;

@JsonProperty("listing_visibility")
private String listingVisibility;

@JsonProperty("passthrough_request_headers")
private List<String> passthroughRequestHeaders;

@JsonProperty("allowed_response_headers")
private List<String> allowedResponseHeaders;

@JsonProperty("allowed_managed_keys")
private List<String> allowedManagedKeys;

@JsonProperty("delegated_auth_accessors")
private List<String> delegatedAuthAccessors;

@JsonProperty("user_lockout_config")
private UserLockoutConfig userLockoutConfig;

/**
* @return Default lease TTL
*/
public Integer getDefaultLeaseTtl() {
return defaultLeaseTtl;
}

/**
* @return Maximum lease TTL
*/
public Integer getMaxLeaseTtl() {
return maxLeaseTtl;
}

/**
* @return Force no cache?
*/
public Boolean getForceNoCache() {
return forceNoCache;
}

/**
* @return Token type
*/
public String getTokenType() {
return tokenType;
}

/**
* @return Audit non HMAC request keys
*/
public List<String> getAuditNonHmacRequestKeys() {
return auditNonHmacRequestKeys;
}

/**
* @return Audit non HMAC response keys
*/
public List<String> getAuditNonHmacResponseKeys() {
return auditNonHmacResponseKeys;
}

/**
* @return Listing visibility
*/
public String getListingVisibility() {
return listingVisibility;
}

/**
* @return Passthrough request headers
*/
public List<String> getPassthroughRequestHeaders() {
return passthroughRequestHeaders;
}

/**
* @return Allowed response headers
*/
public List<String> getAllowedResponseHeaders() {
return allowedResponseHeaders;
}

/**
* @return Allowed managed keys
*/
public List<String> getAllowedManagedKeys() {
return allowedManagedKeys;
}

/**
* @return Delegated auth accessors
*/
public List<String> getDelegatedAuthAccessors() {
return delegatedAuthAccessors;
}

/**
* @return User lockout config
*/
public UserLockoutConfig getUserLockoutConfig() {
return userLockoutConfig;
}

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
} else if (o == null || getClass() != o.getClass()) {
return false;
}
MountConfig that = (MountConfig) o;
return Objects.equals(defaultLeaseTtl, that.defaultLeaseTtl) &&
Objects.equals(maxLeaseTtl, that.maxLeaseTtl) &&
Objects.equals(forceNoCache, that.forceNoCache) &&
Objects.equals(tokenType, that.tokenType) &&
Objects.equals(auditNonHmacRequestKeys, that.auditNonHmacRequestKeys) &&
Objects.equals(auditNonHmacResponseKeys, that.auditNonHmacResponseKeys) &&
Objects.equals(listingVisibility, that.listingVisibility) &&
Objects.equals(passthroughRequestHeaders, that.passthroughRequestHeaders) &&
Objects.equals(allowedResponseHeaders, that.allowedResponseHeaders) &&
Objects.equals(allowedManagedKeys, that.allowedManagedKeys) &&
Objects.equals(delegatedAuthAccessors, that.delegatedAuthAccessors) &&
Objects.equals(userLockoutConfig, that.userLockoutConfig);
}

@Override
public int hashCode() {
return Objects.hash(defaultLeaseTtl, maxLeaseTtl, forceNoCache, tokenType, auditNonHmacRequestKeys,
auditNonHmacResponseKeys, listingVisibility, passthroughRequestHeaders, allowedResponseHeaders,
allowedManagedKeys, delegatedAuthAccessors, userLockoutConfig);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
package de.stklcode.jvault.connector.model.response.embedded;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;

import java.io.Serializable;
import java.util.Objects;

/**
* Embedded user lockout config output.
*
* @author Stefan Kalscheuer
* @since 1.2
*/
@JsonIgnoreProperties(ignoreUnknown = true)
public class UserLockoutConfig implements Serializable {
private static final long serialVersionUID = -8051060041593140550L;

@JsonProperty("lockout_threshold")
private Integer lockoutThreshold;

@JsonProperty("lockout_duration")
private Integer lockoutDuration;

@JsonProperty("lockout_counter_reset_duration")
private Integer lockoutCounterResetDuration;

@JsonProperty("lockout_disable")
private Boolean lockoutDisable;

/**
* @return Lockout threshold
*/
public Integer getLockoutThreshold() {
return lockoutThreshold;
}

/**
* @return Lockout duration
*/
public Integer getLockoutDuration() {
return lockoutDuration;
}

/**
* @return Lockout counter reset duration
*/
public Integer getLockoutCounterResetDuration() {
return lockoutCounterResetDuration;
}

/**
* @return Lockout disabled?
*/
public Boolean getLockoutDisable() {
return lockoutDisable;
}

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
} else if (o == null || getClass() != o.getClass()) {
return false;
}
UserLockoutConfig that = (UserLockoutConfig) o;
return Objects.equals(lockoutThreshold, that.lockoutThreshold) &&
Objects.equals(lockoutDuration, that.lockoutDuration) &&
Objects.equals(lockoutCounterResetDuration, that.lockoutCounterResetDuration) &&
Objects.equals(lockoutDisable, that.lockoutDisable);
}

@Override
public int hashCode() {
return Objects.hash(lockoutThreshold, lockoutDuration, lockoutCounterResetDuration, lockoutDisable);
}
}
Loading

0 comments on commit 6caac86

Please sign in to comment.