本文整理汇总了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;
}
示例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()));
}
}
}
示例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());
}
}
}
示例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;
}
示例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");
}
}
示例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);
}
}
示例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)));
}
}
示例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)));
}
}
示例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()));
}
}
}
示例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)));
}
}
示例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)));
}
}
示例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)));
}
}
示例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)));
}
}
示例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());
}
示例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());
}