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


Java Store.getMatches方法代码示例

本文整理汇总了Java中org.bouncycastle.util.Store.getMatches方法的典型用法代码示例。如果您正苦于以下问题:Java Store.getMatches方法的具体用法?Java Store.getMatches怎么用?Java Store.getMatches使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bouncycastle.util.Store的用法示例。


在下文中一共展示了Store.getMatches方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getSignersCertificates

import org.bouncycastle.util.Store; //导入方法依赖的package包/类
private Collection<X509Certificate> getSignersCertificates(CMSSignedData previewSignerData) {
	Collection<X509Certificate> result = new HashSet<X509Certificate>();
	Store<?> certStore = previewSignerData.getCertificates();
	SignerInformationStore signers = previewSignerData.getSignerInfos();
	Iterator<?> it = signers.getSigners().iterator();
	while (it.hasNext()) {
		SignerInformation signer = (SignerInformation) it.next();
		@SuppressWarnings("unchecked")
		Collection<?> certCollection = certStore.getMatches(signer.getSID());
		Iterator<?> certIt = certCollection.iterator();
		X509CertificateHolder certificateHolder = (X509CertificateHolder) certIt.next();
		try {
			result.add(new JcaX509CertificateConverter().getCertificate(certificateHolder));
		} catch (CertificateException error) {
		}
	}
	return result;

}
 
开发者ID:demoiselle,项目名称:signer,代码行数:20,代码来源:CAdESSigner.java

示例2: verifyRSASignatures

import org.bouncycastle.util.Store; //导入方法依赖的package包/类
private void verifyRSASignatures(CMSSignedData s, byte[] contentDigest)
    throws Exception
{
    Store                   certStore = s.getCertificates();
    SignerInformationStore  signers = s.getSignerInfos();

    Collection c = signers.getSigners();
    Iterator it = c.iterator();

    while (it.hasNext())
    {
        SignerInformation   signer = (SignerInformation)it.next();
        Collection certCollection = certStore.getMatches(signer.getSID());

        Iterator certIt = certCollection.iterator();
        X509CertificateHolder cert = (X509CertificateHolder)certIt.next();

        assertEquals(true, signer.verify(new BcRSASignerInfoVerifierBuilder(new DefaultCMSSignatureAlgorithmNameGenerator(), new DefaultSignatureAlgorithmIdentifierFinder(), new DefaultDigestAlgorithmIdentifierFinder(), new BcDigestCalculatorProvider()).build(cert)));

        if (contentDigest != null)
        {
            assertTrue(MessageDigest.isEqual(contentDigest, signer.getContentDigest()));
        }
    }
}
 
开发者ID:credentials,项目名称:irma_future_id,代码行数:26,代码来源:BcSignedDataTest.java

示例3: addBasicOcspRespFrom_id_ri_ocsp_response

import org.bouncycastle.util.Store; //导入方法依赖的package包/类
private void addBasicOcspRespFrom_id_ri_ocsp_response(final List<BasicOCSPResp> basicOCSPResps) {
	final Store otherRevocationInfo = cmsSignedData.getOtherRevocationInfo(CMSObjectIdentifiers.id_ri_ocsp_response);
	final Collection otherRevocationInfoMatches = otherRevocationInfo.getMatches(null);
	for (final Object object : otherRevocationInfoMatches) {
		if (object instanceof DERSequence) {
			final DERSequence otherRevocationInfoMatch = (DERSequence) object;
			final BasicOCSPResp basicOCSPResp;
			if (otherRevocationInfoMatch.size() == 4) {
				basicOCSPResp = CMSUtils.getBasicOcspResp(otherRevocationInfoMatch);
			} else {
				final OCSPResp ocspResp = CMSUtils.getOcspResp(otherRevocationInfoMatch);
				basicOCSPResp = CMSUtils.getBasicOCSPResp(ocspResp);
			}
			addBasicOcspResp(basicOCSPResps, basicOCSPResp);
		} else {
			LOG.warn("Unsupported object type for id_ri_ocsp_response (SHALL be DER encoding) : " + object.getClass().getSimpleName());
		}
	}
}
 
