4.8 - Delete Permission Object

void deletePermObj(PermObj pObj) throws SecurityException

This method will remove permission object to perms container in directory. This method will also remove in associated permission objects that are attached to this object.

required parameters:

  • PermObj#objName - contains the name of existing object targeted for removal

Parameters:

  • pObj - must contain the PermObj#objName of object targeted for removal.

Throws:

  • SecurityException - thrown in the event of perm object data or system error.

deletePermObj

import org.apache.directory.fortress.core.AdminMgr;
import org.apache.directory.fortress.core.AdminMgrFactory;
import org.apache.directory.fortress.core.GlobalErrIds;
import org.apache.directory.fortress.core.ReviewMgr;
import org.apache.directory.fortress.core.ReviewMgrFactory;
import org.apache.directory.fortress.core.model.PermObj;
import org.apache.directory.fortress.core.SecurityException;

@test
public static void testDelPermObjects(String objName)
{
    String szLocation = ".testDelPermObjects";

    try
    {
        // Instantiate the AdminMgr implementation which is used to provision RBAC policies.
        AdminMgr adminMgr = AdminMgrFactory.createInstance();
        // this will remove the object along with any operations associated with it:
        adminMgr.deletePermObj(new PermObj(deletePermObj));

        // Instantiate the ReviewMgr implementation which is used to interrogate policy information.
        ReviewMgr reviewMgr = ReviewMgrFactory.createInstance();
        try
        {
            // this should fail:
            reviewMgr.readPermObj(new PermObj(objName));
            fail(szLocation + " permission object delete failed");
        }
        catch (SecurityException se)
        {
            assertTrue(szLocation + " excep id check", se.getErrorId() == GlobalErrIds.PERM_OBJ_NOT_FOUND);
            // pass
        }
        LOG.info(szLocation + " delete permission object [" + objName + "] success");
    }
    catch (SecurityException ex)
    {
        LOG.error(szLocation + " caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
        fail(ex.getMessage());
    }
}