1、修改配置文件
1.1、deployerConfigContext.xml
修改WEB-INF/deployerConfigContext.xml,在id为authenticationManager的bean中添加:
<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,添加
<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过期时间和记住密码的时效时间,单位为毫秒。
<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,在对应位置添加以下代码:
<input type="checkbox" name="rememberMe" id="rememberMe" value="true" /> <label for="rememberMe">Remember Me</label>