Search in sources :

Example 21 with TrustAnchor

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

the class PKIXCertPathValidatorResultTest method testPKIXCertPathValidatorResult01.

//
// Tests
//
/**
     * Test #1 for <code>PKIXCertPathValidatorResult(TrustAnchor,
     * PolicyNode, PublicKey)</code> constructor<br>
     * Assertion: creates an instance of
     * <code>PKIXCertPathValidatorResult</code>
     *
     * @throws NoSuchAlgorithmException
     * @throws InvalidKeySpecException
     */
public final void testPKIXCertPathValidatorResult01() throws InvalidKeySpecException, NoSuchAlgorithmException {
    TrustAnchor ta = TestUtils.getTrustAnchor();
    if (ta == null) {
        fail(getName() + ": not performed (could not create test TrustAnchor)");
    }
    new PKIXCertPathValidatorResult(ta, TestUtils.getPolicyTree(), testPublicKey);
}
Also used : PKIXCertPathValidatorResult(java.security.cert.PKIXCertPathValidatorResult) TrustAnchor(java.security.cert.TrustAnchor)

Example 22 with TrustAnchor

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

the class PKIXCertPathValidatorResultTest method testGetPolicyTree01.

/**
     * Test for <code>getPolicyTree()</code> method<br>
     * Assertion: returns the root node of the valid
     * policy tree or <code>null</code> if there are
     * no valid policies
     * @throws NoSuchAlgorithmException
     * @throws InvalidKeySpecException
     */
public final void testGetPolicyTree01() throws Exception {
    TrustAnchor ta = TestUtils.getTrustAnchor();
    if (ta == null) {
        fail(getName() + ": not performed (could not create test TrustAnchor)");
    }
    // valid policy tree case;
    PolicyNode pn = TestUtils.getPolicyTree();
    PKIXCertPathValidatorResult vr = new PKIXCertPathValidatorResult(ta, pn, testPublicKey);
    // must return the same reference passed
    // as a parameter to the constructor
    assertSame(pn, vr.getPolicyTree());
}
Also used : PKIXCertPathValidatorResult(java.security.cert.PKIXCertPathValidatorResult) TrustAnchor(java.security.cert.TrustAnchor) PolicyNode(java.security.cert.PolicyNode)

Example 23 with TrustAnchor

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

the class PKIXCertPathValidatorResultTest method testToString01.

/**
     * Test #1 for <code>toString()</code> method<br>
     * Assertion: Returns a formatted string describing this object
     * @throws NoSuchAlgorithmException
     * @throws InvalidKeySpecException
     */
public final void testToString01() throws Exception {
    TrustAnchor ta = TestUtils.getTrustAnchor();
    if (ta == null) {
        fail(getName() + ": not performed (could not create test TrustAnchor)");
    }
    PKIXCertPathValidatorResult vr = new PKIXCertPathValidatorResult(ta, TestUtils.getPolicyTree(), testPublicKey);
    assertNotNull(vr.toString());
}
Also used : PKIXCertPathValidatorResult(java.security.cert.PKIXCertPathValidatorResult) TrustAnchor(java.security.cert.TrustAnchor)

Example 24 with TrustAnchor

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

the class PKIXCertPathValidatorResultTest method testGetPolicyTree02.

/**
     * Test for <code>getPolicyTree()</code> method<br>
     * Assertion: returns the root node of the valid
     * policy tree or <code>null</code> if there are
     * no valid policies
     * @throws NoSuchAlgorithmException
     * @throws InvalidKeySpecException
     */
public final void testGetPolicyTree02() throws Exception {
    TrustAnchor ta = TestUtils.getTrustAnchor();
    if (ta == null) {
        fail(getName() + ": not performed (could not create test TrustAnchor)");
    }
    // no valid policy tree case (null)
    PKIXCertPathValidatorResult vr = new PKIXCertPathValidatorResult(ta, null, testPublicKey);
    // must return the same reference passed
    // as a parameter to the constructor
    assertNull(vr.getPolicyTree());
}
Also used : PKIXCertPathValidatorResult(java.security.cert.PKIXCertPathValidatorResult) TrustAnchor(java.security.cert.TrustAnchor)

Example 25 with TrustAnchor

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

the class PKIXCertPathValidatorResultTest method testPKIXCertPathValidatorResult03.

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

Aggregations

TrustAnchor (java.security.cert.TrustAnchor)85 X509Certificate (java.security.cert.X509Certificate)34 PublicKey (java.security.PublicKey)24 X500Principal (javax.security.auth.x500.X500Principal)21 PKIXParameters (java.security.cert.PKIXParameters)17 TestKeyPair (org.apache.harmony.security.tests.support.TestKeyPair)16 HashSet (java.util.HashSet)15 CertificateFactory (java.security.cert.CertificateFactory)14 PKIXBuilderParameters (java.security.cert.PKIXBuilderParameters)13 PKIXCertPathValidatorResult (java.security.cert.PKIXCertPathValidatorResult)13 PKIXCertPathBuilderResult (java.security.cert.PKIXCertPathBuilderResult)12 X509CertSelector (java.security.cert.X509CertSelector)12 CertPathValidatorException (java.security.cert.CertPathValidatorException)11 ArrayList (java.util.ArrayList)11 InvalidAlgorithmParameterException (java.security.InvalidAlgorithmParameterException)10 ByteArrayInputStream (java.io.ByteArrayInputStream)8 IOException (java.io.IOException)7 CertPath (java.security.cert.CertPath)7 CertificateException (java.security.cert.CertificateException)7 Iterator (java.util.Iterator)7