SEC-147: Add processDomainObjectClass property to AfterInvocationProviders.

This commit is contained in:
Ben Alex 2006-04-26 03:30:27 +00:00
parent de4af379cc
commit 5d9ed78b50
2 changed files with 25 additions and 1 deletions

View File

@ -113,9 +113,16 @@ public class BasicAclEntryAfterInvocationCollectionFilteringProvider
private AclManager aclManager; private AclManager aclManager;
private String processConfigAttribute = "AFTER_ACL_COLLECTION_READ"; private String processConfigAttribute = "AFTER_ACL_COLLECTION_READ";
private int[] requirePermission = {SimpleAclEntry.READ}; private int[] requirePermission = {SimpleAclEntry.READ};
private Class processDomainObjectClass = Object.class;
//~ Methods ================================================================ //~ Methods ================================================================
public void setProcessDomainObjectClass(Class processDomainObjectClass) {
Assert.notNull(processDomainObjectClass,
"processDomainObjectClass cannot be set to null");
this.processDomainObjectClass = processDomainObjectClass;
}
public void setAclManager(AclManager aclManager) { public void setAclManager(AclManager aclManager) {
this.aclManager = aclManager; this.aclManager = aclManager;
} }
@ -195,6 +202,8 @@ public class BasicAclEntryAfterInvocationCollectionFilteringProvider
if (domainObject == null) { if (domainObject == null) {
hasPermission = true; hasPermission = true;
} else if (!processDomainObjectClass.isAssignableFrom(domainObject.getClass())) {
hasPermission = true;
} else { } else {
acls = aclManager.getAcls(domainObject, authentication); acls = aclManager.getAcls(domainObject, authentication);
} }

View File

@ -100,9 +100,16 @@ public class BasicAclEntryAfterInvocationProvider
protected MessageSourceAccessor messages = AcegiMessageSource.getAccessor(); protected MessageSourceAccessor messages = AcegiMessageSource.getAccessor();
private String processConfigAttribute = "AFTER_ACL_READ"; private String processConfigAttribute = "AFTER_ACL_READ";
private int[] requirePermission = {SimpleAclEntry.READ}; private int[] requirePermission = {SimpleAclEntry.READ};
private Class processDomainObjectClass = Object.class;
//~ Methods ================================================================ //~ Methods ================================================================
public void setProcessDomainObjectClass(Class processDomainObjectClass) {
Assert.notNull(processDomainObjectClass,
"processDomainObjectClass cannot be set to null");
this.processDomainObjectClass = processDomainObjectClass;
}
public void afterPropertiesSet() throws Exception { public void afterPropertiesSet() throws Exception {
Assert.notNull(processConfigAttribute, Assert.notNull(processConfigAttribute,
"A processConfigAttribute is mandatory"); "A processConfigAttribute is mandatory");
@ -135,6 +142,14 @@ public class BasicAclEntryAfterInvocationProvider
return null; return null;
} }
if (!processDomainObjectClass.isAssignableFrom(returnedObject.getClass())) {
if (logger.isDebugEnabled()) {
logger.debug("Return object is not applicable for this provider, skipping");
}
return null;
}
AclEntry[] acls = aclManager.getAcls(returnedObject, AclEntry[] acls = aclManager.getAcls(returnedObject,
authentication); authentication);