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;
}
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;
}
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"));
}
}
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;
}
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);
}
Aggregations