From ddd575d321a6e59e9646496f041f6c4775a65dc3 Mon Sep 17 00:00:00 2001 From: Misagh Moayyed Date: Sun, 19 Jul 2015 11:32:18 -0700 Subject: [PATCH 1/2] Moving handler result to the upper class, as it has nothing to do with uid/password --- ...ndPostProcessingAuthenticationHandler.java | 21 +++++++++++++++++++ ...UsernamePasswordAuthenticationHandler.java | 15 ------------- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/cas-server-core/src/main/java/org/jasig/cas/authentication/handler/support/AbstractPreAndPostProcessingAuthenticationHandler.java b/cas-server-core/src/main/java/org/jasig/cas/authentication/handler/support/AbstractPreAndPostProcessingAuthenticationHandler.java index 04b54d4ddc28..5b256cd785d5 100644 --- a/cas-server-core/src/main/java/org/jasig/cas/authentication/handler/support/AbstractPreAndPostProcessingAuthenticationHandler.java +++ b/cas-server-core/src/main/java/org/jasig/cas/authentication/handler/support/AbstractPreAndPostProcessingAuthenticationHandler.java @@ -18,15 +18,20 @@ */ package org.jasig.cas.authentication.handler.support; +import org.jasig.cas.MessageDescriptor; import org.jasig.cas.authentication.AbstractAuthenticationHandler; +import org.jasig.cas.authentication.BasicCredentialMetaData; import org.jasig.cas.authentication.Credential; +import org.jasig.cas.authentication.DefaultHandlerResult; import org.jasig.cas.authentication.HandlerResult; import org.jasig.cas.authentication.PreventedException; +import org.jasig.cas.authentication.principal.Principal; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.security.auth.login.FailedLoginException; import java.security.GeneralSecurityException; +import java.util.List; /** * Abstract authentication handler that allows deployers to utilize the bundled @@ -93,4 +98,20 @@ public final HandlerResult authenticate(final Credential credential) */ protected abstract HandlerResult doAuthentication(final Credential credential) throws GeneralSecurityException, PreventedException; + + /** + * Helper method to construct a handler result + * on successful authentication events. + * + * @param credential the credential on which the authentication was successfully performed. + * Note that this credential instance may be different from what was originally provided + * as transformation of the username may have occurred, if one is in fact defined. + * @param principal the resolved principal + * @param warnings the warnings + * @return the constructed handler result + */ + protected final HandlerResult createHandlerResult(final Credential credential, final Principal principal, + final List warnings) { + return new DefaultHandlerResult(this, new BasicCredentialMetaData(credential), principal, warnings); + } } diff --git a/cas-server-core/src/main/java/org/jasig/cas/authentication/handler/support/AbstractUsernamePasswordAuthenticationHandler.java b/cas-server-core/src/main/java/org/jasig/cas/authentication/handler/support/AbstractUsernamePasswordAuthenticationHandler.java index e3d1f069ca85..72bb1e4ad935 100644 --- a/cas-server-core/src/main/java/org/jasig/cas/authentication/handler/support/AbstractUsernamePasswordAuthenticationHandler.java +++ b/cas-server-core/src/main/java/org/jasig/cas/authentication/handler/support/AbstractUsernamePasswordAuthenticationHandler.java @@ -113,21 +113,6 @@ protected final PasswordPolicyConfiguration getPasswordPolicyConfiguration() { return this.passwordPolicyConfiguration; } - /** - * Helper method to construct a handler result - * on successful authentication events. - * - * @param credential the credential on which the authentication was successfully performed. - * Note that this credential instance may be different from what was originally provided - * as transformation of the username may have occurred, if one is in fact defined. - * @param principal the resolved principal - * @param warnings the warnings - * @return the constructed handler result - */ - protected final HandlerResult createHandlerResult(final Credential credential, final Principal principal, - final List warnings) { - return new DefaultHandlerResult(this, new BasicCredentialMetaData(credential), principal, warnings); - } /** * Sets the PasswordEncoder to be used with this class. * From 32238e2e8fc8a0b7318b26fb556cc71cc5fbd51b Mon Sep 17 00:00:00 2001 From: Misagh Moayyed Date: Sun, 19 Jul 2015 19:46:13 -0700 Subject: [PATCH 2/2] fixed CS issues --- .../AbstractUsernamePasswordAuthenticationHandler.java | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/cas-server-core/src/main/java/org/jasig/cas/authentication/handler/support/AbstractUsernamePasswordAuthenticationHandler.java b/cas-server-core/src/main/java/org/jasig/cas/authentication/handler/support/AbstractUsernamePasswordAuthenticationHandler.java index 72bb1e4ad935..55c62c723d02 100644 --- a/cas-server-core/src/main/java/org/jasig/cas/authentication/handler/support/AbstractUsernamePasswordAuthenticationHandler.java +++ b/cas-server-core/src/main/java/org/jasig/cas/authentication/handler/support/AbstractUsernamePasswordAuthenticationHandler.java @@ -18,12 +18,7 @@ */ package org.jasig.cas.authentication.handler.support; -import java.security.GeneralSecurityException; -import java.util.List; - -import org.jasig.cas.MessageDescriptor; -import org.jasig.cas.authentication.BasicCredentialMetaData; -import org.jasig.cas.authentication.DefaultHandlerResult; +import org.jasig.cas.authentication.Credential; import org.jasig.cas.authentication.HandlerResult; import org.jasig.cas.authentication.PreventedException; import org.jasig.cas.authentication.UsernamePasswordCredential; @@ -31,12 +26,11 @@ import org.jasig.cas.authentication.handler.PasswordEncoder; import org.jasig.cas.authentication.handler.PlainTextPasswordEncoder; import org.jasig.cas.authentication.handler.PrincipalNameTransformer; -import org.jasig.cas.authentication.principal.Principal; import org.jasig.cas.authentication.support.PasswordPolicyConfiguration; -import org.jasig.cas.authentication.Credential; import javax.security.auth.login.AccountNotFoundException; import javax.validation.constraints.NotNull; +import java.security.GeneralSecurityException; /** * Abstract class to override supports so that we don't need to duplicate the