CAS(8)Cas记住密码功能

1、修改配置文件

1.1、deployerConfigContext.xml

修改WEB-INF/deployerConfigContext.xml,在id为authenticationManager的bean中添加:

1
2
3
4
5
<property name="authenticationMetaDataPopulators">
<list>
<bean class="org.jasig.cas.authentication.principal.RememberMeAuthenticationMetaDataPopulator"></bean>
</list>
</property>

1.2、login-webflow.xml

修改WEB-INF/login-webflow.xml,添加

1
2
3
4
5
6
<view-state id="viewLoginForm" view="casLoginView" model="credential">
<binder>
<binding property="username" />
<binding property="password" />
<binding property="rememberMe" />
</binder>

1.3、ticketExpirationPolicies.xml

修改WEB-INF/spring-configuration/ticketExpirationPolicies.xml,参数分别为session过期时间和记住密码的时效时间,单位为毫秒。

1
2
3
4
5
6
7
8
9
10
11
12
<bean id="grantingTicketExpirationPolicy" class="org.jasig.cas.ticket.support.RememberMeDelegatingExpirationPolicy">
<property name="sessionExpirationPolicy">
<bean class="org.jasig.cas.ticket.support.TimeoutExpirationPolicy">
<constructor-arg index="0" value="7200000"></constructor-arg>
</bean>
</property>
<property name="rememberMeExpirationPolicy">
<bean class="org.jasig.cas.ticket.support.TimeoutExpirationPolicy">
<constructor-arg index="0" value="7200000"></constructor-arg>
</bean>
</property>
</bean>

2、修改登录页面

cas默认登录页面为WEB-INF/view/jsp/default/ui/casLoginView.jsp,在对应位置添加以下代码:

1
<input type="checkbox" name="rememberMe" id="rememberMe" value="true" /> <label for="rememberMe">Remember Me</label>
>