Merge remote-tracking branch 'origin/main'

This commit is contained in:
Olga Maciaszek-Sharma
2024-10-14 20:28:01 +02:00
21 changed files with 89 additions and 129 deletions

View File

@@ -1,10 +1,10 @@
{
"dependencies": {
"antora": "3.2.0-alpha.4",
"antora": "3.2.0-alpha.6",
"@antora/atlas-extension": "1.0.0-alpha.2",
"@antora/collector-extension": "1.0.0-alpha.3",
"@antora/collector-extension": "1.0.0-beta.2",
"@asciidoctor/tabs": "1.0.0-beta.6",
"@springio/antora-extensions": "1.11.1",
"@springio/asciidoctor-extensions": "1.0.0-alpha.13"
"@springio/antora-extensions": "1.14.2",
"@springio/asciidoctor-extensions": "1.0.0-alpha.14"
}
}

23
pom.xml
View File

@@ -28,8 +28,7 @@
<properties>
<bintray.package>commons</bintray.package>
<evictor.version>1.0.0</evictor.version>
<!-- Deprecated - reached EOL -->
<spring-security-oauth2-autoconfigure.version>2.5.2</spring-security-oauth2-autoconfigure.version>
<bouncycastle-bcprov-jdk18on.version>1.78.1</bouncycastle-bcprov-jdk18on.version>
</properties>
<build>
<plugins>
@@ -169,21 +168,11 @@
<artifactId>spring-cloud-test-support</artifactId>
<version>${project.version}</version>
</dependency>
<!--<dependency>
<groupId>org.springframework.security.oauth.boot</groupId>
<artifactId>spring-security-oauth2-autoconfigure</artifactId>
<version>${spring-security-oauth2-autoconfigure.version}</version>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-autoconfigure</artifactId>
</exclusion>
</exclusions>
</dependency>-->
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk18on</artifactId>
<version>${bouncycastle-bcprov-jdk18on.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
<modules>

View File

@@ -15,25 +15,9 @@
<name>spring-cloud-commons-dependencies</name>
<description>Spring Cloud Commons Dependencies</description>
<properties>
<spring-security-rsa.version>1.1.5</spring-security-rsa.version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-rsa</artifactId>
<version>${spring-security-rsa.version}</version>
<exclusions>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-crypto</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-commons</artifactId>

View File

@@ -131,11 +131,6 @@
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-crypto</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-rsa</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.integration</groupId>
<artifactId>spring-integration-jmx</artifactId>
@@ -146,25 +141,6 @@
<artifactId>spring-boot-starter-hateoas</artifactId>
<optional>true</optional>
</dependency>
<!--<dependency>
<groupId>org.springframework.security.oauth.boot</groupId>
<artifactId>spring-security-oauth2-autoconfigure</artifactId>
<optional>true</optional>
<exclusions>
<exclusion>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
</exclusion>
<exclusion>
<groupId>com.sun.activation</groupId>
<artifactId>jakarta.activation</artifactId>
</exclusion>
<exclusion>
<groupId>javax.activation</groupId>
<artifactId>javax.activation-api</artifactId>
</exclusion>
</exclusions>
</dependency>-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 the original author or authors.
* Copyright 2012-2024 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.
@@ -72,7 +72,7 @@ public interface ReactiveDiscoveryClient extends Ordered {
* within. We are leaving it with a deprecation in order not to bring downstream
* implementations.
*/
@Deprecated
@Deprecated(forRemoval = true)
default void probe() {
if (LOG.isWarnEnabled()) {
LOG.warn("ReactiveDiscoveryClient#probe has been called. If you're calling this method directly, "

View File

@@ -37,11 +37,28 @@ public class LoadBalancerRestClientBuilderBeanPostProcessor<T extends ClientHttp
private final ApplicationContext context;
/**
* Creates a {@link LoadBalancerRestClientBuilderBeanPostProcessor} instance using a
* provided {@link ClientHttpRequestInterceptor} and application context.
* @param loadBalancerInterceptor a {@link ClientHttpRequestInterceptor} used for
* load-balancing
* @param context {@link ApplicationContext}
* @deprecated in favour of
* {@link LoadBalancerRestClientBuilderBeanPostProcessor#LoadBalancerRestClientBuilderBeanPostProcessor(ObjectProvider, ApplicationContext)}
*/
@Deprecated(forRemoval = true)
public LoadBalancerRestClientBuilderBeanPostProcessor(T loadBalancerInterceptor, ApplicationContext context) {
this.loadBalancerInterceptorProvider = new SimpleObjectProvider<>(loadBalancerInterceptor);
this.context = context;
}
/**
* Creates a {@link LoadBalancerRestClientBuilderBeanPostProcessor} instance using
* interceptor {@link ObjectProvider} and application context.
* @param loadBalancerInterceptorProvider an {@link ObjectProvider} for
* {@link ClientHttpRequestInterceptor} used for load-balancing
* @param context {@link ApplicationContext}
*/
public LoadBalancerRestClientBuilderBeanPostProcessor(ObjectProvider<T> loadBalancerInterceptorProvider,
ApplicationContext context) {
this.loadBalancerInterceptorProvider = loadBalancerInterceptorProvider;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 the original author or authors.
* Copyright 2012-2024 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.
@@ -35,10 +35,10 @@ import org.apache.commons.logging.LogFactory;
/**
* @author Spencer Gibb
* @author Sergey Tsypanov
*/
public class InetUtils implements Closeable {
// TODO: maybe shutdown the thread pool if it isn't being used?
private final ExecutorService executorService;
private final InetUtilsProperties properties;
@@ -47,7 +47,7 @@ public class InetUtils implements Closeable {
public InetUtils(final InetUtilsProperties properties) {
this.properties = properties;
this.executorService = Executors.newSingleThreadExecutor(r -> {
this.executorService = Executors.newCachedThreadPool(r -> {
Thread thread = new Thread(r);
thread.setName(InetUtilsProperties.PREFIX);
thread.setDaemon(true);

View File

@@ -25,12 +25,16 @@ import java.security.UnrecoverableKeyException;
import javax.net.ssl.SSLContext;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hc.core5.ssl.SSLContextBuilder;
import org.springframework.core.io.Resource;
public class SSLContextFactory {
private static Log logger = LogFactory.getLog(SSLContextFactory.class);
private TlsProperties properties;
public SSLContextFactory(TlsProperties properties) {
@@ -39,28 +43,34 @@ public class SSLContextFactory {
public SSLContext createSSLContext() throws GeneralSecurityException, IOException {
SSLContextBuilder builder = new SSLContextBuilder();
char[] keyPassword = properties.keyPassword();
KeyStore keyStore = createKeyStore();
try {
builder.loadKeyMaterial(keyStore, keyPassword);
}
catch (UnrecoverableKeyException e) {
if (keyPassword.length == 0) {
// Retry if empty password, see
// https://rt.openssl.org/Ticket/Display.html?id=1497&user=guest&pass=guest
builder.loadKeyMaterial(keyStore, new char[] { '\0' });
}
else {
throw e;
}
}
KeyStore trust = createTrustStore();
if (trust != null) {
builder.loadTrustMaterial(trust, null);
}
char[] keyPassword = properties.keyPassword();
try {
KeyStore keyStore = createKeyStore();
try {
builder.loadKeyMaterial(keyStore, keyPassword);
}
catch (UnrecoverableKeyException e) {
if (keyPassword.length == 0) {
// Retry if empty password, see
// https://rt.openssl.org/Ticket/Display.html?id=1497&user=guest&pass=guest
builder.loadKeyMaterial(keyStore, new char[] { '\0' });
}
else {
logger.warn("Could not create keystore.", e);
}
}
}
catch (KeyStoreException e) {
logger.warn("Could not create keystore.", e);
}
return builder.build();
}

View File

@@ -166,6 +166,7 @@ class RetryableLoadBalancerExchangeFilterFunctionIntegrationTests {
}
@Test
@Disabled
void correctResponseReturnedAfterRetryingOnNextServiceInstanceWithBackoff() {
loadBalancerProperties.getRetry().getBackoff().setEnabled(true);
loadBalancerProperties.getRetry().setMaxRetriesOnSameServiceInstance(1);

View File

@@ -47,8 +47,8 @@
<artifactId>spring-security-crypto</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-rsa</artifactId>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk18on</artifactId>
<optional>true</optional>
</dependency>
<dependency>

View File

@@ -38,7 +38,12 @@ public class TextEncryptorConfigBootstrapper implements BootstrapRegistryInitial
* RsaSecretEncryptor present.
*/
public static final boolean RSA_IS_PRESENT = ClassUtils
.isPresent("org.springframework.security.rsa.crypto.RsaSecretEncryptor", null);
.isPresent("org.springframework.security.crypto.encrypt.RsaSecretEncryptor", null);
/**
* RsaSecretEncryptor present.
*/
public static final boolean BCPROV_IS_PRESENT = ClassUtils.isPresent("org.bouncycastle.asn1.ASN1Sequence", null);
@Override
public void initialize(BootstrapRegistry registry) {
@@ -50,7 +55,7 @@ public class TextEncryptorConfigBootstrapper implements BootstrapRegistryInitial
context -> context.get(Binder.class)
.bind(KeyProperties.PREFIX, KeyProperties.class)
.orElseGet(KeyProperties::new));
if (RSA_IS_PRESENT) {
if (RSA_IS_PRESENT && BCPROV_IS_PRESENT) {
registry.registerIfAbsent(RsaProperties.class,
context -> context.get(Binder.class)
.bind(RsaProperties.PREFIX, RsaProperties.class)
@@ -69,7 +74,7 @@ public class TextEncryptorConfigBootstrapper implements BootstrapRegistryInitial
if (keyProperties != null) {
beanFactory.registerSingleton("keyProperties", keyProperties);
}
if (RSA_IS_PRESENT) {
if (RSA_IS_PRESENT && BCPROV_IS_PRESENT) {
RsaProperties rsaProperties = bootstrapContext.get(RsaProperties.class);
if (rsaProperties != null) {
beanFactory.registerSingleton("rsaProperties", rsaProperties);

View File

@@ -16,6 +16,8 @@
package org.springframework.cloud.bootstrap.encrypt;
import org.bouncycastle.asn1.ASN1Sequence;
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionOutcome;
@@ -32,8 +34,8 @@ import org.springframework.context.annotation.Conditional;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
import org.springframework.core.type.AnnotatedTypeMetadata;
import org.springframework.security.crypto.encrypt.RsaSecretEncryptor;
import org.springframework.security.crypto.encrypt.TextEncryptor;
import org.springframework.security.rsa.crypto.RsaSecretEncryptor;
import org.springframework.util.StringUtils;
/**
@@ -73,7 +75,7 @@ public class EncryptionBootstrapConfiguration {
@Configuration(proxyBeanMethods = false)
@Conditional(KeyCondition.class)
@ConditionalOnClass(RsaSecretEncryptor.class)
@ConditionalOnClass({ RsaSecretEncryptor.class, ASN1Sequence.class })
@EnableConfigurationProperties
protected static class RsaEncryptionConfiguration {
@@ -93,7 +95,7 @@ public class EncryptionBootstrapConfiguration {
@Configuration(proxyBeanMethods = false)
@Conditional(KeyCondition.class)
@ConditionalOnMissingClass("org.springframework.security.rsa.crypto.RsaSecretEncryptor")
@ConditionalOnMissingClass("org.bouncycastle.asn1.ASN1Sequence")
protected static class VanillaEncryptionConfiguration {
@Autowired

View File

@@ -30,7 +30,7 @@ class EncryptionRuntimeHints implements RuntimeHintsRegistrar {
@Override
public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
hints.reflection()
.registerTypeIfPresent(classLoader, "org.springframework.security.rsa.crypto.RsaSecretEncryptor",
.registerTypeIfPresent(classLoader, "org.springframework.security.crypto.encrypt.RsaSecretEncryptor",
MemberCategory.INVOKE_DECLARED_CONSTRUCTORS);
}

View File

@@ -18,7 +18,7 @@ package org.springframework.cloud.bootstrap.encrypt;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.security.rsa.crypto.RsaAlgorithm;
import org.springframework.security.crypto.encrypt.RsaAlgorithm;
/**
* @author Ryan Baxter

View File

@@ -31,12 +31,14 @@ import org.springframework.context.ApplicationContext;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.core.env.Environment;
import org.springframework.core.env.MutablePropertySources;
import org.springframework.security.crypto.encrypt.KeyStoreKeyFactory;
import org.springframework.security.crypto.encrypt.RsaSecretEncryptor;
import org.springframework.security.crypto.encrypt.TextEncryptor;
import org.springframework.security.rsa.crypto.KeyStoreKeyFactory;
import org.springframework.security.rsa.crypto.RsaSecretEncryptor;
import org.springframework.util.ClassUtils;
import org.springframework.util.StringUtils;
import static org.springframework.cloud.bootstrap.TextEncryptorConfigBootstrapper.BCPROV_IS_PRESENT;
public abstract class TextEncryptorUtils {
/**
@@ -58,7 +60,7 @@ public abstract class TextEncryptorUtils {
.orElseGet(KeyProperties::new);
if (TextEncryptorUtils.keysConfigured(keyProperties)) {
decryptor.setFailOnError(keyProperties.isFailOnError());
if (ClassUtils.isPresent("org.springframework.security.rsa.crypto.RsaSecretEncryptor", null)) {
if (ClassUtils.isPresent("org.springframework.security.crypto.encrypt.RsaSecretEncryptor", null)) {
RsaProperties rsaProperties = binder.bind(RsaProperties.PREFIX, RsaProperties.class)
.orElseGet(RsaProperties::new);
return TextEncryptorUtils.createTextEncryptor(keyProperties, rsaProperties);
@@ -78,7 +80,7 @@ public abstract class TextEncryptorUtils {
registry.registerIfAbsent(TextEncryptor.class, context -> {
KeyProperties keyProperties = context.get(KeyProperties.class);
if (TextEncryptorConfigBootstrapper.keysConfigured(keyProperties)) {
if (TextEncryptorConfigBootstrapper.RSA_IS_PRESENT) {
if (TextEncryptorConfigBootstrapper.RSA_IS_PRESENT && BCPROV_IS_PRESENT) {
RsaProperties rsaProperties = context.get(RsaProperties.class);
return createTextEncryptor(keyProperties, rsaProperties);
}

View File

@@ -17,8 +17,8 @@
package org.springframework.cloud.context.encrypt;
import org.springframework.security.crypto.encrypt.Encryptors;
import org.springframework.security.crypto.encrypt.RsaSecretEncryptor;
import org.springframework.security.crypto.encrypt.TextEncryptor;
import org.springframework.security.rsa.crypto.RsaSecretEncryptor;
/**
* @author Dave Syer

View File

@@ -21,8 +21,8 @@ import org.junit.jupiter.api.Test;
import org.springframework.boot.WebApplicationType;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.security.crypto.encrypt.RsaAlgorithm;
import org.springframework.security.crypto.encrypt.TextEncryptor;
import org.springframework.security.rsa.crypto.RsaAlgorithm;
import static org.assertj.core.api.BDDAssertions.then;

View File

@@ -24,7 +24,7 @@ import org.springframework.aot.hint.RuntimeHints;
import org.springframework.aot.hint.RuntimeHintsRegistrar;
import org.springframework.aot.hint.predicate.RuntimeHintsPredicates;
import org.springframework.core.io.support.SpringFactoriesLoader;
import org.springframework.security.rsa.crypto.RsaSecretEncryptor;
import org.springframework.security.crypto.encrypt.RsaSecretEncryptor;
import org.springframework.util.ClassUtils;
import static org.assertj.core.api.Assertions.assertThat;

View File

@@ -32,7 +32,7 @@ import static org.assertj.core.api.BDDAssertions.then;
/**
* @author Ryan Baxter
*/
@ClassPathExclusions({ "spring-security-rsa*.jar" })
@ClassPathExclusions({ "bcprov-jdk*.jar" })
public class RsaDisabledTests {
private ConfigurableApplicationContext context;
@@ -54,7 +54,7 @@ public class RsaDisabledTests {
}
@Test
public void testLoadBalancedRetryFactoryBean() throws Exception {
public void testNoRsaProperites() throws Exception {
Map<String, RsaProperties> properties = this.context.getBeansOfType(RsaProperties.class);
then(properties.values()).hasSize(0);
}

View File

@@ -84,25 +84,6 @@
</exclusion>
</exclusions>
</dependency>
<!--<dependency>
<groupId>org.springframework.security.oauth.boot</groupId>
<artifactId>spring-security-oauth2-autoconfigure</artifactId>
<optional>true</optional>
<exclusions>
<exclusion>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
</exclusion>
<exclusion>
<groupId>com.sun.activation</groupId>
<artifactId>jakarta.activation</artifactId>
</exclusion>
<exclusion>
<groupId>javax.activation</groupId>
<artifactId>javax.activation-api</artifactId>
</exclusion>
</exclusions>
</dependency>-->
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-core</artifactId>

View File

@@ -30,15 +30,8 @@
<artifactId>spring-cloud-commons</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-rsa</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<!-- Only needed at compile time -->
<scope>compile</scope>
<optional>true</optional>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk18on</artifactId>
</dependency>
</dependencies>
</project>