|
<bean id="casDataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName">
<value>com.mysql.jdbc.Driver</value>
</property>
<property name="url">
<value>jdbc:mysql://192.168.1.22:3306/databaseName?useUnicode=true&useServerPrepStmts=false&characterEncoding=UTF-8&autoReconnect=true</value>
</property>
<property name="username">
<value>root</value>
</property>
<property name="password">
<value>root</value>
</property>
</bean>
添加 cas 服务的验证
D:/server/apache-tomcat-6.0.18/webapps/cas/WEB-INF/deployerConfigContext.xml 配置文件找到下面代码:
|
<bean 、class="org.jasig.cas.authentication.handler.support.SimpleTestUsernamePasswordAuthenticationHandler" />
|
替换为下面代码:
|
<bean class="org.jasig.cas.adaptors.jdbc.QueryDatabaseAuthenticationHandler">
<property name="dataSource" ref="casDataSource" />
<property name="sql" value="select password from tblUser where lower(tblUser.userName) = lower(?) " />
<property name="passwordEncoder" ref="passwordEncoder"/>
<!--- 如果不需要密码加密,可以将上面一句去掉 --->
</bean>
|
取消 https 验证
打开 D:/server/apache-tomcat-6.0.18/webapps/cas/WEB-INF/spring-configuration/ticketGrantingTicketCookieGenerator.xml 配置文件,将 p:cookieSecure="true" 改为p:cookieSecure="false" ,改完后如下:
|
<bean id="ticketGrantingTicketCookieGenerator" class="org.jasig.cas.web.support.CookieRetrievingCookieGenerator"
p:cookieSecure="false"
p:cookieMaxAge="-1"
p:cookieName="CASTGC"
p:cookiePath="/cas" />
|
打开 D:/server/apache-tomcat-6.0.18/webapps/cas/WEB-INF/spring-configuration/warnCookieGenerator.xml配置文件,将 p:cookieSecure="true" 改为 p:cookieSecure="false" ,改完后如下:
|
<bean id="ticketGrantingTicketCookieGenerator" class="org.jasig.cas.web.support.CookieRetrievingCookieGenerator"
p:cookieSecure="false"
p:cookieMaxAge="-1"
p:cookieName="CASTGC"
p:cookiePath="/cas" />
|
打开 D:/server/apache-tomcat-6.0.18/webapps/cas/WEB-INF/deployerConfigContext.xml 配置文件,找到HttpBasedServiceCredentialsAuthenticationHandler 增加 p:requireSecure="false" ,改完后如下:
|
<bean class="org.jasig.cas.authentication.handler.support.HttpBasedServiceCredentialsAuthenticationHandler"
p:httpClient-ref="httpClient" p:requireSecure="false"/>
|
中文登录
打开 D:/server/apache-tomcat-6.0.18/webapps/cas/WEB-INF/web.xml ,增加下面蓝色部分代码:
|
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/spring-configuration/*.xml
/WEB-INF/deployerConfigContext.xml
</param-value>
</context-param>
<filter>
<filter-name>encoding-filter</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>encoding-filter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
|
这个时候启动 tomcat , cas 可以和你配置的数据库进行交互。
http://localhost:8080/cas 输入配置数据库中的 tblUser 表中的用户名密码即可以登录。
配置 session 有效时间
打开配置文件 D:/server/apache-tomcat-6.0.18/webapps/cas/WEB-INF/spring-configuration/ticketExpirationPolicies.xml ,配置文件很简单,分别是修改 serviceTicket 和 grantingTicket 。
|