Search in sources :

Example 1 with OrgUnit

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

the class DelAdminMgrImpl method addAscendant.

/**
 * {@inheritDoc}
 */
@Override
@AdminPermissionOperation(operationName = "addAscendantOU")
public void addAscendant(OrgUnit child, OrgUnit parent) throws SecurityException {
    String methodName = "addAscendantOU";
    assertContext(CLS_NM, methodName, parent, GlobalErrIds.ORG_PARENT_NULL);
    VUtil.assertNotNull(parent.getType(), GlobalErrIds.ORG_TYPE_NULL, CLS_NM + "." + methodName);
    setEntitySession(CLS_NM, methodName, parent);
    assertContext(CLS_NM, methodName, child, GlobalErrIds.ORG_CHILD_NULL);
    // ensure the child OrgUnit exists:
    OrgUnit newChild = ouP.read(child);
    if (parent.getType() == OrgUnit.Type.USER) {
        UsoUtil.getInstance().validateRelationship(child, parent, false);
    } else {
        PsoUtil.getInstance().validateRelationship(child, parent, false);
    }
    ouP.add(parent);
    newChild.setParent(parent.getName());
    newChild.setContextId(this.contextId);
    ouP.update(newChild);
    if (parent.getType() == OrgUnit.Type.USER) {
        UsoUtil.getInstance().updateHier(this.contextId, new Relationship(child.getName().toUpperCase(), parent.getName().toUpperCase()), Hier.Op.ADD);
    } else {
        PsoUtil.getInstance().updateHier(this.contextId, new Relationship(child.getName().toUpperCase(), parent.getName().toUpperCase()), Hier.Op.ADD);
    }
}
Also used : OrgUnit(org.apache.directory.fortress.core.model.OrgUnit) Relationship(org.apache.directory.fortress.core.model.Relationship) AdminPermissionOperation(org.apache.directory.fortress.annotation.AdminPermissionOperation)

Example 2 with OrgUnit

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

the class CommandLineInterpreter method processDelegatedAdminCommand.

