Search in sources :

Example 51 with OrgUnit

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

the class DelegatedAdminMgrConsole method delete.

private void delete(OrgUnit.Type type) {
    OrgUnit ou = new OrgUnit();
    try {
        ReaderUtil.clearScreen();
        System.out.println("Enter orgunit name:");
        ou.setName(ReaderUtil.readLn());
        ou.setType(type);
        dAmgr.delete(ou);
        System.out.println("name [" + ou.getName() + "]");
        System.out.println("has been deleted");
        System.out.println("ENTER to continue");
    } catch (SecurityException e) {
        LOG.error("delete caught SecurityException rc=" + e.getErrorId() + ", msg=" + e.getMessage(), e);
    }
    ReaderUtil.readChar();
}
Also used : OrgUnit(org.apache.directory.fortress.core.model.OrgUnit)

Example 52 with OrgUnit

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

the class ReviewMgrConsole method findUsersByOrg.

/**
 */
void findUsersByOrg() {
    String szOu;
    ReaderUtil.clearScreen();
    try {
        System.out.println("Enter OrgUnit name");
        szOu = ReaderUtil.readLn();
        OrgUnit ou = new OrgUnit(szOu);
        ou.setType(OrgUnit.Type.USER);
        List<User> list = rm.findUsers(ou);
        int ctr = 0;
        for (User ue : list) {
            System.out.println("USER[" + ++ctr + "]");
            System.out.println("    userId      [" + ue.getUserId() + "]");
            System.out.println("    internalId  [" + ue.getInternalId() + "]");
            System.out.println("    description [" + ue.getDescription() + "]");
            System.out.println("    common name [" + ue.getCn() + "]");
            System.out.println("    surname     [" + ue.getSn() + "]");
            System.out.println("    orgUnitId   [" + ue.getOu() + "]");
            System.out.println("    pwpolicy    [" + ue.getPwPolicy() + "]");
            printTemporal(ue, "USER");
            printAddress(ue.getAddress(), "ADDRESS");
            printPhone(ue.getPhones(), "PHONES");
            printPhone(ue.getMobiles(), "MOBILES");
            if (ue.getRoles() != null) {
                for (UserRole ur : ue.getRoles()) {
                    printTemporal(ur, "RBACROLE");
                }
            }
            if (ue.getAdminRoles() != null) {
                for (UserAdminRole ur : ue.getAdminRoles()) {
                    printAdminRole(ur);
                    printTemporal(ur, "ADMINROLE");
                }
            }
            if (ue.getProperties() != null && ue.getProperties().size() > 0) {
                int pctr = 0;
                for (Enumeration e = ue.getProperties().propertyNames(); e.hasMoreElements(); ) {
                    String key = (String) e.nextElement();
                    String val = ue.getProperty(key);
                    System.out.println("prop key[" + pctr + "]=" + key);
                    System.out.println("prop value[" + pctr++ + "]=" + val);
                }
            }
            System.out.println();
        }
        System.out.println("ENTER to continue");
    } catch (SecurityException e) {
        LOG.error("findUsersByOrg caught SecurityException rc=" + e.getErrorId() + ", msg=" + e.getMessage(), e);
    }
    ReaderUtil.readChar();
}
Also used : OrgUnit(org.apache.directory.fortress.core.model.OrgUnit) User(org.apache.directory.fortress.core.model.User) Enumeration(java.util.Enumeration) UserRole(org.apache.directory.fortress.core.model.UserRole) UserAdminRole(org.apache.directory.fortress.core.model.UserAdminRole) Constraint(org.apache.directory.fortress.core.model.Constraint)

Example 53 with OrgUnit

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

the class UsoUtil method loadGraph.

/**
 * Read this ldap record,{@code cn=Hierarchies, ou=OS-P} into this entity, {@link Hier}, before loading into this collection class,{@code org.jgrapht.graph.SimpleDirectedGraph}
 * using 3rd party lib, <a href="http://www.jgrapht.org/">JGraphT</a>.
 *
 * @param contextId maps to sub-tree in DIT, e.g. ou=contextId, dc=example, dc=com.
 * @return handle to simple digraph containing user ou hierarchies.
 */
