参考网址:
官方文档 https://wiki.jasig.org/display/CASUM/Remember+Me
中文的: http://my.oschina.net/mashiguang/blog/71005
我用的server端版本是3.5.2 --------------------------------------
(1) WEB-INF\deployerConfigContext.xml
在id是AuthenticationManager 的bean中增加 <property name="authenticationMetaDataPopulators"> <list> <bean class="org.jasig.cas.authentication.principal.RememberMeAuthenticationMetaDataPopulator" /> </list> </property>
(2)WEB-INF\login-webflow.xml
原来的: <var name="credentials" class="org.jasig.cas.authentication.principal.UsernamePasswordCredentials" /> 改为: <var name="credentials" class="org.jasig.cas.authentication.principal.RememberMeUsernamePasswordCredentials" />
(3)还是WEB-INF\login-webflow.xml
找到<view-state id="viewLoginForm",添加<binding property="rememberMe" /> 也就是这样: <binder> <binding property="username" /> <binding property="password" /> <binding property="rememberMe" /> </binder>
(4)WEB-INF\spring-configuration\ticketExpirationPolicies.xml
原来是: <bean id="grantingTicketExpirationPolicy" class="org.jasig.cas.ticket.support.TicketGrantingTicketExpirationPolicy" p:maxTimeToLiveInSeconds="${tgt.maxTimeToLiveInSeconds:28800}" p:timeToKillInSeconds="${tgt.timeToKillInSeconds:7200}"/>
改为: <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="2592000000"></constructor-arg> </bean> </property> <property name="rememberMeExpirationPolicy"> <bean class="org.jasig.cas.ticket.support.TimeoutExpirationPolicy"> <constructor-arg index="0" value="2592000000"></constructor-arg> </bean> </property> </bean> 其中,2592000000是毫秒数,也就是30天,也就是remember me,30天内有效。 当然,你不能点退出,30天内直接输入网址就无需登录了。
(5)WEB-INF\spring-configuration\ticketGrantingTicketCookieGenerator.xml
原来是: <bean id="ticketGrantingTicketCookieGenerator" class="org.jasig.cas.web.support.CookieRetrievingCookieGenerator" p:cookieSecure="false" p:cookieMaxAge="-1" p:cookieName="CASTGC" p:cookiePath="/cas" p:rememberMeMaxAge="2592000"/>
改为: <bean id="ticketGrantingTicketCookieGenerator" class="org.jasig.cas.web.support.CookieRetrievingCookieGenerator" p:cookieSecure="false" p:cookieMaxAge="-1" p:cookieName="CASTGC" p:cookiePath="/cas" />
也就是增加p:rememberMeMaxAge="2592000",这个单位是秒数,好像是设置TGT Cookie的有效期吧~~
(6)WEB-INF\view\jsp\default\ui\casLoginView.jsp
表单里增加: <label><input id="rememberMe" name="rememberMe" value="true" tabindex="4" type="checkbox" />记住我</label>
(7)OK了~~
|