private void processDelegatedAdminCommand(Set<String> commands, Options options) {
    String command;
    try {
        if (commands.contains(ADD_ROLE)) {
            command = ADD_ROLE;
            LOG.info(command);
            AdminRole role = options.getAdminRole();
            delAdminMgr.addRole(role);
        } else if (commands.contains(UPDATE_ROLE)) {
            command = UPDATE_ROLE;
            LOG.info(command);
            AdminRole role = options.getAdminRole();
            delAdminMgr.updateRole(role);
        } else if (commands.contains(DELETE_ROLE)) {
            command = DELETE_ROLE;
            LOG.info(command);
            AdminRole role = options.getAdminRole();
            delAdminMgr.deleteRole(role);
        } else if (commands.contains(ASSIGN_ROLE)) {
            command = ASSIGN_ROLE;
            LOG.info(command);
            Role role = options.getRole();
            String userId = options.getUserId();
            delAdminMgr.assignUser(new UserAdminRole(userId, role));
        } else if (commands.contains(DEASSIGN_ROLE)) {
            command = DEASSIGN_ROLE;
            LOG.info(command);
            Role role = options.getRole();
            String userId = options.getUserId();
            delAdminMgr.deassignUser(new UserAdminRole(userId, role));
        } else if (commands.contains(ADD_ROLE_INHERITANCE)) {
            command = ADD_ROLE_INHERITANCE;
            LOG.info(command);
            Relationship relationship = options.getRelationship();
            delAdminMgr.addInheritance(new AdminRole(relationship.getParent()), new AdminRole(relationship.getChild()));
        } else if (commands.contains(DELETE_ROLE_INHERITANCE)) {
            command = DELETE_ROLE_INHERITANCE;
            LOG.info(command);
            Relationship relationship = options.getRelationship();
            delAdminMgr.deleteInheritance(new AdminRole(relationship.getParent()), new AdminRole(relationship.getChild()));
        } else if (commands.contains(ADD_POBJ)) {
            command = ADD_POBJ;
            LOG.info(command);
            PermObj permObj = options.getPermObj();
            delAdminMgr.addPermObj(permObj);
        } else if (commands.contains(UPDATE_POBJ)) {
            command = UPDATE_POBJ;
            LOG.info(command);
            PermObj permObj = options.getPermObj();
            delAdminMgr.updatePermObj(permObj);
        } else if (commands.contains(DELETE_POBJ)) {
            command = DELETE_POBJ;
            LOG.info(command);
            PermObj permObj = options.getPermObj();
            delAdminMgr.deletePermObj(permObj);
        } else if (commands.contains(ADD_PERM)) {
            command = ADD_PERM;
            LOG.info(command);
            Permission perm = options.getPermission();
            delAdminMgr.addPermission(perm);
        } else if (commands.contains(UPDATE_PERM)) {
            command = UPDATE_PERM;
            LOG.info(command);
            Permission perm = options.getPermission();
            delAdminMgr.updatePermission(perm);
        } else if (commands.contains(DELETE_PERM)) {
            command = DELETE_PERM;
            LOG.info(command);
            Permission permObj = options.getPermission();
            delAdminMgr.deletePermission(permObj);
        } else if (commands.contains(GRANT)) {
            command = GRANT;
            LOG.info(command);
            Permission perm = options.getPermission();
            AdminRole role = options.getAdminRole();
            role.setName(options.getRoleNm());
            delAdminMgr.grantPermission(perm, role);
        } else if (commands.contains(REVOKE)) {
            command = REVOKE;
            LOG.info(command);
            Permission perm = options.getPermission();
            AdminRole role = options.getAdminRole();
            role.setName(options.getRoleNm());
            delAdminMgr.revokePermission(perm, role);
        } else if (commands.contains(ADD_USERORG)) {
            command = ADD_USERORG;
            LOG.info(command);
            OrgUnit orgUnit = options.getOrgUnit();
            orgUnit.setType(OrgUnit.Type.USER);
            delAdminMgr.add(orgUnit);
        } else if (commands.contains(UPDATE_USERORG)) {
            command = UPDATE_USERORG;
            LOG.info(command);
            OrgUnit orgUnit = options.getOrgUnit();
            orgUnit.setType(OrgUnit.Type.USER);
            delAdminMgr.update(orgUnit);
        } else if (commands.contains(DELETE_USERORG)) {
            command = DELETE_USERORG;
            LOG.info(command);
            OrgUnit orgUnit = options.getOrgUnit();
            orgUnit.setType(OrgUnit.Type.USER);
            delAdminMgr.delete(orgUnit);
        } else if (commands.contains(ADD_USERORG_INHERITANCE)) {
            command = ADD_USERORG_INHERITANCE;
            LOG.info(command);
            Relationship relationship = options.getRelationship();
            delAdminMgr.addInheritance(new OrgUnit(relationship.getParent(), OrgUnit.Type.USER), new OrgUnit(relationship.getChild(), OrgUnit.Type.USER));
        } else if (commands.contains(DELETE_USERORG_INHERITANCE)) {
            command = DELETE_USERORG_INHERITANCE;
            LOG.info(command);
            Relationship relationship = options.getRelationship();
            delAdminMgr.deleteInheritance(new OrgUnit(relationship.getParent(), OrgUnit.Type.USER), new OrgUnit(relationship.getChild(), OrgUnit.Type.USER));
        } else if (commands.contains(ADD_PERMORG)) {
            command = ADD_PERMORG;
            LOG.info(command);
            OrgUnit orgUnit = options.getOrgUnit();
            orgUnit.setType(OrgUnit.Type.PERM);
            delAdminMgr.add(orgUnit);
        } else if (commands.contains(UPDATE_PERMORG)) {
            command = UPDATE_PERMORG;
            LOG.info(command);
            OrgUnit orgUnit = options.getOrgUnit();
            orgUnit.setType(OrgUnit.Type.PERM);
            delAdminMgr.update(orgUnit);
        } else if (commands.contains(DELETE_PERMORG)) {
            command = DELETE_PERMORG;
            LOG.info(command);
            OrgUnit orgUnit = options.getOrgUnit();
            orgUnit.setType(OrgUnit.Type.PERM);
            delAdminMgr.delete(orgUnit);
        } else if (commands.contains(ADD_PERMORG_INHERITANCE)) {
            command = ADD_PERMORG_INHERITANCE;
            LOG.info(command);
            Relationship relationship = options.getRelationship();
            delAdminMgr.addInheritance(new OrgUnit(relationship.getParent(), OrgUnit.Type.PERM), new OrgUnit(relationship.getChild(), OrgUnit.Type.PERM));
        } else if (commands.contains(DELETE_PERMORG_INHERITANCE)) {
            command = DELETE_PERMORG_INHERITANCE;
            LOG.info(command);
            Relationship relationship = options.getRelationship();
            delAdminMgr.deleteInheritance(new OrgUnit(relationship.getParent(), OrgUnit.Type.PERM), new OrgUnit(relationship.getChild(), OrgUnit.Type.PERM));
        } else {
            LOG.warn("unknown delegated admin operation detected");
            return;
        }
        LOG.info("command:{} was successful", command);
    } catch (org.apache.directory.fortress.core.SecurityException se) {
        String error = "processDelegatedAdminCommand caught SecurityException=" + se + ", return code=" + se.getErrorId();
        LOG.error(error);
    }
}
Also used : AdminRole(org.apache.directory.fortress.core.model.AdminRole) Role(org.apache.directory.fortress.core.model.Role) UserAdminRole(org.apache.directory.fortress.core.model.UserAdminRole) UserRole(org.apache.directory.fortress.core.model.UserRole) OrgUnit(org.apache.directory.fortress.core.model.OrgUnit) org.apache.directory.fortress.core(org.apache.directory.fortress.core) PermObj(org.apache.directory.fortress.core.model.PermObj) UserAdminRole(org.apache.directory.fortress.core.model.UserAdminRole) Relationship(org.apache.directory.fortress.core.model.Relationship) Permission(org.apache.directory.fortress.core.model.Permission) SecurityException(org.apache.directory.fortress.core.SecurityException) AdminRole(org.apache.directory.fortress.core.model.AdminRole) UserAdminRole(org.apache.directory.fortress.core.model.UserAdminRole)

