本文整理汇总了Java中org.bouncycastle.cms.CMSTypedStream.drain方法的典型用法代码示例。如果您正苦于以下问题:Java CMSTypedStream.drain方法的具体用法?Java CMSTypedStream.drain怎么用?Java CMSTypedStream.drain使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bouncycastle.cms.CMSTypedStream
的用法示例。
在下文中一共展示了CMSTypedStream.drain方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: verifySignatures
import org.bouncycastle.cms.CMSTypedStream; //导入方法依赖的package包/类
private void verifySignatures(CMSSignedDataParser sp)
throws Exception
{
CMSTypedStream sc = sp.getSignedContent();
if (sc != null)
{
sc.drain();
}
CertStore certs = sp.getCertificatesAndCRLs("Collection", BC);
SignerInformationStore signers = sp.getSignerInfos();
Collection c = signers.getSigners();
Iterator it = c.iterator();
while (it.hasNext())
{
SignerInformation signer = (SignerInformation)it.next();
Collection certCollection = certs.getCertificates(selectorConverter.getCertSelector(signer.getSID()));
Iterator certIt = certCollection.iterator();
X509Certificate cert = (X509Certificate)certIt.next();
verifySigner(signer, cert);
}
}
示例2: checkSigParseable
import org.bouncycastle.cms.CMSTypedStream; //导入方法依赖的package包/类
private void checkSigParseable(byte[] sig)
throws Exception
{
CMSSignedDataParser sp = new CMSSignedDataParser(sig);
sp.getVersion();
CMSTypedStream sc = sp.getSignedContent();
if (sc != null)
{
sc.drain();
}
sp.getCertificatesAndCRLs("Collection", BC);
sp.getSignerInfos();
sp.close();
}
示例3: checkSigParseable
import org.bouncycastle.cms.CMSTypedStream; //导入方法依赖的package包/类
private void checkSigParseable(byte[] sig)
throws Exception
{
CMSSignedDataParser sp = new CMSSignedDataParser(new JcaDigestCalculatorProviderBuilder().setProvider(BC).build(), sig);
sp.getVersion();
CMSTypedStream sc = sp.getSignedContent();
if (sc != null)
{
sc.drain();
}
sp.getCertificates();
sp.getCRLs();
sp.getSignerInfos();
sp.close();
}
示例4: testSHA1WithRSANonData
import org.bouncycastle.cms.CMSTypedStream; //导入方法依赖的package包/类
public void testSHA1WithRSANonData()
throws Exception
{
List certList = new ArrayList();
ByteArrayOutputStream bOut = new ByteArrayOutputStream();
certList.add(_origCert);
certList.add(_signCert);
certList.add(_signCrl);
certList.add(_origCrl);
CertStore certsAndCrls = CertStore.getInstance("Collection",
new CollectionCertStoreParameters(certList), BC);
CMSSignedDataStreamGenerator gen = new CMSSignedDataStreamGenerator();
gen.addSigner(_origKP.getPrivate(), _origCert, CMSSignedDataStreamGenerator.DIGEST_SHA1, BC);
gen.addCertificatesAndCRLs(certsAndCrls);
OutputStream sigOut = gen.open(bOut, "1.2.3.4", true);
sigOut.write(TEST_MESSAGE.getBytes());
sigOut.close();
CMSSignedDataParser sp = new CMSSignedDataParser(bOut.toByteArray());
CMSTypedStream stream = sp.getSignedContent();
assertEquals(new ASN1ObjectIdentifier("1.2.3.4"), stream.getContentType());
stream.drain();
//
// compute expected content digest
//
MessageDigest md = MessageDigest.getInstance("SHA1", BC);
verifySignatures(sp, md.digest(TEST_MESSAGE.getBytes()));
}
示例5: testSHA1WithRSAAndOtherRevocation
import org.bouncycastle.cms.CMSTypedStream; //导入方法依赖的package包/类
public void testSHA1WithRSAAndOtherRevocation()
throws Exception
{
List certList = new ArrayList();
CMSTypedData msg = new CMSProcessableByteArray("Hello world!".getBytes());
ByteArrayOutputStream bOut = new ByteArrayOutputStream();
certList.add(_origCert);
certList.add(_signCert);
Store certs = new JcaCertStore(certList);
CMSSignedDataStreamGenerator gen = new CMSSignedDataStreamGenerator();
ContentSigner sha1Signer = new JcaContentSignerBuilder("SHA1withRSA").setProvider(BC).build(_origKP.getPrivate());
gen.addSignerInfoGenerator(new JcaSignerInfoGeneratorBuilder(new JcaDigestCalculatorProviderBuilder().setProvider(BC).build()).build(sha1Signer, _origCert));
gen.addCertificates(certs);
List otherInfo = new ArrayList();
OCSPResp response = new OCSPResp(successResp);
otherInfo.add(response.toASN1Structure());
gen.addOtherRevocationInfo(CMSObjectIdentifiers.id_ri_ocsp_response, new CollectionStore(otherInfo));
OutputStream sigOut = gen.open(bOut, true);
sigOut.write(TEST_MESSAGE.getBytes());
sigOut.close();
CMSSignedDataParser sp = new CMSSignedDataParser(new JcaDigestCalculatorProviderBuilder().setProvider(BC).build(), bOut.toByteArray());
CMSTypedStream stream = sp.getSignedContent();
assertEquals(CMSObjectIdentifiers.data, stream.getContentType());
stream.drain();
//
// check version
//
assertEquals(5, sp.getVersion());
//
// compute expected content digest
//
MessageDigest md = MessageDigest.getInstance("SHA1", BC);
verifySignatures(sp, md.digest(TEST_MESSAGE.getBytes()));
Store dataOtherInfo = sp.getOtherRevocationInfo(CMSObjectIdentifiers.id_ri_ocsp_response);
assertEquals(1, dataOtherInfo.getMatches(null).size());
OCSPResp dataResponse = new OCSPResp(OCSPResponse.getInstance(dataOtherInfo.getMatches(null).iterator().next()));
assertEquals(response, dataResponse);
}
示例6: testSHA1WithRSANonData
import org.bouncycastle.cms.CMSTypedStream; //导入方法依赖的package包/类
public void testSHA1WithRSANonData()
throws Exception
{
List certList = new ArrayList();
List crlList = new ArrayList();
ByteArrayOutputStream bOut = new ByteArrayOutputStream();
certList.add(new JcaX509CertificateHolder(_origCert));
certList.add(new JcaX509CertificateHolder(_signCert));
crlList.add(new JcaX509CRLHolder(_signCrl));
crlList.add(new JcaX509CRLHolder(_origCrl));
Store certs = new JcaCertStore(certList);
Store crls = new JcaCRLStore(crlList);
CMSSignedDataStreamGenerator gen = new CMSSignedDataStreamGenerator();
ContentSigner sha1Signer = new JcaContentSignerBuilder("SHA1withRSA").setProvider(BC).build(_origKP.getPrivate());
gen.addSignerInfoGenerator(new JcaSignerInfoGeneratorBuilder(new JcaDigestCalculatorProviderBuilder().setProvider(BC).build()).build(sha1Signer, _origCert));
gen.addCertificates(certs);
gen.addCRLs(crls);
OutputStream sigOut = gen.open(new ASN1ObjectIdentifier("1.2.3.4"), bOut, true);
sigOut.write(TEST_MESSAGE.getBytes());
sigOut.close();
CMSSignedDataParser sp = new CMSSignedDataParser(new JcaDigestCalculatorProviderBuilder().setProvider(BC).build(), bOut.toByteArray());
CMSTypedStream stream = sp.getSignedContent();
assertEquals(new ASN1ObjectIdentifier("1.2.3.4"), stream.getContentType());
stream.drain();
//
// compute expected content digest
//
MessageDigest md = MessageDigest.getInstance("SHA1", BC);
verifySignatures(sp, md.digest(TEST_MESSAGE.getBytes()));
}