Skip to content

Commit 830f6be

Browse files
authored
Merge branch 'spring-projects:main' into refactor-for-issue#14768
2 parents 3457e76 + 9ba2435 commit 830f6be

File tree

258 files changed

+11672
-2319
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

258 files changed

+11672
-2319
lines changed

.github/workflows/continuous-integration-workflow.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ jobs:
6363
samples_branch=$(cat gradle.properties | grep "samplesBranch=" | awk -F'=' '{print $2}')
6464
./gradlew publishMavenJavaPublicationToLocalRepository
6565
./gradlew cloneRepository -PrepositoryName="spring-projects/spring-security-samples" -Pref="$samples_branch" -PcloneOutputDirectory="$SAMPLES_DIR"
66-
./gradlew --project-dir "$SAMPLES_DIR" --init-script spring-security-ci.gradle -PlocalRepositoryPath="$LOCAL_REPOSITORY_PATH" -PspringSecurityVersion="$version" check
66+
./gradlew --refresh-dependencies --project-dir "$SAMPLES_DIR" --init-script spring-security-ci.gradle -PlocalRepositoryPath="$LOCAL_REPOSITORY_PATH" -PspringSecurityVersion="$version" test integrationTest
6767
check-tangles:
6868
name: Check for Package Tangles
6969
runs-on: ubuntu-latest

.github/workflows/dependabot-auto-merge-forward.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
id: run-auto-merge-forward
3939
uses: spring-io/spring-security-release-tools/.github/actions/auto-merge-forward@actions-v1
4040
with:
41-
branches: ${{ needs.get-supported-branches.outputs.supported_versions }},main
41+
branches: 5.8.x,${{ needs.get-supported-branches.outputs.supported_versions }},main
4242
from-author: dependabot[bot]
4343
notify_result:
4444
name: Check for failures

