Search in sources :

Example 31 with AdminRole

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

the class DelegatedMgrImplTest method delAdminRoleAscendant.

/**
 * @param msg
 * @param rArray
 */
private void delAdminRoleAscendant(String msg, String[][] rArray) {
    LogUtil.logIt(msg);
    try {
        DelAdminMgr dAdminMgr = getManagedDelegatedMgr();
        for (String[] rle : rArray) {
            AdminRole adminRole = AdminRoleTestData.getRole(rle);
            Set<String> ascs = RoleTestData.getRelationships(rle);
            if (ascs != null) {
                for (String asc : ascs) {
                    dAdminMgr.deleteInheritance(new AdminRole(asc), adminRole);
                    LOG.debug("delAdminRoleAscendant desc adminRole [" + adminRole.getName() + "] asc adminRole [" + asc + "] successful");
                }
            }
            Set<String> inheritances = RoleTestData.getInheritances(rle);
            if (inheritances != null) {
                for (String asc : inheritances) {
                    dAdminMgr.deleteInheritance(new AdminRole(asc), adminRole);
                    LOG.debug("delAdminRoleAscendant desc adminRole [" + adminRole.getName() + "] asc orgUnit [" + asc + "] successful");
                }
            }
            dAdminMgr.deleteRole(adminRole);
            LOG.debug("delAdminRoleAscendant remove desc adminRole [" + adminRole.getName() + "] successful");
        }
        // cleanup the top ascendant from orgUnit data set.
        DelReviewMgr dReviewMgr = getManagedDelegatedReviewMgr();
        String adminRoleSrchVal = RoleTestData.getName(rArray[0]);
        // stip off prefix and search:
        adminRoleSrchVal = adminRoleSrchVal.substring(0, 3);
        List<AdminRole> cleanup = dReviewMgr.findRoles(adminRoleSrchVal);
        for (AdminRole re : cleanup) {
            dAdminMgr.deleteRole(re);
            LOG.debug("delAdminRoleAscendant cleanup adminRole [" + re.getName() + "] successful");
        }
    } catch (SecurityException ex) {
        LOG.error("delAdminRoleAscendant 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) DelReviewMgr(org.apache.directory.fortress.core.DelReviewMgr)

Example 32 with AdminRole

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

the class DelegatedMgrImplTest method delAdminRoleDescendant.

private void delAdminRoleDescendant(String msg, String[][] rArray) {
    LogUtil.logIt(msg);
    try {
        DelAdminMgr dAdminMgr = getManagedDelegatedMgr();
        for (String[] rle : rArray) {
            AdminRole adminRole = AdminRoleTestData.getRole(rle);
            // 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.deleteInheritance(parent, new AdminRole(desc));
                        LOG.debug("delAdminRoleDescendant asc adminRole [" + adminRole.getName() + "] desc adminRole [" + desc + "] successful");
                        parent = child;
                    }
                } else {
                    for (String desc : descs) {
                        dAdminMgr.deleteInheritance(adminRole, new AdminRole(desc));
                        LOG.debug("delAdminRoleDescendant asc adminRole [" + adminRole.getName() + "] desc adminRole [" + desc + "] successful");
                    }
                }
            }
            Set<String> inheritances = RoleTestData.getInheritances(rle);
            if (inheritances != null) {
                for (String desc : inheritances) {
                    dAdminMgr.deleteInheritance(adminRole, new AdminRole(desc));
                    LOG.debug("delAdminRoleDescendant asc adminRole [" + adminRole.getName() + "] desc adminRole [" + desc + "] successful");
                }
            }
            dAdminMgr.deleteRole(adminRole);
            LOG.debug("delAdminRoleDescendant remove asc adminRole [" + adminRole.getName() + "] successful");
        }
        // cleanup the last row of descendants from orgUnit data set.
        DelReviewMgr dReviewMgr = getManagedDelegatedReviewMgr();
        String srchVal = TestUtils.getSrchValue(RoleTestData.getName(rArray[0]));
        List<AdminRole> cleanup = dReviewMgr.findRoles(srchVal);
        for (Role re : cleanup) {
            dAdminMgr.deleteRole((AdminRole) re);
            LOG.debug("delAdminRoleDescendant cleanup adminRole [" + re.getName() + "] successful");
        }
    } catch (SecurityException ex) {
        LOG.error("delOrgUnitDescendant caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
        fail(ex.getMessage());
    }
}
Also used : AdminRole(org.apache.directory.fortress.core.model.AdminRole) Role(org.apache.directory.fortress.core.model.Role) UserAdminRole(org.apache.directory.fortress.core.model.UserAdminRole) 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) DelReviewMgr(org.apache.directory.fortress.core.DelReviewMgr)

