Search in sources :

Example 11 with User

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

the class GroupMgrImpl method assign.

/**
 * {@inheritDoc}
 */
@Override
@AdminPermissionOperation
public Group assign(Group group, String member) throws SecurityException {
    String methodName = "assign";
    assertContext(CLS_NM, methodName, group, GlobalErrIds.GROUP_NULL);
    checkAccess(CLS_NM, methodName);
    ReviewMgr reviewMgr = ReviewMgrFactory.createInstance(this.contextId);
    String dn;
    if (group.getType() == Group.Type.ROLE) {
        Role inRole = new Role(member);
        inRole.setContextId(group.getContextId());
        Role role = reviewMgr.readRole(inRole);
        dn = role.getDn();
        // Validate SSD constraints
        SDUtil.getInstance().validateSSD(group, role);
    } else {
        User inUser = new User(member);
        inUser.setContextId(group.getContextId());
        User user = reviewMgr.readUser(inUser);
        dn = user.getDn();
    }
    return groupP.assign(group, dn);
}
Also used : Role(org.apache.directory.fortress.core.model.Role) UserRole(org.apache.directory.fortress.core.model.UserRole) User(org.apache.directory.fortress.core.model.User) ReviewMgr(org.apache.directory.fortress.core.ReviewMgr) AdminPermissionOperation(org.apache.directory.fortress.annotation.AdminPermissionOperation)

Example 12 with User

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

the class GroupMgrImpl method loadUserDn.

private void loadUserDn(User inUser) throws SecurityException {
    ReviewMgr reviewMgr = ReviewMgrFactory.createInstance(this.contextId);
    User outUser = reviewMgr.readUser(inUser);
    inUser.setDn(outUser.getDn());
}
Also used : User(org.apache.directory.fortress.core.model.User) ReviewMgr(org.apache.directory.fortress.core.ReviewMgr)

Example 13 with User

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

the class ReviewMgrImpl method assignedRoles.

/**
 * {@inheritDoc}
 */
@Override
@AdminPermissionOperation
public List<UserRole> assignedRoles(User user) throws SecurityException {
    String methodName = "assignedRoles";
    assertContext(CLS_NM, methodName, user, GlobalErrIds.USER_NULL);
    checkAccess(CLS_NM, methodName);
    User ue = userP.read(user, true);
    return ue.getRoles();
}
Also used : User(org.apache.directory.fortress.core.model.User) AdminPermissionOperation(org.apache.directory.fortress.annotation.AdminPermissionOperation)

Example 14 with User

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

the class DelAdminMgrImpl method updateRole.

/**
 * {@inheritDoc}
 */
@Override
@AdminPermissionOperation
public AdminRole updateRole(AdminRole role) throws SecurityException {
    String methodName = "updateRole";
    assertContext(CLS_NM, methodName, role, GlobalErrIds.ARLE_NULL);
    setEntitySession(CLS_NM, methodName, role);
    AdminRole re = admRP.update(role);
    // search for all users assigned this role and update:
    List<User> users = userP.getAssignedUsers(role);
    if (CollectionUtils.isNotEmpty(users)) {
        final AdminMgr aMgr = AdminMgrFactory.createInstance(this.contextId);
        for (User ue : users) {
            User upUe = new User(ue.getUserId());
            setAdminData(CLS_NM, methodName, upUe);
            List<UserAdminRole> uaRoles = ue.getAdminRoles();
            UserAdminRole chgRole = new UserAdminRole();
            chgRole.setName(role.getName());
            chgRole.setUserId(ue.getUserId());
            chgRole.setOsPSet(role.getOsPSet());
            chgRole.setOsUSet(role.getOsUSet());
            uaRoles.remove(chgRole);
            ConstraintUtil.copy(re, chgRole);
            uaRoles.add(chgRole);
            upUe.setUserId(ue.getUserId());
            upUe.setAdminRole(chgRole);
            aMgr.updateUser(upUe);
        }
    }
    return re;
}
Also used : User(org.apache.directory.fortress.core.model.User) UserAdminRole(org.apache.directory.fortress.core.model.UserAdminRole) AdminRole(org.apache.directory.fortress.core.model.AdminRole) UserAdminRole(org.apache.directory.fortress.core.model.UserAdminRole) AdminMgr(org.apache.directory.fortress.core.AdminMgr) DelAdminMgr(org.apache.directory.fortress.core.DelAdminMgr) AdminPermissionOperation(org.apache.directory.fortress.annotation.AdminPermissionOperation)

Example 15 with User

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

the class DelReviewMgrRestImpl method assignedUsers.

/**
 * {@inheritDoc}
 */
@Override
public List<User> assignedUsers(AdminRole role) throws SecurityException {
    VUtil.assertNotNull(role, GlobalErrIds.ARLE_NULL, CLS_NM + ".assignedUsers");
    List<User> retUsers;
    FortRequest request = new FortRequest();
    request.setContextId(this.contextId);
    request.setEntity(role);
    String szRequest = RestUtils.marshal(request);
    String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.USER_ASGNED_ADMIN);
    FortResponse response = RestUtils.unmarshall(szResponse);
    if (response.getErrorCode() == 0) {
        retUsers = response.getEntities();
        // do not return a null list to the caller:
        if (retUsers == null) {
            retUsers = new ArrayList<>();
        }
    } else {
        throw new SecurityException(response.getErrorCode(), response.getErrorMessage());
    }
    return retUsers;
}
Also used : User(org.apache.directory.fortress.core.model.User) FortResponse(org.apache.directory.fortress.core.model.FortResponse) SecurityException(org.apache.directory.fortress.core.SecurityException) FortRequest(org.apache.directory.fortress.core.model.FortRequest)

Aggregations

User (org.apache.directory.fortress.core.model.User)203 SecurityException (org.apache.directory.fortress.core.SecurityException)135 UserRole (org.apache.directory.fortress.core.model.UserRole)72 Session (org.apache.directory.fortress.core.model.Session)55 RoleConstraint (org.apache.directory.fortress.core.model.RoleConstraint)44 AdminMgr (org.apache.directory.fortress.core.AdminMgr)41 AccessMgr (org.apache.directory.fortress.core.AccessMgr)34 Role (org.apache.directory.fortress.core.model.Role)33 ReviewMgr (org.apache.directory.fortress.core.ReviewMgr)32 Permission (org.apache.directory.fortress.core.model.Permission)27 UserAdminRole (org.apache.directory.fortress.core.model.UserAdminRole)27 AdminPermissionOperation (org.apache.directory.fortress.annotation.AdminPermissionOperation)18 AdminRole (org.apache.directory.fortress.core.model.AdminRole)17 ArrayList (java.util.ArrayList)13 AccelMgr (org.apache.directory.fortress.core.AccelMgr)12 PwPolicyMgr (org.apache.directory.fortress.core.PwPolicyMgr)10 Constraint (org.apache.directory.fortress.core.model.Constraint)9 FortRequest (org.apache.directory.fortress.core.model.FortRequest)9 FortResponse (org.apache.directory.fortress.core.model.FortResponse)9 Enumeration (java.util.Enumeration)6