Search in sources :

Example 16 with AdminRole

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

the class DelegatedMgrImplTest method deleteInheritedAdminRoles.

/**
 * @param msg
 * @param rArray
 */
private static void deleteInheritedAdminRoles(String msg, String[][] rArray) {
    LogUtil.logIt(msg);
    try {
        DelAdminMgr dAdminMgr = getManagedDelegatedMgr();
        for (String[] rle : rArray) {
            AdminRole role = AdminRoleTestData.getRole(rle);
            Set<String> parents = RoleTestData.getRelationships(rle);
            if (parents != null) {
                for (String pRole : parents) {
                    dAdminMgr.deleteInheritance(new AdminRole(pRole), role);
                    LOG.debug("deleteInheritedAdminRoles child role [" + role.getName() + "] parent role [" + pRole + "] successful");
                }
            }
        }
    } catch (SecurityException ex) {
        LOG.error("deleteInheritedAdminRoles caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
        fail(ex.getMessage());
    }
}
Also used : DelAdminMgr(org.apache.directory.fortress.core.DelAdminMgr) SecurityException(org.apache.directory.fortress.core.SecurityException) AdminRole(org.apache.directory.fortress.core.model.AdminRole) UserAdminRole(org.apache.directory.fortress.core.model.UserAdminRole)

Example 17 with AdminRole

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

the class DelegatedMgrImplTest method readAdminRoles.

/**
 * @param msg
 * @param rArray
 */
public static void readAdminRoles(String msg, String[][] rArray) {
    LogUtil.logIt(msg);
    try {
        DelReviewMgr dReviewMgr = getManagedDelegatedReviewMgr();
        for (String[] rle : rArray) {
            AdminRole entity = dReviewMgr.readRole(AdminRoleTestData.getRole(rle));
            AdminRoleTestData.assertEquals(entity, rle);
            LOG.debug("readAdminRoles [" + entity.getName() + "] successful");
        }
    } catch (SecurityException ex) {
        LOG.error("readAdminRoles caught SecurityException=" + ex.getMessage(), ex);
        fail(ex.getMessage());
    }
}
Also used : SecurityException(org.apache.directory.fortress.core.SecurityException) AdminRole(org.apache.directory.fortress.core.model.AdminRole) UserAdminRole(org.apache.directory.fortress.core.model.UserAdminRole) DelReviewMgr(org.apache.directory.fortress.core.DelReviewMgr)

Example 18 with AdminRole

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

the class DelegatedMgrImplTest method addAdminRoleDescendant.

/**
 * @param msg
 * @param rArray
 */
public static void addAdminRoleDescendant(String msg, String[][] rArray) {
    LogUtil.logIt(msg);
    try {
        DelAdminMgr dAdminMgr = getManagedDelegatedMgr();
        int ctr = 0;
        for (String[] rle : rArray) {
            AdminRole adminRole = AdminRoleTestData.getRole(rle);
            if (ctr++ == 0 || RoleTestData.isTree(rle)) {
                dAdminMgr.addRole(adminRole);
                LOG.debug("addAdminRoleDescendant add role [" + adminRole.getName() + "] successful");
            }
            // use list because order is important for test structure:
            List<String> descs = RoleTestData.getRelationshipList(rle);
            if (descs != null) {
                if (RoleTestData.isTree(rle)) {
                    AdminRole parent = adminRole;
                    for (String desc : descs) {
                        AdminRole child = new AdminRole(desc);
                        dAdminMgr.addDescendant(parent, new AdminRole(desc));
                        LOG.debug("addAdminRoleDescendant asc role [" + adminRole.getName() + "] desc role [" + desc + "] successful");
                        parent = child;
                    }
                } else {
                    for (String desc : descs) {
                        dAdminMgr.addDescendant(adminRole, new AdminRole(desc));
                        LOG.debug("addAdminRoleDescendant asc role [" + adminRole.getName() + "] desc role [" + desc + "] successful");
                    }
                }
            }
            Set<String> inheritances = RoleTestData.getInheritances(rle);
            if (inheritances != null) {
                for (String desc : inheritances) {
                    dAdminMgr.addInheritance(adminRole, new AdminRole(desc));
                    LOG.debug("addAdminRoleDescendant asc role [" + adminRole.getName() + "] desc role [" + desc + "] successful");
                }
            }
        }
    } catch (SecurityException ex) {
        LOG.error("addAdminRoleDescendant caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
        fail(ex.getMessage());
    }
}
Also used : DelAdminMgr(org.apache.directory.fortress.core.DelAdminMgr) SecurityException(org.apache.directory.fortress.core.SecurityException) AdminRole(org.apache.directory.fortress.core.model.AdminRole) UserAdminRole(org.apache.directory.fortress.core.model.UserAdminRole)

Example 19 with AdminRole

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

the class DelegatedMgrImplTest method loadAdminRequired.

private static boolean loadAdminRequired(String msg, String[][] rArray) {
    // default return is 'true':
    boolean loadAdmin = true;
    String methodName = ".loadAdminRequired";
    LogUtil.logIt(msg);
    try {
        DelReviewMgr dReviewMgr = getDelegatedReviewMgr();
        for (String[] rle : rArray) {
            AdminRole entity = dReviewMgr.readRole(new AdminRole(RoleTestData.getName(rle)));
            if (entity == null) {
                break;
            }
        // AdminRoleTestData.assertEquals( entity, rle );
        }
        // if we get to here it means that admin role has already been loaded
        loadAdmin = false;
    } catch (SecurityException ex) {
        // This is the expected when teardown is not required:
        if (ex.getErrorId() == GlobalErrIds.ROLE_NOT_FOUND) {
        // did not find so need to load admin roles
        } else {
            // Something unexpected occurred here, Report as warning to the logger:
            String warning = methodName + " caught SecurityException=" + ex.getMessage();
            LOG.warn(warning);
        // TODO: Determine if it would be better to throw a SecurityException here.
        }
    }
    LOG.info(methodName + ":" + loadAdmin);
    return loadAdmin;
}
Also used : SecurityException(org.apache.directory.fortress.core.SecurityException) AdminRole(org.apache.directory.fortress.core.model.AdminRole) UserAdminRole(org.apache.directory.fortress.core.model.UserAdminRole) DelReviewMgr(org.apache.directory.fortress.core.DelReviewMgr)

Example 20 with AdminRole

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

the class DelegatedMgrImplTest method addAdminRoles.

/**
 * @param rArray
 */
public static void addAdminRoles(String msg, String[][] rArray, boolean isAdmin) {
    LogUtil.logIt(msg);
    try {
        DelAdminMgr dAdminMgr;
        if (isAdmin) {
            dAdminMgr = getManagedDelegatedMgr();
        } else {
            dAdminMgr = DelAdminMgrFactory.createInstance(TestUtils.getContext());
        }
        for (String[] rle : rArray) {
            AdminRole role = AdminRoleTestData.getRole(rle);
            AdminRole entity = dAdminMgr.addRole(role);
            LOG.debug("addAdminRoles role [" + entity.getName() + "] successful");
        }
    } catch (SecurityException ex) {
        LOG.error("addAdminRoles caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
        fail(ex.getMessage());
    }
}
Also used : DelAdminMgr(org.apache.directory.fortress.core.DelAdminMgr) SecurityException(org.apache.directory.fortress.core.SecurityException) AdminRole(org.apache.directory.fortress.core.model.AdminRole) UserAdminRole(org.apache.directory.fortress.core.model.UserAdminRole)

Aggregations

AdminRole (org.apache.directory.fortress.core.model.AdminRole)46 UserAdminRole (org.apache.directory.fortress.core.model.UserAdminRole)37 SecurityException (org.apache.directory.fortress.core.SecurityException)18 DelAdminMgr (org.apache.directory.fortress.core.DelAdminMgr)10 AdminPermissionOperation (org.apache.directory.fortress.annotation.AdminPermissionOperation)8 DelReviewMgr (org.apache.directory.fortress.core.DelReviewMgr)5 Role (org.apache.directory.fortress.core.model.Role)5 FortRequest (org.apache.directory.fortress.core.model.FortRequest)4 FortResponse (org.apache.directory.fortress.core.model.FortResponse)4 Relationship (org.apache.directory.fortress.core.model.Relationship)4 FinderException (org.apache.directory.fortress.core.FinderException)3 User (org.apache.directory.fortress.core.model.User)3 LdapException (org.apache.directory.api.ldap.model.exception.LdapException)2 OrgUnit (org.apache.directory.fortress.core.model.OrgUnit)2 PermObj (org.apache.directory.fortress.core.model.PermObj)2 Permission (org.apache.directory.fortress.core.model.Permission)2 UserRole (org.apache.directory.fortress.core.model.UserRole)2 LdapConnection (org.apache.directory.ldap.client.api.LdapConnection)2 ArrayList (java.util.ArrayList)1 CursorException (org.apache.directory.api.ldap.model.cursor.CursorException)1