Search in sources :

Example 41 with ASN1Sequence

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

the class ListConfigurationsExtendedResultTestCase method testDecodeValueInvalidConfigType.

/**
 * Tests the behavior when trying to decode a generic extended result whose
 * value sequence contains an element with an invalid configuration type.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test(expectedExceptions = { LDAPException.class })
public void testDecodeValueInvalidConfigType() throws Exception {
    final ASN1Sequence valueSequence = new ASN1Sequence(new ASN1OctetString((byte) 0x80, "config.ldif"), new ASN1OctetString((byte) 0x85, "invalid"));
    new ListConfigurationsExtendedResult(new ExtendedResult(123, ResultCode.SUCCESS, null, null, null, "1.3.6.1.4.1.30221.2.6.27", 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 42 with ASN1Sequence

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

the class GetConfigurationExtendedResultTestCase method testDecodeInvalidConfigType.

/**
 * Tests the behavior when trying to decode a result whose value sequence
 * recognizes an unexpected configuration type.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test(expectedExceptions = { LDAPException.class })
public void testDecodeInvalidConfigType() throws Exception {
    final ASN1Sequence valueSequence = new ASN1Sequence(new ASN1Enumerated((byte) 0x80, 123), new ASN1OctetString((byte) 0x81, "config.ldif"), new ASN1OctetString((byte) 0x82, TEST_CONFIG_FILE_BYTES));
    new GetConfigurationExtendedResult(new ExtendedResult(123, ResultCode.SUCCESS, null, null, null, "1.3.6.1.4.1.30221.2.6.29", new ASN1OctetString(valueSequence.encode()), null));
}
Also used : ASN1OctetString(com.unboundid.asn1.ASN1OctetString) ASN1Sequence(com.unboundid.asn1.ASN1Sequence) ASN1Enumerated(com.unboundid.asn1.ASN1Enumerated) ExtendedResult(com.unboundid.ldap.sdk.ExtendedResult) Test(org.testng.annotations.Test)

Example 43 with ASN1Sequence

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

the class GetSubtreeAccessibilityExtendedResultTestCase method testGetAccessibilityValueSequenceMissingEffectiveTime.

/**
 * Tests the behavior when trying to decode a result whose value sequence has
 * an invalid accessibility state element.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test(expectedExceptions = { LDAPException.class })
public void testGetAccessibilityValueSequenceMissingEffectiveTime() throws Exception {
    final ASN1Sequence valueSequence = new ASN1Sequence(new ASN1OctetString((byte) 0x80, "ou=subtree,dc=example,dc=com"), new ASN1Enumerated((byte) 0x81, 1), new ASN1OctetString((byte) 0x82, "uid=bypass,dc=example,dc=com"));
    new GetSubtreeAccessibilityExtendedResult(new ExtendedResult(1234, ResultCode.OTHER, null, null, null, GetSubtreeAccessibilityExtendedResult.GET_SUBTREE_ACCESSIBILITY_RESULT_OID, new ASN1OctetString(new ASN1Sequence(valueSequence).encode()), null));
}
Also used : ASN1OctetString(com.unboundid.asn1.ASN1OctetString) ASN1Sequence(com.unboundid.asn1.ASN1Sequence) ASN1Enumerated(com.unboundid.asn1.ASN1Enumerated) ExtendedResult(com.unboundid.ldap.sdk.ExtendedResult) Test(org.testng.annotations.Test)

Example 44 with ASN1Sequence

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

the class GetSubtreeAccessibilityExtendedResultTestCase method testGetAccessibilityValueSequenceMissingState.

/**
 * Tests the behavior when trying to decode a result whose value sequence is
 * missing an accessibility state element.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test(expectedExceptions = { LDAPException.class })
public void testGetAccessibilityValueSequenceMissingState() throws Exception {
    final ASN1Sequence valueSequence = new ASN1Sequence(new ASN1OctetString((byte) 0x80, "ou=subtree,dc=example,dc=com"), new ASN1OctetString((byte) 0x82, "uid=bypass,dc=example,dc=com"), new ASN1OctetString((byte) 0x83, "20120101012345.678Z"));
    new GetSubtreeAccessibilityExtendedResult(new ExtendedResult(1234, ResultCode.OTHER, null, null, null, GetSubtreeAccessibilityExtendedResult.GET_SUBTREE_ACCESSIBILITY_RESULT_OID, new ASN1OctetString(new ASN1Sequence(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 45 with ASN1Sequence

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

the class MultiUpdateExtendedRequestTestCase method testDecodeInvalidErrorBehavior.

/**
 * Tests the behavior when trying to decode a multi-update extended request
 * that contains an invalid error behavior value.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test(expectedExceptions = { LDAPException.class })
public void testDecodeInvalidErrorBehavior() throws Exception {
    final ASN1Sequence valueSequence = new ASN1Sequence(new ASN1Enumerated(1234), new ASN1Sequence(new ASN1Sequence(new ASN1OctetString(LDAPMessage.PROTOCOL_OP_TYPE_DELETE_REQUEST, "uid=test.user,ou=People,dc=example,dc=com"))));
    new MultiUpdateExtendedRequest(new ExtendedRequest(MultiUpdateExtendedRequest.MULTI_UPDATE_REQUEST_OID, new ASN1OctetString(valueSequence.encode())));
}
Also used : ASN1OctetString(com.unboundid.asn1.ASN1OctetString) ASN1Sequence(com.unboundid.asn1.ASN1Sequence) ASN1Enumerated(com.unboundid.asn1.ASN1Enumerated) ExtendedRequest(com.unboundid.ldap.sdk.ExtendedRequest) PasswordModifyExtendedRequest(com.unboundid.ldap.sdk.extensions.PasswordModifyExtendedRequest) 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