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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -17,7 +17,7 @@ package org.acegisecurity.providers.dao.cache;
import junit.framework.TestCase;
import net.sf.ehcache.Cache;
import net.sf.ehcache.Ehcache;
import org.acegisecurity.GrantedAuthority;
import org.acegisecurity.GrantedAuthorityImpl;
@ -38,7 +38,6 @@ public class EhCacheBasedUserCacheTests extends TestCase {
//~ Constructors ===================================================================================================
public EhCacheBasedUserCacheTests() {
super();
}
public EhCacheBasedUserCacheTests(String arg0) {
@ -47,10 +46,10 @@ public class EhCacheBasedUserCacheTests extends TestCase {
//~ Methods ========================================================================================================
private Cache getCache() {
private Ehcache getCache() {
ApplicationContext ctx = MockApplicationContext.getContext();
return (Cache) ctx.getBean("eHCacheBackend");
return (Ehcache) ctx.getBean("eHCacheBackend");
}
private User getUser() {
@ -58,10 +57,6 @@ public class EhCacheBasedUserCacheTests extends TestCase {
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 {
super.setUp();
}
@ -94,7 +89,7 @@ public class EhCacheBasedUserCacheTests extends TestCase {
assertTrue(true);
}
Cache myCache = getCache();
Ehcache myCache = getCache();
cache.setCache(myCache);
assertEquals(myCache, cache.getCache());
}

View File

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