Remove Lombok usage.
Closes gh-444.
This commit is contained in:
@@ -153,13 +153,6 @@
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.6</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.amazonaws</groupId>
|
||||
<artifactId>aws-java-sdk-core</artifactId>
|
||||
|
||||
@@ -15,10 +15,6 @@
|
||||
*/
|
||||
package org.springframework.vault.authentication;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
import org.springframework.vault.authentication.AppRoleAuthenticationOptions.RoleId;
|
||||
import org.springframework.vault.authentication.AppRoleAuthenticationOptions.SecretId;
|
||||
import org.springframework.vault.support.VaultToken;
|
||||
@@ -41,30 +37,48 @@ class AppRoleTokens {
|
||||
/**
|
||||
* Wrapped roleId/secretId via Cubbyhole.
|
||||
*/
|
||||
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
|
||||
@Getter
|
||||
static class Wrapped implements RoleId, SecretId {
|
||||
|
||||
final VaultToken initialToken;
|
||||
|
||||
Wrapped(VaultToken initialToken) {
|
||||
this.initialToken = initialToken;
|
||||
}
|
||||
|
||||
public VaultToken getInitialToken() {
|
||||
return this.initialToken;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Pull-mode.
|
||||
*/
|
||||
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
|
||||
@Getter
|
||||
static class Pull implements RoleId, SecretId {
|
||||
|
||||
final VaultToken initialToken;
|
||||
|
||||
Pull(VaultToken initialToken) {
|
||||
this.initialToken = initialToken;
|
||||
}
|
||||
|
||||
public VaultToken getInitialToken() {
|
||||
return this.initialToken;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Static, provided roleId/secretId.
|
||||
*/
|
||||
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
|
||||
@Getter
|
||||
static class Provided implements RoleId, SecretId {
|
||||
|
||||
final String value;
|
||||
|
||||
Provided(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return this.value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,15 +24,6 @@ import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.ToString;
|
||||
import lombok.Value;
|
||||
import lombok.experimental.FieldDefaults;
|
||||
|
||||
import org.springframework.http.HttpEntity;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
@@ -422,25 +413,23 @@ public class AuthenticationSteps {
|
||||
*
|
||||
* @param <T> authentication state object type produced by this request.
|
||||
*/
|
||||
@FieldDefaults(makeFinal = true, level = AccessLevel.PACKAGE)
|
||||
@Getter(AccessLevel.PACKAGE)
|
||||
public static class HttpRequest<T> {
|
||||
|
||||
HttpMethod method;
|
||||
final HttpMethod method;
|
||||
|
||||
@Nullable
|
||||
URI uri;
|
||||
final URI uri;
|
||||
|
||||
@Nullable
|
||||
String uriTemplate;
|
||||
final String uriTemplate;
|
||||
|
||||
@Nullable
|
||||
String[] urlVariables;
|
||||
final String[] urlVariables;
|
||||
|
||||
@Nullable
|
||||
HttpEntity<?> entity;
|
||||
final HttpEntity<?> entity;
|
||||
|
||||
Class<T> responseType;
|
||||
final Class<T> responseType;
|
||||
|
||||
HttpRequest(HttpRequestBuilder builder, Class<T> responseType) {
|
||||
this.method = builder.method;
|
||||
@@ -456,35 +445,86 @@ public class AuthenticationSteps {
|
||||
return String.format("%s %s AS %s", getMethod(), getUri() != null ? getUri()
|
||||
: getUriTemplate(), getResponseType());
|
||||
}
|
||||
|
||||
HttpMethod getMethod() {
|
||||
return this.method;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
URI getUri() {
|
||||
return this.uri;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
String getUriTemplate() {
|
||||
return this.uriTemplate;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
String[] getUrlVariables() {
|
||||
return this.urlVariables;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
HttpEntity<?> getEntity() {
|
||||
return this.entity;
|
||||
}
|
||||
|
||||
Class<T> getResponseType() {
|
||||
return this.responseType;
|
||||
}
|
||||
}
|
||||
|
||||
@Value
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
|
||||
static class HttpRequestNode<T> extends Node<T> implements PathAware {
|
||||
static final class HttpRequestNode<T> extends Node<T> implements PathAware {
|
||||
|
||||
@NonNull
|
||||
HttpRequest<T> definition;
|
||||
private final HttpRequest<T> definition;
|
||||
|
||||
@NonNull
|
||||
Node<?> previous;
|
||||
private final Node<?> previous;
|
||||
|
||||
HttpRequestNode(HttpRequest<T> definition, Node<?> previous) {
|
||||
this.definition = definition;
|
||||
this.previous = previous;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return definition.toString();
|
||||
}
|
||||
|
||||
public HttpRequest<T> getDefinition() {
|
||||
return this.definition;
|
||||
}
|
||||
|
||||
public Node<?> getPrevious() {
|
||||
return this.previous;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o)
|
||||
return true;
|
||||
if (!(o instanceof HttpRequestNode))
|
||||
return false;
|
||||
HttpRequestNode<?> that = (HttpRequestNode<?>) o;
|
||||
return definition.equals(that.definition) && previous.equals(that.previous);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(definition, previous);
|
||||
}
|
||||
}
|
||||
|
||||
@Value
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
|
||||
static class MapStep<I, O> extends Node<O> implements PathAware {
|
||||
static final class MapStep<I, O> extends Node<O> implements PathAware {
|
||||
|
||||
@NonNull
|
||||
Function<? super I, ? extends O> mapper;
|
||||
private final Function<? super I, ? extends O> mapper;
|
||||
|
||||
@NonNull
|
||||
Node<?> previous;
|
||||
private final Node<?> previous;
|
||||
|
||||
MapStep(Function<? super I, ? extends O> mapper, Node<?> previous) {
|
||||
this.mapper = mapper;
|
||||
this.previous = previous;
|
||||
}
|
||||
|
||||
O apply(I in) {
|
||||
return mapper.apply(in);
|
||||
@@ -494,17 +534,36 @@ public class AuthenticationSteps {
|
||||
public String toString() {
|
||||
return "Map: " + mapper.toString();
|
||||
}
|
||||
|
||||
public Function<? super I, ? extends O> getMapper() {
|
||||
return this.mapper;
|
||||
}
|
||||
|
||||
public Node<?> getPrevious() {
|
||||
return this.previous;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o)
|
||||
return true;
|
||||
if (!(o instanceof MapStep))
|
||||
return false;
|
||||
MapStep<?, ?> mapStep = (MapStep<?, ?>) o;
|
||||
return mapper.equals(mapStep.mapper) && previous.equals(mapStep.previous);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(mapper, previous);
|
||||
}
|
||||
}
|
||||
|
||||
@Value
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
static class ZipStep<L, R> extends Node<Pair<L, R>> implements PathAware {
|
||||
static final class ZipStep<L, R> extends Node<Pair<L, R>> implements PathAware {
|
||||
|
||||
@NonNull
|
||||
Node<?> left;
|
||||
private final Node<?> left;
|
||||
|
||||
@NonNull
|
||||
List<Node<?>> right;
|
||||
private final List<Node<?>> right;
|
||||
|
||||
ZipStep(Node<?> left, PathAware right) {
|
||||
this.left = left;
|
||||
@@ -520,18 +579,41 @@ public class AuthenticationSteps {
|
||||
public String toString() {
|
||||
return "Zip";
|
||||
}
|
||||
|
||||
public AuthenticationSteps.Node<?> getLeft() {
|
||||
return this.left;
|
||||
}
|
||||
|
||||
public List<Node<?>> getRight() {
|
||||
return this.right;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o)
|
||||
return true;
|
||||
if (!(o instanceof ZipStep))
|
||||
return false;
|
||||
ZipStep<?, ?> zipStep = (ZipStep<?, ?>) o;
|
||||
return left.equals(zipStep.left) && right.equals(zipStep.right);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(left, right);
|
||||
}
|
||||
}
|
||||
|
||||
@Value
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
|
||||
static class OnNextStep<T> extends Node<T> implements PathAware {
|
||||
static final class OnNextStep<T> extends Node<T> implements PathAware {
|
||||
|
||||
@NonNull
|
||||
Consumer<? super T> consumer;
|
||||
private final Consumer<? super T> consumer;
|
||||
|
||||
@NonNull
|
||||
Node<?> previous;
|
||||
private final Node<?> previous;
|
||||
|
||||
OnNextStep(Consumer<? super T> consumer, Node<?> previous) {
|
||||
this.consumer = consumer;
|
||||
this.previous = previous;
|
||||
}
|
||||
|
||||
T apply(T in) {
|
||||
consumer.accept(in);
|
||||
@@ -542,18 +624,41 @@ public class AuthenticationSteps {
|
||||
public String toString() {
|
||||
return "Consumer: " + consumer.toString();
|
||||
}
|
||||
|
||||
public Consumer<? super T> getConsumer() {
|
||||
return this.consumer;
|
||||
}
|
||||
|
||||
public AuthenticationSteps.Node<?> getPrevious() {
|
||||
return this.previous;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o)
|
||||
return true;
|
||||
if (!(o instanceof OnNextStep))
|
||||
return false;
|
||||
OnNextStep<?> that = (OnNextStep<?>) o;
|
||||
return consumer.equals(that.consumer) && previous.equals(that.previous);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(consumer, previous);
|
||||
}
|
||||
}
|
||||
|
||||
@Value
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
|
||||
static class SupplierStep<T> extends Node<T> implements PathAware {
|
||||
static final class SupplierStep<T> extends Node<T> implements PathAware {
|
||||
|
||||
@NonNull
|
||||
Supplier<T> supplier;
|
||||
private final Supplier<T> supplier;
|
||||
|
||||
@NonNull
|
||||
Node<?> previous;
|
||||
private final Node<?> previous;
|
||||
|
||||
SupplierStep(Supplier<T> supplier, Node<?> previous) {
|
||||
this.supplier = supplier;
|
||||
this.previous = previous;
|
||||
}
|
||||
|
||||
public T get() {
|
||||
return supplier.get();
|
||||
@@ -563,6 +668,29 @@ public class AuthenticationSteps {
|
||||
public String toString() {
|
||||
return "Supplier: " + supplier.toString();
|
||||
}
|
||||
|
||||
public Supplier<T> getSupplier() {
|
||||
return this.supplier;
|
||||
}
|
||||
|
||||
public Node<?> getPrevious() {
|
||||
return this.previous;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o)
|
||||
return true;
|
||||
if (!(o instanceof SupplierStep))
|
||||
return false;
|
||||
SupplierStep<?> that = (SupplierStep<?>) o;
|
||||
return supplier.equals(that.supplier) && previous.equals(that.previous);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(supplier, previous);
|
||||
}
|
||||
}
|
||||
|
||||
interface PathAware {
|
||||
@@ -576,8 +704,6 @@ public class AuthenticationSteps {
|
||||
* @param <R>
|
||||
* @since 2.1
|
||||
*/
|
||||
@EqualsAndHashCode
|
||||
@ToString
|
||||
public static class Pair<L, R> {
|
||||
|
||||
private final L left;
|
||||
@@ -617,5 +743,30 @@ public class AuthenticationSteps {
|
||||
public R getRight() {
|
||||
return right;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o)
|
||||
return true;
|
||||
if (!(o instanceof Pair))
|
||||
return false;
|
||||
Pair<?, ?> pair = (Pair<?, ?>) o;
|
||||
return left.equals(pair.left) && right.equals(pair.right);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(left, right);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
sb.append(getClass().getSimpleName());
|
||||
sb.append(" [left=").append(left);
|
||||
sb.append(", right=").append(right);
|
||||
sb.append(']');
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,9 +19,6 @@ import java.time.Duration;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
import org.springframework.beans.factory.DisposableBean;
|
||||
import org.springframework.http.HttpEntity;
|
||||
import org.springframework.scheduling.TaskScheduler;
|
||||
@@ -397,11 +394,22 @@ public class LifecycleAwareSessionManager extends LifecycleAwareSessionManagerSu
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
@Getter
|
||||
protected static class TokenWrapper {
|
||||
|
||||
private final VaultToken token;
|
||||
private final boolean revocable;
|
||||
|
||||
TokenWrapper(VaultToken token, boolean revocable) {
|
||||
this.token = token;
|
||||
this.revocable = revocable;
|
||||
}
|
||||
|
||||
public VaultToken getToken() {
|
||||
return this.token;
|
||||
}
|
||||
|
||||
public boolean isRevocable() {
|
||||
return this.revocable;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,6 @@ import java.util.Date;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
@@ -165,13 +164,16 @@ public abstract class LifecycleAwareSessionManagerSupport extends
|
||||
* This one-shot trigger creates only one execution time to trigger an execution only
|
||||
* once.
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
protected static class OneShotTrigger implements Trigger {
|
||||
|
||||
private final AtomicBoolean fired = new AtomicBoolean();
|
||||
|
||||
private final Date nextExecutionTime;
|
||||
|
||||
public OneShotTrigger(Date nextExecutionTime) {
|
||||
this.nextExecutionTime = nextExecutionTime;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Date nextExecutionTime(TriggerContext triggerContext) {
|
||||
|
||||
|
||||
@@ -17,8 +17,6 @@ package org.springframework.vault.authentication;
|
||||
|
||||
import java.time.Duration;
|
||||
|
||||
import lombok.ToString;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.vault.support.VaultToken;
|
||||
|
||||
@@ -27,7 +25,6 @@ import org.springframework.vault.support.VaultToken;
|
||||
*
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
@ToString
|
||||
public class LoginToken extends VaultToken {
|
||||
|
||||
private final boolean renewable;
|
||||
@@ -210,4 +207,13 @@ public class LoginToken extends VaultToken {
|
||||
return renewable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
sb.append(getClass().getSimpleName());
|
||||
sb.append(" [renewable=").append(renewable);
|
||||
sb.append(", leaseDuration=").append(leaseDuration);
|
||||
sb.append(']');
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,8 +18,6 @@ package org.springframework.vault.authentication;
|
||||
import java.time.Duration;
|
||||
import java.util.Map;
|
||||
|
||||
import lombok.experimental.UtilityClass;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
@@ -27,8 +25,12 @@ import org.springframework.util.Assert;
|
||||
*
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
@UtilityClass
|
||||
class LoginTokenUtil {
|
||||
final class LoginTokenUtil {
|
||||
|
||||
private LoginTokenUtil() {
|
||||
throw new UnsupportedOperationException(
|
||||
"This is a utility class and cannot be instantiated");
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a {@link LoginToken} from an auth response.
|
||||
|
||||
@@ -20,8 +20,6 @@ import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import org.springframework.beans.factory.DisposableBean;
|
||||
@@ -480,12 +478,23 @@ public class ReactiveLifecycleAwareSessionManager extends
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
@Getter
|
||||
protected static class TokenWrapper {
|
||||
|
||||
private final VaultToken token;
|
||||
private final boolean revocable;
|
||||
|
||||
public TokenWrapper(VaultToken token, boolean revocable) {
|
||||
this.token = token;
|
||||
this.revocable = revocable;
|
||||
}
|
||||
|
||||
public VaultToken getToken() {
|
||||
return this.token;
|
||||
}
|
||||
|
||||
public boolean isRevocable() {
|
||||
return this.revocable;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -18,8 +18,7 @@ package org.springframework.vault.client;
|
||||
import java.io.Serializable;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URI;
|
||||
|
||||
import lombok.EqualsAndHashCode;
|
||||
import java.util.Objects;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
@@ -33,7 +32,6 @@ import org.springframework.util.StringUtils;
|
||||
*
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
@EqualsAndHashCode
|
||||
public class VaultEndpoint implements Serializable {
|
||||
|
||||
public static final String API_VERSION = "v1";
|
||||
@@ -218,6 +216,22 @@ public class VaultEndpoint implements Serializable {
|
||||
getPath(), path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o)
|
||||
return true;
|
||||
if (!(o instanceof VaultEndpoint))
|
||||
return false;
|
||||
VaultEndpoint that = (VaultEndpoint) o;
|
||||
return port == that.port && host.equals(that.host) && scheme.equals(that.scheme)
|
||||
&& path.equals(that.path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(host, port, scheme, path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("%s://%s:%d", scheme, host, port);
|
||||
|
||||
@@ -17,7 +17,6 @@ package org.springframework.vault.config;
|
||||
|
||||
import java.time.Duration;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
@@ -178,11 +177,14 @@ public abstract class AbstractReactiveVaultConfiguration extends
|
||||
* Simple {@link SessionManager} adapter using a {@link ReactiveSessionManager} to
|
||||
* obtain tokens.
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
static class ReactiveSessionManagerAdapter implements SessionManager {
|
||||
|
||||
private final ReactiveSessionManager sessionManager;
|
||||
|
||||
public ReactiveSessionManagerAdapter(ReactiveSessionManager sessionManager) {
|
||||
this.sessionManager = sessionManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VaultToken getSessionToken() {
|
||||
return sessionManager.getSessionToken().block(Duration.ofSeconds(30));
|
||||
|
||||
@@ -21,6 +21,7 @@ import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonAnySetter;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
@@ -28,7 +29,6 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.SerializationFeature;
|
||||
import lombok.Data;
|
||||
|
||||
import org.springframework.core.ParameterizedTypeReference;
|
||||
import org.springframework.http.HttpEntity;
|
||||
@@ -188,8 +188,7 @@ public class VaultSysTemplate implements VaultSysOperations {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void authMount(String path, VaultMount vaultMount)
|
||||
throws VaultException {
|
||||
public void authMount(String path, VaultMount vaultMount) throws VaultException {
|
||||
|
||||
Assert.hasText(path, "Path must not be empty");
|
||||
Assert.notNull(vaultMount, "VaultMount must not be null");
|
||||
@@ -411,7 +410,6 @@ public class VaultSysTemplate implements VaultSysOperations {
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
static class VaultInitializationResponseImpl implements VaultInitializationResponse {
|
||||
|
||||
private List<String> keys = new ArrayList<>();
|
||||
@@ -419,12 +417,41 @@ public class VaultSysTemplate implements VaultSysOperations {
|
||||
@JsonProperty("root_token")
|
||||
private String rootToken = "";
|
||||
|
||||
public VaultInitializationResponseImpl() {
|
||||
}
|
||||
|
||||
public VaultToken getRootToken() {
|
||||
return VaultToken.of(rootToken);
|
||||
}
|
||||
|
||||
public List<String> getKeys() {
|
||||
return this.keys;
|
||||
}
|
||||
|
||||
public void setKeys(List<String> keys) {
|
||||
this.keys = keys;
|
||||
}
|
||||
|
||||
public void setRootToken(String rootToken) {
|
||||
this.rootToken = rootToken;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o)
|
||||
return true;
|
||||
if (!(o instanceof VaultInitializationResponseImpl))
|
||||
return false;
|
||||
VaultInitializationResponseImpl that = (VaultInitializationResponseImpl) o;
|
||||
return keys.equals(that.keys) && rootToken.equals(that.rootToken);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(keys, rootToken);
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
static class VaultUnsealStatusImpl implements VaultUnsealStatus {
|
||||
|
||||
private boolean sealed;
|
||||
@@ -436,9 +463,59 @@ public class VaultSysTemplate implements VaultSysOperations {
|
||||
private int secretShares;
|
||||
|
||||
private int progress;
|
||||
|
||||
public VaultUnsealStatusImpl() {
|
||||
}
|
||||
|
||||
public boolean isSealed() {
|
||||
return this.sealed;
|
||||
}
|
||||
|
||||
public int getSecretThreshold() {
|
||||
return this.secretThreshold;
|
||||
}
|
||||
|
||||
public int getSecretShares() {
|
||||
return this.secretShares;
|
||||
}
|
||||
|
||||
public int getProgress() {
|
||||
return this.progress;
|
||||
}
|
||||
|
||||
public void setSealed(boolean sealed) {
|
||||
this.sealed = sealed;
|
||||
}
|
||||
|
||||
public void setSecretThreshold(int secretThreshold) {
|
||||
this.secretThreshold = secretThreshold;
|
||||
}
|
||||
|
||||
public void setSecretShares(int secretShares) {
|
||||
this.secretShares = secretShares;
|
||||
}
|
||||
|
||||
public void setProgress(int progress) {
|
||||
this.progress = progress;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o)
|
||||
return true;
|
||||
if (!(o instanceof VaultUnsealStatusImpl))
|
||||
return false;
|
||||
VaultUnsealStatusImpl that = (VaultUnsealStatusImpl) o;
|
||||
return sealed == that.sealed && secretThreshold == that.secretThreshold
|
||||
&& secretShares == that.secretShares && progress == that.progress;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(sealed, secretThreshold, secretShares, progress);
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
static class VaultHealthImpl implements VaultHealth {
|
||||
|
||||
@@ -462,5 +539,43 @@ public class VaultSysTemplate implements VaultSysOperations {
|
||||
this.serverTimeUtc = serverTimeUtc;
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
public boolean isInitialized() {
|
||||
return this.initialized;
|
||||
}
|
||||
|
||||
public boolean isSealed() {
|
||||
return this.sealed;
|
||||
}
|
||||
|
||||
public boolean isStandby() {
|
||||
return this.standby;
|
||||
}
|
||||
|
||||
public int getServerTimeUtc() {
|
||||
return this.serverTimeUtc;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getVersion() {
|
||||
return this.version;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o)
|
||||
return true;
|
||||
if (!(o instanceof VaultHealthImpl))
|
||||
return false;
|
||||
VaultHealthImpl that = (VaultHealthImpl) o;
|
||||
return initialized == that.initialized && sealed == that.sealed
|
||||
&& standby == that.standby && serverTimeUtc == that.serverTimeUtc
|
||||
&& Objects.equals(version, that.version);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(initialized, sealed, standby, serverTimeUtc, version);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,9 +20,9 @@ import java.util.Collections;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
@@ -570,7 +570,6 @@ public class VaultTransitTemplate implements VaultTransitOperations {
|
||||
"batch_results");
|
||||
}
|
||||
|
||||
@Data
|
||||
static class VaultTransitKeyImpl implements VaultTransitKey {
|
||||
|
||||
@Nullable
|
||||
@@ -613,6 +612,9 @@ public class VaultTransitTemplate implements VaultTransitOperations {
|
||||
@JsonProperty("supports_signing")
|
||||
private boolean supportsSigning;
|
||||
|
||||
public VaultTransitKeyImpl() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType() {
|
||||
|
||||
@@ -642,14 +644,197 @@ public class VaultTransitTemplate implements VaultTransitOperations {
|
||||
public boolean supportsSigning() {
|
||||
return isSupportsSigning();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public String getCipherMode() {
|
||||
return this.cipherMode;
|
||||
}
|
||||
|
||||
public boolean isDeletionAllowed() {
|
||||
return this.deletionAllowed;
|
||||
}
|
||||
|
||||
public boolean isDerived() {
|
||||
return this.derived;
|
||||
}
|
||||
|
||||
public boolean isExportable() {
|
||||
return this.exportable;
|
||||
}
|
||||
|
||||
public Map<String, Object> getKeys() {
|
||||
return this.keys;
|
||||
}
|
||||
|
||||
public int getLatestVersion() {
|
||||
return this.latestVersion;
|
||||
}
|
||||
|
||||
public int getMinDecryptionVersion() {
|
||||
return this.minDecryptionVersion;
|
||||
}
|
||||
|
||||
public int getMinEncryptionVersion() {
|
||||
return this.minEncryptionVersion;
|
||||
}
|
||||
|
||||
public boolean isSupportsDecryption() {
|
||||
return this.supportsDecryption;
|
||||
}
|
||||
|
||||
public boolean isSupportsEncryption() {
|
||||
return this.supportsEncryption;
|
||||
}
|
||||
|
||||
public boolean isSupportsDerivation() {
|
||||
return this.supportsDerivation;
|
||||
}
|
||||
|
||||
public boolean isSupportsSigning() {
|
||||
return this.supportsSigning;
|
||||
}
|
||||
|
||||
public void setName(@Nullable String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public void setCipherMode(String cipherMode) {
|
||||
this.cipherMode = cipherMode;
|
||||
}
|
||||
|
||||
public void setType(@Nullable String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public void setDeletionAllowed(boolean deletionAllowed) {
|
||||
this.deletionAllowed = deletionAllowed;
|
||||
}
|
||||
|
||||
public void setDerived(boolean derived) {
|
||||
this.derived = derived;
|
||||
}
|
||||
|
||||
public void setExportable(boolean exportable) {
|
||||
this.exportable = exportable;
|
||||
}
|
||||
|
||||
public void setKeys(Map<String, Object> keys) {
|
||||
this.keys = keys;
|
||||
}
|
||||
|
||||
public void setLatestVersion(int latestVersion) {
|
||||
this.latestVersion = latestVersion;
|
||||
}
|
||||
|
||||
public void setMinDecryptionVersion(int minDecryptionVersion) {
|
||||
this.minDecryptionVersion = minDecryptionVersion;
|
||||
}
|
||||
|
||||
public void setMinEncryptionVersion(int minEncryptionVersion) {
|
||||
this.minEncryptionVersion = minEncryptionVersion;
|
||||
}
|
||||
|
||||
public void setSupportsDecryption(boolean supportsDecryption) {
|
||||
this.supportsDecryption = supportsDecryption;
|
||||
}
|
||||
|
||||
public void setSupportsEncryption(boolean supportsEncryption) {
|
||||
this.supportsEncryption = supportsEncryption;
|
||||
}
|
||||
|
||||
public void setSupportsDerivation(boolean supportsDerivation) {
|
||||
this.supportsDerivation = supportsDerivation;
|
||||
}
|
||||
|
||||
public void setSupportsSigning(boolean supportsSigning) {
|
||||
this.supportsSigning = supportsSigning;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o)
|
||||
return true;
|
||||
if (!(o instanceof VaultTransitKeyImpl))
|
||||
return false;
|
||||
VaultTransitKeyImpl that = (VaultTransitKeyImpl) o;
|
||||
return deletionAllowed == that.deletionAllowed && derived == that.derived
|
||||
&& exportable == that.exportable
|
||||
&& latestVersion == that.latestVersion
|
||||
&& minDecryptionVersion == that.minDecryptionVersion
|
||||
&& minEncryptionVersion == that.minEncryptionVersion
|
||||
&& supportsDecryption == that.supportsDecryption
|
||||
&& supportsEncryption == that.supportsEncryption
|
||||
&& supportsDerivation == that.supportsDerivation
|
||||
&& supportsSigning == that.supportsSigning
|
||||
&& Objects.equals(name, that.name)
|
||||
&& cipherMode.equals(that.cipherMode)
|
||||
&& Objects.equals(type, that.type) && keys.equals(that.keys);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(name, cipherMode, type, deletionAllowed, derived,
|
||||
exportable, keys, latestVersion, minDecryptionVersion,
|
||||
minEncryptionVersion, supportsDecryption, supportsEncryption,
|
||||
supportsDerivation, supportsSigning);
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
static class RawTransitKeyImpl implements RawTransitKey {
|
||||
|
||||
private Map<String, String> keys = Collections.emptyMap();
|
||||
|
||||
@Nullable
|
||||
private String name;
|
||||
|
||||
public RawTransitKeyImpl() {
|
||||
}
|
||||
|
||||
public Map<String, String> getKeys() {
|
||||
return this.keys;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public void setKeys(Map<String, String> keys) {
|
||||
this.keys = keys;
|
||||
}
|
||||
|
||||
public void setName(@Nullable String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o)
|
||||
return true;
|
||||
if (!(o instanceof RawTransitKeyImpl))
|
||||
return false;
|
||||
RawTransitKeyImpl that = (RawTransitKeyImpl) o;
|
||||
return keys.equals(that.keys) && Objects.equals(name, that.name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(keys, name);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
sb.append(getClass().getSimpleName());
|
||||
sb.append(" [vaultOperations=").append(vaultOperations);
|
||||
sb.append(", path='").append(path).append('\'');
|
||||
sb.append(']');
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,8 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import lombok.extern.apachecommons.CommonsLog;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.beans.factory.DisposableBean;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
@@ -116,7 +117,6 @@ import org.springframework.web.client.HttpStatusCodeException;
|
||||
* @see Lease
|
||||
* @see LeaseEndpoints
|
||||
*/
|
||||
@CommonsLog
|
||||
public class SecretLeaseContainer extends SecretLeaseEventPublisher implements
|
||||
InitializingBean, DisposableBean {
|
||||
|
||||
@@ -128,6 +128,7 @@ public class SecretLeaseContainer extends SecretLeaseEventPublisher implements
|
||||
private static final int STATUS_INITIAL = 0;
|
||||
private static final int STATUS_STARTED = 1;
|
||||
private static final int STATUS_DESTROYED = 2;
|
||||
private static final Log log = LogFactory.getLog(SecretLeaseContainer.class);
|
||||
|
||||
private final List<RequestedSecret> requestedSecrets = new CopyOnWriteArrayList<>();
|
||||
|
||||
@@ -699,9 +700,10 @@ public class SecretLeaseContainer extends SecretLeaseEventPublisher implements
|
||||
* a newer {@link Lease} for renewal, the previously registered renewal task will skip
|
||||
* renewal.
|
||||
*/
|
||||
@CommonsLog
|
||||
static class LeaseRenewalScheduler {
|
||||
|
||||
private static final Log log = org.apache.commons.logging.LogFactory
|
||||
.getLog(LeaseRenewalScheduler.class);
|
||||
private final TaskScheduler taskScheduler;
|
||||
|
||||
final AtomicReference<Lease> currentLeaseRef = new AtomicReference<>();
|
||||
|
||||
@@ -19,7 +19,8 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CopyOnWriteArraySet;
|
||||
|
||||
import lombok.extern.apachecommons.CommonsLog;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.lang.Nullable;
|
||||
@@ -209,11 +210,12 @@ public class SecretLeaseEventPublisher implements InitializingBean {
|
||||
/**
|
||||
* Simple {@link LeaseErrorListener} implementation to log errors.
|
||||
*/
|
||||
@CommonsLog
|
||||
public enum LoggingErrorListener implements LeaseErrorListener {
|
||||
|
||||
INSTANCE;
|
||||
|
||||
private static final Log log = LogFactory.getLog(LoggingErrorListener.class);
|
||||
|
||||
@Override
|
||||
public void onLeaseError(SecretLeaseEvent leaseEvent, Exception exception) {
|
||||
log.warn(
|
||||
|
||||
@@ -20,8 +20,6 @@ import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.ConcurrentReferenceHashMap;
|
||||
import org.springframework.util.StringUtils;
|
||||
@@ -145,7 +143,6 @@ public class KeyValueDelegate {
|
||||
return mountInfo;
|
||||
}
|
||||
|
||||
@Getter
|
||||
static class MountInfo {
|
||||
|
||||
static final MountInfo UNAVAILABLE = new MountInfo("", Collections.emptyMap(),
|
||||
@@ -203,5 +200,18 @@ public class KeyValueDelegate {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public String getPath() {
|
||||
return this.path;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Map<String, Object> getOptions() {
|
||||
return this.options;
|
||||
}
|
||||
|
||||
public boolean isAvailable() {
|
||||
return this.available;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,9 +17,7 @@ package org.springframework.vault.repository.convert;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
import java.util.Objects;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
@@ -37,8 +35,6 @@ import org.springframework.vault.support.VaultResponse;
|
||||
* @author Mark Paluch
|
||||
* @since 2.0
|
||||
*/
|
||||
@EqualsAndHashCode
|
||||
@ToString
|
||||
public class SecretDocument {
|
||||
|
||||
private @Nullable String id;
|
||||
@@ -134,4 +130,29 @@ public class SecretDocument {
|
||||
public void put(String key, Object value) {
|
||||
this.body.put(key, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o)
|
||||
return true;
|
||||
if (!(o instanceof SecretDocument))
|
||||
return false;
|
||||
SecretDocument that = (SecretDocument) o;
|
||||
return Objects.equals(id, that.id) && Objects.equals(body, that.body);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(id, body);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
sb.append(getClass().getSimpleName());
|
||||
sb.append(" [id='").append(id).append('\'');
|
||||
sb.append(", body=").append(body);
|
||||
sb.append(']');
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,8 +15,6 @@
|
||||
*/
|
||||
package org.springframework.vault.repository.query;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
import org.springframework.data.keyvalue.core.KeyValueOperations;
|
||||
import org.springframework.data.keyvalue.repository.query.KeyValuePartTreeQuery;
|
||||
import org.springframework.data.mapping.context.MappingContext;
|
||||
@@ -58,12 +56,16 @@ public class VaultPartTreeQuery extends KeyValuePartTreeQuery {
|
||||
(MappingContext) keyValueOperations.getMappingContext()));
|
||||
}
|
||||
|
||||
@RequiredArgsConstructor
|
||||
static class VaultQueryCreatorFactory implements
|
||||
QueryCreatorFactory<VaultQueryCreator> {
|
||||
|
||||
private final MappingContext<VaultPersistentEntity<?>, VaultPersistentProperty> mappingContext;
|
||||
|
||||
public VaultQueryCreatorFactory(
|
||||
MappingContext<VaultPersistentEntity<?>, VaultPersistentProperty> mappingContext) {
|
||||
this.mappingContext = mappingContext;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VaultQueryCreator queryCreatorFor(PartTree partTree,
|
||||
ParameterAccessor accessor) {
|
||||
|
||||
@@ -22,8 +22,6 @@ import java.util.function.BiPredicate;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import lombok.Value;
|
||||
|
||||
import org.springframework.dao.InvalidDataAccessApiUsageException;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.keyvalue.core.query.KeyValueQuery;
|
||||
@@ -191,16 +189,67 @@ public class VaultQueryCreator extends
|
||||
return part.shouldIgnoreCase() != IgnoreCaseType.NEVER;
|
||||
}
|
||||
|
||||
@Value
|
||||
static class Criteria<T> implements Predicate<String> {
|
||||
static final class Criteria<T> implements Predicate<String> {
|
||||
|
||||
private T value;
|
||||
private BiPredicate<T, String> predicate;
|
||||
private final T value;
|
||||
private final BiPredicate<T, String> predicate;
|
||||
|
||||
public Criteria(T value, BiPredicate<T, String> predicate) {
|
||||
this.value = value;
|
||||
this.predicate = predicate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test(String s) {
|
||||
return predicate.test(value, s);
|
||||
}
|
||||
|
||||
public T getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
public BiPredicate<T, String> getPredicate() {
|
||||
return this.predicate;
|
||||
}
|
||||
|
||||
public boolean equals(final Object o) {
|
||||
if (o == this)
|
||||
return true;
|
||||
if (!(o instanceof Criteria))
|
||||
return false;
|
||||
final Criteria<?> other = (Criteria<?>) o;
|
||||
final Object this$value = this.getValue();
|
||||
final Object other$value = other.getValue();
|
||||
if (this$value == null ? other$value != null : !this$value
|
||||
.equals(other$value))
|
||||
return false;
|
||||
final Object this$predicate = this.getPredicate();
|
||||
final Object other$predicate = other.getPredicate();
|
||||
if (this$predicate == null ? other$predicate != null : !this$predicate
|
||||
.equals(other$predicate))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
final int PRIME = 59;
|
||||
int result = 1;
|
||||
final Object $value = this.getValue();
|
||||
result = result * PRIME + ($value == null ? 43 : $value.hashCode());
|
||||
final Object $predicate = this.getPredicate();
|
||||
result = result * PRIME + ($predicate == null ? 43 : $predicate.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
sb.append(getClass().getSimpleName());
|
||||
sb.append(" [value=").append(value);
|
||||
sb.append(", predicate=").append(predicate);
|
||||
sb.append(']');
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
||||
enum VariableAccessor {
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
package org.springframework.vault.support;
|
||||
|
||||
import lombok.EqualsAndHashCode;
|
||||
import java.util.Objects;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
@@ -26,7 +26,6 @@ import org.springframework.util.Assert;
|
||||
* @author Mark Paluch
|
||||
* @since 1.1
|
||||
*/
|
||||
@EqualsAndHashCode
|
||||
public class Ciphertext {
|
||||
|
||||
private final String ciphertext;
|
||||
@@ -73,4 +72,19 @@ public class Ciphertext {
|
||||
|
||||
return new Ciphertext(getCiphertext(), context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o)
|
||||
return true;
|
||||
if (!(o instanceof Ciphertext))
|
||||
return false;
|
||||
Ciphertext that = (Ciphertext) o;
|
||||
return ciphertext.equals(that.ciphertext) && context.equals(that.context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(ciphertext, context);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,8 +15,7 @@
|
||||
*/
|
||||
package org.springframework.vault.support;
|
||||
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
import java.util.Objects;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
@@ -27,8 +26,6 @@ import org.springframework.util.Assert;
|
||||
* @author Mark Paluch
|
||||
* @since 2.0
|
||||
*/
|
||||
@EqualsAndHashCode
|
||||
@ToString
|
||||
public class Hmac {
|
||||
|
||||
private final String hmac;
|
||||
@@ -53,4 +50,28 @@ public class Hmac {
|
||||
public String getHmac() {
|
||||
return hmac;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o)
|
||||
return true;
|
||||
if (!(o instanceof Hmac))
|
||||
return false;
|
||||
Hmac other = (Hmac) o;
|
||||
return hmac.equals(other.hmac);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(hmac);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
sb.append(getClass().getSimpleName());
|
||||
sb.append(" [hmac='").append(hmac).append('\'');
|
||||
sb.append(']');
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,8 @@
|
||||
*/
|
||||
package org.springframework.vault.support;
|
||||
|
||||
import lombok.EqualsAndHashCode;
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
@@ -27,7 +28,6 @@ import org.springframework.util.Assert;
|
||||
* @author Mark Paluch
|
||||
* @since 1.1
|
||||
*/
|
||||
@EqualsAndHashCode
|
||||
public class Plaintext {
|
||||
|
||||
private static final Plaintext EMPTY = new Plaintext(new byte[0],
|
||||
@@ -115,4 +115,22 @@ public class Plaintext {
|
||||
public String asString() {
|
||||
return new String(getPlaintext());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o)
|
||||
return true;
|
||||
if (!(o instanceof Plaintext))
|
||||
return false;
|
||||
Plaintext plaintext1 = (Plaintext) o;
|
||||
return Arrays.equals(plaintext, plaintext1.plaintext)
|
||||
&& context.equals(plaintext1.context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = Objects.hash(context);
|
||||
result = 31 * result + Arrays.hashCode(plaintext);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ import java.util.LinkedHashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
@@ -46,7 +47,6 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.type.TypeFactory;
|
||||
import com.fasterxml.jackson.databind.util.Converter;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
@@ -65,7 +65,6 @@ import org.springframework.vault.support.Policy.PolicySerializer;
|
||||
*/
|
||||
@JsonSerialize(using = PolicySerializer.class)
|
||||
@JsonDeserialize(using = PolicyDeserializer.class)
|
||||
@EqualsAndHashCode
|
||||
public class Policy {
|
||||
|
||||
private static final Policy EMPTY = new Policy(Collections.emptySet());
|
||||
@@ -157,13 +156,27 @@ public class Policy {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o)
|
||||
return true;
|
||||
if (!(o instanceof Policy))
|
||||
return false;
|
||||
Policy policy = (Policy) o;
|
||||
return rules.equals(policy.rules);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(rules);
|
||||
}
|
||||
|
||||
/**
|
||||
* Value object representing a rule for a certain path. Rule equality is considered by
|
||||
* comparing only the path segment to guarante uniqueness within a {@link Set}.
|
||||
*
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
@EqualsAndHashCode(of = "path")
|
||||
@JsonInclude(Include.NON_EMPTY)
|
||||
public static class Rule {
|
||||
|
||||
@@ -245,6 +258,15 @@ public class Policy {
|
||||
this.deniedParameters = deniedParameters;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new builder for {@link Rule}.
|
||||
*
|
||||
* @return a new {@link RuleBuilder}.
|
||||
*/
|
||||
public static RuleBuilder builder() {
|
||||
return new RuleBuilder();
|
||||
}
|
||||
|
||||
private Rule withPath(String path) {
|
||||
return new Rule(path, capabilities, minWrappingTtl, maxWrappingTtl,
|
||||
allowedParameters, deniedParameters);
|
||||
@@ -276,13 +298,19 @@ public class Policy {
|
||||
return deniedParameters;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new builder for {@link Rule}.
|
||||
*
|
||||
* @return a new {@link RuleBuilder}.
|
||||
*/
|
||||
public static RuleBuilder builder() {
|
||||
return new RuleBuilder();
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o)
|
||||
return true;
|
||||
if (!(o instanceof Rule))
|
||||
return false;
|
||||
Rule rule = (Rule) o;
|
||||
return path.equals(rule.path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(path);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -15,8 +15,7 @@
|
||||
*/
|
||||
package org.springframework.vault.support;
|
||||
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
import java.util.Objects;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
@@ -27,8 +26,6 @@ import org.springframework.util.Assert;
|
||||
* @author Mark Paluch
|
||||
* @since 2.0
|
||||
*/
|
||||
@EqualsAndHashCode
|
||||
@ToString
|
||||
public class Signature {
|
||||
|
||||
private final String signature;
|
||||
@@ -53,4 +50,28 @@ public class Signature {
|
||||
public String getSignature() {
|
||||
return signature;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o)
|
||||
return true;
|
||||
if (!(o instanceof Signature))
|
||||
return false;
|
||||
Signature that = (Signature) o;
|
||||
return signature.equals(that.signature);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(signature);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
sb.append(getClass().getSimpleName());
|
||||
sb.append(" [signature='").append(signature).append('\'');
|
||||
sb.append(']');
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,8 +15,7 @@
|
||||
*/
|
||||
package org.springframework.vault.support;
|
||||
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Value object representing the result of a {@link Signature} validation.
|
||||
@@ -24,8 +23,6 @@ import lombok.ToString;
|
||||
* @author Mark Paluch
|
||||
* @since 2.0
|
||||
*/
|
||||
@EqualsAndHashCode
|
||||
@ToString
|
||||
public class SignatureValidation {
|
||||
|
||||
private static final SignatureValidation VALID = new SignatureValidation(true);
|
||||
@@ -63,4 +60,28 @@ public class SignatureValidation {
|
||||
public boolean isValid() {
|
||||
return state;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o)
|
||||
return true;
|
||||
if (!(o instanceof SignatureValidation))
|
||||
return false;
|
||||
SignatureValidation that = (SignatureValidation) o;
|
||||
return state == that.state;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
sb.append(getClass().getSimpleName());
|
||||
sb.append(" [state=").append(state);
|
||||
sb.append(']');
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,9 +15,6 @@
|
||||
*/
|
||||
package org.springframework.vault.support;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
/**
|
||||
* Enumeration to specify the type of the transit key. Intended for use with
|
||||
* {@link org.springframework.vault.core.VaultTransitOperations}
|
||||
@@ -25,11 +22,17 @@ import lombok.RequiredArgsConstructor;
|
||||
* @author Sven Schürmann
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
@Getter
|
||||
@RequiredArgsConstructor
|
||||
public enum TransitKeyType {
|
||||
|
||||
ENCRYPTION_KEY("encryption-key"), SIGNING_KEY("signing-key"), HMAC_KEY("hmac-key");
|
||||
|
||||
final String value;
|
||||
|
||||
TransitKeyType(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return this.value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,9 +18,6 @@ package org.springframework.vault.support;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
@@ -28,8 +25,6 @@ import org.springframework.util.Assert;
|
||||
*
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
@EqualsAndHashCode
|
||||
@ToString(exclude = "token")
|
||||
public class VaultToken {
|
||||
|
||||
private final char[] token;
|
||||
@@ -81,4 +76,22 @@ public class VaultToken {
|
||||
return token;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o)
|
||||
return true;
|
||||
if (!(o instanceof VaultToken))
|
||||
return false;
|
||||
VaultToken that = (VaultToken) o;
|
||||
return Arrays.equals(token, that.token);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Arrays.hashCode(token);
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return getClass().getSimpleName();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
package org.springframework.vault.support;
|
||||
|
||||
import lombok.EqualsAndHashCode;
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
@@ -24,7 +24,6 @@ import org.springframework.util.Assert;
|
||||
*
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
@EqualsAndHashCode
|
||||
public class VaultTransitContext {
|
||||
|
||||
/**
|
||||
@@ -93,6 +92,23 @@ public class VaultTransitContext {
|
||||
return nonce;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o)
|
||||
return true;
|
||||
if (!(o instanceof VaultTransitContext))
|
||||
return false;
|
||||
VaultTransitContext that = (VaultTransitContext) o;
|
||||
return Arrays.equals(context, that.context) && Arrays.equals(nonce, that.nonce);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = Arrays.hashCode(context);
|
||||
result = 31 * result + Arrays.hashCode(nonce);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builder for {@link VaultTransitContext}.
|
||||
*/
|
||||
|
||||
@@ -17,8 +17,6 @@ package org.springframework.vault.annotation;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
@@ -43,7 +41,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@ExtendWith(VaultExtension.class)
|
||||
@ContextConfiguration
|
||||
public class VaultPropertySourceInBeanConfigurationIntegrationTest {
|
||||
class VaultPropertySourceInBeanConfigurationIntegrationTest {
|
||||
|
||||
@VaultPropertySource({ "secret/myapp" })
|
||||
static class Config extends VaultIntegrationTestConfiguration {
|
||||
@@ -71,9 +69,19 @@ public class VaultPropertySourceInBeanConfigurationIntegrationTest {
|
||||
assertThat(clientClass.getMyapp()).isEqualTo("myvalue");
|
||||
}
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
static class ClientClass {
|
||||
String myapp;
|
||||
|
||||
public ClientClass(String myapp) {
|
||||
this.myapp = myapp;
|
||||
}
|
||||
|
||||
public String getMyapp() {
|
||||
return this.myapp;
|
||||
}
|
||||
|
||||
public void setMyapp(String myapp) {
|
||||
this.myapp = myapp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@ExtendWith(VaultExtension.class)
|
||||
@ContextConfiguration
|
||||
public class VaultPropertySourceIntegrationTests {
|
||||
class VaultPropertySourceIntegrationTests {
|
||||
|
||||
@Import({ Partial1.class, Partial2.class })
|
||||
static class Config extends VaultIntegrationTestConfiguration {
|
||||
|
||||
@@ -42,7 +42,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@ExtendWith(VaultExtension.class)
|
||||
@ContextConfiguration
|
||||
public class VaultPropertySourceMultipleIntegrationTests {
|
||||
class VaultPropertySourceMultipleIntegrationTests {
|
||||
|
||||
@VaultPropertySource(value = "secret/myapp/profile", propertyNamePrefix = "database.")
|
||||
@VaultPropertySource("secret/myapp")
|
||||
|
||||
@@ -38,10 +38,10 @@ class LoginTokenUnitTests {
|
||||
void toStringShouldPrintFields() {
|
||||
|
||||
assertThat(LoginToken.of("token").toString()).isEqualTo(
|
||||
"LoginToken(renewable=false, leaseDuration=PT0S)");
|
||||
"LoginToken [renewable=false, leaseDuration=PT0S]");
|
||||
assertThat(LoginToken.of("token", 1).toString()).isEqualTo(
|
||||
"LoginToken(renewable=false, leaseDuration=PT1S)");
|
||||
"LoginToken [renewable=false, leaseDuration=PT1S]");
|
||||
assertThat(LoginToken.renewable("token", 1).toString()).isEqualTo(
|
||||
"LoginToken(renewable=true, leaseDuration=PT1S)");
|
||||
"LoginToken [renewable=true, leaseDuration=PT1S]");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,12 +19,12 @@ import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import lombok.Data;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.vault.core.VaultKeyValueOperationsSupport.KeyValueBackend;
|
||||
import org.springframework.vault.domain.Person;
|
||||
import org.springframework.vault.util.IntegrationTestSupport;
|
||||
import org.springframework.vault.util.RequiresVaultVersion;
|
||||
import org.springframework.vault.util.VaultInitializer;
|
||||
@@ -122,11 +122,4 @@ abstract class AbstractVaultKeyValueTemplateIntegrationTests extends
|
||||
|
||||
assertThat(kvOperations.get(key)).isNull();
|
||||
}
|
||||
|
||||
@Data
|
||||
static class Person {
|
||||
|
||||
String firstname;
|
||||
String lastname;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ import reactor.test.StepVerifier;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
import org.springframework.vault.domain.Person;
|
||||
import org.springframework.vault.support.ObjectMapperSupplier;
|
||||
import org.springframework.vault.util.IntegrationTestSupport;
|
||||
|
||||
@@ -177,26 +178,4 @@ class ReactiveVaultTemplateGenericIntegrationTests extends IntegrationTestSuppor
|
||||
|
||||
}).verifyComplete();
|
||||
}
|
||||
|
||||
static class Person {
|
||||
|
||||
String firstname;
|
||||
String password;
|
||||
|
||||
void setFirstname(String firstname) {
|
||||
this.firstname = firstname;
|
||||
}
|
||||
|
||||
void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
String getFirstname() {
|
||||
return firstname;
|
||||
}
|
||||
|
||||
String getPassword() {
|
||||
return password;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
import org.springframework.vault.domain.Person;
|
||||
import org.springframework.vault.support.ObjectMapperSupplier;
|
||||
import org.springframework.vault.support.VaultResponse;
|
||||
import org.springframework.vault.support.VaultResponseSupport;
|
||||
@@ -137,27 +138,4 @@ class VaultTemplateGenericIntegrationTests extends IntegrationTestSupport {
|
||||
VaultResponse read = vaultOperations.read("secret/mykey");
|
||||
assertThat(read).isNull();
|
||||
}
|
||||
|
||||
static class Person {
|
||||
|
||||
String firstname;
|
||||
|
||||
String password;
|
||||
|
||||
void setFirstname(String firstname) {
|
||||
this.firstname = firstname;
|
||||
}
|
||||
|
||||
void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
String getFirstname() {
|
||||
return firstname;
|
||||
}
|
||||
|
||||
String getPassword() {
|
||||
return password;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,6 @@ import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import lombok.Data;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
@@ -29,6 +28,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
import org.springframework.vault.VaultException;
|
||||
import org.springframework.vault.domain.Person;
|
||||
import org.springframework.vault.support.Versioned;
|
||||
import org.springframework.vault.support.Versioned.Metadata;
|
||||
import org.springframework.vault.support.Versioned.Version;
|
||||
@@ -223,11 +223,4 @@ class VaultVersionedKeyValueTemplateIntegrationTests extends IntegrationTestSupp
|
||||
assertThat(versioned.getRequiredMetadata().isDestroyed()).isTrue();
|
||||
assertThat(versioned.getRequiredMetadata().getDeletedAt()).isNull();
|
||||
}
|
||||
|
||||
@Data
|
||||
static class Person {
|
||||
|
||||
String firstname;
|
||||
String lastname;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,8 +21,6 @@ import java.util.Collections;
|
||||
import java.util.Map;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Value;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
@@ -153,13 +151,41 @@ class VaultWrappingTemplateIntegrationTests extends IntegrationTestSupport {
|
||||
() -> wrappingOperations.rewrap(VaultToken.of("foo")));
|
||||
}
|
||||
|
||||
@Value
|
||||
@EqualsAndHashCode
|
||||
static class Secret {
|
||||
final String key;
|
||||
static final class Secret {
|
||||
private final String key;
|
||||
|
||||
Secret(@JsonProperty("key") String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
public String getKey() {
|
||||
return this.key;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "VaultWrappingTemplateIntegrationTests.Secret(key=" + this.getKey()
|
||||
+ ")";
|
||||
}
|
||||
|
||||
public boolean equals(final Object o) {
|
||||
if (o == this)
|
||||
return true;
|
||||
if (!(o instanceof Secret))
|
||||
return false;
|
||||
final Secret other = (Secret) o;
|
||||
final Object this$key = this.getKey();
|
||||
final Object other$key = other.getKey();
|
||||
if (this$key == null ? other$key != null : !this$key.equals(other$key))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
final int PRIME = 59;
|
||||
int result = 1;
|
||||
final Object $key = this.getKey();
|
||||
result = result * PRIME + ($key == null ? 43 : $key.hashCode());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
* Copyright 2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.vault.domain;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import org.springframework.data.annotation.Id;
|
||||
|
||||
/**
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
public class Person {
|
||||
|
||||
@Id
|
||||
private String id;
|
||||
|
||||
private String firstname;
|
||||
|
||||
private String lastname;
|
||||
|
||||
private String password;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getFirstname() {
|
||||
return firstname;
|
||||
}
|
||||
|
||||
public void setFirstname(String firstname) {
|
||||
this.firstname = firstname;
|
||||
}
|
||||
|
||||
public String getLastname() {
|
||||
return lastname;
|
||||
}
|
||||
|
||||
public void setLastname(String lastname) {
|
||||
this.lastname = lastname;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o)
|
||||
return true;
|
||||
if (!(o instanceof Person))
|
||||
return false;
|
||||
Person person = (Person) o;
|
||||
return Objects.equals(id, person.id)
|
||||
&& Objects.equals(firstname, person.firstname)
|
||||
&& Objects.equals(password, person.password);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(id, firstname, password);
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,6 @@ package org.springframework.vault.repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import lombok.Data;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
@@ -26,13 +25,13 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.FilterType;
|
||||
import org.springframework.context.annotation.ComponentScan.Filter;
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.map.repository.config.EnableMapRepositories;
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
import org.springframework.vault.core.VaultIntegrationTestConfiguration;
|
||||
import org.springframework.vault.core.VaultTemplate;
|
||||
import org.springframework.vault.domain.Person;
|
||||
import org.springframework.vault.repository.MultipleSpringDataModulesIntegrationTests.MultipleModulesActiveTestConfiguration;
|
||||
import org.springframework.vault.repository.configuration.EnableVaultRepositories;
|
||||
import org.springframework.vault.util.IntegrationTestSupport;
|
||||
@@ -40,11 +39,13 @@ import org.springframework.vault.util.IntegrationTestSupport;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Integration tests for Vault repositories with multiple Spring Data modules.
|
||||
*
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@ContextConfiguration(classes = MultipleModulesActiveTestConfiguration.class)
|
||||
public class MultipleSpringDataModulesIntegrationTests extends IntegrationTestSupport {
|
||||
class MultipleSpringDataModulesIntegrationTests extends IntegrationTestSupport {
|
||||
|
||||
@Configuration
|
||||
@EnableMapRepositories(considerNestedRepositories = true, //
|
||||
@@ -74,7 +75,7 @@ public class MultipleSpringDataModulesIntegrationTests extends IntegrationTestSu
|
||||
|
||||
Person person = new Person();
|
||||
person.setId("foo-key");
|
||||
person.setName("bar");
|
||||
person.setFirstname("bar");
|
||||
|
||||
vaultRepository.save(person);
|
||||
|
||||
@@ -91,14 +92,14 @@ public class MultipleSpringDataModulesIntegrationTests extends IntegrationTestSu
|
||||
|
||||
Person person = new Person();
|
||||
person.setId("foo-key");
|
||||
person.setName("bar");
|
||||
person.setFirstname("bar");
|
||||
|
||||
mapRepository.save(person);
|
||||
|
||||
Iterable<Person> all = mapRepository.findAll();
|
||||
|
||||
assertThat(all).contains(person);
|
||||
assertThat(mapRepository.findByNameStartsWith("bar")).contains(person);
|
||||
assertThat(mapRepository.findByFirstnameStartsWith("bar")).contains(person);
|
||||
assertThat(vaultRepository.findById("foo-key")).isEmpty();
|
||||
}
|
||||
|
||||
@@ -109,14 +110,6 @@ public class MultipleSpringDataModulesIntegrationTests extends IntegrationTestSu
|
||||
|
||||
interface MapRepository extends CrudRepository<Person, String> {
|
||||
|
||||
List<Person> findByNameStartsWith(String prefix);
|
||||
}
|
||||
|
||||
@Data
|
||||
static class Person {
|
||||
|
||||
@Id
|
||||
String id;
|
||||
String name;
|
||||
List<Person> findByFirstnameStartsWith(String prefix);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@ package org.springframework.vault.repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import lombok.Data;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
@@ -31,6 +30,7 @@ import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
import org.springframework.vault.core.VaultIntegrationTestConfiguration;
|
||||
import org.springframework.vault.core.VaultTemplate;
|
||||
import org.springframework.vault.domain.Person;
|
||||
import org.springframework.vault.repository.VaultRepositoryIntegrationTests.VaultRepositoryTestConfiguration;
|
||||
import org.springframework.vault.repository.configuration.EnableVaultRepositories;
|
||||
import org.springframework.vault.util.IntegrationTestSupport;
|
||||
@@ -40,11 +40,13 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
import static org.springframework.data.domain.Sort.Order.asc;
|
||||
|
||||
/**
|
||||
* Integration tests for Vault repositories.
|
||||
*
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@ContextConfiguration(classes = VaultRepositoryTestConfiguration.class)
|
||||
public class VaultRepositoryIntegrationTests extends IntegrationTestSupport {
|
||||
class VaultRepositoryIntegrationTests extends IntegrationTestSupport {
|
||||
|
||||
@Configuration
|
||||
@EnableVaultRepositories(considerNestedRepositories = true)
|
||||
@@ -68,7 +70,7 @@ public class VaultRepositoryIntegrationTests extends IntegrationTestSupport {
|
||||
|
||||
Person person = new Person();
|
||||
person.setId("foo-key");
|
||||
person.setName("bar");
|
||||
person.setFirstname("bar");
|
||||
|
||||
vaultRepository.save(person);
|
||||
|
||||
@@ -83,13 +85,13 @@ public class VaultRepositoryIntegrationTests extends IntegrationTestSupport {
|
||||
|
||||
Person walter = new Person();
|
||||
walter.setId("walter");
|
||||
walter.setName("Walter");
|
||||
walter.setFirstname("Walter");
|
||||
|
||||
vaultRepository.save(walter);
|
||||
|
||||
Person skyler = new Person();
|
||||
skyler.setId("skyler");
|
||||
skyler.setName("Skyler");
|
||||
skyler.setFirstname("Skyler");
|
||||
|
||||
vaultRepository.save(skyler);
|
||||
|
||||
@@ -103,20 +105,20 @@ public class VaultRepositoryIntegrationTests extends IntegrationTestSupport {
|
||||
|
||||
Person walter = new Person();
|
||||
walter.setId("walter");
|
||||
walter.setName("Walter");
|
||||
walter.setFirstname("Walter");
|
||||
|
||||
vaultRepository.save(walter);
|
||||
|
||||
Person skyler = new Person();
|
||||
skyler.setId("skyler");
|
||||
skyler.setName("Skyler");
|
||||
skyler.setFirstname("Skyler");
|
||||
|
||||
vaultRepository.save(skyler);
|
||||
|
||||
assertThat(vaultRepository.findAllByOrderByNameAsc()).containsSequence(skyler,
|
||||
walter);
|
||||
assertThat(vaultRepository.findAllByOrderByNameDesc()).containsSequence(walter,
|
||||
skyler);
|
||||
assertThat(vaultRepository.findAllByOrderByFirstnameAsc()).containsSequence(
|
||||
skyler, walter);
|
||||
assertThat(vaultRepository.findAllByOrderByFirstnameDesc()).containsSequence(
|
||||
walter, skyler);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -124,41 +126,36 @@ public class VaultRepositoryIntegrationTests extends IntegrationTestSupport {
|
||||
|
||||
Person walter = new Person();
|
||||
walter.setId("walter");
|
||||
walter.setName("Walter");
|
||||
walter.setFirstname("Walter");
|
||||
|
||||
vaultRepository.save(walter);
|
||||
|
||||
Person skyler = new Person();
|
||||
skyler.setId("skyler");
|
||||
skyler.setName("Skyler");
|
||||
skyler.setFirstname("Skyler");
|
||||
|
||||
vaultRepository.save(skyler);
|
||||
|
||||
assertThat(vaultRepository.findTop1By(Sort.by(asc("name")))).containsOnly(skyler);
|
||||
assertThat(vaultRepository.findTop1By(Sort.by(asc("firstname")))).containsOnly(
|
||||
skyler);
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldFailForNonIdCriteria() {
|
||||
assertThatExceptionOfType(InvalidDataAccessApiUsageException.class).isThrownBy(
|
||||
() -> vaultRepository.findInvalidByName("foo"));
|
||||
() -> vaultRepository.findInvalidByFirstname("foo"));
|
||||
}
|
||||
|
||||
interface VaultRepository extends CrudRepository<Person, String> {
|
||||
|
||||
List<Person> findByIdStartsWith(String prefix);
|
||||
|
||||
List<Person> findAllByOrderByNameAsc();
|
||||
List<Person> findAllByOrderByFirstnameAsc();
|
||||
|
||||
List<Person> findAllByOrderByNameDesc();
|
||||
List<Person> findAllByOrderByFirstnameDesc();
|
||||
|
||||
List<Person> findTop1By(Sort sort);
|
||||
|
||||
List<Person> findInvalidByName(String name);
|
||||
}
|
||||
|
||||
@Data
|
||||
static class Person {
|
||||
|
||||
String id, name;
|
||||
List<Person> findInvalidByFirstname(String name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,10 +20,8 @@ import java.util.Collections;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@@ -37,7 +35,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
*
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
public class MappingVaultConverterUnitTests {
|
||||
class MappingVaultConverterUnitTests {
|
||||
|
||||
VaultMappingContext context = new VaultMappingContext();
|
||||
|
||||
@@ -285,74 +283,203 @@ public class MappingVaultConverterUnitTests {
|
||||
skyler);
|
||||
}
|
||||
|
||||
@Data
|
||||
static class SimpleEntity {
|
||||
|
||||
String id;
|
||||
String username;
|
||||
String password;
|
||||
|
||||
public String getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return this.username;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return this.password;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
static class ExtendedEntity extends SimpleEntity {
|
||||
|
||||
String location;
|
||||
|
||||
public String getLocation() {
|
||||
return this.location;
|
||||
}
|
||||
|
||||
public void setLocation(String location) {
|
||||
this.location = location;
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
static class EntityWithNestedType {
|
||||
|
||||
NestedType nested;
|
||||
|
||||
public NestedType getNested() {
|
||||
return this.nested;
|
||||
}
|
||||
|
||||
public void setNested(NestedType nested) {
|
||||
this.nested = nested;
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
static class EntityWithEnum {
|
||||
|
||||
Condition condition;
|
||||
|
||||
public Condition getCondition() {
|
||||
return this.condition;
|
||||
}
|
||||
|
||||
public void setCondition(Condition condition) {
|
||||
this.condition = condition;
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
@RequiredArgsConstructor
|
||||
static class ConstructorCreation {
|
||||
|
||||
final String id;
|
||||
final String username;
|
||||
String password;
|
||||
|
||||
public ConstructorCreation(String id, String username) {
|
||||
this.id = id;
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return this.username;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return this.password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
static class EntityWithListOfStrings {
|
||||
|
||||
List<String> usernames;
|
||||
|
||||
public List<String> getUsernames() {
|
||||
return this.usernames;
|
||||
}
|
||||
|
||||
public void setUsernames(List<String> usernames) {
|
||||
this.usernames = usernames;
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
static class EntityWithListOfEntities {
|
||||
|
||||
List<NestedType> nested;
|
||||
|
||||
public List<NestedType> getNested() {
|
||||
return this.nested;
|
||||
}
|
||||
|
||||
public void setNested(List<NestedType> nested) {
|
||||
this.nested = nested;
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
static class EntityWithMap {
|
||||
|
||||
Map<String, Integer> keyVersions;
|
||||
|
||||
public EntityWithMap() {
|
||||
}
|
||||
|
||||
public Map<String, Integer> getKeyVersions() {
|
||||
return this.keyVersions;
|
||||
}
|
||||
|
||||
public void setKeyVersions(Map<String, Integer> keyVersions) {
|
||||
this.keyVersions = keyVersions;
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
static class NestedType {
|
||||
|
||||
String username;
|
||||
String password;
|
||||
|
||||
public NestedType(String username, String password) {
|
||||
this.username = username;
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return this.username;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return this.password;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o)
|
||||
return true;
|
||||
if (!(o instanceof NestedType))
|
||||
return false;
|
||||
NestedType that = (NestedType) o;
|
||||
return Objects.equals(username, that.username)
|
||||
&& Objects.equals(password, that.password);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(username, password);
|
||||
}
|
||||
}
|
||||
|
||||
enum Condition {
|
||||
GOOD, BAD
|
||||
}
|
||||
|
||||
@Data
|
||||
static class Person {
|
||||
final String name;
|
||||
|
||||
public Person(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
}
|
||||
|
||||
enum DocumentToPersonConverter implements Converter<SecretDocument, Person> {
|
||||
|
||||
@@ -17,8 +17,7 @@ package org.springframework.vault.util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import lombok.EqualsAndHashCode;
|
||||
import java.util.Objects;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
@@ -28,7 +27,6 @@ import org.springframework.util.StringUtils;
|
||||
*
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
@EqualsAndHashCode
|
||||
public class Version implements Comparable<Version> {
|
||||
|
||||
private static final String VERSION_PARSE_ERROR = "Invalid version string! Could not parse segment %s within %s.";
|
||||
@@ -200,4 +198,20 @@ public class Version implements Comparable<Version> {
|
||||
|
||||
return StringUtils.collectionToDelimitedString(digits, ".");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o)
|
||||
return true;
|
||||
if (!(o instanceof Version))
|
||||
return false;
|
||||
Version version = (Version) o;
|
||||
return major == version.major && minor == version.minor
|
||||
&& bugfix == version.bugfix && build == version.build;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(major, minor, bugfix, build);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user