Search in sources :

Example 51 with X509CRLSelector

use of java.security.cert.X509CRLSelector in project j2objc by google.

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.
 */
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)

Example 52 with X509CRLSelector

use of java.security.cert.X509CRLSelector in project j2objc by google.

the class X509CRLSelector2Test method testMatchLjava_security_cert_X509CRL.

/**
 * match(CRL crl) method testing. Tests if the null object matches to the
 * selector or not.
 */
public void testMatchLjava_security_cert_X509CRL() {
    X509CRLSelector selector = new X509CRLSelector();
    assertFalse("The null object should not match", selector.match((X509CRL) null));
}
Also used : X509CRL(java.security.cert.X509CRL) X509CRLSelector(java.security.cert.X509CRLSelector)

Example 53 with X509CRLSelector

use of java.security.cert.X509CRLSelector in project j2objc by google.

the class X509CRLSelector2Test method testSetIssuersLjava_util_Collection.

/**
 * setIssuers(Collection <X500Principal> issuers) method testing. Tests if
 * CRLs with any issuers match the selector in the case of null issuerNames
 * criteria, if specified issuers match the selector, and if not specified
 * issuer does not match the selector.
 */
public void testSetIssuersLjava_util_Collection() {
    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.");
    TestCRL crl1 = new TestCRL(iss1);
    TestCRL crl2 = new TestCRL(iss2);
    TestCRL crl3 = new TestCRL(iss3);
    selector.setIssuers(null);
    assertTrue("Any CRL issuers should match in the case of null issuers.", selector.match(crl1) && selector.match(crl2));
    ArrayList<X500Principal> issuers = new ArrayList<X500Principal>(2);
    issuers.add(iss1);
    issuers.add(iss2);
    selector.setIssuers(issuers);
    assertTrue("The CRL should match the selection criteria.", selector.match(crl1) && selector.match(crl2));
    assertFalse("The CRL should not match the selection criteria.", selector.match(crl3));
    issuers.add(iss3);
    assertFalse("The internal issuer collection is not protected " + "against the modifications.", selector.match(crl3));
}
Also used : ArrayList(java.util.ArrayList) X500Principal(javax.security.auth.x500.X500Principal) X509CRLSelector(java.security.cert.X509CRLSelector)

Example 54 with X509CRLSelector

use of java.security.cert.X509CRLSelector in project j2objc by google.

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)

Example 55 with X509CRLSelector

use of java.security.cert.X509CRLSelector in project j2objc by google.

the class X509CRLSelectorTest method test_addIssuerNameLjava_lang_String01.

/**
 * java.security.cert.X509CRLSelector#addIssuerName(java.lang.String)
 */
public void test_addIssuerNameLjava_lang_String01() throws Exception {
    // Regression for HARMONY-465
    X509CRLSelector obj = new X509CRLSelector();
    try {
        obj.addIssuerName("234");
        fail("IOException expected");
    } catch (IOException e) {
    // expected
    }
    // Regression for HARMONY-1076
    try {
        new X509CRLSelector().addIssuerName("w=y");
        fail("IOException expected");
    } catch (IOException e) {
    // expected
    }
}
Also used : 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