Search in sources :

Example 11 with AdminRole

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

the class DelReviewMgrRestImpl method readRole.

/**
 * {@inheritDoc}
 */
@Override
public AdminRole readRole(AdminRole role) throws SecurityException {
    VUtil.assertNotNull(role, GlobalErrIds.ARLE_NULL, CLS_NM + ".readRole");
    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_READ);
    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 12 with AdminRole

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

the class DelReviewMgrRestImpl method findRoles.

/**
 * {@inheritDoc}
 */
@Override
public List<AdminRole> findRoles(String searchVal) throws SecurityException {
    VUtil.assertNotNull(searchVal, GlobalErrIds.ARLE_NM_NULL, CLS_NM + ".findRoles");
    List<AdminRole> retRoles;
    FortRequest request = new FortRequest();
    request.setContextId(this.contextId);
    request.setValue(searchVal);
    if (this.adminSess != null) {
        request.setSession(adminSess);
    }
    String szRequest = RestUtils.marshal(request);
    String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.ARLE_SEARCH);
    FortResponse response = RestUtils.unmarshall(szResponse);
    if (response.getErrorCode() == 0) {
        retRoles = response.getEntities();
    } else {
        throw new SecurityException(response.getErrorCode(), response.getErrorMessage());
    }
    return retRoles;
}
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 13 with AdminRole

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

the class AdminRoleTestData method getRole.

public static AdminRole getRole(String[] rle) {
    AdminRole role = (AdminRole) getRoleConstraint(rle);
    role.setName(RoleTestData.getName(rle));
    role.setDescription(RoleTestData.getDescription(rle));
    role.setOsUSet(getOsUSet(rle));
    role.setOsPSet(getOsPSet(rle));
    role.setBeginRange(getBeginRange(rle));
    role.setEndRange(getEndRange(rle));
    role.setBeginInclusive(isBeginInclusive(rle));
    role.setEndInclusive(isEndInclusive(rle));
    return role;
}
Also used : AdminRole(org.apache.directory.fortress.core.model.AdminRole)

Example 14 with AdminRole

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

the class DelegatedMgrImplTest method addInheritedAdminRoles.

/**
 * @param msg
 * @param rArray
 */
public static void addInheritedAdminRoles(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.addInheritance(new AdminRole(pRole), role);
                    LOG.debug("addInheritedAdminRoles child role [" + role.getName() + "] parent role [" + pRole + "] successful");
                }
            }
        }
    } catch (SecurityException ex) {
        LOG.error("addInheritedAdminRoles 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 15 with AdminRole

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

the class DelegatedMgrImplTest method addAdminRoleAscendant.

/**
 * @param msg
 * @param rArray
 */
public static void addAdminRoleAscendant(String msg, String[][] rArray) {
    LogUtil.logIt(msg);
    try {
        DelAdminMgr dAdminMgr = getManagedDelegatedMgr();
        for (String[] rle : rArray) {
            AdminRole adminRole = AdminRoleTestData.getRole(rle);
            if (RoleTestData.isCreate(rle)) {
                dAdminMgr.addRole(adminRole);
                LOG.debug("addAdminRoleAscendant add adminRole [" + adminRole.getName() + "] successful");
            }
            Set<String> ascs = RoleTestData.getRelationships(rle);
            if (ascs != null) {
                for (String asc : ascs) {
                    dAdminMgr.addAscendant(adminRole, new AdminRole(asc));
                    LOG.debug("addAdminRoleAscendant desc role [" + adminRole.getName() + "] asc role [" + asc + "] successful");
                }
            }
            Set<String> inheritances = RoleTestData.getInheritances(rle);
            if (inheritances != null) {
                for (String asc : inheritances) {
                    dAdminMgr.addInheritance(new AdminRole(asc), adminRole);
                    LOG.debug("addAdminRoleAscendant desc role [" + adminRole.getName() + "] asc role [" + asc + "] successful");
                }
            }
        }
    } catch (SecurityException ex) {
        LOG.error("addAdminRoleAscendant 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