use of org.webpki.asn1.ASN1Integer in project ldapsdk by pingidentity.
the class MatchingEntryCountResponseControlTestCase method testDecodeValueInvalidCountType.
/**
* Tests the behavior when trying to decode a control whose value sequence
* contains an invalid count type.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test(expectedExceptions = { LDAPException.class })
public void testDecodeValueInvalidCountType() throws Exception {
final ASN1Sequence valueSequence = new ASN1Sequence(new ASN1Integer((byte) 0x84, 12345));
new MatchingEntryCountResponseControl("1.3.6.1.4.1.30221.2.5.37", false, new ASN1OctetString(valueSequence.encode()));
}
use of org.webpki.asn1.ASN1Integer in project ldapsdk by pingidentity.
the class UndeleteRequestControlTestCase method testDecodeValueSequenceBadElement.
/**
* Tests the behavior when attempting to decode a control whose value has an
* invalid sequence element.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test(expectedExceptions = { LDAPException.class })
public void testDecodeValueSequenceBadElement() throws Exception {
final ASN1Sequence valueSequence = new ASN1Sequence(new ASN1Integer((byte) 0x82, -1), new ASN1OctetString((byte) 0x83, "unexpected type"));
new UndeleteRequestControl(new Control(UndeleteRequestControl.UNDELETE_REQUEST_OID, true, new ASN1OctetString(valueSequence.encode())));
}
use of org.webpki.asn1.ASN1Integer in project ldapsdk by pingidentity.
the class SoftDeleteRequestControlTestCase method testDecodeValueSequenceBadElement.
/**
* Tests the behavior when attempting to decode a control whose value has an
* invalid sequence element.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test(expectedExceptions = { LDAPException.class })
public void testDecodeValueSequenceBadElement() throws Exception {
final ASN1Sequence valueSequence = new ASN1Sequence(new ASN1Integer((byte) 0x82, -1), new ASN1OctetString((byte) 0x83, "unexpected type"));
new SoftDeleteRequestControl(new Control(SoftDeleteRequestControl.SOFT_DELETE_REQUEST_OID, true, new ASN1OctetString(valueSequence.encode())));
}
use of org.webpki.asn1.ASN1Integer in project ldapsdk by pingidentity.
the class StreamProxyValuesExtendedRequestTestCase method testDecodeInvalidValueSequenceElement.
/**
* Tests the behavior when trying to decode a request with an invalid value
* sequence element.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test(expectedExceptions = { LDAPException.class })
public void testDecodeInvalidValueSequenceElement() throws Exception {
StreamProxyValuesBackendSet s = new StreamProxyValuesBackendSet(new ASN1OctetString("foo"), new String[] { "ds.example.com" }, new int[] { 389 });
ASN1Sequence valueSequence = new ASN1Sequence(new ASN1OctetString((byte) 0x80, "dc=example,dc=com"), new ASN1Sequence((byte) 0xA1, new ASN1Enumerated((byte) 0x80, 2)), new ASN1Integer((byte) 0x83, -1), new ASN1Sequence((byte) 0xA4, s.encode()), new ASN1OctetString((byte) 0x8F));
ASN1OctetString value = new ASN1OctetString(valueSequence.encode());
ExtendedRequest r = new ExtendedRequest("1.3.6.1.4.1.30221.2.6.8", value);
new StreamProxyValuesExtendedRequest(r);
}
use of org.webpki.asn1.ASN1Integer in project ldapsdk by pingidentity.
the class PassphraseEncryptedStreamsTestCase method testReadBadEncodingVersion.
/**
* Tests the behavior when trying to read a header with an invalid encoding
* version.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test(expectedExceptions = { LDAPException.class })
public void testReadBadEncodingVersion() throws Exception {
final ASN1Sequence headerSequence = new ASN1Sequence(new ASN1Integer(PassphraseEncryptedStreamHeader.TYPE_ENCODING_VERSION, PassphraseEncryptedStreamHeader.ENCODING_VERSION_1 + 1), new ASN1OctetString(PassphraseEncryptedStreamHeader.TYPE_KEY_FACTORY_ALGORITHM, "PBKDF2WithHmacSHA1"), new ASN1Integer(PassphraseEncryptedStreamHeader.TYPE_KEY_FACTORY_ITERATION_COUNT, 16_384), new ASN1OctetString(PassphraseEncryptedStreamHeader.TYPE_KEY_FACTORY_SALT, new byte[16]), new ASN1Integer(PassphraseEncryptedStreamHeader.TYPE_KEY_FACTORY_KEY_LENGTH_BITS, 128), new ASN1OctetString(PassphraseEncryptedStreamHeader.TYPE_CIPHER_TRANSFORMATION, "AES/CBC/PKCS5Padding"), new ASN1OctetString(PassphraseEncryptedStreamHeader.TYPE_CIPHER_INITIALIZATION_VECTOR, new byte[16]), new ASN1OctetString(PassphraseEncryptedStreamHeader.TYPE_KEY_IDENTIFIER, "key-identifier"), new ASN1OctetString(PassphraseEncryptedStreamHeader.TYPE_MAC_ALGORITHM, "HmacSHA256"), new ASN1OctetString(PassphraseEncryptedStreamHeader.TYPE_MAC_ALGORITHM, StaticUtils.getBytes("bad-mac")));
final ByteStringBuffer buffer = new ByteStringBuffer();
buffer.append(PassphraseEncryptedStreamHeader.MAGIC_BYTES);
buffer.append(headerSequence.encode());
final ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(buffer.toByteArray());
PassphraseEncryptedStreamHeader.readFrom(byteArrayInputStream, "passphrase".toCharArray());
}
Aggregations