Search in sources :

Example 36 with SDSet

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

the class CacheSample method loadCache.

private void loadCache() {
    try {
        SDSet sdSet = new SDSet();
        sdSet.setType(SDSet.SDType.DYNAMIC);
        sdSet.setName("");
        List<SDSet> dsds = sdP.search(sdSet);
        if (dsds != null) {
            for (SDSet dsd : dsds) {
                Set<String> members = dsd.getMembers();
                if (members != null) {
                    for (String member : members) {
                        DsdCacheEntry entry = new DsdCacheEntry(member, dsd);
                        String key = dsd.getName() + ":" + member;
                        cache.put(key, entry);
                        LOG.info("Add DSD key: " + key + " members: " + dsd.getMembers() + " to the cache");
                    }
                }
            }
        } else {
            LOG.info("No records found for loading into test cache");
        }
    } catch (org.apache.directory.fortress.core.SecurityException se) {
        String error = " static initializer caught SecurityException=" + se.getMessage() + " rc=" + se.getErrorId();
        LOG.error(error);
    }
}
Also used : SDSet(org.apache.directory.fortress.core.model.SDSet)

Example 37 with SDSet

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

the class CacheSample method runTests.

void runTests() {
    loadCache();
    Attribute<String> member = cache.getSearchAttribute("member");
    Query query = cache.createQuery();
    query.includeKeys();
    query.includeValues();
    Set<String> roles = new HashSet<>();
    roles.add("oamt17dsd1");
    roles.add("oamt17dsd4");
    roles.add("oamT13DSD6");
    roles.add("oamT16SDR7");
    query.addCriteria(member.in(roles));
    Results results = query.execute();
    System.out.println(" Size: " + results.size());
    System.out.println("----Results-----\n");
    Set<SDSet> resultSet = new HashSet<>();
    for (Result result : results.all()) {
        DsdCacheEntry entry = (DsdCacheEntry) result.getValue();
        resultSet.add(entry.getSdSet());
    }
    for (SDSet sdSet : resultSet) {
        LOG.info("Found SDSet: " + sdSet.getName());
    }
}
Also used : SDSet(org.apache.directory.fortress.core.model.SDSet) Query(net.sf.ehcache.search.Query) Results(net.sf.ehcache.search.Results) HashSet(java.util.HashSet) Result(net.sf.ehcache.search.Result)

Example 38 with SDSet

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

the class ReviewMgrImplTest method searchSsdSets.

/**
 * @param msg
 * @param srchValue
 * @param sArray
 */
public static void searchSsdSets(String msg, String srchValue, String[][] sArray) {
    LogUtil.logIt(msg);
    try {
        ReviewMgr reviewMgr = getManagedReviewMgr();
        SDSet sdSet = new SDSet();
        sdSet.setName(srchValue);
        List<SDSet> sdSetList = reviewMgr.ssdSets(sdSet);
        assertNotNull(sdSetList);
    } catch (SecurityException ex) {
        LOG.error("searchRoles searchSsdSets [" + srchValue + "] caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
        fail(ex.getMessage());
    }
}
Also used : SDSet(org.apache.directory.fortress.core.model.SDSet) ReviewMgr(org.apache.directory.fortress.core.ReviewMgr) SecurityException(org.apache.directory.fortress.core.SecurityException)

Example 39 with SDSet

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

the class ReviewMgrImplTest method searchDsdSets.

/**
 * @param msg
 * @param srchValue
 * @param sArray
 */
public static void searchDsdSets(String msg, String srchValue, String[][] sArray) {
    LogUtil.logIt(msg);
    try {
        ReviewMgr reviewMgr = getManagedReviewMgr();
        SDSet sdSet = new SDSet();
        sdSet.setName(srchValue);
        List<SDSet> sdSetList = reviewMgr.ssdSets(sdSet);
        assertNotNull(sdSetList);
    } catch (SecurityException ex) {
        LOG.error("searchRoles searchDsdSets [" + srchValue + "] caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
        fail(ex.getMessage());
    }
}
Also used : SDSet(org.apache.directory.fortress.core.model.SDSet) ReviewMgr(org.apache.directory.fortress.core.ReviewMgr) SecurityException(org.apache.directory.fortress.core.SecurityException)

Example 40 with SDSet

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

the class RoleTestData method getSDSet.

/**
 * @param rle
 * @return
 */
/*
    public static Map<String, String> getMembers(String[] rle)
    {
        Map<String, String> mems = new HashMap<>();
        if(org.apache.directory.fortress.core.util.attr.StringUtils.isNotEmpty(rle[MEMBERS]))
        {
            StringTokenizer charSetTkn = new StringTokenizer(rle[MEMBERS], TestUtils.DELIMITER_TEST_DATA);
            if (charSetTkn.countTokens() > 0)
            {
                while (charSetTkn.hasMoreTokens())
                {
                    String pRole = charSetTkn.nextToken();
                    mems.put(pRole, "");
                }
            }
        }
        return mems;
    }
    */
/**
 * @param ssdArry
 * @return
 */
public static SDSet getSDSet(String[] ssdArry) {
    SDSet ssd = new SDSet();
    ssd.setName(getName(ssdArry));
    ssd.setDescription(getDescription(ssdArry));
    ssd.setCardinality(getCardinality(ssdArry));
    ssd.setMembers(getMembers(ssdArry));
    return ssd;
}
Also used : SDSet(org.apache.directory.fortress.core.model.SDSet)

Aggregations

SDSet (org.apache.directory.fortress.core.model.SDSet)58 SecurityException (org.apache.directory.fortress.core.SecurityException)37 FortRequest (org.apache.directory.fortress.core.model.FortRequest)20 FortResponse (org.apache.directory.fortress.core.model.FortResponse)20 AdminMgr (org.apache.directory.fortress.core.AdminMgr)12 UserRole (org.apache.directory.fortress.core.model.UserRole)12 AdminPermissionOperation (org.apache.directory.fortress.annotation.AdminPermissionOperation)8 ReviewMgr (org.apache.directory.fortress.core.ReviewMgr)8 Role (org.apache.directory.fortress.core.model.Role)7 User (org.apache.directory.fortress.core.model.User)5 LdapException (org.apache.directory.api.ldap.model.exception.LdapException)4 FinderException (org.apache.directory.fortress.core.FinderException)4 RoleConstraint (org.apache.directory.fortress.core.model.RoleConstraint)4 LdapConnection (org.apache.directory.ldap.client.api.LdapConnection)4 CursorException (org.apache.directory.api.ldap.model.cursor.CursorException)3 SearchCursor (org.apache.directory.api.ldap.model.cursor.SearchCursor)3 Constraint (org.apache.directory.fortress.core.model.Constraint)3 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 AccessMgr (org.apache.directory.fortress.core.AccessMgr)2