Search in sources :

Example 1 with MyCertPath

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

the class TimestampTest method testHashCode.

/*
     * Class under test for String hashCode()
     */
public void testHashCode() {
    Timestamp one = new Timestamp(now, cpath);
    Timestamp two = new Timestamp(now, cpath);
    Timestamp three = new Timestamp(now, new MyCertPath(new byte[] { 10, 20, 30 }));
    Timestamp four = null;
    assertTrue(one.hashCode() == two.hashCode());
    assertTrue(one.hashCode() != three.hashCode());
    assertTrue(two.hashCode() != three.hashCode());
    try {
        four.hashCode();
        fail("NullPointerException expected");
    } catch (NullPointerException e) {
    // expected
    }
}
Also used : MyCertPath(org.apache.harmony.security.tests.support.cert.MyCertPath) Timestamp(java.security.Timestamp)

Example 2 with MyCertPath

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

the class PKIXCertPathBuilderResultTest method testPKIXCertPathBuilderResult01.

//
// Tests
//
/**
     * Test #1 for <code>PKIXCertPathBuilderResult(CertPath, TrustAnchor,
     *   PolicyNode, PublicKey)</code> constructor<br>
     * Assertion: Creates an instance of <code>PKIXCertPathBuilderResult</code>
     * @throws NoSuchAlgorithmException
     * @throws InvalidKeySpecException
     */
public final void testPKIXCertPathBuilderResult01() throws InvalidKeySpecException, NoSuchAlgorithmException {
    TrustAnchor ta = TestUtils.getTrustAnchor();
    if (ta == null) {
        fail(getName() + ": not performed (could not create test TrustAnchor)");
    }
    CertPathBuilderResult r = new PKIXCertPathBuilderResult(new MyCertPath(testEncoding), ta, TestUtils.getPolicyTree(), testPublicKey);
    assertTrue(r instanceof PKIXCertPathBuilderResult);
}
Also used : MyCertPath(org.apache.harmony.security.tests.support.cert.MyCertPath) PKIXCertPathBuilderResult(java.security.cert.PKIXCertPathBuilderResult) CertPathBuilderResult(java.security.cert.CertPathBuilderResult) PKIXCertPathBuilderResult(java.security.cert.PKIXCertPathBuilderResult) TrustAnchor(java.security.cert.TrustAnchor)

Example 3 with MyCertPath

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

the class PKIXCertPathBuilderResultTest method testPKIXCertPathBuilderResult04.

/**
     * Test #4 for <code>PKIXCertPathBuilderResult(CertPath, TrustAnchor,
     *   PolicyNode, PublicKey)</code> constructor<br>
     * Assertion: <code>NullPointerException</code>
     * if trustAnchor is <code>null</code>
     */
public final void testPKIXCertPathBuilderResult04() {
    try {
        // pass null
        new PKIXCertPathBuilderResult(new MyCertPath(testEncoding), null, TestUtils.getPolicyTree(), testPublicKey);
        fail("NPE expected");
    } catch (NullPointerException e) {
    }
}
Also used : MyCertPath(org.apache.harmony.security.tests.support.cert.MyCertPath) PKIXCertPathBuilderResult(java.security.cert.PKIXCertPathBuilderResult)

Example 4 with MyCertPath

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

the class PKIXCertPathBuilderResultTest method testToString.

/**
     * Test for <code>toString()</code> method<br>
     * Assertion: the printable representation of this object
     * @throws NoSuchAlgorithmException
     * @throws InvalidKeySpecException
     */
public final void testToString() throws InvalidKeySpecException, NoSuchAlgorithmException {
    TrustAnchor ta = TestUtils.getTrustAnchor();
    if (ta == null) {
        fail(getName() + ": not performed (could not create test TrustAnchor)");
    }
    CertPathBuilderResult r = new PKIXCertPathBuilderResult(new MyCertPath(testEncoding), ta, TestUtils.getPolicyTree(), testPublicKey);
    assertNotNull(r.toString());
}
Also used : MyCertPath(org.apache.harmony.security.tests.support.cert.MyCertPath) PKIXCertPathBuilderResult(java.security.cert.PKIXCertPathBuilderResult) CertPathBuilderResult(java.security.cert.CertPathBuilderResult) PKIXCertPathBuilderResult(java.security.cert.PKIXCertPathBuilderResult) TrustAnchor(java.security.cert.TrustAnchor)

Example 5 with MyCertPath

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

the class CertPathCertPathRepTest method testCertPathCertPathRep.

/**
     * Test for <code>CertPath.CertPathRep(String type, byte[] data)</code>
     * method<br>
     */
public final void testCertPathCertPathRep() {
    MyCertPath cp = new MyCertPath(testEncoding);
    MyCertPathRep rep = cp.new MyCertPathRep("MyEncoding", testEncoding);
    assertEquals(testEncoding, rep.getData());
    assertEquals("MyEncoding", rep.getType());
    try {
        cp.new MyCertPathRep(null, null);
    } catch (Exception e) {
        fail("Unexpected exeption " + e.getMessage());
    }
}
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)

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