Search in sources :

Example 6 with X509CRLSelector

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

the class X509CRLSelector2Test method testAddIssuerName$B.

/**
     * addIssuerName(byte[] name) method testing. Tests if CRLs with specified
     * issuers match the selector, and if not specified issuer does not match
     * the selector.
     */
public void testAddIssuerName$B() {
    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 };
    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) IOException(java.io.IOException) X509CRLSelector(java.security.cert.X509CRLSelector)

Example 7 with X509CRLSelector

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

the class X509CRLSelector2Test method testClone.

/**
     * clone() method testing. Tests if the selector is cloned correctly: the
     * crl which matche to the initial selector should match to the clone and
     * the change of clone should not cause the change of initial selector.
     */
@AndroidOnly("Uses specific classes: " + "org.apache.harmony.security.asn1.ASN1OctetString, " + "org.apache.harmony.security.asn1.ASN1Integer.")
public void testClone() {
    X509CRLSelector selector = new X509CRLSelector();
    X500Principal iss1 = new X500Principal("O=First Org.");
    X500Principal iss2 = new X500Principal("O=Second Org.");
    X500Principal iss3 = new X500Principal("O=Third Org.");
    BigInteger minCRL = new BigInteger("10000");
    BigInteger maxCRL = new BigInteger("10000");
    Date date = new Date(200);
    selector.addIssuer(iss1);
    selector.addIssuer(iss2);
    selector.setMinCRLNumber(minCRL);
    selector.setMaxCRLNumber(maxCRL);
    selector.setDateAndTime(date);
    X509CRLSelector clone = (X509CRLSelector) selector.clone();
    TestCRL crl = new TestCRL(iss1);
    crl.setCrlNumber(minCRL);
    crl.setUpdateDates(new Date(200), new Date(200));
    assertTrue("The specified CRL should match the clone selector.", selector.match(crl));
    clone.addIssuer(iss3);
    assertFalse("The changes of the clone selector should not cause " + "the changes of initial object", selector.getIssuerNames().size() == 3);
}
Also used : X500Principal(javax.security.auth.x500.X500Principal) BigInteger(java.math.BigInteger) X509CRLSelector(java.security.cert.X509CRLSelector) Date(java.util.Date) AndroidOnly(dalvik.annotation.AndroidOnly)

Example 8 with X509CRLSelector

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

the class X509CRLSelectorTest method test_addIssuerNameLjava_lang_String02.

/**
     * java.security.cert.X509CRLSelector#addIssuerName(java.lang.String)
     */
public void test_addIssuerNameLjava_lang_String02() throws IOException {
    // Regression for HARMONY-736
    X509CRLSelector selector = new X509CRLSelector();
    // no exception for null
    selector.addIssuerName((String) null);
}
Also used : X509CRLSelector(java.security.cert.X509CRLSelector)

Example 9 with X509CRLSelector

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

the class X509CRLSelectorTest method test_setIssuerNamesLjava_util_Collection01.

/**
     * setIssuerNames(Collection <?> names)
     */
public void test_setIssuerNamesLjava_util_Collection01() throws IOException {
    // Regression for HARMONY-737
    X509CRLSelector selector = new X509CRLSelector();
    selector.setIssuerNames(new TreeSet<Comparable>() {

        private static final long serialVersionUID = 6009545505321092498L;

        public Iterator<Comparable> iterator() {
            return null;
        }
    });
}
Also used : Iterator(java.util.Iterator) X509CRLSelector(java.security.cert.X509CRLSelector)

Example 10 with X509CRLSelector

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

the class X509CRLSelectorTest method testGetIssuersImmutable.

public void testGetIssuersImmutable() {
    X509CRLSelector crlSelector = new X509CRLSelector();
    crlSelector.addIssuer(PRINCIPAL);
    Collection<X500Principal> issuers = crlSelector.getIssuers();
    try {
        issuers.clear();
        fail();
    } catch (UnsupportedOperationException expected) {
    }
}
Also used : X500Principal(javax.security.auth.x500.X500Principal) X509CRLSelector(java.security.cert.X509CRLSelector)

Aggregations

X509CRLSelector (java.security.cert.X509CRLSelector)29 X500Principal (javax.security.auth.x500.X500Principal)9 IOException (java.io.IOException)7 BigInteger (java.math.BigInteger)6 Date (java.util.Date)4 AndroidOnly (dalvik.annotation.AndroidOnly)3 X509CRL (java.security.cert.X509CRL)3 ByteArrayInputStream (java.io.ByteArrayInputStream)2 CRL (java.security.cert.CRL)2 CertStoreException (java.security.cert.CertStoreException)2 CertificateFactory (java.security.cert.CertificateFactory)2 X509Certificate (java.security.cert.X509Certificate)2 ArrayList (java.util.ArrayList)2 ASN1OctetString (org.apache.harmony.security.asn1.ASN1OctetString)2 InputStream (java.io.InputStream)1 HttpURLConnection (java.net.HttpURLConnection)1 URI (java.net.URI)1 URLConnection (java.net.URLConnection)1 KeyStoreException (java.security.KeyStoreException)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1