Search in sources :

Example 61 with ASN1Boolean

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());
}
Also used : ASN1OctetString(com.unboundid.asn1.ASN1OctetString) ASN1Sequence(com.unboundid.asn1.ASN1Sequence) ASN1Enumerated(com.unboundid.asn1.ASN1Enumerated) ASN1Element(com.unboundid.asn1.ASN1Element) ArrayList(java.util.ArrayList) ASN1Boolean(com.unboundid.asn1.ASN1Boolean) ASN1OctetString(com.unboundid.asn1.ASN1OctetString) ASN1Integer(com.unboundid.asn1.ASN1Integer) NotNull(com.unboundid.util.NotNull)

Aggregations

ASN1Boolean (com.unboundid.asn1.ASN1Boolean)51 ASN1OctetString (com.unboundid.asn1.ASN1OctetString)51 ASN1Sequence (com.unboundid.asn1.ASN1Sequence)51 ASN1Element (com.unboundid.asn1.ASN1Element)38 NotNull (com.unboundid.util.NotNull)32 ArrayList (java.util.ArrayList)32 ASN1Integer (com.unboundid.asn1.ASN1Integer)15 Test (org.testng.annotations.Test)14 ASN1Enumerated (com.unboundid.asn1.ASN1Enumerated)12 ASN1Boolean (com.github.zhenwei.core.asn1.ASN1Boolean)5 Nullable (com.unboundid.util.Nullable)5 IOException (java.io.IOException)5 ASN1Integer (com.github.zhenwei.core.asn1.ASN1Integer)4 ASN1Sequence (com.github.zhenwei.core.asn1.ASN1Sequence)4 ASN1TaggedObject (com.github.zhenwei.core.asn1.ASN1TaggedObject)4 ASN1Set (com.unboundid.asn1.ASN1Set)4 DERTaggedObject (com.github.zhenwei.core.asn1.DERTaggedObject)3 ASN1Long (com.unboundid.asn1.ASN1Long)3 Control (com.unboundid.ldap.sdk.Control)3 ASN1Boolean (org.bouncycastle.asn1.ASN1Boolean)3