Search in sources :

Example 31 with ASN1BufferSequence

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

the class ExtendedResultTestCase method testReadExtendedResultFromInvalidElementType.

/**
 * Tests the {@code readBindResultFrom} method with a sequence containing an
 * invalid element type.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test(expectedExceptions = { LDAPException.class })
public void testReadExtendedResultFromInvalidElementType() throws Exception {
    ASN1Buffer b = new ASN1Buffer();
    ASN1BufferSequence msgSequence = b.beginSequence();
    b.addInteger(1);
    ASN1BufferSequence opSequence = b.beginSequence(LDAPMessage.PROTOCOL_OP_TYPE_EXTENDED_RESPONSE);
    b.addEnumerated(0);
    b.addOctetString();
    b.addOctetString();
    b.addOctetString((byte) 0x00);
    opSequence.end();
    msgSequence.end();
    ByteArrayInputStream inputStream = new ByteArrayInputStream(b.toByteArray());
    ASN1StreamReader reader = new ASN1StreamReader(inputStream);
    LDAPMessage.readLDAPResponseFrom(reader, true);
}
Also used : ASN1BufferSequence(com.unboundid.asn1.ASN1BufferSequence) ByteArrayInputStream(java.io.ByteArrayInputStream) ASN1Buffer(com.unboundid.asn1.ASN1Buffer) ASN1StreamReader(com.unboundid.asn1.ASN1StreamReader) Test(org.testng.annotations.Test)

Example 32 with ASN1BufferSequence

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

the class ExtendedResultTestCase method testReadExtendedResultFromTooShort.

/**
 * Tests the {@code readBindResultFrom} method with an element containing
 * a response sequence that is too short.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test(expectedExceptions = { LDAPException.class })
public void testReadExtendedResultFromTooShort() throws Exception {
    ASN1Buffer b = new ASN1Buffer();
    ASN1BufferSequence msgSequence = b.beginSequence();
    b.addInteger(1);
    ASN1BufferSequence opSequence = b.beginSequence(LDAPMessage.PROTOCOL_OP_TYPE_EXTENDED_RESPONSE);
    b.addEnumerated(0);
    opSequence.end();
    msgSequence.end();
    ByteArrayInputStream inputStream = new ByteArrayInputStream(b.toByteArray());
    ASN1StreamReader reader = new ASN1StreamReader(inputStream);
    LDAPMessage.readLDAPResponseFrom(reader, true);
}
Also used : ASN1BufferSequence(com.unboundid.asn1.ASN1BufferSequence) ByteArrayInputStream(java.io.ByteArrayInputStream) ASN1Buffer(com.unboundid.asn1.ASN1Buffer) ASN1StreamReader(com.unboundid.asn1.ASN1StreamReader) Test(org.testng.annotations.Test)

Example 33 with ASN1BufferSequence

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

the class SearchResultReferenceTestCase method testReadSearchReferenceMalformedControl.

/**
 * Tests the {@code readSearchReferenceFrom} method with an element containing
 * a malformed control.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test(expectedExceptions = { LDAPException.class })
public void testReadSearchReferenceMalformedControl() throws Exception {
    ASN1Buffer b = new ASN1Buffer();
    ASN1BufferSequence msgSequence = b.beginSequence();
    b.addInteger(1);
    ASN1BufferSequence opSequence = b.beginSequence(LDAPMessage.PROTOCOL_OP_TYPE_SEARCH_RESULT_REFERENCE);
    b.addOctetString("ldap://server.example.com/dc=example,dc=com");
    opSequence.end();
    ASN1BufferSequence ctrlsSequence = b.beginSequence(LDAPMessage.MESSAGE_TYPE_CONTROLS);
    ASN1BufferSequence ctlSequence = b.beginSequence();
    b.addOctetString("1.2.3.4");
    b.addInteger(1);
    ctlSequence.end();
    ctrlsSequence.end();
    msgSequence.end();
    ByteArrayInputStream inputStream = new ByteArrayInputStream(b.toByteArray());
    ASN1StreamReader reader = new ASN1StreamReader(inputStream);
    LDAPMessage.readLDAPResponseFrom(reader, true);
}
Also used : ASN1BufferSequence(com.unboundid.asn1.ASN1BufferSequence) ByteArrayInputStream(java.io.ByteArrayInputStream) ASN1Buffer(com.unboundid.asn1.ASN1Buffer) ASN1StreamReader(com.unboundid.asn1.ASN1StreamReader) Test(org.testng.annotations.Test)

Example 34 with ASN1BufferSequence

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

the class SearchResultReferenceTestCase method testReadSearchReferenceProtocolOpNotSequence.

/**
 * Tests the {@code readSearchReferenceFrom} method with an element in which
 * the protocol op is not a valid sequence.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test(expectedExceptions = { LDAPException.class })
public void testReadSearchReferenceProtocolOpNotSequence() throws Exception {
    ASN1Buffer b = new ASN1Buffer();
    ASN1BufferSequence msgSequence = b.beginSequence();
    b.addInteger(1);
    b.addInteger(LDAPMessage.PROTOCOL_OP_TYPE_SEARCH_RESULT_REFERENCE, 1);
    msgSequence.end();
    ByteArrayInputStream inputStream = new ByteArrayInputStream(b.toByteArray());
    ASN1StreamReader reader = new ASN1StreamReader(inputStream);
    LDAPMessage.readLDAPResponseFrom(reader, true);
}
Also used : ASN1BufferSequence(com.unboundid.asn1.ASN1BufferSequence) ByteArrayInputStream(java.io.ByteArrayInputStream) ASN1Buffer(com.unboundid.asn1.ASN1Buffer) ASN1StreamReader(com.unboundid.asn1.ASN1StreamReader) Test(org.testng.annotations.Test)

Example 35 with ASN1BufferSequence

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

the class CompareRequestProtocolOp method writeTo.

/**
 * {@inheritDoc}
 */
@Override()
public void writeTo(@NotNull final ASN1Buffer buffer) {
    final ASN1BufferSequence opSequence = buffer.beginSequence(LDAPMessage.PROTOCOL_OP_TYPE_COMPARE_REQUEST);
    buffer.addOctetString(dn);
    final ASN1BufferSequence avaSequence = buffer.beginSequence();
    buffer.addOctetString(attributeName);
    buffer.addElement(assertionValue);
    avaSequence.end();
    opSequence.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