Search in sources :

Example 41 with ASN1BufferSequence

use of com.unboundid.asn1.ASN1BufferSequence in project ldapsdk by pingidentity.

the class BindResponseProtocolOp method writeTo.

/**
 * {@inheritDoc}
 */
@Override()
public void writeTo(@NotNull final ASN1Buffer buffer) {
    final ASN1BufferSequence opSequence = buffer.beginSequence(LDAPMessage.PROTOCOL_OP_TYPE_BIND_RESPONSE);
    buffer.addEnumerated(resultCode);
    buffer.addOctetString(matchedDN);
    buffer.addOctetString(diagnosticMessage);
    if (!referralURLs.isEmpty()) {
        final ASN1BufferSequence refSequence = buffer.beginSequence(GenericResponseProtocolOp.TYPE_REFERRALS);
        for (final String s : referralURLs) {
            buffer.addOctetString(s);
        }
        refSequence.end();
    }
    if (serverSASLCredentials != null) {
        buffer.addElement(serverSASLCredentials);
    }
    opSequence.end();
}
Also used : ASN1BufferSequence(com.unboundid.asn1.ASN1BufferSequence) ASN1OctetString(com.unboundid.asn1.ASN1OctetString)

Example 42 with ASN1BufferSequence

use of com.unboundid.asn1.ASN1BufferSequence in project ldapsdk by pingidentity.

the class Filter method writeTo.

/**
 * Writes an ASN.1-encoded representation of this filter to the provided ASN.1
 * buffer.
 *
 * @param  buffer  The ASN.1 buffer to which the encoded representation should
 *                 be written.
 */
public void writeTo(@NotNull final ASN1Buffer buffer) {
    switch(filterType) {
        case FILTER_TYPE_AND:
        case FILTER_TYPE_OR:
            final ASN1BufferSet compSet = buffer.beginSet(filterType);
            for (final Filter f : filterComps) {
                f.writeTo(buffer);
            }
            compSet.end();
            break;
        case FILTER_TYPE_NOT:
            buffer.addElement(new ASN1Element(filterType, notComp.encode().encode()));
            break;
        case FILTER_TYPE_EQUALITY:
        case FILTER_TYPE_GREATER_OR_EQUAL:
        case FILTER_TYPE_LESS_OR_EQUAL:
        case FILTER_TYPE_APPROXIMATE_MATCH:
            final ASN1BufferSequence avaSequence = buffer.beginSequence(filterType);
            buffer.addOctetString(attrName);
            buffer.addElement(assertionValue);
            avaSequence.end();
            break;
        case FILTER_TYPE_SUBSTRING:
            final ASN1BufferSequence subFilterSequence = buffer.beginSequence(filterType);
            buffer.addOctetString(attrName);
            final ASN1BufferSequence valueSequence = buffer.beginSequence();
            if (subInitial != null) {
                buffer.addOctetString(SUBSTRING_TYPE_SUBINITIAL, subInitial.getValue());
            }
            for (final ASN1OctetString s : subAny) {
                buffer.addOctetString(SUBSTRING_TYPE_SUBANY, s.getValue());
            }
            if (subFinal != null) {
                buffer.addOctetString(SUBSTRING_TYPE_SUBFINAL, subFinal.getValue());
            }
            valueSequence.end();
            subFilterSequence.end();
            break;
        case FILTER_TYPE_PRESENCE:
            buffer.addOctetString(filterType, attrName);
            break;
        case FILTER_TYPE_EXTENSIBLE_MATCH:
            final ASN1BufferSequence mrSequence = buffer.beginSequence(filterType);
            if (matchingRuleID != null) {
                buffer.addOctetString(EXTENSIBLE_TYPE_MATCHING_RULE_ID, matchingRuleID);
            }
            if (attrName != null) {
                buffer.addOctetString(EXTENSIBLE_TYPE_ATTRIBUTE_NAME, attrName);
            }
            buffer.addOctetString(EXTENSIBLE_TYPE_MATCH_VALUE, assertionValue.getValue());
            if (dnAttributes) {
                buffer.addBoolean(EXTENSIBLE_TYPE_DN_ATTRIBUTES, true);
            }
            mrSequence.end();
            break;
    }
}
Also used : ASN1OctetString(com.unboundid.asn1.ASN1OctetString) JSONObjectFilter(com.unboundid.ldap.sdk.unboundidds.jsonfilter.JSONObjectFilter) ASN1BufferSequence(com.unboundid.asn1.ASN1BufferSequence) ASN1Element(com.unboundid.asn1.ASN1Element) ASN1BufferSet(com.unboundid.asn1.ASN1BufferSet)

