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


Java CertStoreParameters类代码示例

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


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

示例1: getCertificates

import java.security.cert.CertStoreParameters; //导入依赖的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

示例2: getCertificates

import java.security.cert.CertStoreParameters; //导入依赖的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

示例3: getParameters

import java.security.cert.CertStoreParameters; //导入依赖的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

示例4: URICertStore

import java.security.cert.CertStoreParameters; //导入依赖的package包/类
/**
 * Creates a URICertStore.
 *
 * @param parameters specifying the URI
 */
URICertStore(CertStoreParameters params)
    throws InvalidAlgorithmParameterException, NoSuchAlgorithmException {
    super(params);
    if (!(params instanceof URICertStoreParameters)) {
        throw new InvalidAlgorithmParameterException
            ("params must be instanceof URICertStoreParameters");
    }
    this.uri = ((URICertStoreParameters) params).uri;
    // if ldap URI, use an LDAPCertStore to fetch certs and CRLs
    if (uri.getScheme().toLowerCase(Locale.ENGLISH).equals("ldap")) {
        ldap = true;
        ldapHelper = CertStoreHelper.getInstance("LDAP");
        ldapCertStore = ldapHelper.getCertStore(uri);
        ldapPath = uri.getPath();
        // strip off leading '/'
        if (ldapPath.charAt(0) == '/') {
            ldapPath = ldapPath.substring(1);
        }
    }
    try {
        factory = CertificateFactory.getInstance("X.509");
    } catch (CertificateException e) {
        throw new RuntimeException();
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:31,代码来源:URICertStore.java

示例5: URICertStore

import java.security.cert.CertStoreParameters; //导入依赖的package包/类
/**
 * Creates a URICertStore.
 *
 * @param parameters specifying the URI
 */
URICertStore(CertStoreParameters params)
    throws InvalidAlgorithmParameterException, NoSuchAlgorithmException {
    super(params);
    if (!(params instanceof URICertStoreParameters)) {
        throw new InvalidAlgorithmParameterException
            ("params must be instanceof URICertStoreParameters");
    }
    this.uri = ((URICertStoreParameters) params).getURI();
    // if ldap URI, use an LDAPCertStore to fetch certs and CRLs
    if (uri.getScheme().toLowerCase(Locale.ENGLISH).equals("ldap")) {
        ldap = true;
        ldapCertStore = CertStore.getInstance("LDAP", params);
    }
    try {
        factory = CertificateFactory.getInstance("X.509");
    } catch (CertificateException e) {
        throw new RuntimeException();
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:25,代码来源:URICertStore.java

示例6: newInstance

import java.security.cert.CertStoreParameters; //导入依赖的package包/类
@Override
public Object newInstance(Object ctrParamObj)
    throws NoSuchAlgorithmException {
    String type = getType();
    String algo = getAlgorithm();
    if (type.equals("CertStore") && algo.equals("LDAP")) {
        if (ctrParamObj != null &&
            !(ctrParamObj instanceof CertStoreParameters)) {
            throw new InvalidParameterException
            ("constructorParameter must be instanceof CertStoreParameters");
        }
        try {
            return new LDAPCertStore((CertStoreParameters) ctrParamObj);
        } catch (Exception ex) {
            throw new NoSuchAlgorithmException("Error constructing " +
                type + " for " + algo + " using JdkLDAP", ex);
        }
    }
    throw new ProviderException("No impl for " + algo + " " + type);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:21,代码来源:JdkLDAP.java

示例7: getParameters

import java.security.cert.CertStoreParameters; //导入依赖的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

示例8: testCertStore05

import java.security.cert.CertStoreParameters; //导入依赖的package包/类
/**
 * Test for <code>getInstance(String type, CertStoreParameters params)</code> method
 * Assertion: return CertStore object
 */
@TestTargetNew(
    level = TestLevel.PARTIAL,
    notes = "InvalidAlgorithmParameterException checking missed",
    method = "getInstance",
    args = {java.lang.String.class, java.security.cert.CertStoreParameters.class}
)
public void testCertStore05()
        throws InvalidAlgorithmParameterException, NoSuchAlgorithmException {
    if (!initParams()) {
        return;
    }
    CertStore certS;
    for (int i = 0; i < dValid.length; i++) {
        certS = CertStore.getInstance(dValid[i], dParams);
        assertEquals("Incorrect type", certS.getType(), dValid[i]);
        certS.getCertStoreParameters();
    }
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:23,代码来源:CertStore1Test.java

示例9: testCertStore07

import java.security.cert.CertStoreParameters; //导入依赖的package包/类
/**
 * Test for method
 * <code>getInstance(String type, CertStoreParameters params, String provider)</code>
 * Assertion: throws NoSuchProviderException when provider has invalid value
 */
@TestTargetNew(
    level = TestLevel.PARTIAL,
    notes = "Verifies NoSuchProviderException. InvalidAlgorithmParameterException checking missed.",
    method = "getInstance",
    args = {java.lang.String.class, java.security.cert.CertStoreParameters.class, java.lang.String.class}
)
public void testCertStore07()
        throws InvalidAlgorithmParameterException, NoSuchAlgorithmException {
    if (!initParams()) {
        return;
    }
    for (int i = 0; i < dValid.length; i++) {
        for (int j = 1; j < invalidValues.length; j++ ) {
            try {
                CertStore.getInstance(dValid[i], dParams, invalidValues[j]);
                fail("NoSuchProviderException must be thrown");
            } catch (NoSuchProviderException e) {
            }
        }
    }
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:27,代码来源:CertStore1Test.java

示例10: testCertStore10

import java.security.cert.CertStoreParameters; //导入依赖的package包/类
/**
 * Test for method
 * <code>getInstance(String type, CertStoreParameters params, String provider)</code>
 * Assertion: return CertStore object
 */
@TestTargetNew(
    level = TestLevel.PARTIAL,
    notes = "Verifies positive case. InvalidAlgorithmParameterException checking missed.",
    method = "getInstance",
    args = {java.lang.String.class, java.security.cert.CertStoreParameters.class, java.lang.String.class}
)
public void testCertStore10()
        throws InvalidAlgorithmParameterException, NoSuchAlgorithmException, NoSuchProviderException {
    if (!initParams()) {
        return;
    }
    CertStore certS;
    for (int i = 0; i < dValid.length; i++) {
        certS = CertStore.getInstance(dValid[i], dParams, dName);
        assertEquals("Incorrect type", certS.getType(), dValid[i]);
        certS.getCertStoreParameters();
    }
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:24,代码来源:CertStore1Test.java

示例11: testCertStore11

import java.security.cert.CertStoreParameters; //导入依赖的package包/类
/**
 * Test for method
 * <code>getInstance(String type, CertStoreParameters params, Provider provider)</code>
 * Assertion: throws IllegalArgumentException when provider is null
 */
@TestTargetNew(
    level = TestLevel.PARTIAL,
    notes = "Verifies that getInstance throws IllegalArgumentException when provider is null. InvalidAlgorithmParameterException checking missed.",
    method = "getInstance",
    args = {java.lang.String.class, java.security.cert.CertStoreParameters.class, java.security.Provider.class}
)
public void testCertStore11() throws InvalidAlgorithmParameterException,
        NoSuchAlgorithmException {
    if (!initParams()) {
        return;
    }
    Provider provider = null;
    for (int i = 0; i < dValid.length; i++) {
        try {
            CertStore.getInstance(dValid[i], dParams, provider);
            fail("IllegalArgumentException must be thrown");
        } catch (IllegalArgumentException e) {
        }
    }
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:26,代码来源:CertStore1Test.java

示例12: testCertStore14

import java.security.cert.CertStoreParameters; //导入依赖的package包/类
/**
 * Test for method
 * <code>getInstance(String type, CertStoreParameters params, Provider provider)</code>
 * Assertion: return CertStore object
 */
@TestTargetNew(
    level = TestLevel.PARTIAL,
    notes = "Verifies positive case. InvalidAlgorithmParameterException checking missed.",
    method = "getInstance",
    args = {java.lang.String.class, java.security.cert.CertStoreParameters.class, java.security.Provider.class}
)
public void testCertStore14()
        throws InvalidAlgorithmParameterException, NoSuchAlgorithmException {
    if (!initParams()) {
        return;
    }
    CertStore certS;
    for (int i = 0; i < dValid.length; i++) {
        certS = CertStore.getInstance(dValid[i], dParams, dProv);
        assertEquals("Incorrect type", certS.getType(), dValid[i]);
        certS.getCertStoreParameters();
    }
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:24,代码来源:CertStore1Test.java

示例13: MultiCertStoreSpi

import java.security.cert.CertStoreParameters; //导入依赖的package包/类
public MultiCertStoreSpi(CertStoreParameters params)
    throws InvalidAlgorithmParameterException
{
    super(params);

    if (!(params instanceof MultiCertStoreParameters))
    {
        throw new InvalidAlgorithmParameterException("org.bouncycastle.jce.provider.MultiCertStoreSpi: parameter must be a MultiCertStoreParameters object\n" +  params.toString());
    }

    this.params = (MultiCertStoreParameters)params;
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:13,代码来源:MultiCertStoreSpi.java

示例14: CertStoreCollectionSpi

import java.security.cert.CertStoreParameters; //导入依赖的package包/类
public CertStoreCollectionSpi(CertStoreParameters params)
    throws InvalidAlgorithmParameterException
{
    super(params);

    if (!(params instanceof CollectionCertStoreParameters))
    {
        throw new InvalidAlgorithmParameterException("org.bouncycastle.jce.provider.CertStoreCollectionSpi: parameter must be a CollectionCertStoreParameters object\n" +  params.toString());
    }

    this.params = (CollectionCertStoreParameters)params;
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:13,代码来源:CertStoreCollectionSpi.java

示例15: X509LDAPCertStoreSpi

import java.security.cert.CertStoreParameters; //导入依赖的package包/类
public X509LDAPCertStoreSpi(CertStoreParameters params)
    throws InvalidAlgorithmParameterException
{
    super(params);

    if (!(params instanceof X509LDAPCertStoreParameters))
    {
        throw new InvalidAlgorithmParameterException(
            X509LDAPCertStoreSpi.class.getName() + ": parameter must be a " + X509LDAPCertStoreParameters.class.getName() + " object\n"
                + params.toString());
    }

    this.params = (X509LDAPCertStoreParameters)params;
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:15,代码来源:X509LDAPCertStoreSpi.java


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