private synchronized SimpleDirectedGraph<String, Relationship> loadGraph(String contextId) {
    Hier inHier = new Hier(Hier.Type.ROLE);
    inHier.setContextId(contextId);
    LOG.info("loadGraph initializing USO context [{}]", inHier.getContextId());
    List<Graphable> descendants = null;
    try {
        OrgUnit orgUnit = new OrgUnit();
        orgUnit.setType(OrgUnit.Type.USER);
        orgUnit.setContextId(contextId);
        descendants = orgUnitP.getAllDescendants(orgUnit);
    } catch (SecurityException se) {
        LOG.info("loadGraph caught SecurityException={}", se);
    }
    Hier hier = HierUtil.loadHier(contextId, descendants);
    SimpleDirectedGraph<String, Relationship> graph;
    graph = HierUtil.buildGraph(hier);
    usoCache.put(getKey(contextId), graph);
    return graph;
}
Also used : OrgUnit(org.apache.directory.fortress.core.model.OrgUnit) Relationship(org.apache.directory.fortress.core.model.Relationship) SecurityException(org.apache.directory.fortress.core.SecurityException) Graphable(org.apache.directory.fortress.core.model.Graphable) Hier(org.apache.directory.fortress.core.model.Hier)

Example 54 with OrgUnit

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

the class PermP method validate.

/**
 * Method will perform various validations to ensure the integrity of the Permission Object entity targeted for insertion
 * or updating in directory.  Data reasonability checks will be performed on all non-null attributes.
 *
 * @param pObj     Permission Object entity contains data targeted for insertion or update.
 * @param isUpdate if true update operation is being performed which specifies a different set of targeted attributes.
 * @throws org.apache.directory.fortress.core.ValidationException in the event of data validation error.
 */
void validate(PermObj pObj, boolean isUpdate) throws ValidationException {
    if (!isUpdate) {
        // Validate length
        VUtil.orgUnit(pObj.getOu());
        // ensure ou exists in the OS-P pool:
        OrgUnit ou = new OrgUnit(pObj.getOu(), OrgUnit.Type.PERM);
        ou.setContextId(pObj.getContextId());
        if (!orgUnitP.isValid(ou)) {
            String error = "validate detected invalid orgUnit name [" + pObj.getOu() + "] for object name [" + pObj.getObjName() + "]";
            // log.warn(error);
            throw new ValidationException(GlobalErrIds.PERM_OU_INVALID, error);
        }
        if (StringUtils.isNotEmpty(pObj.getObjName())) {
            VUtil.description(pObj.getObjName());
        }
        if (StringUtils.isNotEmpty(pObj.getOu())) {
            VUtil.orgUnit(pObj.getOu());
        }
        if (StringUtils.isNotEmpty(pObj.getDescription())) {
            VUtil.description(pObj.getDescription());
        }
    } else {
        if (StringUtils.isNotEmpty(pObj.getOu())) {
            VUtil.orgUnit(pObj.getOu());
            // ensure ou exists in the OS-P pool:
            OrgUnit ou = new OrgUnit(pObj.getOu(), OrgUnit.Type.PERM);
            ou.setContextId(pObj.getContextId());
            if (!orgUnitP.isValid(ou)) {
                String error = "validate detected invalid orgUnit name [" + pObj.getOu() + "] for object name [" + pObj.getObjName() + "]";
                throw new ValidationException(GlobalErrIds.PERM_OU_INVALID, error);
            }
        }
        if (StringUtils.isNotEmpty(pObj.getDescription())) {
            VUtil.description(pObj.getDescription());
        }
    }
}
Also used : OrgUnit(org.apache.directory.fortress.core.model.OrgUnit) ValidationException(org.apache.directory.fortress.core.ValidationException)

Example 55 with OrgUnit

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

the class AdminRoleP method validateOrgs.

/**
 * Called by validate()
 *
 * @param orgs
 * @param contextId
 * @throws SecurityException
 */
private void validateOrgs(Set<String> orgs, OrgUnit.Type type, String contextId) throws SecurityException {
    for (String ou : orgs) {
        OrgUnit inOe = new OrgUnit(ou);
        inOe.setType(type);
        inOe.setContextId(contextId);
        op.read(inOe);
    }
}
Also used : OrgUnit(org.apache.directory.fortress.core.model.OrgUnit)

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