Search in sources :

Example 41 with ASN1Integer

use of org.webpki.asn1.ASN1Integer in project ldapsdk by pingidentity.

the class EntryChangeNotificationControlTestCase method testConstructor4AllElements.

/**
 * Tests the fourth constructor with a valid control with all elements
 * present.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test()
public void testConstructor4AllElements() throws Exception {
    ASN1Element[] elements = { new ASN1Enumerated(PersistentSearchChangeType.MODIFY_DN.intValue()), new ASN1OctetString("ou=People,dc=example,dc=com"), new ASN1Integer(5) };
    EntryChangeNotificationControl c = new EntryChangeNotificationControl("2.16.840.1.113730.3.4.7", false, new ASN1OctetString(new ASN1Sequence(elements).encode()));
    assertEquals(c.getChangeType().intValue(), 8);
    assertNotNull(c.getPreviousDN());
    assertEquals(c.getPreviousDN(), "ou=People,dc=example,dc=com");
    assertEquals(c.getChangeNumber(), 5);
    assertFalse(c.isCritical());
    assertNotNull(c.getControlName());
    assertNotNull(c.toString());
}
Also used : ASN1OctetString(com.unboundid.asn1.ASN1OctetString) ASN1Sequence(com.unboundid.asn1.ASN1Sequence) ASN1Enumerated(com.unboundid.asn1.ASN1Enumerated) ASN1Element(com.unboundid.asn1.ASN1Element) ASN1Integer(com.unboundid.asn1.ASN1Integer) Test(org.testng.annotations.Test)

Example 42 with ASN1Integer

use of org.webpki.asn1.ASN1Integer in project ldapsdk by pingidentity.

the class VirtualListViewResponseControlTestCase method testConstructor3ValueSequenceFirstElementNotInteger.

/**
 * Tests the third constructor with a value sequence in which the first
 * element cannot be decoded as an integer.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test(expectedExceptions = { LDAPException.class })
public void testConstructor3ValueSequenceFirstElementNotInteger() throws Exception {
    ASN1Element[] elements = { new ASN1OctetString(), new ASN1Integer(10), new ASN1Enumerated(0) };
    new VirtualListViewResponseControl("2.16.840.1.113730.3.4.10", false, new ASN1OctetString(new ASN1Sequence(elements).encode()));
}
Also used : ASN1OctetString(com.unboundid.asn1.ASN1OctetString) ASN1Sequence(com.unboundid.asn1.ASN1Sequence) ASN1Enumerated(com.unboundid.asn1.ASN1Enumerated) ASN1Element(com.unboundid.asn1.ASN1Element) ASN1Integer(com.unboundid.asn1.ASN1Integer) Test(org.testng.annotations.Test)

Example 43 with ASN1Integer

use of org.webpki.asn1.ASN1Integer in project ldapsdk by pingidentity.

the class VirtualListViewResponseControlTestCase method testConstructor3ValueSequenceSecondElementNotEnumerated.

/**
 * Tests the third constructor with a value sequence in which the third
 * element cannot be decoded as an enumerated element.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test(expectedExceptions = { LDAPException.class })
public void testConstructor3ValueSequenceSecondElementNotEnumerated() throws Exception {
    ASN1Element[] elements = { new ASN1Integer(5), new ASN1Integer(10), new ASN1OctetString() };
    new VirtualListViewResponseControl("2.16.840.1.113730.3.4.10", false, new ASN1OctetString(new ASN1Sequence(elements).encode()));
}
Also used : ASN1OctetString(com.unboundid.asn1.ASN1OctetString) ASN1Sequence(com.unboundid.asn1.ASN1Sequence) ASN1Element(com.unboundid.asn1.ASN1Element) ASN1Integer(com.unboundid.asn1.ASN1Integer) Test(org.testng.annotations.Test)

Example 44 with ASN1Integer

use of org.webpki.asn1.ASN1Integer in project ldapsdk by pingidentity.

the class VirtualListViewResponseControlTestCase method testConstructor3WithoutContextID.

/**
 * Tests the third constructor not including a context ID.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test()
public void testConstructor3WithoutContextID() throws Exception {
    ASN1Element[] elements = { new ASN1Integer(10), new ASN1Integer(100), new ASN1Enumerated(0) };
    VirtualListViewResponseControl c = new VirtualListViewResponseControl("2.16.840.1.113730.3.4.10", false, new ASN1OctetString(new ASN1Sequence(elements).encode()));
    assertEquals(c.getTargetPosition(), 10);
    assertEquals(c.getContentCount(), 100);
    assertEquals(c.getResultCode(), ResultCode.SUCCESS);
    assertNull(c.getContextID());
    assertFalse(c.isCritical());
    assertNotNull(c.getControlName());
    assertNotNull(c.toString());
}
Also used : ASN1OctetString(com.unboundid.asn1.ASN1OctetString) ASN1Sequence(com.unboundid.asn1.ASN1Sequence) ASN1Enumerated(com.unboundid.asn1.ASN1Enumerated) ASN1Element(com.unboundid.asn1.ASN1Element) ASN1Integer(com.unboundid.asn1.ASN1Integer) Test(org.testng.annotations.Test)

Example 45 with ASN1Integer

use of org.webpki.asn1.ASN1Integer in project ldapsdk by pingidentity.

the class SimplePagedResultsControlTestCase method testConstructor6EmptyCookie.

/**
 * Tests the sixth constructor with a valid size and an empty cookie.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test()
public void testConstructor6EmptyCookie() throws Exception {
    ASN1Element[] elements = { new ASN1Integer(10), new ASN1OctetString() };
    SimplePagedResultsControl c = new SimplePagedResultsControl("1.2.840.113556.1.4.319", false, new ASN1OctetString(new ASN1Sequence(elements).encode()));
    assertEquals(c.getSize(), 10);
    assertNotNull(c.getCookie());
    assertFalse(c.moreResultsToReturn());
    assertFalse(c.isCritical());
    assertNotNull(c.getControlName());
    assertNotNull(c.toString());
}
Also used : ASN1OctetString(com.unboundid.asn1.ASN1OctetString) ASN1Sequence(com.unboundid.asn1.ASN1Sequence) ASN1Element(com.unboundid.asn1.ASN1Element) ASN1Integer(com.unboundid.asn1.ASN1Integer) Test(org.testng.annotations.Test)

Aggregations

ASN1Integer (org.bouncycastle.asn1.ASN1Integer)213 ASN1Integer (com.unboundid.asn1.ASN1Integer)96 ASN1Sequence (com.unboundid.asn1.ASN1Sequence)94 ASN1EncodableVector (org.bouncycastle.asn1.ASN1EncodableVector)91 IOException (java.io.IOException)89 DERSequence (org.bouncycastle.asn1.DERSequence)89 ASN1Integer (com.github.zhenwei.core.asn1.ASN1Integer)86 BigInteger (java.math.BigInteger)86 ASN1OctetString (com.unboundid.asn1.ASN1OctetString)80 ASN1Element (com.unboundid.asn1.ASN1Element)69 Test (org.testng.annotations.Test)63 ArrayList (java.util.ArrayList)50 ASN1EncodableVector (com.github.zhenwei.core.asn1.ASN1EncodableVector)49 DERSequence (com.github.zhenwei.core.asn1.DERSequence)47 ASN1Sequence (org.bouncycastle.asn1.ASN1Sequence)47 DEROctetString (org.bouncycastle.asn1.DEROctetString)38 ASN1ObjectIdentifier (org.bouncycastle.asn1.ASN1ObjectIdentifier)35 ASN1InputStream (org.bouncycastle.asn1.ASN1InputStream)28 ASN1Encodable (org.bouncycastle.asn1.ASN1Encodable)27 AlgorithmIdentifier (org.bouncycastle.asn1.x509.AlgorithmIdentifier)27