[java-identity-provider COMMIT] in /trunk/idp-authn-api/src: main/java/net/shibboleth/idp/authn/AbstractValidationAct...

noreply at shibboleth.net noreply at shibboleth.net
Mon Sep 16 16:00:41 EDT 2013


Author: scantor
Date: Mon Sep 16 16:00:41 2013
New Revision: 4769

URL: http://svn.shibboleth.net/view/java-identity-provider?rev=4769&view=rev
Log:
Remove some stale classes and fix CS warnings.

Modified:
    trunk/idp-authn-api/src/main/java/net/shibboleth/idp/authn/AbstractValidationAction.java
    trunk/idp-authn-api/src/main/java/net/shibboleth/idp/authn/BaseAuthenticationResultSerializer.java
    trunk/idp-authn-api/src/main/java/net/shibboleth/idp/session/logic/
    trunk/idp-authn-api/src/test/java/net/shibboleth/idp/authn/BaseAuthenticationResultSerializerTest.java

Modified: trunk/idp-authn-api/src/main/java/net/shibboleth/idp/authn/AbstractValidationAction.java
URL: http://svn.shibboleth.net/view/java-identity-provider/trunk/idp-authn-api/src/main/java/net/shibboleth/idp/authn/AbstractValidationAction.java?rev=4769&r1=4768&r2=4769&view=diff
==============================================================================
--- trunk/idp-authn-api/src/main/java/net/shibboleth/idp/authn/AbstractValidationAction.java (original)
+++ trunk/idp-authn-api/src/main/java/net/shibboleth/idp/authn/AbstractValidationAction.java Mon Sep 16 16:00:41 2013
@@ -40,9 +40,11 @@
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import com.google.common.base.Predicate;
 import com.google.common.base.Predicates;
 import com.google.common.collect.Collections2;
 import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Iterables;
 import com.google.common.collect.Lists;
 
 /**
@@ -309,40 +311,42 @@
         
         ActionSupport.buildEvent(profileRequestContext, eventId);
 
-        for (String m : unknownUsernameErrors) {
-            if (e.getMessage().contains(m)) {
-                errorCtx.setUnknownUsername(true);
-                return;
-            }
-        }
-
-        for (String m : invalidPasswordErrors) {
-            if (e.getMessage().contains(m)) {
-                errorCtx.setInvalidPassword(true);
-                return;
-            }
-        }
-
-        for (String m : expiredPasswordErrors) {
-            if (e.getMessage().contains(m)) {
-                errorCtx.setExpiredPassword(true);
-                return;
-            }
-        }
-
-
-        for (String m : accountDisabledErrors) {
-            if (e.getMessage().contains(m)) {
-                errorCtx.setAccountDisabled(true);
-                return;
-            }
-        }
-        
-        for (String m : accountLockedErrors) {
-            if (e.getMessage().contains(m)) {
-                errorCtx.setAccountLocked(true);
-                return;
-            }
+        MessageChecker checker = new MessageChecker(e);
+        
+        if (Iterables.any(unknownUsernameErrors, checker)) {
+            errorCtx.setUnknownUsername(true);
+        } else if (Iterables.any(invalidPasswordErrors, checker)) {
+            errorCtx.setInvalidPassword(true);
+        } else if (Iterables.any(expiredPasswordErrors, checker)) {
+            errorCtx.setExpiredPassword(true);
+        } else if (Iterables.any(accountDisabledErrors, checker)) {
+            errorCtx.setAccountDisabled(true);
+        } else if (Iterables.any(accountLockedErrors, checker)) {
+            errorCtx.setAccountLocked(true);
+        }
+    }
+    
+    /**
+     * A predicate that examines an Exception to see if its error message contains
+     * a particular String.
+     */
+    private class MessageChecker implements Predicate<String> {
+
+        /** Exception to operate on. */
+        private Exception e;
+        
+        /**
+         * Constructor.
+         *
+         * @param ex exception to operate on
+         */
+        public MessageChecker(@Nonnull final Exception ex) {
+            e = ex;
+        }
+        
+        /** {@inheritDoc} */
+        public boolean apply(String input) {
+            return e.getMessage().contains(input);
         }
     }
     

Modified: trunk/idp-authn-api/src/main/java/net/shibboleth/idp/authn/BaseAuthenticationResultSerializer.java
URL: http://svn.shibboleth.net/view/java-identity-provider/trunk/idp-authn-api/src/main/java/net/shibboleth/idp/authn/BaseAuthenticationResultSerializer.java?rev=4769&r1=4768&r2=4769&view=diff
==============================================================================
--- trunk/idp-authn-api/src/main/java/net/shibboleth/idp/authn/BaseAuthenticationResultSerializer.java (original)
+++ trunk/idp-authn-api/src/main/java/net/shibboleth/idp/authn/BaseAuthenticationResultSerializer.java Mon Sep 16 16:00:41 2013
@@ -54,6 +54,10 @@
 import com.google.common.collect.BiMap;
 import com.google.common.collect.HashBiMap;
 import com.google.common.collect.ImmutableBiMap;
+
+// Checkstyle: AbstractClassName OFF
+// My preferred name would be "BasicAuthenticationResultSerializer", but that causes confusion with
+// the term "Basic Authentication" in HTTP.
 
 /**
  * Handles serialization of results that carry only custom {@link Principal} objects of a simple

Modified: trunk/idp-authn-api/src/test/java/net/shibboleth/idp/authn/BaseAuthenticationResultSerializerTest.java

[... 14 lines stripped ...]


More information about the commits mailing list