mirror of
https://github.com/spring-projects/spring-security.git
synced 2025-06-25 21:42:17 +00:00
ProviderManager should have a varargs constructor
- Added varargs constructor to ProviderManager. - Added check for null values in AuthenticationProvider list. - Updated ProviderManagerTests to test for null values using both constructors. Fixes gh-7713
This commit is contained in:
parent
df8feb8919
commit
5ce60022d3
@ -15,6 +15,7 @@
|
||||
*/
|
||||
package org.springframework.security.authentication;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@ -104,6 +105,10 @@ public class ProviderManager implements AuthenticationManager, MessageSourceAwar
|
||||
this(providers, null);
|
||||
}
|
||||
|
||||
public ProviderManager(AuthenticationProvider... providers) {
|
||||
this(Arrays.asList(providers), null);
|
||||
}
|
||||
|
||||
public ProviderManager(List<AuthenticationProvider> providers,
|
||||
AuthenticationManager parent) {
|
||||
Assert.notNull(providers, "providers list cannot be null");
|
||||
@ -124,6 +129,9 @@ public class ProviderManager implements AuthenticationManager, MessageSourceAwar
|
||||
throw new IllegalArgumentException(
|
||||
"A parent AuthenticationManager or a list "
|
||||
+ "of AuthenticationProviders is required");
|
||||
} else if (providers.contains(null)) {
|
||||
throw new IllegalArgumentException(
|
||||
"providers list cannot contain null values");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -95,8 +95,13 @@ public class ProviderManagerTests {
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testStartupFailsIfProvidersNotSet() {
|
||||
new ProviderManager(null);
|
||||
public void testStartupFailsIfProvidersNotSetAsList() {
|
||||
new ProviderManager((List<AuthenticationProvider>) null);
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testStartupFailsIfProvidersNotSetAsVarargs() {
|
||||
new ProviderManager((AuthenticationProvider) null);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
Loading…
x
Reference in New Issue
Block a user