use of com.github.zhenwei.core.asn1.ASN1Boolean in project ldapsdk by pingidentity.
the class SortKey method encode.
/**
* Encodes this sort key into an ASN.1 sequence suitable for use in the
* server-side sort control.
*
* @return An ASN.1 sequence containing the encoded representation of this
* sort key.
*/
@NotNull()
ASN1Sequence encode() {
final ArrayList<ASN1Element> elements = new ArrayList<>(3);
elements.add(new ASN1OctetString(attributeName));
if (matchingRuleID != null) {
elements.add(new ASN1OctetString(TYPE_MATCHING_RULE_ID, matchingRuleID));
}
if (reverseOrder) {
elements.add(new ASN1Boolean(TYPE_REVERSE_ORDER, reverseOrder));
}
return new ASN1Sequence(elements);
}
use of com.github.zhenwei.core.asn1.ASN1Boolean in project ldapsdk by pingidentity.
the class PersistentSearchRequestControl method encodeValue.
/**
* Encodes the provided information into an octet string that can be used as
* the value for this control.
*
* @param changeType The change type for which to register. It must not be
* {@code null}.
* @param changesOnly Indicates whether the search should only return search
* result entries for changes made to entries matching
* the search criteria, or if existing matching entries
* in the server should be returned as well.
* @param returnECs Indicates whether the search result entries returned
* as part of this persistent search should include the
* entry change notification control.
*
* @return An ASN.1 octet string that can be used as the value for this
* control.
*/
@NotNull()
private static ASN1OctetString encodeValue(@NotNull final PersistentSearchChangeType changeType, final boolean changesOnly, final boolean returnECs) {
Validator.ensureNotNull(changeType);
final ASN1Element[] elements = { new ASN1Integer(changeType.intValue()), new ASN1Boolean(changesOnly), new ASN1Boolean(returnECs) };
return new ASN1OctetString(new ASN1Sequence(elements).encode());
}
use of com.github.zhenwei.core.asn1.ASN1Boolean in project ldapsdk by pingidentity.
the class EndTransactionExtendedRequest method encodeValue.
/**
* Generates the value to include in this extended request.
*
* @param transactionID The transaction ID for the transaction to commit or
* abort. It must not be {@code null}.
* @param commit {@code true} if the transaction should be committed,
* or {@code false} if the transaction should be
* aborted.
*
* @return The ASN.1 octet string containing the encoded request value.
*/
@NotNull()
private static ASN1OctetString encodeValue(@NotNull final ASN1OctetString transactionID, final boolean commit) {
Validator.ensureNotNull(transactionID);
final ASN1Element[] valueElements;
if (commit) {
valueElements = new ASN1Element[] { transactionID };
} else {
valueElements = new ASN1Element[] { new ASN1Boolean(commit), transactionID };
}
return new ASN1OctetString(new ASN1Sequence(valueElements).encode());
}
use of com.github.zhenwei.core.asn1.ASN1Boolean in project ldapsdk by pingidentity.
the class JoinRequestValue method encode.
/**
* Encodes this join request value as appropriate for inclusion in the join
* request control.
*
* @return The ASN.1 element containing the encoded join request value.
*/
@NotNull()
ASN1Element encode() {
final ArrayList<ASN1Element> elements = new ArrayList<>(9);
elements.add(joinRule.encode());
elements.add(baseDN.encode());
if (scope != null) {
elements.add(new ASN1Enumerated(TYPE_SCOPE, scope.intValue()));
}
if (derefPolicy != null) {
elements.add(new ASN1Enumerated(TYPE_DEREF_POLICY, derefPolicy.intValue()));
}
if (sizeLimit != null) {
elements.add(new ASN1Integer(TYPE_SIZE_LIMIT, sizeLimit));
}
if (filter != null) {
elements.add(new ASN1OctetString(TYPE_FILTER, filter.encode().encode()));
}
if ((attributes != null) && (attributes.length > 0)) {
final ASN1Element[] attrElements = new ASN1Element[attributes.length];
for (int i = 0; i < attributes.length; i++) {
attrElements[i] = new ASN1OctetString(attributes[i]);
}
elements.add(new ASN1Sequence(TYPE_ATTRIBUTES, attrElements));
}
if (requireMatch) {
elements.add(new ASN1Boolean(TYPE_REQUIRE_MATCH, requireMatch));
}
if (nestedJoin != null) {
elements.add(new ASN1OctetString(TYPE_NESTED_JOIN, nestedJoin.encode().getValue()));
}
return new ASN1Sequence(elements);
}
use of com.github.zhenwei.core.asn1.ASN1Boolean in project ldapsdk by pingidentity.
the class MatchingEntryCountResponseControl method encodeValue.
/**
* Encodes a control value with the provided information.
*
* @param countType The matching entry count type. It must not
* be {@code null}.
* @param countValue The matching entry count value. It must be
* greater than or equal to zero for a count
* type of either {@code EXAMINED_COUNT} or
* {@code UNEXAMINED_COUNT}. It must be greater
* than zero for a count type of
* {@code UPPER_BOUND}. It must be -1 for a
* count type of {@code UNKNOWN}.
* @param searchIndexed Indicates whether the search criteria is
* considered at least partially indexed and
* could be processed more efficiently than
* examining all entries with a full database
* scan.
* @param shortCircuited Indicates whether the server short-circuited
* during candidate set processing before
* evaluating all elements of the search
* criteria (the filter and scope). This may be
* {@code null} if it is not available (e.g.,
* because extended response data was not
* requested).
* @param fullyIndexed Indicates whether the search is considered
* fully indexed. Note that this may be
* {@code false} even if the filter is actually
* fully indexed if server index processing
* short-circuited before evaluating all
* components of the filter. To avoid this,
* issue the request control with both fast and
* slow short-circuit thresholds set to zero.
* This may be {@code null} if this is not
* available (e.g., because extended response
* data was not requested).
* @param candidatesAreInScope Indicates whether all the identified
* candidate entries are within the scope of
* the search. It may be {@code null} if this
* is not available (e.g., because extended
* response data was not requested).
* @param remainingFilter The portion of the filter that was either
* identified as unindexed or that was not
* evaluated because processing short-circuited
* in the course of building the candidate set.
* It may be {@code null} if there is no
* remaining filter or if this information is
* not available (e.g., because extended
* response data was not requested).
* @param debugInfo An optional list of messages providing debug
* information about the processing performed by
* the server. It may be {@code null} or empty
* if no debug messages should be included.
*
* @return The encoded control value.
*/
@NotNull()
private static ASN1OctetString encodeValue(@NotNull final MatchingEntryCountType countType, final int countValue, final boolean searchIndexed, @Nullable final Boolean shortCircuited, @Nullable final Boolean fullyIndexed, @Nullable final Boolean candidatesAreInScope, @Nullable final Filter remainingFilter, @Nullable final Collection<String> debugInfo) {
final ArrayList<ASN1Element> elements = new ArrayList<>(3);
switch(countType) {
case EXAMINED_COUNT:
case UNEXAMINED_COUNT:
case UPPER_BOUND:
elements.add(new ASN1Integer(countType.getBERType(), countValue));
break;
case UNKNOWN:
elements.add(new ASN1Null(countType.getBERType()));
break;
}
if (debugInfo != null) {
final ArrayList<ASN1Element> debugElements = new ArrayList<>(debugInfo.size());
for (final String s : debugInfo) {
debugElements.add(new ASN1OctetString(s));
}
elements.add(new ASN1Sequence(TYPE_DEBUG_INFO, debugElements));
}
if (!searchIndexed) {
elements.add(new ASN1Boolean(TYPE_SEARCH_INDEXED, searchIndexed));
}
if (shortCircuited != null) {
elements.add(new ASN1Boolean(TYPE_SHORT_CIRCUITED, shortCircuited));
}
if (fullyIndexed != null) {
elements.add(new ASN1Boolean(TYPE_FULLY_INDEXED, fullyIndexed));
}
if (candidatesAreInScope != null) {
elements.add(new ASN1Boolean(TYPE_CANDIDATES_ARE_IN_SCOPE, candidatesAreInScope));
}
if (remainingFilter != null) {
elements.add(new ASN1OctetString(TYPE_REMAINING_FILTER, remainingFilter.encode().encode()));
}
return new ASN1OctetString(new ASN1Sequence(elements).encode());
}
Aggregations