[java-identity-provider COMMIT] in /branches/3.1/idp-authn-impl/src: main/java/net/shibboleth/idp/authn/impl/Validate...

noreply at shibboleth.net noreply at shibboleth.net
Thu Jun 25 11:59:19 EDT 2015


Author: rdw
Date: Thu Jun 25 11:59:18 2015
New Revision: 7607

URL: http://svn.shibboleth.net/view/java-identity-provider?rev=7607&view=rev
Log:
IDP-728
Merge of R7558 
If an account state error is found on successful auth, use error value instead of ACCOUNT_WARNING.
Add unit test.

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

Modified: branches/3.1/idp-authn-impl/src/main/java/net/shibboleth/idp/authn/impl/ValidateUsernamePasswordAgainstLDAP.java
URL: http://svn.shibboleth.net/view/java-identity-provider/branches/3.1/idp-authn-impl/src/main/java/net/shibboleth/idp/authn/impl/ValidateUsernamePasswordAgainstLDAP.java?rev=7607&r1=7606&r2=7607&view=diff
==============================================================================
--- branches/3.1/idp-authn-impl/src/main/java/net/shibboleth/idp/authn/impl/ValidateUsernamePasswordAgainstLDAP.java	(original)
+++ branches/3.1/idp-authn-impl/src/main/java/net/shibboleth/idp/authn/impl/ValidateUsernamePasswordAgainstLDAP.java	Thu Jun 25 11:59:18 2015
@@ -124,24 +124,22 @@
     }
 
     /** {@inheritDoc} */
-    @Override
-    protected void doInitialize() throws ComponentInitializationException {
+    @Override protected void doInitialize() throws ComponentInitializationException {
         super.doInitialize();
-        
+
         if (authenticator == null) {
             throw new ComponentInitializationException("Authenticator cannot be null");
         }
     }
 
     /** {@inheritDoc} */
-    @Override
-    protected boolean doPreExecute(@Nonnull final ProfileRequestContext profileRequestContext,
+    @Override protected boolean doPreExecute(@Nonnull final ProfileRequestContext profileRequestContext,
             @Nonnull final AuthenticationContext authenticationContext) {
-        
+
         if (!super.doPreExecute(profileRequestContext, authenticationContext)) {
             return false;
         }
-        
+
         if (authenticationContext.getAttemptedFlow() == null) {
             log.debug("{} No attempted flow within authentication context", getLogPrefix());
             ActionSupport.buildEvent(profileRequestContext, EventIds.INVALID_PROFILE_CTX);
@@ -168,8 +166,7 @@
     }
 
     /** {@inheritDoc} */
-    @Override
-    protected void doExecute(@Nonnull final ProfileRequestContext profileRequestContext,
+    @Override protected void doExecute(@Nonnull final ProfileRequestContext profileRequestContext,
             @Nonnull final AuthenticationContext authenticationContext) {
         try {
             log.debug("{} Attempting to authenticate user {}", getLogPrefix(), upContext.getUsername());
@@ -183,11 +180,12 @@
                 authenticationContext.getSubcontext(LDAPResponseContext.class, true)
                         .setAuthenticationResponse(response);
                 if (response.getAccountState() != null) {
+                    final AccountState.Error error = response.getAccountState().getError();
                     handleWarning(
                             profileRequestContext,
                             authenticationContext,
-                            String.format("%s:%s:%s", "ACCOUNT_WARNING", response.getResultCode(),
-                                    response.getMessage()), AuthnEventIds.ACCOUNT_WARNING);
+                            String.format("%s:%s:%s", error != null ? error : "ACCOUNT_WARNING",
+                                    response.getResultCode(), response.getMessage()), AuthnEventIds.ACCOUNT_WARNING);
                 }
                 buildAuthenticationResult(profileRequestContext, authenticationContext);
             } else {
@@ -205,8 +203,9 @@
                             state.getError(), response.getResultCode(), response.getMessage()),
                             AuthnEventIds.ACCOUNT_ERROR);
                 } else {
-                    handleError(profileRequestContext, authenticationContext, String.format("%s:%s",
-                            response.getResultCode(), response.getMessage()), AuthnEventIds.INVALID_CREDENTIALS);
+                    handleError(profileRequestContext, authenticationContext,
+                            String.format("%s:%s", response.getResultCode(), response.getMessage()),
+                            AuthnEventIds.INVALID_CREDENTIALS);
                 }
             }
         } catch (LdapException e) {
@@ -216,8 +215,7 @@
     }
 
     /** {@inheritDoc} */
-    @Override
-    @Nonnull protected Subject populateSubject(@Nonnull final Subject subject) {
+    @Override @Nonnull protected Subject populateSubject(@Nonnull final Subject subject) {
         subject.getPrincipals().add(new UsernamePrincipal(upContext.getUsername()));
         subject.getPrincipals().add(new LdapPrincipal(upContext.getUsername(), response.getLdapEntry()));
         return subject;


[... 72 lines stripped ...]


More information about the commits mailing list