use of com.github.zhenwei.core.asn1.ASN1Boolean in project ldapsdk by pingidentity.
the class StreamProxyValuesExtendedRequest method encodeValue.
/**
* Encodes the provided information into a form suitable for use as the value
* of this extended request.
*
* @param baseDN The base DN which indicates the portion of the
* DIT to target.
* @param scope The scope for which to return information about
* entry DNs in the specified portion of the DIT.
* This may be {@code null} if information about
* entry DNs should not be returned.
* @param relativeDNs Indicates whether DNs returned should be
* relative to the base DN rather than full DNs.
* @param attributes The names of the attributes for which to
* retrieve the values. This may be {@code null}
* or empty if only entry DNs should be retrieved.
* @param valuesPerResponse The maximum number of values to include per
* response. A value less than or equal to zero
* indicates that the server should choose an
* appropriate value.
* @param backendSets The list of backend sets defined in the
* Directory Proxy Server issuing the request.
*
* @return The ASN.1 octet string containing the encoded value to use for
* this extended request.
*/
@NotNull()
private static ASN1OctetString encodeValue(@NotNull final String baseDN, @Nullable final SearchScope scope, final boolean relativeDNs, @Nullable final List<String> attributes, final int valuesPerResponse, @NotNull final List<StreamProxyValuesBackendSet> backendSets) {
Validator.ensureNotNull(baseDN, backendSets);
Validator.ensureFalse(backendSets.isEmpty());
final ArrayList<ASN1Element> svElements = new ArrayList<>(4);
svElements.add(new ASN1OctetString(TYPE_BASE_DN, baseDN));
if (scope != null) {
final ArrayList<ASN1Element> idElements = new ArrayList<>(2);
idElements.add(new ASN1Enumerated(TYPE_SCOPE, scope.intValue()));
if (!relativeDNs) {
idElements.add(new ASN1Boolean(TYPE_RELATIVE, relativeDNs));
}
svElements.add(new ASN1Sequence(TYPE_INCLUDE_DNS, idElements));
}
if ((attributes != null) && (!attributes.isEmpty())) {
final ArrayList<ASN1Element> attrElements = new ArrayList<>(attributes.size());
for (final String s : attributes) {
attrElements.add(new ASN1OctetString(s));
}
svElements.add(new ASN1Sequence(TYPE_ATTRIBUTES, attrElements));
}
if (valuesPerResponse > 0) {
svElements.add(new ASN1Integer(TYPE_VALUES_PER_RESPONSE, valuesPerResponse));
}
final ASN1Element[] backendSetElements = new ASN1Element[backendSets.size()];
for (int i = 0; i < backendSetElements.length; i++) {
backendSetElements[i] = backendSets.get(i).encode();
}
svElements.add(new ASN1Sequence(TYPE_BACKEND_SETS, backendSetElements));
return new ASN1OctetString(new ASN1Sequence(svElements).encode());
}
Aggregations