use ehcache for distributed support
This commit is contained in:
Scott Battaglia 2009-09-20 16:09:56 +00:00
parent ccdd0596c7
commit bdb354531e
4 changed files with 95 additions and 0 deletions

View File

@ -58,6 +58,17 @@ public class Cas20ProxyReceivingTicketValidationFilter extends AbstractTicketVal
super.initInternal(filterConfig);
setProxyReceptorUrl(getPropertyFromInitParams(filterConfig, "proxyReceptorUrl", null));
final String proxyGrantingTicketStorageClass = getPropertyFromInitParams(filterConfig, "proxyGrantingTicketStorageClass", null);
if (proxyGrantingTicketStorageClass != null) {
try {
final Class storageClass = Class.forName(proxyGrantingTicketStorageClass);
this.proxyGrantingTicketStorage = (ProxyGrantingTicketStorage) storageClass.newInstance();
} catch (final Exception e) {
throw new RuntimeException(e);
}
}
log.trace("Setting proxyReceptorUrl parameter: " + this.proxyReceptorUrl);
this.millisBetweenCleanUps = Integer.parseInt(getPropertyFromInitParams(filterConfig, "millisBetweenCleanUps", Integer.toString(DEFAULT_MILLIS_BETWEEN_CLEANUPS)));
}

View File

@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>cas-client</artifactId>
<groupId>org.jasig.cas</groupId>
<version>3.1.9-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.jasig.cas</groupId>
<artifactId>cas-client-support-distributed</artifactId>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>org.jasig.cas</groupId>
<artifactId>cas-client-core</artifactId>
<version>${project.version}</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>net.sf.ehcache</groupId>
<artifactId>ehcache</artifactId>
<version>${ehcache.version}</version>
<scope>compile</scope>
<type>jar</type>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,45 @@
package org.jasig.cas.client.proxy;
import net.sf.ehcache.Cache;
import net.sf.ehcache.Element;
import net.sf.ehcache.CacheManager;
/**
* @author Scott Battaglia
* @version $Revision$ $Date$
* @since 3.1.9
*/
public final class EhcacheBackedProxyGrantingTicketStorageImpl implements ProxyGrantingTicketStorage {
public static final String EHCACHE_CACHE_NAME = "org.jasig.cas.client.proxy.EhcacheBackedProxyGrantingTicketStorageImpl.cache";
final Cache cache;
public EhcacheBackedProxyGrantingTicketStorageImpl() {
this(CacheManager.create().getCache(EHCACHE_CACHE_NAME));
}
public EhcacheBackedProxyGrantingTicketStorageImpl(final Cache cache) {
this.cache = cache;
}
public void save(final String proxyGrantingTicketIou, final String proxyGrantingTicket) {
final Element element = new Element(proxyGrantingTicketIou, proxyGrantingTicket);
this.cache.put(element);
}
public String retrieve(final String proxyGrantingTicketIou) {
final Element element = this.cache.get(proxyGrantingTicketIou);
if (element == null) {
return null;
}
return (String) element.getValue();
}
public void cleanUp() {
return;
}
}

View File

@ -129,7 +129,12 @@
<modules>
<module>cas-client-core</module>
<module>cas-client-integration-atlassian</module>
<module>cas-client-support-distributed</module>
</modules>
<properties>
<ehcache.version>1.5.0</ehcache.version>
</properties>
<distributionManagement>
<repository>