config/spring-security-config.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ dependencies {
2121
api 'org.springframework:spring-context'
2222
api 'org.springframework:spring-core'
2323

24+
optional project(':spring-security-data')
2425
optional project(':spring-security-ldap')
2526
optional project(':spring-security-messaging')
2627
optional project(path: ':spring-security-saml2-service-provider')
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*
2+
* Copyright 2002-2013 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.security.config;
18+
19+
import org.springframework.beans.factory.Aware;
20+
import org.springframework.beans.factory.DisposableBean;
21+
import org.springframework.beans.factory.InitializingBean;
22+
23+
/**
24+
* Allows initialization of Objects. Typically this is used to call the {@link Aware}
25+
* methods, {@link InitializingBean#afterPropertiesSet()}, and ensure that
26+
* {@link DisposableBean#destroy()} has been invoked.
27+
*
28+
* @param <T> the bound of the types of Objects this {@link ObjectPostProcessor} supports.
29+
* @author Rob Winch
30+
* @since 3.2
31+
*/
32+
public interface ObjectPostProcessor<T> {
33+
34+
static <S> ObjectPostProcessor<S> identity() {
35+
return new ObjectPostProcessor<>() {
36+
@Override
37+
public <O extends S> O postProcess(O object) {
38+
return object;
39+
}
40+
};
41+
}
42+
43+
/**
44+
* Initialize the object possibly returning a modified instance that should be used
45+
* instead.
46+
* @param object the object to initialize
47+
* @return the initialized version of the object
48+
*/
49+
<O extends T> O postProcess(O object);
50+
51+
}

config/src/main/java/org/springframework/security/config/annotation/AbstractConfiguredSecurityBuilder.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import org.apache.commons.logging.LogFactory;
2929

3030
import org.springframework.security.config.Customizer;
31+
import org.springframework.security.config.ObjectPostProcessor;
3132
import org.springframework.security.config.annotation.web.builders.WebSecurity;
3233
import org.springframework.util.Assert;
3334
import org.springframework.web.filter.DelegatingFilterProxy;

config/src/main/java/org/springframework/security/config/annotation/ObjectPostProcessor.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,11 @@
2828
* @param <T> the bound of the types of Objects this {@link ObjectPostProcessor} supports.
2929
* @author Rob Winch
3030
* @since 3.2
31+
* @deprecated please use {@link org.springframework.security.config.ObjectPostProcessor}
32+
* instead
3133
*/
32-
public interface ObjectPostProcessor<T> {
34+
@Deprecated
35+
public interface ObjectPostProcessor<T> extends org.springframework.security.config.ObjectPostProcessor<T> {
3336

3437
/**
3538
* Initialize the object possibly returning a modified instance that should be used

config/src/main/java/org/springframework/security/config/annotation/SecurityConfigurerAdapter.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
import org.springframework.core.GenericTypeResolver;
2323
import org.springframework.core.annotation.AnnotationAwareOrderComparator;
24+
import org.springframework.security.config.ObjectPostProcessor;
2425
import org.springframework.util.Assert;
2526

2627
/**

config/src/main/java/org/springframework/security/config/annotation/authentication/builders/AuthenticationManagerBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
import org.springframework.security.authentication.AuthenticationManager;
2727
import org.springframework.security.authentication.AuthenticationProvider;
2828
import org.springframework.security.authentication.ProviderManager;
29+
import org.springframework.security.config.ObjectPostProcessor;
2930
import org.springframework.security.config.annotation.AbstractConfiguredSecurityBuilder;
30-
import org.springframework.security.config.annotation.ObjectPostProcessor;
3131
import org.springframework.security.config.annotation.SecurityBuilder;
3232
import org.springframework.security.config.annotation.SecurityConfigurer;
3333
import org.springframework.security.config.annotation.authentication.ProviderManagerBuilder;

config/src/main/java/org/springframework/security/config/annotation/authentication/configuration/AuthenticationConfiguration.java

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2022 the original author or authors.
2+
* Copyright 2002-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -28,7 +28,6 @@
2828
import org.springframework.aop.framework.ProxyFactoryBean;
2929
import org.springframework.aop.target.LazyInitTargetSource;
3030
import org.springframework.beans.factory.BeanFactoryUtils;
31-
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
3231
import org.springframework.beans.factory.annotation.Autowired;
3332
import org.springframework.context.ApplicationContext;
3433
import org.springframework.context.ConfigurableApplicationContext;
@@ -40,7 +39,7 @@
4039
import org.springframework.security.authentication.AuthenticationEventPublisher;
4140
import org.springframework.security.authentication.AuthenticationManager;
4241
import org.springframework.security.authentication.DefaultAuthenticationEventPublisher;
43-
import org.springframework.security.config.annotation.ObjectPostProcessor;
42+
import org.springframework.security.config.ObjectPostProcessor;
4443
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
4544
import org.springframework.security.config.annotation.authentication.configurers.provisioning.InMemoryUserDetailsManagerConfigurer;
4645
import org.springframework.security.config.annotation.authentication.configurers.provisioning.JdbcUserDetailsManagerConfigurer;
@@ -57,6 +56,7 @@
5756
* Exports the authentication {@link Configuration}
5857
*
5958
* @author Rob Winch
59+
* @author Ngoc Nhan
6060
* @since 3.2
6161
*
6262
*/
@@ -197,15 +197,6 @@ private AuthenticationManager getAuthenticationManagerBean() {
197197
return lazyBean(AuthenticationManager.class);
198198
}
199199

200-
private static <T> T getBeanOrNull(ApplicationContext applicationContext, Class<T> type) {
201-
try {
202-
return applicationContext.getBean(type);
203-
}
204-
catch (NoSuchBeanDefinitionException notFound) {
205-
return null;
206-
}
207-
}
208-
209200
private static class EnableGlobalAuthenticationAutowiredConfigurer extends GlobalAuthenticationConfigurerAdapter {
210201

211202
private final ApplicationContext context;
@@ -330,12 +321,9 @@ private PasswordEncoder getPasswordEncoder() {
330321
if (this.passwordEncoder != null) {
331322
return this.passwordEncoder;
332323
}
333-
PasswordEncoder passwordEncoder = getBeanOrNull(this.applicationContext, PasswordEncoder.class);
334-
if (passwordEncoder == null) {
335-
passwordEncoder = PasswordEncoderFactories.createDelegatingPasswordEncoder();
336-
}
337-
this.passwordEncoder = passwordEncoder;
338-
return passwordEncoder;
324+
this.passwordEncoder = this.applicationContext.getBeanProvider(PasswordEncoder.class)
325+
.getIfUnique(PasswordEncoderFactories::createDelegatingPasswordEncoder);
326+
return this.passwordEncoder;
339327
}
340328

341329
@Override

config/src/main/java/org/springframework/security/config/annotation/authentication/configuration/InitializeAuthenticationProviderBeanManagerConfigurer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ private <T> List<BeanWithName<T>> getBeansWithName(Class<T> type) {
9494
String[] beanNames = InitializeAuthenticationProviderBeanManagerConfigurer.this.context
9595
.getBeanNamesForType(type);
9696
for (String beanName : beanNames) {
97-
T bean = InitializeAuthenticationProviderBeanManagerConfigurer.this.context.getBean(beanNames[0], type);
97+
T bean = InitializeAuthenticationProviderBeanManagerConfigurer.this.context.getBean(beanName, type);
9898
beanWithNames.add(new BeanWithName<T>(bean, beanName));
9999
}
100100
return beanWithNames;

0 commit comments

Comments
 (0)