Search in sources :

Example 11 with PKIXCertPathBuilderResult

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

the class PKIXCertPathBuilderResultTest method testPKIXCertPathBuilderResult05.

/**
     * Test #5 for <code>PKIXCertPathBuilderResult(CertPath, TrustAnchor,
     *   PolicyNode, PublicKey)</code> constructor<br>
     * Assertion: <code>NullPointerException</code>
     * if publicKey is <code>null</code>
     */
public final void testPKIXCertPathBuilderResult05() {
    TrustAnchor ta = TestUtils.getTrustAnchor();
    if (ta == null) {
        fail(getName() + ": not performed (could not create test TrustAnchor)");
    }
    try {
        // pass null
        new PKIXCertPathBuilderResult(new MyCertPath(testEncoding), ta, TestUtils.getPolicyTree(), null);
        fail("NPE expected");
    } catch (NullPointerException e) {
    }
}
Also used : MyCertPath(org.apache.harmony.security.tests.support.cert.MyCertPath) PKIXCertPathBuilderResult(java.security.cert.PKIXCertPathBuilderResult) TrustAnchor(java.security.cert.TrustAnchor)

Example 12 with PKIXCertPathBuilderResult

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

the class PKIXCertPathBuilderResultTest method testGetCertPath.

/**
     * Test for <code>getCertPath()</code> method<br>
     * Assertion: the built and validated <code>CertPath</code>
     * (never <code>null</code>)
     * @throws NoSuchAlgorithmException
     * @throws InvalidKeySpecException
     */
public final void testGetCertPath() throws Exception {
    TrustAnchor ta = TestUtils.getTrustAnchor();
    if (ta == null) {
        fail(getName() + ": not performed (could not create test TrustAnchor)");
    }
    CertPath cp = new MyCertPath(testEncoding);
    CertPathBuilderResult r = new PKIXCertPathBuilderResult(cp, ta, TestUtils.getPolicyTree(), testPublicKey);
    // must return the same reference
    // as passed to the constructor
    assertSame(cp, r.getCertPath());
}
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) MyCertPath(org.apache.harmony.security.tests.support.cert.MyCertPath) CertPath(java.security.cert.CertPath)

Example 13 with PKIXCertPathBuilderResult

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

the class PKIXCertPathBuilderResultTest method test_clone.

public final void test_clone() {
    // Regression for HARMONY-2786.
    TrustAnchor ta = TestUtils.getTrustAnchor();
    assertNotNull(getName() + ": not performed (could not create test TrustAnchor)", ta);
    PKIXCertPathBuilderResult init = new PKIXCertPathBuilderResult(new MyCertPath(testEncoding), ta, TestUtils.getPolicyTree(), testPublicKey);
    PKIXCertPathBuilderResult clone = (PKIXCertPathBuilderResult) init.clone();
    assertSame(init.getCertPath(), clone.getCertPath());
    assertSame(init.getPolicyTree(), clone.getPolicyTree());
    assertSame(init.getPublicKey(), clone.getPublicKey());
    assertSame(init.getTrustAnchor(), clone.getTrustAnchor());
}
Also used : MyCertPath(org.apache.harmony.security.tests.support.cert.MyCertPath) PKIXCertPathBuilderResult(java.security.cert.PKIXCertPathBuilderResult) TrustAnchor(java.security.cert.TrustAnchor)

Example 14 with PKIXCertPathBuilderResult

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

the class PKIXCertPathBuilderResultTest method testPKIXCertPathBuilderResult02.

/**
     * Test #2 for <code>PKIXCertPathBuilderResult(CertPath, TrustAnchor,
     *   PolicyNode, PublicKey)</code> constructor<br>
     * Assertion: policy tree parameter may be <code>null</code>
     * @throws NoSuchAlgorithmException
     * @throws InvalidKeySpecException
     */
public final void testPKIXCertPathBuilderResult02() 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, null, 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 15 with PKIXCertPathBuilderResult

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

the class PKIXCertPathBuilderResultTest method testPKIXCertPathBuilderResult03.

/**
     * Test #3 for <code>PKIXCertPathBuilderResult(CertPath, TrustAnchor,
     *   PolicyNode, PublicKey)</code> constructor<br>
     * Assertion: <code>NullPointerException</code>
     * if certPath is <code>null</code>
     */
public final void testPKIXCertPathBuilderResult03() {
    TrustAnchor ta = TestUtils.getTrustAnchor();
    if (ta == null) {
        fail(getName() + ": not performed (could not create test TrustAnchor)");
    }
    try {
        // pass null
        new PKIXCertPathBuilderResult(null, ta, TestUtils.getPolicyTree(), testPublicKey);
        fail("NPE expected");
    } catch (NullPointerException e) {
    }
}
Also used : PKIXCertPathBuilderResult(java.security.cert.PKIXCertPathBuilderResult) TrustAnchor(java.security.cert.TrustAnchor)

Aggregations

PKIXCertPathBuilderResult (java.security.cert.PKIXCertPathBuilderResult)17 TrustAnchor (java.security.cert.TrustAnchor)12 X509Certificate (java.security.cert.X509Certificate)8 MyCertPath (org.apache.harmony.security.tests.support.cert.MyCertPath)7 CertPathBuilderException (java.security.cert.CertPathBuilderException)6 CertPathBuilderResult (java.security.cert.CertPathBuilderResult)6 HashSet (java.util.HashSet)6 CertPath (java.security.cert.CertPath)5 PKIXBuilderParameters (java.security.cert.PKIXBuilderParameters)5 CollectionCertStoreParameters (java.security.cert.CollectionCertStoreParameters)4 X509CertSelector (java.security.cert.X509CertSelector)4 CertPathBuilder (java.security.cert.CertPathBuilder)3 CertPathValidator (java.security.cert.CertPathValidator)3 CertStore (java.security.cert.CertStore)3 PKIXCertPathValidatorResult (java.security.cert.PKIXCertPathValidatorResult)3 GeneralSecurityException (java.security.GeneralSecurityException)2 InvalidAlgorithmParameterException (java.security.InvalidAlgorithmParameterException)2 InvalidKeyException (java.security.InvalidKeyException)2 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)2 SignatureException (java.security.SignatureException)2