use of java.security.cert.TrustAnchor in project scdl by passy.
the class SystemKeyStore method getPkixParameters.
private PKIXParameters getPkixParameters() {
try {
final KeyStore trustStore = this.getTrustStore();
final Set<TrustAnchor> trusted = new HashSet<TrustAnchor>();
for (final Enumeration<String> aliases = trustStore.aliases(); aliases.hasMoreElements(); ) {
final String alias = aliases.nextElement();
final X509Certificate cert = (X509Certificate) trustStore.getCertificate(alias);
if (cert != null) {
trusted.add(new TrustAnchor(cert, null));
}
}
final PKIXParameters parameters = new PKIXParameters(trusted);
parameters.setRevocationEnabled(false);
return parameters;
} catch (final InvalidAlgorithmParameterException e) {
throw new AssertionError(e);
} catch (final KeyStoreException e) {
throw new AssertionError(e);
}
}
use of java.security.cert.TrustAnchor 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.TrustAnchor 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.TrustAnchor 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.TrustAnchor 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) {
}
}
Aggregations