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


Java CollectionCertStoreParameters类代码示例

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


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

示例1: convertHolders

import java.security.cert.CollectionCertStoreParameters; //导入依赖的package包/类
private CollectionCertStoreParameters convertHolders(JcaX509CertificateConverter certificateConverter, JcaX509CRLConverter crlConverter)
    throws CertificateException, CRLException
{
    List jcaObjs = new ArrayList(certs.size() + crls.size());

    for (Iterator it = certs.iterator(); it.hasNext();)
    {
        jcaObjs.add(certificateConverter.getCertificate((X509CertificateHolder)it.next()));
    }

    for (Iterator it = crls.iterator(); it.hasNext();)
    {
        jcaObjs.add(crlConverter.getCRL((X509CRLHolder)it.next()));
    }

    return new CollectionCertStoreParameters(jcaObjs);
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:18,代码来源:JcaCertStoreBuilder.java

示例2: getCertificates

import java.security.cert.CollectionCertStoreParameters; //导入依赖的package包/类
/**
 * If the request is signed return a possibly empty CertStore containing the certificates in the
 * request. If the request is not signed the method returns null.
 * 
 * @param type type of CertStore to return
 * @param provider provider to use
 * @return null if not signed, a CertStore otherwise
 * @throws NoSuchAlgorithmException
 * @throws NoSuchProviderException
 * @throws OCSPException
 */
public CertStore getCertificates(
    String type,
    String provider) 
    throws NoSuchAlgorithmException, NoSuchProviderException, OCSPException
{
    if (!this.isSigned())
    {
        return null;
    }
    
    try
    {
        CertStoreParameters params = new CollectionCertStoreParameters(this.getCertList(provider));
        return OCSPUtil.createCertStoreInstance(type, params, provider);
    }
    catch (InvalidAlgorithmParameterException e)
    {
        throw new OCSPException("can't setup the CertStore", e);
    }
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:32,代码来源:OCSPReq.java

示例3: getCertificates

import java.security.cert.CollectionCertStoreParameters; //导入依赖的package包/类
/**
 * Return the certificates, if any associated with the response.
 * @param type type of CertStore to create
 * @param provider provider to use
 * @return a CertStore, possibly empty
 * @throws NoSuchAlgorithmException
 * @throws NoSuchProviderException
 * @throws OCSPException
 */
public CertStore getCertificates(
    String type,
    String provider) 
    throws NoSuchAlgorithmException, NoSuchProviderException, OCSPException
{
    try
    {
        CertStoreParameters params = new CollectionCertStoreParameters(this.getCertList(provider));
        return OCSPUtil.createCertStoreInstance(type, params, provider);
    }
    catch (InvalidAlgorithmParameterException e)
    {
        throw new OCSPException("can't setup the CertStore", e);
    }
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:25,代码来源:BasicOCSPResp.java

示例4: getParameters

import java.security.cert.CollectionCertStoreParameters; //导入依赖的package包/类
/**
 * Return the initialization parameters for the TrustManager.
 * Currently, only the default <code>PKIX</code> is supported.
 * 
 * @param algorithm The algorithm to get parameters for.
 * @param crlf The path to the CRL file.
 * @param trustStore The configured TrustStore.
 * @return The parameters including the CRLs and TrustStore.
 */
protected CertPathParameters getParameters(String algorithm, 
                                            String crlf, 
                                            KeyStore trustStore)
    throws Exception {
    CertPathParameters params = null;
    if("PKIX".equalsIgnoreCase(algorithm)) {
        PKIXBuilderParameters xparams = new PKIXBuilderParameters(trustStore, 
                                                                 new X509CertSelector());
        Collection crls = getCRLs(crlf);
        CertStoreParameters csp = new CollectionCertStoreParameters(crls);
        CertStore store = CertStore.getInstance("Collection", csp);
        xparams.addCertStore(store);
        xparams.setRevocationEnabled(true);
        xparams.setMaxPathLength(listener.getSslTrustMaxCertLength());

        params = xparams;
    } else {
        throw new CRLException("CRLs not supported for type: "+algorithm);
    }
    return params;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:31,代码来源:JSSESocketFactory.java

示例5: getParameters

import java.security.cert.CollectionCertStoreParameters; //导入依赖的package包/类
/**
 * Return the initialization parameters for the TrustManager. Currently,
 * only the default <code>PKIX</code> is supported.
 *
 * @param algorithm
 *            The algorithm to get parameters for.
 * @param crlf
 *            The path to the CRL file.
 * @param trustStore
 *            The configured TrustStore.
 * @return The parameters including the CRLs and TrustStore.
 */
protected CertPathParameters getParameters(String algorithm, String crlf, KeyStore trustStore) throws Exception {
	CertPathParameters params = null;
	if ("PKIX".equalsIgnoreCase(algorithm)) {
		PKIXBuilderParameters xparams = new PKIXBuilderParameters(trustStore, new X509CertSelector());
		Collection<? extends CRL> crls = getCRLs(crlf);
		CertStoreParameters csp = new CollectionCertStoreParameters(crls);
		CertStore store = CertStore.getInstance("Collection", csp);
		xparams.addCertStore(store);
		xparams.setRevocationEnabled(true);
		String trustLength = endpoint.getTrustMaxCertLength();
		if (trustLength != null) {
			try {
				xparams.setMaxPathLength(Integer.parseInt(trustLength));
			} catch (Exception ex) {
				log.warn("Bad maxCertLength: " + trustLength);
			}
		}

		params = xparams;
	} else {
		throw new CRLException("CRLs not supported for type: " + algorithm);
	}
	return params;
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:37,代码来源:JSSESocketFactory.java

示例6: build

import java.security.cert.CollectionCertStoreParameters; //导入依赖的package包/类
/**
 * Build the CertStore from the current inputs.
 *
 * @return  a CertStore.
 * @throws GeneralSecurityException
 */
public CertStore build()
    throws GeneralSecurityException
{
    CollectionCertStoreParameters params = convertHolders(certificateConverter, crlConverter);

    if (provider instanceof String)
    {
        return CertStore.getInstance(type, params, (String)provider);
    }

    if (provider instanceof Provider)
    {
        return CertStore.getInstance(type, params, (Provider)provider);
    }

    return CertStore.getInstance(type, params);
}
 
开发者ID:thedrummeraki,项目名称:Aki-SSL,代码行数:24,代码来源:JcaCertStoreBuilder.java

示例7: testCollectionCertStoreParameters02

import java.security.cert.CollectionCertStoreParameters; //导入依赖的package包/类
/**
 * Test #2 for <code>CollectionCertStoreParameters</code> constructor<br>
 */
@TestTargetNew(
    level = TestLevel.PARTIAL_COMPLETE,
    notes = "",
    method = "CollectionCertStoreParameters",
    args = {}
)
@SuppressWarnings("unchecked")
public final void testCollectionCertStoreParameters02() {
    CollectionCertStoreParameters cp = new CollectionCertStoreParameters();
    Collection c = cp.getCollection();
    assertTrue("isEmpty", c.isEmpty());

    // check that empty collection is immutable
    try {
        // try to modify it
        c.add(new Object());
        fail("empty collection must be immutable");
    } catch (Exception e) {
    }
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:24,代码来源:CollectionCertStoreParametersTest.java

示例8: testCollectionCertStoreParametersCollection03

import java.security.cert.CollectionCertStoreParameters; //导入依赖的package包/类
/**
 * Test #3 for <code>CollectionCertStoreParameters(Collection)</code>
 * constructor<br>
 */
@TestTargetNew(
    level = TestLevel.PARTIAL_COMPLETE,
    notes = "",
    method = "CollectionCertStoreParameters",
    args = {java.util.Collection.class}
)
public final void testCollectionCertStoreParametersCollection03() {
    Vector<Certificate> certificates = new Vector<Certificate>();
    // create using empty collection
    CollectionCertStoreParameters cp =
        new CollectionCertStoreParameters(certificates);
    // check that the reference is used
    assertTrue("isRefUsed_1", certificates == cp.getCollection());
    // check that collection still empty
    assertTrue("isEmpty", cp.getCollection().isEmpty());
    // modify our collection
    certificates.add(new MyCertificate("TEST", new byte[] {(byte)1}));
    certificates.add(new MyCertificate("TEST", new byte[] {(byte)2}));
    // check that internal state has been changed accordingly
    assertTrue("isRefUsed_2", certificates.equals(cp.getCollection()));
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:26,代码来源:CollectionCertStoreParametersTest.java

示例9: testClone01

import java.security.cert.CollectionCertStoreParameters; //导入依赖的package包/类
/**
 * Test #1 for <code>clone()</code> method<br>
 */
@TestTargetNew(
    level = TestLevel.PARTIAL_COMPLETE,
    notes = "",
    method = "clone",
    args = {}
)
public final void testClone01() {
    Vector<Certificate> certificates = new Vector<Certificate>();
    certificates.add(new MyCertificate("TEST", new byte[] {(byte)4}));
    CollectionCertStoreParameters cp1 =
        new CollectionCertStoreParameters(certificates);
    CollectionCertStoreParameters cp2 =
        (CollectionCertStoreParameters)cp1.clone();
    // check that that we have new object
    assertTrue(cp1 != cp2);
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:20,代码来源:CollectionCertStoreParametersTest.java

示例10: testClone02

import java.security.cert.CollectionCertStoreParameters; //导入依赖的package包/类
/**
 * Test #2 for <code>clone()</code> method<br>
 */
@TestTargetNew(
    level = TestLevel.PARTIAL_COMPLETE,
    notes = "",
    method = "clone",
    args = {}
)
public final void testClone02() {
    Vector<Certificate> certificates = new Vector<Certificate>();
    certificates.add(new MyCertificate("TEST", new byte[] {(byte)4}));
    CollectionCertStoreParameters cp1 =
        new CollectionCertStoreParameters(certificates);
    CollectionCertStoreParameters cp2 =
        (CollectionCertStoreParameters)cp1.clone();
    // check that both objects hold the same reference
    assertTrue(cp1.getCollection() == cp2.getCollection());
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:20,代码来源:CollectionCertStoreParametersTest.java

示例11: testClone03

import java.security.cert.CollectionCertStoreParameters; //导入依赖的package包/类
/**
 * Test #3 for <code>clone()</code> method<br>
 */
@TestTargetNew(
    level = TestLevel.PARTIAL_COMPLETE,
    notes = "",
    method = "clone",
    args = {}
)
public final void testClone03() {
    CollectionCertStoreParameters cp1 =
        new CollectionCertStoreParameters();
    CollectionCertStoreParameters cp2 =
        (CollectionCertStoreParameters)cp1.clone();
    CollectionCertStoreParameters cp3 =
        (CollectionCertStoreParameters)cp2.clone();
    // check that all objects hold the same reference
    assertTrue(cp1.getCollection() == cp2.getCollection() &&
               cp3.getCollection() == cp2.getCollection());
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:21,代码来源:CollectionCertStoreParametersTest.java

示例12: ClientTrustManager

import java.security.cert.CollectionCertStoreParameters; //导入依赖的package包/类
public ClientTrustManager(KeyStore trustTrust) {
    super();
    this.trustStore = trustTrust;

    //Note: A reference of the Collection is used in the CertStore, so we can add CRL's 
    // after creating the CertStore.
    crls = new ArrayList<>();
    CollectionCertStoreParameters params = new CollectionCertStoreParameters(crls);
    
    try {
        crlStore = CertStore.getInstance("Collection", params);
    }
    catch (InvalidAlgorithmParameterException | NoSuchAlgorithmException ex) {
        Log.warn("ClientTrustManager: ",ex);
    }

    loadCRL();
   
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:20,代码来源:ClientTrustManager.java

示例13: testCollectionCertStoreParametersCollection03

import java.security.cert.CollectionCertStoreParameters; //导入依赖的package包/类
/**
 * Test #3 for <code>CollectionCertStoreParameters(Collection)</code>
 * constructor<br>
 * Assertion: The Collection is not copied. Instead, a reference is used.
 * This allows the caller to subsequently add or remove Certificates or
 * CRLs from the Collection, thus changing the set of Certificates or CRLs
 * available to the Collection CertStore. The Collection CertStore will
 * not modify the contents of the Collection 
 */
public final void testCollectionCertStoreParametersCollection03() {
    Vector certificates = new Vector();
    // create using empty collection
    CollectionCertStoreParameters cp =
        new CollectionCertStoreParameters(certificates);
    // check that the reference is used 
    assertTrue("isRefUsed_1", certificates == cp.getCollection());
    // check that collection still empty
    assertTrue("isEmpty", cp.getCollection().isEmpty());
    // modify our collection
    certificates.add(new MyCertificate("TEST", new byte[] {(byte)1}));
    certificates.add(new MyCertificate("TEST", new byte[] {(byte)2}));
    // check that internal state has been changed accordingly
    assertTrue("isRefUsed_2", certificates.equals(cp.getCollection()));
}
 
开发者ID:shannah,项目名称:cn1,代码行数:25,代码来源:CollectionCertStoreParametersTest.java

示例14: CrlRevocationChecker

import java.security.cert.CollectionCertStoreParameters; //导入依赖的package包/类
CrlRevocationChecker(TrustAnchor anchor, PKIXParameters params,
    Collection<X509Certificate> certs, boolean onlyEECert)
    throws CertPathValidatorException {
    mAnchor = anchor;
    mParams = params;
    mStores = new ArrayList<CertStore>(params.getCertStores());
    mSigProvider = params.getSigProvider();
    if (certs != null) {
        try {
            mStores.add(CertStore.getInstance("Collection",
                new CollectionCertStoreParameters(certs)));
        } catch (Exception e) {
            // should never occur but not necessarily fatal, so log it,
            // ignore and continue
            if (debug != null) {
                debug.println("CrlRevocationChecker: " +
                    "error creating Collection CertStore: " + e);
            }
        }
    }
    Date testDate = params.getDate();
    mCurrentTime = (testDate != null ? testDate : new Date());
    mOnlyEECert = onlyEECert;
    init(false);
}
 
开发者ID:greghaskins,项目名称:openjdk-jdk7u-jdk,代码行数:26,代码来源:CrlRevocationChecker.java

示例15: testRevoked

import java.security.cert.CollectionCertStoreParameters; //导入依赖的package包/类
public void testRevoked() throws Exception
{
    String message = "validator.revoked.eml";
    PKIXParameters params = createDefaultParams();
    List crlList = new ArrayList();
    crlList.add(loadCRL("validator.revoked.crl"));
    CertStore crls = CertStore.getInstance("Collection",new CollectionCertStoreParameters(crlList));
    params.addCertStore(crls);
    params.setRevocationEnabled(true);
    
    SignedMailValidator.ValidationResult result = doTest(message, params);
    
    assertTrue(result.isVerifiedSignature());
    assertFalse(result.isValidSignature());
    
    PKIXCertPathReviewer review = result.getCertPathReview();
    assertFalse(review.isValidCertPath());
    assertContainsMessage(
            review.getErrors(0),
            "CertPathReviewer.certRevoked",
            "The certificate was revoked at Sep 1, 2006 9:30:00 AM GMT. Reason: Key Compromise.");
}
 
开发者ID:mlundblad,项目名称:bc-java,代码行数:23,代码来源:SignedMailValidatorTest.java


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