码迷,mamicode.com
首页 > 其他好文 > 详细

CAS客户端配置

时间:2014-08-01 15:23:42      阅读:217      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   color   os   strong   io   文件   

1. 导出证书

bubuko.com,布布扣  

以上操作会在当前目录产生文件:ssodemo.crt(需要用到的文件请看CAS服务端配置那篇文章)

2. 客户端导入证书

  bubuko.com,布布扣

  以上操作会在jdk安装目录jre\lib\security下产生文件:cacerts

  注意:多台电脑要重复以上操作,每个jdk都要导入这个文件

  另一种导入证书的方法详见:http://www.cnblogs.com/cxyj/p/3884507.html

3. 添加cas客户端jar包到自己需要单点登录的web应用web-inf/lib目录下

  下载地址:http://downloads.jasig.org/cas-clients/

  或者maven配置:

    <dependency>
      <groupId>org.jasig.cas.client</groupId>
      <artifactId>cas-client-core</artifactId>
      <version>3.2.1</version>
   </dependency>

4. 配置web.xml 文件

 <!-- ======================== 单点登录开始 ======================== -->
  <!-- 用于单点退出,该过滤器用于实现单点登出功能,可选配置-->
  <listener>
   <listener-class>org.jasig.cas.client.session.SingleSignOutHttpSessionListener</listener-class>
  </listener>
  <!-- 该过滤器用于实现单点登出功能,可选配置。 -->
  <filter>
   <filter-name>CAS Single Sign Out Filter</filter-name>
   <filter-class>org.jasig.cas.client.session.SingleSignOutFilter</filter-class>
  </filter>
  <filter-mapping>
   <filter-name>CAS Single Sign Out Filter</filter-name>
   <url-pattern>/*</url-pattern>
  </filter-mapping>
  <filter>
   <filter-name>CAS Filter</filter-name>
   <filter-class>org.jasig.cas.client.authentication.AuthenticationFilter</filter-class>
   <init-param>
    <param-name>casServerLoginUrl</param-name>
    <param-value>https://localhost:8443/cas/login</param-value>
   </init-param>
   <init-param>
    <param-name>serverName</param-name>
    <param-value>http://localhost:8080</param-value>
   </init-param>
  </filter>
  <filter-mapping>
   <filter-name>CAS Filter</filter-name>
   <url-pattern>/*</url-pattern>
  </filter-mapping>
  <!-- 该过滤器负责对Ticket的校验工作,必须启用它 -->
  <filter>
   <filter-name>CAS Validation Filter</filter-name>
   <filter-class>
    org.jasig.cas.client.validation.Cas20ProxyReceivingTicketValidationFilter</filter-class>
   <init-param>
    <param-name>casServerUrlPrefix</param-name>
    <param-value>https://localhost:8443/cas</param-value>
   </init-param>
   <init-param>
    <param-name>serverName</param-name>
    <param-value>http://localhost:8080</param-value>
   </init-param>
  </filter>
  <filter-mapping>
   <filter-name>CAS Validation Filter</filter-name>
   <url-pattern>/*</url-pattern>
  </filter-mapping>
  <!--
   该过滤器负责实现HttpServletRequest请求的包裹,
   比如允许开发者通过HttpServletRequest的getRemoteUser()方法获得SSO登录用户的登录名,可选配置。
  -->
  <filter>
   <filter-name>CAS HttpServletRequest Wrapper Filter</filter-name>
   <filter-class>
    org.jasig.cas.client.util.HttpServletRequestWrapperFilter</filter-class>
  </filter>
  <filter-mapping>
   <filter-name>CAS HttpServletRequest Wrapper Filter</filter-name>
   <url-pattern>/*</url-pattern>
  </filter-mapping>
    <!--
  该过滤器使得开发者可以通过org.jasig.cas.client.util.AssertionHolder来获取用户的登录名。
  比如AssertionHolder.getAssertion().getPrincipal().getName()。
  -->
  <filter>
   <filter-name>CAS Assertion Thread Local Filter</filter-name>
   <filter-class>org.jasig.cas.client.util.AssertionThreadLocalFilter</filter-class>
  </filter>
  <filter-mapping>
   <filter-name>CAS Assertion Thread Local Filter</filter-name>
   <url-pattern>/*</url-pattern>
  </filter-mapping>
  <!-- ======================== 单点登录结束 ======================== -->

  以上配置中https://localhost:8443/cas  为cas服务端路径  http://localhost:8080为当前web项目的路径

 

CAS客户端配置,布布扣,bubuko.com

CAS客户端配置

标签:style   blog   http   color   os   strong   io   文件   

原文地址:http://www.cnblogs.com/cxyj/p/3884427.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!