Search in sources :

Example 36 with ASN1BufferSequence

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

the class ExtendedResponseProtocolOp method writeTo.

/**
 * {@inheritDoc}
 */
@Override()
public void writeTo(@NotNull final ASN1Buffer buffer) {
    final ASN1BufferSequence opSequence = buffer.beginSequence(LDAPMessage.PROTOCOL_OP_TYPE_EXTENDED_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 (responseOID != null) {
        buffer.addOctetString(TYPE_RESPONSE_OID, responseOID);
    }
    if (responseValue != null) {
        buffer.addOctetString(TYPE_RESPONSE_VALUE, responseValue.getValue());
    }
    opSequence.end();
}
Also used : ASN1BufferSequence(com.unboundid.asn1.ASN1BufferSequence) ASN1OctetString(com.unboundid.asn1.ASN1OctetString)

Example 37 with ASN1BufferSequence

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

the class LDAPMessage method writeTo.

/**
 * Writes an encoded representation of this LDAP message 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) {
    final ASN1BufferSequence messageSequence = buffer.beginSequence();
    buffer.addInteger(messageID);
    protocolOp.writeTo(buffer);
    if (!controls.isEmpty()) {
        final ASN1BufferSequence controlsSequence = buffer.beginSequence(MESSAGE_TYPE_CONTROLS);
        for (final Control c : controls) {
            c.writeTo(buffer);
        }
        controlsSequence.end();
    }
    messageSequence.end();
}
Also used : Control(com.unboundid.ldap.sdk.Control) ASN1BufferSequence(com.unboundid.asn1.ASN1BufferSequence)

Example 38 with ASN1BufferSequence

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

the class ModifyRequestProtocolOp method writeTo.

/**
 * {@inheritDoc}
 */
@Override()
public void writeTo(@NotNull final ASN1Buffer writer) {
    final ASN1BufferSequence opSequence = writer.beginSequence(LDAPMessage.PROTOCOL_OP_TYPE_MODIFY_REQUEST);
    writer.addOctetString(dn);
    final ASN1BufferSequence modSequence = writer.beginSequence();
    for (final Modification m : modifications) {
        m.writeTo(writer);
    }
    modSequence.end();
    opSequence.end();
}
Also used : Modification(com.unboundid.ldap.sdk.Modification) ASN1BufferSequence(com.unboundid.asn1.ASN1BufferSequence)

Example 39 with ASN1BufferSequence

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

the class AddRequest method writeTo.

/**
 * {@inheritDoc}
 */
@Override()
public void writeTo(@NotNull final ASN1Buffer buffer) {
    final ASN1BufferSequence requestSequence = buffer.beginSequence(LDAPMessage.PROTOCOL_OP_TYPE_ADD_REQUEST);
    buffer.addOctetString(dn);
    final ASN1BufferSequence attrSequence = buffer.beginSequence();
    for (final Attribute a : attributes) {
        a.writeTo(buffer);
    }
    attrSequence.end();
    requestSequence.end();
}
Also used : ASN1BufferSequence(com.unboundid.asn1.ASN1BufferSequence)

Example 40 with ASN1BufferSequence

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

the class BindRequestProtocolOp method writeTo.

/**
 * {@inheritDoc}
 */
@Override()
public void writeTo(@NotNull final ASN1Buffer buffer) {
    final ASN1BufferSequence opSequence = buffer.beginSequence(LDAPMessage.PROTOCOL_OP_TYPE_BIND_REQUEST);
    buffer.addInteger(version);
    buffer.addOctetString(bindDN);
    if (credentialsType == CRED_TYPE_SIMPLE) {
        buffer.addElement(simplePassword);
    } else {
        final ASN1BufferSequence saslSequence = buffer.beginSequence(CRED_TYPE_SASL);
        buffer.addOctetString(saslMechanism);
        if (saslCredentials != null) {
            buffer.addElement(saslCredentials);
        }
        saslSequence.end();
    }
    opSequence.end();
    buffer.setZeroBufferOnClear();
}
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