搭建CAS单点登录服务器

  最近公司的一个项目需要用到单点登录的功能,之前对单点登录了解得不多。于是网上找了下单点登录的解决方案,发现CAS是个不错的解决方案。于是搭个环境测试了一下。这里记录下测试的详细步骤。

  官网:http://jasig.github.io/cas/

  Cas Server下载:http://developer.jasig.org/cas/

  Cas Client下载:http://developer.jasig.org/cas-clients/

  测试环境:

    jdk:java version "1.8.0_60"

    tomcat:apache-tomcat-7.0.65

    mysql:mysql5.5.40

    CAS Server:cas-server-4.0.0-release.zip

    CAS Client:cas-client-3.1.12-release.zip

  此教程是在jdk和tomcat成功安装的基础上完成,至于jdk和tomcat的安装大家可以网上找找资料。好吧,下面入正题。

  一、生成证书

  1、生成证书:

    keytool -genkey -alias castest -keyalg RSA -keystore F:/keys/castest

    生成一个别名为castest的证书。

    此处需要特别注意口令(后续导入导出证书、CAS服务器端均要用到此口类)和“名字与姓氏”(为CAS跳转域名,否则会报错)

    

  2、导出证书:

    keytool -export -file F:/keys/castest.crt -alias castest -keystore F:/keys/castest

  3、将证书导入到客户端JRE中(注意、是导入JRE中),如果security中已经存在cacerts,需要先将其删除。

    keytool -import -keystore "D:\Program Files\Java\jdk1.8.0_60\jre\lib\security\cacerts" -file F:/keys/castest.crt -alias castest

  二、配置服务器端

  1、从http://developer.jasig.org/cas/上下载cas服务器端cas-server-4.0.0-release.zip,在modules目录下找到cas-server-webapp-4.0.0.war,将其复制到%TOMCAT_HOME%\webapps下,并将名称改为cas.war

  2、修改%TOMCAT_HOME%\conf\server.xml文件,去掉此文件83到93行之间的注释,修改为:

<Connector SSLEnabled="true" clientAuth="false" keystoreFile="F:/keys/castest" >
keystorePass="castest" —证书密码-->
maxThreads="150" port="8443" protocol="org.apache.coyote.http11.Http11Protocol" scheme="https" secure="true" sslProtocol="TLS"/>

  3、测试:https://localhost:8443/

  

  点击继续浏览此网页

  

  如果此时可以正常访问,说明证书安装成功

  https://localhost:8443/cas/login,出现

  

  输入账号和密码

  casuser
  Mellon

  

  此时说明服务器端已经配置成功。可通过https://localhost:8443/cas/logout退出登录

  三、配置客户端

  1. 从http://developer.jasig.org/cas-clients/上下载cas-client-3.1.12-release.zip,在modules目录下找到cas-client-core-3.1.12.jar、commons-collections-3.2.jar、commons-logging-1.1.jar复制到项目WEB-INF/lib下

  2. 添加映射域名,在C:\Windows\System32\drivers\etc\hosts文件中添加

    127.0.0.1 sso.castest.com
  3. 创建web项目CasClient,并在项目的web.xml配置过滤器

