Search in sources :

Example 36 with AdminPermissionOperation

use of org.apache.directory.fortress.annotation.AdminPermissionOperation in project directory-fortress-core by apache.

the class AdminMgrImpl method removeRoleConstraint.

/**
 * {@inheritDoc}
 */
@Override
@AdminPermissionOperation
public void removeRoleConstraint(UserRole uRole, RoleConstraint roleConstraint) throws SecurityException {
    String methodName = "assignUser";
    assertContext(CLS_NM, methodName, uRole, GlobalErrIds.URLE_NULL);
    AdminUtil.canDeassign(uRole.getAdminSession(), new User(uRole.getUserId()), new Role(uRole.getName()), contextId);
    // todo assert roleconstraint here
    userP.deassign(uRole, roleConstraint);
}
Also used : AdminRole(org.apache.directory.fortress.core.model.AdminRole) Role(org.apache.directory.fortress.core.model.Role) UserRole(org.apache.directory.fortress.core.model.UserRole) User(org.apache.directory.fortress.core.model.User) AdminPermissionOperation(org.apache.directory.fortress.annotation.AdminPermissionOperation)

Example 37 with AdminPermissionOperation

use of org.apache.directory.fortress.annotation.AdminPermissionOperation in project directory-fortress-core by apache.

the class PwPolicyMgrImpl method read.

/**
 * {@inheritDoc}
 */
@Override
@AdminPermissionOperation
public PwPolicy read(String name) throws SecurityException {
    String methodName = "read";
    VUtil.assertNotNullOrEmpty(name, GlobalErrIds.PSWD_NAME_NULL, CLS_NM + "." + methodName);
    checkAccess(CLS_NM, methodName);
    PwPolicy policy = new PwPolicy(name);
    policy.setContextId(this.contextId);
    return policyP.read(policy);
}
Also used : PwPolicy(org.apache.directory.fortress.core.model.PwPolicy) AdminPermissionOperation(org.apache.directory.fortress.annotation.AdminPermissionOperation)

Example 38 with AdminPermissionOperation

use of org.apache.directory.fortress.annotation.AdminPermissionOperation in project directory-fortress-core by apache.

the class PwPolicyMgrImpl method updateUserPolicy.

/**
 * {@inheritDoc}
 */
@Override
@AdminPermissionOperation
public void updateUserPolicy(String userId, String policyName) throws SecurityException {
    String methodName = "updateUserPolicy";
    VUtil.assertNotNullOrEmpty(userId, GlobalErrIds.USER_NULL, CLS_NM + "." + methodName);
    VUtil.assertNotNullOrEmpty(policyName, GlobalErrIds.PSWD_NAME_NULL, CLS_NM + "." + methodName);
    User user = new User(userId);
    user.setPwPolicy(policyName);
    user.setAdminSession(adminSess);
    setEntitySession(CLS_NM, methodName, user);
    userP.update(user);
}
Also used : User(org.apache.directory.fortress.core.model.User) AdminPermissionOperation(org.apache.directory.fortress.annotation.AdminPermissionOperation)

Example 39 with AdminPermissionOperation

use of org.apache.directory.fortress.annotation.AdminPermissionOperation in project directory-fortress-core by apache.

the class PwPolicyMgrImpl method search.

/**
 * {@inheritDoc}
 */
@Override
@AdminPermissionOperation
public List<PwPolicy> search(String searchVal) throws SecurityException {
    String methodName = "search";
    VUtil.assertNotNull(searchVal, GlobalErrIds.PSWD_NAME_NULL, CLS_NM + "." + methodName);
    checkAccess(CLS_NM, methodName);
    PwPolicy policy = new PwPolicy(searchVal);
    policy.setContextId(this.contextId);
    return policyP.search(policy);
}
Also used : PwPolicy(org.apache.directory.fortress.core.model.PwPolicy) AdminPermissionOperation(org.apache.directory.fortress.annotation.AdminPermissionOperation)

Example 40 with AdminPermissionOperation

use of org.apache.directory.fortress.annotation.AdminPermissionOperation in project directory-fortress-core by apache.

the class ReviewMgrImpl method authorizedPermissionUsers.

/**
 * {@inheritDoc}
 */
@Override
@AdminPermissionOperation
public Set<String> authorizedPermissionUsers(Permission perm) throws SecurityException {
    Set<String> authorizedUsers = null;
    String methodName = "authorizedPermissionUsers";
    assertContext(CLS_NM, methodName, perm, GlobalErrIds.PERM_OPERATION_NULL);
    checkAccess(CLS_NM, methodName);
    // Pull the permission from ldap:
    Permission pe = permP.read(perm);
    // Get all roles that this permission is authorized for:
    Set<String> authorizedRoles = authorizeRoles(pe.getRoles());
    if (authorizedRoles != null) {
        // Pull the set of users assigned to descendant or assigned roles from ldap:
        authorizedUsers = userP.getAssignedUsers(authorizedRoles, this.contextId);
    }
    // Now add any users who have been directly assigned to this permission entity:
    Set<String> assignedUsers = pe.getUsers();
    if (assignedUsers != null) {
        // It is possible this dataset has not yet been instantiated (if perm has no assigned roles):
        if (authorizedUsers == null) {
            authorizedUsers = new HashSet<>();
        }
        authorizedUsers.addAll(assignedUsers);
    }
    // The returned list includes all assigned users plus any users assigned via authorized roles.
    return authorizedUsers;
}
Also used : Permission(org.apache.directory.fortress.core.model.Permission) AdminPermissionOperation(org.apache.directory.fortress.annotation.AdminPermissionOperation)

Aggregations

AdminPermissionOperation (org.apache.directory.fortress.annotation.AdminPermissionOperation)54 AdminRole (org.apache.directory.fortress.core.model.AdminRole)18 User (org.apache.directory.fortress.core.model.User)18 UserRole (org.apache.directory.fortress.core.model.UserRole)16 Relationship (org.apache.directory.fortress.core.model.Relationship)15 Role (org.apache.directory.fortress.core.model.Role)15 SDSet (org.apache.directory.fortress.core.model.SDSet)8 UserAdminRole (org.apache.directory.fortress.core.model.UserAdminRole)8 Permission (org.apache.directory.fortress.core.model.Permission)5 OrgUnit (org.apache.directory.fortress.core.model.OrgUnit)4 ReviewMgr (org.apache.directory.fortress.core.ReviewMgr)3 SecurityException (org.apache.directory.fortress.core.SecurityException)3 PwPolicy (org.apache.directory.fortress.core.model.PwPolicy)2 RoleConstraint (org.apache.directory.fortress.core.model.RoleConstraint)2 Method (java.lang.reflect.Method)1 ArrayList (java.util.ArrayList)1 AdminMgr (org.apache.directory.fortress.core.AdminMgr)1 DelAdminMgr (org.apache.directory.fortress.core.DelAdminMgr)1 FinderException (org.apache.directory.fortress.core.FinderException)1 Group (org.apache.directory.fortress.core.model.Group)1