Search in sources :

Example 1 with SimpleIterator

use of com.sun.identity.entitlement.util.SimpleIterator in project OpenAM by OpenRock.

the class OpenSSOIndexStore method search.

/**
     * Search for policies.
     *
     * @param realm
     *         The realm of which the policy resides.
     * @param indexes
     *         Policy indexes.
     * @param subjectIndexes
     *         Subject indexes.
     * @param bSubTree
     *         Whether in subtree mode.
     * @param bReferral
     *         Whether there is a policy referral.
     * @return An iterator of policies.
     * @throws EntitlementException
     *         Should an error occur searching for policies.
     */
public Iterator<IPrivilege> search(String realm, ResourceSearchIndexes indexes, Set<String> subjectIndexes, boolean bSubTree, boolean bReferral) throws EntitlementException {
    BufferedIterator iterator = (isMultiThreaded) ? new BufferedIterator() : new SimpleIterator();
    // When not in subtree mode path indexes should be available.
    if (!bSubTree && indexes.getPathIndexes().isEmpty()) {
        return iterator;
    }
    // When in subtree mode parent path indexes should be available.
    if (bSubTree && indexes.getParentPathIndexes().isEmpty()) {
        return iterator;
    }
    Set setDNs = new HashSet();
    if (indexCacheSize > 0) {
        setDNs.addAll(searchPrivileges(indexes, subjectIndexes, bSubTree, iterator));
        setDNs.addAll(searchReferrals(indexes, bSubTree, iterator));
    }
    if (bReferral) {
        String tmp = LDAPUtils.isDN(realm) ? DNMapper.orgNameToRealmName(realm) : realm;
        if (tmp.equals("/")) {
            ReferralPrivilege ref = getOrgAliasReferral(indexes);
            if (ref != null) {
                iterator.add(ref);
            }
        }
    }
    if (indexCacheSize == 0 || isDSSearchNecessary()) {
        threadPool.submit(new SearchTask(iterator, indexes, subjectIndexes, bSubTree, setDNs));
    } else {
        iterator.isDone();
    }
    return iterator;
}
Also used : BufferedIterator(com.sun.identity.shared.BufferedIterator) HashSet(java.util.HashSet) Set(java.util.Set) ReferralPrivilege(com.sun.identity.entitlement.ReferralPrivilege) SimpleIterator(com.sun.identity.entitlement.util.SimpleIterator) HashSet(java.util.HashSet)

Aggregations

ReferralPrivilege (com.sun.identity.entitlement.ReferralPrivilege)1 SimpleIterator (com.sun.identity.entitlement.util.SimpleIterator)1 BufferedIterator (com.sun.identity.shared.BufferedIterator)1 HashSet (java.util.HashSet)1 Set (java.util.Set)1