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

noreply at shibboleth.net noreply at shibboleth.net
Thu Dec 5 22:54:39 EST 2013


Author: dfisher
Date: Thu Dec  5 22:54:39 2013
New Revision: 4996

URL: http://svn.shibboleth.net/view/java-identity-provider?rev=4996&view=rev
Log:
Update LDAP authentication to support return attributes and account states.
Add the LDAPResponseContext post authentication.
Update unit test accordingly.
See IDP-113.

Modified:
    trunk/idp-authn-impl/src/main/java/net/shibboleth/idp/authn/impl/ValidateUsernamePasswordAgainstLDAP.java
    trunk/idp-authn-impl/src/test/java/net/shibboleth/idp/authn/impl/ValidateUsernamePasswordAgainstLDAPTest.java

Modified: trunk/idp-authn-impl/src/main/java/net/shibboleth/idp/authn/impl/ValidateUsernamePasswordAgainstLDAP.java
URL: http://svn.shibboleth.net/view/java-identity-provider/trunk/idp-authn-impl/src/main/java/net/shibboleth/idp/authn/impl/ValidateUsernamePasswordAgainstLDAP.java?rev=4996&r1=4995&r2=4996&view=diff
==============================================================================
--- trunk/idp-authn-impl/src/main/java/net/shibboleth/idp/authn/impl/ValidateUsernamePasswordAgainstLDAP.java (original)
+++ trunk/idp-authn-impl/src/main/java/net/shibboleth/idp/authn/impl/ValidateUsernamePasswordAgainstLDAP.java Thu Dec  5 22:54:39 2013
@@ -26,6 +26,7 @@
 import net.shibboleth.idp.authn.AuthnEventIds;
 import net.shibboleth.idp.authn.UsernamePrincipal;
 import net.shibboleth.idp.authn.context.AuthenticationContext;
+import net.shibboleth.idp.authn.context.LDAPResponseContext;
 import net.shibboleth.idp.authn.context.UsernamePasswordContext;
 import net.shibboleth.utilities.java.support.annotation.constraint.NonnullAfterInit;
 import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
@@ -34,12 +35,14 @@
 
 import org.ldaptive.Credential;
 import org.ldaptive.LdapException;
+import org.ldaptive.auth.AccountState;
 import org.ldaptive.auth.AuthenticationRequest;
 import org.ldaptive.auth.AuthenticationResponse;
+import org.ldaptive.auth.AuthenticationResultCode;
 import org.ldaptive.auth.Authenticator;
+import org.ldaptive.jaas.LdapPrincipal;
 import org.opensaml.profile.action.ActionSupport;
 import org.opensaml.profile.action.EventIds;
-import org.opensaml.profile.context.EventContext;
 import org.opensaml.profile.context.ProfileRequestContext;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -52,11 +55,14 @@
  * @event {@link EventIds#INVALID_PROFILE_CTX}
  * @event {@link AuthnEventIds#INVALID_CREDENTIALS}
  * @event {@link AuthnEventIds#NO_CREDENTIALS}
- * @pre <pre>ProfileRequestContext.getSubcontext(AuthenticationContext.class, false).getAttemptedFlow() != null</pre>
- * @post If AuthenticationContext.getSubcontext(UsernamePasswordContext.class, false) != null, then
- * an {@link net.shibboleth.idp.authn.AuthenticationResult} is saved to the {@link AuthenticationContext} on a
- * successful login. On a failed login, the {@link net.shibboleth.idp.authn.AbstractValidationAction#handleError(
- * ProfileRequestContext, AuthenticationContext, Exception, String)} method is called.
+ * @pre <pre>
+ * ProfileRequestContext.getSubcontext(AuthenticationContext.class, false).getAttemptedFlow() != null
+ * </pre>
+ * @post If AuthenticationContext.getSubcontext(UsernamePasswordContext.class, false) != null, then an
+ *       {@link net.shibboleth.idp.authn.AuthenticationResult} is saved to the {@link AuthenticationContext} on a
+ *       successful login. On a failed login, the
+ *       {@link net.shibboleth.idp.authn.AbstractValidationAction#handleError(ProfileRequestContext, AuthenticationContext, String, String)}
+ *       method is called.
  */
 public class ValidateUsernamePasswordAgainstLDAP extends AbstractValidationAction {
 
@@ -69,6 +75,12 @@
     /** LDAP authenticator. */
     @Nonnull private Authenticator authenticator;
 
+    /** Attributes to return from authentication. */
+    @Nullable private String[] returnAttributes;
+
+    /** Authentication response associated with the login. */
+    @Nullable private AuthenticationResponse response;
+
     /**
      * Returns the authenticator.
      * 
@@ -87,6 +99,26 @@
         ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
 
         authenticator = Constraint.isNotNull(auth, "Authenticator cannot be null");
+    }
+
+    /**
+     * Returns the return attributes.
+     * 
+     * @return attribute names
+     */
+    @Nullable public String[] getReturnAttributes() {
+        return returnAttributes;
+    }
+
+    /**
+     * Sets the return attributes.
+     * 
+     * @param attributes attribute names
+     */
+    public void setReturnAttributes(@Nullable final String... attributes) {
+        ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
+
+        returnAttributes = attributes;
     }
 
     /** {@inheritDoc} */
@@ -127,18 +159,44 @@
         try {
             log.debug("{} attempting to authenticate user {}", getLogPrefix(), upContext.getUsername());
             final AuthenticationRequest request =
-                    new AuthenticationRequest(upContext.getUsername(), new Credential(upContext.getPassword()));

[... 293 lines stripped ...]


More information about the commits mailing list