Search in sources :

Example 1 with X509CRLSelector

use of java.security.cert.X509CRLSelector in project robovm by robovm.

the class X509CRLSelector2Test method testGetMaxCRL.

/**
     * getMaxCRL() method testing. Tests if the method return null in the case
     * of not specified maxCRL criteria, and if the returned value corresponds
     * to the specified one.
     */
public void testGetMaxCRL() {
    X509CRLSelector selector = new X509CRLSelector();
    assertNull("Initially the maxCRL should be null.", selector.getMaxCRL());
    BigInteger maxCRL = new BigInteger("10000");
    selector.setMaxCRLNumber(maxCRL);
    assertTrue("The result should be equal to specified.", maxCRL.equals(selector.getMaxCRL()));
}
Also used : BigInteger(java.math.BigInteger) X509CRLSelector(java.security.cert.X509CRLSelector)

Example 2 with X509CRLSelector

use of java.security.cert.X509CRLSelector in project robovm by robovm.

the class X509CRLSelector2Test method testGetIssuerNames.

/**
     * getIssuerNames() method testing. Tests if the method return null in the
     * case of not specified issuers, if the returned collection corresponds to
     * the specified issuers.
     */
public void testGetIssuerNames() {
    X509CRLSelector selector = new X509CRLSelector();
    byte[] iss1 = new byte[] // manually obtained DER encoding of "O=First Org." issuer name;
    { 48, 21, 49, 19, 48, 17, 6, 3, 85, 4, 10, 19, 10, 70, 105, 114, 115, 116, 32, 79, 114, 103, 46 };
    byte[] iss2 = new byte[] // manually obtained DER encoding of "O=Second Org." issuer name;
    { 48, 22, 49, 20, 48, 18, 6, 3, 85, 4, 10, 19, 11, 83, 101, 99, 111, 110, 100, 32, 79, 114, 103, 46 };
    assertNull("The collection should be null.", selector.getIssuerNames());
    try {
        selector.addIssuerName(iss1);
        selector.addIssuerName(iss2);
    } catch (IOException e) {
        e.printStackTrace();
        fail("Unexpected IOException was thrown.");
    }
    Collection<Object> result = selector.getIssuerNames();
    assertEquals("The collection should contain all of the specified DNs.", 2, result.size());
}
Also used : IOException(java.io.IOException) X509CRLSelector(java.security.cert.X509CRLSelector)

Example 3 with X509CRLSelector

use of java.security.cert.X509CRLSelector in project robovm by robovm.

the class X509CRLSelector2Test method testGetMinCRL.

/**
     * getMinCRL() method testing. Tests if the method return null in the case
     * of not specified minCRL criteria, and if the returned value corresponds
     * to the specified one.
     */
public void testGetMinCRL() {
    X509CRLSelector selector = new X509CRLSelector();
    assertNull("Initially the minCRL should be null.", selector.getMinCRL());
    BigInteger minCRL = new BigInteger("10000");
    selector.setMinCRLNumber(minCRL);
    assertTrue("The result should be equal to specified.", minCRL.equals(selector.getMinCRL()));
}
Also used : BigInteger(java.math.BigInteger) X509CRLSelector(java.security.cert.X509CRLSelector)

Example 4 with X509CRLSelector

use of java.security.cert.X509CRLSelector in project robovm by robovm.

the class X509CRLSelector2Test method testX509CRLSelector.

/**
     * constructor testing.
     *
     */
public void testX509CRLSelector() {
    X509CRLSelector selector = new X509CRLSelector();
    assertNull(selector.getDateAndTime());
    assertNull(selector.getCertificateChecking());
    assertNull(selector.getIssuerNames());
    assertNull(selector.getIssuers());
    assertNull(selector.getMaxCRL());
    assertNull(selector.getMinCRL());
}
Also used : X509CRLSelector(java.security.cert.X509CRLSelector)

Example 5 with X509CRLSelector

use of java.security.cert.X509CRLSelector in project robovm by robovm.

the class X509CRLSelector2Test method testAddIssuerNameLjava_lang_String03.

/**
     * addIssuerName(String name) method testing. Tests if CRLs with specified
     * issuers match the selector, and if not specified issuer does not match
     * the selector.
     */
public void testAddIssuerNameLjava_lang_String03() {
    X509CRLSelector selector = new X509CRLSelector();
    String iss1 = "O=First Org.";
    String iss2 = "O=Second Org.";
    TestCRL crl1 = new TestCRL(new X500Principal(iss1));
    TestCRL crl2 = new TestCRL(new X500Principal(iss2));
    try {
        selector.addIssuerName(iss1);
    } catch (IOException e) {
        e.printStackTrace();
        fail("Unexpected IOException was thrown.");
    }
    assertTrue("The CRL should match the selection criteria.", selector.match(crl1));
    assertFalse("The CRL should not match the selection criteria.", selector.match(crl2));
    try {
        selector.addIssuerName(iss2);
    } catch (IOException e) {
        e.printStackTrace();
        fail("Unexpected IOException was thrown.");
    }
    assertTrue("The CRL should match the selection criteria.", selector.match(crl2));
}
Also used : X500Principal(javax.security.auth.x500.X500Principal) ASN1OctetString(org.apache.harmony.security.asn1.ASN1OctetString) IOException(java.io.IOException) X509CRLSelector(java.security.cert.X509CRLSelector)

Aggregations

X509CRLSelector (java.security.cert.X509CRLSelector)58 X500Principal (javax.security.auth.x500.X500Principal)19 IOException (java.io.IOException)13 BigInteger (java.math.BigInteger)12 Date (java.util.Date)8 X509CRL (java.security.cert.X509CRL)7 X509Certificate (java.security.cert.X509Certificate)5 ByteArrayInputStream (java.io.ByteArrayInputStream)4 CRL (java.security.cert.CRL)4 CertStoreException (java.security.cert.CertStoreException)4 CertificateFactory (java.security.cert.CertificateFactory)4 ArrayList (java.util.ArrayList)4 AndroidOnly (dalvik.annotation.AndroidOnly)3 KeyStoreException (java.security.KeyStoreException)3 URI (java.net.URI)2 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)2 UnrecoverableEntryException (java.security.UnrecoverableEntryException)2 UnrecoverableKeyException (java.security.UnrecoverableKeyException)2 CertStore (java.security.cert.CertStore)2 CertificateException (java.security.cert.CertificateException)2