diff --git a/code/jeeplatform-sso/src/main/java/org/muses/jeeplatform/cas/authentication/security/providers/CostomUsernamePasswordAuthentication.java b/code/jeeplatform-sso/src/main/java/org/muses/jeeplatform/cas/authentication/security/providers/CostomUsernamePasswordAuthentication.java new file mode 100644 index 0000000000000000000000000000000000000000..eb92d161dec18695ca4177e2f91f666fe5ef4b18 --- /dev/null +++ b/code/jeeplatform-sso/src/main/java/org/muses/jeeplatform/cas/authentication/security/providers/CostomUsernamePasswordAuthentication.java @@ -0,0 +1,45 @@ +package org.muses.jeeplatform.cas.authentication.security.providers; + +import org.jasig.cas.authentication.HandlerResult; +import org.jasig.cas.authentication.PreventedException; +import org.jasig.cas.authentication.UsernamePasswordCredential; +import org.jasig.cas.authentication.handler.support.AbstractUsernamePasswordAuthenticationHandler; + +import javax.security.auth.login.FailedLoginException; +import java.security.GeneralSecurityException; + +/** + *
+ * CAS单点登录验证 + *+ * + * @author nicky.ma + *
+ * 修改记录 + * 修改后版本: 修改人: 修改日期: 2019年05月19日 修改内容: + *+ */ +public class CostomUsernamePasswordAuthentication extends AbstractUsernamePasswordAuthenticationHandler { + + + @Override + protected HandlerResult authenticateUsernamePasswordInternal(UsernamePasswordCredential usernamePasswordCredential) throws GeneralSecurityException, PreventedException { + if (usernamePasswordCredential == null) { + throw new FailedLoginException("No user can be accepted because none is defined"); + } + return doAuthentication(usernamePasswordCredential); + } + + /** + * 用户密码验证 + * @param credential + * @return + */ + private HandlerResult doAuthentication(UsernamePasswordCredential credential) { + String username = credential.getUsername(); + String password = credential.getPassword(); + + String fullUserName = username; + return createHandlerResult(credential , this.principalFactory.createPrincipal(username), null); + } +} diff --git a/code/jeeplatform-sso/src/main/webapp/WEB-INF/deployerConfigContext.xml b/code/jeeplatform-sso/src/main/webapp/WEB-INF/deployerConfigContext.xml index fe73ecf052bd5277fd8260eb98629f7f70a86f02..2ba7dd61700802e9b4613f2c07b10d736c71470c 100644 --- a/code/jeeplatform-sso/src/main/webapp/WEB-INF/deployerConfigContext.xml +++ b/code/jeeplatform-sso/src/main/webapp/WEB-INF/deployerConfigContext.xml @@ -15,10 +15,37 @@ http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd"> +