SEC-518: Fix. "Cache" in EhCache is a class, so change the APIs to use the interface it implements (Ehcache).

This commit is contained in:
Luke Taylor 2007-08-27 23:41:59 +00:00
parent 87d6b8dedd
commit 3f123e1478
9 changed files with 36 additions and 51 deletions

View File

@ -15,9 +15,9 @@
package org.acegisecurity.acl.basic.cache; package org.acegisecurity.acl.basic.cache;
import net.sf.ehcache.Cache;
import net.sf.ehcache.CacheException; import net.sf.ehcache.CacheException;
import net.sf.ehcache.Element; import net.sf.ehcache.Element;
import net.sf.ehcache.Ehcache;
import org.acegisecurity.acl.basic.AclObjectIdentity; import org.acegisecurity.acl.basic.AclObjectIdentity;
import org.acegisecurity.acl.basic.BasicAclEntry; import org.acegisecurity.acl.basic.BasicAclEntry;
@ -47,7 +47,7 @@ public class EhCacheBasedAclEntryCache implements BasicAclEntryCache, Initializi
//~ Instance fields ================================================================================================ //~ Instance fields ================================================================================================
private Cache cache; private Ehcache cache;
//~ Methods ======================================================================================================== //~ Methods ========================================================================================================
@ -55,10 +55,6 @@ public class EhCacheBasedAclEntryCache implements BasicAclEntryCache, Initializi
Assert.notNull(cache, "cache mandatory"); Assert.notNull(cache, "cache mandatory");
} }
public Cache getCache() {
return cache;
}
public BasicAclEntry[] getEntriesFromCache(AclObjectIdentity aclObjectIdentity) { public BasicAclEntry[] getEntriesFromCache(AclObjectIdentity aclObjectIdentity) {
Element element = null; Element element = null;
@ -101,7 +97,11 @@ public class EhCacheBasedAclEntryCache implements BasicAclEntryCache, Initializi
cache.remove(aclObjectIdentity); cache.remove(aclObjectIdentity);
} }
public void setCache(Cache cache) { public Ehcache getCache() {
return cache;
}
public void setCache(Ehcache cache) {
this.cache = cache; this.cache = cache;
} }
} }

View File

@ -14,9 +14,9 @@
*/ */
package org.acegisecurity.acls.jdbc; package org.acegisecurity.acls.jdbc;
import net.sf.ehcache.Cache;
import net.sf.ehcache.CacheException; import net.sf.ehcache.CacheException;
import net.sf.ehcache.Element; import net.sf.ehcache.Element;
import net.sf.ehcache.Ehcache;
import org.acegisecurity.acls.MutableAcl; import org.acegisecurity.acls.MutableAcl;
import org.acegisecurity.acls.objectidentity.ObjectIdentity; import org.acegisecurity.acls.objectidentity.ObjectIdentity;
@ -35,11 +35,11 @@ import java.io.Serializable;
public class EhCacheBasedAclCache implements AclCache { public class EhCacheBasedAclCache implements AclCache {
//~ Instance fields ================================================================================================ //~ Instance fields ================================================================================================
private Cache cache; private Ehcache cache;
//~ Constructors =================================================================================================== //~ Constructors ===================================================================================================
public EhCacheBasedAclCache(Cache cache) { public EhCacheBasedAclCache(Ehcache cache) {
Assert.notNull(cache, "Cache required"); Assert.notNull(cache, "Cache required");
this.cache = cache; this.cache = cache;
} }

View File

@ -15,9 +15,9 @@
package org.acegisecurity.providers.cas.cache; package org.acegisecurity.providers.cas.cache;
import net.sf.ehcache.Cache;
import net.sf.ehcache.CacheException; import net.sf.ehcache.CacheException;
import net.sf.ehcache.Element; import net.sf.ehcache.Element;
import net.sf.ehcache.Ehcache;
import org.acegisecurity.providers.cas.CasAuthenticationToken; import org.acegisecurity.providers.cas.CasAuthenticationToken;
import org.acegisecurity.providers.cas.StatelessTicketCache; import org.acegisecurity.providers.cas.StatelessTicketCache;
@ -45,7 +45,7 @@ public class EhCacheBasedTicketCache implements StatelessTicketCache, Initializi
//~ Instance fields ================================================================================================ //~ Instance fields ================================================================================================
private Cache cache; private Ehcache cache;
//~ Methods ======================================================================================================== //~ Methods ========================================================================================================
@ -73,7 +73,7 @@ public class EhCacheBasedTicketCache implements StatelessTicketCache, Initializi
} }
} }
public Cache getCache() { public Ehcache getCache() {
return cache; return cache;
} }
@ -99,7 +99,7 @@ public class EhCacheBasedTicketCache implements StatelessTicketCache, Initializi
cache.remove(serviceTicket); cache.remove(serviceTicket);
} }
public void setCache(Cache cache) { public void setCache(Ehcache cache) {
this.cache = cache; this.cache = cache;
} }
} }

View File