开发者ID:esig,项目名称:dss,代码行数:20,代码来源:CAdESOCSPSource.java

示例4: getCertificateChain

import org.bouncycastle.util.Store; //导入方法依赖的package包/类
private static List<X509Certificate> getCertificateChain(
		X509CertificateHolder certificateHolder, Store certificatesStore)
		throws CertificateException, IOException {
	CertificateFactory certificateFactory = CertificateFactory
			.getInstance("X.509");
	List<X509Certificate> certificateChain = new LinkedList<>();
	while (true) {
		X509Certificate certificate = (X509Certificate) certificateFactory
				.generateCertificate(new ByteArrayInputStream(
						certificateHolder.getEncoded()));
		certificateChain.add(certificate);
		LOG.debug("certificate: " + certificate.getSubjectX500Principal());
		IssuerSelector issuerSelector = new IssuerSelector(
				certificateHolder);
		Collection<X509CertificateHolder> issuerCollection = certificatesStore
				.getMatches(issuerSelector);
		if (issuerCollection.isEmpty()) {
			break;
		}
		certificateHolder = issuerCollection.iterator().next();
	}
	return certificateChain;
}
 
开发者ID:e-Contract,项目名称:jtrust,代码行数:24,代码来源:TSATest.java

示例5: verify

import org.bouncycastle.util.Store; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public void verify(CMSSignature signature) throws CryptoException {
    Store certStore = signature.getSignedDataCertificates();
    SignerInformationStore signerInformationStore = signature.getSignerInformationStore();
    Collection<SignerInformation> signerCollection = signerInformationStore.getSigners();
    if (signerCollection.isEmpty()) {
        throw new InvalidCmsSignatureException("Invalid CMS signature. Signature does not contain SignerInformation element.");
    }
    if (signerCollection.size() != 1) {
        throw new InvalidCmsSignatureException("Invalid CMS signature. Signature contains multiple SingerInformation elements.");
    }
    SignerInformation signerInfo = signerCollection.iterator().next();
    Collection certCollection = certStore.getMatches(signerInfo.getSID());
    Iterator certIterator = certCollection.iterator();

    if (certCollection.isEmpty()) {
        throw new InvalidCmsSignatureException("Invalid CMS signature. Signer certificate collection is empty.");
    }

    X509CertificateHolder certHolder = (X509CertificateHolder) certIterator.next();
    verifyCmsSignerInfo(signerInfo, certHolder);
    if(!trustStore.isTrusted(getCertificate(certHolder), certStore)) {
        throw new InvalidCmsSignatureException("Certificate that was used for singing isn't trusted");
    }
}
 
开发者ID:guardtime,项目名称:ksi-java-sdk,代码行数:26,代码来源:CMSSignatureVerifier.java

示例6: certRecursive

import org.bouncycastle.util.Store; //导入方法依赖的package包/类
private void certRecursive( List<CertificateInfo> chains ,
		Store store1, X509CertificateHolder certholder )
		throws CertificateException {
	
	AttributeCertificateHolder selec = new AttributeCertificateHolder(
			certholder.getIssuer());
	
	Collection<X509CertificateHolder> holdersd = store1.getMatches(selec);

	for (X509CertificateHolder certholder2 : holdersd) {
		X509Certificate c2 = jcaX509CertificateConverter
				.getCertificate(certholder2);
		CertificateInfo parent = new CertificateInfo();
		adattaCertificate(c2, parent);
		certRecursive(chains, store1, certholder2 );
		chains.add(parent);
	}
	
}
 
开发者ID:tornabene,项目名称:jopenpec,代码行数:20,代码来源:PECVerifier.java

示例7: checkSignerStoreReplacement

