服务端cas
从网上下载cas:/
在cas下:
    在cas-client下:
解压cas-server-3.5.2-release.zip\cas-server-3.5.2\module\cas-server-webapp-3.5.2.war部署到tomcat上,
设置
F:\apache-tomcat-6.0.30\webapps\cas\l(大家取实际情况的路径)
<bean id="logoutController" class="org.jasig.cas.web.LogoutController"
        p:followServiceRedirects="${cas.logout.followServiceRedirects:true}"/>
默认为false,这个设置是为了让登出(logout)以后进入到指定页面.
设置l
配置数据源和加密:
<bean
id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
  <property name="driverClassName"><value>oracle.jdbc.driver.OracleDriver</value></property>
  <property name="url"><value>jdbc:oracle:thin:@127.0.0.1:1521:orcl</value></property>param name
  <property name="username"><value>require</value></property>
  <property name="password"><value>require</value></property>
</bean>
<!-- <bean
id="MD5PasswordEncoder" class="org.jasig.cas.authentication.handler.DefaultPasswordEncoder">
    <constructor-arg index="0">
        <value>MD5</value>
    </constructor-arg>
</bean> -->
然后注释掉下面这行,这行是为了测试使用,只要账号密码相同就可以通过验证
<bean class="org.jasig.cas.authentication.handler.support.SimpleTestUsernamePasswor
dAuthenticationHandler" />
这里看sql语句就知道是连数据库验证账号密码了
<bean class="org.jasig.cas.adaptors.jdbc.QueryDatabaseAuthenticationHandler">
    <property name="dataSource" ref="dataSource"></property>  <property name="sql" value="select userpassword from user_ where useraccount=?"></property>
          </bean>
CAS服务器端的修改: 
修改l
<="" span="">
    p:cookieSecure="true"
    p:cookieMaxAge="-1"
    p:cookieName="CASTGC"
    p:cookiePath="/cas" />
 将p:cookieSecure="true" 改为 false false才能避免取消ssl后重复登录
这个设置完大家就不要用https了直接使用http:xxx
还有一个地方要特别说明:
  有一个地方设置系统数量的:在spring-configuration/l
设置c:numberOfUses="2";你要加多少个系统就写多少数字。
服务端配置完成了。
客户端
  在项目中导入cas-client.jar
设置filter
编辑l,然后粘贴下面的代码:
<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>CASFilter</FILTER-NAME>
<FILTER-CLASS>org.jasig.cas.client.authentication.AuthenticationFilter</FILTER-CLASS>
<INIT-PARAM>
<PARAM-NAME>casServerLoginUrl</PARAM-NAME>
<PARAM-VALUE>sso.wsria:8443/cas/login</PARAM-VALUE>
</INIT-PARAM>
<INIT-PARAM>
<PARAM-NAME>serverName</PARAM-NAME>
<PARAM-VALUE>localhost:10000</PARAM-VALUE>
</INIT-PARAM>
</FILTER>
<FILTER-MAPPING>
<FILTER-NAME>CASFilter</FILTER-NAME>
<URL-PATTERN>/*</URL-PATTERN>
</FILTER-MAPPING>
<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>sso.wsria:8443/cas</PARAM-VALUE>
</INIT-PARAM>
<INIT-PARAM>
<PARAM-NAME>serverName</PARAM-NAME>
<PARAM-VALUE>localhost:10000</PARAM-VALUE>
</INIT-PARAM>
</FILTER>
<FILTER-MAPPING>
<FILTER-NAME>CAS Validation Filter</FILTER-NAME>
<URL-PATTERN>/*</URL-PATTERN>
</FILTER-MAPPING>
<!--
该过滤器负责实现HttpServletRequest请求的包裹,
比如允许开发者通过HttpServletRequest的getRemoteUser()方法获得SSO登录用户的登录名,可选配置。
AttributePrincipal principal = (AttributePrincipal) UserPrincipal();
String username = Name();
-->
<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来获取用户的登录名。
比如Assertion().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>
<!-- 自动根据单点登录的结果设置本系统的用户信息可选配置-->
<FILTER>
<DISPLAY-NAME>AutoSetUserAdapterFilter</DISPLAY-NAME>
<FILTER-NAME>AutoSetUserAdapterFilter</FILTER-NAME>
<FILTER-CLASS>com.wsria.demo.filter.AutoSetUserAdapterFilter</FILTER-CLASS>
</FILTER>
<FILTER-MAPPING>
<FILTER-NAME>AutoSetUserAdapterFilter</FILTER-NAME>
<URL-PATTERN>/*</URL-PATTERN>
</FILTER-MAPPING>
关注我的微薄:weibo/tototototototot
_唐晨_壹9久0
还有问题的发我QQ邮箱:236016210@qq

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。