Search in sources :

Example 21 with ASN1Integer

use of com.mindbright.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()));
}
Also used : ASN1OctetString(com.unboundid.asn1.ASN1OctetString) ASN1Sequence(com.unboundid.asn1.ASN1Sequence) ASN1Integer(com.unboundid.asn1.ASN1Integer) Test(org.testng.annotations.Test)

Example 22 with ASN1Integer

use of com.mindbright.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())));
}
Also used : ASN1OctetString(com.unboundid.asn1.ASN1OctetString) Control(com.unboundid.ldap.sdk.Control) ASN1Sequence(com.unboundid.asn1.ASN1Sequence) ASN1Integer(com.unboundid.asn1.ASN1Integer) Test(org.testng.annotations.Test)

Example 23 with ASN1Integer

use of com.mindbright.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())));
}
Also used : ASN1OctetString(com.unboundid.asn1.ASN1OctetString) Control(com.unboundid.ldap.sdk.Control) ASN1Sequence(com.unboundid.asn1.ASN1Sequence) ASN1Integer(com.unboundid.asn1.ASN1Integer) Test(org.testng.annotations.Test)

Example 24 with ASN1Integer

use of com.mindbright.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);
}
Also used : ASN1OctetString(com.unboundid.asn1.ASN1OctetString) ASN1Sequence(com.unboundid.asn1.ASN1Sequence) ASN1Enumerated(com.unboundid.asn1.ASN1Enumerated) ExtendedRequest(com.unboundid.ldap.sdk.ExtendedRequest) ASN1Integer(com.unboundid.asn1.ASN1Integer) Test(org.testng.annotations.Test)

Example 25 with ASN1Integer

use of com.mindbright.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());
}
Also used : ASN1OctetString(com.unboundid.asn1.ASN1OctetString) ASN1Sequence(com.unboundid.asn1.ASN1Sequence) ByteArrayInputStream(java.io.ByteArrayInputStream) ASN1Integer(com.unboundid.asn1.ASN1Integer) Test(org.testng.annotations.Test)

Aggregations

ASN1Integer (org.bouncycastle.asn1.ASN1Integer)213 ASN1Integer (com.unboundid.asn1.ASN1Integer)96 ASN1Sequence (com.unboundid.asn1.ASN1Sequence)94 ASN1EncodableVector (org.bouncycastle.asn1.ASN1EncodableVector)91 IOException (java.io.IOException)89 DERSequence (org.bouncycastle.asn1.DERSequence)89 ASN1Integer (com.github.zhenwei.core.asn1.ASN1Integer)86 BigInteger (java.math.BigInteger)86 ASN1OctetString (com.unboundid.asn1.ASN1OctetString)80 ASN1Element (com.unboundid.asn1.ASN1Element)69 Test (org.testng.annotations.Test)63 ArrayList (java.util.ArrayList)50 ASN1EncodableVector (com.github.zhenwei.core.asn1.ASN1EncodableVector)49 DERSequence (com.github.zhenwei.core.asn1.DERSequence)47 ASN1Sequence (org.bouncycastle.asn1.ASN1Sequence)47 DEROctetString (org.bouncycastle.asn1.DEROctetString)38 ASN1ObjectIdentifier (org.bouncycastle.asn1.ASN1ObjectIdentifier)35 ASN1InputStream (org.bouncycastle.asn1.ASN1InputStream)28 ASN1Encodable (org.bouncycastle.asn1.ASN1Encodable)27 AlgorithmIdentifier (org.bouncycastle.asn1.x509.AlgorithmIdentifier)27