复制代码
xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">

        <display-name>cas-demodisplay-name>
        
        
        
        <listener>
                <listener-class>org.jasig.cas.client.session.SingleSignOutHttpSessionListenerlistener-class>
        listener>

        
        <filter>
                <filter-name>CAS Single Sign Out Filterfilter-name>
                <filter-class>org.jasig.cas.client.session.SingleSignOutFilterfilter-class>
        filter>
        <filter-mapping>
                <filter-name>CAS Single Sign Out Filterfilter-name>
                <url-pattern>/CasClient/*url-pattern>
        filter-mapping>

        
        <filter>
                <filter-name>CASFilterfilter-name>
                <filter-class>org.jasig.cas.client.authentication.AuthenticationFilterfilter-class>
                <init-param>
                        <param-name>casServerLoginUrlparam-name>
                        <param-value>https://sso.castest.com:8443/cas/loginparam-value>
                        
                init-param>
                <init-param>
                        <param-name>serverNameparam-name>
                        <param-value>http://localhost:8080param-value>
                init-param>
        filter>
        <filter-mapping>
                <filter-name>CASFilterfilter-name>
                <url-pattern>/*url-pattern>
        filter-mapping>

        
        <filter>
                <filter-name>CAS Validation Filterfilter-name>
                <filter-class>
                        org.jasig.cas.client.validation.Cas20ProxyReceivingTicketValidationFilterfilter-class>
                <init-param>
                        <param-name>casServerUrlPrefixparam-name>
                        <param-value>https://sso.castest.com:8443/cas/param-value>
                init-param>
                <init-param>
                        <param-name>serverNameparam-name>
                        <param-value>http://localhost:8080param-value>
                init-param>
        filter>
        <filter-mapping>
                <filter-name>CAS Validation Filterfilter-name>
                <url-pattern>/*url-pattern>
        filter-mapping>

        
        <filter>
                <filter-name>CAS HttpServletRequest Wrapper Filterfilter-name>
                <filter-class>
                        org.jasig.cas.client.util.HttpServletRequestWrapperFilterfilter-class>
        filter>
        <filter-mapping>
                <filter-name>CAS HttpServletRequest Wrapper Filterfilter-name>
                <url-pattern>/*url-pattern>
        filter-mapping>

        
        <filter>
                <filter-name>CAS Assertion Thread Local Filterfilter-name>
                <filter-class>org.jasig.cas.client.util.AssertionThreadLocalFilterfilter-class>
        filter>
        <filter-mapping>
                <filter-name>CAS Assertion Thread Local Filterfilter-name>
                <url-pattern>/*url-pattern>
        filter-mapping>
        
        

        
        <session-config>
                <session-timeout>2session-timeout>
        session-config>

web-app>
复制代码

  4. 此时访问http://localhost:8080/CasClient/Index.jsp时会自动跳转到sso.castest.com下去登录

  

  输入账号和密码casuser:Mellon

  

  此时客户端已安装成功。

  可以用类似的方式新建多个站点,站点1登录以后站点而无需登录也可访问,如果未登录则会跳转到相应的url进行登录验证。

  至此,简单的服务器搭建已经完成了。然而,此时用户的验证是通过配置文件cas\WEB-INF\deployerConfigContext.xml中指定用户名和密码的方式进行验证的。显然这不满足我们日常的需求,今天先介绍到这。下面再另行介绍通过mysql数据库验证的方式。

---------------------------------------------------------------------------------我是分割线--------------------------------------------------------------------------

to be a better me, talk is cheap show me the code

版权所有,转载请注明原文链接。

文中有不妥或者错误的地方还望指出,以免误人子弟。如果觉得本文对你有所帮助不妨【推荐】一下!如果你有更好的建议,可以给我留言讨论,共同进步!

再次感谢您耐心的读完本篇文章。


http://www.cnblogs.com/rwxwsblog/p/4954795.html  

最近公司的一个项目需要用到单点登录的功能,之前对单点登录了解得不多。于是网上找了下单点登录的解决方案,发现CAS是个不错的解决方案。于是搭个环境测试了一下。这里记录下测试的详细步骤。

  官网:http://jasig.github.io/cas/

  Cas Server下载:http://developer.jasig.org/cas/

  Cas Client下载:http://developer.jasig.org/cas-clients/

  测试环境:

    jdk:java version "1.8.0_60"

    tomcat:apache-tomcat-7.0.65

    mysql:mysql5.5.40

    CAS Server:cas-server-4.0.0-release.zip

    CAS Client:cas-client-3.1.12-release.zip

  此教程是在jdk和tomcat成功安装的基础上完成,至于jdk和tomcat的安装大家可以网上找找资料。好吧,下面入正题。

  一、生成证书

  1、生成证书:

    keytool -genkey -alias castest -keyalg RSA -keystore F:/keys/castest

    生成一个别名为castest的证书。

    此处需要特别注意口令(后续导入导出证书、CAS服务器端均要用到此口类)和“名字与姓氏”(为CAS跳转域名,否则会报错)

    

  2、导出证书:

    keytool -export -file F:/keys/castest.crt -alias castest -keystore F:/keys/castest

  3、将证书导入到客户端JRE中(注意、是导入JRE中),如果security中已经存在cacerts,需要先将其删除。

    keytool -import -keystore "D:\Program Files\Java\jdk1.8.0_60\jre\lib\security\cacerts" -file F:/keys/castest.crt -alias castest

  二、配置服务器端

  1、从http://developer.jasig.org/cas/上下载cas服务器端cas-server-4.0.0-release.zip,在modules目录下找到cas-server-webapp-4.0.0.war,将其复制到%TOMCAT_HOME%\webapps下,并将名称改为cas.war

  2、修改%TOMCAT_HOME%\conf\server.xml文件,去掉此文件83到93行之间的注释,修改为:

<Connector SSLEnabled="true" clientAuth="false" keystoreFile="F:/keys/castest" >
keystorePass="castest" —证书密码-->
maxThreads="150" port="8443" protocol="org.apache.coyote.http11.Http11Protocol" scheme="https" secure="true" sslProtocol="TLS"/>

  3、测试:https://localhost:8443/

  

  点击继续浏览此网页

  

  如果此时可以正常访问,说明证书安装成功

  https://localhost:8443/cas/login,出现

  

  输入账号和密码

  casuser
  Mellon

  

  此时说明服务器端已经配置成功。可通过https://localhost:8443/cas/logout退出登录

  三、配置客户端

  1. 从http://developer.jasig.org/cas-clients/上下载cas-client-3.1.12-release.zip,在modules目录下找到cas-client-core-3.1.12.jar、commons-collections-3.2.jar、commons-logging-1.1.jar复制到项目WEB-INF/lib下

  2. 添加映射域名,在C:\Windows\System32\drivers\etc\hosts文件中添加

    127.0.0.1 sso.castest.com
  3. 创建web项目CasClient,并在项目的web.xml配置过滤器

复制代码
xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">

        <display-name>cas-demodisplay-name>
        
        
        
        <listener>
                <listener-class>org.jasig.cas.client.session.SingleSignOutHttpSessionListenerlistener-class>
        listener>

        
        <filter>
                <filter-name>CAS Single Sign Out Filterfilter-name>
                <filter-class>org.jasig.cas.client.session.SingleSignOutFilterfilter-class>
        filter>
        <filter-mapping>
                <filter-name>CAS Single Sign Out Filterfilter-name>
                <url-pattern>/CasClient/*url-pattern>
        filter-mapping>

        
        <filter>
                <filter-name>CASFilterfilter-name>
                <filter-class>org.jasig.cas.client.authentication.AuthenticationFilterfilter-class>
                <init-param>
                        <param-name>casServerLoginUrlparam-name>
                        <param-value>https://sso.castest.com:8443/cas/loginparam-value>
                        
                init-param>
                <init-param>
                        <param-name>serverNameparam-name>
                        <param-value>http://localhost:8080param-value>
                init-param>
        filter>
        <filter-mapping>
                <filter-name>CASFilterfilter-name>
                <url-pattern>/*url-pattern>
        filter-mapping>

        
        <filter>
                <filter-name>CAS Validation Filterfilter-name>
                <filter-class>
                        org.jasig.cas.client.validation.Cas20ProxyReceivingTicketValidationFilterfilter-class>
                <init-param>
                        <param-name>casServerUrlPrefixparam-name>
                        <param-value>https://sso.castest.com:8443/cas/param-value>
                init-param>
                <init-param>
                        <param-name>serverNameparam-name>
                        <param-value>http://localhost:8080param-value>
                init-param>
        filter>
        <filter-mapping>
                <filter-name>CAS Validation Filterfilter-name>
                <url-pattern>/*url-pattern>
        filter-mapping>

        
        <filter>
                <filter-name>CAS HttpServletRequest Wrapper Filterfilter-name>
                <filter-class>
                        org.jasig.cas.client.util.HttpServletRequestWrapperFilterfilter-class>
        filter>
        <filter-mapping>
                <filter-name>CAS HttpServletRequest Wrapper Filterfilter-name>
                <url-pattern>/*url-pattern>
        filter-mapping>

        
        <filter>
                <filter-name>CAS Assertion Thread Local Filterfilter-name>
                <filter-class>org.jasig.cas.client.util.AssertionThreadLocalFilterfilter-class>
        filter>
        <filter-mapping>
                <filter-name>CAS Assertion Thread Local Filterfilter-name>
                <url-pattern>/*url-pattern>
        filter-mapping>
        
        

        
        <session-config>
                <session-timeout>2session-timeout>
        session-config>

web-app>
复制代码

  4. 此时访问http://localhost:8080/CasClient/Index.jsp时会自动跳转到sso.castest.com下去登录

  

  输入账号和密码casuser:Mellon

  

  此时客户端已安装成功。

  可以用类似的方式新建多个站点,站点1登录以后站点而无需登录也可访问,如果未登录则会跳转到相应的url进行登录验证。

  至此,简单的服务器搭建已经完成了。然而,此时用户的验证是通过配置文件cas\WEB-INF\deployerConfigContext.xml中指定用户名和密码的方式进行验证的。显然这不满足我们日常的需求,今天先介绍到这。下面再另行介绍通过mysql数据库验证的方式。

---------------------------------------------------------------------------------我是分割线--------------------------------------------------------------------------

to be a better me, talk is cheap show me the code

版权所有,转载请注明原文链接。

文中有不妥或者错误的地方还望指出,以免误人子弟。如果觉得本文对你有所帮助不妨【推荐】一下!如果你有更好的建议,可以给我留言讨论,共同进步!

再次感谢您耐心的读完本篇文章。


http://www.cnblogs.com/rwxwsblog/p/4954795.html

  最近公司的一个项目需要用到单点登录的功能,之前对单点登录了解得不多。于是网上找了下单点登录的解决方案,发现CAS是个不错的解决方案。于是搭个环境测试了一下。这里记录下测试的详细步骤。

  官网:http://jasig.github.io/cas/

  Cas Server下载:http://developer.jasig.org/cas/

  Cas Client下载:http://developer.jasig.org/cas-clients/

  测试环境:

    jdk:java version "1.8.0_60"

    tomcat:apache-tomcat-7.0.65

    mysql:mysql5.5.40

    CAS Server:cas-server-4.0.0-release.zip

    CAS Client:cas-client-3.1.12-release.zip

  此教程是在jdk和tomcat成功安装的基础上完成,至于jdk和tomcat的安装大家可以网上找找资料。好吧,下面入正题。

  一、生成证书

  1、生成证书:

    keytool -genkey -alias castest -keyalg RSA -keystore F:/keys/castest

    生成一个别名为castest的证书。

    此处需要特别注意口令(后续导入导出证书、CAS服务器端均要用到此口类)和“名字与姓氏”(为CAS跳转域名,否则会报错)

    

  2、导出证书:

    keytool -export -file F:/keys/castest.crt -alias castest -keystore F:/keys/castest

  3、将证书导入到客户端JRE中(注意、是导入JRE中),如果security中已经存在cacerts,需要先将其删除。

    keytool -import -keystore "D:\Program Files\Java\jdk1.8.0_60\jre\lib\security\cacerts" -file F:/keys/castest.crt -alias castest

  二、配置服务器端

  1、从http://developer.jasig.org/cas/上下载cas服务器端cas-server-4.0.0-release.zip,在modules目录下找到cas-server-webapp-4.0.0.war,将其复制到%TOMCAT_HOME%\webapps下,并将名称改为cas.war

  2、修改%TOMCAT_HOME%\conf\server.xml文件,去掉此文件83到93行之间的注释,修改为:

<Connector SSLEnabled="true" clientAuth="false" keystoreFile="F:/keys/castest" >
keystorePass="castest" —证书密码-->
maxThreads="150" port="8443" protocol="org.apache.coyote.http11.Http11Protocol" scheme="https" secure="true" sslProtocol="TLS"/>

  3、测试:https://localhost:8443/

  

  点击继续浏览此网页

  

  如果此时可以正常访问,说明证书安装成功

  https://localhost:8443/cas/login,出现

  

  输入账号和密码

  casuser
  Mellon

  

  此时说明服务器端已经配置成功。可通过https://localhost:8443/cas/logout退出登录

  三、配置客户端

  1. 从http://developer.jasig.org/cas-clients/上下载cas-client-3.1.12-release.zip,在modules目录下找到cas-client-core-3.1.12.jar、commons-collections-3.2.jar、commons-logging-1.1.jar复制到项目WEB-INF/lib下

  2. 添加映射域名,在C:\Windows\System32\drivers\etc\hosts文件中添加

    127.0.0.1 sso.castest.com
  3. 创建web项目CasClient,并在项目的web.xml配置过滤器

复制代码
xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">

        <display-name>cas-demodisplay-name>
        
        
        
        <listener>
                <listener-class>org.jasig.cas.client.session.SingleSignOutHttpSessionListenerlistener-class>
        listener>

        
        <filter>
                <filter-name>CAS Single Sign Out Filterfilter-name>
                <filter-class>org.jasig.cas.client.session.SingleSignOutFilterfilter-class>
        filter>
        <filter-mapping>
                <filter-name>CAS Single Sign Out Filterfilter-name>
                <url-pattern>/CasClient/*url-pattern>
        filter-mapping>

        
        <filter>
                <filter-name>CASFilterfilter-name>
                <filter-class>org.jasig.cas.client.authentication.AuthenticationFilterfilter-class>
                <init-param>
                        <param-name>casServerLoginUrlparam-name>
                        <param-value>https://sso.castest.com:8443/cas/loginparam-value>
                        
                init-param>
                <init-param>
                        <param-name>serverNameparam-name>
                        <param-value>http://localhost:8080param-value>
                init-param>
        filter>
        <filter-mapping>
                <filter-name>CASFilterfilter-name>
                <url-pattern>/*url-pattern>
        filter-mapping>

        
        <filter>
                <filter-name>CAS Validation Filterfilter-name>
                <filter-class>
                        org.jasig.cas.client.validation.Cas20ProxyReceivingTicketValidationFilterfilter-class>
                <init-param>
                        <param-name>casServerUrlPrefixparam-name>
                        <param-value>https://sso.castest.com:8443/cas/param-value>
                init-param>
                <init-param>
                        <param-name>serverNameparam-name>
                        <param-value>http://localhost:8080param-value>
                init-param>
        filter>
        <filter-mapping>
                <filter-name>CAS Validation Filterfilter-name>
                <url-pattern>/*url-pattern>
        filter-mapping>

        
        <filter>
                <filter-name>CAS HttpServletRequest Wrapper Filterfilter-name>
                <filter-class>
                        org.jasig.cas.client.util.HttpServletRequestWrapperFilterfilter-class>
        filter>
        <filter-mapping>
                <filter-name>CAS HttpServletRequest Wrapper Filterfilter-name>
                <url-pattern>/*url-pattern>
        filter-mapping>

        
        <filter>
                <filter-name>CAS Assertion Thread Local Filterfilter-name>
                <filter-class>org.jasig.cas.client.util.AssertionThreadLocalFilterfilter-class>
        filter>
        <filter-mapping>
                <filter-name>CAS Assertion Thread Local Filterfilter-name>
                <url-pattern>/*url-pattern>
        filter-mapping>
        
        

        
        <session-config>
                <session-timeout>2session-timeout>
        session-config>

web-app>
复制代码

  4. 此时访问http://localhost:8080/CasClient/Index.jsp时会自动跳转到sso.castest.com下去登录

  

  输入账号和密码casuser:Mellon

  

  此时客户端已安装成功。

  可以用类似的方式新建多个站点,站点1登录以后站点而无需登录也可访问,如果未登录则会跳转到相应的url进行登录验证。

  至此,简单的服务器搭建已经完成了。然而,此时用户的验证是通过配置文件cas\WEB-INF\deployerConfigContext.xml中指定用户名和密码的方式进行验证的。显然这不满足我们日常的需求,今天先介绍到这。下面再另行介绍通过mysql数据库验证的方式。

---------------------------------------------------------------------------------我是分割线--------------------------------------------------------------------------

to be a better me, talk is cheap show me the code

版权所有,转载请注明原文链接。

文中有不妥或者错误的地方还望指出,以免误人子弟。如果觉得本文对你有所帮助不妨【推荐】一下!如果你有更好的建议,可以给我留言讨论,共同进步!

再次感谢您耐心的读完本篇文章。

  最近公司的一个项目需要用到单点登录的功能,之前对单点登录了解得不多。于是网上找了下单点登录的解决方案,发现CAS是个不错的解决方案。于是搭个环境测试了一下。这里记录下测试的详细步骤。

  官网:http://jasig.github.io/cas/

  Cas Server下载:http://developer.jasig.org/cas/

  Cas Client下载:http://developer.jasig.org/cas-clients/

  测试环境:

    jdk:java version "1.8.0_60"

    tomcat:apache-tomcat-7.0.65

    mysql:mysql5.5.40

    CAS Server:cas-server-4.0.0-release.zip

    CAS Client:cas-client-3.1.12-release.zip

  此教程是在jdk和tomcat成功安装的基础上完成,至于jdk和tomcat的安装大家可以网上找找资料。好吧,下面入正题。

  一、生成证书

  1、生成证书:

    keytool -genkey -alias castest -keyalg RSA -keystore F:/keys/castest

    生成一个别名为castest的证书。

    此处需要特别注意口令(后续导入导出证书、CAS服务器端均要用到此口类)和“名字与姓氏”(为CAS跳转域名,否则会报错)

    

  2、导出证书:

    keytool -export -file F:/keys/castest.crt -alias castest -keystore F:/keys/castest

  3、将证书导入到客户端JRE中(注意、是导入JRE中),如果security中已经存在cacerts,需要先将其删除。

    keytool -import -keystore "D:\Program Files\Java\jdk1.8.0_60\jre\lib\security\cacerts" -file F:/keys/castest.crt -alias castest

  二、配置服务器端

  1、从http://developer.jasig.org/cas/上下载cas服务器端cas-server-4.0.0-release.zip,在modules目录下找到cas-server-webapp-4.0.0.war,将其复制到%TOMCAT_HOME%\webapps下,并将名称改为cas.war

  2、修改%TOMCAT_HOME%\conf\server.xml文件,去掉此文件83到93行之间的注释,修改为:

<Connector SSLEnabled="true" clientAuth="false" keystoreFile="F:/keys/castest" >
keystorePass="castest" —证书密码-->
maxThreads="150" port="8443" protocol="org.apache.coyote.http11.Http11Protocol" scheme="https" secure="true" sslProtocol="TLS"/>

  3、测试:https://localhost:8443/

  

  点击继续浏览此网页

  

  如果此时可以正常访问,说明证书安装成功

  https://localhost:8443/cas/login,出现

  

  输入账号和密码

  casuser
  Mellon

  

  此时说明服务器端已经配置成功。可通过https://localhost:8443/cas/logout退出登录

  三、配置客户端

  1. 从http://developer.jasig.org/cas-clients/上下载cas-client-3.1.12-release.zip,在modules目录下找到cas-client-core-3.1.12.jar、commons-collections-3.2.jar、commons-logging-1.1.jar复制到项目WEB-INF/lib下

  2. 添加映射域名,在C:\Windows\System32\drivers\etc\hosts文件中添加

    127.0.0.1 sso.castest.com
  3. 创建web项目CasClient,并在项目的web.xml配置过滤器

复制代码
xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">

        <display-name>cas-demodisplay-name>
        
        
        
        <listener>
                <listener-class>org.jasig.cas.client.session.SingleSignOutHttpSessionListenerlistener-class>
        listener>

        
        <filter>
                <filter-name>CAS Single Sign Out Filterfilter-name>
                <filter-class>org.jasig.cas.client.session.SingleSignOutFilterfilter-class>
        filter>
        <filter-mapping>
                <filter-name>CAS Single Sign Out Filterfilter-name>
                <url-pattern>/CasClient/*url-pattern>
        filter-mapping>

        
        <filter>
                <filter-name>CASFilterfilter-name>
                <filter-class>org.jasig.cas.client.authentication.AuthenticationFilterfilter-class>
                <init-param>
                        <param-name>casServerLoginUrlparam-name>
                        <param-value>https://sso.castest.com:8443/cas/loginparam-value>
                        
                init-param>
                <init-param>
                        <param-name>serverNameparam-name>
                        <param-value>http://localhost:8080param-value>
                init-param>
        filter>
        <filter-mapping>
                <filter-name>CASFilterfilter-name>
                <url-pattern>/*url-pattern>
        filter-mapping>

        
        <filter>
                <filter-name>CAS Validation Filterfilter-name>
                <filter-class>
                        org.jasig.cas.client.validation.Cas20ProxyReceivingTicketValidationFilterfilter-class>
                <init-param>
                        <param-name>casServerUrlPrefixparam-name>
                        <param-value>https://sso.castest.com:8443/cas/param-value>
                init-param>
                <init-param>
                        <param-name>serverNameparam-name>
                        <param-value>http://localhost:8080param-value>
                init-param>
        filter>
        <filter-mapping>
                <filter-name>CAS Validation Filterfilter-name>
                <url-pattern>/*url-pattern>
        filter-mapping>

        
        <filter>
                <filter-name>CAS HttpServletRequest Wrapper Filterfilter-name>
                <filter-class>
                        org.jasig.cas.client.util.HttpServletRequestWrapperFilterfilter-class>
        filter>
        <filter-mapping>
                <filter-name>CAS HttpServletRequest Wrapper Filterfilter-name>
                <url-pattern>/*url-pattern>
        filter-mapping>

        
        <filter>
                <filter-name>CAS Assertion Thread Local Filterfilter-name>
                <filter-class>org.jasig.cas.client.util.AssertionThreadLocalFilterfilter-class>
        filter>
        <filter-mapping>
                <filter-name>CAS Assertion Thread Local Filterfilter-name>
                <url-pattern>/*url-pattern>
        filter-mapping>
        
        

        
        <session-config>
                <session-timeout>2session-timeout>
        session-config>

web-app>
复制代码

  4. 此时访问http://localhost:8080/CasClient/Index.jsp时会自动跳转到sso.castest.com下去登录

  

  输入账号和密码casuser:Mellon

  

  此时客户端已安装成功。

  可以用类似的方式新建多个站点,站点1登录以后站点而无需登录也可访问,如果未登录则会跳转到相应的url进行登录验证。

  至此,简单的服务器搭建已经完成了。然而,此时用户的验证是通过配置文件cas\WEB-INF\deployerConfigContext.xml中指定用户名和密码的方式进行验证的。显然这不满足我们日常的需求,今天先介绍到这。下面再另行介绍通过mysql数据库验证的方式。

---------------------------------------------------------------------------------我是分割线--------------------------------------------------------------------------

to be a better me, talk is cheap show me the code

版权所有,转载请注明原文链接。

文中有不妥或者错误的地方还望指出,以免误人子弟。如果觉得本文对你有所帮助不妨【推荐】一下!如果你有更好的建议,可以给我留言讨论,共同进步!

再次感谢您耐心的读完本篇文章。

你可能感兴趣的:(java)