shiro-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lhazlew...@apache.org
Subject svn commit: r888024 - /incubator/shiro/trunk/core/src/main/java/org/apache/shiro/authc/pam/AtLeastOneSuccessfulStrategy.java
Date Mon, 07 Dec 2009 17:21:40 GMT
Author: lhazlewood
Date: Mon Dec  7 17:21:40 2009
New Revision: 888024

URL: http://svn.apache.org/viewvc?rev=888024&view=rev
Log:
changed exception check for more correct isEmpty call

Modified:
    incubator/shiro/trunk/core/src/main/java/org/apache/shiro/authc/pam/AtLeastOneSuccessfulStrategy.java

Modified: incubator/shiro/trunk/core/src/main/java/org/apache/shiro/authc/pam/AtLeastOneSuccessfulStrategy.java
URL: http://svn.apache.org/viewvc/incubator/shiro/trunk/core/src/main/java/org/apache/shiro/authc/pam/AtLeastOneSuccessfulStrategy.java?rev=888024&r1=888023&r2=888024&view=diff
==============================================================================
--- incubator/shiro/trunk/core/src/main/java/org/apache/shiro/authc/pam/AtLeastOneSuccessfulStrategy.java
(original)
+++ incubator/shiro/trunk/core/src/main/java/org/apache/shiro/authc/pam/AtLeastOneSuccessfulStrategy.java
Mon Dec  7 17:21:40 2009
@@ -21,15 +21,16 @@
 import org.apache.shiro.authc.AuthenticationException;
 import org.apache.shiro.authc.AuthenticationInfo;
 import org.apache.shiro.authc.AuthenticationToken;
+import org.apache.shiro.util.CollectionUtils;
 
 /**
  * <tt>AuthenticationStrategy</tt> implementation that requires <em>at
least one</em> configured realm to
  * successfully process the submitted <tt>AuthenticationToken</tt> during the
log-in attempt.
- *
+ * <p/>
  * <p>This means any number of configured realms do not have to support the submitted
log-in token, or they may
  * be unable to acquire <tt>AuthenticationInfo</tt> for the token, but as long
as at least one can do both, this
  * Strategy implementation will allow the log-in process to be successful.
- *
+ * <p/>
  * <p>Note that this implementation will aggregate the account data from <em>all</em>
successfully consulted
  * realms during the authentication attempt. If you want only the account data from the first
successfully
  * consulted realm and want to ignore all subsequent realms, use the
@@ -50,9 +51,7 @@
     public AuthenticationInfo afterAllAttempts(AuthenticationToken token, AuthenticationInfo
aggregate) throws AuthenticationException {
         //we know if one or more were able to succesfully authenticate if the aggregated
account object does not
         //contain null or empty data:
-        boolean oneOrMoreSuccessful = aggregate != null && (aggregate.getPrincipals()
!= null);
-
-        if (!oneOrMoreSuccessful) {
+        if (aggregate == null || CollectionUtils.isEmpty(aggregate.getPrincipals())) {
             throw new AuthenticationException("Authentication token of type [" + token.getClass()
+ "] " +
                     "could not be authenticated by any configured realms.  Please ensure
that at least one realm can " +
                     "authenticate these tokens.");



Mime
View raw message