Search in sources :

Example 26 with CertPathValidatorException

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

the class CertPathValidatorExceptionTest method testCertPathValidatorException16.

/**
     * Test for <code>getIndex()</code>. Returns the index of the certificate
     * in the certification path that caused the exception to be thrown. Note
     * that the list of certificates in a CertPath is zero based. If no index
     * has been set, -1 is returned.
     */
public void testCertPathValidatorException16() {
    CertPathValidatorException tE = new CertPathValidatorException();
    assertEquals("getIndex() must be equals -1", -1, tE.getIndex());
    for (int i = 0; i < msgs.length; i++) {
        tE = new CertPathValidatorException(msgs[i]);
        assertEquals("getIndex() must be equals -1", -1, tE.getIndex());
    }
    Throwable cause = null;
    tE = new CertPathValidatorException(cause);
    assertEquals("getIndex() must be equals -1", -1, tE.getIndex());
    tE = new CertPathValidatorException(tCause);
    assertEquals("getIndex() must be equals -1", -1, tE.getIndex());
    for (int i = 0; i < msgs.length; i++) {
        tE = new CertPathValidatorException(msgs[i], tCause);
        assertEquals("getIndex() must be equals -1", -1, tE.getIndex());
    }
    tE = new CertPathValidatorException(null, null, null, -1);
    assertEquals("getIndex() must be equals -1", -1, tE.getIndex());
    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("getIndex() must not return null", tE.getCertPath());
            assertEquals("getIndex() must return ".concat(cp.toString()), tE.getCertPath(), cp);
        } catch (IndexOutOfBoundsException e) {
            fail("Unexpected IndexOutOfBoundsException was thrown. " + e.getMessage());
        }
    }
}
Also used : CertPathValidatorException(java.security.cert.CertPathValidatorException) CertPath(java.security.cert.CertPath)

Example 27 with CertPathValidatorException

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

the class CertPathValidatorExceptionTest method testCertPathValidatorException02.

/**
     * Test for <code>CertPathValidatorException(String)</code> constructor
     * Assertion: constructs CertPathValidatorException with detail message msg.
     * Parameter <code>msg</code> is not null.
     */
public void testCertPathValidatorException02() {
    CertPathValidatorException tE;
    for (int i = 0; i < msgs.length; i++) {
        tE = new CertPathValidatorException(msgs[i]);
        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 28 with CertPathValidatorException

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

the class CertPathValidatorExceptionTest method testCertPathValidatorException05.

/**
     * Test for <code>CertPathValidatorException(Throwable)</code> constructor
     * Assertion: constructs CertPathValidatorException when <code>cause</code>
     * is not null
     */
public void testCertPathValidatorException05() {
    CertPathValidatorException tE = new CertPathValidatorException(tCause);
    if (tE.getMessage() != null) {
        String toS = tCause.toString();
        String getM = tE.getMessage();
        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);
}
Also used : CertPathValidatorException(java.security.cert.CertPathValidatorException)

Example 29 with CertPathValidatorException

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

the class CertPathValidatorExceptionTest method testCertPathValidatorException06.

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

Example 30 with CertPathValidatorException

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

the class CertPathValidatorSpiTest method testCertPathValidatorSpi01.

/**
     * Test for <code>CertPathValidatorSpi</code> constructor Assertion:
     * constructs CertPathValidatorSpi
     */
public void testCertPathValidatorSpi01() throws CertPathValidatorException, InvalidAlgorithmParameterException {
    CertPathValidatorSpi certPathValid = new MyCertPathValidatorSpi();
    CertPathParameters params = null;
    CertPath certPath = null;
    CertPathValidatorResult cpvResult = certPathValid.engineValidate(certPath, params);
    assertNull("Not null CertPathValidatorResult", cpvResult);
    try {
        certPathValid.engineValidate(certPath, params);
        fail("CertPathValidatorException must be thrown");
    } catch (CertPathValidatorException e) {
    }
    try {
        certPathValid.engineValidate(certPath, params);
        fail("InvalidAlgorithmParameterException must be thrown");
    } catch (InvalidAlgorithmParameterException e) {
    }
}
Also used : CertPathValidatorException(java.security.cert.CertPathValidatorException) InvalidAlgorithmParameterException(java.security.InvalidAlgorithmParameterException) CertPathParameters(java.security.cert.CertPathParameters) CertPath(java.security.cert.CertPath) CertPathValidatorResult(java.security.cert.CertPathValidatorResult) MyCertPathValidatorSpi(org.apache.harmony.security.tests.support.cert.MyCertPathValidatorSpi) MyCertPathValidatorSpi(org.apache.harmony.security.tests.support.cert.MyCertPathValidatorSpi) CertPathValidatorSpi(java.security.cert.CertPathValidatorSpi)

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