@ -15,9 +15,9 @@
package org.acegisecurity.providers.dao.cache; package org.acegisecurity.providers.dao.cache;
import net.sf.ehcache.Cache;
import net.sf.ehcache.CacheException; import net.sf.ehcache.CacheException;
import net.sf.ehcache.Element; import net.sf.ehcache.Element;
import net.sf.ehcache.Ehcache;
import org.acegisecurity.providers.dao.UserCache; import org.acegisecurity.providers.dao.UserCache;
@ -47,7 +47,7 @@ public class EhCacheBasedUserCache implements UserCache, InitializingBean {
//~ Instance fields ================================================================================================ //~ Instance fields ================================================================================================
private Cache cache; private Ehcache cache;
//~ Methods ======================================================================================================== //~ Methods ========================================================================================================
@ -55,7 +55,7 @@ public class EhCacheBasedUserCache implements UserCache, InitializingBean {
Assert.notNull(cache, "cache mandatory"); Assert.notNull(cache, "cache mandatory");
} }
public Cache getCache() { public Ehcache getCache() {
return cache; return cache;
} }
@ -101,7 +101,7 @@ public class EhCacheBasedUserCache implements UserCache, InitializingBean {
cache.remove(username); cache.remove(username);
} }
public void setCache(Cache cache) { public void setCache(Ehcache cache) {
this.cache = cache; this.cache = cache;
} }
} }

View File

@ -15,9 +15,9 @@
package org.acegisecurity.providers.x509.cache; package org.acegisecurity.providers.x509.cache;
import net.sf.ehcache.Cache;
import net.sf.ehcache.CacheException; import net.sf.ehcache.CacheException;
import net.sf.ehcache.Element; import net.sf.ehcache.Element;
import net.sf.ehcache.Ehcache;
import org.acegisecurity.providers.x509.X509UserCache; import org.acegisecurity.providers.x509.X509UserCache;
@ -50,7 +50,7 @@ public class EhCacheBasedX509UserCache implements X509UserCache, InitializingBea
//~ Instance fields ================================================================================================ //~ Instance fields ================================================================================================
private Cache cache; private Ehcache cache;
//~ Methods ======================================================================================================== //~ Methods ========================================================================================================
@ -102,7 +102,7 @@ public class EhCacheBasedX509UserCache implements X509UserCache, InitializingBea
cache.remove(userCert); cache.remove(userCert);
} }
public void setCache(Cache cache) { public void setCache(Ehcache cache) {
this.cache = cache; this.cache = cache;
} }
} }

View File

@ -17,7 +17,7 @@ package org.acegisecurity.acl.basic.cache;
import junit.framework.TestCase; import junit.framework.TestCase;
import net.sf.ehcache.Cache; import net.sf.ehcache.Ehcache;
import org.acegisecurity.MockApplicationContext; import org.acegisecurity.MockApplicationContext;
@ -56,14 +56,10 @@ public class EhCacheBasedAclEntryCacheTests extends TestCase {
//~ Methods ======================================================================================================== //~ Methods ========================================================================================================
private Cache getCache() { private Ehcache getCache() {
ApplicationContext ctx = MockApplicationContext.getContext(); ApplicationContext ctx = MockApplicationContext.getContext();
return (Cache) ctx.getBean("eHCacheBackend"); return (Ehcache) ctx.getBean("eHCacheBackend");
}
public static void main(String[] args) {
junit.textui.TestRunner.run(EhCacheBasedAclEntryCacheTests.class);
} }
public final void setUp() throws Exception { public final void setUp() throws Exception {
@ -99,7 +95,7 @@ public class EhCacheBasedAclEntryCacheTests extends TestCase {
assertTrue(true); assertTrue(true);
} }
Cache myCache = getCache(); Ehcache myCache = getCache();
cache.setCache(myCache); cache.setCache(myCache);
assertEquals(myCache, cache.getCache()); assertEquals(myCache, cache.getCache());
} }

View File

@ -17,7 +17,7 @@ package org.acegisecurity.providers.cas.cache;
import junit.framework.TestCase; import junit.framework.TestCase;
import net.sf.ehcache.Cache; import net.sf.ehcache.Ehcache;
import org.acegisecurity.GrantedAuthority; import org.acegisecurity.GrantedAuthority;
import org.acegisecurity.GrantedAuthorityImpl; import org.acegisecurity.GrantedAuthorityImpl;
@ -43,7 +43,6 @@ public class EhCacheBasedTicketCacheTests extends TestCase {
//~ Constructors =================================================================================================== //~ Constructors ===================================================================================================
public EhCacheBasedTicketCacheTests() { public EhCacheBasedTicketCacheTests() {
super();
} }
public EhCacheBasedTicketCacheTests(String arg0) { public EhCacheBasedTicketCacheTests(String arg0) {
@ -52,10 +51,10 @@ public class EhCacheBasedTicketCacheTests extends TestCase {
//~ Methods ======================================================================================================== //~ Methods ========================================================================================================
private Cache getCache() { private Ehcache getCache() {
ApplicationContext ctx = MockApplicationContext.getContext(); ApplicationContext ctx = MockApplicationContext.getContext();
return (Cache) ctx.getBean("eHCacheBackend"); return (Ehcache) ctx.getBean("eHCacheBackend");
} }
private CasAuthenticationToken getToken() { private CasAuthenticationToken getToken() {
@ -70,10 +69,6 @@ public class EhCacheBasedTicketCacheTests extends TestCase {
proxyList, "PGTIOU-0-R0zlgrl4pdAQwBvJWO3vnNpevwqStbSGcq3vKB2SqSFFRnjPHt"); proxyList, "PGTIOU-0-R0zlgrl4pdAQwBvJWO3vnNpevwqStbSGcq3vKB2SqSFFRnjPHt");
} }
public static void main(String[] args) {
junit.textui.TestRunner.run(EhCacheBasedTicketCacheTests.class);
}
public final void setUp() throws Exception { public final void setUp() throws Exception {
super.setUp(); super.setUp();
} }
@ -106,7 +101,7 @@ public class EhCacheBasedTicketCacheTests extends TestCase {
assertTrue(true); assertTrue(true);
} }
Cache myCache = getCache(); Ehcache myCache = getCache();
cache.setCache(myCache); cache.setCache(myCache);
assertEquals(myCache, cache.getCache()); assertEquals(myCache, cache.getCache());
} }

