隨筆 - 0, 文章 - 2, 評(píng)論 - 0, 引用 - 0
          數(shù)據(jù)加載中……

          cas3.4.3.1客戶端使用

          下面介紹用http協(xié)議使用cas單點(diǎn)登錄系統(tǒng)。
          一,前提條件
              1,cas服務(wù)器部署測試成功。
              2,下載cas-client-core-3.1.10.jar到你的應(yīng)用lib目錄下。
          二,客戶端配置(這里使用spring的方式來配置,spring本身的配置這里就不描述了)
              1,配置web.xml文件,cas有4個(gè)filter需要配置,配置順序不能改變,

                   <filter>
                       <filter-name>CAS Single Sign Out Filter</filter-name>
                           <filter-class>org.jasig.cas.client.session.SingleSignOutFilter</filter-class>
                      </filter>

                  <filter>
                       <filter-name>CAS Authentication Filter</filter-name>
                       <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
                       <init-param>
                            <param-name>targetBeanName</param-name>
                            <param-value>casAuthenticationFilter</param-value>
                       </init-param>
                  </filter>

          <filter>
           <filter-name>CAS Validation Filter</filter-name>
           <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
           <init-param>
            <param-name>targetBeanName</param-name>
            <param-value>casValidationFilter</param-value>
           </init-param>
          </filter>

          <filter>
           <filter-name>CAS HttpServletRequestWrapperFilter</filter-name>
           <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
           <init-param>
            <param-name>targetBeanName</param-name>
            <param-value>casHttpServletRequestWrapperFilter</param-value>
           </init-param>
          </filter>

          <filter-mapping>
           <filter-name>CAS Single Sign Out Filter</filter-name>
           <url-pattern>*.do</url-pattern>
          </filter-mapping>

          <filter-mapping>
           <filter-name>CAS Authentication Filter</filter-name>
           <url-pattern>*.do</url-pattern>
          </filter-mapping>

          <filter-mapping>
           <filter-name>CAS Validation Filter</filter-name>
           <url-pattern>*.do</url-pattern>
          </filter-mapping>

          <filter-mapping>
           <filter-name>CAS HttpServletRequestWrapperFilter</filter-name>
           <url-pattern>*.do</url-pattern>
          </filter-mapping>

                  2,spring文件的配置,新增一個(gè)spring配置文件,文件名隨意,我這里叫做applicationContext-cas.xml,文件內(nèi)容為

          <?xml version="1.0" encoding="UTF-8"?>
          <beans xmlns="http://www.springframework.org/schema/beans"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
           xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
           xmlns:context="http://www.springframework.org/schema/context"
           xmlns:jee="http://www.springframework.org/schema/jee" xmlns:util="http://www.springframework.org/schema/util"
           xsi:schemaLocation="http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.0.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd"
           default-autowire="byName" default-lazy-init="false">

           <bean id="casAuthenticationFilter"
            class="org.jasig.cas.client.authentication.AuthenticationFilter">
            <property name="casServerLoginUrl" value="${cas.url}/login" />
            <property name="serverName" value="${project.url}" />
            <property name="renew" value="false" />
            <property name="gateway" value="false" />
            
           </bean>

           <bean id="casValidationFilter"
            class="org.jasig.cas.client.validation.Cas20ProxyReceivingTicketValidationFilter">
            <property name="ticketValidator">
             <ref bean="Cas20ServiceTicketValidator" />
            </property>
            <property name="useSession" value="true" />
            <property name="serverName" value="${project.url}" />
            <property name="redirectAfterValidation" value="true" />
           </bean>

           <bean id="Cas20ServiceTicketValidator"
            class="org.jasig.cas.client.validation.Cas20ServiceTicketValidator">
            <constructor-arg index="0" value="${cas.url}" />
           </bean>

           <bean id="casHttpServletRequestWrapperFilter"
            class="org.jasig.cas.client.util.HttpServletRequestWrapperFilter" />
          </beans>

           上面紅色部分的意思是: cas.url是你cas服務(wù)器的地址,project.url是你客戶端應(yīng)用的地址。下面是我本地的配置

              #cas服務(wù)器地址
              cas.url=http://127.0.0.1:8080/cas
              #客戶端url地址
              project.url=http://127.0.0.1:8080

          3,客戶端數(shù)據(jù)庫的配置

              建議cas服務(wù)器和客戶端公用同一個(gè)數(shù)據(jù)庫,如果分開,就會(huì)涉及到數(shù)據(jù)同步問題。

          posted on 2011-04-11 10:30 汪長軍 閱讀(1196) 評(píng)論(0)  編輯  收藏 所屬分類: cas單點(diǎn)登錄


          只有注冊用戶登錄后才能發(fā)表評(píng)論。


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 且末县| 塔城市| 澄迈县| 正安县| 无棣县| 寿光市| 格尔木市| 泽州县| 浦城县| 四会市| 怀安县| 镇平县| 神木县| 霍邱县| 茌平县| 绥芬河市| 合肥市| 乌兰浩特市| 台州市| 邓州市| 余干县| 天气| 新平| 武宣县| 石首市| 东宁县| 育儿| 双峰县| 临沭县| 上栗县| 麻江县| 突泉县| 嘉义市| 肥西县| 凤冈县| 竹北市| 宝坻区| 周口市| 长岛县| 凤山县| 自贡市|