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


Java CertPathParameters类代码示例

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


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

示例1: getParameters

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

示例2: getParameters

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

示例3: getCertPathParameters

import java.security.cert.CertPathParameters; //导入依赖的package包/类
public static CertPathParameters getCertPathParameters()
        throws InvalidAlgorithmParameterException {
    if ((rootCertificateSS == null) || (theCertSelector == null)
            || (builder == null)) {
        throw new RuntimeException(
                "Call initCertPathSSCertChain prior to buildCertPath");
    }
    PKIXBuilderParameters buildParams = new PKIXBuilderParameters(
            Collections.singleton(new TrustAnchor(rootCertificateSS, null)),
            theCertSelector);

    buildParams.addCertStore(store);
    buildParams.setRevocationEnabled(false);

    return buildParams;

}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:18,代码来源:TestUtils.java

示例4: engineValidate

import java.security.cert.CertPathParameters; //导入依赖的package包/类
public CertPathValidatorResult engineValidate(CertPath certPath,
        CertPathParameters params) throws CertPathValidatorException,
        InvalidAlgorithmParameterException {
    ++sw;
    if (certPath == null) {
        if ((sw % 2) == 0) {
            throw new CertPathValidatorException("certPath null");
        }
    }
    if (params == null) {
        if ((sw % 3) == 0) {
            throw new InvalidAlgorithmParameterException("params null");
        }
    }
    return null;
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:17,代码来源:MyCertPathValidatorSpi.java

示例5: testCertPathBuilder11

import java.security.cert.CertPathParameters; //导入依赖的package包/类
/**
 * Test for <code>build(CertPathParameters params)</code> method
 * Assertion: throws InvalidAlgorithmParameterException params is null
 */
@TestTargetNew(
    level = TestLevel.PARTIAL_COMPLETE,
    notes = "Verifies that build method throws InvalidAlgorithmParameterException if a parameter is null.",
    method = "build",
    args = {java.security.cert.CertPathParameters.class}
)
public void testCertPathBuilder11()
        throws NoSuchAlgorithmException, NoSuchProviderException,
        CertPathBuilderException {
    if (!PKIXSupport) {
        fail(NotSupportMsg);
        return;
    }
    CertPathBuilder [] certPB = createCPBs();
    assertNotNull("CertPathBuilder objects were not created", certPB);
    for (int i = 0; i < certPB.length; i++ ){
        try {
            certPB[i].build(null);
            fail("InvalidAlgorithmParameterException must be thrown");
        } catch(InvalidAlgorithmParameterException e) {
        }
    }
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:28,代码来源:CertPathBuilder1Test.java

示例6: testBuild

import java.security.cert.CertPathParameters; //导入依赖的package包/类
@TestTargetNew(
        level=TestLevel.PARTIAL_COMPLETE,
        notes = "Verifies normal case",
        method="build",
        args={CertPathParameters.class}
)
// Test passed on RI
@KnownFailure(value="expired certificate bug 2322662")
public void testBuild() throws Exception {
    TestUtils.initCertPathSSCertChain();
    CertPathParameters params = TestUtils.getCertPathParameters();
    CertPathBuilder builder = TestUtils.getCertPathBuilder();

    try {
        CertPathBuilderResult result = builder.build(params);
        assertNotNull("builder result is null", result);
        CertPath certPath = result.getCertPath();
        assertNotNull("certpath of builder result is null", certPath);
    } catch (InvalidAlgorithmParameterException e) {
        fail("unexpected Exception: " + e);
    }

}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:24,代码来源:CertPathBuilder1Test.java

示例7: testCertPathValidator

import java.security.cert.CertPathParameters; //导入依赖的package包/类
@TestTargets({
    @TestTargetNew(
            level=TestLevel.ADDITIONAL,
            method="getInstance",
            args={String.class}
    ),
    @TestTargetNew(
            level=TestLevel.ADDITIONAL,
            method="validate",
            args={CertPath.class, CertPathParameters.class}
    ),
    @TestTargetNew(
            level=TestLevel.COMPLETE,
            method="method",
            args={}
    )
})
public void testCertPathValidator() throws Exception {
    CertPathValidator certPathValidator = CertPathValidator.getInstance(
            algorithmName);

    CertPathValidatorResult validatorResult = certPathValidator.validate(
            getCertPath(), getParams());

    validateResult(validatorResult);
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:27,代码来源:CertPathValidatorTest.java

示例8: test_getParameters

import java.security.cert.CertPathParameters; //导入依赖的package包/类
/**
 * @tests javax.net.ssl.CertPathTrustManagerParameters#getParameters()
 */
@TestTargetNew(
    level = TestLevel.COMPLETE,
    notes = "",
    method = "getParameters",
    args = {}
)
public void test_getParameters() {
    CertPathParameters parameters = new MyCertPathParameters();
    CertPathTrustManagerParameters p = new CertPathTrustManagerParameters(
            parameters);
    if (!(p.getParameters() instanceof MyCertPathParameters)) {
        fail("incorrect parameters");
    }
    assertNotSame("Parameters were cloned incorrectly",
            parameters, p.getParameters());
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:20,代码来源:CertPathTrustManagerParametersTest.java

示例9: engineValidate

import java.security.cert.CertPathParameters; //导入依赖的package包/类
public CertPathValidatorResult engineValidate(CertPath certPath,
        CertPathParameters params) throws CertPathValidatorException,
        InvalidAlgorithmParameterException {
    ++sw; 
    if (certPath == null) {
        if ((sw % 2) == 0) {
            throw new CertPathValidatorException("certPath null");
        }
    }
    if (params == null) {
        if ((sw % 3) == 0) {
            throw new InvalidAlgorithmParameterException("params null");
        }
    }
    return null;
}
 
开发者ID:shannah,项目名称:cn1,代码行数:17,代码来源:MyCertPathValidatorSpi.java

示例10: getParameters

import java.security.cert.CertPathParameters; //导入依赖的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:liaokailin,项目名称:tomcat7,代码行数:38,代码来源:JSSESocketFactory.java

示例11: getParameters

import java.security.cert.CertPathParameters; //导入依赖的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);
        String trustLength = (String)attributes.get("trustMaxCertLength");
        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:lamsfoundation,项目名称:lams,代码行数:38,代码来源:JSSESocketFactory.java

示例12: engineBuild

import java.security.cert.CertPathParameters; //导入依赖的package包/类
public CertPathBuilderResult engineBuild(CertPathParameters params)
        throws CertPathBuilderException, InvalidAlgorithmParameterException {
    swi++;
    if ((params == null) && ((swi %2 ) != 0)) {
        throw new CertPathBuilderException("Null parameter");
    }
    return null;
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:9,代码来源:MyCertPathBuilderSpi.java

示例13: testCertPathBuilderSpi01

import java.security.cert.CertPathParameters; //导入依赖的package包/类
/**
 * Test for <code>CertPathBuilderSpi</code> constructor Assertion:
 * constructs CertPathBuilderSpi
 */
@TestTargets({
    @TestTargetNew(
        level = TestLevel.COMPLETE,
        notes = "",
        method = "CertPathBuilderSpi",
        args = {}
    ),
    @TestTargetNew(
        level = TestLevel.COMPLETE,
        notes = "",
        method = "engineBuild",
        args = {java.security.cert.CertPathParameters.class}
    )
})
public void testCertPathBuilderSpi01() throws CertPathBuilderException,
        InvalidAlgorithmParameterException {
    CertPathBuilderSpi certPathBuilder = new MyCertPathBuilderSpi();
    CertPathParameters cpp = null;
    try {
        certPathBuilder.engineBuild(cpp);
        fail("CertPathBuilderException must be thrown");
    } catch (CertPathBuilderException e) {
    }
    CertPathBuilderResult cpbResult = certPathBuilder.engineBuild(cpp);
    assertNull("Not null CertPathBuilderResult", cpbResult);
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:31,代码来源:CertPathBuilderSpiTest.java

示例14: testCertPathBuilder

import java.security.cert.CertPathParameters; //导入依赖的package包/类
@TestTargets({
    @TestTargetNew(
            level=TestLevel.ADDITIONAL,
            method="getInstance",
            args={String.class}
    ),
    @TestTargetNew(
            level=TestLevel.ADDITIONAL,
            method="build",
            args={CertPathParameters.class}
    ),
    @TestTargetNew(
            level=TestLevel.ADDITIONAL,
            clazz=CertPathBuilderResult.class,
            method="getCertPath",
            args={}
    ),
    @TestTargetNew(
            level=TestLevel.COMPLETE,
            method="method",
            args={}
    )
})
public void testCertPathBuilder() throws Exception {
    CertPathBuilder pathBuilder = CertPathBuilder.getInstance(
            algorithmName);

    CertPathBuilderResult builderResult = pathBuilder.build(params);

    CertPath path = builderResult.getCertPath();

    assertNotNull("built path is null", path);

    validateCertPath(path);
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:36,代码来源:CertPathBuilderTest.java

示例15: getCertPathParameters

import java.security.cert.CertPathParameters; //导入依赖的package包/类
@Override
public CertPathParameters getCertPathParameters() throws Exception {
    KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType());

    keyStore.load(null, null);

    CertificateFactory certificateFactory = CertificateFactory.getInstance(
            "X509");

    X509Certificate selfSignedcertificate =
            (X509Certificate) certificateFactory.generateCertificate(
                    new ByteArrayInputStream(selfSignedCert.getBytes()));

    keyStore.setCertificateEntry("selfSignedCert", selfSignedcertificate);

    X509CertSelector targetConstraints = new X509CertSelector();
    targetConstraints.setCertificate(selfSignedcertificate);

    List<Certificate> certList = new ArrayList<Certificate>();
    certList.add(selfSignedcertificate);
    CertStoreParameters storeParams = new CollectionCertStoreParameters(
            certList);


    CertStore certStore = CertStore.getInstance("Collection", storeParams);


    PKIXBuilderParameters parameters = new PKIXBuilderParameters(
            keyStore, targetConstraints);
    parameters.addCertStore(certStore);
    parameters.setRevocationEnabled(false);
    return parameters;
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:34,代码来源:CertPathBuilderTestPKIX.java


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