use of com.unboundid.ldap.sdk.controls.ServerSideSortResponseControl in project ldapsdk by pingidentity.
the class InMemoryRequestHandler method processSearchRequest.
/**
* Attempts to process the provided search request. The attempt will fail
* if any of the following conditions is true:
* <UL>
* <LI>There is a problem with any of the request controls.</LI>
* <LI>The modify DN request contains a malformed target DN, new RDN, or
* new superior DN.</LI>
* <LI>The new DN of the entry would conflict with the DN of an existing
* entry.</LI>
* <LI>The new DN of the entry would exist outside the set of defined
* base DNs.</LI>
* <LI>The new DN of the entry is not a defined base DN and does not exist
* immediately below an existing entry.</LI>
* </UL>
*
* @param messageID The message ID of the LDAP message containing the
* search request.
* @param request The search request that was included in the LDAP
* message that was received.
* @param controls The set of controls included in the LDAP message.
* It may be empty if there were no controls, but will
* not be {@code null}.
* @param entryList A list to which to add search result entries
* intended for return to the client. It must not be
* {@code null}.
* @param referenceList A list to which to add search result references
* intended for return to the client. It must not be
* {@code null}.
*
* @return The {@link LDAPMessage} containing the response to send to the
* client. The protocol op in the {@code LDAPMessage} must be an
* {@code SearchResultDoneProtocolOp}.
*/
@NotNull()
LDAPMessage processSearchRequest(final int messageID, @NotNull final SearchRequestProtocolOp request, @NotNull final List<Control> controls, @NotNull final List<SearchResultEntry> entryList, @NotNull final List<SearchResultReference> referenceList) {
synchronized (entryMap) {
// Sleep before processing, if appropriate.
final long processingStartTime = System.currentTimeMillis();
sleepBeforeProcessing();
// Look at the filter and see if it contains any unsupported elements.
try {
ensureFilterSupported(request.getFilter());
} catch (final LDAPException le) {
Debug.debugException(le);
return new LDAPMessage(messageID, new SearchResultDoneProtocolOp(le.getResultCode().intValue(), null, le.getMessage(), null));
}
// Look at the time limit for the search request and see if sleeping
// would have caused us to exceed that time limit. It's extremely
// unlikely that any search in the in-memory directory server would take
// a second or more to complete, and that's the minimum time limit that
// can be requested, so there's no need to check the time limit in most
// cases. However, someone may want to force a "time limit exceeded"
// response by configuring a delay that is greater than the requested time
// limit, so we should check now to see if that's been exceeded.
final long timeLimitMillis = 1000L * request.getTimeLimit();
if (timeLimitMillis > 0L) {
final long timeLimitExpirationTime = processingStartTime + timeLimitMillis;
if (System.currentTimeMillis() >= timeLimitExpirationTime) {
return new LDAPMessage(messageID, new SearchResultDoneProtocolOp(ResultCode.TIME_LIMIT_EXCEEDED_INT_VALUE, null, ERR_MEM_HANDLER_TIME_LIMIT_EXCEEDED.get(), null));
}
}
// Process the provided request controls.
final Map<String, Control> controlMap;
try {
controlMap = RequestControlPreProcessor.processControls(LDAPMessage.PROTOCOL_OP_TYPE_SEARCH_REQUEST, controls);
} catch (final LDAPException le) {
Debug.debugException(le);
return new LDAPMessage(messageID, new SearchResultDoneProtocolOp(le.getResultCode().intValue(), null, le.getMessage(), null));
}
final ArrayList<Control> responseControls = new ArrayList<>(1);
// If this operation type is not allowed, then reject it.
final boolean isInternalOp = controlMap.containsKey(OID_INTERNAL_OPERATION_REQUEST_CONTROL);
if ((!isInternalOp) && (!config.getAllowedOperationTypes().contains(OperationType.SEARCH))) {
return new LDAPMessage(messageID, new SearchResultDoneProtocolOp(ResultCode.UNWILLING_TO_PERFORM_INT_VALUE, null, ERR_MEM_HANDLER_SEARCH_NOT_ALLOWED.get(), null));
}
// client is authenticated.
if ((authenticatedDN.isNullDN() && config.getAuthenticationRequiredOperationTypes().contains(OperationType.SEARCH))) {
return new LDAPMessage(messageID, new SearchResultDoneProtocolOp(ResultCode.INSUFFICIENT_ACCESS_RIGHTS_INT_VALUE, null, ERR_MEM_HANDLER_SEARCH_REQUIRES_AUTH.get(), null));
}
// Get the parsed base DN.
final DN baseDN;
final Schema schema = schemaRef.get();
try {
baseDN = new DN(request.getBaseDN(), schema);
} catch (final LDAPException le) {
Debug.debugException(le);
return new LDAPMessage(messageID, new SearchResultDoneProtocolOp(ResultCode.INVALID_DN_SYNTAX_INT_VALUE, null, ERR_MEM_HANDLER_SEARCH_MALFORMED_BASE.get(request.getBaseDN(), le.getMessage()), null));
}
// See if the search base or one of its superiors is a smart referral.
final boolean hasManageDsaIT = controlMap.containsKey(ManageDsaITRequestControl.MANAGE_DSA_IT_REQUEST_OID);
if (!hasManageDsaIT) {
final Entry referralEntry = findNearestReferral(baseDN);
if (referralEntry != null) {
return new LDAPMessage(messageID, new SearchResultDoneProtocolOp(ResultCode.REFERRAL_INT_VALUE, referralEntry.getDN(), INFO_MEM_HANDLER_REFERRAL_ENCOUNTERED.get(), getReferralURLs(baseDN, referralEntry)));
}
}
// Make sure that the base entry exists. It may be the root DSE or
// subschema subentry.
final Entry baseEntry;
boolean includeChangeLog = true;
if (baseDN.isNullDN()) {
baseEntry = generateRootDSE();
includeChangeLog = false;
} else if (baseDN.equals(subschemaSubentryDN)) {
baseEntry = subschemaSubentryRef.get();
} else {
baseEntry = entryMap.get(baseDN);
}
if (baseEntry == null) {
return new LDAPMessage(messageID, new SearchResultDoneProtocolOp(ResultCode.NO_SUCH_OBJECT_INT_VALUE, getMatchedDNString(baseDN), ERR_MEM_HANDLER_SEARCH_BASE_DOES_NOT_EXIST.get(request.getBaseDN()), null));
}
// controls.
try {
handleAssertionRequestControl(controlMap, baseEntry);
handleProxiedAuthControl(controlMap);
} catch (final LDAPException le) {
Debug.debugException(le);
return new LDAPMessage(messageID, new SearchResultDoneProtocolOp(le.getResultCode().intValue(), null, le.getMessage(), null));
}
// Determine whether to include subentries in search results.
final boolean includeSubEntries;
final boolean includeNonSubEntries;
final SearchScope scope = request.getScope();
if (scope == SearchScope.BASE) {
includeSubEntries = true;
includeNonSubEntries = true;
} else if (controlMap.containsKey(DraftLDUPSubentriesRequestControl.SUBENTRIES_REQUEST_OID)) {
includeSubEntries = true;
includeNonSubEntries = false;
} else if (controlMap.containsKey(RFC3672SubentriesRequestControl.SUBENTRIES_REQUEST_OID)) {
includeSubEntries = true;
final RFC3672SubentriesRequestControl c = (RFC3672SubentriesRequestControl) controlMap.get(RFC3672SubentriesRequestControl.SUBENTRIES_REQUEST_OID);
includeNonSubEntries = (!c.returnOnlySubEntries());
} else if (baseEntry.hasObjectClass("ldapSubEntry") || baseEntry.hasObjectClass("inheritableLDAPSubEntry")) {
includeSubEntries = true;
includeNonSubEntries = true;
} else if (filterIncludesLDAPSubEntry(request.getFilter())) {
includeSubEntries = true;
includeNonSubEntries = true;
} else {
includeSubEntries = false;
includeNonSubEntries = true;
}
// Create a temporary list to hold all of the entries to be returned.
// These entries will not have been pared down based on the requested
// attributes.
final List<Entry> fullEntryList = new ArrayList<>(entryMap.size());
findEntriesAndRefs: {
// Check the scope. If it is a base-level search, then we only need to
// examine the base entry. Otherwise, we'll have to scan the entire
// entry map.
final Filter filter = request.getFilter();
if (scope == SearchScope.BASE) {
try {
if (filter.matchesEntry(baseEntry, schema)) {
processSearchEntry(baseEntry, includeSubEntries, includeNonSubEntries, includeChangeLog, hasManageDsaIT, fullEntryList, referenceList);
}
} catch (final Exception e) {
Debug.debugException(e);
}
break findEntriesAndRefs;
}
// set.
if ((scope == SearchScope.ONE) && baseDN.isNullDN()) {
for (final DN dn : baseDNs) {
final Entry e = entryMap.get(dn);
if (e != null) {
try {
if (filter.matchesEntry(e, schema)) {
processSearchEntry(e, includeSubEntries, includeNonSubEntries, includeChangeLog, hasManageDsaIT, fullEntryList, referenceList);
}
} catch (final Exception ex) {
Debug.debugException(ex);
}
}
}
break findEntriesAndRefs;
}
// Try to use indexes to process the request. If we can't use any
// indexes to get a candidate list, then just iterate over all the
// entries. It's not necessary to consider the root DSE for non-base
// scopes.
final Set<DN> candidateDNs = indexSearch(filter);
if (candidateDNs == null) {
for (final Map.Entry<DN, ReadOnlyEntry> me : entryMap.entrySet()) {
final DN dn = me.getKey();
final Entry entry = me.getValue();
try {
if (dn.matchesBaseAndScope(baseDN, scope)) {
if (filter.matchesEntry(entry, schema) || (((!hasManageDsaIT) && entry.hasObjectClass("referral") && entry.hasAttribute("ref")))) {
processSearchEntry(entry, includeSubEntries, includeNonSubEntries, includeChangeLog, hasManageDsaIT, fullEntryList, referenceList);
}
}
} catch (final Exception e) {
Debug.debugException(e);
}
}
} else {
for (final DN dn : candidateDNs) {
try {
if (!dn.matchesBaseAndScope(baseDN, scope)) {
continue;
}
final Entry entry = entryMap.get(dn);
if (filter.matchesEntry(entry, schema) || (((!hasManageDsaIT) && entry.hasObjectClass("referral") && entry.hasAttribute("ref")))) {
processSearchEntry(entry, includeSubEntries, includeNonSubEntries, includeChangeLog, hasManageDsaIT, fullEntryList, referenceList);
}
} catch (final Exception e) {
Debug.debugException(e);
}
}
}
}
// If the request included the server-side sort request control, then sort
// the matching entries appropriately.
final ServerSideSortRequestControl sortRequestControl = (ServerSideSortRequestControl) controlMap.get(ServerSideSortRequestControl.SERVER_SIDE_SORT_REQUEST_OID);
if (sortRequestControl != null) {
final EntrySorter entrySorter = new EntrySorter(false, schema, sortRequestControl.getSortKeys());
final SortedSet<Entry> sortedEntrySet = entrySorter.sort(fullEntryList);
fullEntryList.clear();
fullEntryList.addAll(sortedEntrySet);
responseControls.add(new ServerSideSortResponseControl(ResultCode.SUCCESS, null));
}
// If the request included the simple paged results control, then handle
// it.
final SimplePagedResultsControl pagedResultsControl = (SimplePagedResultsControl) controlMap.get(SimplePagedResultsControl.PAGED_RESULTS_OID);
if (pagedResultsControl != null) {
final int totalSize = fullEntryList.size();
final int pageSize = pagedResultsControl.getSize();
final ASN1OctetString cookie = pagedResultsControl.getCookie();
final int offset;
if ((cookie == null) || (cookie.getValueLength() == 0)) {
// This is the first request in the series, so start at the beginning
// of the list.
offset = 0;
} else {
// offset within the result list at which to start the next batch.
try {
final ASN1Integer offsetInteger = ASN1Integer.decodeAsInteger(cookie.getValue());
offset = offsetInteger.intValue();
} catch (final Exception e) {
Debug.debugException(e);
return new LDAPMessage(messageID, new SearchResultDoneProtocolOp(ResultCode.PROTOCOL_ERROR_INT_VALUE, null, ERR_MEM_HANDLER_MALFORMED_PAGED_RESULTS_COOKIE.get(), null), responseControls);
}
}
// Create an iterator that will be used to remove entries from the
// result set that are outside of the requested page of results.
int pos = 0;
final Iterator<Entry> iterator = fullEntryList.iterator();
// offset.
while (iterator.hasNext() && (pos < offset)) {
iterator.next();
iterator.remove();
pos++;
}
// Next, skip over the entries that should be returned.
int keptEntries = 0;
while (iterator.hasNext() && (keptEntries < pageSize)) {
iterator.next();
pos++;
keptEntries++;
}
// to include in the response. Otherwise, use an empty cookie.
if (iterator.hasNext()) {
responseControls.add(new SimplePagedResultsControl(totalSize, new ASN1OctetString(new ASN1Integer(pos).encode()), false));
while (iterator.hasNext()) {
iterator.next();
iterator.remove();
}
} else {
responseControls.add(new SimplePagedResultsControl(totalSize, new ASN1OctetString(), false));
}
}
// If the request includes the virtual list view request control, then
// handle it.
final VirtualListViewRequestControl vlvRequest = (VirtualListViewRequestControl) controlMap.get(VirtualListViewRequestControl.VIRTUAL_LIST_VIEW_REQUEST_OID);
if (vlvRequest != null) {
final int totalEntries = fullEntryList.size();
final ASN1OctetString assertionValue = vlvRequest.getAssertionValue();
// Figure out the position of the target entry in the list.
int offset = vlvRequest.getTargetOffset();
if (assertionValue == null) {
// The offset is one-based, so we need to adjust it for the list's
// zero-based offset. Also, make sure to put it within the bounds of
// the list.
offset--;
offset = Math.max(0, offset);
offset = Math.min(fullEntryList.size(), offset);
} else {
final SortKey primarySortKey = sortRequestControl.getSortKeys()[0];
final Entry testEntry = new Entry("cn=test", schema, new Attribute(primarySortKey.getAttributeName(), assertionValue));
final EntrySorter entrySorter = new EntrySorter(false, schema, primarySortKey);
offset = fullEntryList.size();
for (int i = 0; i < fullEntryList.size(); i++) {
if (entrySorter.compare(fullEntryList.get(i), testEntry) >= 0) {
offset = i;
break;
}
}
}
// Get the start and end positions based on the before and after counts.
final int beforeCount = Math.max(0, vlvRequest.getBeforeCount());
final int afterCount = Math.max(0, vlvRequest.getAfterCount());
final int start = Math.max(0, (offset - beforeCount));
final int end = Math.min(fullEntryList.size(), (offset + afterCount + 1));
// Create an iterator to use to alter the list so that it only contains
// the appropriate set of entries.
int pos = 0;
final Iterator<Entry> iterator = fullEntryList.iterator();
while (iterator.hasNext()) {
iterator.next();
if ((pos < start) || (pos >= end)) {
iterator.remove();
}
pos++;
}
// Create the appropriate response control.
responseControls.add(new VirtualListViewResponseControl((offset + 1), totalEntries, ResultCode.SUCCESS, null));
}
// Process the set of requested attributes so that we can pare down the
// entries.
final SearchEntryParer parer = new SearchEntryParer(request.getAttributes(), schema);
final int sizeLimit;
if (request.getSizeLimit() > 0) {
sizeLimit = Math.min(request.getSizeLimit(), maxSizeLimit);
} else {
sizeLimit = maxSizeLimit;
}
int entryCount = 0;
for (final Entry e : fullEntryList) {
entryCount++;
if (entryCount > sizeLimit) {
return new LDAPMessage(messageID, new SearchResultDoneProtocolOp(ResultCode.SIZE_LIMIT_EXCEEDED_INT_VALUE, null, ERR_MEM_HANDLER_SEARCH_SIZE_LIMIT_EXCEEDED.get(), null), responseControls);
}
final Entry trimmedEntry = parer.pareEntry(e);
if (request.typesOnly()) {
final Entry typesOnlyEntry = new Entry(trimmedEntry.getDN(), schema);
for (final Attribute a : trimmedEntry.getAttributes()) {
typesOnlyEntry.addAttribute(new Attribute(a.getName()));
}
entryList.add(new SearchResultEntry(typesOnlyEntry));
} else {
entryList.add(new SearchResultEntry(trimmedEntry));
}
}
return new LDAPMessage(messageID, new SearchResultDoneProtocolOp(ResultCode.SUCCESS_INT_VALUE, null, null, null), responseControls);
}
}
use of com.unboundid.ldap.sdk.controls.ServerSideSortResponseControl in project ldapsdk by pingidentity.
the class InMemoryDirectoryControlsTestCase method testServerSideSortControl.
/**
* Provides test coverage for the server-side sort request control.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testServerSideSortControl() throws Exception {
final InMemoryDirectoryServer ds = getTestDS(true, false);
ds.addEntries(generateOrgUnitEntry("People", "dc=example,dc=com"), generateUserEntry("aaron.asparagus", "ou=People,dc=example,dc=com", "Aaron", "Asparagus", "password"), generateUserEntry("andrea.asparagus", "ou=People,dc=example,dc=com", "Andrea", "Asparagus", "password"), generateUserEntry("barbara.beet", "ou=People,dc=example,dc=com", "Barbara", "Beet", "password"), generateUserEntry("barney.beet", "ou=People,dc=example,dc=com", "Barney", "Beet", "password"), generateUserEntry("carol.cabbage", "ou=People,dc=example,dc=com", "Carol", "Cabbage", "password"), generateUserEntry("charlie.cabbage", "ou=People,dc=example,dc=com", "Charlie", "Cabbage", "password"));
final LDAPConnection conn = ds.getConnection();
// Test without the sort control and verify that no response control is
// returned. Although the order in which entries are returned will be
// predictable (based on DN ordering), we don't really care about that.
final SearchRequest searchRequest = new SearchRequest("dc=example,dc=com", SearchScope.SUB, "(objectClass=person)");
SearchResult searchResult = conn.search(searchRequest);
assertEquals(searchResult.getResultCode(), ResultCode.SUCCESS);
assertEquals(searchResult.getEntryCount(), 6);
assertNotNull(searchResult.getSearchEntries());
assertEquals(searchResult.getSearchEntries().size(), 6);
assertFalse(searchResult.hasResponseControl(ServerSideSortResponseControl.SERVER_SIDE_SORT_RESPONSE_OID));
// Test with a sort control that will sort first based on last name
// (ascending), then based on first name (ascending).
searchRequest.setControls(new ServerSideSortRequestControl(true, new SortKey("sn"), new SortKey("givenName")));
searchResult = conn.search(searchRequest);
assertEquals(searchResult.getResultCode(), ResultCode.SUCCESS);
assertEquals(searchResult.getEntryCount(), 6);
ServerSideSortResponseControl sortResponse = ServerSideSortResponseControl.get(searchResult);
assertNotNull(sortResponse);
assertEquals(sortResponse.getResultCode(), ResultCode.SUCCESS);
assertNull(sortResponse.getAttributeName());
List<SearchResultEntry> entryList = searchResult.getSearchEntries();
assertNotNull(entryList);
assertEquals(entryList.size(), 6);
assertEquals(entryList.get(0).getParsedDN(), new DN("uid=aaron.asparagus,ou=People,dc=example,dc=com"));
assertEquals(entryList.get(1).getParsedDN(), new DN("uid=andrea.asparagus,ou=People,dc=example,dc=com"));
assertEquals(entryList.get(2).getParsedDN(), new DN("uid=barbara.beet,ou=People,dc=example,dc=com"));
assertEquals(entryList.get(3).getParsedDN(), new DN("uid=barney.beet,ou=People,dc=example,dc=com"));
assertEquals(entryList.get(4).getParsedDN(), new DN("uid=carol.cabbage,ou=People,dc=example,dc=com"));
assertEquals(entryList.get(5).getParsedDN(), new DN("uid=charlie.cabbage,ou=People,dc=example,dc=com"));
// Test with a sort control that will sort first based on last name
// (descending), then based on first name (descending).
searchRequest.setControls(new ServerSideSortRequestControl(true, new SortKey("sn", true), new SortKey("givenName", true)));
searchResult = conn.search(searchRequest);
assertEquals(searchResult.getResultCode(), ResultCode.SUCCESS);
assertEquals(searchResult.getEntryCount(), 6);
sortResponse = ServerSideSortResponseControl.get(searchResult);
assertNotNull(sortResponse);
assertEquals(sortResponse.getResultCode(), ResultCode.SUCCESS);
assertNull(sortResponse.getAttributeName());
entryList = searchResult.getSearchEntries();
assertNotNull(entryList);
assertEquals(entryList.size(), 6);
assertEquals(entryList.get(0).getParsedDN(), new DN("uid=charlie.cabbage,ou=People,dc=example,dc=com"));
assertEquals(entryList.get(1).getParsedDN(), new DN("uid=carol.cabbage,ou=People,dc=example,dc=com"));
assertEquals(entryList.get(2).getParsedDN(), new DN("uid=barney.beet,ou=People,dc=example,dc=com"));
assertEquals(entryList.get(3).getParsedDN(), new DN("uid=barbara.beet,ou=People,dc=example,dc=com"));
assertEquals(entryList.get(4).getParsedDN(), new DN("uid=andrea.asparagus,ou=People,dc=example,dc=com"));
assertEquals(entryList.get(5).getParsedDN(), new DN("uid=aaron.asparagus,ou=People,dc=example,dc=com"));
// Test with a sort control that will sort first based on last name
// (ascending), then based on first name (descending).
searchRequest.setControls(new ServerSideSortRequestControl(true, new SortKey("sn", false), new SortKey("givenName", true)));
searchResult = conn.search(searchRequest);
assertEquals(searchResult.getResultCode(), ResultCode.SUCCESS);
assertEquals(searchResult.getEntryCount(), 6);
sortResponse = ServerSideSortResponseControl.get(searchResult);
assertNotNull(sortResponse);
assertEquals(sortResponse.getResultCode(), ResultCode.SUCCESS);
assertNull(sortResponse.getAttributeName());
entryList = searchResult.getSearchEntries();
assertNotNull(entryList);
assertEquals(entryList.size(), 6);
assertEquals(entryList.get(0).getParsedDN(), new DN("uid=andrea.asparagus,ou=People,dc=example,dc=com"));
assertEquals(entryList.get(1).getParsedDN(), new DN("uid=aaron.asparagus,ou=People,dc=example,dc=com"));
assertEquals(entryList.get(2).getParsedDN(), new DN("uid=barney.beet,ou=People,dc=example,dc=com"));
assertEquals(entryList.get(3).getParsedDN(), new DN("uid=barbara.beet,ou=People,dc=example,dc=com"));
assertEquals(entryList.get(4).getParsedDN(), new DN("uid=charlie.cabbage,ou=People,dc=example,dc=com"));
assertEquals(entryList.get(5).getParsedDN(), new DN("uid=carol.cabbage,ou=People,dc=example,dc=com"));
conn.close();
}
use of com.unboundid.ldap.sdk.controls.ServerSideSortResponseControl in project ldapsdk by pingidentity.
the class ResultUtilsTestCase method getFormatResponseControlData.
/**
* Retrieves a set of data for testing the {@code formatResponseControl}
* method.
*
* @return The test data.
*
* @throws Exception If an unexpected problem occurs.
*/
@DataProvider(name = "formatResponseControlData")
public Iterator<Object[]> getFormatResponseControlData() throws Exception {
final LinkedList<Object[]> resultList = new LinkedList<Object[]>();
// A generic response control with no value.
resultList.add(new Object[] { new Control("1.2.3.4"), Arrays.asList("# Response Control:", "# OID: 1.2.3.4", "# Is Critical: false") });
// A generic response control with a value.
resultList.add(new Object[] { new Control("1.2.3.4", true, new ASN1OctetString("control value")), Arrays.asList("# Response Control:", "# OID: 1.2.3.4", "# Is Critical: true", "# Raw Value:", "# 63 6f 6e 74 72 6f 6c 20 76 61 6c 75 " + "65 control value") });
// A valid authorization identity response control.
resultList.add(new Object[] { new AuthorizationIdentityResponseControl("u:test.user"), Arrays.asList("# Authorization Identity Response Control:", "# OID: " + AuthorizationIdentityResponseControl.AUTHORIZATION_IDENTITY_RESPONSE_OID, "# Authorization ID: u:test.user") });
// An invalid authorization identity response control.
resultList.add(new Object[] { new Control(AuthorizationIdentityResponseControl.AUTHORIZATION_IDENTITY_RESPONSE_OID), Arrays.asList("# Response Control:", "# OID: " + AuthorizationIdentityResponseControl.AUTHORIZATION_IDENTITY_RESPONSE_OID, "# Is Critical: false") });
// A valid content synchronization done response control.
resultList.add(new Object[] { new ContentSyncDoneControl(new ASN1OctetString("cookie"), true), Arrays.asList("# Content Synchronization Done Response Control:", "# OID: " + ContentSyncDoneControl.SYNC_DONE_OID, "# Refresh Deletes: true", "# Cookie Data:", "# 63 6f 6f 6b 69 " + "65 cookie") });
// An invalid content synchronization done response control.
resultList.add(new Object[] { new Control(ContentSyncDoneControl.SYNC_DONE_OID), Arrays.asList("# Response Control:", "# OID: " + ContentSyncDoneControl.SYNC_DONE_OID, "# Is Critical: false") });
// A valid content synchronization state response control.
final UUID uuid = CryptoHelper.getRandomUUID();
resultList.add(new Object[] { new ContentSyncStateControl(ContentSyncState.MODIFY, uuid, new ASN1OctetString("cookie")), Arrays.asList("# Content Synchronization State Response Control:", "# OID: " + ContentSyncStateControl.SYNC_STATE_OID, "# Entry UUID: " + uuid.toString(), "# Synchronization State: MODIFY", "# Cookie Data:", "# 63 6f 6f 6b 69 " + "65 cookie") });
// An invalid content synchronization state response control.
resultList.add(new Object[] { new Control(ContentSyncStateControl.SYNC_STATE_OID), Arrays.asList("# Response Control:", "# OID: " + ContentSyncStateControl.SYNC_STATE_OID, "# Is Critical: false") });
// A valid entry change notification control.
resultList.add(new Object[] { new EntryChangeNotificationControl(PersistentSearchChangeType.MODIFY_DN, "ou=People,dc=example,dc=com", 123456789L), Arrays.asList("# Entry Change Notification Control:", "# OID: " + EntryChangeNotificationControl.ENTRY_CHANGE_NOTIFICATION_OID, "# Change Type: moddn", "# Change Number: 123456789", "# Previous DN: ou=People,dc=example,dc=com") });
// An invalid entry change notification control.
resultList.add(new Object[] { new Control(EntryChangeNotificationControl.ENTRY_CHANGE_NOTIFICATION_OID), Arrays.asList("# Response Control:", "# OID: " + EntryChangeNotificationControl.ENTRY_CHANGE_NOTIFICATION_OID, "# Is Critical: false") });
// A valid password expired control.
resultList.add(new Object[] { new PasswordExpiredControl(), Arrays.asList("# Password Expired Response Control:", "# OID: " + PasswordExpiredControl.PASSWORD_EXPIRED_OID) });
// An invalid password expired control.
resultList.add(new Object[] { new Control(PasswordExpiredControl.PASSWORD_EXPIRED_OID, false, new ASN1OctetString("control value")), Arrays.asList("# Response Control:", "# OID: " + PasswordExpiredControl.PASSWORD_EXPIRED_OID, "# Is Critical: false", "# Raw Value:", "# 63 6f 6e 74 72 6f 6c 20 76 61 6c 75 " + "65 control value") });
// A valid password expiring control.
resultList.add(new Object[] { new PasswordExpiringControl(12345), Arrays.asList("# Password Expiring Response Control:", "# OID: " + PasswordExpiringControl.PASSWORD_EXPIRING_OID, "# Seconds Until Expiration: 12345") });
// An invalid password expiring control.
resultList.add(new Object[] { new Control(PasswordExpiringControl.PASSWORD_EXPIRING_OID), Arrays.asList("# Response Control:", "# OID: " + PasswordExpiringControl.PASSWORD_EXPIRING_OID, "# Is Critical: false") });
// A valid post-read response control.
resultList.add(new Object[] { new PostReadResponseControl(new ReadOnlyEntry("dn: dc=example,dc=com", "objectClass: top", "objectClass: domain", "dc: example")), Arrays.asList("# Post-Read Response Control:", "# OID: " + PostReadResponseControl.POST_READ_RESPONSE_OID, "# Post-Read Entry:", "# dn: dc=example,dc=com", "# objectClass: top", "# objectClass: domain", "# dc: example") });
// An invalid post-read response control.
resultList.add(new Object[] { new Control(PostReadResponseControl.POST_READ_RESPONSE_OID), Arrays.asList("# Response Control:", "# OID: " + PostReadResponseControl.POST_READ_RESPONSE_OID, "# Is Critical: false") });
// A valid pre-read response control.
resultList.add(new Object[] { new PreReadResponseControl(new ReadOnlyEntry("dn: dc=example,dc=com", "objectClass: top", "objectClass: domain", "dc: example")), Arrays.asList("# Pre-Read Response Control:", "# OID: " + PreReadResponseControl.PRE_READ_RESPONSE_OID, "# Pre-Read Entry:", "# dn: dc=example,dc=com", "# objectClass: top", "# objectClass: domain", "# dc: example") });
// An invalid pre-read response control.
resultList.add(new Object[] { new Control(PreReadResponseControl.PRE_READ_RESPONSE_OID), Arrays.asList("# Response Control:", "# OID: " + PreReadResponseControl.PRE_READ_RESPONSE_OID, "# Is Critical: false") });
// A valid server-side sort response control.
resultList.add(new Object[] { new ServerSideSortResponseControl(ResultCode.INVALID_ATTRIBUTE_SYNTAX, "objectClass", false), Arrays.asList("# Server-Side Sort Response Control:", "# OID: " + ServerSideSortResponseControl.SERVER_SIDE_SORT_RESPONSE_OID, "# Result Code: 21 (invalid attribute syntax)", "# Attribute Name: objectClass") });
// An invalid server-side sort response control.
resultList.add(new Object[] { new Control(ServerSideSortResponseControl.SERVER_SIDE_SORT_RESPONSE_OID), Arrays.asList("# Response Control:", "# OID: " + ServerSideSortResponseControl.SERVER_SIDE_SORT_RESPONSE_OID, "# Is Critical: false") });
// A valid simple paged results response control.
resultList.add(new Object[] { new SimplePagedResultsControl(12345, new ASN1OctetString("cookie")), Arrays.asList("# Simple Paged Results Response Control:", "# OID: " + SimplePagedResultsControl.PAGED_RESULTS_OID, "# Estimated Total Result Set Size: 12345", "# Cookie Data:", "# 63 6f 6f 6b 69 " + "65 cookie") });
// An invalid simple paged results response control.
resultList.add(new Object[] { new Control(SimplePagedResultsControl.PAGED_RESULTS_OID), Arrays.asList("# Response Control:", "# OID: " + SimplePagedResultsControl.PAGED_RESULTS_OID, "# Is Critical: false") });
// A valid virtual list view response control.
resultList.add(new Object[] { new VirtualListViewResponseControl(12345, 67890, ResultCode.SUCCESS, new ASN1OctetString("cookie")), Arrays.asList("# Virtual List View Response Control:", "# OID: " + VirtualListViewResponseControl.VIRTUAL_LIST_VIEW_RESPONSE_OID, "# Result Code: 0 (success)", "# Estimated Content Count: 67890", "# Target Position: 12345", "# Context ID:", "# 63 6f 6f 6b 69 " + "65 cookie") });
// An invalid virtual list view response control.
resultList.add(new Object[] { new Control(VirtualListViewResponseControl.VIRTUAL_LIST_VIEW_RESPONSE_OID), Arrays.asList("# Response Control:", "# OID: " + VirtualListViewResponseControl.VIRTUAL_LIST_VIEW_RESPONSE_OID, "# Is Critical: false") });
// A valid account usable response control that indicates the account is
// usable.
resultList.add(new Object[] { new AccountUsableResponseControl(12345), Arrays.asList("# Account Usable Response Control:", "# OID: " + AccountUsableResponseControl.ACCOUNT_USABLE_RESPONSE_OID, "# Account Is Usable: true", "# Password Is Expired: false", "# Must Change Password: false", "# Account Is Inactive: false", "# Seconds Until Password Expiration: 12345") });
// A valid account usable response control that indicates the account is not
// usable.
resultList.add(new Object[] { new AccountUsableResponseControl(true, true, true, 12345, 67890), Arrays.asList("# Account Usable Response Control:", "# OID: " + AccountUsableResponseControl.ACCOUNT_USABLE_RESPONSE_OID, "# Account Is Usable: false", "# Unusable Reasons:", "# The account has been locked or deactivated.", "# The password must be changed before any " + "other operations will be allowed.", "# The password is expired.", "# 12345 grace logins are available.", "# The account will be automatically unlocked " + "in 67890 seconds.", "# Password Is Expired: true", "# Must Change Password: true", "# Account Is Inactive: true", "# Remaining Grace Logins: 12345", "# Seconds Until Account Unlock: 67890") });
// An invalid account usable response control.
resultList.add(new Object[] { new Control(AccountUsableResponseControl.ACCOUNT_USABLE_RESPONSE_OID), Arrays.asList("# Response Control:", "# OID: " + AccountUsableResponseControl.ACCOUNT_USABLE_RESPONSE_OID, "# Is Critical: false") });
// A valid assured replication response control that indicates the account
// is usable.
resultList.add(new Object[] { new AssuredReplicationResponseControl(AssuredReplicationLocalLevel.PROCESSED_ALL_SERVERS, true, "local message", AssuredReplicationRemoteLevel.RECEIVED_ANY_REMOTE_LOCATION, false, "remote message", "csn", Arrays.asList(new AssuredReplicationServerResult(AssuredReplicationServerResultCode.COMPLETE, (short) 12345, (short) 12346), new AssuredReplicationServerResult(AssuredReplicationServerResultCode.TIMEOUT, (short) 12347, (short) 12348))), Arrays.asList("# Assured Replication Response Control:", "# OID: " + AssuredReplicationResponseControl.ASSURED_REPLICATION_RESPONSE_OID, "# Change Sequence Number: csn", "# Local Assurance Level: PROCESSED_ALL_SERVERS", "# Local Assurance Satisfied: true", "# Local Assurance Message: local message", "# Remote Assurance Level: " + "RECEIVED_ANY_REMOTE_LOCATION", "# Remote Assurance Satisfied: false", "# Remote Assurance Message: remote message", "# Server Result:", "# Server Result Code: COMPLETE", "# Replication Server ID: 12345", "# Replica ID: 12346", "# Server Result:", "# Server Result Code: TIMEOUT", "# Replication Server ID: 12347", "# Replica ID: 12348") });
// An invalid assured replication response control.
resultList.add(new Object[] { new Control(AssuredReplicationResponseControl.ASSURED_REPLICATION_RESPONSE_OID), Arrays.asList("# Response Control:", "# OID: " + AssuredReplicationResponseControl.ASSURED_REPLICATION_RESPONSE_OID, "# Is Critical: false") });
// A valid generate password response control without a password expiration
// time.
resultList.add(new Object[] { new GeneratePasswordResponseControl("generated-password", false, (Long) null), Arrays.asList("# Generate Password Response Control:", "# OID: " + GeneratePasswordResponseControl.GENERATE_PASSWORD_RESPONSE_OID, "# Generated Password: generated-password", "# Must Change Password: false") });
// A valid generate password response control with a password expiration
// time.
resultList.add(new Object[] { new GeneratePasswordResponseControl("generated-password", true, 86400L), Arrays.asList("# Generate Password Response Control:", "# OID: " + GeneratePasswordResponseControl.GENERATE_PASSWORD_RESPONSE_OID, "# Generated Password: generated-password", "# Must Change Password: true", "# Seconds Until Expiration: 86400") });
// An invalid generate password response control.
resultList.add(new Object[] { new Control(GeneratePasswordResponseControl.GENERATE_PASSWORD_RESPONSE_OID), Arrays.asList("# Response Control:", "# OID: " + GeneratePasswordResponseControl.GENERATE_PASSWORD_RESPONSE_OID, "# Is Critical: false") });
// A valid get authorization entry response control for an unauthenticated
// connection.
resultList.add(new Object[] { new GetAuthorizationEntryResponseControl(false, true, "dn:", null, null, null), Arrays.asList("# Get Authorization Entry Response Control:", "# OID: " + GetAuthorizationEntryResponseControl.GET_AUTHORIZATION_ENTRY_RESPONSE_OID, "# Is Authenticated: false") });
// A valid get authorization entry response control for an authenticated
// connection in which the authentication and authorization identities
// match.
resultList.add(new Object[] { new GetAuthorizationEntryResponseControl(true, true, "u:test.user", new ReadOnlyEntry("dn: uid=test.user,ou=People,dc=example,dc=com", "objectClass: top", "objectClass: person", "objectClass: organizationalPerson", "objectClass: inetOrgPerson", "uid: test.user", "givenName: Test", "sn: User", "cn: Test User"), null, null), Arrays.asList("# Get Authorization Entry Response Control:", "# OID: " + GetAuthorizationEntryResponseControl.GET_AUTHORIZATION_ENTRY_RESPONSE_OID, "# Is Authenticated: true", "# Authentication and Authorization Identities " + "Match: true", "# Authentication Identity ID: u:test.user", "# Authentication Identity Entry:", "# dn: uid=test.user,ou=People,dc=example," + "dc=com", "# objectClass: top", "# objectClass: person", "# objectClass: organizationalPerson", "# objectClass: inetOrgPerson", "# uid: test.user", "# givenName: Test", "# sn: User", "# cn: Test User") });
// A valid get authorization entry response control for an authenticated
// connection in which the authentication and authorization identities
// differ.
resultList.add(new Object[] { new GetAuthorizationEntryResponseControl(true, false, "u:test.user", new ReadOnlyEntry("dn: uid=test.user,ou=People,dc=example,dc=com", "objectClass: top", "objectClass: person", "objectClass: organizationalPerson", "objectClass: inetOrgPerson", "uid: test.user", "givenName: Test", "sn: User", "cn: Test User"), "u:another.user", new ReadOnlyEntry("dn: uid=another.user,ou=People,dc=example,dc=com", "objectClass: top", "objectClass: person", "objectClass: organizationalPerson", "objectClass: inetOrgPerson", "uid: another.user", "givenName: Another", "sn: User", "cn: Another User")), Arrays.asList("# Get Authorization Entry Response Control:", "# OID: " + GetAuthorizationEntryResponseControl.GET_AUTHORIZATION_ENTRY_RESPONSE_OID, "# Is Authenticated: true", "# Authentication and Authorization Identities " + "Match: false", "# Authentication Identity ID: u:test.user", "# Authentication Identity Entry:", "# dn: uid=test.user,ou=People,dc=example," + "dc=com", "# objectClass: top", "# objectClass: person", "# objectClass: organizationalPerson", "# objectClass: inetOrgPerson", "# uid: test.user", "# givenName: Test", "# sn: User", "# cn: Test User", "# Authorization Identity ID: u:another.user", "# Authorization Identity Entry:", "# dn: uid=another.user,ou=People,dc=example," + "dc=com", "# objectClass: top", "# objectClass: person", "# objectClass: organizationalPerson", "# objectClass: inetOrgPerson", "# uid: another.user", "# givenName: Another", "# sn: User", "# cn: Another User") });
// An invalid get authorization identity response control.
resultList.add(new Object[] { new Control(GetAuthorizationEntryResponseControl.GET_AUTHORIZATION_ENTRY_RESPONSE_OID), Arrays.asList("# Response Control:", "# OID: " + GetAuthorizationEntryResponseControl.GET_AUTHORIZATION_ENTRY_RESPONSE_OID, "# Is Critical: false") });
// A valid get backend set ID response control with a single backend set ID.
resultList.add(new Object[] { new GetBackendSetIDResponseControl("rpID", "bsID"), Arrays.asList("# Get Backend Set ID Response Control:", "# OID: " + GetBackendSetIDResponseControl.GET_BACKEND_SET_ID_RESPONSE_OID, "# Entry-Balancing Request Processor ID: rpID", "# Backend Set ID: bsID") });
// A valid get backend set ID response control with multiple backend set
// IDs.
resultList.add(new Object[] { new GetBackendSetIDResponseControl("rpID", Arrays.asList("bs1", "bs2")), Arrays.asList("# Get Backend Set ID Response Control:", "# OID: " + GetBackendSetIDResponseControl.GET_BACKEND_SET_ID_RESPONSE_OID, "# Entry-Balancing Request Processor ID: rpID", "# Backend Set ID: bs1", "# Backend Set ID: bs2") });
// An invalid get backend set ID response control.
resultList.add(new Object[] { new Control(GetBackendSetIDResponseControl.GET_BACKEND_SET_ID_RESPONSE_OID), Arrays.asList("# Response Control:", "# OID: " + GetBackendSetIDResponseControl.GET_BACKEND_SET_ID_RESPONSE_OID, "# Is Critical: false") });
// A valid get password policy state issues response control without any
// issues.
resultList.add(new Object[] { new GetPasswordPolicyStateIssuesResponseControl(null, null, null), Arrays.asList("# Get Password Policy State Issues Response Control:", "# OID: " + GetPasswordPolicyStateIssuesResponseControl.GET_PASSWORD_POLICY_STATE_ISSUES_RESPONSE_OID) });
// A valid get password policy state issues response control with multiple
// notices, warnings, and errors, and an authentication failure reason
resultList.add(new Object[] { new GetPasswordPolicyStateIssuesResponseControl(Arrays.asList(new PasswordPolicyStateAccountUsabilityNotice(PasswordPolicyStateAccountUsabilityNotice.NOTICE_TYPE_IN_MINIMUM_PASSWORD_AGE, PasswordPolicyStateAccountUsabilityNotice.NOTICE_NAME_IN_MINIMUM_PASSWORD_AGE, "You can't change your password yet"), new PasswordPolicyStateAccountUsabilityNotice(PasswordPolicyStateAccountUsabilityNotice.NOTICE_TYPE_OUTSTANDING_RETIRED_PASSWORD, PasswordPolicyStateAccountUsabilityNotice.NOTICE_NAME_OUTSTANDING_RETIRED_PASSWORD, "You have a valid retired password")), Arrays.asList(new PasswordPolicyStateAccountUsabilityWarning(PasswordPolicyStateAccountUsabilityWarning.WARNING_TYPE_ACCOUNT_EXPIRING, PasswordPolicyStateAccountUsabilityWarning.WARNING_NAME_ACCOUNT_EXPIRING, "Your account will expire soon"), new PasswordPolicyStateAccountUsabilityWarning(PasswordPolicyStateAccountUsabilityWarning.WARNING_TYPE_PASSWORD_EXPIRING, PasswordPolicyStateAccountUsabilityWarning.WARNING_NAME_PASSWORD_EXPIRING, "Your password will expire soon")), Arrays.asList(new PasswordPolicyStateAccountUsabilityError(PasswordPolicyStateAccountUsabilityError.ERROR_TYPE_ACCOUNT_DISABLED, PasswordPolicyStateAccountUsabilityError.ERROR_NAME_ACCOUNT_DISABLED, "Your account is disabled"), new PasswordPolicyStateAccountUsabilityError(PasswordPolicyStateAccountUsabilityError.ERROR_TYPE_ACCOUNT_EXPIRED, PasswordPolicyStateAccountUsabilityError.ERROR_NAME_ACCOUNT_EXPIRED, "Your account is expired")), new AuthenticationFailureReason(AuthenticationFailureReason.FAILURE_TYPE_ACCOUNT_NOT_USABLE, AuthenticationFailureReason.FAILURE_NAME_ACCOUNT_NOT_USABLE, "Your account is not usable")), Arrays.asList("# Get Password Policy State Issues Response Control:", "# OID: " + GetPasswordPolicyStateIssuesResponseControl.GET_PASSWORD_POLICY_STATE_ISSUES_RESPONSE_OID, "# Authentication Failure Reason:", "# Failure Type: account-not-usable", "# Failure Message: Your account is not usable", "# Account Usability Error:", "# Error Name: account-disabled", "# Error Message: Your account is disabled", "# Account Usability Error:", "# Error Name: account-expired", "# Error Message: Your account is expired", "# Account Usability Warning:", "# Warning Name: account-expiring", "# Warning Message: Your account will expire " + "soon", "# Account Usability Warning:", "# Warning Name: password-expiring", "# Warning Message: Your password will " + "expire soon", "# Account Usability Notice:", "# Notice Name: in-minimum-password-age", "# Notice Message: You can't change your " + "password yet", "# Account Usability Notice:", "# Notice Name: outstanding-retired-password", "# Notice Message: You have a valid retired " + "password") });
// An invalid get password policy state issues response control.
resultList.add(new Object[] { new Control(GetPasswordPolicyStateIssuesResponseControl.GET_PASSWORD_POLICY_STATE_ISSUES_RESPONSE_OID), Arrays.asList("# Response Control:", "# OID: " + GetPasswordPolicyStateIssuesResponseControl.GET_PASSWORD_POLICY_STATE_ISSUES_RESPONSE_OID, "# Is Critical: false") });
// A valid get recent login history response control without any successful
// or failed attempts.
resultList.add(new Object[] { new GetRecentLoginHistoryResponseControl(new RecentLoginHistory(null, null)), Arrays.asList("# Get Recent Login History Response Control:", "# OID: " + GetRecentLoginHistoryResponseControl.GET_RECENT_LOGIN_HISTORY_RESPONSE_OID, "# No Successful Attempts", "# No Failed Attempts") });
// A valid get recent login history response control with both successful
// and failed attempts.
final long currentTime = System.currentTimeMillis();
final TreeSet<RecentLoginHistoryAttempt> successes = new TreeSet<>();
successes.add(new RecentLoginHistoryAttempt(true, currentTime, "simple", "1.2.3.4", null, 0L));
final TreeSet<RecentLoginHistoryAttempt> failures = new TreeSet<>();
failures.add(new RecentLoginHistoryAttempt(false, (currentTime - 5_000L), "simple", "1.2.3.4", "invalid-credentials", 1L));
RecentLoginHistory recentLoginHistory = new RecentLoginHistory(successes, failures);
resultList.add(new Object[] { new GetRecentLoginHistoryResponseControl(recentLoginHistory), Arrays.asList("# Get Recent Login History Response Control:", "# OID: " + GetRecentLoginHistoryResponseControl.GET_RECENT_LOGIN_HISTORY_RESPONSE_OID, "# Successful Attempt:", "# Timestamp: " + StaticUtils.encodeRFC3339Time(currentTime), "# Authentication Method: simple", "# Client IP Address: 1.2.3.4", "# Additional Attempt Count: 0", "# Failed Attempt:", "# Timestamp: " + StaticUtils.encodeRFC3339Time(currentTime - 5_000L), "# Authentication Method: simple", "# Client IP Address: 1.2.3.4", "# Failure Reason: invalid-credentials", "# Additional Attempt Count: 1") });
// An invalid recent login history response control.
resultList.add(new Object[] { new Control(GetRecentLoginHistoryResponseControl.GET_RECENT_LOGIN_HISTORY_RESPONSE_OID), Arrays.asList("# Response Control:", "# OID: " + GetRecentLoginHistoryResponseControl.GET_RECENT_LOGIN_HISTORY_RESPONSE_OID, "# Is Critical: false") });
// A valid get server ID response control.
resultList.add(new Object[] { new GetServerIDResponseControl("serverID"), Arrays.asList("# Get Server ID Response Control:", "# OID: " + GetServerIDResponseControl.GET_SERVER_ID_RESPONSE_OID, "# Server ID: serverID") });
// An invalid get server ID response control.
resultList.add(new Object[] { new Control(GetServerIDResponseControl.GET_SERVER_ID_RESPONSE_OID), Arrays.asList("# Response Control:", "# OID: " + GetServerIDResponseControl.GET_SERVER_ID_RESPONSE_OID, "# Is Critical: false") });
// A valid get user resource limits response control with a minimal set of
// fields and unlimited values where possible.
resultList.add(new Object[] { new GetUserResourceLimitsResponseControl(0L, 0L, 0L, 0L, null, null), Arrays.asList("# Get User Resource Limits Response Control:", "# OID: " + GetUserResourceLimitsResponseControl.GET_USER_RESOURCE_LIMITS_RESPONSE_OID, "# Size Limit: Unlimited", "# Time Limit: Unlimited", "# Idle Time Limit: Unlimited", "# Lookthrough Limit: Unlimited") });
// A valid get user resource limits response control with all fields and
// definite limits.
resultList.add(new Object[] { new GetUserResourceLimitsResponseControl(12345L, 67890L, 98765L, 54321L, "uid=equivalent.user,ou=People,dc=example,dc=com", "CCP", Arrays.asList("cn=Group 1,ou=Groups,dc=example,dc=com", "cn=Group 2,ou=Groups,dc=example,dc=com"), Arrays.asList("bypass-read-acl", "config-read"), Arrays.asList(new Attribute("other-attr-1", "value1"), new Attribute("other-attr-2", "value2"))), Arrays.asList("# Get User Resource Limits Response Control:", "# OID: " + GetUserResourceLimitsResponseControl.GET_USER_RESOURCE_LIMITS_RESPONSE_OID, "# Size Limit: 12345", "# Time Limit: 67890 seconds", "# Idle Time Limit: 98765 seconds", "# Lookthrough Limit: 54321", "# Equivalent Authorization User DN: " + "uid=equivalent.user,ou=People,dc=example,dc=com", "# Client Connection Policy Name: CCP", "# Group DNs:", "# cn=Group 1,ou=Groups,dc=example,dc=com", "# cn=Group 2,ou=Groups,dc=example,dc=com", "# Privileges:", "# bypass-read-acl", "# config-read", "# Other Attributes:", "# other-attr-1: value1", "# other-attr-2: value2") });
// An invalid get user resource limits response control.
resultList.add(new Object[] { new Control(GetUserResourceLimitsResponseControl.GET_USER_RESOURCE_LIMITS_RESPONSE_OID), Arrays.asList("# Response Control:", "# OID: " + GetUserResourceLimitsResponseControl.GET_USER_RESOURCE_LIMITS_RESPONSE_OID, "# Is Critical: false") });
// A valid intermediate client response control.
resultList.add(new Object[] { new IntermediateClientResponseControl(new IntermediateClientResponseValue(new IntermediateClientResponseValue(null, "upstream.server.address", false, "upstreamServerName", "upstreamSessionID", "upstreamResponseID"), "intermediate.server.address", true, "intermediateServerName", "intermediateSessionID", "intermediateResponseID")), Arrays.asList("# Intermediate Client Response Control:", "# OID: " + IntermediateClientResponseControl.INTERMEDIATE_CLIENT_RESPONSE_OID, "# Upstream Server Address: " + "intermediate.server.address", "# Upstream Server Secure: true", "# Server Name: intermediateServerName", "# Server Session ID: intermediateSessionID", "# Server Response ID: intermediateResponseID", "# Upstream Response:", "# Upstream Server Address: " + "upstream.server.address", "# Upstream Server Secure: false", "# Server Name: upstreamServerName", "# Server Session ID: upstreamSessionID", "# Server Response ID: upstreamResponseID") });
// An invalid intermediate client response control.
resultList.add(new Object[] { new Control(IntermediateClientResponseControl.INTERMEDIATE_CLIENT_RESPONSE_OID), Arrays.asList("# Response Control:", "# OID: " + IntermediateClientResponseControl.INTERMEDIATE_CLIENT_RESPONSE_OID, "# Is Critical: false") });
// A valid join result control.
resultList.add(new Object[] { new JoinResultControl(ResultCode.SUCCESS, "diag", "dc=example,dc=com", Arrays.asList("ldap://ds1.example.com:389/dc=example,dc=com", "ldap://ds2.example.com:389/dc=example,dc=com"), Arrays.asList(new JoinedEntry(new ReadOnlyEntry("dn: ou=joined 1,dc=example,dc=com", "objectClass: top", "objectClass: organizationalUnit", "ou: joined 1"), Arrays.asList(new JoinedEntry(new ReadOnlyEntry("dn: ou=joined 1a,dc=example,dc=com", "objectClass: top", "objectClass: organizationalUnit", "ou: joined 1a"), null), new JoinedEntry(new ReadOnlyEntry("dn: ou=joined 1b,dc=example,dc=com", "objectClass: top", "objectClass: organizationalUnit", "ou: joined 1b"), null))), new JoinedEntry(new ReadOnlyEntry("dn: ou=joined 2,dc=example,dc=com", "objectClass: top", "objectClass: organizationalUnit", "ou: joined 2"), Arrays.asList(new JoinedEntry(new ReadOnlyEntry("dn: ou=joined 2a,dc=example,dc=com", "objectClass: top", "objectClass: organizationalUnit", "ou: joined 2a"), null), new JoinedEntry(new ReadOnlyEntry("dn: ou=joined 2b,dc=example,dc=com", "objectClass: top", "objectClass: organizationalUnit", "ou: joined 2b"), null))))), Arrays.asList("# Join Result Control:", "# OID: " + JoinResultControl.JOIN_RESULT_OID, "# Join Result Code: 0 (success)", "# Join Diagnostic Message: diag", "# Join Matched DN: dc=example,dc=com", "# Join Referral URL: " + "ldap://ds1.example.com:389/dc=example,dc=com", "# Join Referral URL: " + "ldap://ds2.example.com:389/dc=example,dc=com", "# Joined With Entry:", "# dn: ou=joined 1,dc=example,dc=com", "# objectClass: top", "# objectClass: organizationalUnit", "# ou: joined 1", "# Joined With Entry:", "# dn: ou=joined 1a,dc=example,dc=com", "# objectClass: top", "# objectClass: organizationalUnit", "# ou: joined 1a", "# Joined With Entry:", "# dn: ou=joined 1b,dc=example,dc=com", "# objectClass: top", "# objectClass: organizationalUnit", "# ou: joined 1b", "# Joined With Entry:", "# dn: ou=joined 2,dc=example,dc=com", "# objectClass: top", "# objectClass: organizationalUnit", "# ou: joined 2", "# Joined With Entry:", "# dn: ou=joined 2a,dc=example,dc=com", "# objectClass: top", "# objectClass: organizationalUnit", "# ou: joined 2a", "# Joined With Entry:", "# dn: ou=joined 2b,dc=example,dc=com", "# objectClass: top", "# objectClass: organizationalUnit", "# ou: joined 2b") });
// An invalid join result control.
resultList.add(new Object[] { new Control(JoinResultControl.JOIN_RESULT_OID), Arrays.asList("# Response Control:", "# OID: " + JoinResultControl.JOIN_RESULT_OID, "# Is Critical: false") });
// A valid matching entry count response control for an examined count.
resultList.add(new Object[] { MatchingEntryCountResponseControl.createExactCountResponse(12345, true, true, true, false, true, Filter.createEqualityFilter("objectClass", "person"), Arrays.asList("debug message 1", "debug message 2")), Arrays.asList("# Matching Entry Count Response Control:", "# OID: " + MatchingEntryCountResponseControl.MATCHING_ENTRY_COUNT_RESPONSE_OID, "# Count Type: Examined", "# Count Value: 12345", "# Search Is Indexed: true", "# Short Circuited: true", "# Fully Indexed: false", "# Candidates Are in Scope: true", "# Remaining Filter: (objectClass=person)", "# Debug Info:", "# debug message 1", "# debug message 2") });
// A valid matching entry count response control for an unexamined count.
resultList.add(new Object[] { MatchingEntryCountResponseControl.createExactCountResponse(67890, false, true, Arrays.asList("debug message 1", "debug message 2")), Arrays.asList("# Matching Entry Count Response Control:", "# OID: " + MatchingEntryCountResponseControl.MATCHING_ENTRY_COUNT_RESPONSE_OID, "# Count Type: Unexamined", "# Count Value: 67890", "# Search Is Indexed: true", "# Debug Info:", "# debug message 1", "# debug message 2") });
// A valid matching entry count response control for an upper bound count.
resultList.add(new Object[] { MatchingEntryCountResponseControl.createUpperBoundResponse(98765, false, Arrays.asList("debug message 1", "debug message 2")), Arrays.asList("# Matching Entry Count Response Control:", "# OID: " + MatchingEntryCountResponseControl.MATCHING_ENTRY_COUNT_RESPONSE_OID, "# Count Type: Upper Bound", "# Count Value: 98765", "# Search Is Indexed: false", "# Debug Info:", "# debug message 1", "# debug message 2") });
// A valid matching entry count response control for an unknown count.
resultList.add(new Object[] { MatchingEntryCountResponseControl.createUnknownCountResponse(Arrays.asList("debug message 1", "debug message 2")), Arrays.asList("# Matching Entry Count Response Control:", "# OID: " + MatchingEntryCountResponseControl.MATCHING_ENTRY_COUNT_RESPONSE_OID, "# Count Type: Unknown", "# Search Is Indexed: false", "# Debug Info:", "# debug message 1", "# debug message 2") });
// An invalid matching entry count response control.
resultList.add(new Object[] { new Control(MatchingEntryCountResponseControl.MATCHING_ENTRY_COUNT_RESPONSE_OID), Arrays.asList("# Response Control:", "# OID: " + MatchingEntryCountResponseControl.MATCHING_ENTRY_COUNT_RESPONSE_OID, "# Is Critical: false") });
// A valid password policy response control for a password that is about to
// expire.
resultList.add(new Object[] { new PasswordPolicyResponseControl(PasswordPolicyWarningType.TIME_BEFORE_EXPIRATION, 12345, null), Arrays.asList("# Password Policy Response Control:", "# OID: " + PasswordPolicyResponseControl.PASSWORD_POLICY_RESPONSE_OID, "# Error Type: None", "# Warning Type: time before expiration", "# Warning Value: 12345") });
// A valid password policy response control for an account that is locked.
resultList.add(new Object[] { new PasswordPolicyResponseControl(null, -1, PasswordPolicyErrorType.ACCOUNT_LOCKED), Arrays.asList("# Password Policy Response Control:", "# OID: " + PasswordPolicyResponseControl.PASSWORD_POLICY_RESPONSE_OID, "# Error Type: account locked", "# Warning Type: None") });
// An invalid password policy response control.
resultList.add(new Object[] { new Control(PasswordPolicyResponseControl.PASSWORD_POLICY_RESPONSE_OID), Arrays.asList("# Response Control:", "# OID: " + PasswordPolicyResponseControl.PASSWORD_POLICY_RESPONSE_OID, "# Is Critical: false") });
// A valid password validation details response control for a validation
// details response.
final LinkedHashMap<String, String> r1Map = new LinkedHashMap<String, String>(2);
r1Map.put("prop1a", "value1a");
r1Map.put("prop1b", "value1b");
final LinkedHashMap<String, String> r2Map = new LinkedHashMap<String, String>(2);
r2Map.put("prop2a", "value2a");
r2Map.put("prop2b", "value2b");
resultList.add(new Object[] { new PasswordValidationDetailsResponseControl(PasswordValidationDetailsResponseType.VALIDATION_DETAILS, Arrays.asList(new PasswordQualityRequirementValidationResult(new PasswordQualityRequirement("Requirement 1", "first-requirement", r1Map), true, "Requirement 1 was satisfied"), new PasswordQualityRequirementValidationResult(new PasswordQualityRequirement("Requirement 2", "second-requirement", r2Map), false, "Requirement 2 was not satisfied")), false, true, 12345), Arrays.asList("# Password Validation Details Response Control:", "# OID: " + PasswordValidationDetailsResponseControl.PASSWORD_VALIDATION_DETAILS_RESPONSE_OID, "# Result Type: Validation Result", "# Password Quality Requirement Validation " + "Result:", "# Password Quality Requirement " + "Description: Requirement 1", "# Client-Side Validation Type: " + "first-requirement", "# Client-Side Validation Property: " + "prop1a=value1a", "# Client-Side Validation Property: " + "prop1b=value1b", "# Requirement Satisfied: true", "# Additional Validation Info: " + "Requirement 1 was satisfied", "# Password Quality Requirement Validation " + "Result:", "# Password Quality Requirement " + "Description: Requirement 2", "# Client-Side Validation Type: " + "second-requirement", "# Client-Side Validation Property: " + "prop2a=value2a", "# Client-Side Validation Property: " + "prop2b=value2b", "# Requirement Satisfied: false", "# Additional Validation Info: " + "Requirement 2 was not satisfied", "# Missing Current Password: false", "# Must Change Password: true", "# Seconds Until Expiration: 12345") });
// A valid password validation details response control for a "no password
// provided" response.
resultList.add(new Object[] { new PasswordValidationDetailsResponseControl(PasswordValidationDetailsResponseType.NO_PASSWORD_PROVIDED, null, true, false, null), Arrays.asList("# Password Validation Details Response Control:", "# OID: " + PasswordValidationDetailsResponseControl.PASSWORD_VALIDATION_DETAILS_RESPONSE_OID, "# Result Type: No Password Provided", "# Missing Current Password: true", "# Must Change Password: false") });
// A valid password validation details response control for a "multiple
// passwords provided" response.
resultList.add(new Object[] { new PasswordValidationDetailsResponseControl(PasswordValidationDetailsResponseType.MULTIPLE_PASSWORDS_PROVIDED, null, true, false, null), Arrays.asList("# Password Validation Details Response Control:", "# OID: " + PasswordValidationDetailsResponseControl.PASSWORD_VALIDATION_DETAILS_RESPONSE_OID, "# Result Type: Multiple Passwords Provided", "# Missing Current Password: true", "# Must Change Password: false") });
// A valid password validation details response control for a "no validation
// attempted" response.
resultList.add(new Object[] { new PasswordValidationDetailsResponseControl(PasswordValidationDetailsResponseType.NO_VALIDATION_ATTEMPTED, null, true, false, null), Arrays.asList("# Password Validation Details Response Control:", "# OID: " + PasswordValidationDetailsResponseControl.PASSWORD_VALIDATION_DETAILS_RESPONSE_OID, "# Result Type: No Validation Attempted", "# Missing Current Password: true", "# Must Change Password: false") });
// An invalid password validation details response control.
resultList.add(new Object[] { new Control(PasswordValidationDetailsResponseControl.PASSWORD_VALIDATION_DETAILS_RESPONSE_OID), Arrays.asList("# Response Control:", "# OID: " + PasswordValidationDetailsResponseControl.PASSWORD_VALIDATION_DETAILS_RESPONSE_OID, "# Is Critical: false") });
// A valid soft delete response control.
resultList.add(new Object[] { new SoftDeleteResponseControl("ou=test+entryUUID=" + uuid.toString() + ",dc=example,dc=com"), Arrays.asList("# Soft Delete Response Control:", "# OID: " + SoftDeleteResponseControl.SOFT_DELETE_RESPONSE_OID, "# Soft-Deleted Entry DN: ou=test+entryUUID=" + uuid.toString() + ",dc=example,dc=com") });
// An invalid soft delete response control.
resultList.add(new Object[] { new Control(SoftDeleteResponseControl.SOFT_DELETE_RESPONSE_OID), Arrays.asList("# Response Control:", "# OID: " + SoftDeleteResponseControl.SOFT_DELETE_RESPONSE_OID, "# Is Critical: false") });
// A valid transaction settings response control.
resultList.add(new Object[] { new TransactionSettingsResponseControl(12345, true), Arrays.asList("# Transaction Settings Response Control:", "# OID: " + TransactionSettingsResponseControl.TRANSACTION_SETTINGS_RESPONSE_OID, "# Number of Lock Conflicts: 12345", "# Backend Lock Acquired: true") });
// An invalid transaction settings response control.
resultList.add(new Object[] { new Control(TransactionSettingsResponseControl.TRANSACTION_SETTINGS_RESPONSE_OID), Arrays.asList("# Response Control:", "# OID: " + TransactionSettingsResponseControl.TRANSACTION_SETTINGS_RESPONSE_OID, "# Is Critical: false") });
// A valid uniqueness response control in which all of the tests passed.
resultList.add(new Object[] { new UniquenessResponseControl("all-passed", true, true, null), Arrays.asList("# Uniqueness Response Control:", "# OID: " + UniquenessResponseControl.UNIQUENESS_RESPONSE_OID, "# Uniqueness ID: all-passed", "# Pre-Commit Validation Status: Passed", "# Post-Commit Validation Status: Passed") });
// A valid uniqueness response control in which the pre-commit attempt
// failed.
resultList.add(new Object[] { new UniquenessResponseControl("pre-commit-failed", false, null, "The pre-commit attempt failed"), Arrays.asList("# Uniqueness Response Control:", "# OID: " + UniquenessResponseControl.UNIQUENESS_RESPONSE_OID, "# Uniqueness ID: pre-commit-failed", "# Pre-Commit Validation Status: Failed", "# Post-Commit Validation Status: Not Attempted", "# Message: The pre-commit attempt failed") });
// A valid uniqueness response control in which the pre-commit attempt
// passed but the post-commit attempt failed.
resultList.add(new Object[] { new UniquenessResponseControl("post-commit-failed", true, false, "The post-commit attempt failed"), Arrays.asList("# Uniqueness Response Control:", "# OID: " + UniquenessResponseControl.UNIQUENESS_RESPONSE_OID, "# Uniqueness ID: post-commit-failed", "# Pre-Commit Validation Status: Passed", "# Post-Commit Validation Status: Failed", "# Message: The post-commit attempt failed") });
// A valid uniqueness response control in which no validation was attempted.
resultList.add(new Object[] { new UniquenessResponseControl("not-attempted", null, null, "No validation was attempted"), Arrays.asList("# Uniqueness Response Control:", "# OID: " + UniquenessResponseControl.UNIQUENESS_RESPONSE_OID, "# Uniqueness ID: not-attempted", "# Pre-Commit Validation Status: Not Attempted", "# Post-Commit Validation Status: Not Attempted", "# Message: No validation was attempted") });
// An invalid uniqueness response control.
resultList.add(new Object[] { new Control(UniquenessResponseControl.UNIQUENESS_RESPONSE_OID), Arrays.asList("# Response Control:", "# OID: " + UniquenessResponseControl.UNIQUENESS_RESPONSE_OID, "# Is Critical: false") });
return resultList.iterator();
}
use of com.unboundid.ldap.sdk.controls.ServerSideSortResponseControl in project ldapsdk by pingidentity.
the class ResultUtils method addServerSideSortResponseControl.
/**
* Adds a multi-line string representation of the provided control, which is
* expected to be a server-side sort response control, to the given list.
*
* @param lines The list to which the lines should be added.
* @param c The control to be formatted.
* @param prefix The prefix to use for each line.
* @param maxWidth The maximum length of each line in characters, including
* the comment prefix and indent.
*/
private static void addServerSideSortResponseControl(@NotNull final List<String> lines, @NotNull final Control c, @NotNull final String prefix, final int maxWidth) {
final ServerSideSortResponseControl decoded;
try {
decoded = new ServerSideSortResponseControl(c.getOID(), c.isCritical(), c.getValue());
} catch (final Exception e) {
Debug.debugException(e);
addGenericResponseControl(lines, c, prefix, maxWidth);
return;
}
wrap(lines, INFO_RESULT_UTILS_SORT_HEADER.get(), prefix, maxWidth);
final String indentPrefix = prefix + " ";
wrap(lines, INFO_RESULT_UTILS_RESPONSE_CONTROL_OID.get(c.getOID()), indentPrefix, maxWidth);
final ResultCode resultCode = decoded.getResultCode();
if (resultCode != null) {
wrap(lines, INFO_RESULT_UTILS_SORT_RESULT_CODE.get(String.valueOf(resultCode)), indentPrefix, maxWidth);
}
final String attributeName = decoded.getAttributeName();
if (attributeName != null) {
wrap(lines, INFO_RESULT_UTILS_SORT_ATTRIBUTE_NAME.get(attributeName), indentPrefix, maxWidth);
}
}
Aggregations