CAS3.3.0在logout后不能自动根据service跳转,所以装了个CAS4.0.0,记录一下

简介:

环境:

Oracle 11g

Centos 6.5

CAS 4.0

Tomcat 7

JDK 1.7


CAS3.3.0在logout后不能自动根据service跳转,所以装了个CAS4.0.0,记录一下

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

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

2. 下载完毕4.0.zip文件后,解压后再module里面会有一个4.0的war包cas-server-webapp-4.0.0.war。
3. 把这个war包拷到tomcat7中,重命名为cas.war。
4. 把tomcat7启动起来,然后再cas目录下找到WEB-INF中的lib中,
5. 加入这几个jar包:
cas-server-support-jdbc-4.0.0.jar
oracle-jdbc-11.2.jar
ojdbc6.jar
commons-dbcp-1.3.jar
自己写的PasswordEncoder-0.6.1.jar
commons-pool-1.5.6.jar
6. 然后修改cas\WEB-INF\spring-configuration\ticketGrantingTicketCookieGenerator.xml
的p:cookieSecure="false",如下

<?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"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
	<description>
		Defines the cookie that stores the TicketGrantingTicket.  You most likely should never modify these (especially the "secure" property).
		You can change the name if you want to make it harder for people to guess.
	</description>
	<bean id="ticketGrantingTicketCookieGenerator" class="org.jasig.cas.web.support.CookieRetrievingCookieGenerator"
		p:cookieSecure="true"
		p:cookieMaxAge="-1"
		p:cookieName="CASTGC"
		p:cookiePath="/cas" />
</beans>



7.修改cas\web-inf\ deployerConfigContext.xml文件:


<?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:c="http://www.springframework.org/schema/c"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xmlns:util="http://www.springframework.org/schema/util"
       xmlns:sec="http://www.springframework.org/schema/security"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
       http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd
       http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.2.xsd
       http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">

    <bean id="authenticationManager" class="org.jasig.cas.authentication.PolicyBasedAuthenticationManager">
        <constructor-arg>
            <map>
                <entry key-ref="proxyAuthenticationHandler" value-ref="proxyPrincipalResolver" />
		 		<entry key-ref="dbAuthHandler" value-ref="primaryPrincipalResolver"/>
            </map>
        </constructor-arg>
        <property name="authenticationPolicy">
            <bean class="org.jasig.cas.authentication.AnyAuthenticationPolicy" />
        </property>
    </bean>
    <bean id="proxyAuthenticationHandler"
          class="org.jasig.cas.authentication.handler.support.HttpBasedServiceCredentialsAuthenticationHandler"
          p:httpClient-ref="httpClient" />
	<bean id="casDataSource" class="org.apache.commons.dbcp.BasicDataSource">
		   <property name="driverClassName">
			   <value>oracle.jdbc.driver.OracleDriver</value>
		   </property>
		   <property name="url">
			   <value>jdbc:oracle:thin:@10.0.1.177:1521:shdgdb</value>
		   </property>    
		   <property name="username">
			   <value>shdg</value>    
		   </property>
		   <property name="password">
			   <value>shdg</value>
		   </property>
	</bean>
	<bean id="myPasswordEncoder" class="com.esteel.cas.until.PasswordEncoder"/>
	<bean id="dbAuthHandler"
      class="org.jasig.cas.adaptors.jdbc.QueryDatabaseAuthenticationHandler"
      p:dataSource-ref="casDataSource"
      p:sql="select trade_passwd from tb_cus_user where cus_user_id = ?"
	  p:passwordEncoder-ref="myPasswordEncoder"
	  />
	<bean id="proxyPrincipalResolver"
          class="org.jasig.cas.authentication.principal.BasicPrincipalResolver" />
	<bean id="primaryPrincipalResolver"
          class="org.jasig.cas.authentication.principal.PersonDirectoryPrincipalResolver" >
        <property name="attributeRepository" ref="attributeRepository" />
    </bean>
    <bean id="attributeRepository" class="org.jasig.services.persondir.support.StubPersonAttributeDao"
            p:backingMap-ref="attrRepoBackingMap" />
    <util:map id="attrRepoBackingMap">
        <entry key="uid" value="uid" />
        <entry key="eduPersonAffiliation" value="eduPersonAffiliation" /> 
        <entry key="groupMembership" value="groupMembership" />
    </util:map>
    <bean id="serviceRegistryDao" class="org.jasig.cas.services.InMemoryServiceRegistryDaoImpl"
            p:registeredServices-ref="registeredServicesList" />
    <util:list id="registeredServicesList">
        <bean class="org.jasig.cas.services.RegexRegisteredService"
              p:id="0" p:name="HTTP and IMAP" p:description="Allows HTTP(S) and IMAP(S) protocols"
              p:serviceId="^(https?|imaps?)://.*" p:evaluationOrder="10000001" />
    </util:list>
    <bean id="auditTrailManager" class="com.github.inspektr.audit.support.Slf4jLoggingAuditTrailManager" />
    <bean id="healthCheckMonitor" class="org.jasig.cas.monitor.HealthCheckMonitor" p:monitors-ref="monitorsList" />
    <util:list id="monitorsList">
      <bean class="org.jasig.cas.monitor.MemoryMonitor" p:freeMemoryWarnThreshold="10" />
      <bean class="org.jasig.cas.monitor.SessionMonitor"
          p:ticketRegistry-ref="ticketRegistry"
          p:serviceTicketCountWarnThreshold="5000"
          p:sessionCountWarnThreshold="100000" />
    </util:list>