Example 3 with OrgUnit

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

the class Options method getOrgUnit.

/**
 */
public OrgUnit getOrgUnit() {
    OrgUnit orgUnit = new OrgUnit();
    orgUnit.setName(getName());
    orgUnit.setDescription(getDescription());
    return orgUnit;
}
Also used : OrgUnit(org.apache.directory.fortress.core.model.OrgUnit)

Example 4 with OrgUnit

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

the class DelReviewMgrImpl method search.

/**
 * {@inheritDoc}
 */
@Override
@AdminPermissionOperation(operationName = "searchOU")
public List<OrgUnit> search(OrgUnit.Type type, String searchVal) throws SecurityException {
    String methodName = "searchOU";
    // VUtil.assertNotNullOrEmpty(searchVal, GlobalErrIds.ORG_NULL, CLS_NM + "." + methodName);
    VUtil.assertNotNull(type, GlobalErrIds.ORG_TYPE_NULL, CLS_NM + "." + methodName);
    checkAccess(CLS_NM, methodName);
    OrgUnit orgUnit = new OrgUnit(searchVal);
    orgUnit.setType(type);
    orgUnit.setContextId(this.contextId);
    return ouP.search(orgUnit);
}
Also used : OrgUnit(org.apache.directory.fortress.core.model.OrgUnit) AdminPermissionOperation(org.apache.directory.fortress.annotation.AdminPermissionOperation)

Example 5 with OrgUnit

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

the class OrgUnitDAO method unloadDescendants.

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

Aggregations

OrgUnit (org.apache.directory.fortress.core.model.OrgUnit)60 SecurityException (org.apache.directory.fortress.core.SecurityException)36 DelAdminMgr (org.apache.directory.fortress.core.DelAdminMgr)26 DelReviewMgr (org.apache.directory.fortress.core.DelReviewMgr)7 Relationship (org.apache.directory.fortress.core.model.Relationship)6 FinderException (org.apache.directory.fortress.core.FinderException)5 FortRequest (org.apache.directory.fortress.core.model.FortRequest)5 FortResponse (org.apache.directory.fortress.core.model.FortResponse)5 HashSet (java.util.HashSet)4 AdminPermissionOperation (org.apache.directory.fortress.annotation.AdminPermissionOperation)4 ArrayList (java.util.ArrayList)3 UserAdminRole (org.apache.directory.fortress.core.model.UserAdminRole)3 UserRole (org.apache.directory.fortress.core.model.UserRole)3 TreeSet (java.util.TreeSet)2 LdapException (org.apache.directory.api.ldap.model.exception.LdapException)2 ValidationException (org.apache.directory.fortress.core.ValidationException)2 AdminRole (org.apache.directory.fortress.core.model.AdminRole)2 Graphable (org.apache.directory.fortress.core.model.Graphable)2 Hier (org.apache.directory.fortress.core.model.Hier)2 ObjectFactory (org.apache.directory.fortress.core.model.ObjectFactory)2