@ -73,11 +73,11 @@ public class BasicAclEntryVoterTests extends TestCase {
// Setup an AclManager
// Setup an AclManager
AclManager aclManager = new MockAclManager ( domainObject , "rod" ,
AclManager aclManager = new MockAclManager ( domainObject , "rod" ,
new AclEntry [ ] {
new AclEntry [ ] {
new MockAclEntry ( ) ,
new MockAclEntry ( ) ,
new SimpleAclEntry ( "rod" , new MockAclObjectIdentity ( ) , null , SimpleAclEntry . ADMINISTRATION ) ,
new SimpleAclEntry ( "rod" , new MockAclObjectIdentity ( ) , null , SimpleAclEntry . ADMINISTRATION ) ,
new SimpleAclEntry ( "rod" , new MockAclObjectIdentity ( ) , null , SimpleAclEntry . READ ) ,
new SimpleAclEntry ( "rod" , new MockAclObjectIdentity ( ) , null , SimpleAclEntry . READ ) ,
new SimpleAclEntry ( "rod" , new MockAclObjectIdentity ( ) , null , SimpleAclEntry . DELETE )
new SimpleAclEntry ( "rod" , new MockAclObjectIdentity ( ) , null , SimpleAclEntry . DELETE )
} ) ;
} ) ;
// Wire up a voter
// Wire up a voter
@ -86,21 +86,20 @@ public class BasicAclEntryVoterTests extends TestCase {
assertEquals ( aclManager , voter . getAclManager ( ) ) ;
assertEquals ( aclManager , voter . getAclManager ( ) ) ;
voter . setProcessConfigAttribute ( "FOO_ADMIN_OR_WRITE_ACCESS" ) ;
voter . setProcessConfigAttribute ( "FOO_ADMIN_OR_WRITE_ACCESS" ) ;
assertEquals ( "FOO_ADMIN_OR_WRITE_ACCESS" , voter . getProcessConfigAttribute ( ) ) ;
assertEquals ( "FOO_ADMIN_OR_WRITE_ACCESS" , voter . getProcessConfigAttribute ( ) ) ;
voter . setRequirePermission ( new int [ ] { SimpleAclEntry . ADMINISTRATION , SimpleAclEntry . WRITE } ) ;
voter . setRequirePermission ( new int [ ] { SimpleAclEntry . ADMINISTRATION , SimpleAclEntry . WRITE } ) ;
assertEquals ( 2 , voter . getRequirePermission ( ) . length ) ;
assertEquals ( 2 , voter . getRequirePermission ( ) . length ) ;
voter . setProcessDomainObjectClass ( SomeDomainObject . class ) ;
voter . setProcessDomainObjectClass ( SomeDomainObject . class ) ;
assertEquals ( SomeDomainObject . class , voter . getProcessDomainObjectClass ( ) ) ;
assertEquals ( SomeDomainObject . class , voter . getProcessDomainObjectClass ( ) ) ;
voter . afterPropertiesSet ( ) ;
voter . afterPropertiesSet ( ) ;
// Wire up an invocation to be voted on
// Wire up an invocation to be voted on
ConfigAttributeDefinition attr = new ConfigAttributeDefinition ( ) ;
ConfigAttributeDefinition attr = new ConfigAttributeDefinition ( "FOO_ADMIN_OR_WRITE_ACCESS" ) ;
attr . addConfigAttribute ( new SecurityConfig ( "FOO_ADMIN_OR_WRITE_ACCESS" ) ) ;
// Setup a MockMethodInvocation, so voter can retrieve domainObject
// Setup a MockMethodInvocation, so voter can retrieve domainObject
MethodInvocation mi = getMethodInvocation ( domainObject ) ;
MethodInvocation mi = getMethodInvocation ( domainObject ) ;
assertEquals ( AccessDecisionVoter . ACCESS_GRANTED ,
assertEquals ( AccessDecisionVoter . ACCESS_GRANTED ,
voter . vote ( new UsernamePasswordAuthenticationToken ( "rod" , null ) , mi , attr ) ) ;
voter . vote ( new UsernamePasswordAuthenticationToken ( "rod" , null ) , mi , attr ) ) ;
}
}
public void testOnlySupportsMethodInvocationAndJoinPoint ( ) {
public void testOnlySupportsMethodInvocationAndJoinPoint ( ) {
@ -206,30 +205,29 @@ public class BasicAclEntryVoterTests extends TestCase {
// Setup an AclManager
// Setup an AclManager
AclManager aclManager = new MockAclManager ( domainObject , "rod" ,
AclManager aclManager = new MockAclManager ( domainObject , "rod" ,
new AclEntry [ ] {
new AclEntry [ ] {
new MockAclEntry ( ) ,
new MockAclEntry ( ) ,
new SimpleAclEntry ( "rod" , new MockAclObjectIdentity ( ) , null , SimpleAclEntry . ADMINISTRATION ) ,
new SimpleAclEntry ( "rod" , new MockAclObjectIdentity ( ) , null , SimpleAclEntry . ADMINISTRATION ) ,
new SimpleAclEntry ( "rod" , new MockAclObjectIdentity ( ) , null , SimpleAclEntry . READ ) ,
new SimpleAclEntry ( "rod" , new MockAclObjectIdentity ( ) , null , SimpleAclEntry . READ ) ,
new SimpleAclEntry ( "rod" , new MockAclObjectIdentity ( ) , null , SimpleAclEntry . DELETE )
new SimpleAclEntry ( "rod" , new MockAclObjectIdentity ( ) , null , SimpleAclEntry . DELETE )
} ) ;
} ) ;
// Wire up a voter
// Wire up a voter
BasicAclEntryVoter voter = new BasicAclEntryVoter ( ) ;
BasicAclEntryVoter voter = new BasicAclEntryVoter ( ) ;
voter . setAclManager ( aclManager ) ;
voter . setAclManager ( aclManager ) ;
voter . setProcessConfigAttribute ( "FOO_ADMIN_OR_WRITE_ACCESS" ) ;
voter . setProcessConfigAttribute ( "FOO_ADMIN_OR_WRITE_ACCESS" ) ;
voter . setRequirePermission ( new int [ ] { SimpleAclEntry . ADMINISTRATION , SimpleAclEntry . WRITE } ) ;
voter . setRequirePermission ( new int [ ] { SimpleAclEntry . ADMINISTRATION , SimpleAclEntry . WRITE } ) ;
voter . setProcessDomainObjectClass ( SomeDomainObject . class ) ;
voter . setProcessDomainObjectClass ( SomeDomainObject . class ) ;
voter . afterPropertiesSet ( ) ;
voter . afterPropertiesSet ( ) ;
// Wire up an invocation to be voted on
// Wire up an invocation to be voted on
ConfigAttributeDefinition attr = new ConfigAttributeDefinition ( ) ;
ConfigAttributeDefinition attr = new ConfigAttributeDefinition ( "A_DIFFERENT_ATTRIBUTE" ) ;
attr . addConfigAttribute ( new SecurityConfig ( "A_DIFFERENT_ATTRIBUTE" ) ) ;
// Setup a MockMethodInvocation, so voter can retrieve domainObject
// Setup a MockMethodInvocation, so voter can retrieve domainObject
MethodInvocation mi = getMethodInvocation ( domainObject ) ;
MethodInvocation mi = getMethodInvocation ( domainObject ) ;
assertEquals ( AccessDecisionVoter . ACCESS_ABSTAIN ,
assertEquals ( AccessDecisionVoter . ACCESS_ABSTAIN ,
voter . vote ( new UsernamePasswordAuthenticationToken ( "rod" , null ) , mi , attr ) ) ;
voter . vote ( new UsernamePasswordAuthenticationToken ( "rod" , null ) , mi , attr ) ) ;
}
}
public void testVoterAbstainsIfNotMatchingConfigAttribute ( )
public void testVoterAbstainsIfNotMatchingConfigAttribute ( )
@ -239,30 +237,29 @@ public class BasicAclEntryVoterTests extends TestCase {
// Setup an AclManager
// Setup an AclManager
AclManager aclManager = new MockAclManager ( domainObject , "rod" ,
AclManager aclManager = new MockAclManager ( domainObject , "rod" ,
new AclEntry [ ] {
new AclEntry [ ] {
new MockAclEntry ( ) ,
new MockAclEntry ( ) ,
new SimpleAclEntry ( "rod" , new MockAclObjectIdentity ( ) , null , SimpleAclEntry . ADMINISTRATION ) ,
new SimpleAclEntry ( "rod" , new MockAclObjectIdentity ( ) , null , SimpleAclEntry . ADMINISTRATION ) ,
new SimpleAclEntry ( "rod" , new MockAclObjectIdentity ( ) , null , SimpleAclEntry . READ ) ,
new SimpleAclEntry ( "rod" , new MockAclObjectIdentity ( ) , null , SimpleAclEntry . READ ) ,
new SimpleAclEntry ( "rod" , new MockAclObjectIdentity ( ) , null , SimpleAclEntry . DELETE )
new SimpleAclEntry ( "rod" , new MockAclObjectIdentity ( ) , null , SimpleAclEntry . DELETE )
} ) ;
} ) ;
// Wire up a voter
// Wire up a voter
BasicAclEntryVoter voter = new BasicAclEntryVoter ( ) ;
BasicAclEntryVoter voter = new BasicAclEntryVoter ( ) ;
voter . setAclManager ( aclManager ) ;
voter . setAclManager ( aclManager ) ;
voter . setProcessConfigAttribute ( "FOO_ADMIN_OR_WRITE_ACCESS" ) ;
voter . setProcessConfigAttribute ( "FOO_ADMIN_OR_WRITE_ACCESS" ) ;
voter . setRequirePermission ( new int [ ] { SimpleAclEntry . ADMINISTRATION , SimpleAclEntry . WRITE } ) ;
voter . setRequirePermission ( new int [ ] { SimpleAclEntry . ADMINISTRATION , SimpleAclEntry . WRITE } ) ;
voter . setProcessDomainObjectClass ( SomeDomainObject . class ) ;
voter . setProcessDomainObjectClass ( SomeDomainObject . class ) ;
voter . afterPropertiesSet ( ) ;
voter . afterPropertiesSet ( ) ;
// Wire up an invocation to be voted on
// Wire up an invocation to be voted on
ConfigAttributeDefinition attr = new ConfigAttributeDefinition ( ) ;
ConfigAttributeDefinition attr = new ConfigAttributeDefinition ( "FOO_ADMIN_OR_WRITE_ACCESS" ) ;
attr . addConfigAttribute ( new SecurityConfig ( "FOO_ADMIN_OR_WRITE_ACCESS" ) ) ;
// Setup a MockMethodInvocation, so voter can retrieve domainObject
// Setup a MockMethodInvocation, so voter can retrieve domainObject
MethodInvocation mi = getMethodInvocation ( domainObject ) ;
MethodInvocation mi = getMethodInvocation ( domainObject ) ;
assertEquals ( AccessDecisionVoter . ACCESS_ABSTAIN ,
assertEquals ( AccessDecisionVoter . ACCESS_ABSTAIN ,
voter . vote ( new UsernamePasswordAuthenticationToken ( "rod" , null ) , mi , attr ) ) ;
voter . vote ( new UsernamePasswordAuthenticationToken ( "rod" , null ) , mi , attr ) ) ;
}
}
public void testVoterCanDenyAccessBasedOnInternalMethodOfDomainObject ( )
public void testVoterCanDenyAccessBasedOnInternalMethodOfDomainObject ( )
@ -272,29 +269,28 @@ public class BasicAclEntryVoterTests extends TestCase {
// Setup an AclManager
// Setup an AclManager
AclManager aclManager = new MockAclManager ( domainObject . getParent ( ) , "rod" ,
AclManager aclManager = new MockAclManager ( domainObject . getParent ( ) , "rod" ,
new AclEntry [ ] {
new AclEntry [ ] {
new MockAclEntry ( ) ,
new MockAclEntry ( ) ,
new SimpleAclEntry ( "rod" , new MockAclObjectIdentity ( ) , null , SimpleAclEntry . DELETE )
new SimpleAclEntry ( "rod" , new MockAclObjectIdentity ( ) , null , SimpleAclEntry . DELETE )
} ) ;
} ) ;
// Wire up a voter
// Wire up a voter
BasicAclEntryVoter voter = new BasicAclEntryVoter ( ) ;
BasicAclEntryVoter voter = new BasicAclEntryVoter ( ) ;
voter . setAclManager ( aclManager ) ;
voter . setAclManager ( aclManager ) ;
voter . setProcessConfigAttribute ( "FOO_ADMIN_OR_WRITE_ACCESS" ) ;
voter . setProcessConfigAttribute ( "FOO_ADMIN_OR_WRITE_ACCESS" ) ;
voter . setRequirePermission ( new int [ ] { SimpleAclEntry . ADMINISTRATION , SimpleAclEntry . WRITE } ) ;
voter . setRequirePermission ( new int [ ] { SimpleAclEntry . ADMINISTRATION , SimpleAclEntry . WRITE } ) ;
voter . setProcessDomainObjectClass ( SomeDomainObject . class ) ;
voter . setProcessDomainObjectClass ( SomeDomainObject . class ) ;
voter . setInternalMethod ( "getParent" ) ;
voter . setInternalMethod ( "getParent" ) ;
voter . afterPropertiesSet ( ) ;
voter . afterPropertiesSet ( ) ;
// Wire up an invocation to be voted on
// Wire up an invocation to be voted on
ConfigAttributeDefinition attr = new ConfigAttributeDefinition ( ) ;
ConfigAttributeDefinition attr = new ConfigAttributeDefinition ( "FOO_ADMIN_OR_WRITE_ACCESS" ) ;
attr . addConfigAttribute ( new SecurityConfig ( "FOO_ADMIN_OR_WRITE_ACCESS" ) ) ;
// Setup a MockMethodInvocation, so voter can retrieve domainObject
// Setup a MockMethodInvocation, so voter can retrieve domainObject
MethodInvocation mi = getMethodInvocation ( domainObject ) ;
MethodInvocation mi = getMethodInvocation ( domainObject ) ;
assertEquals ( AccessDecisionVoter . ACCESS_DENIED ,
assertEquals ( AccessDecisionVoter . ACCESS_DENIED ,
voter . vote ( new UsernamePasswordAuthenticationToken ( "rod" , null ) , mi , attr ) ) ;
voter . vote ( new UsernamePasswordAuthenticationToken ( "rod" , null ) , mi , attr ) ) ;
}
}
public void testVoterCanDenyAccessIfPrincipalHasNoPermissionsAtAllToDomainObject ( )
public void testVoterCanDenyAccessIfPrincipalHasNoPermissionsAtAllToDomainObject ( )
@ -304,30 +300,29 @@ public class BasicAclEntryVoterTests extends TestCase {
// Setup an AclManager
// Setup an AclManager
AclManager aclManager = new MockAclManager ( domainObject , "rod" ,
AclManager aclManager = new MockAclManager ( domainObject , "rod" ,
new AclEntry [ ] {
new AclEntry [ ] {
new MockAclEntry ( ) ,
new MockAclEntry ( ) ,
new SimpleAclEntry ( "rod" , new MockAclObjectIdentity ( ) , null , SimpleAclEntry . DELETE )
new SimpleAclEntry ( "rod" , new MockAclObjectIdentity ( ) , null , SimpleAclEntry . DELETE )
} ) ;
} ) ;
// Wire up a voter
// Wire up a voter
BasicAclEntryVoter voter = new BasicAclEntryVoter ( ) ;
BasicAclEntryVoter voter = new BasicAclEntryVoter ( ) ;
voter . setAclManager ( aclManager ) ;
voter . setAclManager ( aclManager ) ;
voter . setProcessConfigAttribute ( "FOO_ADMIN_OR_WRITE_ACCESS" ) ;
voter . setProcessConfigAttribute ( "FOO_ADMIN_OR_WRITE_ACCESS" ) ;
voter . setRequirePermission ( new int [ ] { SimpleAclEntry . ADMINISTRATION , SimpleAclEntry . WRITE } ) ;
voter . setRequirePermission ( new int [ ] { SimpleAclEntry . ADMINISTRATION , SimpleAclEntry . WRITE } ) ;
voter . setProcessDomainObjectClass ( SomeDomainObject . class ) ;
voter . setProcessDomainObjectClass ( SomeDomainObject . class ) ;
voter . setInternalMethod ( "getParent" ) ;
voter . setInternalMethod ( "getParent" ) ;
voter . afterPropertiesSet ( ) ;
voter . afterPropertiesSet ( ) ;
// Wire up an invocation to be voted on
// Wire up an invocation to be voted on
ConfigAttributeDefinition attr = new ConfigAttributeDefinition ( ) ;
ConfigAttributeDefinition attr = new ConfigAttributeDefinition ( "FOO_ADMIN_OR_WRITE_ACCESS" ) ;
attr . addConfigAttribute ( new SecurityConfig ( "FOO_ADMIN_OR_WRITE_ACCESS" ) ) ;
// Setup a MockMethodInvocation, so voter can retrieve domainObject
// Setup a MockMethodInvocation, so voter can retrieve domainObject
MethodInvocation mi = getMethodInvocation ( domainObject ) ;
MethodInvocation mi = getMethodInvocation ( domainObject ) ;
// NB: scott is the principal, not rod
// NB: scott is the principal, not rod
assertEquals ( AccessDecisionVoter . ACCESS_DENIED ,
assertEquals ( AccessDecisionVoter . ACCESS_DENIED ,
voter . vote ( new UsernamePasswordAuthenticationToken ( "scott" , null ) , mi , attr ) ) ;
voter . vote ( new UsernamePasswordAuthenticationToken ( "scott" , null ) , mi , attr ) ) ;
}
}
public void testVoterCanGrantAccessBasedOnInternalMethodOfDomainObject ( )
public void testVoterCanGrantAccessBasedOnInternalMethodOfDomainObject ( )
@ -337,33 +332,32 @@ public class BasicAclEntryVoterTests extends TestCase {
// Setup an AclManager
// Setup an AclManager
AclManager aclManager = new MockAclManager ( domainObject . getParent ( ) , "rod" ,
AclManager aclManager = new MockAclManager ( domainObject . getParent ( ) , "rod" ,
new AclEntry [ ] {
new AclEntry [ ] {
new MockAclEntry ( ) ,
new MockAclEntry ( ) ,
new SimpleAclEntry ( "rod" , new MockAclObjectIdentity ( ) , null , SimpleAclEntry . ADMINISTRATION ) ,
new SimpleAclEntry ( "rod" , new MockAclObjectIdentity ( ) , null , SimpleAclEntry . ADMINISTRATION ) ,
new SimpleAclEntry ( "rod" , new MockAclObjectIdentity ( ) , null , SimpleAclEntry . READ ) ,
new SimpleAclEntry ( "rod" , new MockAclObjectIdentity ( ) , null , SimpleAclEntry . READ ) ,
new SimpleAclEntry ( "rod" , new MockAclObjectIdentity ( ) , null , SimpleAclEntry . DELETE )
new SimpleAclEntry ( "rod" , new MockAclObjectIdentity ( ) , null , SimpleAclEntry . DELETE )
} ) ;
} ) ;
// Wire up a voter
// Wire up a voter
BasicAclEntryVoter voter = new BasicAclEntryVoter ( ) ;
BasicAclEntryVoter voter = new BasicAclEntryVoter ( ) ;
voter . setAclManager ( aclManager ) ;
voter . setAclManager ( aclManager ) ;
voter . setProcessConfigAttribute ( "FOO_ADMIN_OR_WRITE_ACCESS" ) ;
voter . setProcessConfigAttribute ( "FOO_ADMIN_OR_WRITE_ACCESS" ) ;
voter . setRequirePermission ( new int [ ] { SimpleAclEntry . ADMINISTRATION , SimpleAclEntry . WRITE } ) ;
voter . setRequirePermission ( new int [ ] { SimpleAclEntry . ADMINISTRATION , SimpleAclEntry . WRITE } ) ;
voter . setProcessDomainObjectClass ( SomeDomainObject . class ) ;
voter . setProcessDomainObjectClass ( SomeDomainObject . class ) ;
voter . setInternalMethod ( "getParent" ) ;
voter . setInternalMethod ( "getParent" ) ;
assertEquals ( "getParent" , voter . getInternalMethod ( ) ) ;
assertEquals ( "getParent" , voter . getInternalMethod ( ) ) ;
voter . afterPropertiesSet ( ) ;
voter . afterPropertiesSet ( ) ;
// Wire up an invocation to be voted on
// Wire up an invocation to be voted on
ConfigAttributeDefinition attr = new ConfigAttributeDefinition ( ) ;
ConfigAttributeDefinition attr = new ConfigAttributeDefinition ( "FOO_ADMIN_OR_WRITE_ACCESS" ) ;
attr . addConfigAttribute ( new SecurityConfig ( "FOO_ADMIN_OR_WRITE_ACCESS" ) ) ;
// Setup a MockMethodInvocation, so voter can retrieve domainObject
// Setup a MockMethodInvocation, so voter can retrieve domainObject
// (well actually it will access domainObject.getParent())
// (well actually it will access domainObject.getParent())
MethodInvocation mi = getMethodInvocation ( domainObject ) ;
MethodInvocation mi = getMethodInvocation ( domainObject ) ;
assertEquals ( AccessDecisionVoter . ACCESS_GRANTED ,
assertEquals ( AccessDecisionVoter . ACCESS_GRANTED ,
voter . vote ( new UsernamePasswordAuthenticationToken ( "rod" , null ) , mi , attr ) ) ;
voter . vote ( new UsernamePasswordAuthenticationToken ( "rod" , null ) , mi , attr ) ) ;
}
}
public void testVoterThrowsExceptionIfInvalidInternalMethodOfDomainObject ( )
public void testVoterThrowsExceptionIfInvalidInternalMethodOfDomainObject ( )
@ -373,25 +367,24 @@ public class BasicAclEntryVoterTests extends TestCase {
// Setup an AclManager
// Setup an AclManager
AclManager aclManager = new MockAclManager ( domainObject . getParent ( ) , "rod" ,
AclManager aclManager = new MockAclManager ( domainObject . getParent ( ) , "rod" ,
new AclEntry [ ] {
new AclEntry [ ] {
new MockAclEntry ( ) ,
new MockAclEntry ( ) ,
new SimpleAclEntry ( "rod" , new MockAclObjectIdentity ( ) , null , SimpleAclEntry . ADMINISTRATION ) ,
new SimpleAclEntry ( "rod" , new MockAclObjectIdentity ( ) , null , SimpleAclEntry . ADMINISTRATION ) ,
new SimpleAclEntry ( "rod" , new MockAclObjectIdentity ( ) , null , SimpleAclEntry . READ ) ,
new SimpleAclEntry ( "rod" , new MockAclObjectIdentity ( ) , null , SimpleAclEntry . READ ) ,
new SimpleAclEntry ( "rod" , new MockAclObjectIdentity ( ) , null , SimpleAclEntry . DELETE )
new SimpleAclEntry ( "rod" , new MockAclObjectIdentity ( ) , null , SimpleAclEntry . DELETE )
} ) ;
} ) ;
// Wire up a voter
// Wire up a voter
BasicAclEntryVoter voter = new BasicAclEntryVoter ( ) ;
BasicAclEntryVoter voter = new BasicAclEntryVoter ( ) ;
voter . setAclManager ( aclManager ) ;
voter . setAclManager ( aclManager ) ;
voter . setProcessConfigAttribute ( "FOO_ADMIN_OR_WRITE_ACCESS" ) ;
voter . setProcessConfigAttribute ( "FOO_ADMIN_OR_WRITE_ACCESS" ) ;
voter . setRequirePermission ( new int [ ] { SimpleAclEntry . ADMINISTRATION , SimpleAclEntry . WRITE } ) ;
voter . setRequirePermission ( new int [ ] { SimpleAclEntry . ADMINISTRATION , SimpleAclEntry . WRITE } ) ;
voter . setProcessDomainObjectClass ( SomeDomainObject . class ) ;
voter . setProcessDomainObjectClass ( SomeDomainObject . class ) ;
voter . setInternalMethod ( "getNonExistentParentName" ) ;
voter . setInternalMethod ( "getNonExistentParentName" ) ;
voter . afterPropertiesSet ( ) ;
voter . afterPropertiesSet ( ) ;
// Wire up an invocation to be voted on
// Wire up an invocation to be voted on
ConfigAttributeDefinition attr = new ConfigAttributeDefinition ( ) ;
ConfigAttributeDefinition attr = new ConfigAttributeDefinition ( "FOO_ADMIN_OR_WRITE_ACCESS" ) ;
attr . addConfigAttribute ( new SecurityConfig ( "FOO_ADMIN_OR_WRITE_ACCESS" ) ) ;
// Setup a MockMethodInvocation, so voter can retrieve domainObject
// Setup a MockMethodInvocation, so voter can retrieve domainObject
// (well actually it will access domainObject.getParent())
// (well actually it will access domainObject.getParent())
@ -412,30 +405,29 @@ public class BasicAclEntryVoterTests extends TestCase {
// Setup an AclManager
// Setup an AclManager
AclManager aclManager = new MockAclManager ( domainObject . getParent ( ) , "rod" ,
AclManager aclManager = new MockAclManager ( domainObject . getParent ( ) , "rod" ,
new AclEntry [ ] {
new AclEntry [ ] {
new MockAclEntry ( ) ,
new MockAclEntry ( ) ,
new SimpleAclEntry ( "rod" , new MockAclObjectIdentity ( ) , null , SimpleAclEntry . ADMINISTRATION ) ,
new SimpleAclEntry ( "rod" , new MockAclObjectIdentity ( ) , null , SimpleAclEntry . ADMINISTRATION ) ,
new SimpleAclEntry ( "rod" , new MockAclObjectIdentity ( ) , null , SimpleAclEntry . READ ) ,
new SimpleAclEntry ( "rod" , new MockAclObjectIdentity ( ) , null , SimpleAclEntry . READ ) ,
new SimpleAclEntry ( "rod" , new MockAclObjectIdentity ( ) , null , SimpleAclEntry . DELETE )
new SimpleAclEntry ( "rod" , new MockAclObjectIdentity ( ) , null , SimpleAclEntry . DELETE )
} ) ;
} ) ;
// Wire up a voter
// Wire up a voter
BasicAclEntryVoter voter = new BasicAclEntryVoter ( ) ;
BasicAclEntryVoter voter = new BasicAclEntryVoter ( ) ;
voter . setAclManager ( aclManager ) ;
voter . setAclManager ( aclManager ) ;
voter . setProcessConfigAttribute ( "FOO_ADMIN_OR_WRITE_ACCESS" ) ;
voter . setProcessConfigAttribute ( "FOO_ADMIN_OR_WRITE_ACCESS" ) ;
voter . setRequirePermission ( new int [ ] { SimpleAclEntry . ADMINISTRATION , SimpleAclEntry . WRITE } ) ;
voter . setRequirePermission ( new int [ ] { SimpleAclEntry . ADMINISTRATION , SimpleAclEntry . WRITE } ) ;
voter . setProcessDomainObjectClass ( SomeDomainObject . class ) ;
voter . setProcessDomainObjectClass ( SomeDomainObject . class ) ;
voter . afterPropertiesSet ( ) ;
voter . afterPropertiesSet ( ) ;
// Wire up an invocation to be voted on
// Wire up an invocation to be voted on
ConfigAttributeDefinition attr = new ConfigAttributeDefinition ( ) ;
ConfigAttributeDefinition attr = new ConfigAttributeDefinition ( "FOO_ADMIN_OR_WRITE_ACCESS" ) ;
attr . addConfigAttribute ( new SecurityConfig ( "FOO_ADMIN_OR_WRITE_ACCESS" ) ) ;
// Setup a MockMethodInvocation that doesn't provide SomeDomainObject arg
// Setup a MockMethodInvocation that doesn't provide SomeDomainObject arg
Class clazz = String . class ;
Class clazz = String . class ;
Method method = clazz . getMethod ( "toString" , new Class [ ] { } ) ;
Method method = clazz . getMethod ( "toString" , new Class [ ] { } ) ;
MethodInvocation mi = new SimpleMethodInvocation ( method , new Object [ ] { domainObject } ) ;
MethodInvocation mi = new SimpleMethodInvocation ( method , new Object [ ] { domainObject } ) ;
try {
try {
voter . vote ( new UsernamePasswordAuthenticationToken ( "rod" , null ) , mi , attr ) ;
voter . vote ( new UsernamePasswordAuthenticationToken ( "rod" , null ) , mi , attr ) ;