• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java SignatureAlgorithmIdentifierFinder类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: getSignerInfos

import org.bouncycastle.operator.SignatureAlgorithmIdentifierFinder; //导入依赖的package包/类
/**
 * return the collection of signers that are associated with the
 * signatures for the message.
 */
public SignerInformationStore getSignerInfos()
{
    if (signerInfoStore == null)
    {
        ASN1Set         s = signedData.getSignerInfos();
        List            signerInfos = new ArrayList();
        SignatureAlgorithmIdentifierFinder sigAlgFinder = new DefaultSignatureAlgorithmIdentifierFinder();

        for (int i = 0; i != s.size(); i++)
        {
            SignerInfo info = SignerInfo.getInstance(s.getObjectAt(i));
            ASN1ObjectIdentifier contentType = signedData.getEncapContentInfo().getContentType();

            if (hashes == null)
            {
                signerInfos.add(new SignerInformation(info, contentType, signedContent, null));
            }
            else
            {
                Object obj = hashes.keySet().iterator().next();
                byte[] hash = (obj instanceof String) ? (byte[])hashes.get(info.getDigestAlgorithm().getAlgorithm().getId()) : (byte[])hashes.get(info.getDigestAlgorithm().getAlgorithm());

                signerInfos.add(new SignerInformation(info, contentType, null, hash));
            }
        }

        signerInfoStore = new SignerInformationStore(signerInfos);
    }

    return signerInfoStore;
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:36,代码来源:CMSSignedData.java


示例2: BcRSASignerInfoVerifierBuilder

import org.bouncycastle.operator.SignatureAlgorithmIdentifierFinder; //导入依赖的package包/类
public BcRSASignerInfoVerifierBuilder(CMSSignatureAlgorithmNameGenerator sigAlgNameGen, SignatureAlgorithmIdentifierFinder sigAlgIdFinder, DigestAlgorithmIdentifierFinder digestAlgorithmFinder, DigestCalculatorProvider digestCalculatorProvider)
{
    this.sigAlgNameGen = sigAlgNameGen;
    this.sigAlgIdFinder = sigAlgIdFinder;
    this.contentVerifierProviderBuilder = new BcRSAContentVerifierProviderBuilder(digestAlgorithmFinder);
    this.digestCalculatorProvider = digestCalculatorProvider;
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:8,代码来源:BcRSASignerInfoVerifierBuilder.java


示例3: SignerInformationVerifier

import org.bouncycastle.operator.SignatureAlgorithmIdentifierFinder; //导入依赖的package包/类
public SignerInformationVerifier(CMSSignatureAlgorithmNameGenerator sigNameGenerator, SignatureAlgorithmIdentifierFinder sigAlgorithmFinder, ContentVerifierProvider verifierProvider, DigestCalculatorProvider digestProvider)
{
    this.sigNameGenerator = sigNameGenerator;
    this.sigAlgorithmFinder = sigAlgorithmFinder;
    this.verifierProvider = verifierProvider;
    this.digestProvider = digestProvider;
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:8,代码来源:SignerInformationVerifier.java


示例4: setSignatureAlgorithmFinder

import org.bouncycastle.operator.SignatureAlgorithmIdentifierFinder; //导入依赖的package包/类
public JcaSignerInfoVerifierBuilder setSignatureAlgorithmFinder(SignatureAlgorithmIdentifierFinder sigAlgIDFinder)
{
    this.sigAlgIDFinder = sigAlgIDFinder;

    return this;
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:7,代码来源:JcaSignerInfoVerifierBuilder.java


示例5: testCreateCsrFromPemV2_bcprov_jdk15on_1_50

import org.bouncycastle.operator.SignatureAlgorithmIdentifierFinder; //导入依赖的package包/类
/**
 * Read the pkcs#10 CSR pem text and create a BC CSR object for subsequent
 * verifying and manipulation. This test uses bcprov-jdk15on-1.50.jar and
 * bcpkix-jdk15on-1.50.jar
 *
 * @throws Exception
 */
@Test
public void testCreateCsrFromPemV2_bcprov_jdk15on_1_50() throws Exception {
    SignatureAlgorithmIdentifierFinder algFinder = new DefaultSignatureAlgorithmIdentifierFinder();
    String csrPemStr = this.getCsrIrregularOrderDN();

    PemReader pemReader = new PemReader(new StringReader(csrPemStr));
    PemObject obj = pemReader.readPemObject();
    pemReader.close();
    byte[] pembytes = obj.getContent();
    PKCS10CertificationRequest req = new PKCS10CertificationRequest(pembytes);

    assertEquals("CN=some body,C=UK,L=DL,O=eScience,OU=CLRC", req.getSubject().toString());
    //System.out.println(req.getSubject().toString());
    SubjectPublicKeyInfo pkInfo = req.getSubjectPublicKeyInfo();

    // get the algorithm of the pubkey RSA  
    AlgorithmIdentifier pubKeyAlgId = pkInfo.getAlgorithm();
    //System.out.println(pubKeyAlgId.getAlgorithm().getId());   // 1.2.840.113549.1.1.1
    //System.out.println(pubKeyAlgId.getAlgorithm().toString());// 1.2.840.113549.1.1.1
    assertEquals("1.2.840.113549.1.1.1", pubKeyAlgId.getAlgorithm().getId());

    // get the algorithm of the request (we expect SHA1 with RSA)  
    AlgorithmIdentifier reqSigAlgId = req.getSignatureAlgorithm();
    AlgorithmIdentifier algIdExpected = algFinder.find("SHA1WITHRSAENCRYPTION"); // or "SHA1withRSA", "SHA1withRSAEncryption" 
    assertEquals(reqSigAlgId.getAlgorithm().getId(), algIdExpected.getAlgorithm().getId());
    assertEquals("1.2.840.113549.1.1.5", algIdExpected.getAlgorithm().getId());

    // Get java.security.PublicKey so we can validate and get the DB formatted pub key  
    // Looks like we can get the public key in two ways: 
    //
    // 1) 
    //http://stackoverflow.com/questions/11028932/how-to-get-publickey-from-pkcs10certificationrequest-using-new-bouncy-castle-lib
    RSAKeyParameters rsa = (RSAKeyParameters) PublicKeyFactory.createKey(pkInfo);
    assertEquals(2048, rsa.getModulus().bitLength());
    RSAPublicKeySpec rsaSpec = new RSAPublicKeySpec(rsa.getModulus(), rsa.getExponent());
    KeyFactory kf = KeyFactory.getInstance("RSA");
    PublicKey pubKey1 = kf.generatePublic(rsaSpec);
    String pubkey1DBFormat = getDBFormattedRSAPublicKey(pubKey1);
    boolean valid = req.isSignatureValid((new JcaContentVerifierProviderBuilder()).build(pubKey1));
    assertTrue(valid);
    //
    // 2) 
    JcaPKCS10CertificationRequest jcaReq = new JcaPKCS10CertificationRequest(req);
    PublicKey pubKey2 = jcaReq.getPublicKey();
    RSAPublicKey rsa2 = (RSAPublicKey) pubKey2;
    assertEquals(2048, rsa2.getModulus().bitLength());

    String pubkey2DBFormat = getDBFormattedRSAPublicKey(pubKey2);
    assertTrue(jcaReq.isSignatureValid((new JcaContentVerifierProviderBuilder()).build(pubKey2)));

    // Test that the two DB formated pubkeys are the same 
    assertEquals(pubkey1DBFormat, pubkey2DBFormat);

}
 
开发者ID:UKCA,项目名称:CAPortal,代码行数:62,代码来源:TestBC_PKCS10.java


示例6: testPythonSigned

import org.bouncycastle.operator.SignatureAlgorithmIdentifierFinder; //导入依赖的package包/类
@Test
public void testPythonSigned() throws Exception {
    final InputStream pythonIs = Thread.currentThread().getContextClassLoader().getResourceAsStream("python_signed.txt");

  /*
  Message message = new Message(pythonIs);
  Multipart multipart = (Multipart)message.getBody();
  System.out.println("count: " + multipart.getCount());
  */

    ByteArrayDataSource ds = new ByteArrayDataSource(pythonIs, "multipart/signed");
    MimeMultipart mm = new MimeMultipart(ds);

    System.out.println(mm.getContentType());

    System.out.println("Multipart.count(): " + mm.getCount());

    MimeBodyPart mbp = (MimeBodyPart) mm.getBodyPart(0);

    output(mbp);

    SMIMESigned signed = new SMIMESigned(mm);

    SignerInformationStore signers = signed.getSignerInfos();
    Assert.assertEquals(1, signers.size());
    SignerInformation signer = (SignerInformation) signers.getSigners().iterator().next();


    final CMSSignatureAlgorithmNameGenerator cmsSignatureAlgorithmNameGenerator = new DefaultCMSSignatureAlgorithmNameGenerator();
    final SignatureAlgorithmIdentifierFinder signatureAlgorithmIdentifierFinder = new DefaultSignatureAlgorithmIdentifierFinder();
    final JcaContentVerifierProviderBuilder jcaContentVerifierProviderBuilder = new JcaContentVerifierProviderBuilder();
    final ContentVerifierProvider contentVerifierProvider = jcaContentVerifierProviderBuilder.build(cert.getPublicKey());
    final DigestCalculatorProvider digestCalculatorProvider = new BcDigestCalculatorProvider();

    SignerInformationVerifier verifier = new SignerInformationVerifier(
            cmsSignatureAlgorithmNameGenerator,
            signatureAlgorithmIdentifierFinder,
            contentVerifierProvider,
            digestCalculatorProvider);

    Assert.assertTrue(signer.verify(verifier));
}
 
开发者ID:gini,项目名称:jersey-smime,代码行数:43,代码来源:SignedTest.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Header类代码示例发布时间:2022-05-23
下一篇:
Java InvalidTypesException类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap