浏览代码

Stop causing an exception when there is no AuthenticationException to ApplicationEvent mapping. Requested by Brian Moseley on acegisecurity-developer 10 November 2005.

Ben Alex 20 年之前
父节点
当前提交
b1d247835a
共有 1 个文件被更改,包括 9 次插入5 次删除
  1. 9 5
      core/src/main/java/org/acegisecurity/providers/ProviderManager.java

+ 9 - 5
core/src/main/java/org/acegisecurity/providers/ProviderManager.java

@@ -200,7 +200,7 @@ public class ProviderManager extends AbstractAuthenticationManager
             exceptionMappings.put(BadCredentialsException.class.getName(),
                 AuthenticationFailureBadCredentialsEvent.class.getName());
             exceptionMappings.put(UsernameNotFoundException.class.getName(),
-                    AuthenticationFailureBadCredentialsEvent.class.getName());
+                AuthenticationFailureBadCredentialsEvent.class.getName());
             exceptionMappings.put(ConcurrentLoginException.class.getName(),
                 AuthenticationFailureConcurrentLoginEvent.class.getName());
             exceptionMappings.put(ProviderNotFoundException.class.getName(),
@@ -295,10 +295,14 @@ public class ProviderManager extends AbstractAuthenticationManager
             catch (InvocationTargetException ignored) {}
         }
 
-        Assert.notNull(event,
-            "A valid event must be available for the exception "
-            + lastException.getClass().getName());
-        applicationEventPublisher.publishEvent(event);
+        if (event != null) {
+            applicationEventPublisher.publishEvent(event);
+        } else {
+            if (logger.isDebugEnabled()) {
+                logger.debug("No event was found for the exception "
+                    + lastException.getClass().getName());
+            }
+        }
 
         // Throw the exception
         throw lastException;