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);
}
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);
}
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);
}
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);
}
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();
}
Aggregations