[心缘地方]同学录
首页 | 功能说明 | 站长通知 | 最近更新 | 编码查看转换 | 代码下载 | 常见问题及讨论 | 《深入解析ASP核心技术》 | 王小鸭自动发工资条VBA版
登录系统:用户名: 密码: 如果要讨论问题,请先注册。

[整理]CAS单点登录,remember me功能的设置~~

上一篇:[备忘]VB6字符串编码,转换
下一篇:[转帖]Git的windows客户端,总让输入用户名和密码的问题~~

添加日期:2013/11/21 15:56:32 快速返回   返回列表 阅读7561次

参考网址:

官方文档
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了~~
 

评论 COMMENTS
没有评论 No Comments.

添加评论 Add new comment.
昵称 Name:
评论内容 Comment:
验证码(不区分大小写)
Validation Code:
(not case sensitive)
看不清?点这里换一张!(Change it here!)
 
评论由管理员查看后才能显示。the comment will be showed after it is checked by admin.
CopyRight © 心缘地方 2005-2999. All Rights Reserved