import org.bouncycastle.util.Store; //导入方法依赖的package包/类
private void checkSignerStoreReplacement(
    CMSSignedData orig, 
    SignerInformationStore signers) 
    throws Exception
{
    CMSSignedData s = CMSSignedData.replaceSigners(orig, signers);
    
    Store certs = s.getCertificates();
    
    signers = s.getSignerInfos();
    Collection c = signers.getSigners();
    Iterator it = c.iterator();

    while (it.hasNext())
    {
        SignerInformation   signer = (SignerInformation)it.next();
        Collection certCollection = certs.getMatches(signer.getSID());

        Iterator certIt = certCollection.iterator();
        X509CertificateHolder cert = (X509CertificateHolder)certIt.next();

        assertEquals(true, signer.verify(new JcaSimpleSignerInfoVerifierBuilder().setProvider(BC).build(cert)));
    }
}
 
开发者ID:credentials,项目名称:irma_future_id,代码行数:25,代码来源:BcSignedDataTest.java

示例8: testUnsortedAttributes

import org.bouncycastle.util.Store; //导入方法依赖的package包/类
public void testUnsortedAttributes()
    throws Exception
{
    CMSSignedData s = new CMSSignedData(new CMSProcessableByteArray(disorderedMessage), disorderedSet);

    Store certs = s.getCertificates();

    SignerInformationStore  signers = s.getSignerInfos();
    Collection c = signers.getSigners();
    Iterator it = c.iterator();

    while (it.hasNext())
    {
        SignerInformation   signer = (SignerInformation)it.next();
        Collection certCollection = certs.getMatches(signer.getSID());
        Iterator certIt = certCollection.iterator();
        X509CertificateHolder cert = (X509CertificateHolder)certIt.next();

        assertEquals(true, signer.verify(new JcaSimpleSignerInfoVerifierBuilder().setProvider(BC).build(cert)));
    }
}
 
开发者ID:credentials,项目名称:irma_future_id,代码行数:22,代码来源:BcSignedDataTest.java

示例9: verifyRSASignatures

import org.bouncycastle.util.Store; //导入方法依赖的package包/类
private void verifyRSASignatures(CMSSignedData s, byte[] contentDigest)
    throws Exception
{
    Store                   certStore = s.getCertificates();
    SignerInformationStore  signers = s.getSignerInfos();

    Collection              c = signers.getSigners();
    Iterator                it = c.iterator();

    while (it.hasNext())
    {
        SignerInformation   signer = (SignerInformation)it.next();
        Collection          certCollection = certStore.getMatches(signer.getSID());

        Iterator        certIt = certCollection.iterator();
        X509CertificateHolder cert = (X509CertificateHolder)certIt.next();

        assertEquals(true, signer.verify(new BcRSASignerInfoVerifierBuilder(new DefaultCMSSignatureAlgorithmNameGenerator(), new DefaultSignatureAlgorithmIdentifierFinder(), new DefaultDigestAlgorithmIdentifierFinder(), new BcDigestCalculatorProvider()).build(cert)));

        if (contentDigest != null)
        {
            assertTrue(MessageDigest.isEqual(contentDigest, signer.getContentDigest()));
        }
    }
}
 
开发者ID:credentials,项目名称:irma_future_id,代码行数:26,代码来源:NewSignedDataTest.java

示例10: checkSignerStoreReplacement

import org.bouncycastle.util.Store; //导入方法依赖的package包/类
private void checkSignerStoreReplacement(
    CMSSignedData orig, 
    SignerInformationStore signers) 
    throws Exception
{
    CMSSignedData s = CMSSignedData.replaceSigners(orig, signers);
    
    Store certs = s.getCertificates();
    
    signers = s.getSignerInfos();
    Collection c = signers.getSigners();
    Iterator   it = c.iterator();

    while (it.hasNext())
    {
        SignerInformation   signer = (SignerInformation)it.next();
        Collection          certCollection = certs.getMatches(signer.getSID());

        Iterator        certIt = certCollection.iterator();
        X509CertificateHolder cert = (X509CertificateHolder)certIt.next();

        assertEquals(true, signer.verify(new JcaSimpleSignerInfoVerifierBuilder().setProvider(BC).build(cert)));
    }
}
 