View File

@ -17,7 +17,7 @@ package org.acegisecurity.providers.dao.cache;
import junit.framework.TestCase; import junit.framework.TestCase;
import net.sf.ehcache.Cache; import net.sf.ehcache.Ehcache;
import org.acegisecurity.GrantedAuthority; import org.acegisecurity.GrantedAuthority;
import org.acegisecurity.GrantedAuthorityImpl; import org.acegisecurity.GrantedAuthorityImpl;
@ -38,7 +38,6 @@ public class EhCacheBasedUserCacheTests extends TestCase {
//~ Constructors =================================================================================================== //~ Constructors ===================================================================================================
public EhCacheBasedUserCacheTests() { public EhCacheBasedUserCacheTests() {
super();
} }
public EhCacheBasedUserCacheTests(String arg0) { public EhCacheBasedUserCacheTests(String arg0) {
@ -47,10 +46,10 @@ public class EhCacheBasedUserCacheTests extends TestCase {
//~ Methods ======================================================================================================== //~ Methods ========================================================================================================
private Cache getCache() { private Ehcache getCache() {
ApplicationContext ctx = MockApplicationContext.getContext(); ApplicationContext ctx = MockApplicationContext.getContext();
return (Cache) ctx.getBean("eHCacheBackend"); return (Ehcache) ctx.getBean("eHCacheBackend");
} }
private User getUser() { private User getUser() {
@ -58,10 +57,6 @@ public class EhCacheBasedUserCacheTests extends TestCase {
new GrantedAuthority[] {new GrantedAuthorityImpl("ROLE_ONE"), new GrantedAuthorityImpl("ROLE_TWO")}); new GrantedAuthority[] {new GrantedAuthorityImpl("ROLE_ONE"), new GrantedAuthorityImpl("ROLE_TWO")});
} }
public static void main(String[] args) {
junit.textui.TestRunner.run(EhCacheBasedUserCacheTests.class);
}
public final void setUp() throws Exception { public final void setUp() throws Exception {
super.setUp(); super.setUp();
} }
@ -94,7 +89,7 @@ public class EhCacheBasedUserCacheTests extends TestCase {
assertTrue(true); assertTrue(true);
} }
Cache myCache = getCache(); Ehcache myCache = getCache();
cache.setCache(myCache); cache.setCache(myCache);
assertEquals(myCache, cache.getCache()); assertEquals(myCache, cache.getCache());
} }

View File

@ -17,7 +17,7 @@ package org.acegisecurity.providers.x509.cache;
import junit.framework.TestCase; import junit.framework.TestCase;
import net.sf.ehcache.Cache; import net.sf.ehcache.Ehcache;
import org.acegisecurity.GrantedAuthority; import org.acegisecurity.GrantedAuthority;
import org.acegisecurity.GrantedAuthorityImpl; import org.acegisecurity.GrantedAuthorityImpl;
@ -41,7 +41,6 @@ public class EhCacheBasedX509UserCacheTests extends TestCase {
//~ Constructors =================================================================================================== //~ Constructors ===================================================================================================
public EhCacheBasedX509UserCacheTests() { public EhCacheBasedX509UserCacheTests() {
super();
} }
public EhCacheBasedX509UserCacheTests(String arg0) { public EhCacheBasedX509UserCacheTests(String arg0) {
@ -50,10 +49,10 @@ public class EhCacheBasedX509UserCacheTests extends TestCase {
//~ Methods ======================================================================================================== //~ Methods ========================================================================================================
private Cache getCache() { private Ehcache getCache() {
ApplicationContext ctx = MockApplicationContext.getContext(); ApplicationContext ctx = MockApplicationContext.getContext();
return (Cache) ctx.getBean("eHCacheBackend"); return (Ehcache) ctx.getBean("eHCacheBackend");
} }
private UserDetails getUser() { private UserDetails getUser() {