[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 Nov 4 19:23:16 EST 2013


Author: scantor
Date: Mon Nov  4 19:23:16 2013
New Revision: 4929

URL: http://svn.shibboleth.net/view/java-identity-provider?rev=4929&view=rev
Log:
IDP-328: Improve error message mapping approach

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/context/AuthenticationErrorContext.java
    trunk/idp-authn-impl/src/test/java/net/shibboleth/idp/authn/impl/ValidateUsernamePasswordAgainstJAASTest.java
    trunk/idp-authn-impl/src/test/java/net/shibboleth/idp/authn/impl/ValidateUsernamePasswordAgainstLDAPTest.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=4929&r1=4928&r2=4929&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 Nov  4 19:23:16 2013
@@ -20,6 +20,7 @@
 import java.security.Principal;
 import java.util.Collection;
 import java.util.Collections;
+import java.util.Map;
 import java.util.Set;
 
 import javax.annotation.Nonnull;
@@ -32,6 +33,7 @@
 import net.shibboleth.idp.authn.context.SubjectCanonicalizationContext;
 import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElements;
 import net.shibboleth.utilities.java.support.annotation.constraint.NotEmpty;
+import net.shibboleth.utilities.java.support.annotation.constraint.NotLive;
 import net.shibboleth.utilities.java.support.annotation.constraint.Unmodifiable;
 import net.shibboleth.utilities.java.support.component.ComponentSupport;
 import net.shibboleth.utilities.java.support.logic.Constraint;
@@ -45,8 +47,9 @@
 import com.google.common.base.Predicates;
 import com.google.common.collect.Collections2;
 import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.Iterables;
-import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
 
 /**
  * A base class for authentication related actions that validate credentials and produce an
@@ -66,20 +69,8 @@
     /** Track whether custom principals have been explicitly set (including the empty set). */
     private boolean principalsAdded;
     
-    /** Error messages indicating an unknown username. */
-    @Nonnull @NonnullElements private Collection<String> unknownUsernameErrors;
-
-    /** Error messages indicating an invalid password. */
-    @Nonnull @NonnullElements private Collection<String> invalidPasswordErrors;
-
-    /** Error messages indicating an expired password. */
-    @Nonnull @NonnullElements private Collection<String> expiredPasswordErrors;
-
-    /** Error messages indicating a locked account. */
-    @Nonnull @NonnullElements private Collection<String> accountLockedErrors;
-
-    /** Error messages indicating a disabled account. */
-    @Nonnull @NonnullElements private Collection<String> accountDisabledErrors;
+    /** Error messages associated with a specific error condition token. */
+    @Nonnull @NonnullElements private Map<String,Collection<String>> classifiedMessages;
     
     /** Predicate to apply when setting AuthenticationResult cacheability. */
     @Nullable private Predicate<ProfileRequestContext> resultCachingPredicate;
@@ -89,20 +80,16 @@
         super();
 
         authenticatedSubject = new Subject();
-        unknownUsernameErrors = Collections.emptyList();
-        invalidPasswordErrors = Collections.emptyList();
-        expiredPasswordErrors = Collections.emptyList();
-        accountLockedErrors = Collections.emptyList();
-        accountDisabledErrors = Collections.emptyList();
-    }
-
-    /**
-     * Get the error messages indicating an unknown username.
-     * 
-     * @return the "unknown username" error messages
-     */
-    @Nonnull @NonnullElements @Unmodifiable public Collection<String> getUnknownUsernameErrors() {
-        return ImmutableList.copyOf(unknownUsernameErrors);
+        classifiedMessages = Collections.emptyMap();
+    }
+
+    /**
+     * Get the error messages classified by specific error conditions.
+     * 
+     * @return classified error message map
+     */
+    @Nonnull @NonnullElements @Unmodifiable @NotLive public Map<String,Collection<String>> getClassifiedErrors() {
+        return ImmutableMap.copyOf(classifiedMessages);
     }
     
     /**
@@ -110,90 +97,18 @@
      * 
      * @param messages the "unknown username" error messages to set
      */
-    public void setUnknownUsernameErrors(@Nonnull @NonnullElements final Collection<String> messages) {
+    public void setClassifiedMessages(@Nonnull @NonnullElements final Map<String,Collection<String>> messages) {
         ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-        

[... 406 lines stripped ...]


More information about the commits mailing list