本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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) {
}
}
}
示例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);
}
}
示例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);
}
示例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());
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
示例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;
}