Search in sources :

Example 16 with Role

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

the class ReviewMgrImpl method findRoles.

/**
 * {@inheritDoc}
 */
@Override
@AdminPermissionOperation
public List<String> findRoles(String searchVal, int limit) throws SecurityException {
    String methodName = "findRoles";
    VUtil.assertNotNull(searchVal, GlobalErrIds.ROLE_NM_NULL, CLS_NM + "." + methodName);
    checkAccess(CLS_NM, methodName);
    Role role = new Role(searchVal);
    role.setContextId(this.contextId);
    return roleP.search(role, limit);
}
Also used : Role(org.apache.directory.fortress.core.model.Role) UserRole(org.apache.directory.fortress.core.model.UserRole) AdminPermissionOperation(org.apache.directory.fortress.annotation.AdminPermissionOperation)

Example 17 with Role

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

the class RoleDAO method unloadDescendants.

/**
 * @param le
 * @param sequence
 * @param contextId
 * @return
 * @throws LdapInvalidAttributeValueException
 * @throws LdapException
 */
private Graphable unloadDescendants(Entry le, long sequence, String contextId) throws LdapInvalidAttributeValueException {
    Role entity = new ObjectFactory().createRole();
    entity.setSequenceId(sequence);
    entity.setName(getAttribute(le, ROLE_NM));
    entity.setParents(getAttributeSet(le, GlobalIds.PARENT_NODES));
    return entity;
}
Also used : Role(org.apache.directory.fortress.core.model.Role) ObjectFactory(org.apache.directory.fortress.core.model.ObjectFactory)

Example 18 with Role

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

the class RoleP method removeOccupant.

/**
 * Remove the User dn occupant attribute from the OrganizationalRole entity in ldap.  This method is called by AdminMgrImpl
 * when the User is being deleted.
 *
 * @param userDn contains the userId targeted for attribute removal.
 * @param contextId maps to sub-tree in DIT, e.g. ou=contextId, dc=example, dc=com.
 * @throws SecurityException in the event of DAO search error.
 */
void removeOccupant(String userDn, String contextId) throws SecurityException {
    List<String> list;
    try {
        list = rDao.findAssignedRoles(userDn, contextId);
        for (String roleNm : list) {
            Role role = new Role(roleNm);
            role.setContextId(contextId);
            deassign(role, userDn);
        }
    } catch (FinderException fe) {
        String error = "removeOccupant userDn [" + userDn + "] caught FinderException=" + fe;
        throw new SecurityException(GlobalErrIds.ROLE_REMOVE_OCCUPANT_FAILED, error, fe);
    }
}
Also used : Role(org.apache.directory.fortress.core.model.Role) UserRole(org.apache.directory.fortress.core.model.UserRole) FinderException(org.apache.directory.fortress.core.FinderException) SecurityException(org.apache.directory.fortress.core.SecurityException)

Example 19 with Role

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

the class RoleP method addOccupant.

/**
 * Add the User dn occupant attribute to the OrganizationalRole entity in ldap.  This method is called by AdminMgrImpl
 * when the User is being added.
 *
 * @param uRoles contains a collection of UserRole being targeted for assignment.
 * @param userDn contains the userId targeted for addition.
 * @param contextId maps to sub-tree in DIT, e.g. ou=contextId, dc=example, dc=com.
 * @throws SecurityException in the event of DAO search error.
 */
void addOccupant(List<UserRole> uRoles, String userDn, String contextId) throws SecurityException {
    if (CollectionUtils.isNotEmpty(uRoles)) {
        for (UserRole uRole : uRoles) {
            Role role = new Role(uRole.getName());
            role.setContextId(contextId);
            assign(role, userDn);
        }
    }
}
Also used : Role(org.apache.directory.fortress.core.model.Role) UserRole(org.apache.directory.fortress.core.model.UserRole) UserRole(org.apache.directory.fortress.core.model.UserRole)

Example 20 with Role

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

the class AdminMgrRestImpl method updateRole.

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

Aggregations

Role (org.apache.directory.fortress.core.model.Role)117 UserRole (org.apache.directory.fortress.core.model.UserRole)83 SecurityException (org.apache.directory.fortress.core.SecurityException)66 AdminMgr (org.apache.directory.fortress.core.AdminMgr)40 ReviewMgr (org.apache.directory.fortress.core.ReviewMgr)30 User (org.apache.directory.fortress.core.model.User)30 AdminRole (org.apache.directory.fortress.core.model.AdminRole)25 Permission (org.apache.directory.fortress.core.model.Permission)24 RoleConstraint (org.apache.directory.fortress.core.model.RoleConstraint)17 AdminPermissionOperation (org.apache.directory.fortress.annotation.AdminPermissionOperation)15 UserAdminRole (org.apache.directory.fortress.core.model.UserAdminRole)15 Relationship (org.apache.directory.fortress.core.model.Relationship)7 SDSet (org.apache.directory.fortress.core.model.SDSet)7 FinderException (org.apache.directory.fortress.core.FinderException)6 PermObj (org.apache.directory.fortress.core.model.PermObj)6 ArrayList (java.util.ArrayList)5 Group (org.apache.directory.fortress.core.model.Group)5 Constraint (org.apache.directory.fortress.core.model.Constraint)4 FortRequest (org.apache.directory.fortress.core.model.FortRequest)4 FortResponse (org.apache.directory.fortress.core.model.FortResponse)4