浏览代码

SEC-1317: Removed check in ProviderManager.getProviders() for empty provider list. A ProviderManager with a non-null parent may have an empty provider list. The afterPropertiesSet() method performs the necessary checks.

Luke Taylor 15 年之前
父节点
当前提交
02a9db7bcf

+ 2 - 5
core/src/main/java/org/springframework/security/authentication/ProviderManager.java

@@ -178,10 +178,6 @@ public class ProviderManager extends AbstractAuthenticationManager implements Me
     }
 
     public List<AuthenticationProvider> getProviders() {
-        if (providers == null || providers.size() == 0) {
-            throw new IllegalArgumentException("A list of AuthenticationProviders is required");
-        }
-
         return providers;
     }
 
@@ -194,6 +190,7 @@ public class ProviderManager extends AbstractAuthenticationManager implements Me
     }
 
     public void setAuthenticationEventPublisher(AuthenticationEventPublisher eventPublisher) {
+        Assert.notNull(eventPublisher, "AuthenticationEventPublisher cannot be null");
         this.eventPublisher = eventPublisher;
     }
 
@@ -207,7 +204,7 @@ public class ProviderManager extends AbstractAuthenticationManager implements Me
      */
     @SuppressWarnings("unchecked")
     public void setProviders(List providers) {
-        Assert.notNull(providers);
+        Assert.notNull(providers, "Providers list cannot be null");
         for(Object currentObject : providers) {
             Assert.isInstanceOf(AuthenticationProvider.class, currentObject, "Can only provide AuthenticationProvider instances");
         }

+ 0 - 6
core/src/test/java/org/springframework/security/authentication/ProviderManagerTests.java

@@ -85,12 +85,6 @@ public class ProviderManagerTests {
         mgr.setProviders(providers);
     }
 
-    @Test(expected=IllegalArgumentException.class)
-    public void getProvidersFailsIfProviderListNotSet() throws Exception {
-        ProviderManager mgr = new ProviderManager();
-        mgr.getProviders();
-    }
-
     @Test(expected=IllegalArgumentException.class)
     public void testStartupFailsIfProvidersNotSet() throws Exception {
         ProviderManager mgr = new ProviderManager();