Search in sources :

Example 61 with ASN1Sequence

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

the class CollectSupportDataExtendedRequestTestCase method testDecodeUndefinedSecurityLevel.

/**
 * Tests the behavior when trying to decode an extended request that has an
 * undefined security level.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test(expectedExceptions = { LDAPException.class })
public void testDecodeUndefinedSecurityLevel() throws Exception {
    final TestCollectSupportDataIntermediateResponseListener listener = new TestCollectSupportDataIntermediateResponseListener();
    final ASN1Sequence valueSequence = new ASN1Sequence(new ASN1Enumerated((byte) 0x86, 1234));
    new CollectSupportDataExtendedRequest(new ExtendedRequest("1.3.6.1.4.1.30221.2.6.64", new ASN1OctetString(valueSequence.encode())), listener);
}
Also used : ASN1OctetString(com.unboundid.asn1.ASN1OctetString) ASN1Sequence(com.unboundid.asn1.ASN1Sequence) ASN1Enumerated(com.unboundid.asn1.ASN1Enumerated) ExtendedRequest(com.unboundid.ldap.sdk.ExtendedRequest) Test(org.testng.annotations.Test)

Example 62 with ASN1Sequence

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

the class DeliverOneTimePasswordExtendedRequestTestCase method testDecodeValueSequenceInvalidElementType.

/**
 * Tests the behavior when trying to decode an extended request when the value
 * sequence has an element with an unexpected type.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test(expectedExceptions = { LDAPException.class })
public void testDecodeValueSequenceInvalidElementType() throws Exception {
    final ASN1Sequence valueSequence = new ASN1Sequence(new ASN1OctetString((byte) 0x80, "u:authid"), new ASN1OctetString((byte) 0x81, "password"), new ASN1OctetString((byte) 0x8F, "invalid"));
    new DeliverOneTimePasswordExtendedRequest(new ExtendedRequest("1.3.6.1.4.1.30221.2.6.24", 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 63 with ASN1Sequence

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

the class DeliverOneTimePasswordExtendedRequestTestCase method testDecodeValueSequenceMissingAuthID.

/**
 * Tests the behavior when trying to decode an extended request when the value
 * sequence does not include the authentication ID.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test(expectedExceptions = { LDAPException.class })
public void testDecodeValueSequenceMissingAuthID() throws Exception {
    final ASN1Sequence valueSequence = new ASN1Sequence(new ASN1OctetString((byte) 0x81, "password"));
    new DeliverOneTimePasswordExtendedRequest(new ExtendedRequest("1.3.6.1.4.1.30221.2.6.24", 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 64 with ASN1Sequence

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

the class DeliverOneTimePasswordExtendedRequestTestCase method testDecodeLegacyRequest.

/**
 * Tests the ability to decode a legacy request that includes only delivery
 * mechanism names.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test()
public void testDecodeLegacyRequest() throws Exception {
    final ASN1Sequence valueSequence = new ASN1Sequence(new ASN1OctetString((byte) 0x80, "u:auth.id"), new ASN1OctetString((byte) 0x81, "password"), new ASN1Sequence((byte) 0xA2, new ASN1OctetString("SMS"), new ASN1OctetString("Voice"), new ASN1OctetString("E-Mail")));
    DeliverOneTimePasswordExtendedRequest r = new DeliverOneTimePasswordExtendedRequest(new ExtendedRequest("1.3.6.1.4.1.30221.2.6.24", new ASN1OctetString(valueSequence.encode())));
    r = new DeliverOneTimePasswordExtendedRequest(r.duplicate());
    assertNotNull(r);
    assertNotNull(r.getAuthenticationID());
    assertEquals(r.getAuthenticationID(), "u:auth.id");
    assertNotNull(r.getStaticPassword());
    assertEquals(r.getStaticPassword().stringValue(), "password");
    assertNotNull(r.getPreferredDeliveryMechanisms());
    assertEquals(r.getPreferredDeliveryMechanisms(), Arrays.asList("SMS", "Voice", "E-Mail"));
    assertNotNull(r.getPreferredDeliveryMechanismNamesAndIDs());
    assertEquals(r.getPreferredDeliveryMechanismNamesAndIDs().size(), 3);
    assertNull(r.getMessageSubject());
    assertNull(r.getFullTextBeforeOTP());
    assertNull(r.getFullTextAfterOTP());
    assertNull(r.getCompactTextBeforeOTP());
    assertNull(r.getCompactTextAfterOTP());
    assertNotNull(r.getOID());
    assertEquals(r.getOID(), "1.3.6.1.4.1.30221.2.6.24");
    assertNotNull(r.getValue());
    assertNotNull(r.getExtendedRequestName());
    assertNotNull(r.toString());
}
Also used : ASN1OctetString(com.unboundid.asn1.ASN1OctetString) ASN1Sequence(com.unboundid.asn1.ASN1Sequence) ExtendedRequest(com.unboundid.ldap.sdk.ExtendedRequest) Test(org.testng.annotations.Test)

Example 65 with ASN1Sequence

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

the class DeliverOneTimePasswordExtendedResultTestCase method testDecodeValueSequenceInvalidElement.

/**
 * Tests the behavior when trying to decode an extended result whose value
 * sequence has an element with an unexpected type.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test(expectedExceptions = { LDAPException.class })
public void testDecodeValueSequenceInvalidElement() throws Exception {
    final ASN1Sequence valueSequence = new ASN1Sequence(new ASN1OctetString((byte) 0x80, "SMS"), 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 ASN1OctetString((byte) 0x8F, "invalid"));
    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)

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