Search in sources :

Example 26 with AdminPermissionOperation

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

the class ReviewMgrImpl method dsdRoleSetRoles.

/**
 * {@inheritDoc}
 */
@Override
@AdminPermissionOperation
public Set<String> dsdRoleSetRoles(SDSet dsd) throws SecurityException {
    String methodName = "dsdRoleSetRoles";
    assertContext(CLS_NM, methodName, dsd, GlobalErrIds.DSD_NULL);
    checkAccess(CLS_NM, methodName);
    dsd.setType(SDSet.SDType.DYNAMIC);
    SDSet se = ssdP.read(dsd);
    return se.getMembers();
}
Also used : SDSet(org.apache.directory.fortress.core.model.SDSet) AdminPermissionOperation(org.apache.directory.fortress.annotation.AdminPermissionOperation)

Example 27 with AdminPermissionOperation

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

the class AdminPermissionUtil method getOperations.

private static List<String> getOperations(Class clazz) {
    List<String> operations = new ArrayList<String>();
    final Method[] declaredMethods = clazz.getDeclaredMethods();
    for (final Method method : declaredMethods) {
        if (method.isAnnotationPresent(AdminPermissionOperation.class)) {
            AdminPermissionOperation annotation = method.getAnnotation(AdminPermissionOperation.class);
            if (annotation.operationName() != null && !annotation.operationName().isEmpty()) {
                operations.add(annotation.operationName());
            } else {
                operations.add(method.getName());
            }
        }
    }
    return operations;
}
Also used : ArrayList(java.util.ArrayList) Method(java.lang.reflect.Method) AdminPermissionOperation(org.apache.directory.fortress.annotation.AdminPermissionOperation)

Example 28 with AdminPermissionOperation

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

the class AdminMgrImpl method addDescendant.

/**
 * {@inheritDoc}
 */
@Override
@AdminPermissionOperation
public void addDescendant(Role parentRole, Role childRole) throws SecurityException {
    String methodName = "addDescendant";
    assertContext(CLS_NM, methodName, parentRole, GlobalErrIds.PARENT_ROLE_NULL);
    assertContext(CLS_NM, methodName, childRole, GlobalErrIds.CHILD_ROLE_NULL);
    setEntitySession(CLS_NM, methodName, childRole);
    // make sure the parent role is already there:
    Role role = new Role(parentRole.getName());
    role.setContextId(this.contextId);
    roleP.read(role);
    RoleUtil.getInstance().validateRelationship(childRole, parentRole, false);
    childRole.setParent(parentRole.getName());
    roleP.add(childRole);
    RoleUtil.getInstance().updateHier(this.contextId, new Relationship(childRole.getName().toUpperCase(), parentRole.getName().toUpperCase()), Hier.Op.ADD);
}
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) Relationship(org.apache.directory.fortress.core.model.Relationship) AdminPermissionOperation(org.apache.directory.fortress.annotation.AdminPermissionOperation)

Example 29 with AdminPermissionOperation

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

the class AdminMgrImpl method addRoleConstraint.

/**
 * {@inheritDoc}
 */
@Override
@AdminPermissionOperation
public RoleConstraint addRoleConstraint(UserRole uRole, RoleConstraint roleConstraint) throws SecurityException {
    String methodName = "assignUser";
    assertContext(CLS_NM, methodName, uRole, GlobalErrIds.URLE_NULL);
    AdminUtil.canAssign(uRole.getAdminSession(), new User(uRole.getUserId()), new Role(uRole.getName()), contextId);
    // todo assert roleconstraint here
    userP.assign(uRole, roleConstraint);
    return 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 30 with AdminPermissionOperation

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

the class AdminMgrImpl method deleteSsdRoleMember.

/**
 * {@inheritDoc}
 */
@Override
@AdminPermissionOperation
public SDSet deleteSsdRoleMember(SDSet ssdSet, Role role) throws SecurityException {
    String methodName = "deleteSsdRoleMember";
    assertContext(CLS_NM, methodName, ssdSet, GlobalErrIds.SSD_NULL);
    assertContext(CLS_NM, methodName, role, GlobalErrIds.ROLE_NULL);
    setEntitySession(CLS_NM, methodName, ssdSet);
    SDSet entity = sdP.read(ssdSet);
    entity.setContextId(this.contextId);
    entity.delMember(role.getName());
    // when removing last role member a placeholder must be left in data set:
    if (entity.getMembers().isEmpty()) {
        entity.addMember(GlobalIds.NONE);
    }
    setAdminData(CLS_NM, methodName, entity);
    SDSet ssdOut = sdP.update(entity);
    // remove any references to the old SSD from cache:
    clearSSDCache(role);
    return ssdOut;
}
Also used : SDSet(org.apache.directory.fortress.core.model.SDSet) 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