Search in sources :

Example 21 with CertPathValidatorException

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

the class CertPathValidatorExceptionTest method testCertPathValidatorException07.

/**
     * Test for <code>CertPathValidatorException(String, Throwable)</code>
     * constructor Assertion: constructs CertPathValidatorException when
     * <code>cause</code> is null <code>msg</code> is not null
     */
public void testCertPathValidatorException07() {
    CertPathValidatorException tE;
    for (int i = 0; i < msgs.length; i++) {
        tE = new CertPathValidatorException(msgs[i], null);
        assertEquals("getMessage() must return: ".concat(msgs[i]), tE.getMessage(), msgs[i]);
        assertNull("getCause() must return null", tE.getCause());
    }
}
Also used : CertPathValidatorException(java.security.cert.CertPathValidatorException)

Example 22 with CertPathValidatorException

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

the class CertPathValidatorExceptionTest method testCertPathValidatorException14.

/**
     * Test for
     * <code>CertPathValidatorException(String, Throwable, CertPath, int)</code>
     * constructor Assertion: constructs CertPathValidatorException when
     * <code>cause</code> not null <code>msg</code> not null
     * <code>certPath</code> not null <code>index</code><
     * certPath.getCertificates().size()
     */
public void testCertPathValidatorException14() {
    CertPathValidatorException tE;
    myCertPath mcp = new myCertPath("X.509", "");
    CertPath cp = mcp.get("X.509");
    for (int i = 0; i < msgs.length; i++) {
        try {
            tE = new CertPathValidatorException(msgs[i], tCause, cp, -1);
            String getM = tE.getMessage();
            String toS = tCause.toString();
            if (msgs[i].length() > 0) {
                assertTrue("getMessage() must contain ".concat(msgs[i]), getM.indexOf(msgs[i]) != -1);
                if (!getM.equals(msgs[i])) {
                    assertTrue("getMessage() should contain ".concat(toS), getM.indexOf(toS) != -1);
                }
            }
            assertNotNull("getCause() must not return null", tE.getCause());
            assertEquals("getCause() must return ".concat(tCause.toString()), tE.getCause(), tCause);
            assertNotNull("getCertPath() must not return null", tE.getCertPath());
            assertEquals("getCertPath() must return ".concat(cp.toString()), tE.getCertPath(), cp);
            assertEquals("getIndex() must return -1", tE.getIndex(), -1);
        } catch (IndexOutOfBoundsException e) {
            fail("Unexpected IndexOutOfBoundsException was thrown. " + e.toString());
        }
    }
}
Also used : CertPathValidatorException(java.security.cert.CertPathValidatorException) CertPath(java.security.cert.CertPath)

Example 23 with CertPathValidatorException

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

the class CertPathValidatorExceptionTest method testCertPathValidatorException04.

/**
     * Test for <code>CertPathValidatorException(Throwable)</code> constructor
     * Assertion: constructs CertPathValidatorException when <code>cause</code>
     * is null
     */
public void testCertPathValidatorException04() {
    Throwable cause = null;
    CertPathValidatorException tE = new CertPathValidatorException(cause);
    assertNull("getMessage() must return null.", tE.getMessage());
    assertNull("getCause() must return null", tE.getCause());
}
Also used : CertPathValidatorException(java.security.cert.CertPathValidatorException)

Example 24 with CertPathValidatorException

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

the class CertPathValidatorExceptionTest method testCertPathValidatorException15.

/**
     * Test for <code>getCertPath()</code>. Returns the certification path
     * that was being validated when the exception was thrown.
     */
