@Test(expected = IllegalArgumentException.class) public void constructorRejectsNullParameters() throws Exception { new SpringCacheBasedAclCache(null, null, null); }
public MutableAcl getFromCache(ObjectIdentity objectIdentity) { Assert.notNull(objectIdentity, "ObjectIdentity required"); return getFromCache((Object) objectIdentity); }
public void putInCache(MutableAcl acl) { Assert.notNull(acl, "Acl required"); Assert.notNull(acl.getObjectIdentity(), "ObjectIdentity required"); Assert.notNull(acl.getId(), "ID required"); if ((acl.getParentAcl() != null) && (acl.getParentAcl() instanceof MutableAcl)) { putInCache((MutableAcl) acl.getParentAcl()); } cache.put(acl.getObjectIdentity(), acl); cache.put(acl.getId(), acl); }
SpringCacheBasedAclCache myCache = new SpringCacheBasedAclCache(cache, permissionGrantingStrategy, aclAuthorizationStrategy); MutableAcl acl = new AclImpl(identity, Long.valueOf(1), aclAuthorizationStrategy, myCache.putInCache(acl); assertThat(acl).isEqualTo(myCache.getFromCache(Long.valueOf(1))); assertThat(acl).isEqualTo(myCache.getFromCache(identity)); aclAuthorizationStrategy, new ConsoleAuditLogger()); myCache.putInCache(acl2); myCache.evictFromCache(Long.valueOf(3)); myCache.evictFromCache(new ObjectIdentityImpl(TARGET_CLASS, Long.valueOf(102))); assertThat(realCache).hasSize(4); myCache.evictFromCache(Long.valueOf(1)); assertThat(realCache).hasSize(2); assertThat(acl2).isEqualTo(myCache.getFromCache(Long.valueOf(2))); assertThat(acl2).isEqualTo(myCache.getFromCache(identity2)); myCache.evictFromCache(identity2); assertThat(realCache).isEmpty();
SpringCacheBasedAclCache myCache = new SpringCacheBasedAclCache(cache, permissionGrantingStrategy, aclAuthorizationStrategy); myCache.putInCache(acl); assertThat(4).isEqualTo(realCache.size()); AclImpl aclFromCache = (AclImpl) myCache.getFromCache(Long.valueOf(1)); assertThat(aclFromCache).isEqualTo(acl); assertThat(FieldUtils.getFieldValue(aclFromCache.getParentAcl(), "permissionGrantingStrategy")).isNotNull(); assertThat(myCache.getFromCache(identity)).isEqualTo(acl); assertThat(FieldUtils.getFieldValue(aclFromCache, "aclAuthorizationStrategy")).isNotNull(); AclImpl parentAclFromCache = (AclImpl) myCache.getFromCache(Long.valueOf(2)); assertThat(parentAclFromCache).isEqualTo(parentAcl); assertThat(FieldUtils.getFieldValue(parentAclFromCache, "aclAuthorizationStrategy")).isNotNull(); assertThat(myCache.getFromCache(identityParent)).isEqualTo(parentAcl);
private MutableAcl getFromCache(Object key) { Cache.ValueWrapper element = cache.get(key); if (element == null) { return null; } return initializeTransientFields((MutableAcl) element.get()); }
private MutableAcl initializeTransientFields(MutableAcl value) { if (value instanceof AclImpl) { FieldUtils.setProtectedFieldValue("aclAuthorizationStrategy", value, this.aclAuthorizationStrategy); FieldUtils.setProtectedFieldValue("permissionGrantingStrategy", value, this.permissionGrantingStrategy); } if (value.getParentAcl() != null) { initializeTransientFields((MutableAcl) value.getParentAcl()); } return value; }
public MutableAcl getFromCache(Serializable pk) { Assert.notNull(pk, "Primary key (identifier) required"); return getFromCache((Object) pk); }
@Bean public AclCache aclCache() { return new SpringCacheBasedAclCache( cacheInstance(), permissionGrantingStrategy(), aclAuthorizationStrategy() ); }
public void putInCache(MutableAcl acl) { Assert.notNull(acl, "Acl required"); Assert.notNull(acl.getObjectIdentity(), "ObjectIdentity required"); Assert.notNull(acl.getId(), "ID required"); if ((acl.getParentAcl() != null) && (acl.getParentAcl() instanceof MutableAcl)) { putInCache((MutableAcl) acl.getParentAcl()); } cache.put(acl.getObjectIdentity(), acl); cache.put(acl.getId(), acl); }
private MutableAcl getFromCache(Object key) { Cache.ValueWrapper element = cache.get(key); if (element == null) { return null; } return initializeTransientFields((MutableAcl) element.get()); }
public void evictFromCache(Serializable pk) { Assert.notNull(pk, "Primary key (identifier) required"); MutableAcl acl = getFromCache(pk); if (acl != null) { cache.evict(acl.getId()); cache.evict(acl.getObjectIdentity()); } }
@Bean public AclCache aclCache() { Cache cache = new CaffeineCache("aclCache", Caffeine.newBuilder().maximumSize(10000).build()); return new SpringCacheBasedAclCache( cache, permissionGrantingStrategy(), aclAuthorizationStrategy()); }
private MutableAcl initializeTransientFields(MutableAcl value) { if (value instanceof AclImpl) { FieldUtils.setProtectedFieldValue("aclAuthorizationStrategy", value, this.aclAuthorizationStrategy); FieldUtils.setProtectedFieldValue("permissionGrantingStrategy", value, this.permissionGrantingStrategy); } if (value.getParentAcl() != null) { initializeTransientFields((MutableAcl) value.getParentAcl()); } return value; }
public void evictFromCache(ObjectIdentity objectIdentity) { Assert.notNull(objectIdentity, "ObjectIdentity required"); MutableAcl acl = getFromCache(objectIdentity); if (acl != null) { cache.evict(acl.getId()); cache.evict(acl.getObjectIdentity()); } }
public MutableAcl getFromCache(ObjectIdentity objectIdentity) { Assert.notNull(objectIdentity, "ObjectIdentity required"); return getFromCache((Object) objectIdentity); }
public MutableAcl getFromCache(Serializable pk) { Assert.notNull(pk, "Primary key (identifier) required"); return getFromCache((Object) pk); }
public void evictFromCache(ObjectIdentity objectIdentity) { Assert.notNull(objectIdentity, "ObjectIdentity required"); MutableAcl acl = getFromCache(objectIdentity); if (acl != null) { cache.evict(acl.getId()); cache.evict(acl.getObjectIdentity()); } }
public void evictFromCache(Serializable pk) { Assert.notNull(pk, "Primary key (identifier) required"); MutableAcl acl = getFromCache(pk); if (acl != null) { cache.evict(acl.getId()); cache.evict(acl.getObjectIdentity()); } }