Search in sources :

Example 11 with SMSDataEntry

use of com.sun.identity.sm.SMSDataEntry in project OpenAM by OpenRock.

the class EmbeddedSearchResultIterator method next.

public SMSDataEntry next() {
    SMSDataEntry tmp = current;
    current = null;
    return tmp;
}
Also used : SMSDataEntry(com.sun.identity.sm.SMSDataEntry)

Example 12 with SMSDataEntry

use of com.sun.identity.sm.SMSDataEntry in project OpenAM by OpenRock.

the class DataStore method getPrivilege.

/**
     * Retrieves an individual privilege from the data store. The privilege is returned by the method and
     * also added to the passed in iterator.
     *
     * @param realm Realm in which the privilege exists.
     * @param privilegeIdentifier The identifier of the privilege to retrieve.
     * @return the privilege.
     * @throws EntitlementException if there were issues retrieving the privilege from the data store.
     */
public IPrivilege getPrivilege(String realm, String privilegeIdentifier) throws EntitlementException {
    final String privilegeDN = getPrivilegeDistinguishedName(privilegeIdentifier, realm, null);
    final long start = DB_MONITOR_PRIVILEGE.start();
    final SSOToken token = AccessController.doPrivileged(AdminTokenAction.getInstance());
    final Privilege privilege;
    try {
        final Iterator i = SMSEntry.search(token, privilegeDN, NO_FILTER, NO_LIMIT, NO_LIMIT, NOT_SORTED, NOT_SORTED, NO_EXCLUSIONS);
        if (i.hasNext()) {
            SMSDataEntry e = (SMSDataEntry) i.next();
            privilege = Privilege.getInstance(new JSONObject(e.getAttributeValue(SERIALIZABLE_INDEX_KEY)));
        } else {
            privilege = null;
        }
    } catch (SMSException e) {
        Object[] arg = { privilegeDN };
        throw new EntitlementException(52, arg, e);
    } catch (JSONException e) {
        Object[] arg = { privilegeDN };
        throw new EntitlementException(52, arg, e);
    }
    DB_MONITOR_PRIVILEGE.end(start);
    return privilege;
}
Also used : EntitlementException(com.sun.identity.entitlement.EntitlementException) SSOToken(com.iplanet.sso.SSOToken) JSONObject(org.json.JSONObject) SMSDataEntry(com.sun.identity.sm.SMSDataEntry) SMSException(com.sun.identity.sm.SMSException) BufferedIterator(com.sun.identity.shared.BufferedIterator) Iterator(java.util.Iterator) JSONException(org.json.JSONException) IPrivilege(com.sun.identity.entitlement.IPrivilege) Privilege(com.sun.identity.entitlement.Privilege) ReferralPrivilege(com.sun.identity.entitlement.ReferralPrivilege)

Example 13 with SMSDataEntry

use of com.sun.identity.sm.SMSDataEntry in project OpenAM by OpenRock.

the class SMSJAXRPCObject method search.

/**
     * Searches the data store for objects that match the filter
     */
public Iterator<SMSDataEntry> search(SSOToken token, String startDN, String filter, int numOfEntries, int timeLimit, boolean sortResults, boolean ascendingOrder, Set excludes) throws SMSException, SSOException {
    try {
        Object[] objs = { token.getTokenID().toString(), startDN, filter, Integer.valueOf(numOfEntries), Integer.valueOf(timeLimit), Boolean.valueOf(sortResults), Boolean.valueOf(ascendingOrder), excludes };
        Set<String> searchResults = ((Set<String>) client.send(client.encodeMessage("search3", objs), sessionCookies.getLBCookie(token.getTokenID().toString()), null));
        Iterator<SMSDataEntry> result = null;
        if (searchResults != null && !searchResults.isEmpty()) {
            Set<SMSDataEntry> dataEntries = new HashSet<SMSDataEntry>(searchResults.size());
            for (String jsonString : searchResults) {
                dataEntries.add(new SMSDataEntry(jsonString));
            }
            result = dataEntries.iterator();
        } else {
            result = Collections.emptyIterator();
        }
        return result;
    } catch (SSOException ssoe) {
        throw ssoe;
    } catch (SMSException smse) {
        throw smse;
    } catch (Exception re) {
        debug.error("SMSJAXRPCObject:search -- Exception:", re);
        throw (new SMSException(re, "sms-JAXRPC-error-in-searching"));
    }
}
Also used : SMSDataEntry(com.sun.identity.sm.SMSDataEntry) SMSException(com.sun.identity.sm.SMSException) SMSObject(com.sun.identity.sm.SMSObject) SSOException(com.iplanet.sso.SSOException) NamingException(javax.naming.NamingException) SMSException(com.sun.identity.sm.SMSException) SSOException(com.iplanet.sso.SSOException) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet)

