• Eclipse配置CAS client


    1.新建一个Maven项目

     

    2.Next,选择

     

    3.输入group id 和 artifact id -->  Finish

     

    4.项目创建完成的目录结构

    编辑pom.xml文件,写上依赖

    注意把servlet-api依赖给去掉了,因为Tomcat库中已经有了这个jar包,不去掉会导致冲突,程序无法正常运行。

    不去掉servlet-api依赖的库,可以看到两个包冲突了。

     

     

    5.配置web.xml

     

    <?xml version="1.0" encoding="UTF-8"?>
    <web-app>
      <display-name>Archetype Created Web Application</display-name>
      
      <!-- 单点退出 -->
      <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>
          <filter-name>CAS Authentication Filter</filter-name>
          <filter-class>org.jasig.cas.client.authentication.AuthenticationFilter</filter-class>
          <init-param>
              <param-name>casServerLoginUrl</param-name>
              <param-value>https://rs-pc:8443/cas-server-webapp-3.5.2.1/login</param-value>
          </init-param>
          <init-param>
              <param-name>serverName</param-name>
              <param-value>http://rs-pc:8080</param-value>
          </init-param>
      </filter>
      <filter-mapping>
          <filter-name>CAS Authentication Filter</filter-name>
          <url-pattern>/*</url-pattern>
      </filter-mapping>
      
      <!-- 该filter负责对请求参数ticket进行验证 -->
      <filter>
          <filter-name>CAS Validation Filter</filter-name>
          <filter-class>org.jasig.cas.client.validation.Cas10TicketValidationFilter</filter-class>
          <init-param>
              <param-name>casServerUrlPrefix</param-name>
              <param-value>https://rs-pc:8443/cas-server-webapp-3.5.2.1</param-value>
          </init-param>
          <init-param>
              <param-name>serverName</param-name>
              <param-value>http://rs-pc:8080</param-value>
          </init-param>
      </filter>
      <filter-mapping>
          <filter-name>CAS Validation Filter</filter-name>
          <url-pattern>/*</url-pattern>
      </filter-mapping>
      
      <!-- HttpServletRequest包裹类,支持getUserPrincipal,getRemoteUser方法取得用户信息 -->
      <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>
      
      <!-- 把Assertion信息放在ThreadLocal变量中,不在web层也能获取当前登录信息 -->
      <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>
       
      
    </web-app>

     

     7.让客户端信任服务端生成的证书,首先将服务端生成的证书casserver.cer文件,复制到$JAVA_HOME/Jre/lib/security下,以管理员方式运行cmd,切换到$JAVA_HOME/Jre/lib/security目录下执行命令:

    keytool -import -trustcacerts -alias casclient -storepass changeit -file casserver.cer -keystore cacerts

    提示是否导入证书,输入y,回车即可。

     

    8.右键项目Run As -> Run on Server

     

    要将(Cas Server也运行起来)

  • 相关阅读:
    windows phone 8 更换锁屏界面图片
    Kinect for Windows 入门与开发
    Windows 8 学习
    windows phone 8 锁屏界面 显示应用程序的消息提醒
    Windows 8 如何在后台播放音频
    C# 4.0 的 Visual Studio 2010 示例
    windows phone 页面切换 动画
    Windows Phone 官方示例学习:Short message dictation and web search grammars sample(语音识别,文字语音)
    Windows Phone 官方示例学习:Background Transfer Service Sample(后台传输)
    打日志流程
  • 原文地址:https://www.cnblogs.com/13jhzeng/p/5728977.html
Copyright © 2020-2023  润新知