Search in sources :

Example 31 with ASN1Boolean

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

the class StreamDirectoryValuesExtendedRequestTestCase method testConstructor2NoBaseDN.

/**
 * Tests the behavior of the second constructor with a request that does not
 * have a base DN.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test(expectedExceptions = { LDAPException.class })
public void testConstructor2NoBaseDN() throws Exception {
    ASN1Element[] idElements = { new ASN1Enumerated((byte) 0x80, 0x02), new ASN1Boolean((byte) 0x81, true) };
    ASN1Element[] svElements = { new ASN1Sequence((byte) 0xA1, idElements), new ASN1Integer((byte) 0x83, -1) };
    ExtendedRequest r = new ExtendedRequest(StreamDirectoryValuesExtendedRequest.STREAM_DIRECTORY_VALUES_REQUEST_OID, new ASN1OctetString(new ASN1Sequence(svElements).encode()));
    new StreamDirectoryValuesExtendedRequest(r);
}
Also used : ASN1OctetString(com.unboundid.asn1.ASN1OctetString) ASN1Sequence(com.unboundid.asn1.ASN1Sequence) ASN1Enumerated(com.unboundid.asn1.ASN1Enumerated) ASN1Element(com.unboundid.asn1.ASN1Element) ExtendedRequest(com.unboundid.ldap.sdk.ExtendedRequest) ASN1Boolean(com.unboundid.asn1.ASN1Boolean) ASN1Integer(com.unboundid.asn1.ASN1Integer) Test(org.testng.annotations.Test)

Example 32 with ASN1Boolean

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

the class PasswordQualityRequirementValidationResultTestCase method testDecodeUnexpectedElementType.

/**
 * Tests the behavior when trying to decode an ASN.1 element whose sequence
 * contains an unexpected element type.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test(expectedExceptions = { LDAPException.class })
public void testDecodeUnexpectedElementType() throws Exception {
    final ASN1Sequence s = new ASN1Sequence(new PasswordQualityRequirement("description").encode(), new ASN1Boolean(true), new ASN1OctetString((byte) 0x12, "unexpected element type"));
    PasswordQualityRequirementValidationResult.decode(s);
}
Also used : PasswordQualityRequirement(com.unboundid.ldap.sdk.unboundidds.extensions.PasswordQualityRequirement) ASN1OctetString(com.unboundid.asn1.ASN1OctetString) ASN1Sequence(com.unboundid.asn1.ASN1Sequence) ASN1Boolean(com.unboundid.asn1.ASN1Boolean) Test(org.testng.annotations.Test)

Example 33 with ASN1Boolean

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

the class UnboundIDExternallyProcessedAuthenticationBindRequestTestCase method testDecodeCredentialsMissingUserDN.

/**
 * Tests the behavior when trying to decode an ASN.1 element that represents
 * encoded credentials that would be valid except that it is missing the
 * required userDN element.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test(expectedExceptions = { LDAPException.class })
public void testDecodeCredentialsMissingUserDN() throws Exception {
    final ASN1Sequence credSequence = new ASN1Sequence(new ASN1OctetString((byte) 0x81, "TEST"), new ASN1Boolean((byte) 0x82, true));
    UnboundIDExternallyProcessedAuthenticationBindRequest.decodeSASLCredentials(new ASN1OctetString(credSequence.encode()));
}
Also used : ASN1OctetString(com.unboundid.asn1.ASN1OctetString) ASN1Sequence(com.unboundid.asn1.ASN1Sequence) ASN1Boolean(com.unboundid.asn1.ASN1Boolean) Test(org.testng.annotations.Test)

Example 34 with ASN1Boolean

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

the class UnboundIDExternallyProcessedAuthenticationBindRequestTestCase method testDecodeValidFullCredentials.

/**
 * Tests the behavior when trying to decode an ASN.1 element that represents
 * a valid set of encoded credentials with a full encoding.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test()
public void testDecodeValidFullCredentials() throws Exception {
    final ASN1Sequence credSequence = new ASN1Sequence(new ASN1OctetString((byte) 0x80, "u:test.user"), new ASN1OctetString((byte) 0x81, "TEST"), new ASN1Boolean((byte) 0x82, false), new ASN1OctetString((byte) 0x83, "It didn't work"), new ASN1Boolean((byte) 0x84, true), new ASN1Boolean((byte) 0x85, true), new ASN1OctetString((byte) 0x86, "127.0.0.1"), new ASN1Sequence((byte) 0xA7, new ASN1Sequence(new ASN1OctetString("name1"), new ASN1OctetString("value1")), new ASN1Sequence(new ASN1OctetString("name2"), new ASN1OctetString("value2"))));
    final UnboundIDExternallyProcessedAuthenticationBindRequest r = UnboundIDExternallyProcessedAuthenticationBindRequest.decodeSASLCredentials(new ASN1OctetString(credSequence.encode()), new Control("1.2.3.4"), new Control("5.6.7.8"));
    assertNotNull(r);
    assertNotNull(r.getSASLMechanismName());
    assertEquals(r.getSASLMechanismName(), "UNBOUNDID-EXTERNALLY-PROCESSED-AUTHENTICATION");
    assertNotNull(r.getAuthenticationID());
    assertEquals(r.getAuthenticationID(), "u:test.user");
    assertNotNull(r.getExternalMechanismName());
    assertEquals(r.getExternalMechanismName(), "TEST");
    assertFalse(r.externalAuthenticationWasSuccessful());
    assertNotNull(r.getExternalAuthenticationFailureReason());
    assertEquals(r.getExternalAuthenticationFailureReason(), "It didn't work");
    assertTrue(r.externalAuthenticationWasPasswordBased());
    assertTrue(r.externalAuthenticationWasSecure());
    assertNotNull(r.getEndClientIPAddress());
    assertEquals(r.getEndClientIPAddress(), "127.0.0.1");
    assertNotNull(r.getAdditionalAccessLogProperties());
    assertEquals(r.getAdditionalAccessLogProperties().size(), 2);
    assertEquals(r.getAdditionalAccessLogProperties().get("name1"), "value1");
    assertEquals(r.getAdditionalAccessLogProperties().get("name2"), "value2");
    assertNotNull(r.getControls());
    assertEquals(r.getControls().length, 2);
    assertNotNull(r.toString());
    final ArrayList<String> toCodeLineList = new ArrayList<String>(10);
    r.toCode(toCodeLineList, "testMinimalConstructorSuccess", 5, true);
    assertFalse(toCodeLineList.isEmpty());
}
Also used : ASN1OctetString(com.unboundid.asn1.ASN1OctetString) Control(com.unboundid.ldap.sdk.Control) ASN1Sequence(com.unboundid.asn1.ASN1Sequence) ArrayList(java.util.ArrayList) ASN1Boolean(com.unboundid.asn1.ASN1Boolean) ASN1OctetString(com.unboundid.asn1.ASN1OctetString) Test(org.testng.annotations.Test)

Example 35 with ASN1Boolean

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

the class AssuredReplicationResponseControlTestCase method testDecodeValueSequenceUnexpectedElement.

/**
 * Tests the behavior when trying to decode a control whose value sequence
 * contains an unexpected element.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test(expectedExceptions = { LDAPException.class })
public void testDecodeValueSequenceUnexpectedElement() throws Exception {
    final ASN1Sequence valueSequence = new ASN1Sequence(new ASN1Boolean((byte) 0x81, true), new ASN1Boolean((byte) 0x84, true), new ASN1OctetString((byte) 0x8F, "foo"));
    new AssuredReplicationResponseControl("1.3.6.1.4.1.30221.2.5.29", false, new ASN1OctetString(valueSequence.encode()));
}
Also used : ASN1OctetString(com.unboundid.asn1.ASN1OctetString) ASN1Sequence(com.unboundid.asn1.ASN1Sequence) ASN1Boolean(com.unboundid.asn1.ASN1Boolean) Test(org.testng.annotations.Test)

Aggregations

ASN1Boolean (com.unboundid.asn1.ASN1Boolean)51 ASN1OctetString (com.unboundid.asn1.ASN1OctetString)51 ASN1Sequence (com.unboundid.asn1.ASN1Sequence)51 ASN1Element (com.unboundid.asn1.ASN1Element)38 NotNull (com.unboundid.util.NotNull)32 ArrayList (java.util.ArrayList)32 ASN1Integer (com.unboundid.asn1.ASN1Integer)15 Test (org.testng.annotations.Test)14 ASN1Enumerated (com.unboundid.asn1.ASN1Enumerated)12 ASN1Boolean (com.github.zhenwei.core.asn1.ASN1Boolean)5 Nullable (com.unboundid.util.Nullable)5 IOException (java.io.IOException)5 ASN1Integer (com.github.zhenwei.core.asn1.ASN1Integer)4 ASN1Sequence (com.github.zhenwei.core.asn1.ASN1Sequence)4 ASN1TaggedObject (com.github.zhenwei.core.asn1.ASN1TaggedObject)4 ASN1Set (com.unboundid.asn1.ASN1Set)4 DERTaggedObject (com.github.zhenwei.core.asn1.DERTaggedObject)3 ASN1Long (com.unboundid.asn1.ASN1Long)3 Control (com.unboundid.ldap.sdk.Control)3 ASN1Boolean (org.bouncycastle.asn1.ASN1Boolean)3