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


Java PKCS10CertificationRequest.equals方法代码示例

本文整理汇总了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);
}
 
开发者ID:credentials,项目名称:irma_future_id,代码行数:41,代码来源:PKCS10Test.java

示例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);
}
 
开发者ID:credentials,项目名称:irma_future_id,代码行数:55,代码来源:BcPKCS10Test.java

示例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);
}
 
开发者ID:credentials,项目名称:irma_future_id,代码行数:46,代码来源:PKCS10Test.java


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