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

noreply at shibboleth.net noreply at shibboleth.net
Thu Oct 15 23:45:56 EDT 2015


Author: dfisher
Date: Thu Oct 15 23:45:56 2015
New Revision: 7830

URL: http://svn.shibboleth.net/view/java-identity-provider?rev=7830&view=rev
Log:
IDP-710 ldaptive 1.0.7

Update ValidateUsernamePasswordAgainstLDAP to handle other LDAP results codes.
Added AuthnEventsIds.AUTHN_ERROR for this case.

Modified:
    trunk/idp-authn-api/src/main/java/net/shibboleth/idp/authn/AuthnEventIds.java
    trunk/idp-authn-api/src/main/java/net/shibboleth/idp/authn/context/LDAPResponseContext.java
    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-api/src/main/java/net/shibboleth/idp/authn/AuthnEventIds.java
URL: http://svn.shibboleth.net/view/java-identity-provider/trunk/idp-authn-api/src/main/java/net/shibboleth/idp/authn/AuthnEventIds.java?rev=7830&r1=7829&r2=7830&view=diff
==============================================================================
--- trunk/idp-authn-api/src/main/java/net/shibboleth/idp/authn/AuthnEventIds.java	(original)
+++ trunk/idp-authn-api/src/main/java/net/shibboleth/idp/authn/AuthnEventIds.java	Thu Oct 15 23:45:56 2015
@@ -75,6 +75,9 @@
     /** ID of event returned if authentication throws an exception unrelated to credential validation. */
     @Nonnull @NotEmpty public static final String AUTHN_EXCEPTION = "AuthenticationException";
 
+    /** ID of event returned if authentication produces an error unrelated to credential validation. */
+    @Nonnull @NotEmpty public static final String AUTHN_ERROR = "AuthenticationError";
+
     /** Constructor. */
     private AuthnEventIds() {
     }

Modified: trunk/idp-authn-api/src/main/java/net/shibboleth/idp/authn/context/LDAPResponseContext.java
URL: http://svn.shibboleth.net/view/java-identity-provider/trunk/idp-authn-api/src/main/java/net/shibboleth/idp/authn/context/LDAPResponseContext.java?rev=7830&r1=7829&r2=7830&view=diff
==============================================================================
--- trunk/idp-authn-api/src/main/java/net/shibboleth/idp/authn/context/LDAPResponseContext.java	(original)
+++ trunk/idp-authn-api/src/main/java/net/shibboleth/idp/authn/context/LDAPResponseContext.java	Thu Oct 15 23:45:56 2015
@@ -22,6 +22,8 @@
 import org.ldaptive.auth.AccountState;
 import org.ldaptive.auth.AuthenticationResponse;
 import org.opensaml.messaging.context.BaseContext;
+
+import com.google.common.base.MoreObjects;
 
 /**
  * A context, usually attached to {@link AuthenticationContext}, containing data about an LDAP authentication operation.
@@ -71,4 +73,13 @@
         final AccountState state = authenticationResponse.getAccountState();
         return state != null ? state.getError() != null : false;
     }
+
+    /** {@inheritDoc} */
+    @Override
+    public String toString() {
+        return MoreObjects.toStringHelper(this)
+                .add("authenticationResponse", authenticationResponse)
+                .toString();
+    }
+
 }

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=7830&r1=7829&r2=7830&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 Oct 15 23:45:56 2015
@@ -32,6 +32,7 @@
 
 import org.ldaptive.Credential;
 import org.ldaptive.LdapException;
+import org.ldaptive.ResultCode;
 import org.ldaptive.auth.AccountState;
 import org.ldaptive.auth.AuthenticationRequest;
 import org.ldaptive.auth.AuthenticationResponse;
@@ -161,10 +162,14 @@
                     handleError(profileRequestContext, authenticationContext, String.format("%s:%s:%s",
                             state.getError(), response.getResultCode(), response.getMessage()),
                             AuthnEventIds.ACCOUNT_ERROR);
+                } else if (response.getResultCode() == ResultCode.INVALID_CREDENTIALS) {
+                    handleError(profileRequestContext, authenticationContext,
+                            String.format("%s:%s", response.getResultCode(), response.getMessage()),
+                            AuthnEventIds.INVALID_CREDENTIALS);
                 } else {
                     handleError(profileRequestContext, authenticationContext,
                             String.format("%s:%s", response.getResultCode(), response.getMessage()),
-                            AuthnEventIds.INVALID_CREDENTIALS);
+                            AuthnEventIds.AUTHN_ERROR);
                 }
             }
         } catch (final LdapException e) {


[... 43 lines stripped ...]


More information about the commits mailing list