SSO demo MySQL (CAS)

Source: Internet
Author: User
Tags cas

Basic configuration reference prior to the essay http://www.cnblogs.com/rocky-fang/p/5354947.html

1. Tomcat-cas Modify Configuration

1.1 Find the Deployerconfigcontext.xml under D:\test\sso\tomcat-cas\webapps\cas\WEB-INF, modify the following:

Comment out

    <!--     <bean id= "Primaryauthenticationhandler"          class= " Org.jasig.cas.authentication.AcceptUsersAuthenticationHandler ">        <property name=" Users ">            < map>                <entry key= "Casuser" value= "Mellon"/>            </map>        </property>    </bean >        

Increase

<BeanID= "DataSource"class= "Com.mchange.v2.c3p0.ComboPooledDataSource"P:driverclass= "Com.mysql.jdbc.Driver"P:jdbcurl= "jdbc:mysql://127.0.0.1:3306/cas?useunicode=true&amp;characterencoding=utf-8&amp; Zerodatetimebehavior=converttonull "P:user= "root"P:password= "root" />      <!--Define The Encode method -     <!--<bean id= "Passwordencoder" class= "Org.jasig.cas.authentication.handler.DefaultPasswordEncoder" autowire= " ByName "> <constructor-arg value=" MD5 "/> </bean> -    <BeanID= "Passwordencoder"class= "Org.jasig.cas.authentication.handler.DefaultPasswordEncoder"C:encodingalgorithm= "MD5"p:characterencoding= "UTF-8" />      <BeanID= "Dbauthhandler"class= "Org.jasig.cas.adaptors.jdbc.QueryDatabaseAuthenticationHandler"P:datasource-ref= "DataSource"P:sql= "Select password from user where name=? and used=1"P:passwordencoder-ref= "Passwordencoder"/>

Modify

    <BeanID= "AuthenticationManager"class= "Org.jasig.cas.authentication.PolicyBasedAuthenticationManager">        <Constructor-arg>            <Map>                <!--                   | IMPORTANT |                   Every handler requires a unique name. | If more than one instance of the same handler class are configured, you must explicitly |                   Set its name to something and than its default name (typically, the simple class name).  -                <entryKey-ref= "Proxyauthenticationhandler"Value-ref= "Proxyprincipalresolver" /><!--to<entryKey-ref= "Dbauthhandler"Value-ref= "Primaryprincipalresolver" />                <!--commented out<entry key-ref= "Primaryauthenticationhandler" value-ref= "Primaryprincipalresolver"/> -            </Map>        </Constructor-arg>

1.2 Create a Database build table Insert Data

CREATE DATABASE/*!32312 IF not exists*/' cas '/*!40100 DEFAULT CHARACTER SET GBK */; Use ' CAs ',/*table structure for table ' user ' */drop table IF EXISTS ' user '; CREATE TABLE ' user ' (  ' id ' int (one) ' NOT null auto_increment,  ' name ' varchar (255) is not NULL,  ' password ' varchar ( 255) Not NULL,  ' used ' tinyint (2) is not NULL,  PRIMARY KEY (' id ')) engine=myisam auto_increment=2 DEFAULT CHARSET=GBK /*data for the table ' user ' */insert into  ' user ' (' id ', ' name ', ' Password ', ' used ') VALUES (1, ' Casuser ', ' 9414f9301cdb492b4dcd83f8c711d8bb ', 1);

1.3 Adding a JAR package

2. Testing

Visit https://demo.cdv.com:8443/cas/login

Sign in with Casuser + Mellon

Successful, this time the authentication is from the database query password comparison.

SSO demo MySQL (CAS)

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.