</beans>

8.修改cas-servlet.xml为如下


<?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:webflow="http://www.springframework.org/schema/webflow-config"
       xmlns:p="http://www.springframework.org/schema/p"
       xmlns:c="http://www.springframework.org/schema/c"
       xmlns:util="http://www.springframework.org/schema/util"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
       http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd
       http://www.springframework.org/schema/webflow-config http://www.springframework.org/schema/webflow-config/spring-webflow-config-2.3.xsd">

  <import resource="spring-configuration/propertyFileConfigurer.xml"/>

  <!-- Theme Resolver -->
  <bean id="themeResolver" class="org.jasig.cas.services.web.ServiceThemeResolver"
        p:defaultThemeName="${cas.themeResolver.defaultThemeName}"
        p:argumentExtractors-ref="argumentExtractors"
        p:servicesManager-ref="servicesManager">
    <property name="mobileBrowsers">
      <util:map>
        <entry key=".*iPhone.*" value="iphone"/>
        <entry key=".*Android.*" value="iphone"/>
        <entry key=".*Safari.*Pre.*" value="iphone"/>
        <entry key=".*Nokia.*AppleWebKit.*" value="iphone"/>
      </util:map>
    </property>
  </bean>

  <!-- View Resolver -->
  <bean id="viewResolver" class="org.springframework.web.servlet.view.ResourceBundleViewResolver"
        p:order="0">
    <property name="basenames">
      <util:list>
        <value>${cas.viewResolver.basename}</value>
        <value>protocol_views</value>
      </util:list>
    </property>
  </bean>
  
  <!-- Locale Resolver -->
  <bean id="localeResolver" class="org.springframework.web.servlet.i18n.CookieLocaleResolver" p:defaultLocale="zh_CN" />

  <bean id="localeChangeInterceptor" class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor"/>

  <bean id="urlBasedViewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver"
        p:viewClass="org.springframework.web.servlet.view.InternalResourceView"
        p:prefix="/WEB-INF/view/jsp/"
        p:suffix=".jsp"
        p:order="1"/>
  
  <bean id="errorHandlerResolver" class="org.jasig.cas.web.FlowExecutionExceptionResolver"/>

  <bean class="org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter"/>

  <bean
      id="handlerMappingC"
      class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping"
      p:alwaysUseFullPath="true">
    <property name="mappings">
      <util:properties>
        <prop key="/serviceValidate">serviceValidateController</prop>
        <prop key="/proxyValidate">proxyValidateController</prop>
        
        <prop key="/p3/serviceValidate">v3ServiceValidateController</prop>
        <prop key="/p3/proxyValidate">v3ProxyValidateController</prop>
        
        <prop key="/validate">legacyValidateController</prop>
        <prop key="/proxy">proxyController</prop>
        <prop key="/authorizationFailure.html">passThroughController</prop>
        <prop key="/status">healthCheckController</prop>
        <prop key="/statistics">statisticsController</prop>
      </util:properties>
    </property>
   
  </bean>

  <bean id="passThroughController" class="org.springframework.web.servlet.mvc.UrlFilenameViewController"/>

  <!-- login webflow configuration -->
  <bean id="loginFlowHandlerMapping" class="org.springframework.webflow.mvc.servlet.FlowHandlerMapping"
        p:flowRegistry-ref="loginFlowRegistry" p:order="2">
    <property name="interceptors">
      <ref local="localeChangeInterceptor" />
    </property>
  </bean>

  <bean id="loginHandlerAdapter" class="org.jasig.cas.web.flow.SelectiveFlowHandlerAdapter"
        p:supportedFlowId="login" p:flowExecutor-ref="loginFlowExecutor" p:flowUrlHandler-ref="loginFlowUrlHandler" />

  <bean id="loginFlowUrlHandler" class="org.jasig.cas.web.flow.CasDefaultFlowUrlHandler" />

  <webflow:flow-executor id="loginFlowExecutor" flow-registry="loginFlowRegistry">
    <webflow:flow-execution-attributes>
      <webflow:always-redirect-on-pause value="false" />
      <webflow:redirect-in-same-state value="false" />
    </webflow:flow-execution-attributes>
    <webflow:flow-execution-listeners>
      <webflow:listener ref="terminateWebSessionListener" />
    </webflow:flow-execution-listeners>
  </webflow:flow-executor>

  <webflow:flow-registry id="loginFlowRegistry" flow-builder-services="builder">
    <webflow:flow-location path="/WEB-INF/login-webflow.xml" id="login" />
  </webflow:flow-registry>

  <!-- logout webflow configuration -->
  <bean id="logoutFlowHandlerMapping" class="org.springframework.webflow.mvc.servlet.FlowHandlerMapping"
        p:flowRegistry-ref="logoutFlowRegistry" p:order="3">
    <property name="interceptors">
      <ref local="localeChangeInterceptor" />
    </property>
  </bean>

  <bean id="logoutHandlerAdapter" class="org.jasig.cas.web.flow.SelectiveFlowHandlerAdapter"
        p:supportedFlowId="logout" p:flowExecutor-ref="logoutFlowExecutor" p:flowUrlHandler-ref="logoutFlowUrlHandler" />

  <bean id="logoutFlowUrlHandler" class="org.jasig.cas.web.flow.CasDefaultFlowUrlHandler"
        p:flowExecutionKeyParameter="RelayState" />

  <webflow:flow-executor id="logoutFlowExecutor" flow-registry="logoutFlowRegistry">
    <webflow:flow-execution-attributes>
      <webflow:always-redirect-on-pause value="false" />
      <webflow:redirect-in-same-state value="false" />
    </webflow:flow-execution-attributes>
    <webflow:flow-execution-listeners>
      <webflow:listener ref="terminateWebSessionListener" />
    </webflow:flow-execution-listeners>
  </webflow:flow-executor>

  <webflow:flow-registry id="logoutFlowRegistry" flow-builder-services="builder">
    <webflow:flow-location path="/WEB-INF/logout-webflow.xml" id="logout" />
  </webflow:flow-registry>

  <webflow:flow-builder-services id="builder" view-factory-creator="viewFactoryCreator" expression-parser="expressionParser" />

  <bean id="logoutConversionService" class="org.jasig.cas.web.flow.LogoutConversionService" />

  <bean id="terminateWebSessionListener" class="org.jasig.cas.web.flow.TerminateWebSessionListener" />

  <bean id="expressionParser" class="org.springframework.webflow.expression.spel.WebFlowSpringELExpressionParser"
        c:conversionService-ref="logoutConversionService">
    <constructor-arg>
        <bean class="org.springframework.expression.spel.standard.SpelExpressionParser" />
    </constructor-arg>
  </bean>

  <bean id="viewFactoryCreator" class="org.springframework.webflow.mvc.builder.MvcViewFactoryCreator">
    <property name="viewResolvers">
      <util:list>
        <ref local="viewResolver"/>
      </util:list>
    </property>
  </bean>
  
  <!--  CAS 2 Protocol service/proxy validation -->     
  <bean id="abstractValidateController" class="org.jasig.cas.web.ServiceValidateController" abstract="true"
        p:centralAuthenticationService-ref="centralAuthenticationService"
        p:proxyHandler-ref="proxy20Handler"
        p:argumentExtractor-ref="casArgumentExtractor"/>
  
  <bean id="proxyValidateController" parent="abstractValidateController"/>

  <bean id="serviceValidateController" parent="abstractValidateController"
        p:validationSpecificationClass="org.jasig.cas.validation.Cas20WithoutProxyingValidationSpecification"/>

  <!--  CAS 3 Protocol service/proxy validation with attributes -->
  <bean id="v3AbstractValidateController" parent="abstractValidateController" abstract="true"
        p:successView="cas3ServiceSuccessView"
        p:failureView="cas3ServiceFailureView" />
        
  <bean id="v3ProxyValidateController" parent="v3AbstractValidateController" />

  <bean id="v3ServiceValidateController" parent="v3AbstractValidateController"
        p:validationSpecificationClass="org.jasig.cas.validation.Cas20WithoutProxyingValidationSpecification"/>
 
  <!--  CAS 1 legacy validation -->       
  <bean id="legacyValidateController" parent="abstractValidateController"
        p:proxyHandler-ref="proxy10Handler"
        p:successView="cas1ServiceSuccessView"
        p:failureView="cas1ServiceFailureView"
        p:validationSpecificationClass="org.jasig.cas.validation.Cas10ProtocolValidationSpecification"/>

  <bean id="proxyController" class="org.jasig.cas.web.ProxyController"
        p:centralAuthenticationService-ref="centralAuthenticationService"/>

  <bean id="statisticsController" class="org.jasig.cas.web.StatisticsController"
        p:casTicketSuffix="${host.name}" c:ticketRegistry-ref="ticketRegistry" />

  <bean id="logoutAction" class="org.jasig.cas.web.flow.LogoutAction"
        p:servicesManager-ref="servicesManager"
        p:followServiceRedirects="${cas.logout.followServiceRedirects:true}"/>

  <bean id="frontChannelLogoutAction" class="org.jasig.cas.web.flow.FrontChannelLogoutAction"
        c:logoutManager-ref="logoutManager"/>

  <bean id="healthCheckController" class="org.jasig.cas.web.HealthCheckController"
        p:healthCheckMonitor-ref="healthCheckMonitor"/>

  <bean id="initialFlowSetupAction" class="org.jasig.cas.web.flow.InitialFlowSetupAction"
        p:argumentExtractors-ref="argumentExtractors"
        p:warnCookieGenerator-ref="warnCookieGenerator"
        p:ticketGrantingTicketCookieGenerator-ref="ticketGrantingTicketCookieGenerator"/>

  <bean id="authenticationViaFormAction" class="org.jasig.cas.web.flow.AuthenticationViaFormAction"
        p:centralAuthenticationService-ref="centralAuthenticationService"
        p:warnCookieGenerator-ref="warnCookieGenerator"
        p:ticketRegistry-ref="ticketRegistry"/>

  <bean id="authenticationExceptionHandler" class="org.jasig.cas.web.flow.AuthenticationExceptionHandler" />

  <bean id="generateServiceTicketAction" class="org.jasig.cas.web.flow.GenerateServiceTicketAction"
        p:centralAuthenticationService-ref="centralAuthenticationService"/>

  <bean id="sendTicketGrantingTicketAction" class="org.jasig.cas.web.flow.SendTicketGrantingTicketAction"
        p:centralAuthenticationService-ref="centralAuthenticationService"
        p:ticketGrantingTicketCookieGenerator-ref="ticketGrantingTicketCookieGenerator"/>

  <bean id="gatewayServicesManagementCheck" class="org.jasig.cas.web.flow.GatewayServicesManagementCheck"
    c:servicesManager-ref="servicesManager" />

  <bean id="serviceAuthorizationCheck" class="org.jasig.cas.web.flow.ServiceAuthorizationCheck"
    c:servicesManager-ref="servicesManager" />

  <bean id="generateLoginTicketAction" class="org.jasig.cas.web.flow.GenerateLoginTicketAction"
        p:ticketIdGenerator-ref="loginTicketUniqueIdGenerator"/>

  <bean id="messageInterpolator" class="org.jasig.cas.util.SpringAwareMessageMessageInterpolator"/>

  <bean id="credentialsValidator" class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean"
        p:messageInterpolator-ref="messageInterpolator"/>

  <bean id="ticketGrantingTicketCheckAction" class="org.jasig.cas.web.flow.TicketGrantingTicketCheckAction"
        c:registry-ref="ticketRegistry" />

  <bean id="terminateSessionAction" class="org.jasig.cas.web.flow.TerminateSessionAction"
        c:cas-ref="centralAuthenticationService"
        c:tgtCookieGenerator-ref="ticketGrantingTicketCookieGenerator"
        c:warnCookieGenerator-ref="warnCookieGenerator"/>
