use of com.unboundid.asn1.ASN1BufferSequence in project ldapsdk by pingidentity.
the class BindResultTestCase method testReadBindResultFromInvalidElementType.
/**
* 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 testReadBindResultFromInvalidElementType() throws Exception {
ASN1Buffer b = new ASN1Buffer();
ASN1BufferSequence msgSequence = b.beginSequence();
b.addInteger(1);
ASN1BufferSequence opSequence = b.beginSequence(LDAPMessage.PROTOCOL_OP_TYPE_BIND_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 ModifyDNRequest method writeTo.
/**
* {@inheritDoc}
*/
@Override()
public void writeTo(@NotNull final ASN1Buffer writer) {
final ASN1BufferSequence requestSequence = writer.beginSequence(LDAPMessage.PROTOCOL_OP_TYPE_MODIFY_DN_REQUEST);
writer.addOctetString(dn);
writer.addOctetString(newRDN);
writer.addBoolean(deleteOldRDN);
if (newSuperiorDN != null) {
writer.addOctetString(NEW_SUPERIOR_TYPE, newSuperiorDN);
}
requestSequence.end();
}
use of com.unboundid.asn1.ASN1BufferSequence in project ldapsdk by pingidentity.
the class SearchRequest method writeTo.
/**
* {@inheritDoc}
*/
@Override()
public void writeTo(@NotNull final ASN1Buffer writer) {
final ASN1BufferSequence requestSequence = writer.beginSequence(LDAPMessage.PROTOCOL_OP_TYPE_SEARCH_REQUEST);
writer.addOctetString(baseDN);
writer.addEnumerated(scope.intValue());
writer.addEnumerated(derefPolicy.intValue());
writer.addInteger(sizeLimit);
writer.addInteger(timeLimit);
writer.addBoolean(typesOnly);
filter.writeTo(writer);
final ASN1BufferSequence attrSequence = writer.beginSequence();
for (final String s : attributes) {
writer.addOctetString(s);
}
attrSequence.end();
requestSequence.end();
}
use of com.unboundid.asn1.ASN1BufferSequence in project ldapsdk by pingidentity.
the class SimpleBindRequest method writeTo.
/**
* {@inheritDoc}
*/
@Override()
public void writeTo(@NotNull final ASN1Buffer buffer) {
final ASN1BufferSequence requestSequence = buffer.beginSequence(LDAPMessage.PROTOCOL_OP_TYPE_BIND_REQUEST);
buffer.addElement(VERSION_ELEMENT);
buffer.addElement(bindDN);
if (passwordProvider == null) {
buffer.addElement(password);
} else {
final byte[] pwBytes;
try {
pwBytes = passwordProvider.getPasswordBytes();
} catch (final LDAPException le) {
Debug.debugException(le);
throw new LDAPRuntimeException(le);
}
final ASN1OctetString pw = new ASN1OctetString(CRED_TYPE_SIMPLE, pwBytes);
buffer.addElement(pw);
buffer.setZeroBufferOnClear();
Arrays.fill(pwBytes, (byte) 0x00);
}
requestSequence.end();
}
use of com.unboundid.asn1.ASN1BufferSequence in project ldapsdk by pingidentity.
the class SearchRequestProtocolOpTestCase method testDecodeMalformedFilter.
/**
* Tests the behavior when trying to decode a search request with a malformed
* filter.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test(expectedExceptions = { LDAPException.class })
public void testDecodeMalformedFilter() throws Exception {
ASN1Buffer b = new ASN1Buffer();
ASN1BufferSequence s = b.beginSequence((byte) 0x63);
b.addOctetString("dc=example,dc=com");
b.addEnumerated(2);
b.addEnumerated(0);
b.addInteger(0);
b.addInteger(0);
b.addBoolean(false);
b.addOctetString((byte) 0x00);
b.beginSequence().end();
s.end();
ByteArrayInputStream inputStream = new ByteArrayInputStream(b.toByteArray());
ASN1StreamReader reader = new ASN1StreamReader(inputStream);
new SearchRequestProtocolOp(reader);
}
Aggregations