public void testCertPathValidatorException15() {
    CertPathValidatorException tE = new CertPathValidatorException();
    assertNull("getCertPath() must return null.", tE.getCertPath());
    for (int i = 0; i < msgs.length; i++) {
        tE = new CertPathValidatorException(msgs[i]);
        assertNull("getCertPath() must return null ", tE.getCertPath());
    }
    Throwable cause = null;
    tE = new CertPathValidatorException(cause);
    assertNull("getCertPath() must return null.", tE.getCertPath());
    tE = new CertPathValidatorException(tCause);
    assertNull("getCertPath() must return null.", tE.getCertPath());
    for (int i = 0; i < msgs.length; i++) {
        tE = new CertPathValidatorException(msgs[i], tCause);
        assertNull("getCertPath() must return null", tE.getCertPath());
    }
    tE = new CertPathValidatorException(null, null, null, -1);
    assertNull("getCertPath() must return null", tE.getCertPath());
    for (int i = 0; i < msgs.length; i++) {
        try {
            tE = new CertPathValidatorException(msgs[i], tCause, null, -1);
            assertNull("getCertPath() must return null", tE.getCertPath());
        } catch (IndexOutOfBoundsException e) {
            fail("Unexpected exception: " + e.getMessage());
        }
    }
    myCertPath mcp = new myCertPath("X.509", "");
    CertPath cp = mcp.get("X.509");
    for (int i = 0; i < msgs.length; i++) {
        try {
            tE = new CertPathValidatorException(msgs[i], tCause, cp, -1);
            assertNotNull("getCertPath() must not return null", tE.getCertPath());
            assertEquals("getCertPath() must return ".concat(cp.toString()), tE.getCertPath(), cp);
        } catch (IndexOutOfBoundsException e) {
            fail("Unexpected IndexOutOfBoundsException was thrown. " + e.toString());
        }
    }
}
Also used : CertPathValidatorException(java.security.cert.CertPathValidatorException) CertPath(java.security.cert.CertPath)

Example 25 with CertPathValidatorException

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

the class CertPathValidatorExceptionTest method testCertPathValidatorException13.

/**
     * Test for
     * <code>CertPathValidatorException(String, Throwable, CertPath, int)</code>
     * constructor Assertion: constructs CertPathValidatorException when
     * <code>cause</code> not null <code>msg</code> not null
     * <code>certPath</code> not null <code>index</code>< -1 || >=
     * certPath.getCertificates().size() throws: IndexOutOfBoundsException
     */
public void testCertPathValidatorException13() {
    myCertPath mcp = new myCertPath("X.509", "");
    CertPath cp = mcp.get("X.509");
    int[] indx = { -2, -100, 0, 1, 100, Integer.MAX_VALUE, Integer.MIN_VALUE };
    for (int j = 0; j < indx.length; j++) {
        for (int i = 0; i < msgs.length; i++) {
            try {
                new CertPathValidatorException(msgs[i], tCause, cp, indx[j]);
                fail("IndexOutOfBoundsException was not thrown as expected. " + " msg: " + msgs[i] + ", certPath is null and index is " + indx[j]);
            } catch (IndexOutOfBoundsException e) {
            }
        }
    }
}
Also used : CertPathValidatorException(java.security.cert.CertPathValidatorException) CertPath(java.security.cert.CertPath)

Aggregations

CertPathValidatorException (java.security.cert.CertPathValidatorException)92 IOException (java.io.IOException)45 X509Certificate (java.security.cert.X509Certificate)43 ExtCertPathValidatorException (org.bouncycastle.jce.exception.ExtCertPathValidatorException)36 ArrayList (java.util.ArrayList)35 GeneralSecurityException (java.security.GeneralSecurityException)32 List (java.util.List)30 CertPathBuilderException (java.security.cert.CertPathBuilderException)24 CertificateExpiredException (java.security.cert.CertificateExpiredException)24 CertificateNotYetValidException (java.security.cert.CertificateNotYetValidException)24 CRLDistPoint (org.bouncycastle.asn1.x509.CRLDistPoint)23 DistributionPoint (org.bouncycastle.asn1.x509.DistributionPoint)23 IssuingDistributionPoint (org.bouncycastle.asn1.x509.IssuingDistributionPoint)21 ASN1Sequence (org.bouncycastle.asn1.ASN1Sequence)18 Enumeration (java.util.Enumeration)15 Iterator (java.util.Iterator)15 CertificateException (java.security.cert.CertificateException)13 CertPath (java.security.cert.CertPath)12 HashSet (java.util.HashSet)12 Set (java.util.Set)10