use of org.apache.harmony.security.tests.support.cert.MyCertPath 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) {
}
}
use of org.apache.harmony.security.tests.support.cert.MyCertPath 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());
}
use of org.apache.harmony.security.tests.support.cert.MyCertPath 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());
}
use of org.apache.harmony.security.tests.support.cert.MyCertPath 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);
}
use of org.apache.harmony.security.tests.support.cert.MyCertPath in project robovm by robovm.
the class CertPathValidator2Test method testValidate.
public void testValidate() throws InvalidAlgorithmParameterException, NoSuchAlgorithmException {
MyCertPath mCP = new MyCertPath(new byte[0]);
CertPathParameters params = new PKIXParameters(TestUtils.getTrustAnchorSet());
CertPathValidator certPV = CertPathValidator.getInstance(defaultAlg);
try {
certPV.validate(mCP, params);
} catch (InvalidAlgorithmParameterException e) {
fail("unexpected exception: " + e);
} catch (CertPathValidatorException e) {
fail("unexpected exception: " + e);
}
try {
certPV.validate(null, params);
fail("NullPointerException must be thrown");
} catch (InvalidAlgorithmParameterException e) {
fail("unexpected exception: " + e);
} catch (CertPathValidatorException e) {
// ok
}
try {
certPV.validate(mCP, null);
fail("InvalidAlgorithmParameterException must be thrown");
} catch (InvalidAlgorithmParameterException e) {
// ok
} catch (CertPathValidatorException e) {
fail("unexpected exception");
}
}
Aggregations