Search in sources :

Example 46 with X509CRLSelector

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

the class X509CRLSelector2Test method testGetIssuers.

/**
 * getIssuers() method testing. Tests if the method return null in the case
 * of not specified issuers, if the returned collection corresponds to the
 * specified issuers and this collection is unmodifiable.
 */
public void testGetIssuers() {
    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.");
    assertNull("The collection should be null.", selector.getIssuers());
    selector.addIssuer(iss1);
    selector.addIssuer(iss2);
    Collection<X500Principal> result = selector.getIssuers();
    try {
        result.add(iss3);
        fail("The returned collection should be unmodifiable.");
    } catch (UnsupportedOperationException e) {
    }
    assertTrue("The collection should contain the specified DN.", result.contains(iss2));
}
Also used : X500Principal(javax.security.auth.x500.X500Principal) X509CRLSelector(java.security.cert.X509CRLSelector)

Example 47 with X509CRLSelector

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

the class X509CRLSelector2Test method testGetCertificateCheckingLjava_X509Certificate.

/**
 * getCertificateChecking() method testing.
 */
public void testGetCertificateCheckingLjava_X509Certificate() throws CertificateException {
    X509CRLSelector selector = new X509CRLSelector();
    CertificateFactory certFact = CertificateFactory.getInstance("X509");
    X509Certificate cert = (X509Certificate) certFact.generateCertificate(new ByteArrayInputStream(TestUtils.getX509Certificate_v3()));
    selector.setCertificateChecking(cert);
    assertEquals(cert, selector.getCertificateChecking());
    selector.setCertificateChecking(null);
    assertNull(selector.getCertificateChecking());
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) CertificateFactory(java.security.cert.CertificateFactory) X509CRLSelector(java.security.cert.X509CRLSelector) X509Certificate(java.security.cert.X509Certificate)

Example 48 with X509CRLSelector

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

the class X509CRLSelector2Test method testSetCertificateCheckingLjava_X509Certificate.

/**
 * setCertificateChecking(X509Certificate) method testing.
 */
public void testSetCertificateCheckingLjava_X509Certificate() throws CertificateException {
    X509CRLSelector selector = new X509CRLSelector();
    CertificateFactory certFact = CertificateFactory.getInstance("X509");
    X509Certificate cert = (X509Certificate) certFact.generateCertificate(new ByteArrayInputStream(TestUtils.getX509Certificate_v3()));
    TestCRL crl = new TestCRL();
    selector.setCertificateChecking(cert);
    assertTrue("The CRL should match the selection criteria.", selector.match(crl));
    assertEquals(cert, selector.getCertificateChecking());
    selector.setCertificateChecking(null);
    assertTrue("The CRL should match the selection criteria.", selector.match(crl));
    assertNull(selector.getCertificateChecking());
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) CertificateFactory(java.security.cert.CertificateFactory) X509CRLSelector(java.security.cert.X509CRLSelector) X509Certificate(java.security.cert.X509Certificate)

Example 49 with X509CRLSelector

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

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 50 with X509CRLSelector

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

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)

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