Search in sources :

Example 1 with MyCertPathValidatorSpi

use of org.apache.harmony.security.tests.support.cert.MyCertPathValidatorSpi in project robovm by robovm.

the class invalidParams method testCertPathValidator12.

/**
     * Test for
     * <code>CertPathValidator</code> constructor
     * Assertion: returns CertPathValidator object
     */
public void testCertPathValidator12() throws CertificateException, NoSuchProviderException, NoSuchAlgorithmException, CertPathValidatorException, InvalidAlgorithmParameterException {
    if (!PKIXSupport) {
        fail(NotSupportMsg);
        return;
    }
    CertPathValidatorSpi spi = new MyCertPathValidatorSpi();
    CertPathValidator certPV = new myCertPathValidator(spi, defaultProvider, defaultType);
    assertEquals("Incorrect algorithm", certPV.getAlgorithm(), defaultType);
    assertEquals("Incorrect provider", certPV.getProvider(), defaultProvider);
    certPV.validate(null, null);
    try {
        certPV.validate(null, null);
        fail("CertPathValidatorException must be thrown");
    } catch (CertPathValidatorException e) {
    }
    certPV = new myCertPathValidator(null, null, null);
    assertNull("Incorrect algorithm", certPV.getAlgorithm());
    assertNull("Incorrect provider", certPV.getProvider());
    try {
        certPV.validate(null, null);
        fail("NullPointerException must be thrown");
    } catch (NullPointerException e) {
    }
}
Also used : CertPathValidator(java.security.cert.CertPathValidator) CertPathValidatorException(java.security.cert.CertPathValidatorException) MyCertPathValidatorSpi(org.apache.harmony.security.tests.support.cert.MyCertPathValidatorSpi) MyCertPathValidatorSpi(org.apache.harmony.security.tests.support.cert.MyCertPathValidatorSpi) CertPathValidatorSpi(java.security.cert.CertPathValidatorSpi)

Example 2 with MyCertPathValidatorSpi

use of org.apache.harmony.security.tests.support.cert.MyCertPathValidatorSpi 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)2 CertPathValidatorSpi (java.security.cert.CertPathValidatorSpi)2 MyCertPathValidatorSpi (org.apache.harmony.security.tests.support.cert.MyCertPathValidatorSpi)2 InvalidAlgorithmParameterException (java.security.InvalidAlgorithmParameterException)1 CertPath (java.security.cert.CertPath)1 CertPathParameters (java.security.cert.CertPathParameters)1 CertPathValidator (java.security.cert.CertPathValidator)1 CertPathValidatorResult (java.security.cert.CertPathValidatorResult)1