Search in sources :

Example 1 with Hier

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

the class AdminRoleUtil 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 adminRole hierarchies.
 */
private static synchronized SimpleDirectedGraph<String, Relationship> loadGraph(String contextId) {
    Hier inHier = new Hier(Hier.Type.ROLE);
    inHier.setContextId(contextId);
    LOG.info("loadGraph initializing ADMIN ROLE context [{}]", inHier.getContextId());
    List<Graphable> descendants = null;
    try {
        descendants = adminRoleP.getAllDescendants(inHier.getContextId());
    } catch (SecurityException se) {
        LOG.info("loadGraph caught SecurityException={}", se);
    }
    Hier hier = HierUtil.loadHier(contextId, descendants);
    SimpleDirectedGraph<String, Relationship> graph;
    graph = HierUtil.buildGraph(hier);
    adminRoleCache.put(getKey(contextId), graph);
    return graph;
}
Also used : 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 2 with Hier

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

the class RoleUtil 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 role hierarchies.
 */
private synchronized SimpleDirectedGraph<String, Relationship> loadGraph(String contextId) {
    Hier inHier = new Hier(Hier.Type.ROLE);
    inHier.setContextId(contextId);
    LOG.info("loadGraph initializing ROLE context [{}]", inHier.getContextId());
    List<Graphable> descendants = null;
    try {
        descendants = roleP.getAllDescendants(inHier.getContextId());
    } catch (SecurityException se) {
        LOG.info("loadGraph caught SecurityException={}", se);
    }
    Hier hier = HierUtil.loadHier(contextId, descendants);
    SimpleDirectedGraph<String, Relationship> graph;
    graph = HierUtil.buildGraph(hier);
    roleCache.put(getKey(contextId), graph);
    return graph;
}
Also used : 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 3 with Hier

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

the class AdminMgrConsole method toHierTest.

/**
 * @param graph
 * @return
 * @throws org.apache.directory.fortress.core.SecurityException
 */
public static Hier toHierTest(UndirectedGraph<String, Relationship> graph) {
    Hier he = new Hier();
    Set<Relationship> eSet = graph.edgeSet();
    for (Relationship edge : eSet) {
        // Edge:(User : Root)
        he.setRelationship(edge);
    }
    Set<String> vSet = graph.vertexSet();
    for (String vertice : vSet) {
    // he.addRole(vertice);
    }
    return he;
}
Also used : Relationship(org.apache.directory.fortress.core.model.Relationship) Hier(org.apache.directory.fortress.core.model.Hier)

Example 4 with Hier

use of org.apache.directory.fortress.core.model.Hier 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 5 with Hier

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

the class PsoUtil 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 perm ou hierarchies.
 */
private synchronized SimpleDirectedGraph<String, Relationship> loadGraph(String contextId) {
    Hier inHier = new Hier(Hier.Type.ROLE);
    inHier.setContextId(contextId);
    LOG.info("loadGraph initializing PSO context [{}]", inHier.getContextId());
    List<Graphable> descendants = null;
    try {
        OrgUnit orgUnit = new OrgUnit();
        orgUnit.setType(OrgUnit.Type.PERM);
        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);
    psoCache.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)

Aggregations

Hier (org.apache.directory.fortress.core.model.Hier)6 Relationship (org.apache.directory.fortress.core.model.Relationship)6 Graphable (org.apache.directory.fortress.core.model.Graphable)5 SecurityException (org.apache.directory.fortress.core.SecurityException)4 OrgUnit (org.apache.directory.fortress.core.model.OrgUnit)2