4.19 - Add Inheritance

void addInheritance(Role parentRole, Role childRole) throws SecurityException

This command establishes a new immediate inheritance relationship parentRole «– childRole between existing roles parentRole, childRole.

The command is valid if and only if:

  • The parentRole and childRole are members of the ROLES data set.
  • The parentRole is not an immediate ascendant of childRole.
  • The childRole does not properly inherit parentRole (in order to avoid cycle creation).

required parameters:

  • parentRole - Role#name - contains the name of existing Role to be parent
  • childRole - Role#name - contains the name of existing Role to be child

Throws:

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

addInheritance

import org.apache.directory.fortress.core.AdminMgr;
import org.apache.directory.fortress.core.AdminMgrFactory;
import org.apache.directory.fortress.core.model.Role;
import org.apache.directory.fortress.core.SecurityException;

@test
public static void testAddInheritance(String childNm, String parentNm)
{
    String szLocation = ".testAddInheritance";
    try
    {
        AdminMgr adminMgr = AdminMgrFactory.createInstance();
        adminMgr.addInheritance( new Role( parentNm ), new Role( childNm ) );
    }
    catch (SecurityException ex)
    {
        LOG.error(szLocation + " caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
        fail(ex.getMessage());
    }
}