Example 43 with ASN1BufferSequence

use of com.unboundid.asn1.ASN1BufferSequence in project ldapsdk by pingidentity.

the class ExtendedRequest method writeTo.

/**
 * {@inheritDoc}
 */
@Override()
public final void writeTo(@NotNull final ASN1Buffer writer) {
    final ASN1BufferSequence requestSequence = writer.beginSequence(LDAPMessage.PROTOCOL_OP_TYPE_EXTENDED_REQUEST);
    writer.addOctetString(TYPE_EXTENDED_REQUEST_OID, oid);
    if (value != null) {
        writer.addOctetString(TYPE_EXTENDED_REQUEST_VALUE, value.getValue());
    }
    requestSequence.end();
}
Also used : ASN1BufferSequence(com.unboundid.asn1.ASN1BufferSequence)

Example 44 with ASN1BufferSequence

use of com.unboundid.asn1.ASN1BufferSequence in project ldapsdk by pingidentity.

the class CompareRequest method writeTo.

/**
 * {@inheritDoc}
 */
@Override()
public void writeTo(@NotNull final ASN1Buffer buffer) {
    final ASN1BufferSequence requestSequence = buffer.beginSequence(LDAPMessage.PROTOCOL_OP_TYPE_COMPARE_REQUEST);
    buffer.addOctetString(dn);
    final ASN1BufferSequence avaSequence = buffer.beginSequence();
    buffer.addOctetString(attributeName);
    buffer.addElement(assertionValue);
    avaSequence.end();
    requestSequence.end();
}
Also used : ASN1BufferSequence(com.unboundid.asn1.ASN1BufferSequence)

Example 45 with ASN1BufferSequence

use of com.unboundid.asn1.ASN1BufferSequence in project ldapsdk by pingidentity.

the class Control method writeTo.

/**
 * Writes an ASN.1-encoded representation of this control to the provided
 * ASN.1 stream writer.
 *
 * @param  writer  The ASN.1 stream writer to which the encoded representation
 *                 should be written.
 */
public final void writeTo(@NotNull final ASN1Buffer writer) {
    final ASN1BufferSequence controlSequence = writer.beginSequence();
    writer.addOctetString(oid);
    if (isCritical) {
        writer.addBoolean(true);
    }
    if (value != null) {
        writer.addOctetString(value.getValue());
    }
    controlSequence.end();
}
Also used : ASN1BufferSequence(com.unboundid.asn1.ASN1BufferSequence)

Aggregations

ASN1BufferSequence (com.unboundid.asn1.ASN1BufferSequence)47 ASN1Buffer (com.unboundid.asn1.ASN1Buffer)22 ASN1StreamReader (com.unboundid.asn1.ASN1StreamReader)22 ByteArrayInputStream (java.io.ByteArrayInputStream)22 Test (org.testng.annotations.Test)22 ASN1OctetString (com.unboundid.asn1.ASN1OctetString)9 ASN1BufferSet (com.unboundid.asn1.ASN1BufferSet)3 Attribute (com.unboundid.ldap.sdk.Attribute)2 ASN1Element (com.unboundid.asn1.ASN1Element)1 Control (com.unboundid.ldap.sdk.Control)1 Modification (com.unboundid.ldap.sdk.Modification)1 JSONObjectFilter (com.unboundid.ldap.sdk.unboundidds.jsonfilter.JSONObjectFilter)1