File tree 2 files changed +15
-2
lines changed
main/java/org/springframework/security/authentication
test/java/org/springframework/security/authentication 2 files changed +15
-2
lines changed Original file line number Diff line number Diff line change 15
15
*/
16
16
package org .springframework .security .authentication ;
17
17
18
+ import java .util .Arrays ;
18
19
import java .util .Collections ;
19
20
import java .util .List ;
20
21
@@ -104,6 +105,10 @@ public ProviderManager(List<AuthenticationProvider> providers) {
104
105
this (providers , null );
105
106
}
106
107
108
+ public ProviderManager (AuthenticationProvider ... providers ) {
109
+ this (Arrays .asList (providers ), null );
110
+ }
111
+
107
112
public ProviderManager (List <AuthenticationProvider > providers ,
108
113
AuthenticationManager parent ) {
109
114
Assert .notNull (providers , "providers list cannot be null" );
@@ -124,6 +129,9 @@ private void checkState() {
124
129
throw new IllegalArgumentException (
125
130
"A parent AuthenticationManager or a list "
126
131
+ "of AuthenticationProviders is required" );
132
+ } else if (providers .contains (null )) {
133
+ throw new IllegalArgumentException (
134
+ "providers list cannot contain null values" );
127
135
}
128
136
}
129
137
Original file line number Diff line number Diff line change @@ -95,8 +95,13 @@ public void authenticationSucceedsWhenFirstProviderReturnsNullButSecondAuthentic
95
95
}
96
96
97
97
@ Test (expected = IllegalArgumentException .class )
98
- public void testStartupFailsIfProvidersNotSet () {
99
- new ProviderManager (null );
98
+ public void testStartupFailsIfProvidersNotSetAsList () {
99
+ new ProviderManager ((List <AuthenticationProvider >) null );
100
+ }
101
+
102
+ @ Test (expected = IllegalArgumentException .class )
103
+ public void testStartupFailsIfProvidersNotSetAsVarargs () {
104
+ new ProviderManager ((AuthenticationProvider ) null );
100
105
}
101
106
102
107
@ Test
You can’t perform that action at this time.
0 commit comments