</beans>

9.最后就是改下登陆的样式。

登陆界面在\cas\WEB-INF\view\jsp\default\ui\中的casLoginView.jsp中修改。


10,最后上传下做好的登陆界面图。



目录
相关文章
|
监控 关系型数据库 PostgreSQL
两阶段提交(2PC, Two-Phase Commit)
【8月更文挑战第24天】
906 9
|
jenkins Devops 机器人
【DevOps】(五)Jenkins构建给企业微信推送消息
【DevOps】(五)Jenkins构建给企业微信推送消息
638 1
|
SQL Java 数据库连接
既生瑜何生亮,浅析下层出不穷的新ORM框架: MyBatis-Flex
这里先说说我的观点哈,仅是个人观点哦,不喜勿喷。现在这些框架层出不穷,其实吧个人感觉没必要过度关注,因为这些框架并没有完完全全做到推陈出新,反倒是有一点互相“学习copy”的感觉,并没有那么新颖强大、从无到有的一个过程。那说回今天的主题ORM框架,在Java后端技术栈里面我们都知道`MyBatis`是主流的ORM框架,现在很多公司都在使用着,后来在`MyBatis`基础上出现了两个比较主流的增强框架`Mybatis-Plus`和`Fluent-MyBatis`
1030 0
|
存储 机器学习/深度学习 大数据
量子计算与大数据:处理海量信息的新方法
量子计算作为革命性的计算范式,凭借量子比特和量子门的独特优势,展现出在大数据处理中的巨大潜力。本文探讨了量子计算的基本原理、在大数据处理中的应用及面临的挑战与前景,展望了其在金融、医疗和物流等领域的广泛应用。
|
Cloud Native Java Go
清理Maven仓库中下载失败的文件
清理Maven仓库中下载失败的文件
327 0
|
JavaScript 前端开发 编译器
TypeScript 详解之 tsc 命令行编译器
TypeScript 详解之 tsc 命令行编译器
|
Linux 调度
Linux内核的基础设施:工作队列、等待队列
本文介绍了Linux内核中的工作队列和等待队列机制,通过一个具体的Demo演示了如何使用等待队列进行条件等待和唤醒,以及工作队列的创建和调度,同时展示了修改唤醒条件导致无法唤醒进程的情况。
436 0
|
消息中间件 JavaScript Linux
消息队列 MQ操作报错合集之客户端在启动时遇到了连接错误,是什么原因
消息队列(MQ)是一种用于异步通信和解耦的应用程序间消息传递的服务,广泛应用于分布式系统中。针对不同的MQ产品,如阿里云的RocketMQ、RabbitMQ等,它们在实现上述场景时可能会有不同的特性和优势,比如RocketMQ强调高吞吐量、低延迟和高可用性,适合大规模分布式系统;而RabbitMQ则以其灵活的路由规则和丰富的协议支持受到青睐。下面是一些常见的消息队列MQ产品的使用场景合集,这些场景涵盖了多种行业和业务需求。
|
JavaScript Java 测试技术
基于SpringBoot+Vue+uniapp微信小程序的在线问卷调查系统的详细设计和实现
基于SpringBoot+Vue+uniapp微信小程序的在线问卷调查系统的详细设计和实现
513 1
|
自然语言处理 数据可视化 知识图谱
【大模型】如何提高LLM决策的可解释性和可解释性?
【5月更文挑战第6天】【大模型】如何提高LLM决策的可解释性和可解释性?