CAS Configuration and custom development

Source: Internet
Author: User

1. Download the CAS server source code

Https://github.com/Jasig/cas/releases

I downloaded the 4.0.1. You can also checkout directly


CAS client:http://downloads.jasig.org/cas-clients/

Version is 3.3.3


2. Unzip the downloaded Cas-4.0.1.zip and execute it in the root directory

MVN Package Install-dmaven.test.skip=true

After execution is complete, you can deploy Cas-server-webapp\target\cas.war to Tomcat


3. Generate a Certificate



Generate certificate

Keytool-genkey-dname "CN=SSO.CAS.COM,OU=CAS,O=CAS,C=CN"-alias cas.com-keypass 123456-keystore Cas.com.keystore- Storepass 123456-validity 180

Export certificate

Keytool-export-file C:\cas.com.crt-keystore cas.com.keystore-storepass 123456-alias cas.com

JDK Import Certificate

Keytool-import-keystore "%java_home%\jre\lib\security\cacerts"-file C:\cas.com.crt


View certificates

Keytool-list-v-keystore "%java_home%\jre\lib\security\lu-cacerts"

Modify the Tomcat conf server.xml:

<connector sslenabled= "true" Clientauth= "false" keystorefile= "Conf/cas.com.keystore" keystorepass= "123456" maxthreads= "port="                     8443 "protocol=" http/1.1 "scheme=" https "secure=" true "sslprotocol=" TLS "/>



4. Developing CAS server

The first type: After downloading the CAS server source code, execute

MVN Eclipse:eclipse
When you import eclipse, you get an error:

Plugin execution not covered by lifecycle Configuration:xxx Plugin

Workaround:

Join the Build-pluginmanagement-plugins node in the Cas-4.0.1\pom.xml:

<plugin><groupid>org.eclipse.m2e</groupid><artifactid>lifecycle-mapping</artifactid ><version>1.0.0</version><configuration> <lifecycleMappingMetadata> < Pluginexecutions> <pluginExecution> <pluginExecutionFilter> <groupid>org.apache.maven. Plugins</groupid> <artifactId>maven-checkstyle-plugin</artifactId> <versionrange>2.1 0</versionrange> <goals> <goal>checkstyle</goal> </goals> </p luginexecutionfilter> <action> <ignore/> </action> </pluginExecution> & Lt;pluginexecution> <pluginExecutionFilter> <groupid>com.mycila.maven-license-plugin</groupi D> <artifactId>maven-license-plugin</artifactId> &LT;VERSIONRANGE&GT;1.9.0&LT;/VERSIONRANGE&G        T <goals> <goal>check</goal> </goals> </pluginExecutionFilter> <action> <ignore/> </ac tion> </pluginExecution> <pluginExecution> <pluginExecutionFilter> <groupid>o Rg.codehaus.mojo</groupid> <artifactId>aspectj-maven-plugin</artifactId> <versionrange& gt;1.4</versionrange> <goals> <goal>compile</goal> </goals> < /pluginexecutionfilter> <action> <ignore/> </action> </pluginExecution> & Lt;/pluginexecutions></lifecyclemappingmetadata></configuration></plugin>


The second method:

Reference: http://jasig.github.io/cas/4.0.x/installation/Maven-Overlay-Installation.html

Download maven Template: Https://github.com/UniconLabs/simple-cas4-overlay-template/archive/master.zip

Import eclipse,import-maven-existing maven projects, add dependency in Pom.xml, support access to database authentication password:


<dependencies> <dependency> <groupId>org.jasig.cas</groupId> <arti Factid>cas-server-webapp</artifactid> <version>${cas.version}</version> <typ e>war</type> <scope>runtime</scope> </dependency> <dependen cy><groupid>org.jasig.cas</groupid><artifactid>cas-server-core</artifactid>< version>${cas.version}</version></dependency><dependency><groupid>org.jasig.cas< /groupid><artifactid>cas-server-support-jdbc</artifactid><version>${cas.version}</ Version></dependency><dependency><groupid>mysql</groupid><artifactid> Mysql-connector-java</artifactid><version>5.1.35</version></dependency><dependency ><groupid>c3p0</groupid><artifactid>c3p0</artifactid><version>${c3p0.version}</version></dependency> <dependency> <groupid>org.springframework</g Roupid> <artifactId>spring-core</artifactId> <version>${spring.version}</ver sion> <scope>compile</scope> </dependency> <dependency> <group Id>javax.validation</groupid> <artifactId>validation-api</artifactId> <version>${java x.validation.version}</version> <scope>compile</scope> </dependency> </dependencies&    Gt <properties> <cas.version>4.0.1</cas.version> &LT;MAVEN.COMPILER.SOURCE&GT;1.7&LT;/MAVEN.C Ompiler.source> <maven.compiler.target>1.7</maven.compiler.target> <project.build.sourceen Coding>utf-8</project.build.sourceencoding> <spring.version>3.2.6.release</spring.version > <jAvax.validation.version>1.0.0.ga</javax.validation.version> <c3p0.version>0.9.1.2</ C3p0.version> </properties>



Modify Deployerconfigcontext.xml:

<bean id= "AuthenticationManager" class= "Org.jasig.cas.authentication.PolicyBasedAuthenticationManager" >        <constructor-arg>            <map>                               <entry key-ref= "Proxyauthenticationhandler" value-ref= " Proxyprincipalresolver "/><!--<entry key-ref=" Primaryauthenticationhandler "value-ref=" Primaryprincipalresolver "/>--><entry key-ref=" Dbauthhandler "value-ref=" PrimaryPrincipalResolver "/>            </map>        </constructor-arg>                <property name= "Authenticationpolicy" >            <bean class= "Org.jasig.cas.authentication.AnyAuthenticationPolicy"/>        </property></bean>

<!--<bean id= "Primaryauthenticationhandler" class= "Org.jasig.cas.authentication.AcceptUsersAuthenticat Ionhandler "> <property name=" Users "> <map> <entry key=" Casuser "value=" Mellon "/> </map> </property> </bean>--><bean id=" DataSource "class=" COM.M Change.v2.c3p0.ComboPooledDataSource "p:driverclass=" Com.mysql.jdbc.Driver "p:jdbcurl=" Jdbc:mysql://localhost :3306/portal_230?useunicode=true&characterencoding=utf8&noaccesstoprocedurebodies=true& Autoreconnect=true&zerodatetimebehavior=converttonull "p:user=" root "p:password=" root "/> <!--password encryption method--& Gt;<bean id= "Passwordencoder" class= "Com.my.cas.authentication.handler.SelfPasswordEncoder" C:encodingalgorit Hm= "SHA1" p:characterencoding= "UTF-8"/><bean id= "Dbauthhandler" class= "Org.jasig.cas.adaptors.jdbc.QueryD Atabaseauthenticationhandler "p:datasource-ref=" DataSource"p:sql=" Select password from Test_user where username=? "p:passwordencoder-ref=" Passwordencoder "/>


One of the

Com.my.cas.authentication.handler.SelfPasswordEncoder

For the custom password encryption class, implement the interface

Org.jasig.cas.authentication.handler.PasswordEncoder



CAS Configuration and custom development

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.