本文整理汇总了Java中java.security.cert.CertPathBuilderResult类的典型用法代码示例。如果您正苦于以下问题:Java CertPathBuilderResult类的具体用法?Java CertPathBuilderResult怎么用?Java CertPathBuilderResult使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CertPathBuilderResult类属于java.security.cert包,在下文中一共展示了CertPathBuilderResult类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testPKIXCertPathBuilderResult01
import java.security.cert.CertPathBuilderResult; //导入依赖的package包/类
/**
* Test #1 for <code>PKIXCertPathBuilderResult(CertPath, TrustAnchor,
* PolicyNode, PublicKey)</code> constructor<br>
* Assertion: Creates an instance of <code>PKIXCertPathBuilderResult</code>
* @throws NoSuchAlgorithmException
* @throws InvalidKeySpecException
*/
@TestTargetNew(
level = TestLevel.PARTIAL_COMPLETE,
method = "PKIXCertPathBuilderResult",
args = {java.security.cert.CertPath.class, java.security.cert.TrustAnchor.class, java.security.cert.PolicyNode.class, java.security.PublicKey.class}
)
public final void testPKIXCertPathBuilderResult01()
throws InvalidKeySpecException,
NoSuchAlgorithmException {
TrustAnchor ta = TestUtils.getTrustAnchor();
if (ta == null) {
fail(getName() + ": not performed (could not create test TrustAnchor)");
}
CertPathBuilderResult r =
new PKIXCertPathBuilderResult(
new MyCertPath(testEncoding),
ta,
TestUtils.getPolicyTree(),
testPublicKey);
assertTrue(r instanceof PKIXCertPathBuilderResult);
}
示例2: testPKIXCertPathBuilderResult02
import java.security.cert.CertPathBuilderResult; //导入依赖的package包/类
/**
* Test #2 for <code>PKIXCertPathBuilderResult(CertPath, TrustAnchor,
* PolicyNode, PublicKey)</code> constructor<br>
* Assertion: policy tree parameter may be <code>null</code>
* @throws NoSuchAlgorithmException
* @throws InvalidKeySpecException
*/
@TestTargetNew(
level = TestLevel.PARTIAL_COMPLETE,
method = "PKIXCertPathBuilderResult",
args = {java.security.cert.CertPath.class, java.security.cert.TrustAnchor.class, java.security.cert.PolicyNode.class, java.security.PublicKey.class}
)
public final void testPKIXCertPathBuilderResult02()
throws InvalidKeySpecException,
NoSuchAlgorithmException {
TrustAnchor ta = TestUtils.getTrustAnchor();
if (ta == null) {
fail(getName() + ": not performed (could not create test TrustAnchor)");
}
CertPathBuilderResult r =
new PKIXCertPathBuilderResult(
new MyCertPath(testEncoding),
ta,
null,
testPublicKey);
assertTrue(r instanceof PKIXCertPathBuilderResult);
}
示例3: testGetCertPath
import java.security.cert.CertPathBuilderResult; //导入依赖的package包/类
/**
* Test for <code>getCertPath()</code> method<br>
* Assertion: the built and validated <code>CertPath</code>
* (never <code>null</code>)
* @throws NoSuchAlgorithmException
* @throws InvalidKeySpecException
*/
@TestTargetNew(
level = TestLevel.COMPLETE,
notes = "",
method = "getCertPath",
args = {}
)
public final void testGetCertPath() throws Exception {
TrustAnchor ta = TestUtils.getTrustAnchor();
if (ta == null) {
fail(getName() + ": not performed (could not create test TrustAnchor)");
}
CertPath cp = new MyCertPath(testEncoding);
CertPathBuilderResult r =
new PKIXCertPathBuilderResult(
cp,
ta,
TestUtils.getPolicyTree(),
testPublicKey);
// must return the same reference
// as passed to the constructor
assertSame(cp, r.getCertPath());
}
示例4: testToString
import java.security.cert.CertPathBuilderResult; //导入依赖的package包/类
/**
* Test for <code>toString()</code> method<br>
* Assertion: the printable representation of this object
* @throws NoSuchAlgorithmException
* @throws InvalidKeySpecException
*/
@TestTargetNew(
level = TestLevel.COMPLETE,
notes = "",
method = "toString",
args = {}
)
public final void testToString()
throws InvalidKeySpecException,
NoSuchAlgorithmException {
TrustAnchor ta = TestUtils.getTrustAnchor();
if (ta == null) {
fail(getName() + ": not performed (could not create test TrustAnchor)");
}
CertPathBuilderResult r =
new PKIXCertPathBuilderResult(
new MyCertPath(testEncoding),
ta,
TestUtils.getPolicyTree(),
testPublicKey);
assertNotNull(r.toString());
}
示例5: testBuild
import java.security.cert.CertPathBuilderResult; //导入依赖的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);
}
}
示例6: checkResult
import java.security.cert.CertPathBuilderResult; //导入依赖的package包/类
private void checkResult(CertPathBuilder certBuild)
throws InvalidAlgorithmParameterException,
CertPathBuilderException {
String dt = CertPathBuilder.getDefaultType();
String propName = CertPathBuilder1Test.DEFAULT_TYPE_PROPERTY;
String dtN;
for (int i = 0; i <invalidValues.length; i++) {
Security.setProperty(propName, invalidValues[i]);
dtN = CertPathBuilder.getDefaultType();
if (!dtN.equals(invalidValues[i]) && !dtN.equals(dt)) {
fail("Incorrect default type: ".concat(dtN));
}
}
Security.setProperty(propName, dt);
assertEquals("Incorrect default type", CertPathBuilder.getDefaultType(),
dt);
try {
certBuild.build(null);
fail("CertPathBuilderException must be thrown");
} catch (CertPathBuilderException e) {
}
CertPathBuilderResult cpbResult = certBuild.build(null);
assertNull("Not null CertPathBuilderResult", cpbResult);
}
示例7: testPKIXCertPathBuilderResult01
import java.security.cert.CertPathBuilderResult; //导入依赖的package包/类
/**
* Test #1 for <code>PKIXCertPathBuilderResult(CertPath, TrustAnchor,
* PolicyNode, PublicKey)</code> constructor<br>
* Assertion: Creates an instance of <code>PKIXCertPathBuilderResult</code>
* @throws NoSuchAlgorithmException
* @throws InvalidKeySpecException
*/
public final void testPKIXCertPathBuilderResult01()
throws InvalidKeySpecException,
NoSuchAlgorithmException {
TrustAnchor ta = TestUtils.getTrustAnchor();
if (ta == null) {
fail(getName() + ": not performed (could not create test TrustAnchor)");
}
CertPathBuilderResult r =
new PKIXCertPathBuilderResult(
new MyCertPath(testEncoding),
ta,
TestUtils.getPolicyTree(),
testPublicKey);
assertTrue(r instanceof PKIXCertPathBuilderResult);
}
示例8: testPKIXCertPathBuilderResult02
import java.security.cert.CertPathBuilderResult; //导入依赖的package包/类
/**
* Test #2 for <code>PKIXCertPathBuilderResult(CertPath, TrustAnchor,
* PolicyNode, PublicKey)</code> constructor<br>
* Assertion: policy tree parameter may be <code>null</code>
* @throws NoSuchAlgorithmException
* @throws InvalidKeySpecException
*/
public final void testPKIXCertPathBuilderResult02()
throws InvalidKeySpecException,
NoSuchAlgorithmException {
TrustAnchor ta = TestUtils.getTrustAnchor();
if (ta == null) {
fail(getName() + ": not performed (could not create test TrustAnchor)");
}
CertPathBuilderResult r =
new PKIXCertPathBuilderResult(
new MyCertPath(testEncoding),
ta,
null,
testPublicKey);
assertTrue(r instanceof PKIXCertPathBuilderResult);
}
示例9: testGetCertPath
import java.security.cert.CertPathBuilderResult; //导入依赖的package包/类
/**
* Test for <code>getCertPath()</code> method<br>
* Assertion: the built and validated <code>CertPath</code>
* (never <code>null</code>)
* @throws NoSuchAlgorithmException
* @throws InvalidKeySpecException
*/
public final void testGetCertPath() throws Exception {
TrustAnchor ta = TestUtils.getTrustAnchor();
if (ta == null) {
fail(getName() + ": not performed (could not create test TrustAnchor)");
}
CertPath cp = new MyCertPath(testEncoding);
CertPathBuilderResult r =
new PKIXCertPathBuilderResult(
cp,
ta,
TestUtils.getPolicyTree(),
testPublicKey);
// must return the same reference
// as passed to the constructor
assertSame(cp, r.getCertPath());
}
示例10: testToString
import java.security.cert.CertPathBuilderResult; //导入依赖的package包/类
/**
* Test for <code>toString()</code> method<br>
* Assertion: the printable representation of this object
* @throws NoSuchAlgorithmException
* @throws InvalidKeySpecException
*/
public final void testToString()
throws InvalidKeySpecException,
NoSuchAlgorithmException {
TrustAnchor ta = TestUtils.getTrustAnchor();
if (ta == null) {
fail(getName() + ": not performed (could not create test TrustAnchor)");
}
CertPathBuilderResult r =
new PKIXCertPathBuilderResult(
new MyCertPath(testEncoding),
ta,
TestUtils.getPolicyTree(),
testPublicKey);
assertNotNull(r.toString());
}
示例11: checkResult
import java.security.cert.CertPathBuilderResult; //导入依赖的package包/类
private void checkResult(CertPathBuilder certBuild)
throws InvalidAlgorithmParameterException,
CertPathBuilderException {
String dt = CertPathBuilder.getDefaultType();
String propName = CertPathBuilder1Test.DEFAULT_TYPE_PROPERTY;
String dtN;
for (int i = 0; i <invalidValues.length; i++) {
Security.setProperty(propName, invalidValues[i]);
dtN = CertPathBuilder.getDefaultType();
if (!dtN.equals(invalidValues[i]) && !dtN.equals(dt)) {
fail("Incorrect default type: ".concat(dtN));
}
}
Security.setProperty(propName, dt);
assertEquals("Incorrect default type", CertPathBuilder.getDefaultType(),
dt);
try {
certBuild.build(null);
fail("CertPathBuilderException must be thrown");
} catch (CertPathBuilderException e) {
}
CertPathBuilderResult cpbResult = certBuild.build(null);
assertNull("Not null CertPathBuilderResult", cpbResult);
}
示例12: doBuild
import java.security.cert.CertPathBuilderResult; //导入依赖的package包/类
private void doBuild(X509Certificate userCert) throws Exception {
// get the set of trusted CA certificates (only one in this instance)
HashSet trustAnchors = new HashSet();
X509Certificate trustedCert = getTrustedCertificate();
trustAnchors.add(new TrustAnchor(trustedCert, null));
// put together a CertStore (repository of the certificates and CRLs)
ArrayList certs = new ArrayList();
certs.add(trustedCert);
certs.add(userCert);
CollectionCertStoreParameters certStoreParams = new CollectionCertStoreParameters(certs);
CertStore certStore = CertStore.getInstance("Collection", certStoreParams);
// specify the target certificate via a CertSelector
X509CertSelector certSelector = new X509CertSelector();
certSelector.setCertificate(userCert);
certSelector.setSubject(userCert.getSubjectDN().getName()); // seems to be required
// build a valid cerificate path
CertPathBuilder certPathBuilder = CertPathBuilder.getInstance("PKIX", "SUN");
PKIXBuilderParameters certPathBuilderParams = new PKIXBuilderParameters(trustAnchors, certSelector);
certPathBuilderParams.addCertStore(certStore);
certPathBuilderParams.setRevocationEnabled(false);
CertPathBuilderResult result = certPathBuilder.build(certPathBuilderParams);
// get and show cert path
CertPath certPath = result.getCertPath();
// System.out.println(certPath.toString());
}
示例13: build
import java.security.cert.CertPathBuilderResult; //导入依赖的package包/类
/**
* Perform a PKIX build.
*
* @param params PKIXBuilderParameters to use in building
* @throws Exception on error
*/
public static void build(PKIXBuilderParameters params)
throws Exception {
CertPathBuilder builder =
CertPathBuilder.getInstance("PKIX");
CertPathBuilderResult cpbr = builder.build(params);
}
示例14: build
import java.security.cert.CertPathBuilderResult; //导入依赖的package包/类
/**
* Perform a PKIX build.
*
* @param params PKIXBuilderParameters to use in the build
* @throws Exception on error
*/
public static void build(PKIXBuilderParameters params)
throws Exception {
CertPathBuilder builder =
CertPathBuilder.getInstance("PKIX", "SUN");
CertPathBuilderResult cpbr = builder.build(params);
}