mirror of
https://github.com/spring-projects/spring-security.git
synced 2025-06-26 13:53:14 +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;
|
package org.springframework.security.authentication;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -104,6 +105,10 @@ public class ProviderManager implements AuthenticationManager, MessageSourceAwar
|
|||||||
this(providers, null);
|
this(providers, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ProviderManager(AuthenticationProvider... providers) {
|
||||||
|
this(Arrays.asList(providers), null);
|
||||||
|
}
|
||||||
|
|
||||||
public ProviderManager(List<AuthenticationProvider> providers,
|
public ProviderManager(List<AuthenticationProvider> providers,
|
||||||
AuthenticationManager parent) {
|
AuthenticationManager parent) {
|
||||||
Assert.notNull(providers, "providers list cannot be null");
|
Assert.notNull(providers, "providers list cannot be null");
|
||||||
@ -124,6 +129,9 @@ public class ProviderManager implements AuthenticationManager, MessageSourceAwar
|
|||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
"A parent AuthenticationManager or a list "
|
"A parent AuthenticationManager or a list "
|
||||||
+ "of AuthenticationProviders is required");
|
+ "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)
|
@Test(expected = IllegalArgumentException.class)
|
||||||
public void testStartupFailsIfProvidersNotSet() {
|
public void testStartupFailsIfProvidersNotSetAsList() {
|
||||||
new ProviderManager(null);
|
new ProviderManager((List<AuthenticationProvider>) null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test(expected = IllegalArgumentException.class)
|
||||||
|
public void testStartupFailsIfProvidersNotSetAsVarargs() {
|
||||||
|
new ProviderManager((AuthenticationProvider) null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
Loading…
x
Reference in New Issue
Block a user