Search in sources :

Example 1 with SimpleReferenceTree

use of org.forgerock.openam.entitlement.utils.indextree.SimpleReferenceTree in project OpenAM by OpenRock.

the class IndexTreeServiceImpl method createAndPopulateTree.

/**
     * Populates a new instance of a index rule tree with policy path indexes retrieved from the associated realm.
     *
     * @param realm
     *         The realm for which policy path indexes are to be read from.
     * @return A newly created tree populated with rules configured against the realm.
     * @throws EntitlementException
     *         When an error occurs reading policy data.
     */
private IndexRuleTree createAndPopulateTree(String realm) throws EntitlementException {
    IndexRuleTree indexTree = null;
    String baseDN = String.format(REALM_DN_TEMPLATE, dnMapper.orgNameToDN(realm));
    SSOToken token = AccessController.doPrivileged(adminAction);
    if (smDAO.checkIfEntryExists(baseDN, token)) {
        indexTree = new SimpleReferenceTree();
        try {
            Set<String> excludes = Collections.emptySet();
            // Carry out search.
            Iterator<SMSDataEntry> i = smDAO.search(token, baseDN, SEARCH_FILTER, 0, 0, false, false, excludes);
            while (i.hasNext()) {
                SMSDataEntry e = i.next();
                // Suppressed warning as unchecked assignment is valid.
                @SuppressWarnings("unchecked") Set<String> policyPathIndexes = e.getAttributeValues(INDEX_PATH_ATT);
                indexTree.addIndexRules(policyPathIndexes);
            }
        } catch (SMSException smsE) {
            throw new EntitlementException(52, new Object[] { baseDN }, smsE);
        }
        if (DEBUG.messageEnabled()) {
            DEBUG.message(String.format("Index rule tree created for '%s'.", realm));
        }
    }
    return indexTree;
}
Also used : EntitlementException(com.sun.identity.entitlement.EntitlementException) SimpleReferenceTree(org.forgerock.openam.entitlement.utils.indextree.SimpleReferenceTree) SSOToken(com.iplanet.sso.SSOToken) SMSDataEntry(com.sun.identity.sm.SMSDataEntry) SMSException(com.sun.identity.sm.SMSException) IndexRuleTree(org.forgerock.openam.entitlement.utils.indextree.IndexRuleTree)

Aggregations

SSOToken (com.iplanet.sso.SSOToken)1 EntitlementException (com.sun.identity.entitlement.EntitlementException)1 SMSDataEntry (com.sun.identity.sm.SMSDataEntry)1 SMSException (com.sun.identity.sm.SMSException)1 IndexRuleTree (org.forgerock.openam.entitlement.utils.indextree.IndexRuleTree)1 SimpleReferenceTree (org.forgerock.openam.entitlement.utils.indextree.SimpleReferenceTree)1