Using the CAS Client in a Distributed Environment

For the most part, the Jasig CAS Client for Java works fine in a distributed environment without additional configuration. However, in certain scenarios, such as when PGTIOUs are involved, additional support is needed.

As of Jasig CAS Client 3.1.9, support for a distributed ProxyGrantingTicketStorage has been implemented.

Including the Dependency

Instead of configuring the "cas-client-core" as a dependency within your project, include the following:

<dependency>
   <groupId>org.jasig.cas</groupId>
   <artifactId>cas-client-support-distributed-ehcache</artifactId>
   <version>3.1.9</version>
   <scope>compile</scope>
   <type>jar</type>
</dependency>

or

<dependency>
   <groupId>org.jasig.cas</groupId>
   <artifactId>cas-client-support-distributed-memcached</artifactId>
   <version>3.1.9</version>
   <scope>compile</scope>
   <type>jar</type>
</dependency>

The memcached client is not available in the public repositories so it must be downloaded manually from http://code.google.com/p/spymemcached/

Configuring the Validation Filter

Configure the validation filter as usual. You'll note, that as of 3.1.9, there is one additional optional property: proxyGrantingTicketStorageClass

This property should be defined as: org.jasig.cas.client.proxy.EhcacheBackedProxyGrantingTicketStorageImpl for the Ehcache version or
org.jasig.cas.client.proxy.MemcachedBackedProxyGrantingTicketStorageImpl for the Memcached version.

That would mean:

<init-param>
    <param-name>proxyGrantingTicketStorageClass</param-name>
    <param-value>org.jasig.cas.client.proxy.EhcacheBackedProxyGrantingTicketStorageImpl</param-value>
</init-param>

or

<init-param>
    <param-name>proxyGrantingTicketStorageClass</param-name>
    <param-value>org.jasig.cas.client.proxy.MemcachedBackedProxyGrantingTicketStorageImpl</param-value>
</init-param>

In either instance, the CAS Client will use the no-arg constructor to instantiate the class. It relies on a separate configuration file. The next section will provide more details on that.

Configuring the EhCache

When loading from the web.xml, the Jasig CAS Client relies on a series of default values, one of which being that the cache must be configured in the default location (i.e. classpath:ehcache.xml). For those who need more fine-grained control, they should look at the Spring Configuration options.

<cacheManagerPeerProviderFactory class="net.sf.ehcache.distribution.RMICacheManagerPeerProviderFactory" 
   properties="peerDiscovery=automatic,
   multicastGroupAddress=230.0.0.1, multicastGroupPort=4446"/>

<cacheManagerPeerListenerFactory class="net.sf.ehcache.distribution.RMICacheManagerPeerListenerFactory"/>

<cache 
   name="org.jasig.cas.client.proxy.EhcacheBackedProxyGrantingTicketStorageImpl.cache"
   maxElementsInMemory="100"
   eternal="false"
   timeToIdleSeconds="100"
   timeToLiveSeconds="100"
   overflowToDisk="false">
   <cacheEventListenerFactory class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"/>
</cache>

Configuring the Memcached Servers

When loading from the web.xml, the Jasig CAS Client relies on a series of default values, one of which being that the list of memcached servers must be defined in "/cas/casclient_memcached_hosts.txt" on the classpath). For those who need more fine-grained control, they should look at the Spring Configuration options.

The file is a simple list of <hostname>:<ports> on separate lines. BE SURE NOT TO HAVE EXTRA LINE BREAKS.