mirror of
https://github.com/spring-projects/spring-security.git
synced 2025-06-28 14:52:24 +00:00
Merge branch '6.3.x'
Use explicit types instead of var Closes gh-155537
This commit is contained in:
commit
71f40f2bc4
@ -76,8 +76,8 @@ class InitializeAuthenticationProviderBeanManagerConfigurer extends GlobalAuthen
|
|||||||
+ "using the DSL.", authenticationProviders.size(), beanNames));
|
+ "using the DSL.", authenticationProviders.size(), beanNames));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var authenticationProvider = authenticationProviders.get(0).getBean();
|
AuthenticationProvider authenticationProvider = authenticationProviders.get(0).getBean();
|
||||||
var authenticationProviderBeanName = authenticationProviders.get(0).getName();
|
String authenticationProviderBeanName = authenticationProviders.get(0).getName();
|
||||||
|
|
||||||
auth.authenticationProvider(authenticationProvider);
|
auth.authenticationProvider(authenticationProvider);
|
||||||
this.logger.info(LogMessage.format(
|
this.logger.info(LogMessage.format(
|
||||||
@ -85,19 +85,6 @@ class InitializeAuthenticationProviderBeanManagerConfigurer extends GlobalAuthen
|
|||||||
authenticationProviderBeanName));
|
authenticationProviderBeanName));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return a bean of the requested class if there's just a single registered
|
|
||||||
* component, null otherwise.
|
|
||||||
*/
|
|
||||||
private <T> T getBeanOrNull(Class<T> type) {
|
|
||||||
String[] beanNames = InitializeAuthenticationProviderBeanManagerConfigurer.this.context
|
|
||||||
.getBeanNamesForType(type);
|
|
||||||
if (beanNames.length != 1) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return InitializeAuthenticationProviderBeanManagerConfigurer.this.context.getBean(beanNames[0], type);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return a list of beans of the requested class, along with their names. If
|
* @return a list of beans of the requested class, along with their names. If
|
||||||
* there are no registered beans of that type, the list is empty.
|
* there are no registered beans of that type, the list is empty.
|
||||||
|
@ -89,8 +89,8 @@ class InitializeUserDetailsBeanManagerConfigurer extends GlobalAuthenticationCon
|
|||||||
beanNames));
|
beanNames));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var userDetailsService = userDetailsServices.get(0).getBean();
|
UserDetailsService userDetailsService = userDetailsServices.get(0).getBean();
|
||||||
var userDetailsServiceBeanName = userDetailsServices.get(0).getName();
|
String userDetailsServiceBeanName = userDetailsServices.get(0).getName();
|
||||||
PasswordEncoder passwordEncoder = getBeanOrNull(PasswordEncoder.class);
|
PasswordEncoder passwordEncoder = getBeanOrNull(PasswordEncoder.class);
|
||||||
UserDetailsPasswordService passwordManager = getBeanOrNull(UserDetailsPasswordService.class);
|
UserDetailsPasswordService passwordManager = getBeanOrNull(UserDetailsPasswordService.class);
|
||||||
CompromisedPasswordChecker passwordChecker = getBeanOrNull(CompromisedPasswordChecker.class);
|
CompromisedPasswordChecker passwordChecker = getBeanOrNull(CompromisedPasswordChecker.class);
|
||||||
|
@ -20,6 +20,7 @@ import java.lang.reflect.Modifier;
|
|||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.jupiter.api.extension.ExtendWith;
|
import org.junit.jupiter.api.extension.ExtendWith;
|
||||||
|
import org.mockito.MockedStatic;
|
||||||
import org.mockito.Mockito;
|
import org.mockito.Mockito;
|
||||||
|
|
||||||
import org.springframework.aop.framework.ProxyFactory;
|
import org.springframework.aop.framework.ProxyFactory;
|
||||||
@ -141,7 +142,7 @@ public class AutowireBeanFactoryObjectPostProcessorTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void postProcessWhenObjectIsCgLibProxyAndInNativeImageThenUseExistingBean() {
|
void postProcessWhenObjectIsCgLibProxyAndInNativeImageThenUseExistingBean() {
|
||||||
try (var detector = Mockito.mockStatic(NativeDetector.class)) {
|
try (MockedStatic<NativeDetector> detector = Mockito.mockStatic(NativeDetector.class)) {
|
||||||
given(NativeDetector.inNativeImage()).willReturn(true);
|
given(NativeDetector.inNativeImage()).willReturn(true);
|
||||||
|
|
||||||
ProxyFactory proxyFactory = new ProxyFactory(new MyClass());
|
ProxyFactory proxyFactory = new ProxyFactory(new MyClass());
|
||||||
@ -158,7 +159,7 @@ public class AutowireBeanFactoryObjectPostProcessorTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void postProcessWhenObjectIsCgLibProxyAndInNativeImageAndBeanDoesNotExistsThenIllegalStateException() {
|
void postProcessWhenObjectIsCgLibProxyAndInNativeImageAndBeanDoesNotExistsThenIllegalStateException() {
|
||||||
try (var detector = Mockito.mockStatic(NativeDetector.class)) {
|
try (MockedStatic<NativeDetector> detector = Mockito.mockStatic(NativeDetector.class)) {
|
||||||
given(NativeDetector.inNativeImage()).willReturn(true);
|
given(NativeDetector.inNativeImage()).willReturn(true);
|
||||||
|
|
||||||
ProxyFactory proxyFactory = new ProxyFactory(new MyClass());
|
ProxyFactory proxyFactory = new ProxyFactory(new MyClass());
|
||||||
|
@ -267,7 +267,7 @@ public class LdapUserDetailsManagerTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRoleNamesStartWithCustomRolePrefix() {
|
public void testRoleNamesStartWithCustomRolePrefix() {
|
||||||
var customPrefix = "GROUP_";
|
String customPrefix = "GROUP_";
|
||||||
this.mgr.setRolePrefix(customPrefix);
|
this.mgr.setRolePrefix(customPrefix);
|
||||||
|
|
||||||
this.mgr.setUsernameMapper(new DefaultLdapUsernameToDnMapper("ou=people", "uid"));
|
this.mgr.setUsernameMapper(new DefaultLdapUsernameToDnMapper("ou=people", "uid"));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user