use of java.security.cert.PKIXParameters in project robovm by robovm.
the class OldPKIXParametersTest method testToString.
/**
* Test for <code>toString</code> method<br>
*/
public final void testToString() throws Exception {
Set<TrustAnchor> taSet = TestUtils.getTrustAnchorSet();
if (taSet == null) {
fail(getName() + ": not performed (could not create test TrustAnchor set)");
}
PKIXParameters p = new PKIXParameters(taSet);
assertNotNull(p.toString());
PKIXParameters p1 = null;
try {
p1.toString();
fail("NullPointerException expected");
} catch (NullPointerException e) {
// expected
}
}
use of java.security.cert.PKIXParameters in project robovm by robovm.
the class OldPKIXParametersTest method testIsRevocationEnabled.
/**
* Test for <code>isPolicyMappingInhibited()</code> method<br>
* Assertion: returns the current value of the RevocationEnabled flag
* Assertion: when a <code>PKIXParameters</code> object is created, this
* flag is set to true
*
* @throws InvalidAlgorithmParameterException
*/
public final void testIsRevocationEnabled() throws Exception {
Set<TrustAnchor> taSet = TestUtils.getTrustAnchorSet();
if (taSet == null) {
fail(getName() + ": not performed (could not create test TrustAnchor set)");
}
PKIXParameters p = new PKIXParameters(taSet);
assertTrue(p.isRevocationEnabled());
CertificateFactory cf = CertificateFactory.getInstance("X.509");
TestUtils.initCertPathSSCertChain();
Set<TrustAnchor> taSet2 = Collections.singleton(new TrustAnchor(TestUtils.rootCertificateSS, null));
p = new PKIXParameters(taSet2);
assertTrue(p.isRevocationEnabled());
p.setRevocationEnabled(false);
assertFalse(p.isRevocationEnabled());
}
use of java.security.cert.PKIXParameters in project robovm by robovm.
the class OldPKIXParametersTest method testPKIXParametersKeyStore04.
/**
* Test #4 for <code>PKIXParameters(KeyStore)</code> constructor<br>
*
* @throws InvalidAlgorithmParameterException
* @throws KeyStoreException
*/
@BrokenTest("Fails in CTS environment, but passes in CoreTestRunner")
public final void testPKIXParametersKeyStore04() throws Exception {
KeyStore store = KeyStore.getInstance("PKCS12");
KeyStoreTestPKCS12 k = new KeyStoreTestPKCS12();
ByteArrayInputStream stream = new ByteArrayInputStream(k.keyStoreData);
try {
PKIXParameters p = new PKIXParameters(store);
} catch (KeyStoreException e) {
// ok
}
store = KeyStore.getInstance("PKCS12");
store.load(stream, new String(KeyStoreTestPKCS12.keyStorePassword).toCharArray());
stream.close();
try {
PKIXParameters p = new PKIXParameters(store);
} catch (InvalidAlgorithmParameterException e) {
// ok
}
KeyStore keystore = KeyStore.getInstance(KeyStore.getDefaultType());
keystore.load(null, null);
keystore.setCertificateEntry("test", TestUtils.rootCertificateSS);
PKIXParameters p = new PKIXParameters(keystore);
}
use of java.security.cert.PKIXParameters in project robovm by robovm.
the class OldPKIXParametersTest method testIsPolicyMappingInhibited.
/**
* Test for <code>isPolicyMappingInhibited()</code> method<br>
* Assertion: returns true if policy mapping is inhibited, false otherwise
* Assertion: by default, policy mapping is not inhibited (the flag is
* false)
*
* @throws InvalidAlgorithmParameterException
*/
public final void testIsPolicyMappingInhibited() throws Exception {
Set<TrustAnchor> taSet = TestUtils.getTrustAnchorSet();
if (taSet == null) {
fail(getName() + ": not performed (could not create test TrustAnchor set)");
}
PKIXParameters p = new PKIXParameters(taSet);
assertFalse(p.isPolicyMappingInhibited());
CertificateFactory cf = CertificateFactory.getInstance("X.509");
TestUtils.initCertPathSSCertChain();
Set<TrustAnchor> taSet2 = Collections.singleton(new TrustAnchor(TestUtils.rootCertificateSS, null));
p = new PKIXParameters(taSet2);
assertFalse(p.isPolicyMappingInhibited());
p.setPolicyMappingInhibited(true);
assertTrue(p.isRevocationEnabled());
}
use of java.security.cert.PKIXParameters in project robovm by robovm.
the class CertificateTest method testVerifyMD2_chain.
public void testVerifyMD2_chain() throws Exception {
CertificateFactory certificateFactory = CertificateFactory.getInstance("X509");
// First check with the trust anchor not included in the chain
CertPath path = certificateFactory.generateCertPath(getCertList(true, false));
CertPathValidator certPathValidator = CertPathValidator.getInstance("PKIX");
PKIXParameters params = createPKIXParams();
CertPathValidatorResult res = certPathValidator.validate(path, params);
assertTrue("wrong result type", res instanceof PKIXCertPathValidatorResult);
PKIXCertPathValidatorResult r = (PKIXCertPathValidatorResult) res;
assertTrue("Wrong trust anchor returned", params.getTrustAnchors().contains(r.getTrustAnchor()));
// Now check with the trust anchor included in the chain
path = certificateFactory.generateCertPath(getCertList(true, true));
certPathValidator = CertPathValidator.getInstance("PKIX");
params = createPKIXParams();
if (StandardNames.IS_RI) {
res = certPathValidator.validate(path, params);
assertTrue("wrong result type", res instanceof PKIXCertPathValidatorResult);
r = (PKIXCertPathValidatorResult) res;
assertTrue("Wrong trust anchor returned", params.getTrustAnchors().contains(r.getTrustAnchor()));
} else {
try {
certPathValidator.validate(path, params);
fail();
} catch (CertPathValidatorException expected) {
}
}
}
Aggregations