当前位置: 首页>>代码示例>>Java>>正文


Java PKIXParameters.getTrustAnchors方法代码示例

本文整理汇总了Java中java.security.cert.PKIXParameters.getTrustAnchors方法的典型用法代码示例。如果您正苦于以下问题:Java PKIXParameters.getTrustAnchors方法的具体用法?Java PKIXParameters.getTrustAnchors怎么用?Java PKIXParameters.getTrustAnchors使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.security.cert.PKIXParameters的用法示例。


在下文中一共展示了PKIXParameters.getTrustAnchors方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getInstance

import java.security.cert.PKIXParameters; //导入方法依赖的package包/类
/**
 * Returns an instance with the parameters of a given
 * <code>PKIXParameters</code> object.
 * 
 * @param pkixParams The given <code>PKIXParameters</code>
 * @return an extended PKIX params object
 */
public static ExtendedPKIXParameters getInstance(PKIXParameters pkixParams)
{
    ExtendedPKIXParameters params;
    try
    {
        params = new ExtendedPKIXParameters(pkixParams.getTrustAnchors());
    }
    catch (Exception e)
    {
        // cannot happen
        throw new RuntimeException(e.getMessage());
    }
    params.setParams(pkixParams);
    return params;
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:23,代码来源:ExtendedPKIXParameters.java

示例2: getInstance

import java.security.cert.PKIXParameters; //导入方法依赖的package包/类
/**
 * Returns an instance of <code>ExtendedPKIXParameters</code> which can be
 * safely casted to <code>ExtendedPKIXBuilderParameters</code>.
 * <p>
 * This method can be used to get a copy from other
 * <code>PKIXBuilderParameters</code>, <code>PKIXParameters</code>,
 * and <code>ExtendedPKIXParameters</code> instances.
 * 
 * @param pkixParams The PKIX parameters to create a copy of.
 * @return An <code>ExtendedPKIXBuilderParameters</code> instance.
 */
public static ExtendedPKIXParameters getInstance(PKIXParameters pkixParams)
{
    ExtendedPKIXBuilderParameters params;
    try
    {
        params = new ExtendedPKIXBuilderParameters(pkixParams
                .getTrustAnchors(), X509CertStoreSelector
                .getInstance((X509CertSelector) pkixParams
                        .getTargetCertConstraints()));
    }
    catch (Exception e)
    {
        // cannot happen
        throw new RuntimeException(e.getMessage());
    }
    params.setParams(pkixParams);
    return params;
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:30,代码来源:ExtendedPKIXBuilderParameters.java

示例3: testPKIXParametersSet02

import java.security.cert.PKIXParameters; //导入方法依赖的package包/类
/**
 * Test #2 for <code>PKIXParameters(Set)</code> constructor<br>
 * Assertion: ... the <code>Set</code> is copied to protect against
 * subsequent modifications
 * @throws InvalidAlgorithmParameterException
 */
public final void testPKIXParametersSet02()
    throws InvalidAlgorithmParameterException {
    Set taSet = TestUtils.getTrustAnchorSet();
    if (taSet == null) {
        fail(getName() + ": not performed (could not create test TrustAnchor set)");
    }
    HashSet originalSet = (HashSet)taSet;
    HashSet originalSetCopy = (HashSet)originalSet.clone();
    // create test object using originalSet 
    PKIXParameters pp = new PKIXParameters(originalSetCopy);
    // modify originalSet
    originalSetCopy.clear();
    // check that test object's internal state
    // has not been affected by the above modification
    Set returnedSet = pp.getTrustAnchors();
    assertEquals(originalSet, returnedSet);
}
 
开发者ID:shannah,项目名称:cn1,代码行数:24,代码来源:PKIXParametersTest.java

示例4: testGetTrustAnchors02

import java.security.cert.PKIXParameters; //导入方法依赖的package包/类
/**
 * Test #2 for <code>getTrustAnchors()</code> method<br>
 * Assertion: an immutable <code>Set</code> of <code>TrustAnchors</code>
 * (never <code>null</code>) 
 * @throws InvalidAlgorithmParameterException
 */
public final void testGetTrustAnchors02() throws Exception {
    Set taSet = TestUtils.getTrustAnchorSet();
    if (taSet == null) {
        fail(getName() + ": not performed (could not create test TrustAnchor set)");
    }

    PKIXParameters p = new PKIXParameters(taSet);
    Set s = p.getTrustAnchors();
    try {
        // try to modify returned set
        s.add(new Object());
        fail("must be immutable");
    } catch (Exception e) {
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:22,代码来源:PKIXParametersTest.java

示例5: testSetTrustAnchors04

import java.security.cert.PKIXParameters; //导入方法依赖的package包/类
/**
 * Test #4 for <code>setTrustAnchors(Set)</code> method<br>
 * Assertion: <code>ClassCastException</code> -
 * if any of the elements in the set are not of type
 * <code>java.security.cert.TrustAnchor</code>
 * @throws InvalidAlgorithmParameterException
 */
public final void testSetTrustAnchors04() throws Exception {
    Set taSet = TestUtils.getTrustAnchorSet();
    if (taSet == null) {
        fail(getName() + ": not performed (could not create test TrustAnchor set)");
    }

    PKIXParameters p = new PKIXParameters(taSet);
    Set s = new HashSet(p.getTrustAnchors());
    s.add(new Object());
    try {
        p.setTrustAnchors(s);
        fail("ClassCastException expected");
    } catch (ClassCastException e) {
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:23,代码来源:PKIXParametersTest.java

示例6: testSetTrustAnchors05

import java.security.cert.PKIXParameters; //导入方法依赖的package包/类
/**
 * Test #5 for <code>setTrustAnchors(Set)</code> method<br>
 * Assertion: <code>Set</code> is copied to protect against
 * subsequent modifications
 * @throws InvalidAlgorithmParameterException
 * @throws KeyStoreException
 */
public final void testSetTrustAnchors05() throws Exception {
    // use several trusted certs in this test
    KeyStore ks = TestUtils.getKeyStore(true, TestUtils.TRUSTED);
    if (ks == null) {
        fail(getName() + ": not performed (could not create test KeyStore)");
    }

    PKIXParameters p = new PKIXParameters(ks);
    // prepare new Set
    HashSet newSet = new HashSet(p.getTrustAnchors());
    HashSet newSetCopy = (HashSet)newSet.clone();
    // set new Set
    p.setTrustAnchors(newSetCopy);
    // modify set - remove one element
    assertTrue("modified", newSetCopy.remove(newSetCopy.iterator().next()));
    // check that set maintained internally has
    // not been changed by the above modification
    assertEquals("isCopied", newSet, p.getTrustAnchors());
}
 
开发者ID:shannah,项目名称:cn1,代码行数:27,代码来源:PKIXParameters_ImplTest.java

示例7: Builder

import java.security.cert.PKIXParameters; //导入方法依赖的package包/类
public Builder(PKIXParameters baseParameters)
{
    this.baseParameters = (PKIXParameters)baseParameters.clone();
    CertSelector constraints = baseParameters.getTargetCertConstraints();
    if (constraints != null)
    {
        this.targetConstraints = new PKIXCertStoreSelector.Builder(constraints).build();
    }
    Date checkDate = baseParameters.getDate();
    this.date = (checkDate == null) ? new Date() : checkDate;
    this.revocationEnabled = baseParameters.isRevocationEnabled();
    this.trustAnchors = baseParameters.getTrustAnchors();
}
 
开发者ID:thedrummeraki,项目名称:Aki-SSL,代码行数:14,代码来源:PKIXExtendedParameters.java


注:本文中的java.security.cert.PKIXParameters.getTrustAnchors方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。