diff --git a/cas-client-support-distributed-ehcache/pom.xml b/cas-client-support-distributed-ehcache/pom.xml new file mode 100644 index 0000000..d826b00 --- /dev/null +++ b/cas-client-support-distributed-ehcache/pom.xml @@ -0,0 +1,37 @@ + + + + cas-client + org.jasig.cas + 3.1.9-SNAPSHOT + + 4.0.0 + + org.jasig.cas + cas-client-support-distributed + jar + + + + org.jasig.cas + + cas-client-core + ${project.version} + jar + compile + + + + + net.sf.ehcache + ehcache + ${ehcache.version} + compile + jar + + + + + \ No newline at end of file diff --git a/cas-client-support-distributed-ehcache/src/main/java/org/jasig/cas/client/proxy/EhcacheBackedProxyGrantingTicketStorageImpl.java b/cas-client-support-distributed-ehcache/src/main/java/org/jasig/cas/client/proxy/EhcacheBackedProxyGrantingTicketStorageImpl.java new file mode 100644 index 0000000..6adc62d --- /dev/null +++ b/cas-client-support-distributed-ehcache/src/main/java/org/jasig/cas/client/proxy/EhcacheBackedProxyGrantingTicketStorageImpl.java @@ -0,0 +1,50 @@ +/* + * Copyright 2007 The JA-SIG Collaborative. All rights reserved. See license + * distributed with this file and available online at + * http://www.ja-sig.org/products/cas/overview/license/index.html + */ +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; + } +} diff --git a/pom.xml b/pom.xml index 8fe880a..5716b36 100644 --- a/pom.xml +++ b/pom.xml @@ -131,6 +131,7 @@ cas-client-integration-atlassian cas-client-support-distributed-ehcache cas-client-support-distributed-memcached + cas-client-support-distributed-ehcache