开发者ID:mlundblad,项目名称:bc-java,代码行数:25,代码来源:NewSignedDataTest.java

示例11: testGostNoAttributesEncapsulated

import org.bouncycastle.util.Store; //导入方法依赖的package包/类
public void testGostNoAttributesEncapsulated()
    throws Exception
{
    CMSSignedData data = new CMSSignedData(rawGost);

    Store                   certStore = data.getCertificates();
    SignerInformationStore  signers = data.getSignerInfos();

    Collection              c = signers.getSigners();
    Iterator                it = c.iterator();

    while (it.hasNext())
    {
        SignerInformation   signer = (SignerInformation)it.next();
        Collection          certCollection = certStore.getMatches(signer.getSID());

        Iterator        certIt = certCollection.iterator();
        X509CertificateHolder cert = (X509CertificateHolder)certIt.next();

        assertEquals(true, signer.verify(new JcaSimpleSignerInfoVerifierBuilder().setProvider("BC").build(cert)));
    }
}
 
开发者ID:mlundblad,项目名称:bc-java,代码行数:23,代码来源:NewSignedDataTest.java

示例12: verifySigners

import org.bouncycastle.util.Store; //导入方法依赖的package包/类
private void verifySigners(Store certs, SignerInformationStore signers) 
    throws Exception
{
    Collection              c = signers.getSigners();
    Iterator                it = c.iterator();

    while (it.hasNext())
    {
        SignerInformation   signer = (SignerInformation)it.next();
        Collection          certCollection = certs.getMatches(signer.getSID());

        Iterator        certIt = certCollection.iterator();
        X509CertificateHolder certHolder = (X509CertificateHolder)certIt.next();

        assertEquals(true, signer.verify(new JcaSimpleSignerInfoVerifierBuilder().build(certHolder)));
    }
}
 
开发者ID:credentials,项目名称:irma_future_id,代码行数:18,代码来源:NewSMIMESignedTest.java

示例13: testUnsortedAttributes

import org.bouncycastle.util.Store; //导入方法依赖的package包/类
public void testUnsortedAttributes()
    throws Exception
{
    CMSSignedData s = new CMSSignedData(new CMSProcessableByteArray(disorderedMessage), disorderedSet);

    Store certs = s.getCertificates();

    SignerInformationStore  signers = s.getSignerInfos();
    Collection              c = signers.getSigners();
    Iterator                it = c.iterator();

    while (it.hasNext())
    {
        SignerInformation   signer = (SignerInformation)it.next();
        Collection          certCollection = certs.getMatches(signer.getSID());
        Iterator              certIt = certCollection.iterator();
        X509CertificateHolder cert = (X509CertificateHolder)certIt.next();

        assertEquals(true, signer.verify(new JcaSimpleSignerInfoVerifierBuilder().setProvider(BC).build(cert)));
    }
}
 
开发者ID:credentials,项目名称:irma_future_id,代码行数:22,代码来源:NewSignedDataTest.java

示例14: addCert

import org.bouncycastle.util.Store; //导入方法依赖的package包/类
public void addCert(Store<X509CertificateHolder> certStore) throws Exception {
    if (certStore == null)
        return;
    Collection<X509CertificateHolder> certStoreList = certStore.getMatches(null);
    for (X509CertificateHolder cert : certStoreList)
        addCert(cert.getEncoded());
}
 
开发者ID:damianofalcioni,项目名称:Websocket-Smart-Card-Signer,代码行数:8,代码来源:CMSSignedDataWrapper.java

示例15: addCrl

import org.bouncycastle.util.Store; //导入方法依赖的package包/类
public void addCrl(Store<X509CRL> crlStore) throws Exception {
    if (crlStore == null)
        return;
    Collection<X509CRL> crlStoreList = crlStore.getMatches(null);
    for (X509CRL crl : crlStoreList)
        addCert(crl.getEncoded());
}
 
开发者ID:damianofalcioni,项目名称:Websocket-Smart-Card-Signer,代码行数:8,代码来源:CMSSignedDataWrapper.java


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