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);
}
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())));
}
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())));
}
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());
}
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));
}
Aggregations