4.14 - Delete Permission

void deletePermission(Permission perm) throws SecurityException

This method will remove permission operation entity from permission object. A Fortress permission is (object->operation). The perm operation must exist before making this call.

required parameters:

  • Permission#objName - contains the name of existing object being targeted for the permission delete
  • Permission#opName - contains the name of existing permission operation being removed

Parameters:

  • perm - must contain the object, Permission#objName, and operation, Permission#opName, that identifies target.

Throws:

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

deletePermission

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.Permission;
import org.apache.directory.fortress.core.SecurityException;

@test
public static void testDelPermission(String objName, String operation)
{
    String szLocation = ".testDelPermission";

    try
    {
        // Instantiate the AdminMgr implementation which is used to provision RBAC policies.
        AdminMgr adminMgr = AdminMgrFactory.createInstance();
        // this will remove the permission:
        Permission inPerm = new Permission(objName, operation);
        adminMgr.deletePermission(inPerm);

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