Acl acl = aclCache.getFromCache(oid); aclCache.putInCache((AclImpl) loadedAcl);
private void clearCacheIncludingChildren(ObjectIdentity objectIdentity) { Assert.notNull(objectIdentity, "ObjectIdentity required"); List<ObjectIdentity> children = findChildren(objectIdentity); if (children != null) { for (ObjectIdentity child : children) { clearCacheIncludingChildren(child); } } aclCache.evictFromCache(objectIdentity); }
@AfterTransaction public void clearContextAndData() throws Exception { SecurityContextHolder.clearContext(); jdbcTemplate.execute("drop table acl_entry"); jdbcTemplate.execute("drop table acl_object_identity"); jdbcTemplate.execute("drop table acl_class"); jdbcTemplate.execute("drop table acl_sid"); aclCache.clearCache(); }
MutableAcl cached = aclCache.getFromCache(new Long(parentId));
@Test @Transactional public void deleteAclRemovesRowsFromDatabase() throws Exception { SecurityContextHolder.getContext().setAuthentication(auth); MutableAcl child = jdbcMutableAclService.createAcl(getChildOid()); child.insertAce(0, BasePermission.DELETE, new PrincipalSid(auth), false); jdbcMutableAclService.updateAcl(child); // Remove the child and check all related database rows were removed accordingly jdbcMutableAclService.deleteAcl(getChildOid(), false); assertThat( jdbcTemplate.queryForList(SELECT_ALL_CLASSES, new Object[] { getTargetClass() })).hasSize(1); assertThat(jdbcTemplate.queryForList("select * from acl_object_identity") ).isEmpty(); assertThat(jdbcTemplate.queryForList("select * from acl_entry")).isEmpty(); // Check the cache assertThat(aclCache.getFromCache(getChildOid())).isNull(); assertThat(aclCache.getFromCache(Long.valueOf(102))).isNull(); }
Acl acl = aclCache.getFromCache(oid); aclCache.putInCache((AclImpl) loadedAcl);
aclCache.evictFromCache(objectIdentity);
MutableAcl cached = aclCache.getFromCache(new Long(parentId));
@Override public void rollbackTransaction(String transactionId) { aclCache.clearCache(); aclClassService.clearCache(); } }
Acl aclFromCache = aclCache.getFromCache(object); acls.put(object, acl); aclCache.putInCache(acl);
private void clearCacheIncludingChildren(ObjectIdentity objectIdentity) { Assert.notNull(objectIdentity, "ObjectIdentity required"); List<ObjectIdentity> children = findChildren(objectIdentity); if (children != null) { for (ObjectIdentity child : children) { clearCacheIncludingChildren(child); } } aclCache.evictFromCache(objectIdentity); }
@Transactional @Override public void deleteAclClass(String type) { LOGGER.debug("Delete AclClass for type {}.", type); jdbcTemplate.update(SQL_DELETE_FROM_ACL_CLASS, type); aclClassCache.invalidate(type); aclCache.clearCache(); }
@Override @Transactional(propagation = Propagation.REQUIRES_NEW) public void removeAcl(ISecuredObject<?> securedObject) { ObjectIdentityImpl objectIdentity = new ObjectIdentityImpl(securedObject.getSecuredClass(), securedObject.getIdForACL()); aclCache.evictFromCache(objectIdentity); aclService.deleteAcl(objectIdentity, false); }
@Transactional public void deleteAcl(ObjectIdentity objectIdentity, boolean deleteChildren) throws ChildrenExistException { AclSecuredClassDescriptionData aclClass = aclSecuredClassDao.load(objectIdentity.getType()); if (aclClass == null) { return; } // No need to check for nulls, as guaranteed non-null by // ObjectIdentity.getIdentifier() interface contract String identifier = objectIdentity.getIdentifier().toString(); long id = (Long.valueOf(identifier)).longValue(); AclSecuredObjectIdentityData aclObjectIdentity = aclObjectIdentityDao.findByObjectId(aclClass.getId(), id); if (aclObjectIdentity != null) { removeAcl(aclObjectIdentity); aclCache.evictFromCache(objectIdentity); } }
@Transactional public MutableAcl updateAcl(MutableAcl acl) throws NotFoundException { // Delete this ACL's ACEs in the acl_entry table // long oid = ((Long) acl.getId()).longValue(); AclSecuredObjectIdentityData aclo = updateAclObjectIdentity(acl); aclEntryDao.deleteByIdentityId(aclo.getId()); aclCache.evictFromCache(acl.getObjectIdentity()); // Create this ACL's ACEs in the acl_entry table createRecords(acl); // Retrieve the ACL via superclass (ensures cache registration, proper // retrieval etc) return (MutableAcl) readAclById(acl.getObjectIdentity()); }
aclCache.evictFromCache(objectIdentity);
@Transactional(propagation = Propagation.REQUIRES_NEW) private void removeAclRecords(Long aclId, String className, SpringAclSid sid) { // we need to remove also the superclass object identity ACLs Class<? extends ISecuredObject<?>> clazz = SecuredClassHelper.getSecuredClass(className); while (!isTopParentClass(clazz)) { if (isHibernateProxy(clazz)) { clazz = getSecuredSuperClass(clazz); continue; } ObjectIdentityImpl objectIdentity = new ObjectIdentityImpl(clazz, aclId); if (sid != null) { aclEntryDao.deleteByIdentityIdAndSid(aclId, clazz, sid, clazz.getName()); } else { aclService.deleteAcl(objectIdentity, false); } aclEntryDao.deleteByIdentityIdAndSid(aclId, clazz, sid); aclCache.evictFromCache(objectIdentity); //aclService.readAclById(objectIdentity); // update cache clazz = getSecuredSuperClass(clazz); } }
@Transactional(propagation = Propagation.REQUIRES_NEW) private void removeAclRecords(Class<? extends ISecuredObject<?>> securedClass, SpringAclSid sid) { // we need to remove also the superclass object identity ACLs Class<? extends ISecuredObject<?>> superClass = securedClass; while (!isTopParentClass(superClass)) { if (isHibernateProxy(superClass)) { superClass = getSecuredSuperClass(superClass); continue; } aclEntryDao.deleteByClassnameAndSid(superClass, sid); List<AclEntryData> entries = aclEntryDao.findByClassnameAndSid(superClass, sid); for (AclEntryData entry : entries) { aclCache.evictFromCache(entry.getObjectIdentity()); aclService.readAclById((ObjectIdentity) entry.getObjectIdentity()); // update // cache } superClass = getSecuredSuperClass(superClass); } }