本文整理汇总了Java中java.security.cert.PKIXParameters.setCertPathCheckers方法的典型用法代码示例。如果您正苦于以下问题:Java PKIXParameters.setCertPathCheckers方法的具体用法?Java PKIXParameters.setCertPathCheckers怎么用?Java PKIXParameters.setCertPathCheckers使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.security.cert.PKIXParameters
的用法示例。
在下文中一共展示了PKIXParameters.setCertPathCheckers方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testGetCertPathCheckers03
import java.security.cert.PKIXParameters; //导入方法依赖的package包/类
/**
* Test #3 for <code>getCertPathCheckers()</code> method<br>
* Assertion: The returned List is immutable, and each
* <code>PKIXCertPathChecker</code> in the <code>List</code>
* is cloned to protect against subsequent modifications
* @throws InvalidAlgorithmParameterException
* @throws CertPathValidatorException
*/
public final void testGetCertPathCheckers03() throws Exception {
Set taSet = TestUtils.getTrustAnchorSet();
if (taSet == null) {
fail(getName() + ": not performed (could not create test TrustAnchor set)");
}
PKIXParameters p = new PKIXParameters(taSet);
PKIXCertPathChecker cpc = TestUtils.getTestCertPathChecker();
List l = new ArrayList();
assertTrue("addedOk", l.add(cpc));
p.setCertPathCheckers(l);
// retrieve checker and modify it
PKIXCertPathChecker cpc1 = p.getCertPathCheckers().get(0);
cpc1.init(true);
assertTrue("modifiedOk", cpc1.isForwardCheckingSupported());
// retrieve checker again and check
// that its state has not been changed
// by the above modification
PKIXCertPathChecker cpc2 = p.getCertPathCheckers().get(0);
assertFalse("isCloned", cpc2.isForwardCheckingSupported());
}
示例2: testSetCertPathCheckers01
import java.security.cert.PKIXParameters; //导入方法依赖的package包/类
/**
* Test #1 for <code>setCertPathCheckers(List)</code> method<br>
* Assertion: sets a <code>List</code> of additional
* certification path checkers
* @throws InvalidAlgorithmParameterException
*/
public final void testSetCertPathCheckers01() throws Exception {
Set taSet = TestUtils.getTrustAnchorSet();
if (taSet == null) {
fail(getName() + ": not performed (could not create test TrustAnchor set)");
}
PKIXParameters p = new PKIXParameters(taSet);
PKIXCertPathChecker cpc = TestUtils.getTestCertPathChecker();
List l = new ArrayList();
assertTrue("addedOk", l.add(cpc));
p.setCertPathCheckers(l);
List l1 = p.getCertPathCheckers();
assertNotNull("notNull", l1);
assertFalse("isNotEmpty", l1.isEmpty());
}
示例3: testSetCertPathCheckers02
import java.security.cert.PKIXParameters; //导入方法依赖的package包/类
/**
* Test #2 for <code>setCertPathCheckers(List)</code> method<br>
* Assertion: <code>List</code> ... may be null
* @throws InvalidAlgorithmParameterException
*/
public final void testSetCertPathCheckers02() throws Exception {
Set taSet = TestUtils.getTrustAnchorSet();
if (taSet == null) {
fail(getName() + ": not performed (could not create test TrustAnchor set)");
}
PKIXParameters p = new PKIXParameters(taSet);
p.setCertPathCheckers(null);
List l1 = p.getCertPathCheckers();
assertNotNull("notNull1", l1);
assertTrue("isEmpty1", l1.isEmpty());
p.setCertPathCheckers(new ArrayList());
List l2 = p.getCertPathCheckers();
assertNotNull("notNull2", l2);
assertTrue("isEmpty2", l2.isEmpty());
}
示例4: testSetCertPathCheckers03
import java.security.cert.PKIXParameters; //导入方法依赖的package包/类
/**
* Test #3 for <code>setCertPathCheckers(List)</code> method<br>
* Assertion: <code>List</code> supplied here is copied and each
* <code>PKIXCertPathChecker</code> in the list is cloned to protect
* against subsequent modifications
* @throws InvalidAlgorithmParameterException
*/
public final void testSetCertPathCheckers03() throws Exception {
// checks that list copied
Set taSet = TestUtils.getTrustAnchorSet();
if (taSet == null) {
fail(getName() + ": not performed (could not create test TrustAnchor set)");
}
PKIXParameters p = new PKIXParameters(taSet);
PKIXCertPathChecker cpc = TestUtils.getTestCertPathChecker();
List l = new ArrayList();
assertTrue("addedOk", l.add(cpc));
p.setCertPathCheckers(l);
// modify list
l.clear();
// retrieve list and check
// that its state has not been changed
// by the above modification
assertFalse("isCopied", p.getCertPathCheckers().isEmpty());
}
示例5: testSetCertPathCheckers04
import java.security.cert.PKIXParameters; //导入方法依赖的package包/类
/**
* Test #4 for <code>setCertPathCheckers(List)</code> method<br>
* Assertion: <code>List</code> supplied here is copied and each
* <code>PKIXCertPathChecker</code> in the list is cloned to protect
* against subsequent modifications
* @throws InvalidAlgorithmParameterException
* @throws InvalidAlgorithmParameterException
* @throws CertPathValidatorException
*/
public final void testSetCertPathCheckers04() throws Exception {
// checks that checkers cloned
Set taSet = TestUtils.getTrustAnchorSet();
if (taSet == null) {
fail(getName() + ": not performed (could not create test TrustAnchor set)");
}
PKIXParameters p = new PKIXParameters(taSet);
PKIXCertPathChecker cpc = TestUtils.getTestCertPathChecker();
List l = new ArrayList();
assertTrue("addedOk", l.add(cpc));
p.setCertPathCheckers(l);
// modify checker
cpc.init(true);
// retrieve list and check that CertPathChecker's
// state it contains has not been changed by the
// above modification
PKIXCertPathChecker cpc1 = p.getCertPathCheckers().get(0);
assertFalse("isCopied", cpc1.isForwardCheckingSupported());
}
示例6: testSetCertPathCheckers05
import java.security.cert.PKIXParameters; //导入方法依赖的package包/类
/**
* Test #5 for <code>setCertPathCheckers(List)</code> method<br>
* Assertion: <code>ClassCastException</code> -
* if any of the elements in the list are not of type
* <code>java.security.cert.PKIXCertPathChecker</code>
* @throws InvalidAlgorithmParameterException
*/
public final void testSetCertPathCheckers05() throws Exception {
Set taSet = TestUtils.getTrustAnchorSet();
if (taSet == null) {
fail(getName() + ": not performed (could not create test TrustAnchor set)");
}
PKIXParameters p = new PKIXParameters(taSet);
PKIXCertPathChecker cpc = TestUtils.getTestCertPathChecker();
List l = new ArrayList();
assertTrue("addedOk", l.add(cpc));
// add wrong object to the list
assertTrue("addedOk", l.add(new Object()));
try {
p.setCertPathCheckers(l);
fail("ClassCastException expected");
} catch (ClassCastException e) {
}
}
示例7: testAddCertPathChecker01
import java.security.cert.PKIXParameters; //导入方法依赖的package包/类
/**
* Test #1 for <code>addCertPathChecker(PKIXCertPathChecker)</code> method<br>
* Assertion: adds a <code>CertPathChecker</code> to the end of the
* list of <code>CertPathChecker</code>s
* @throws CertPathValidatorException
*/
public final void testAddCertPathChecker01() throws Exception {
Set taSet = TestUtils.getTrustAnchorSet();
if (taSet == null) {
fail(getName() + ": not performed (could not create test TrustAnchor set)");
}
PKIXParameters p = new PKIXParameters(taSet);
PKIXCertPathChecker cpc = TestUtils.getTestCertPathChecker();
List l = new ArrayList();
assertTrue("addedOk", l.add(cpc));
p.setCertPathCheckers(l);
// create one more PKIXCertPathChecker
PKIXCertPathChecker cpc1 = TestUtils.getTestCertPathChecker();
cpc1.init(true);
p.addCertPathChecker(cpc1);
// check that we have two PKIXCertPathCheckers and
// they are in right order
List l1 = p.getCertPathCheckers();
assertEquals("listSize", 2, l1.size());
assertFalse("order1",
((PKIXCertPathChecker)l1.get(0)).isForwardCheckingSupported());
assertTrue("order2",
((PKIXCertPathChecker)l1.get(1)).isForwardCheckingSupported());
}
示例8: testAddCertPathChecker02
import java.security.cert.PKIXParameters; //导入方法依赖的package包/类
/**
* Test #2 for <code>addCertPathChecker(PKIXCertPathChecker)</code> method<br>
* Assertion: if null, the checker is ignored (not added to list).
* @throws InvalidAlgorithmParameterException
*/
public final void testAddCertPathChecker02() throws Exception {
Set taSet = TestUtils.getTrustAnchorSet();
if (taSet == null) {
fail(getName() + ": not performed (could not create test TrustAnchor set)");
}
PKIXParameters p = new PKIXParameters(taSet);
PKIXCertPathChecker cpc = TestUtils.getTestCertPathChecker();
List l = new ArrayList();
assertTrue("addedOk", l.add(cpc));
p.setCertPathCheckers(l);
// try to add null
p.addCertPathChecker(null);
// check that we have one PKIXCertPathChecker
List l1 = p.getCertPathCheckers();
assertEquals("listSize", 1, l1.size());
}
示例9: testClone01
import java.security.cert.PKIXParameters; //导入方法依赖的package包/类
/**
* Test #1 for <code>clone()</code> method<br>
* Assertion: Makes a copy of this <code>PKIXParameters</code> object
* @throws KeyStoreException
* @throws InvalidAlgorithmParameterException
* @throws NoSuchAlgorithmException
*/
public final void testClone01() throws Exception {
KeyStore ks = TestUtils.getKeyStore(true, TestUtils.TRUSTED);
if (ks == null) {
fail(getName() + ": not performed (could not create test KeyStore)");
}
PKIXParameters p1 = new PKIXParameters(ks);
// set to some non-default values
p1.setPolicyQualifiersRejected(false);
p1.setAnyPolicyInhibited(true);
p1.setExplicitPolicyRequired(true);
p1.setPolicyMappingInhibited(true);
p1.setRevocationEnabled(false);
String sigProviderName = "Some Provider";
p1.setSigProvider(sigProviderName);
X509CertSelector x509cs = new X509CertSelector();
p1.setTargetCertConstraints(x509cs);
p1.setCertStores(TestUtils.getCollectionCertStoresList());
PKIXCertPathChecker cpc = TestUtils.getTestCertPathChecker();
List l = new ArrayList();
assertTrue("addedOk", l.add(cpc));
p1.setCertPathCheckers(l);
p1.setDate(new Date(555L));
Set s = new HashSet();
s.add("1.2.3.4.5.6.7");
s.add("1.2.3.4.5.6.8");
p1.setInitialPolicies(s);
// TrustAnchors already set
PKIXParameters p2 = (PKIXParameters)p1.clone();
// check that objects match
assertEquals("check1", p1.getPolicyQualifiersRejected(),
p2.getPolicyQualifiersRejected());
assertEquals("check2", p1.isAnyPolicyInhibited(),
p2.isAnyPolicyInhibited());
assertEquals("check3", p1.isExplicitPolicyRequired(),
p2.isExplicitPolicyRequired());
assertEquals("check4", p1.isPolicyMappingInhibited(),
p2.isPolicyMappingInhibited());
assertEquals("check5", p1.isRevocationEnabled(),
p2.isRevocationEnabled());
assertEquals("check6", p1.getSigProvider(), p2.getSigProvider());
// just check that not null
assertNotNull("check7", p2.getTargetCertConstraints());
assertEquals("check8", p1.getCertStores(), p2.getCertStores());
// just check that not empty
assertFalse("check9", p2.getCertPathCheckers().isEmpty());
assertEquals("check10", p1.getDate(), p2.getDate());
assertEquals("check11", p1.getInitialPolicies(),
p2.getInitialPolicies());
assertEquals("check12", p1.getTrustAnchors(), p2.getTrustAnchors());
}