Search in sources :

Example 16 with OrgUnit

use of org.apache.directory.fortress.core.model.OrgUnit in project directory-fortress-core by apache.

the class DelegatedMgrImplTest method updateOrgUnits.

/**
 * @param msg
 * @param oArray
 */
public static void updateOrgUnits(String msg, String[][] oArray) {
    LogUtil.logIt(msg);
    try {
        DelAdminMgr dAdminMgr = getManagedDelegatedMgr();
        for (String[] ole : oArray) {
            OrgUnit ou = OrgUnitTestData.getOrgUnit(ole);
            dAdminMgr.update(ou);
            LOG.debug("updateOrgUnits ou [" + ou.getName() + "] successful");
        }
    } catch (SecurityException ex) {
        LOG.error("updateOrgUnits caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
        fail(ex.getMessage());
    }
}
Also used : OrgUnit(org.apache.directory.fortress.core.model.OrgUnit) DelAdminMgr(org.apache.directory.fortress.core.DelAdminMgr) SecurityException(org.apache.directory.fortress.core.SecurityException)

Example 17 with OrgUnit

use of org.apache.directory.fortress.core.model.OrgUnit in project directory-fortress-core by apache.

the class DelegatedAdminMgrConsole method removeInheritance.

/**
 */
private void removeInheritance(OrgUnit.Type type) {
    try {
        OrgUnit cou = new OrgUnit();
        OrgUnit pou = new OrgUnit();
        cou.setType(type);
        pou.setType(type);
        ReaderUtil.clearScreen();
        System.out.println("Enter child orgunit name:");
        cou.setName(ReaderUtil.readLn());
        System.out.println("Enter parent orgunit name:");
        pou.setName(ReaderUtil.readLn());
        dAmgr.deleteInheritance(pou, cou);
        System.out.println("child orgunit [" + cou.getName() + "]");
        System.out.println("parent orgunit [" + pou.getName() + "]");
        System.out.println("inheritance relationship has been removed");
        System.out.println("ENTER to continue");
    } catch (SecurityException e) {
        LOG.error("removeInheritance caught SecurityException rc=" + e.getErrorId() + ", msg=" + e.getMessage(), e);
    }
    ReaderUtil.readChar();
}
Also used : OrgUnit(org.apache.directory.fortress.core.model.OrgUnit)

Example 18 with OrgUnit

use of org.apache.directory.fortress.core.model.OrgUnit in project directory-fortress-core by apache.

the class DelegatedAdminMgrConsole method addInheritance.

/**
 */
private void addInheritance(OrgUnit.Type type) {
    try {
        OrgUnit cou = new OrgUnit();
        OrgUnit pou = new OrgUnit();
        cou.setType(type);
        pou.setType(type);
        ReaderUtil.clearScreen();
        System.out.println("Enter child orgunit name:");
        cou.setName(ReaderUtil.readLn());
        System.out.println("Enter parent orgunit name:");
        pou.setName(ReaderUtil.readLn());
        dAmgr.addInheritance(pou, cou);
        System.out.println("child orgunit [" + cou.getName() + "]");
        System.out.println("parent orgunit [" + pou.getName() + "]");
        System.out.println("inheritance relationship has been added");
        System.out.println("ENTER to continue");
    } catch (SecurityException e) {
        LOG.error("addInheritance caught SecurityException rc=" + e.getErrorId() + ", msg=" + e.getMessage(), e);
    }
    ReaderUtil.readChar();
}
Also used : OrgUnit(org.apache.directory.fortress.core.model.OrgUnit)

Example 19 with OrgUnit

use of org.apache.directory.fortress.core.model.OrgUnit in project directory-fortress-core by apache.

the class DelegatedAdminMgrConsole method add.

private void add(OrgUnit.Type type) {
    OrgUnit ou = new OrgUnit();
    try {
        ReaderUtil.clearScreen();
        System.out.println("Enter orgunit name:");
        ou.setName(ReaderUtil.readLn());
        System.out.println("Enter description field");
        ou.setDescription(ReaderUtil.readLn());
        ou.setType(type);
        OrgUnit ou2 = dAmgr.add(ou);
        System.out.println("name [" + ou2.getName() + "]");
        System.out.println("internalId [" + ou2.getId() + "]");
        System.out.println("name description [" + ou2.getDescription() + "]");
        System.out.println("has been added");
        System.out.println("ENTER to continue");
    } catch (SecurityException e) {
        LOG.error("add caught SecurityException rc=" + e.getErrorId() + ", msg=" + e.getMessage(), e);
    }
    ReaderUtil.readChar();
}
Also used : OrgUnit(org.apache.directory.fortress.core.model.OrgUnit)

Example 20 with OrgUnit

use of org.apache.directory.fortress.core.model.OrgUnit in project directory-fortress-core by apache.

the class CreateUserOrgHierarchySample method testCreateAscendantUserOrgs.

/**
 * Demonstrate a child to parent OrgUnit structure of one-to-many.  To use this API, the child OrgUnit must be created before
 * the call to addAscendant which will Add a new OrgUnit node and set a OrgUnit relationship with child node.
 * <p>
 * <img src="./doc-files/HierUserOrgAscendants.png" alt="">
 */
public static void testCreateAscendantUserOrgs() {
    String szLocation = ".testCreateAscendantUserOrgs";
    try {
        // Instantiate the DelAdminMgr implementation which is used to provision ARBAC policies.
        DelAdminMgr delAdminMgr = DelAdminMgrFactory.createInstance(TestUtils.getContext());
        // Instantiate the child OrgUnit.  This needs a name and type.
        OrgUnit childOrgUnit = new OrgUnit(TEST_HIER_ASC_USERORG_PREFIX + 1, OrgUnit.Type.USER);
        // This child will have many parents:
        delAdminMgr.add(childOrgUnit);
        // Create OrgUnits, 'sampleHierUserOrgA2' - 'sampleHierUserOrgA6'.
        for (int i = 1; i < TEST_NUMBER; i++) {
            // Instantiate the parent OrgUnit.  This needs a name and type before it can be added to ldap.
            OrgUnit parentOrgUnit = new OrgUnit(TEST_HIER_ASC_USERORG_PREFIX + (i + 1), OrgUnit.Type.USER);
            // Now add parent OrgUnit entity to directory and add relationship with existing child OrgUnit.
            delAdminMgr.addAscendant(childOrgUnit, parentOrgUnit);
        }
    } catch (SecurityException ex) {
        LOG.error(szLocation + " caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
        fail(ex.getMessage());
    }
}
Also used : OrgUnit(org.apache.directory.fortress.core.model.OrgUnit) DelAdminMgr(org.apache.directory.fortress.core.DelAdminMgr) SecurityException(org.apache.directory.fortress.core.SecurityException)

Aggregations

OrgUnit (org.apache.directory.fortress.core.model.OrgUnit)60 SecurityException (org.apache.directory.fortress.core.SecurityException)36 DelAdminMgr (org.apache.directory.fortress.core.DelAdminMgr)26 DelReviewMgr (org.apache.directory.fortress.core.DelReviewMgr)7 Relationship (org.apache.directory.fortress.core.model.Relationship)6 FinderException (org.apache.directory.fortress.core.FinderException)5 FortRequest (org.apache.directory.fortress.core.model.FortRequest)5 FortResponse (org.apache.directory.fortress.core.model.FortResponse)5 HashSet (java.util.HashSet)4 AdminPermissionOperation (org.apache.directory.fortress.annotation.AdminPermissionOperation)4 ArrayList (java.util.ArrayList)3 UserAdminRole (org.apache.directory.fortress.core.model.UserAdminRole)3 UserRole (org.apache.directory.fortress.core.model.UserRole)3 TreeSet (java.util.TreeSet)2 LdapException (org.apache.directory.api.ldap.model.exception.LdapException)2 ValidationException (org.apache.directory.fortress.core.ValidationException)2 AdminRole (org.apache.directory.fortress.core.model.AdminRole)2 Graphable (org.apache.directory.fortress.core.model.Graphable)2 Hier (org.apache.directory.fortress.core.model.Hier)2 ObjectFactory (org.apache.directory.fortress.core.model.ObjectFactory)2