Search in sources :

Example 21 with MyCertPath

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

the class CertPathValidator3Test method testValidate01.

/**
     * Test for <code>validate(CertPath certpath, CertPathParameters params)</code> method
     * Assertion: throws InvalidAlgorithmParameterException
     * when params is instance of PKIXParameters and
     * certpath is not X.509 type
     *
     */
public void testValidate01() throws InvalidAlgorithmParameterException, CertPathValidatorException {
    if (!PKIXSupport) {
        fail(NotSupportMsg);
        return;
    }
    MyCertPath mCP = new MyCertPath(new byte[0]);
    CertPathParameters params = new PKIXParameters(TestUtils.getTrustAnchorSet());
    CertPathValidator[] certPV = createCPVs();
    assertNotNull("CertPathValidator objects were not created", certPV);
    for (int i = 0; i < certPV.length; i++) {
        try {
            certPV[i].validate(mCP, null);
            fail("InvalidAlgorithmParameterException must be thrown");
        } catch (InvalidAlgorithmParameterException e) {
        }
        try {
            certPV[i].validate(null, params);
            fail("NullPointerException must be thrown");
        } catch (NullPointerException e) {
        }
    }
}
Also used : MyCertPath(org.apache.harmony.security.tests.support.cert.MyCertPath) CertPathValidator(java.security.cert.CertPathValidator) InvalidAlgorithmParameterException(java.security.InvalidAlgorithmParameterException) PKIXParameters(java.security.cert.PKIXParameters) CertPathParameters(java.security.cert.CertPathParameters)

Example 22 with MyCertPath

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

the class CertPathCertPathRepTest method testReadResolve.

public final void testReadResolve() {
    MyCertPath cp = new MyCertPath(testEncoding);
    MyCertPathRep rep = cp.new MyCertPathRep("MyEncoding", testEncoding);
    try {
        Object obj = rep.readResolve();
        fail("ObjectStreamException was not thrown.");
    } catch (ObjectStreamException e) {
    //expected
    }
    rep = cp.new MyCertPathRep("MyEncoding", new byte[] { (byte) 1, (byte) 2, (byte) 3 });
    try {
        rep.readResolve();
        fail("ObjectStreamException expected");
    } catch (ObjectStreamException e) {
        // expected
        System.out.println(e);
    }
}
Also used : MyCertPath(org.apache.harmony.security.tests.support.cert.MyCertPath) MyCertPathRep(org.apache.harmony.security.tests.support.cert.MyCertPath.MyCertPathRep) ObjectStreamException(java.io.ObjectStreamException)

Example 23 with MyCertPath

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

the class CertPathTest method testHashCode.

/**
     * Test for <code>hashCode()</code> method<br>
     * Assertion: returns hash of the <code>Certificate</code> instance
     */
public final void testHashCode() {
    CertPath cp1 = new MyCertPath(testEncoding);
    CertPath cp2 = new MyCertPath(testEncoding);
    CertPath cp3 = new MyCertPath(testEncoding1);
    assertTrue(cp1.hashCode() == cp2.hashCode());
    assertTrue(cp1.hashCode() != cp3.hashCode());
}
Also used : MyCertPath(org.apache.harmony.security.tests.support.cert.MyCertPath) MyCertPath(org.apache.harmony.security.tests.support.cert.MyCertPath) CertPath(java.security.cert.CertPath) MyFailingCertPath(org.apache.harmony.security.tests.support.cert.MyFailingCertPath)

Example 24 with MyCertPath

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

the class CertPathTest method testCertPath.

//
// Tests
//
/**
     * Test for <code>CertPath(String type)</code> method<br>
     * Assertion: returns hash of the <code>Certificate</code> instance
     */
public final void testCertPath() {
    try {
        CertPath cp1 = new MyCertPath(testEncoding);
        assertEquals("MyEncoding", cp1.getType());
        assertTrue(Arrays.equals(testEncoding, cp1.getEncoded()));
    } catch (CertificateEncodingException e) {
        fail("Unexpected CertificateEncodingException " + e.getMessage());
    }
    try {
        CertPath cp1 = new MyCertPath(null);
    } catch (Exception e) {
        fail("Unexpected exception " + e.getMessage());
    }
}
Also used : MyCertPath(org.apache.harmony.security.tests.support.cert.MyCertPath) CertificateEncodingException(java.security.cert.CertificateEncodingException) MyCertPath(org.apache.harmony.security.tests.support.cert.MyCertPath) CertPath(java.security.cert.CertPath) MyFailingCertPath(org.apache.harmony.security.tests.support.cert.MyFailingCertPath) ObjectStreamException(java.io.ObjectStreamException) CertificateEncodingException(java.security.cert.CertificateEncodingException)

Example 25 with MyCertPath

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

the class CertPathTest method testEqualsObject04.

/**
     * Test for <code>equals(Object)</code> method<br>
     * Assertion: object not equals to other which is not
     * instance of <code>CertPath</code>
     */
public final void testEqualsObject04() {
    CertPath cp1 = new MyCertPath(testEncoding);
    assertFalse(cp1.equals("MyEncoding"));
}
Also used : MyCertPath(org.apache.harmony.security.tests.support.cert.MyCertPath) MyCertPath(org.apache.harmony.security.tests.support.cert.MyCertPath) CertPath(java.security.cert.CertPath) MyFailingCertPath(org.apache.harmony.security.tests.support.cert.MyFailingCertPath)

Aggregations

MyCertPath (org.apache.harmony.security.tests.support.cert.MyCertPath)27 CertPath (java.security.cert.CertPath)13 MyFailingCertPath (org.apache.harmony.security.tests.support.cert.MyFailingCertPath)12 PKIXCertPathBuilderResult (java.security.cert.PKIXCertPathBuilderResult)7 TrustAnchor (java.security.cert.TrustAnchor)6 ObjectStreamException (java.io.ObjectStreamException)4 CertPathBuilderResult (java.security.cert.CertPathBuilderResult)4 InvalidAlgorithmParameterException (java.security.InvalidAlgorithmParameterException)3 CertPathValidator (java.security.cert.CertPathValidator)3 CertPathParameters (java.security.cert.CertPathParameters)2 PKIXParameters (java.security.cert.PKIXParameters)2 MyCertPathRep (org.apache.harmony.security.tests.support.cert.MyCertPath.MyCertPathRep)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 ObjectOutputStream (java.io.ObjectOutputStream)1 Timestamp (java.security.Timestamp)1 CertPathValidatorException (java.security.cert.CertPathValidatorException)1 CertificateEncodingException (java.security.cert.CertificateEncodingException)1 CertificateException (java.security.cert.CertificateException)1 CertificateFactory (java.security.cert.CertificateFactory)1