Nginx conf:
如何Tomcat 不做SESSION共享可以开启IP_HASH.
upstream tomcat {
##ip_hash;
server 200.10.10.67:8110;
server 200.10.10.67:8120;
}
Tomcat Session 参照【1】
–注意jar版本号
CAS 相应开发配置
Pom.xml 配置:
相应的POM文件引入dependency
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-pool2</artifactId>
<version>2.2</version>
</dependency>
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
<version>2.8.1</version>
</dependency>
ticketRegistry.xml配置内容
index=0 是redis 集群地址
index=1 是TGT 过期时间
index=2 是TGT 过期时间
<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>
Configuration for the default TicketRegistry which stores the tickets in-memory and cleans them out as specified intervals.
</description>
<!-- Ticket Registry -->
<bean id="ticketRegistry" class="org.jasig.cas.ticket.registry.RedisTicketRegistry">
<constructor-arg index="0" value="Centos6701:6379,Centos6701:6380,Centos6702:6380,Centos6702:6379,Centos6703:6380,Centos6703:6379" />
<constructor-arg index="1" value="28800" />
<constructor-arg index="2" value="200" />
</bean>
</beans>
Redis 存储Token
RedisTicketRegistry.java
/*
* Licensed to Jasig under one or more contributor license
* agreements. See the NOTICE file distributed with this work
* for additional information regarding copyright ownership.
* Jasig licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a
* copy of the License at the following location:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.jasig.cas.ticket.registry;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import javax.validation.constraints.Min;
import org.jasig.cas.ticket.ServiceTicket;
import org.jasig.cas.ticket.Ticket;
import org.jasig.cas.ticket.TicketGrantingTicket;
import org.jasig.cas.ticket.registry.util.RedisTools;
import org.jasig.cas.ticket.registry.util.serialize.ObjectsTranscoder;
import redis.clients.jedis.HostAndPort;
import redis.clients.jedis.JedisCluster;
/**
* Key-value ticket registry implementation that stores tickets in redis keyed on the ticket ID.
*
* @author lumz
*