// ----------------------------------------------------------------------------------
// Modify with Attribute Addition
// ----------------------------------------------------------------------------------
// create the add modifications
EntryAttribute attr = new DefaultClientAttribute( "registeredAddress", "100 Park Ave." );
Modification[] mods = toItems( ModificationOperation.ADD_ATTRIBUTE, attr );
// create the non-admin user
createUser( "billyd", "billyd" );
createGroup( "TestGroup" );
// try a modify operation which should fail without any ACI
assertFalse( checkCanModifyAs( "billyd", "billyd", "ou=testou", mods ) );
// Gives grantModify, and grantRead perm to all users in the TestGroup group for
// entries and all attribute types and values
createAccessControlSubentry(
"administratorModifyAdd",
"{ "
+ "identificationTag \"addAci\", "
+ "precedence 14, "
+ "authenticationLevel none, "
+ "itemOrUserFirst userFirst: { "
+ "userClasses { userGroup { \"cn=TestGroup,ou=groups,ou=system\" } }, "
+ "userPermissions { "
+ "{ protectedItems {entry}, grantsAndDenials { grantModify, grantBrowse } }, "
+ "{ protectedItems {attributeType {registeredAddress}, allAttributeValues {registeredAddress}}, grantsAndDenials { grantAdd } } "
+ "} } }" );
// see if we can now add that test entry which we could not before
// add op should still fail since billd is not in the admin group
assertFalse( checkCanModifyAs( "billyd", "billyd", "ou=testou", mods ) );
// now add billyd to the TestGroup group and try again
addUserToGroup( "billyd", "TestGroup" );
// try a modify operation which should succeed with ACI and group membership change
assertTrue( checkCanModifyAs( "billyd", "billyd", "ou=testou", mods ) );
deleteAccessControlSubentry( "administratorModifyAdd" );
// ----------------------------------------------------------------------------------
// Modify with Attribute Removal
// ----------------------------------------------------------------------------------
// now let's test to see if we can perform a modify with a delete op
mods = toItems( ModificationOperation.REMOVE_ATTRIBUTE, new DefaultClientAttribute( "telephoneNumber",
"867-5309" ) );
// make sure we cannot remove the telephone number from the test entry
assertFalse( checkCanModifyAs( "billyd", "billyd", "ou=testou", mods ) );
// Gives grantModify, and grantRead perm to all users in the TestGroup group for
// entries and all attribute types and values
createAccessControlSubentry(
"administratorModifyRemove",
"{ "
+ "identificationTag \"addAci\", "
+ "precedence 14, "
+ "authenticationLevel none, "
+ "itemOrUserFirst userFirst: { "
+ "userClasses { userGroup { \"cn=TestGroup,ou=groups,ou=system\" } }, "
+ "userPermissions { "
+ "{ protectedItems {entry}, grantsAndDenials { grantModify, grantBrowse } }, "
+ "{ protectedItems {attributeType {telephoneNumber}, allAttributeValues {telephoneNumber}}, grantsAndDenials { grantRemove } } "
+ "} } }" );
// try a modify operation which should succeed with ACI and group membership change
assertTrue( checkCanModifyAs( "billyd", "billyd", "ou=testou", mods ) );
deleteAccessControlSubentry( "administratorModifyRemove" );
// ----------------------------------------------------------------------------------
// Modify with Attribute Replace (requires both grantRemove and grantAdd on attrs)
// ----------------------------------------------------------------------------------
// now let's test to see if we can perform a modify with a delete op
mods = toItems( ModificationOperation.REPLACE_ATTRIBUTE, new DefaultClientAttribute( "telephoneNumber",
"867-5309" ) );
// make sure we cannot remove the telephone number from the test entry
assertFalse( checkCanModifyAs( "billyd", "billyd", "ou=testou", mods ) );
// Gives grantModify, and grantRead perm to all users in the TestGroup group for
// entries and all attribute types and values
createAccessControlSubentry(
"administratorModifyReplace",
"{ "
+ "identificationTag \"addAci\", "
+ "precedence 14, "
+ "authenticationLevel none, "
+ "itemOrUserFirst userFirst: { "
+ "userClasses { userGroup { \"cn=TestGroup,ou=groups,ou=system\" } }, "
+ "userPermissions { "
+ "{ protectedItems {entry}, grantsAndDenials { grantModify, grantBrowse } }, "
+ "{ protectedItems {attributeType {registeredAddress}, allAttributeValues {telephoneNumber}}, grantsAndDenials { grantAdd, grantRemove } } "
+ "} } }" );
// try a modify operation which should succeed with ACI and group membership change
assertTrue( checkCanModifyAs( "billyd", "billyd", "ou=testou", mods ) );
deleteAccessControlSubentry( "administratorModifyReplace" );
/* =================================================================================
* DO IT ALL OVER AGAIN BUT USE THE OTHER MODIFY METHOD
* ================================================================================= */
// ----------------------------------------------------------------------------------
// Modify with Attribute Addition
// ----------------------------------------------------------------------------------
// create the add modifications
EntryAttribute changes = new DefaultClientAttribute( "registeredAddress", "100 Park Ave." );
// try a modify operation which should fail without any ACI
assertFalse( checkCanModifyAs( "billyd", "billyd", "ou=testou", ModificationOperation.ADD_ATTRIBUTE, changes ) );
// Gives grantModify, and grantRead perm to all users in the TestGroup group for
// entries and all attribute types and values
createAccessControlSubentry(
"administratorModifyAdd",
"{ "
+ "identificationTag \"addAci\", "
+ "precedence 14, "
+ "authenticationLevel none, "
+ "itemOrUserFirst userFirst: { "
+ "userClasses { userGroup { \"cn=TestGroup,ou=groups,ou=system\" } }, "
+ "userPermissions { "
+ "{ protectedItems {entry}, grantsAndDenials { grantModify, grantBrowse } }, "
+ "{ protectedItems {attributeType {registeredAddress}, allAttributeValues {registeredAddress}}, grantsAndDenials { grantAdd } } "
+ "} } }" );
// try a modify operation which should succeed with ACI and group membership change
assertTrue( checkCanModifyAs( "billyd", "billyd", "ou=testou", ModificationOperation.ADD_ATTRIBUTE, changes ) );
deleteAccessControlSubentry( "administratorModifyAdd" );
// ----------------------------------------------------------------------------------
// Modify with Attribute Removal
// ----------------------------------------------------------------------------------
// now let's test to see if we can perform a modify with a delete op
changes = new DefaultClientAttribute( "telephoneNumber", "867-5309" );
// make sure we cannot remove the telephone number from the test entry
assertFalse( checkCanModifyAs( "billyd", "billyd", "ou=testou", ModificationOperation.REMOVE_ATTRIBUTE, changes ) );
// Gives grantModify, and grantRead perm to all users in the TestGroup group for
// entries and all attribute types and values
createAccessControlSubentry(
"administratorModifyRemove",
"{ "
+ "identificationTag \"addAci\", "
+ "precedence 14, "
+ "authenticationLevel none, "
+ "itemOrUserFirst userFirst: { "
+ "userClasses { userGroup { \"cn=TestGroup,ou=groups,ou=system\" } }, "
+ "userPermissions { "
+ "{ protectedItems {entry}, grantsAndDenials { grantModify, grantBrowse } }, "
+ "{ protectedItems {attributeType {telephoneNumber}, allAttributeValues {telephoneNumber}}, grantsAndDenials { grantRemove } } "
+ "} } }" );
// try a modify operation which should succeed with ACI and group membership change
assertTrue( checkCanModifyAs( "billyd", "billyd", "ou=testou", ModificationOperation.REMOVE_ATTRIBUTE, changes ) );
deleteAccessControlSubentry( "administratorModifyRemove" );
// ----------------------------------------------------------------------------------
// Modify with Attribute Replace (requires both grantRemove and grantAdd on attrs)
// ----------------------------------------------------------------------------------
// now let's test to see if we can perform a modify with a delete op
changes = new DefaultClientAttribute( "telephoneNumber", "867-5309" );
// make sure we cannot remove the telephone number from the test entry
assertFalse( checkCanModifyAs( "billyd", "billyd", "ou=testou", ModificationOperation.REPLACE_ATTRIBUTE, changes ) );
// Gives grantModify, and grantRead perm to all users in the TestGroup group for