Search in sources :

Example 66 with ASN1Sequence

use of com.github.zhenwei.core.asn1.ASN1Sequence in project ldapsdk by pingidentity.

the class DeliverOneTimePasswordExtendedResultTestCase method testDecodeValueMissingDeliveryMechanism.

/**
 * Tests the behavior when trying to decode an extended result whose value
 * sequence is missing the delivery mechanism.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test(expectedExceptions = { LDAPException.class })
public void testDecodeValueMissingDeliveryMechanism() throws Exception {
    final ASN1Sequence valueSequence = new ASN1Sequence(new ASN1OctetString((byte) 0x81, "uid=test.user,dc=example,dc=com"), new ASN1OctetString((byte) 0x82, "test.user@example.com"), new ASN1OctetString((byte) 0x83, "Delivery message"));
    new DeliverOneTimePasswordExtendedResult(new ExtendedResult(1, ResultCode.SUCCESS, null, null, null, "1.3.6.1.4.1.30221.2.6.25", new ASN1OctetString(valueSequence.encode()), null));
}
Also used : ASN1OctetString(com.unboundid.asn1.ASN1OctetString) ASN1Sequence(com.unboundid.asn1.ASN1Sequence) ExtendedResult(com.unboundid.ldap.sdk.ExtendedResult) Test(org.testng.annotations.Test)

Example 67 with ASN1Sequence

use of com.github.zhenwei.core.asn1.ASN1Sequence in project ldapsdk by pingidentity.

the class DeliverPasswordResetTokenExtendedRequestTestCase method testDecodeValueUnrecognizedSequenceElement.

/**
 * Tests the behavior when trying to decode a request with a value whose
 * sequence contains an element with an unrecognized BER type.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test(expectedExceptions = { LDAPException.class })
public void testDecodeValueUnrecognizedSequenceElement() throws Exception {
    final ASN1Sequence valueSequence = new ASN1Sequence(new ASN1OctetString("uid=test.user,ou=People,dc=example,dc=com"), new ASN1OctetString((byte) 0x12, "foo"));
    new DeliverPasswordResetTokenExtendedRequest(new ExtendedRequest("1.3.6.1.4.1.30221.2.6.45", new ASN1OctetString(valueSequence.encode())));
}
Also used : ASN1OctetString(com.unboundid.asn1.ASN1OctetString) ASN1Sequence(com.unboundid.asn1.ASN1Sequence) ExtendedRequest(com.unboundid.ldap.sdk.ExtendedRequest) Test(org.testng.annotations.Test)

Example 68 with ASN1Sequence

use of com.github.zhenwei.core.asn1.ASN1Sequence in project ldapsdk by pingidentity.

the class DeliverPasswordResetTokenExtendedResultTestCase method testDecodeValueUnrecognizedSequenceElement.

/**
 * Tests the behavior when trying to decode a result with a value whose
 * sequence contains an element with an unrecognized BER type.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test(expectedExceptions = { LDAPException.class })
public void testDecodeValueUnrecognizedSequenceElement() throws Exception {
    final ASN1Sequence valueSequence = new ASN1Sequence(new ASN1OctetString("Email"), new ASN1OctetString((byte) 0x80, "test.user@example.com"), new ASN1OctetString((byte) 0x12, "invalid"));
    new DeliverPasswordResetTokenExtendedResult(new ExtendedResult(1, ResultCode.SUCCESS, null, null, null, "1.3.6.1.4.1.30221.2.6.46", new ASN1OctetString(valueSequence.encode()), null));
}
Also used : ASN1OctetString(com.unboundid.asn1.ASN1OctetString) ASN1Sequence(com.unboundid.asn1.ASN1Sequence) ExtendedResult(com.unboundid.ldap.sdk.ExtendedResult) Test(org.testng.annotations.Test)

Example 69 with ASN1Sequence

use of com.github.zhenwei.core.asn1.ASN1Sequence in project ldapsdk by pingidentity.

the class EndInteractiveTransactionExtendedRequestTestCase method testConstructor3ValueEmptySequence.

/**
 * Tests the third constructor with an extended request whose value is an
 * empty sequence.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test(expectedExceptions = { LDAPException.class })
public void testConstructor3ValueEmptySequence() throws Exception {
    ASN1OctetString value = new ASN1OctetString(new ASN1Sequence().encode());
    ExtendedRequest r = new ExtendedRequest("1.3.6.1.4.1.30221.2.6.4", value);
    new EndInteractiveTransactionExtendedRequest(r);
}
Also used : ASN1OctetString(com.unboundid.asn1.ASN1OctetString) ASN1Sequence(com.unboundid.asn1.ASN1Sequence) ExtendedRequest(com.unboundid.ldap.sdk.ExtendedRequest) Test(org.testng.annotations.Test)

Example 70 with ASN1Sequence

use of com.github.zhenwei.core.asn1.ASN1Sequence in project ldapsdk by pingidentity.

the class UniquenessRequestControlTestCase method testDecodeControlValueSequenceInvalidPostCommitValidationLevel.

/**
 * Tests the behavior when trying to decode a control whose value sequence has
 * an invalid multiple post-commit validation level value.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test(expectedExceptions = { LDAPException.class })
public void testDecodeControlValueSequenceInvalidPostCommitValidationLevel() throws Exception {
    final ASN1Sequence valueSequence = new ASN1Sequence(new ASN1OctetString((byte) 0x80, "uniqueness-id"), new ASN1Set((byte) 0xA1, new ASN1OctetString("uid")), new ASN1Enumerated((byte) 0x87, 12345));
    new UniquenessRequestControl(new Control("1.3.6.1.4.1.30221.2.5.52", true, new ASN1OctetString(valueSequence.encode())));
}
Also used : ASN1OctetString(com.unboundid.asn1.ASN1OctetString) Control(com.unboundid.ldap.sdk.Control) ASN1Sequence(com.unboundid.asn1.ASN1Sequence) ASN1Set(com.unboundid.asn1.ASN1Set) ASN1Enumerated(com.unboundid.asn1.ASN1Enumerated) Test(org.testng.annotations.Test)

Aggregations

ASN1Sequence (com.unboundid.asn1.ASN1Sequence)455 ASN1OctetString (com.unboundid.asn1.ASN1OctetString)397 Test (org.testng.annotations.Test)311 ASN1Sequence (org.bouncycastle.asn1.ASN1Sequence)297 ASN1Element (com.unboundid.asn1.ASN1Element)231 ArrayList (java.util.ArrayList)184 IOException (java.io.IOException)141 NotNull (com.unboundid.util.NotNull)116 ASN1Enumerated (com.unboundid.asn1.ASN1Enumerated)95 ASN1Integer (com.unboundid.asn1.ASN1Integer)94 ASN1Sequence (com.github.zhenwei.core.asn1.ASN1Sequence)85 ASN1Encodable (org.bouncycastle.asn1.ASN1Encodable)76 ASN1InputStream (org.bouncycastle.asn1.ASN1InputStream)73 ASN1ObjectIdentifier (org.bouncycastle.asn1.ASN1ObjectIdentifier)69 ASN1OctetString (org.bouncycastle.asn1.ASN1OctetString)64 ASN1Primitive (org.bouncycastle.asn1.ASN1Primitive)57 Enumeration (java.util.Enumeration)54 ASN1Boolean (com.unboundid.asn1.ASN1Boolean)53 X509Certificate (java.security.cert.X509Certificate)53 BigInteger (java.math.BigInteger)50