[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 Jun 11 23:47:02 EDT 2015
Author: dfisher
Date: Thu Jun 11 23:47:02 2015
New Revision: 7558
URL: http://svn.shibboleth.net/view/java-identity-provider?rev=7558&view=rev
Log:
IDP-728
If an account state error is found on successful auth, use error value instead of ACCOUNT_WARNING.
Add unit test.
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=7558&r1=7557&r2=7558&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 Jun 11 23:47:02 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;
Modified: trunk/idp-authn-impl/src/test/java/net/shibboleth/idp/authn/impl/ValidateUsernamePasswordAgainstLDAPTest.java
[... 71 lines stripped ...]
More information about the commits
mailing list