本文整理汇总了Java中org.bouncycastle.pkcs.PKCS10CertificationRequest.equals方法的典型用法代码示例。如果您正苦于以下问题:Java PKCS10CertificationRequest.equals方法的具体用法?Java PKCS10CertificationRequest.equals怎么用?Java PKCS10CertificationRequest.equals使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bouncycastle.pkcs.PKCS10CertificationRequest
的用法示例。
在下文中一共展示了PKCS10CertificationRequest.equals方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: nullPointerTest
import org.bouncycastle.pkcs.PKCS10CertificationRequest; //导入方法依赖的package包/类
private void nullPointerTest()
throws Exception
{
KeyPairGenerator keyGen = KeyPairGenerator.getInstance("RSA", "BC");
keyGen.initialize(1024, new SecureRandom());
KeyPair pair = keyGen.generateKeyPair();
JcaX509ExtensionUtils extUtils = new JcaX509ExtensionUtils();
Extension[] ext = new Extension[] {
new Extension(Extension.basicConstraints, true, new DEROctetString(new BasicConstraints(true))),
new Extension(Extension.keyUsage, true, new DEROctetString(new KeyUsage(KeyUsage.keyCertSign | KeyUsage.cRLSign))),
new Extension(Extension.subjectKeyIdentifier, false, new DEROctetString(extUtils.createSubjectKeyIdentifier(pair.getPublic())))
};
PKCS10CertificationRequest p1 = new JcaPKCS10CertificationRequestBuilder(
new X500Name("cn=csr"),
pair.getPublic())
.addAttribute(PKCSObjectIdentifiers.pkcs_9_at_extensionRequest, new Extensions(ext))
.build(new JcaContentSignerBuilder("SHA1withRSA").setProvider(BC).build(pair.getPrivate()));
PKCS10CertificationRequest p2 = new JcaPKCS10CertificationRequestBuilder(
new X500Name("cn=csr"),
pair.getPublic())
.addAttribute(PKCSObjectIdentifiers.pkcs_9_at_extensionRequest, new Extensions(ext))
.build(new JcaContentSignerBuilder("SHA1withRSA").setProvider(BC).build(pair.getPrivate()));
if (!p1.equals(p2))
{
fail("cert request comparison failed");
}
Attribute[] attr1 = p1.getAttributes();
Attribute[] attr2 = p1.getAttributes();
checkAttrs(1, attr1, attr2);
attr1 = p1.getAttributes(PKCSObjectIdentifiers.pkcs_9_at_extensionRequest);
attr2 = p1.getAttributes(PKCSObjectIdentifiers.pkcs_9_at_extensionRequest);
checkAttrs(1, attr1, attr2);
}
示例2: nullPointerTest
import org.bouncycastle.pkcs.PKCS10CertificationRequest; //导入方法依赖的package包/类
private void nullPointerTest()
throws Exception
{
AsymmetricCipherKeyPairGenerator kpg = new RSAKeyPairGenerator();
RSAKeyGenerationParameters genParam = new RSAKeyGenerationParameters(
BigInteger.valueOf(0x1001), new SecureRandom(), 1024, 25);
kpg.init(genParam);
AsymmetricCipherKeyPair kp = kpg.generateKeyPair();
ExtensionsGenerator extGen = new ExtensionsGenerator();
extGen.addExtension(Extension.basicConstraints, true, new BasicConstraints(true));
extGen.addExtension(Extension.keyUsage, true, new KeyUsage(KeyUsage.keyCertSign | KeyUsage.cRLSign));
BcX509ExtensionUtils extUtils = new BcX509ExtensionUtils(new SHA1DigestCalculator());
SubjectKeyIdentifier subjectKeyIdentifier = extUtils.createSubjectKeyIdentifier(kp.getPublic());
extGen.addExtension(Extension.subjectKeyIdentifier, false, subjectKeyIdentifier);
DefaultSignatureAlgorithmIdentifierFinder sigAlgFinder = new DefaultSignatureAlgorithmIdentifierFinder();
DefaultDigestAlgorithmIdentifierFinder digAlgFinder = new DefaultDigestAlgorithmIdentifierFinder();
AlgorithmIdentifier sigAlgId = sigAlgFinder.find("SHA1withRSA");
AlgorithmIdentifier digAlgId = digAlgFinder.find(sigAlgId);
BcContentSignerBuilder contentSignerBuilder = new BcRSAContentSignerBuilder(sigAlgId, digAlgId);
PKCS10CertificationRequest p1 = new BcPKCS10CertificationRequestBuilder(
new X500Name("cn=csr"), kp.getPublic())
.addAttribute(PKCSObjectIdentifiers.pkcs_9_at_extensionRequest, extGen.generate())
.build(contentSignerBuilder.build(kp.getPrivate()));
PKCS10CertificationRequest p2 = new BcPKCS10CertificationRequestBuilder(
new X500Name("cn=csr"), kp.getPublic())
.addAttribute(PKCSObjectIdentifiers.pkcs_9_at_extensionRequest, extGen.generate())
.build(contentSignerBuilder.build(kp.getPrivate()));
if (!p1.equals(p2))
{
fail("cert request comparison failed");
}
Attribute[] attr1 = p1.getAttributes();
Attribute[] attr2 = p1.getAttributes();
checkAttrs(1, attr1, attr2);
attr1 = p1.getAttributes(PKCSObjectIdentifiers.pkcs_9_at_extensionRequest);
attr2 = p1.getAttributes(PKCSObjectIdentifiers.pkcs_9_at_extensionRequest);
checkAttrs(1, attr1, attr2);
}
示例3: nullPointerTest
import org.bouncycastle.pkcs.PKCS10CertificationRequest; //导入方法依赖的package包/类
private void nullPointerTest()
throws Exception
{
KeyPairGenerator keyGen = KeyPairGenerator.getInstance("RSA", "BC");
keyGen.initialize(1024, new SecureRandom());
KeyPair pair = keyGen.generateKeyPair();
Vector oids = new Vector();
Vector values = new Vector();
oids.addElement(X509Extension.basicConstraints);
values.addElement(new X509Extension(true, new DEROctetString(new BasicConstraints(true))));
oids.addElement(X509Extension.keyUsage);
values.addElement(new X509Extension(true, new DEROctetString(
new KeyUsage(KeyUsage.keyCertSign | KeyUsage.cRLSign))));
SubjectKeyIdentifier subjectKeyIdentifier = new SubjectKeyIdentifierStructure(pair.getPublic());
X509Extension ski = new X509Extension(false, new DEROctetString(subjectKeyIdentifier));
oids.addElement(X509Extension.subjectKeyIdentifier);
values.addElement(ski);
PKCS10CertificationRequest p1 = new JcaPKCS10CertificationRequestBuilder(
new X500Name("cn=csr"),
pair.getPublic())
.addAttribute(PKCSObjectIdentifiers.pkcs_9_at_extensionRequest, new X509Extensions(oids, values))
.build(new JcaContentSignerBuilder("SHA1withRSA").setProvider(BC).build(pair.getPrivate()));
PKCS10CertificationRequest p2 = new JcaPKCS10CertificationRequestBuilder(
new X500Name("cn=csr"),
pair.getPublic())
.addAttribute(PKCSObjectIdentifiers.pkcs_9_at_extensionRequest, new X509Extensions(oids, values))
.build(new JcaContentSignerBuilder("SHA1withRSA").setProvider(BC).build(pair.getPrivate()));
if (!p1.equals(p2))
{
fail("cert request comparison failed");
}
Attribute[] attr1 = p1.getAttributes();
Attribute[] attr2 = p1.getAttributes();
checkAttrs(1, attr1, attr2);
attr1 = p1.getAttributes(PKCSObjectIdentifiers.pkcs_9_at_extensionRequest);
attr2 = p1.getAttributes(PKCSObjectIdentifiers.pkcs_9_at_extensionRequest);
checkAttrs(1, attr1, attr2);
}