use of org.forgerock.opendj.ldap.DecodeException in project OpenAM by OpenRock.
the class LDAPAuthUtils method processControls.
private List<Control> processControls(Result result) {
if (result == null) {
return Collections.EMPTY_LIST;
}
List<Control> controls = new ArrayList<Control>();
DecodeOptions options = new DecodeOptions();
Control c;
try {
c = result.getControl(PasswordExpiredResponseControl.DECODER, options);
if (c != null) {
controls.add(c);
}
} catch (DecodeException de) {
if (debug.warningEnabled()) {
debug.warning("unable to decode PasswordExpiredResponseControl", de);
}
}
try {
c = result.getControl(PasswordExpiringResponseControl.DECODER, options);
if (c != null) {
controls.add(c);
}
} catch (DecodeException de) {
if (debug.warningEnabled()) {
debug.warning("unable to decode PasswordExpiringResponseControl", de);
}
}
try {
c = result.getControl(PasswordPolicyResponseControl.DECODER, options);
if (c != null) {
controls.add(c);
}
} catch (DecodeException de) {
if (debug.warningEnabled()) {
debug.warning("unable to decode PasswordPolicyResponseControl", de);
}
}
return controls;
}
use of org.forgerock.opendj.ldap.DecodeException in project OpenAM by OpenRock.
the class LdapQueryBuilder method getEntries.
private Collection<Entry> getEntries(Connection connection) throws CoreTokenException {
// Prepare the search
Filter ldapFilter = getLDAPFilter();
SearchRequest searchRequest = LDAPRequests.newSearchRequest(dataLayerConfiguration.getTokenStoreRootSuffix(), SearchScope.WHOLE_SUBTREE, ldapFilter, requestedAttributes);
searchRequest.setSizeLimit(sizeLimit);
if (isPagingResults()) {
searchRequest = searchRequest.addControl(SimplePagedResultsControl.newControl(true, pageSize, pagingCookie));
}
// Perform the search
Collection<Entry> entries = createResultsList();
final Result result = handler.performSearch(connection, searchRequest, entries);
if (isPagingResults()) {
try {
SimplePagedResultsControl control = result.getControl(SimplePagedResultsControl.DECODER, new DecodeOptions());
if (control == null) {
if (debug.warningEnabled()) {
debug.warning("There was no paged result control in the search response, it is recommended to " + "set the CTS user's size-limit at least to " + (pageSize + 1));
}
pagingCookie = getEmptyPagingCookie();
} else {
pagingCookie = control.getCookie();
}
} catch (DecodeException e) {
throw new CoreTokenException("Failed to decode Paging Cookie", e);
}
}
if (debug.messageEnabled()) {
debug.message(MessageFormat.format(CoreTokenConstants.DEBUG_HEADER + "Query: matched {0} results\n" + "Search Request: {1}\n" + "Filter: {2}\n" + "Result: {3}", entries.size(), searchRequest, ldapFilter.toString(), result));
}
return entries;
}
use of org.forgerock.opendj.ldap.DecodeException in project OpenAM by OpenRock.
the class IndexChangeHandler method handleEntry.
@Override
public boolean handleEntry(SearchResultEntry entry) {
EntryChangeNotificationResponseControl control = null;
try {
// Retrieve details of the policy change.
control = entry.getControl(EntryChangeNotificationResponseControl.DECODER, new DecodeOptions());
} catch (DecodeException dE) {
DEBUG.error("Error occurred attempting to read policy rule change.", dE);
// Notify observers of the exception and proceed no further.
observable.notifyObservers(ErrorEventType.SEARCH_FAILURE.createEvent());
return true;
}
// Extract the realm from the DN to be passed as part of the event.
String dn = entry.getName().toString();
String orgName = dn.substring(dn.indexOf(SERVICE_DECLARATION) + SERVICE_DECLARATION.length());
String realm = dnMapper.orgNameToRealmName(orgName);
// Retrieve all sunxmlKeyValue attributes.
Attribute attributes = entry.getAttribute(AttributeDescription.valueOf("sunxmlKeyValue"));
for (ByteString attrValue : attributes) {
String attStrValue = attrValue.toString();
if (attStrValue.startsWith(INDEX_PATH_ATT)) {
// Extract the path index out of the attribute value.
String pathIndex = attStrValue.substring(INDEX_PATH_ATT.length() + 1);
switch(control.getChangeType()) {
case MODIFY:
// this will result in the old index remaining.
case ADD:
observable.notifyObservers(ModificationEventType.ADD.createEvent(pathIndex, realm));
break;
case DELETE:
observable.notifyObservers(ModificationEventType.DELETE.createEvent(pathIndex, realm));
break;
}
}
}
return true;
}
Aggregations