From 445770f4ad097fb511ef98df4dd8eebc3fc78cc5 Mon Sep 17 00:00:00 2001 From: Mark Paluch Date: Wed, 3 Jul 2019 09:29:26 +0200 Subject: [PATCH] Remove Lombok usage. Closes gh-341. --- pom.xml | 7 - .../vault/config/aws/VaultAwsProperties.java | 43 +- .../config/consul/VaultConsulProperties.java | 35 +- .../databases/VaultCassandraProperties.java | 43 +- .../databases/VaultDatabaseProperties.java | 43 +- .../databases/VaultMongoProperties.java | 46 +- .../databases/VaultMySqlProperties.java | 52 +- .../databases/VaultPostgreSqlProperties.java | 54 +- .../rabbitmq/VaultRabbitMqProperties.java | 43 +- .../config/ClientAuthenticationFactory.java | 11 +- .../DefaultSecretBackendConfigurer.java | 9 +- ...eryClientVaultServiceInstanceProvider.java | 13 +- .../LeasingVaultPropertySourceLocator.java | 6 +- .../vault/config/SecretBackendFactories.java | 6 +- .../vault/config/VaultConfigTemplate.java | 6 +- .../config/VaultGenericBackendProperties.java | 59 +- .../VaultKeyValueBackendProperties.java | 68 ++- .../cloud/vault/config/VaultProperties.java | 537 +++++++++++++++++- .../vault/config/VaultPropertySource.java | 8 +- .../VaultPropertySourceLocatorSupport.java | 13 +- .../config/VaultReactiveHealthIndicator.java | 58 +- ...lientVaultBootstrapConfigurationTests.java | 46 +- 22 files changed, 1110 insertions(+), 96 deletions(-) diff --git a/pom.xml b/pom.xml index 2b032721..dde56b29 100644 --- a/pom.xml +++ b/pom.xml @@ -143,13 +143,6 @@ provided - - org.projectlombok - lombok - provided - 1.16.22 - - org.springframework.boot spring-boot-autoconfigure diff --git a/spring-cloud-vault-config-aws/src/main/java/org/springframework/cloud/vault/config/aws/VaultAwsProperties.java b/spring-cloud-vault-config-aws/src/main/java/org/springframework/cloud/vault/config/aws/VaultAwsProperties.java index 5d06b4aa..8f487827 100644 --- a/spring-cloud-vault-config-aws/src/main/java/org/springframework/cloud/vault/config/aws/VaultAwsProperties.java +++ b/spring-cloud-vault-config-aws/src/main/java/org/springframework/cloud/vault/config/aws/VaultAwsProperties.java @@ -18,8 +18,6 @@ package org.springframework.cloud.vault.config.aws; import javax.validation.constraints.NotEmpty; -import lombok.Data; - import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.cloud.vault.config.VaultSecretBackendDescriptor; import org.springframework.validation.annotation.Validated; @@ -30,7 +28,6 @@ import org.springframework.validation.annotation.Validated; * @author Mark Paluch */ @ConfigurationProperties("spring.cloud.vault.aws") -@Data @Validated public class VaultAwsProperties implements VaultSecretBackendDescriptor { @@ -62,4 +59,44 @@ public class VaultAwsProperties implements VaultSecretBackendDescriptor { @NotEmpty private String secretKeyProperty = "cloud.aws.credentials.secretKey"; + public boolean isEnabled() { + return this.enabled; + } + + public String getRole() { + return this.role; + } + + public String getBackend() { + return this.backend; + } + + public String getAccessKeyProperty() { + return this.accessKeyProperty; + } + + public String getSecretKeyProperty() { + return this.secretKeyProperty; + } + + public void setEnabled(boolean enabled) { + this.enabled = enabled; + } + + public void setRole(String role) { + this.role = role; + } + + public void setBackend(String backend) { + this.backend = backend; + } + + public void setAccessKeyProperty(String accessKeyProperty) { + this.accessKeyProperty = accessKeyProperty; + } + + public void setSecretKeyProperty(String secretKeyProperty) { + this.secretKeyProperty = secretKeyProperty; + } + } diff --git a/spring-cloud-vault-config-consul/src/main/java/org/springframework/cloud/vault/config/consul/VaultConsulProperties.java b/spring-cloud-vault-config-consul/src/main/java/org/springframework/cloud/vault/config/consul/VaultConsulProperties.java index 734e1698..bcb501cf 100644 --- a/spring-cloud-vault-config-consul/src/main/java/org/springframework/cloud/vault/config/consul/VaultConsulProperties.java +++ b/spring-cloud-vault-config-consul/src/main/java/org/springframework/cloud/vault/config/consul/VaultConsulProperties.java @@ -18,8 +18,6 @@ package org.springframework.cloud.vault.config.consul; import javax.validation.constraints.NotEmpty; -import lombok.Data; - import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.cloud.vault.config.VaultSecretBackendDescriptor; import org.springframework.validation.annotation.Validated; @@ -30,7 +28,6 @@ import org.springframework.validation.annotation.Validated; * @author Mark Paluch */ @ConfigurationProperties("spring.cloud.vault.consul") -@Data @Validated public class VaultConsulProperties implements VaultSecretBackendDescriptor { @@ -56,4 +53,36 @@ public class VaultConsulProperties implements VaultSecretBackendDescriptor { @NotEmpty private String tokenProperty = "spring.cloud.consul.token"; + public boolean isEnabled() { + return this.enabled; + } + + public String getRole() { + return this.role; + } + + public String getBackend() { + return this.backend; + } + + public String getTokenProperty() { + return this.tokenProperty; + } + + public void setEnabled(boolean enabled) { + this.enabled = enabled; + } + + public void setRole(String role) { + this.role = role; + } + + public void setBackend(String backend) { + this.backend = backend; + } + + public void setTokenProperty(String tokenProperty) { + this.tokenProperty = tokenProperty; + } + } diff --git a/spring-cloud-vault-config-databases/src/main/java/org/springframework/cloud/vault/config/databases/VaultCassandraProperties.java b/spring-cloud-vault-config-databases/src/main/java/org/springframework/cloud/vault/config/databases/VaultCassandraProperties.java index cea2ba1c..e6ff1a01 100644 --- a/spring-cloud-vault-config-databases/src/main/java/org/springframework/cloud/vault/config/databases/VaultCassandraProperties.java +++ b/spring-cloud-vault-config-databases/src/main/java/org/springframework/cloud/vault/config/databases/VaultCassandraProperties.java @@ -18,8 +18,6 @@ package org.springframework.cloud.vault.config.databases; import javax.validation.constraints.NotEmpty; -import lombok.Data; - import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.validation.annotation.Validated; @@ -29,7 +27,6 @@ import org.springframework.validation.annotation.Validated; * @author Mark Paluch */ @ConfigurationProperties("spring.cloud.vault.cassandra") -@Data @Validated public class VaultCassandraProperties implements DatabaseSecretProperties { @@ -61,4 +58,44 @@ public class VaultCassandraProperties implements DatabaseSecretProperties { @NotEmpty private String passwordProperty = "spring.data.cassandra.password"; + public boolean isEnabled() { + return this.enabled; + } + + public String getRole() { + return this.role; + } + + public String getBackend() { + return this.backend; + } + + public String getUsernameProperty() { + return this.usernameProperty; + } + + public String getPasswordProperty() { + return this.passwordProperty; + } + + public void setEnabled(boolean enabled) { + this.enabled = enabled; + } + + public void setRole(String role) { + this.role = role; + } + + public void setBackend(String backend) { + this.backend = backend; + } + + public void setUsernameProperty(String usernameProperty) { + this.usernameProperty = usernameProperty; + } + + public void setPasswordProperty(String passwordProperty) { + this.passwordProperty = passwordProperty; + } + } diff --git a/spring-cloud-vault-config-databases/src/main/java/org/springframework/cloud/vault/config/databases/VaultDatabaseProperties.java b/spring-cloud-vault-config-databases/src/main/java/org/springframework/cloud/vault/config/databases/VaultDatabaseProperties.java index 7846d965..ad4952fa 100644 --- a/spring-cloud-vault-config-databases/src/main/java/org/springframework/cloud/vault/config/databases/VaultDatabaseProperties.java +++ b/spring-cloud-vault-config-databases/src/main/java/org/springframework/cloud/vault/config/databases/VaultDatabaseProperties.java @@ -18,8 +18,6 @@ package org.springframework.cloud.vault.config.databases; import javax.validation.constraints.NotEmpty; -import lombok.Data; - import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.validation.annotation.Validated; @@ -30,7 +28,6 @@ import org.springframework.validation.annotation.Validated; * @since 2.0 */ @ConfigurationProperties("spring.cloud.vault.database") -@Data @Validated public class VaultDatabaseProperties implements DatabaseSecretProperties { @@ -62,4 +59,44 @@ public class VaultDatabaseProperties implements DatabaseSecretProperties { @NotEmpty private String passwordProperty = "spring.datasource.password"; + public boolean isEnabled() { + return this.enabled; + } + + public String getRole() { + return this.role; + } + + public String getBackend() { + return this.backend; + } + + public String getUsernameProperty() { + return this.usernameProperty; + } + + public String getPasswordProperty() { + return this.passwordProperty; + } + + public void setEnabled(boolean enabled) { + this.enabled = enabled; + } + + public void setRole(String role) { + this.role = role; + } + + public void setBackend(String backend) { + this.backend = backend; + } + + public void setUsernameProperty(String usernameProperty) { + this.usernameProperty = usernameProperty; + } + + public void setPasswordProperty(String passwordProperty) { + this.passwordProperty = passwordProperty; + } + } diff --git a/spring-cloud-vault-config-databases/src/main/java/org/springframework/cloud/vault/config/databases/VaultMongoProperties.java b/spring-cloud-vault-config-databases/src/main/java/org/springframework/cloud/vault/config/databases/VaultMongoProperties.java index 3341e175..6171d6c2 100644 --- a/spring-cloud-vault-config-databases/src/main/java/org/springframework/cloud/vault/config/databases/VaultMongoProperties.java +++ b/spring-cloud-vault-config-databases/src/main/java/org/springframework/cloud/vault/config/databases/VaultMongoProperties.java @@ -18,8 +18,6 @@ package org.springframework.cloud.vault.config.databases; import javax.validation.constraints.NotEmpty; -import lombok.Data; - import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.validation.annotation.Validated; @@ -29,7 +27,6 @@ import org.springframework.validation.annotation.Validated; * @author Mark Paluch */ @ConfigurationProperties("spring.cloud.vault.mongodb") -@Data @Validated public class VaultMongoProperties implements DatabaseSecretProperties { @@ -61,4 +58,47 @@ public class VaultMongoProperties implements DatabaseSecretProperties { @NotEmpty private String passwordProperty = "spring.data.mongodb.password"; + public VaultMongoProperties() { + } + + public boolean isEnabled() { + return this.enabled; + } + + public String getRole() { + return this.role; + } + + public String getBackend() { + return this.backend; + } + + public String getUsernameProperty() { + return this.usernameProperty; + } + + public String getPasswordProperty() { + return this.passwordProperty; + } + + public void setEnabled(boolean enabled) { + this.enabled = enabled; + } + + public void setRole(String role) { + this.role = role; + } + + public void setBackend(String backend) { + this.backend = backend; + } + + public void setUsernameProperty(String usernameProperty) { + this.usernameProperty = usernameProperty; + } + + public void setPasswordProperty(String passwordProperty) { + this.passwordProperty = passwordProperty; + } + } diff --git a/spring-cloud-vault-config-databases/src/main/java/org/springframework/cloud/vault/config/databases/VaultMySqlProperties.java b/spring-cloud-vault-config-databases/src/main/java/org/springframework/cloud/vault/config/databases/VaultMySqlProperties.java index 0fd6747d..9d89e096 100644 --- a/spring-cloud-vault-config-databases/src/main/java/org/springframework/cloud/vault/config/databases/VaultMySqlProperties.java +++ b/spring-cloud-vault-config-databases/src/main/java/org/springframework/cloud/vault/config/databases/VaultMySqlProperties.java @@ -18,11 +18,7 @@ package org.springframework.cloud.vault.config.databases; import javax.validation.constraints.NotEmpty; -import lombok.Data; -import lombok.Getter; - import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.boot.context.properties.DeprecatedConfigurationProperty; import org.springframework.cloud.vault.config.VaultSecretBackendDescriptor; import org.springframework.validation.annotation.Validated; @@ -33,7 +29,6 @@ import org.springframework.validation.annotation.Validated; * @deprecated since 2.0. Use {@link VaultDatabaseProperties}. */ @ConfigurationProperties("spring.cloud.vault.mysql") -@Data @Validated @Deprecated public class VaultMySqlProperties @@ -42,15 +37,11 @@ public class VaultMySqlProperties /** * Enable mysql backend usage. */ - @Getter(onMethod_ = { @DeprecatedConfigurationProperty( - reason = "Use spring.cloud.vault.database") }) private boolean enabled = false; /** * Role name for credentials. */ - @Getter(onMethod_ = { @DeprecatedConfigurationProperty( - reason = "Use spring.cloud.vault.database") }) private String role; /** @@ -71,4 +62,47 @@ public class VaultMySqlProperties @NotEmpty private String passwordProperty = "spring.datasource.password"; + public VaultMySqlProperties() { + } + + public String getBackend() { + return this.backend; + } + + public String getUsernameProperty() { + return this.usernameProperty; + } + + public String getPasswordProperty() { + return this.passwordProperty; + } + + public void setEnabled(boolean enabled) { + this.enabled = enabled; + } + + public void setRole(String role) { + this.role = role; + } + + public void setBackend(String backend) { + this.backend = backend; + } + + public void setUsernameProperty(String usernameProperty) { + this.usernameProperty = usernameProperty; + } + + public void setPasswordProperty(String passwordProperty) { + this.passwordProperty = passwordProperty; + } + + public boolean isEnabled() { + return this.enabled; + } + + public String getRole() { + return this.role; + } + } diff --git a/spring-cloud-vault-config-databases/src/main/java/org/springframework/cloud/vault/config/databases/VaultPostgreSqlProperties.java b/spring-cloud-vault-config-databases/src/main/java/org/springframework/cloud/vault/config/databases/VaultPostgreSqlProperties.java index 834e6510..69d0d6a7 100644 --- a/spring-cloud-vault-config-databases/src/main/java/org/springframework/cloud/vault/config/databases/VaultPostgreSqlProperties.java +++ b/spring-cloud-vault-config-databases/src/main/java/org/springframework/cloud/vault/config/databases/VaultPostgreSqlProperties.java @@ -18,11 +18,7 @@ package org.springframework.cloud.vault.config.databases; import javax.validation.constraints.NotEmpty; -import lombok.Data; -import lombok.Getter; - import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.boot.context.properties.DeprecatedConfigurationProperty; import org.springframework.validation.annotation.Validated; /** @@ -32,7 +28,6 @@ import org.springframework.validation.annotation.Validated; * @deprecated since 2.0. Use {@link VaultDatabaseProperties}. */ @ConfigurationProperties("spring.cloud.vault.postgresql") -@Data @Validated @Deprecated public class VaultPostgreSqlProperties implements DatabaseSecretProperties { @@ -41,15 +36,11 @@ public class VaultPostgreSqlProperties implements DatabaseSecretProperties { * Enable postgresql backend usage. */ @Deprecated - @Getter(onMethod_ = { @DeprecatedConfigurationProperty( - reason = "Use spring.cloud.vault.database") }) private boolean enabled = false; /** * Role name for credentials. */ - @Getter(onMethod_ = { @DeprecatedConfigurationProperty( - reason = "Use spring.cloud.vault.database") }) private String role; /** @@ -70,4 +61,49 @@ public class VaultPostgreSqlProperties implements DatabaseSecretProperties { @NotEmpty private String passwordProperty = "spring.datasource.password"; + public VaultPostgreSqlProperties() { + } + + public String getBackend() { + return this.backend; + } + + public String getUsernameProperty() { + return this.usernameProperty; + } + + public String getPasswordProperty() { + return this.passwordProperty; + } + + @Deprecated + public void setEnabled(boolean enabled) { + this.enabled = enabled; + } + + public void setRole(String role) { + this.role = role; + } + + public void setBackend(String backend) { + this.backend = backend; + } + + public void setUsernameProperty(String usernameProperty) { + this.usernameProperty = usernameProperty; + } + + public void setPasswordProperty(String passwordProperty) { + this.passwordProperty = passwordProperty; + } + + @Deprecated + public boolean isEnabled() { + return this.enabled; + } + + public String getRole() { + return this.role; + } + } diff --git a/spring-cloud-vault-config-rabbitmq/src/main/java/org/springframework/cloud/vault/config/rabbitmq/VaultRabbitMqProperties.java b/spring-cloud-vault-config-rabbitmq/src/main/java/org/springframework/cloud/vault/config/rabbitmq/VaultRabbitMqProperties.java index cba4f007..49d9ca27 100644 --- a/spring-cloud-vault-config-rabbitmq/src/main/java/org/springframework/cloud/vault/config/rabbitmq/VaultRabbitMqProperties.java +++ b/spring-cloud-vault-config-rabbitmq/src/main/java/org/springframework/cloud/vault/config/rabbitmq/VaultRabbitMqProperties.java @@ -18,8 +18,6 @@ package org.springframework.cloud.vault.config.rabbitmq; import javax.validation.constraints.NotEmpty; -import lombok.Data; - import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.cloud.vault.config.VaultSecretBackendDescriptor; import org.springframework.validation.annotation.Validated; @@ -30,7 +28,6 @@ import org.springframework.validation.annotation.Validated; * @author Mark Paluch */ @ConfigurationProperties("spring.cloud.vault.rabbitmq") -@Data @Validated public class VaultRabbitMqProperties implements VaultSecretBackendDescriptor { @@ -62,4 +59,44 @@ public class VaultRabbitMqProperties implements VaultSecretBackendDescriptor { @NotEmpty private String passwordProperty = "spring.rabbitmq.password"; + public boolean isEnabled() { + return this.enabled; + } + + public String getRole() { + return this.role; + } + + public String getBackend() { + return this.backend; + } + + public String getUsernameProperty() { + return this.usernameProperty; + } + + public String getPasswordProperty() { + return this.passwordProperty; + } + + public void setEnabled(boolean enabled) { + this.enabled = enabled; + } + + public void setRole(String role) { + this.role = role; + } + + public void setBackend(String backend) { + this.backend = backend; + } + + public void setUsernameProperty(String usernameProperty) { + this.usernameProperty = usernameProperty; + } + + public void setPasswordProperty(String passwordProperty) { + this.passwordProperty = passwordProperty; + } + } diff --git a/spring-cloud-vault-config/src/main/java/org/springframework/cloud/vault/config/ClientAuthenticationFactory.java b/spring-cloud-vault-config/src/main/java/org/springframework/cloud/vault/config/ClientAuthenticationFactory.java index eee1c079..f7b8d341 100644 --- a/spring-cloud-vault-config/src/main/java/org/springframework/cloud/vault/config/ClientAuthenticationFactory.java +++ b/spring-cloud-vault-config/src/main/java/org/springframework/cloud/vault/config/ClientAuthenticationFactory.java @@ -27,8 +27,6 @@ import com.amazonaws.auth.AWSCredentials; import com.amazonaws.auth.AWSCredentialsProvider; import com.amazonaws.auth.DefaultAWSCredentialsProviderChain; import com.google.api.client.googleapis.auth.oauth2.GoogleCredential; -import lombok.RequiredArgsConstructor; -import lombok.extern.apachecommons.CommonsLog; import org.springframework.beans.BeanUtils; import org.springframework.cloud.vault.config.VaultProperties.AppRoleProperties; @@ -84,8 +82,6 @@ import org.springframework.web.client.RestOperations; * @author Michal Budzyn * @since 1.1 */ -@RequiredArgsConstructor -@CommonsLog class ClientAuthenticationFactory { private final VaultProperties vaultProperties; @@ -94,6 +90,13 @@ class ClientAuthenticationFactory { private final RestOperations externalRestOperations; + ClientAuthenticationFactory(VaultProperties vaultProperties, + RestOperations restOperations, RestOperations externalRestOperations) { + this.vaultProperties = vaultProperties; + this.restOperations = restOperations; + this.externalRestOperations = externalRestOperations; + } + static AppRoleAuthenticationOptions getAppRoleAuthenticationOptions( VaultProperties vaultProperties) { diff --git a/spring-cloud-vault-config/src/main/java/org/springframework/cloud/vault/config/DefaultSecretBackendConfigurer.java b/spring-cloud-vault-config/src/main/java/org/springframework/cloud/vault/config/DefaultSecretBackendConfigurer.java index 2ee7f075..ce4d5ad0 100644 --- a/spring-cloud-vault-config/src/main/java/org/springframework/cloud/vault/config/DefaultSecretBackendConfigurer.java +++ b/spring-cloud-vault-config/src/main/java/org/springframework/cloud/vault/config/DefaultSecretBackendConfigurer.java @@ -22,8 +22,6 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; -import lombok.RequiredArgsConstructor; - import org.springframework.util.Assert; import org.springframework.vault.core.lease.domain.RequestedSecret; import org.springframework.vault.core.lease.domain.RequestedSecret.Mode; @@ -132,13 +130,18 @@ class DefaultSecretBackendConfigurer return new ArrayList<>(this.secretBackends.values()); } - @RequiredArgsConstructor private static class SimpleSecretBackendMetadata implements SecretBackendMetadata { private final String path; private final PropertyTransformer propertyTransformer; + SimpleSecretBackendMetadata(String path, + PropertyTransformer propertyTransformer) { + this.path = path; + this.propertyTransformer = propertyTransformer; + } + @Override public String getName() { return String.format("Context backend: %s", this.path); diff --git a/spring-cloud-vault-config/src/main/java/org/springframework/cloud/vault/config/DiscoveryClientVaultServiceInstanceProvider.java b/spring-cloud-vault-config/src/main/java/org/springframework/cloud/vault/config/DiscoveryClientVaultServiceInstanceProvider.java index 81410257..20b79b82 100644 --- a/spring-cloud-vault-config/src/main/java/org/springframework/cloud/vault/config/DiscoveryClientVaultServiceInstanceProvider.java +++ b/spring-cloud-vault-config/src/main/java/org/springframework/cloud/vault/config/DiscoveryClientVaultServiceInstanceProvider.java @@ -18,8 +18,8 @@ package org.springframework.cloud.vault.config; import java.util.List; -import lombok.RequiredArgsConstructor; -import lombok.extern.apachecommons.CommonsLog; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.springframework.cloud.client.ServiceInstance; import org.springframework.cloud.client.discovery.DiscoveryClient; @@ -30,13 +30,18 @@ import org.springframework.cloud.client.discovery.DiscoveryClient; * @author Mark Paluch * @since 1.1 */ -@CommonsLog -@RequiredArgsConstructor public class DiscoveryClientVaultServiceInstanceProvider implements VaultServiceInstanceProvider { + private static final Log log = LogFactory + .getLog(DiscoveryClientVaultServiceInstanceProvider.class); + private final DiscoveryClient client; + public DiscoveryClientVaultServiceInstanceProvider(DiscoveryClient client) { + this.client = client; + } + @Override public ServiceInstance getVaultServerInstance(String serviceId) { diff --git a/spring-cloud-vault-config/src/main/java/org/springframework/cloud/vault/config/LeasingVaultPropertySourceLocator.java b/spring-cloud-vault-config/src/main/java/org/springframework/cloud/vault/config/LeasingVaultPropertySourceLocator.java index 1dcaf466..75c43bc3 100644 --- a/spring-cloud-vault-config/src/main/java/org/springframework/cloud/vault/config/LeasingVaultPropertySourceLocator.java +++ b/spring-cloud-vault-config/src/main/java/org/springframework/cloud/vault/config/LeasingVaultPropertySourceLocator.java @@ -18,7 +18,7 @@ package org.springframework.cloud.vault.config; import java.util.concurrent.atomic.AtomicReference; -import lombok.extern.apachecommons.CommonsLog; +import org.apache.commons.logging.Log; import org.springframework.core.PriorityOrdered; import org.springframework.core.env.PropertySource; @@ -36,10 +36,12 @@ import org.springframework.vault.core.lease.event.LeaseErrorListener; * @author Mark Paluch * @see LeaseAwareVaultPropertySource */ -@CommonsLog class LeasingVaultPropertySourceLocator extends VaultPropertySourceLocatorSupport implements PriorityOrdered { + private static final Log log = org.apache.commons.logging.LogFactory + .getLog(LeasingVaultPropertySourceLocator.class); + private final SecretLeaseContainer secretLeaseContainer; private final VaultProperties properties; diff --git a/spring-cloud-vault-config/src/main/java/org/springframework/cloud/vault/config/SecretBackendFactories.java b/spring-cloud-vault-config/src/main/java/org/springframework/cloud/vault/config/SecretBackendFactories.java index d25e7f6e..ce0e8bf8 100644 --- a/spring-cloud-vault-config/src/main/java/org/springframework/cloud/vault/config/SecretBackendFactories.java +++ b/spring-cloud-vault-config/src/main/java/org/springframework/cloud/vault/config/SecretBackendFactories.java @@ -20,7 +20,8 @@ import java.util.ArrayList; import java.util.Collection; import java.util.List; -import lombok.extern.apachecommons.CommonsLog; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; /** * Utility class to create {@link SecretBackendMetadata} from a @@ -28,9 +29,10 @@ import lombok.extern.apachecommons.CommonsLog; * * @author Mark Paluch */ -@CommonsLog final class SecretBackendFactories { + private static final Log log = LogFactory.getLog(SecretBackendFactories.class); + private SecretBackendFactories() { } diff --git a/spring-cloud-vault-config/src/main/java/org/springframework/cloud/vault/config/VaultConfigTemplate.java b/spring-cloud-vault-config/src/main/java/org/springframework/cloud/vault/config/VaultConfigTemplate.java index 0a97ab13..e4946467 100644 --- a/spring-cloud-vault-config/src/main/java/org/springframework/cloud/vault/config/VaultConfigTemplate.java +++ b/spring-cloud-vault-config/src/main/java/org/springframework/cloud/vault/config/VaultConfigTemplate.java @@ -18,7 +18,8 @@ package org.springframework.cloud.vault.config; import java.util.Map; -import lombok.extern.apachecommons.CommonsLog; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.springframework.util.Assert; import org.springframework.vault.VaultException; @@ -33,9 +34,10 @@ import org.springframework.vault.support.VaultResponse; * @author Mark Paluch * @see VaultOperations */ -@CommonsLog public class VaultConfigTemplate implements VaultConfigOperations { + private static final Log log = LogFactory.getLog(VaultConfigTemplate.class); + private final VaultOperations vaultOperations; private final VaultProperties properties; diff --git a/spring-cloud-vault-config/src/main/java/org/springframework/cloud/vault/config/VaultGenericBackendProperties.java b/spring-cloud-vault-config/src/main/java/org/springframework/cloud/vault/config/VaultGenericBackendProperties.java index 876529a2..bf0d1a12 100644 --- a/spring-cloud-vault-config/src/main/java/org/springframework/cloud/vault/config/VaultGenericBackendProperties.java +++ b/spring-cloud-vault-config/src/main/java/org/springframework/cloud/vault/config/VaultGenericBackendProperties.java @@ -18,8 +18,6 @@ package org.springframework.cloud.vault.config; import javax.validation.constraints.NotEmpty; -import lombok.Data; - import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.context.EnvironmentAware; import org.springframework.core.env.Environment; @@ -32,7 +30,6 @@ import org.springframework.validation.annotation.Validated; * @author Mark Paluch */ @ConfigurationProperties("spring.cloud.vault.generic") -@Data @Validated public class VaultGenericBackendProperties implements EnvironmentAware, VaultKeyValueBackendPropertiesSupport { @@ -65,6 +62,9 @@ public class VaultGenericBackendProperties */ private String applicationName = "application"; + public VaultGenericBackendProperties() { + } + @Override public void setEnvironment(Environment environment) { @@ -83,4 +83,57 @@ public class VaultGenericBackendProperties } } + public boolean isEnabled() { + return this.enabled; + } + + public String getBackend() { + return this.backend; + } + + public String getDefaultContext() { + return this.defaultContext; + } + + public String getProfileSeparator() { + return this.profileSeparator; + } + + public String getApplicationName() { + return this.applicationName; + } + + public void setEnabled(boolean enabled) { + this.enabled = enabled; + } + + public void setBackend(String backend) { + this.backend = backend; + } + + public void setDefaultContext(String defaultContext) { + this.defaultContext = defaultContext; + } + + public void setProfileSeparator(String profileSeparator) { + this.profileSeparator = profileSeparator; + } + + public void setApplicationName(String applicationName) { + this.applicationName = applicationName; + } + + @Override + public String toString() { + StringBuffer sb = new StringBuffer(); + sb.append(getClass().getSimpleName()); + sb.append(" [enabled=").append(this.enabled); + sb.append(", backend='").append(this.backend).append('\''); + sb.append(", defaultContext='").append(this.defaultContext).append('\''); + sb.append(", profileSeparator='").append(this.profileSeparator).append('\''); + sb.append(", applicationName='").append(this.applicationName).append('\''); + sb.append(']'); + return sb.toString(); + } + } diff --git a/spring-cloud-vault-config/src/main/java/org/springframework/cloud/vault/config/VaultKeyValueBackendProperties.java b/spring-cloud-vault-config/src/main/java/org/springframework/cloud/vault/config/VaultKeyValueBackendProperties.java index 7afb97a7..88e35f76 100644 --- a/spring-cloud-vault-config/src/main/java/org/springframework/cloud/vault/config/VaultKeyValueBackendProperties.java +++ b/spring-cloud-vault-config/src/main/java/org/springframework/cloud/vault/config/VaultKeyValueBackendProperties.java @@ -18,8 +18,6 @@ package org.springframework.cloud.vault.config; import javax.validation.constraints.NotEmpty; -import lombok.Data; - import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.context.EnvironmentAware; import org.springframework.core.env.Environment; @@ -33,7 +31,6 @@ import org.springframework.validation.annotation.Validated; * @since 2.0 */ @ConfigurationProperties("spring.cloud.vault.kv") -@Data @Validated public class VaultKeyValueBackendProperties implements EnvironmentAware, VaultKeyValueBackendPropertiesSupport { @@ -74,6 +71,9 @@ public class VaultKeyValueBackendProperties */ private int backendVersion = 2; + public VaultKeyValueBackendProperties() { + } + @Override public void setEnvironment(Environment environment) { @@ -92,4 +92,66 @@ public class VaultKeyValueBackendProperties } } + public boolean isEnabled() { + return this.enabled; + } + + public String getBackend() { + return this.backend; + } + + public String getDefaultContext() { + return this.defaultContext; + } + + public String getProfileSeparator() { + return this.profileSeparator; + } + + public String getApplicationName() { + return this.applicationName; + } + + public int getBackendVersion() { + return this.backendVersion; + } + + public void setEnabled(boolean enabled) { + this.enabled = enabled; + } + + public void setBackend(String backend) { + this.backend = backend; + } + + public void setDefaultContext(String defaultContext) { + this.defaultContext = defaultContext; + } + + public void setProfileSeparator(String profileSeparator) { + this.profileSeparator = profileSeparator; + } + + public void setApplicationName(String applicationName) { + this.applicationName = applicationName; + } + + public void setBackendVersion(int backendVersion) { + this.backendVersion = backendVersion; + } + + @Override + public String toString() { + StringBuffer sb = new StringBuffer(); + sb.append(getClass().getSimpleName()); + sb.append(" [enabled=").append(this.enabled); + sb.append(", backend='").append(this.backend).append('\''); + sb.append(", defaultContext='").append(this.defaultContext).append('\''); + sb.append(", profileSeparator='").append(this.profileSeparator).append('\''); + sb.append(", applicationName='").append(this.applicationName).append('\''); + sb.append(", backendVersion=").append(this.backendVersion); + sb.append(']'); + return sb.toString(); + } + } diff --git a/spring-cloud-vault-config/src/main/java/org/springframework/cloud/vault/config/VaultProperties.java b/spring-cloud-vault-config/src/main/java/org/springframework/cloud/vault/config/VaultProperties.java index a336ea62..ecb55340 100644 --- a/spring-cloud-vault-config/src/main/java/org/springframework/cloud/vault/config/VaultProperties.java +++ b/spring-cloud-vault-config/src/main/java/org/springframework/cloud/vault/config/VaultProperties.java @@ -20,9 +20,6 @@ import java.time.Duration; import javax.validation.constraints.NotEmpty; -import lombok.Data; -import org.hibernate.validator.constraints.Range; - import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.context.EnvironmentAware; import org.springframework.core.env.Environment; @@ -42,7 +39,6 @@ import org.springframework.vault.core.lease.LeaseEndpoints; * @author MÃ¥rten Svantesson */ @ConfigurationProperties("spring.cloud.vault") -@Data @Validated public class VaultProperties implements EnvironmentAware { @@ -54,13 +50,13 @@ public class VaultProperties implements EnvironmentAware { /** * Vault server host. */ - @NotEmpty + // @NotEmpty private String host = "localhost"; /** * Vault server port. */ - @Range(min = 1, max = 65535) + // @Range(min = 1, max = 65535) private int port = 8200; /** @@ -135,6 +131,182 @@ public class VaultProperties implements EnvironmentAware { } } + public boolean isEnabled() { + return this.enabled; + } + + public String getHost() { + return this.host; + } + + public int getPort() { + return this.port; + } + + public String getScheme() { + return this.scheme; + } + + public String getUri() { + return this.uri; + } + + public Discovery getDiscovery() { + return this.discovery; + } + + public int getConnectionTimeout() { + return this.connectionTimeout; + } + + public int getReadTimeout() { + return this.readTimeout; + } + + public boolean isFailFast() { + return this.failFast; + } + + public String getToken() { + return this.token; + } + + public AppIdProperties getAppId() { + return this.appId; + } + + public AppRoleProperties getAppRole() { + return this.appRole; + } + + public AwsEc2Properties getAwsEc2() { + return this.awsEc2; + } + + public AwsIamProperties getAwsIam() { + return this.awsIam; + } + + public AzureMsiProperties getAzureMsi() { + return this.azureMsi; + } + + public GcpGceProperties getGcpGce() { + return this.gcpGce; + } + + public GcpIamProperties getGcpIam() { + return this.gcpIam; + } + + public KubernetesProperties getKubernetes() { + return this.kubernetes; + } + + public Ssl getSsl() { + return this.ssl; + } + + public Config getConfig() { + return this.config; + } + + public String getApplicationName() { + return this.applicationName; + } + + public AuthenticationMethod getAuthentication() { + return this.authentication; + } + + public void setEnabled(boolean enabled) { + this.enabled = enabled; + } + + public void setHost(String host) { + this.host = host; + } + + public void setPort(int port) { + this.port = port; + } + + public void setScheme(String scheme) { + this.scheme = scheme; + } + + public void setUri(String uri) { + this.uri = uri; + } + + public void setDiscovery(Discovery discovery) { + this.discovery = discovery; + } + + public void setConnectionTimeout(int connectionTimeout) { + this.connectionTimeout = connectionTimeout; + } + + public void setReadTimeout(int readTimeout) { + this.readTimeout = readTimeout; + } + + public void setFailFast(boolean failFast) { + this.failFast = failFast; + } + + public void setToken(String token) { + this.token = token; + } + + public void setAppId(AppIdProperties appId) { + this.appId = appId; + } + + public void setAppRole(AppRoleProperties appRole) { + this.appRole = appRole; + } + + public void setAwsEc2(AwsEc2Properties awsEc2) { + this.awsEc2 = awsEc2; + } + + public void setAwsIam(AwsIamProperties awsIam) { + this.awsIam = awsIam; + } + + public void setAzureMsi(AzureMsiProperties azureMsi) { + this.azureMsi = azureMsi; + } + + public void setGcpGce(GcpGceProperties gcpGce) { + this.gcpGce = gcpGce; + } + + public void setGcpIam(GcpIamProperties gcpIam) { + this.gcpIam = gcpIam; + } + + public void setKubernetes(KubernetesProperties kubernetes) { + this.kubernetes = kubernetes; + } + + public void setSsl(Ssl ssl) { + this.ssl = ssl; + } + + public void setConfig(Config config) { + this.config = config; + } + + public void setApplicationName(String applicationName) { + this.applicationName = applicationName; + } + + public void setAuthentication(AuthenticationMethod authentication) { + this.authentication = authentication; + } + /** * Enumeration of authentication methods. */ @@ -147,7 +319,6 @@ public class VaultProperties implements EnvironmentAware { /** * Discovery properties. */ - @Data public static class Discovery { /** @@ -166,12 +337,27 @@ public class VaultProperties implements EnvironmentAware { */ private String serviceId = DEFAULT_VAULT; + public boolean isEnabled() { + return this.enabled; + } + + public String getServiceId() { + return this.serviceId; + } + + public void setEnabled(boolean enabled) { + this.enabled = enabled; + } + + public void setServiceId(String serviceId) { + this.serviceId = serviceId; + } + } /** * AppId properties. */ - @Data @Validated public static class AppIdProperties { @@ -206,12 +392,35 @@ public class VaultProperties implements EnvironmentAware { @NotEmpty private String userId = MAC_ADDRESS; + public String getAppIdPath() { + return this.appIdPath; + } + + public String getNetworkInterface() { + return this.networkInterface; + } + + public String getUserId() { + return this.userId; + } + + public void setAppIdPath(String appIdPath) { + this.appIdPath = appIdPath; + } + + public void setNetworkInterface(String networkInterface) { + this.networkInterface = networkInterface; + } + + public void setUserId(String userId) { + this.userId = userId; + } + } /** * AppRole properties. */ - @Data @Validated public static class AppRoleProperties { @@ -235,12 +444,43 @@ public class VaultProperties implements EnvironmentAware { */ private String secretId = null; + public String getAppRolePath() { + return this.appRolePath; + } + + public String getRole() { + return this.role; + } + + public String getRoleId() { + return this.roleId; + } + + public String getSecretId() { + return this.secretId; + } + + public void setAppRolePath(String appRolePath) { + this.appRolePath = appRolePath; + } + + public void setRole(String role) { + this.role = role; + } + + public void setRoleId(String roleId) { + this.roleId = roleId; + } + + public void setSecretId(String secretId) { + this.secretId = secretId; + } + } /** * AWS-EC2 properties. */ - @Data @Validated public static class AwsEc2Properties { @@ -267,12 +507,43 @@ public class VaultProperties implements EnvironmentAware { */ private String nonce; + public String getIdentityDocument() { + return this.identityDocument; + } + + public String getAwsEc2Path() { + return this.awsEc2Path; + } + + public String getRole() { + return this.role; + } + + public String getNonce() { + return this.nonce; + } + + public void setIdentityDocument(String identityDocument) { + this.identityDocument = identityDocument; + } + + public void setAwsEc2Path(String awsEc2Path) { + this.awsEc2Path = awsEc2Path; + } + + public void setRole(String role) { + this.role = role; + } + + public void setNonce(String nonce) { + this.nonce = nonce; + } + } /** * AWS-IAM properties. */ - @Data public static class AwsIamProperties { /** @@ -292,12 +563,35 @@ public class VaultProperties implements EnvironmentAware { */ private String serverName; + public String getAwsPath() { + return this.awsPath; + } + + public String getRole() { + return this.role; + } + + public String getServerName() { + return this.serverName; + } + + public void setAwsPath(String awsPath) { + this.awsPath = awsPath; + } + + public void setRole(String role) { + this.role = role; + } + + public void setServerName(String serverName) { + this.serverName = serverName; + } + } /** * Azure MSI properties. */ - @Data public static class AzureMsiProperties { /** @@ -311,12 +605,27 @@ public class VaultProperties implements EnvironmentAware { */ private String role = ""; + public String getAzurePath() { + return this.azurePath; + } + + public String getRole() { + return this.role; + } + + public void setAzurePath(String azurePath) { + this.azurePath = azurePath; + } + + public void setRole(String role) { + this.role = role; + } + } /** * GCP-GCE properties. */ - @Data public static class GcpGceProperties { /** @@ -335,12 +644,35 @@ public class VaultProperties implements EnvironmentAware { */ private String serviceAccount = ""; + public String getGcpPath() { + return this.gcpPath; + } + + public String getRole() { + return this.role; + } + + public String getServiceAccount() { + return this.serviceAccount; + } + + public void setGcpPath(String gcpPath) { + this.gcpPath = gcpPath; + } + + public void setRole(String role) { + this.role = role; + } + + public void setServiceAccount(String serviceAccount) { + this.serviceAccount = serviceAccount; + } + } /** * GCP-IAM properties. */ - @Data public static class GcpIamProperties { /** @@ -374,12 +706,55 @@ public class VaultProperties implements EnvironmentAware { */ private Duration jwtValidity = Duration.ofMinutes(15); + public GcpCredentials getCredentials() { + return this.credentials; + } + + public String getGcpPath() { + return this.gcpPath; + } + + public String getRole() { + return this.role; + } + + public String getProjectId() { + return this.projectId; + } + + public String getServiceAccountId() { + return this.serviceAccountId; + } + + public Duration getJwtValidity() { + return this.jwtValidity; + } + + public void setGcpPath(String gcpPath) { + this.gcpPath = gcpPath; + } + + public void setRole(String role) { + this.role = role; + } + + public void setProjectId(String projectId) { + this.projectId = projectId; + } + + public void setServiceAccountId(String serviceAccountId) { + this.serviceAccountId = serviceAccountId; + } + + public void setJwtValidity(Duration jwtValidity) { + this.jwtValidity = jwtValidity; + } + } /** * GCP credential properties. */ - @Data public static class GcpCredentials { /** @@ -396,12 +771,27 @@ public class VaultProperties implements EnvironmentAware { */ private String encodedKey; + public Resource getLocation() { + return this.location; + } + + public String getEncodedKey() { + return this.encodedKey; + } + + public void setLocation(Resource location) { + this.location = location; + } + + public void setEncodedKey(String encodedKey) { + this.encodedKey = encodedKey; + } + } /** * Kubernetes properties. */ - @Data public static class KubernetesProperties { /** @@ -421,12 +811,35 @@ public class VaultProperties implements EnvironmentAware { @NotEmpty private String serviceAccountTokenFile = "/var/run/secrets/kubernetes.io/serviceaccount/token"; + public String getKubernetesPath() { + return this.kubernetesPath; + } + + public String getRole() { + return this.role; + } + + public String getServiceAccountTokenFile() { + return this.serviceAccountTokenFile; + } + + public void setKubernetesPath(String kubernetesPath) { + this.kubernetesPath = kubernetesPath; + } + + public void setRole(String role) { + this.role = role; + } + + public void setServiceAccountTokenFile(String serviceAccountTokenFile) { + this.serviceAccountTokenFile = serviceAccountTokenFile; + } + } /** * SSL properties. */ - @Data @Validated public static class Ssl { @@ -456,12 +869,51 @@ public class VaultProperties implements EnvironmentAware { @NotEmpty private String certAuthPath = "cert"; + public Resource getKeyStore() { + return this.keyStore; + } + + public String getKeyStorePassword() { + return this.keyStorePassword; + } + + public Resource getTrustStore() { + return this.trustStore; + } + + public String getTrustStorePassword() { + return this.trustStorePassword; + } + + public String getCertAuthPath() { + return this.certAuthPath; + } + + public void setKeyStore(Resource keyStore) { + this.keyStore = keyStore; + } + + public void setKeyStorePassword(String keyStorePassword) { + this.keyStorePassword = keyStorePassword; + } + + public void setTrustStore(Resource trustStore) { + this.trustStore = trustStore; + } + + public void setTrustStorePassword(String trustStorePassword) { + this.trustStorePassword = trustStorePassword; + } + + public void setCertAuthPath(String certAuthPath) { + this.certAuthPath = certAuthPath; + } + } /** * Property source properties. */ - @Data public static class Config { /** @@ -474,13 +926,28 @@ public class VaultProperties implements EnvironmentAware { private Lifecycle lifecycle = new Lifecycle(); + public int getOrder() { + return this.order; + } + + public Lifecycle getLifecycle() { + return this.lifecycle; + } + + public void setOrder(int order) { + this.order = order; + } + + public void setLifecycle(Lifecycle lifecycle) { + this.lifecycle = lifecycle; + } + } /** * Configuration to Vault lifecycle management (renewal, revocation of tokens and * secrets). */ - @Data public static class Lifecycle { /** @@ -515,6 +982,38 @@ public class VaultProperties implements EnvironmentAware { */ private LeaseEndpoints leaseEndpoints; + public boolean isEnabled() { + return this.enabled; + } + + public Duration getMinRenewal() { + return this.minRenewal; + } + + public Duration getExpiryThreshold() { + return this.expiryThreshold; + } + + public LeaseEndpoints getLeaseEndpoints() { + return this.leaseEndpoints; + } + + public void setEnabled(boolean enabled) { + this.enabled = enabled; + } + + public void setMinRenewal(Duration minRenewal) { + this.minRenewal = minRenewal; + } + + public void setExpiryThreshold(Duration expiryThreshold) { + this.expiryThreshold = expiryThreshold; + } + + public void setLeaseEndpoints(LeaseEndpoints leaseEndpoints) { + this.leaseEndpoints = leaseEndpoints; + } + } } diff --git a/spring-cloud-vault-config/src/main/java/org/springframework/cloud/vault/config/VaultPropertySource.java b/spring-cloud-vault-config/src/main/java/org/springframework/cloud/vault/config/VaultPropertySource.java index 5d062d3e..f2f7b54c 100644 --- a/spring-cloud-vault-config/src/main/java/org/springframework/cloud/vault/config/VaultPropertySource.java +++ b/spring-cloud-vault-config/src/main/java/org/springframework/cloud/vault/config/VaultPropertySource.java @@ -20,7 +20,8 @@ import java.util.LinkedHashMap; import java.util.Map; import java.util.Set; -import lombok.extern.apachecommons.CommonsLog; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.springframework.core.env.EnumerablePropertySource; import org.springframework.util.Assert; @@ -31,9 +32,10 @@ import org.springframework.util.Assert; * @author Spencer Gibb * @author Mark Paluch */ -@CommonsLog class VaultPropertySource extends EnumerablePropertySource { + private static final Log log = LogFactory.getLog(VaultPropertySource.class); + private final boolean failFast; private final SecretBackendMetadata secretBackendMetadata; @@ -93,7 +95,7 @@ class VaultPropertySource extends EnumerablePropertySource strings = this.properties.keySet(); - return strings.toArray(new String[strings.size()]); + return strings.toArray(new String[0]); } } diff --git a/spring-cloud-vault-config/src/main/java/org/springframework/cloud/vault/config/VaultPropertySourceLocatorSupport.java b/spring-cloud-vault-config/src/main/java/org/springframework/cloud/vault/config/VaultPropertySourceLocatorSupport.java index 6a10b4de..2b894426 100644 --- a/spring-cloud-vault-config/src/main/java/org/springframework/cloud/vault/config/VaultPropertySourceLocatorSupport.java +++ b/spring-cloud-vault-config/src/main/java/org/springframework/cloud/vault/config/VaultPropertySourceLocatorSupport.java @@ -22,8 +22,6 @@ import java.util.Collection; import java.util.Collections; import java.util.List; -import lombok.RequiredArgsConstructor; - import org.springframework.cloud.bootstrap.config.PropertySourceLocator; import org.springframework.context.EnvironmentAware; import org.springframework.core.annotation.AnnotationAwareOrderComparator; @@ -210,7 +208,6 @@ public abstract class VaultPropertySourceLocatorSupport implements PropertySourc protected abstract PropertySource createVaultPropertySource( SecretBackendMetadata accessor); - @RequiredArgsConstructor private static class GenericPropertySourceLocatorConfiguration implements EnvironmentAware, PropertySourceLocatorConfiguration { @@ -218,6 +215,11 @@ public abstract class VaultPropertySourceLocatorSupport implements PropertySourc private Environment environment; + GenericPropertySourceLocatorConfiguration( + VaultKeyValueBackendPropertiesSupport genericBackendProperties) { + this.genericBackendProperties = genericBackendProperties; + } + @Override public void setEnvironment(Environment environment) { this.environment = environment; @@ -247,12 +249,15 @@ public abstract class VaultPropertySourceLocatorSupport implements PropertySourc } - @RequiredArgsConstructor private static class WrappedPropertySourceLocatorConfiguration implements PropertySourceLocatorConfiguration { private final List metadata; + WrappedPropertySourceLocatorConfiguration(List metadata) { + this.metadata = metadata; + } + @Override public Collection getSecretBackends() { return this.metadata; diff --git a/spring-cloud-vault-config/src/main/java/org/springframework/cloud/vault/config/VaultReactiveHealthIndicator.java b/spring-cloud-vault-config/src/main/java/org/springframework/cloud/vault/config/VaultReactiveHealthIndicator.java index b1ca397e..bf820d3d 100644 --- a/spring-cloud-vault-config/src/main/java/org/springframework/cloud/vault/config/VaultReactiveHealthIndicator.java +++ b/spring-cloud-vault-config/src/main/java/org/springframework/cloud/vault/config/VaultReactiveHealthIndicator.java @@ -17,11 +17,11 @@ package org.springframework.cloud.vault.config; import java.lang.reflect.UndeclaredThrowableException; +import java.util.Objects; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.ObjectMapper; -import lombok.Data; import reactor.core.publisher.Mono; import org.springframework.boot.actuate.health.AbstractReactiveHealthIndicator; @@ -95,7 +95,6 @@ public class VaultReactiveHealthIndicator extends AbstractReactiveHealthIndicato .map((vaultHealthResponse) -> getHealth(builder, vaultHealthResponse)); } - @Data @JsonIgnoreProperties(ignoreUnknown = true) private static final class VaultHealthImpl implements VaultHealth { @@ -123,6 +122,61 @@ public class VaultReactiveHealthIndicator extends AbstractReactiveHealthIndicato 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 this.initialized == that.initialized && this.sealed == that.sealed + && this.standby == that.standby + && this.serverTimeUtc == that.serverTimeUtc + && Objects.equals(this.version, that.version); + } + + @Override + public int hashCode() { + return Objects.hash(this.initialized, this.sealed, this.standby, + this.serverTimeUtc, this.version); + } + + @Override + public String toString() { + StringBuffer sb = new StringBuffer(); + sb.append(getClass().getSimpleName()); + sb.append(" [initialized=").append(this.initialized); + sb.append(", sealed=").append(this.sealed); + sb.append(", standby=").append(this.standby); + sb.append(", serverTimeUtc=").append(this.serverTimeUtc); + sb.append(", version='").append(this.version).append('\''); + sb.append(']'); + return sb.toString(); + } + } } diff --git a/spring-cloud-vault-config/src/test/java/org/springframework/cloud/vault/config/DiscoveryClientVaultBootstrapConfigurationTests.java b/spring-cloud-vault-config/src/test/java/org/springframework/cloud/vault/config/DiscoveryClientVaultBootstrapConfigurationTests.java index 0226a05b..cff9e627 100644 --- a/spring-cloud-vault-config/src/test/java/org/springframework/cloud/vault/config/DiscoveryClientVaultBootstrapConfigurationTests.java +++ b/spring-cloud-vault-config/src/test/java/org/springframework/cloud/vault/config/DiscoveryClientVaultBootstrapConfigurationTests.java @@ -21,7 +21,6 @@ import java.util.Collections; import java.util.LinkedHashMap; import java.util.Map; -import lombok.Data; import org.junit.Test; import org.mockito.Mockito; @@ -113,7 +112,6 @@ public class DiscoveryClientVaultBootstrapConfigurationTests { } - @Data static class SimpleServiceInstance implements ServiceInstance { private URI uri; @@ -143,6 +141,50 @@ public class DiscoveryClientVaultBootstrapConfigurationTests { } + public URI getUri() { + return this.uri; + } + + public String getHost() { + return this.host; + } + + public int getPort() { + return this.port; + } + + public boolean isSecure() { + return this.secure; + } + + public Map getMetadata() { + return this.metadata; + } + + public String getServiceId() { + return this.serviceId; + } + + public void setHost(String host) { + this.host = host; + } + + public void setPort(int port) { + this.port = port; + } + + public void setSecure(boolean secure) { + this.secure = secure; + } + + public void setMetadata(Map metadata) { + this.metadata = metadata; + } + + public void setServiceId(String serviceId) { + this.serviceId = serviceId; + } + } }