Example 14 with SMSDataEntry

use of com.sun.identity.sm.SMSDataEntry in project OpenAM by OpenRock.

the class DataStore method searchReferrals.

public Set<ReferralPrivilege> searchReferrals(SSOToken adminToken, String realm, String filter) throws EntitlementException {
    Set<ReferralPrivilege> results = new HashSet<ReferralPrivilege>();
    String baseDN = getSearchBaseDN(realm, REFERRAL_STORE);
    if (SMSEntry.checkIfEntryExists(baseDN, adminToken)) {
        try {
            Iterator i = SMSEntry.search(adminToken, baseDN, filter, NO_LIMIT, NO_LIMIT, NOT_SORTED, NOT_SORTED, NO_EXCLUSIONS);
            while (i.hasNext()) {
                SMSDataEntry e = (SMSDataEntry) i.next();
                ReferralPrivilege referral = ReferralPrivilege.getInstance(new JSONObject(e.getAttributeValue(SERIALIZABLE_INDEX_KEY)));
                results.add(referral);
            }
        } catch (JSONException e) {
            Object[] arg = { baseDN };
            throw new EntitlementException(52, arg, e);
        } catch (SMSException e) {
            Object[] arg = { baseDN };
            throw new EntitlementException(52, arg, e);
        }
    }
    return results;
}
Also used : EntitlementException(com.sun.identity.entitlement.EntitlementException) ReferralPrivilege(com.sun.identity.entitlement.ReferralPrivilege) JSONObject(org.json.JSONObject) SMSDataEntry(com.sun.identity.sm.SMSDataEntry) SMSException(com.sun.identity.sm.SMSException) BufferedIterator(com.sun.identity.shared.BufferedIterator) Iterator(java.util.Iterator) JSONException(org.json.JSONException) HashSet(java.util.HashSet)

Example 15 with SMSDataEntry

use of com.sun.identity.sm.SMSDataEntry in project OpenAM by OpenRock.

the class EmbeddedSearchResultIterator method hasNext.

public boolean hasNext() {
    if (!resultIter.hasNext()) {
        return false;
    }
    SearchResultEntry entry = (SearchResultEntry) resultIter.next();
    String dn = entry.getName().toString();
    if (hasExcludeDNs) {
        while (excludeDNs.contains(dn)) {
            if (resultIter.hasNext()) {
                entry = (SearchResultEntry) resultIter.next();
                dn = entry.getName().toString();
            } else {
                entry = null;
                break;
            }
        }
    }
    current = (entry == null) ? null : new SMSDataEntry(dn, convertLDAPAttributeSetToMap(entry.getAttributes()));
    return (current != null);
}
Also used : SMSDataEntry(com.sun.identity.sm.SMSDataEntry) ByteString(org.forgerock.opendj.ldap.ByteString) SearchResultEntry(org.opends.server.types.SearchResultEntry)

Aggregations

SMSDataEntry (com.sun.identity.sm.SMSDataEntry)15 SMSException (com.sun.identity.sm.SMSException)8 HashSet (java.util.HashSet)8 EntitlementException (com.sun.identity.entitlement.EntitlementException)7 SSOToken (com.iplanet.sso.SSOToken)6 Iterator (java.util.Iterator)6 JSONException (org.json.JSONException)6 ReferralPrivilege (com.sun.identity.entitlement.ReferralPrivilege)5 JSONObject (org.json.JSONObject)5 BufferedIterator (com.sun.identity.shared.BufferedIterator)4 IPrivilege (com.sun.identity.entitlement.IPrivilege)3 Privilege (com.sun.identity.entitlement.Privilege)3 ArrayList (java.util.ArrayList)3 Test (org.testng.annotations.Test)2 SSOException (com.iplanet.sso.SSOException)1 SMSObject (com.sun.identity.sm.SMSObject)1 LinkedHashSet (java.util.LinkedHashSet)1 NamingException (javax.naming.NamingException)1 ResourceType (org.forgerock.openam.entitlement.ResourceType)1 IndexRuleTree (org.forgerock.openam.entitlement.utils.indextree.IndexRuleTree)1