當前位置: 首頁>>代碼示例>>Java>>正文


Java PKIXParameters.setExplicitPolicyRequired方法代碼示例

本文整理匯總了Java中java.security.cert.PKIXParameters.setExplicitPolicyRequired方法的典型用法代碼示例。如果您正苦於以下問題:Java PKIXParameters.setExplicitPolicyRequired方法的具體用法?Java PKIXParameters.setExplicitPolicyRequired怎麽用?Java PKIXParameters.setExplicitPolicyRequired使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.security.cert.PKIXParameters的用法示例。


在下文中一共展示了PKIXParameters.setExplicitPolicyRequired方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testSetExplicitPolicyRequired

import java.security.cert.PKIXParameters; //導入方法依賴的package包/類
/**
 * Test for <code>setExplicitPolicyRequired()</code> method<br>
 * Assertion: sets the ExplicitPolicyRequired flag
 * @throws InvalidAlgorithmParameterException
 */
public final void testSetExplicitPolicyRequired() 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.setExplicitPolicyRequired(true);
    assertTrue("setTrue", p.isExplicitPolicyRequired());
    p.setExplicitPolicyRequired(false);
    assertFalse("setFalse", p.isExplicitPolicyRequired());
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:18,代碼來源:PKIXParametersTest.java

示例2: testClone

import java.security.cert.PKIXParameters; //導入方法依賴的package包/類
/**
 * Test for <code>clone()</code> method<br>
 */
@TestTargetNew(
    level = TestLevel.COMPLETE,
    notes = "",
    method = "clone",
    args = {}
)
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
    }
}
 
開發者ID:keplersj,項目名稱:In-the-Box-Fork,代碼行數:58,代碼來源:OldPKIXParametersTest.java

示例3: 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());
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:72,代碼來源:PKIXParameters_ImplTest.java

示例4: doTest

import java.security.cert.PKIXParameters; //導入方法依賴的package包/類
private PKIXCertPathValidatorResult doTest(
    String      trustAnchor,
    String[]    certs,
    String[]    crls,
    Set         policies)
    throws Exception
{
    Set  trustedSet = Collections.singleton(getTrustAnchor(trustAnchor));
    List certsAndCrls = new ArrayList();
    X509Certificate endCert = loadCert(certs[certs.length - 1]);
    
    for (int i = 0; i != certs.length - 1; i++)
    {
        certsAndCrls.add(loadCert(certs[i]));
    }
    
    certsAndCrls.add(endCert);

    CertPath certPath = CertificateFactory.getInstance("X.509","BC").generateCertPath(certsAndCrls);

    for (int i = 0; i != crls.length; i++)
    {
        certsAndCrls.add(loadCrl(crls[i]));
    }

    CertStore  store = CertStore.getInstance("Collection", new CollectionCertStoreParameters(certsAndCrls), "BC");
    
    CertPathValidator validator = CertPathValidator.getInstance("PKIX","BC");
    PKIXParameters    params = new PKIXParameters(trustedSet);
    
    params.addCertStore(store);
    params.setRevocationEnabled(true);
    params.setDate(new GregorianCalendar(2010, 1, 1).getTime());

    if (policies != null)
    {
        params.setExplicitPolicyRequired(true);
        params.setInitialPolicies(policies);
    }
    
    return (PKIXCertPathValidatorResult)validator.validate(certPath, params);
}
 
開發者ID:NoYouShutup,項目名稱:CryptMeme,代碼行數:43,代碼來源:NistCertPathTest.java


注:本文中的java.security.cert.PKIXParameters.setExplicitPolicyRequired方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。