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&characterencoding=utf-8& 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)