Example 33 with AdminRole

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

the class DelAdminMgrRestImpl method updateRole.

/**
 * {@inheritDoc}
 */
@Override
public AdminRole updateRole(AdminRole role) throws SecurityException {
    VUtil.assertNotNull(role, GlobalErrIds.ARLE_NULL, CLS_NM + ".updateRole");
    AdminRole retRole;
    FortRequest request = new FortRequest();
    request.setContextId(this.contextId);
    request.setEntity(role);
    if (this.adminSess != null) {
        request.setSession(adminSess);
    }
    String szRequest = RestUtils.marshal(request);
    String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.ARLE_UPDATE);
    FortResponse response = RestUtils.unmarshall(szResponse);
    if (response.getErrorCode() == 0) {
        retRole = (AdminRole) response.getEntity();
    } else {
        throw new SecurityException(response.getErrorCode(), response.getErrorMessage());
    }
    return retRole;
}
Also used : FortResponse(org.apache.directory.fortress.core.model.FortResponse) SecurityException(org.apache.directory.fortress.core.SecurityException) AdminRole(org.apache.directory.fortress.core.model.AdminRole) UserAdminRole(org.apache.directory.fortress.core.model.UserAdminRole) FortRequest(org.apache.directory.fortress.core.model.FortRequest)

Example 34 with AdminRole

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

the class DelegatedAdminMgrConsole method updateRole.

/**
 */
protected void updateRole() {
    AdminRole re = new AdminRole();
    try {
        ReaderUtil.clearScreen();
        System.out.println("Enter role name:");
        re.setName(ReaderUtil.readLn());
        System.out.println("Enter Role's description field");
        re.setDescription(ReaderUtil.readLn());
        System.out.println("Enter OSP name (or NULL to skip):");
        String val = ReaderUtil.readLn();
        for (int i = 0; val != null && val.length() > 0; i++) {
            re.setOsP(val);
            System.out.println("Enter next name (or NULL if done entering OSPs):");
            val = ReaderUtil.readLn();
        }
        System.out.println("Enter OSU name (or NULL to skip):");
        val = ReaderUtil.readLn();
        for (int i = 0; val != null && val.length() > 0; i++) {
            re.setOsU(val);
            System.out.println("Enter next name (or NULL if done entering OSUs):");
            val = ReaderUtil.readLn();
        }
        AdminRole re2 = dAmgr.updateRole(re);
        System.out.println("name [" + re2.getName() + "]");
        System.out.println("internalId [" + re2.getId() + "]");
        System.out.println("name description [" + re2.getDescription() + "]");
        System.out.println("has been updated");
        System.out.println("ENTER to continue");
    } catch (SecurityException e) {
        LOG.error("updateRole caught SecurityException rc=" + e.getErrorId() + ", msg=" + e.getMessage(), e);
    }
    ReaderUtil.readChar();
}
Also used : AdminRole(org.apache.directory.fortress.core.model.AdminRole) UserAdminRole(org.apache.directory.fortress.core.model.UserAdminRole)

Example 35 with AdminRole

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

the class DelegatedAdminMgrConsole method addRole.

protected void addRole() {
    AdminRole re = new AdminRole();
    try {
        ReaderUtil.clearScreen();
        System.out.println("Enter role name:");
        re.setName(ReaderUtil.readLn());
        System.out.println("Enter Role's description field");
        re.setDescription(ReaderUtil.readLn());
        System.out.println("Enter OSP name (or NULL to skip):");
        String val = ReaderUtil.readLn();
        for (int i = 0; val != null && val.length() > 0; i++) {
            re.setOsP(val);
            System.out.println("Enter next name (or NULL if done entering OSPs):");
            val = ReaderUtil.readLn();
        }
        System.out.println("Enter OSU name (or NULL to skip):");
        val = ReaderUtil.readLn();
        for (int i = 0; val != null && val.length() > 0; i++) {
            re.setOsU(val);
            System.out.println("Enter next name (or NULL if done entering OSUs):");
            val = ReaderUtil.readLn();
        }
        AdminRole re2 = dAmgr.addRole(re);
        System.out.println("name [" + re2.getName() + "]");
        System.out.println("internalId [" + re2.getId() + "]");
        System.out.println("name description [" + re2.getDescription() + "]");
        System.out.println("has been updated");
        System.out.println("ENTER to continue");
    } catch (SecurityException e) {
        LOG.error("updateRole caught SecurityException rc=" + e.getErrorId() + ", msg=" + e.getMessage(), e);
    }
    ReaderUtil.readChar();
}
Also used : 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