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());
}
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());
}
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) {
}
}
use of java.security.cert.TrustAnchor in project robovm by robovm.
the class OldPKIXParametersTest method testClone.
public final void testClone() throws InvalidAlgorithmParameterException {
Set<TrustAnchor> taSet = TestUtils.getTrustAnchorSet();
if (taSet == null) {
fail(getName() + ": not performed (could not create test TrustAnchor set)");
}
PKIXParameters cpp = new PKIXParameters(taSet);
PKIXParameters cppc = (PKIXParameters) cpp.clone();
assertEquals(cpp.getPolicyQualifiersRejected(), cppc.getPolicyQualifiersRejected());
assertEquals(cpp.getCertPathCheckers(), cppc.getCertPathCheckers());
assertEquals(cpp.getCertStores(), cppc.getCertStores());
assertEquals(cpp.getDate(), cppc.getDate());
assertEquals(cpp.getInitialPolicies(), cppc.getInitialPolicies());
assertEquals(cpp.getSigProvider(), cppc.getSigProvider());
assertEquals(cpp.getTargetCertConstraints(), cppc.getTargetCertConstraints());
assertEquals(cpp.getTrustAnchors(), cppc.getTrustAnchors());
assertEquals(cpp.isAnyPolicyInhibited(), cppc.isAnyPolicyInhibited());
assertEquals(cpp.isExplicitPolicyRequired(), cppc.isExplicitPolicyRequired());
assertEquals(cpp.isPolicyMappingInhibited(), cppc.isPolicyMappingInhibited());
assertEquals(cpp.isRevocationEnabled(), cppc.isRevocationEnabled());
cpp.setDate(Calendar.getInstance().getTime());
cpp.setPolicyQualifiersRejected(!cppc.getPolicyQualifiersRejected());
assertFalse(cpp.getDate().equals(cppc.getDate()));
assertFalse(cpp.getPolicyQualifiersRejected() == cppc.getPolicyQualifiersRejected());
cppc.setExplicitPolicyRequired(!cpp.isExplicitPolicyRequired());
cppc.setRevocationEnabled(!cpp.isRevocationEnabled());
assertFalse(cpp.isExplicitPolicyRequired() == cppc.isExplicitPolicyRequired());
assertFalse(cpp.isRevocationEnabled() == cppc.isRevocationEnabled());
PKIXParameters cpp1 = null;
try {
cpp1.clone();
} catch (NullPointerException e) {
// expected
}
}
use of java.security.cert.TrustAnchor in project robovm by robovm.
the class ExtendedPKIXParameters method setTrustedACIssuers.
/**
* Sets the trusted attribute certificate issuers. If attribute certificates
* is verified the trusted AC issuers must be set.
* <p>
* The <code>trustedACIssuers</code> must be a <code>Set</code> of
* <code>TrustAnchor</code>
* <p>
* The given set is cloned.
*
* @param trustedACIssuers The trusted AC issuers to set. Is never
* <code>null</code>.
* @throws ClassCastException if an element of <code>stores</code> is not
* a <code>TrustAnchor</code>.
*/
public void setTrustedACIssuers(Set trustedACIssuers) {
if (trustedACIssuers == null) {
this.trustedACIssuers.clear();
return;
}
for (Iterator it = trustedACIssuers.iterator(); it.hasNext(); ) {
if (!(it.next() instanceof TrustAnchor)) {
throw new ClassCastException("All elements of set must be " + "of type " + TrustAnchor.class.getName() + ".");
}
}
this.trustedACIssuers.clear();
this.trustedACIssuers.addAll(trustedACIssuers);
}
Aggregations