org.bouncycastle.cms
Class CMSSignedDataParser
java.lang.Object
|
+--org.bouncycastle.cms.CMSContentInfoParser
|
+--org.bouncycastle.cms.CMSSignedDataParser
- public class CMSSignedDataParser
- extends CMSContentInfoParser
Parsing class for an CMS Signed Data object from an input stream.
Note: that because we are in a streaming mode only one signer can be tried and it is important
that the methods on the parser are called in the appropriate order.
A simple example of usage for an encapsulated signature.
Two notes: first, in the example below the validity of
the certificate isn't verified, just the fact that one of the certs
matches the given signer, and, second, because we are in a streaming
mode the order of the operations is important.
CMSSignedDataParser sp = new CMSSignedDataParser(encapSigData);
sp.getSignedContent().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(signer.getSID());
Iterator certIt = certCollection.iterator();
X509Certificate cert = (X509Certificate)certIt.next();
System.out.println("verify returns: " + signer.verify(cert, "BC"));
}
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
CMSSignedDataParser
public CMSSignedDataParser(byte[] sigBlock)
throws CMSException
CMSSignedDataParser
public CMSSignedDataParser(CMSTypedStream signedContent,
byte[] sigBlock)
throws CMSException
CMSSignedDataParser
public CMSSignedDataParser(CMSTypedStream signedContent,
java.io.InputStream sigData)
throws CMSException
- base constructor
- Parameters:
signedContent
- the content that was signed.sigData
- the signature object.
CMSSignedDataParser
public CMSSignedDataParser(java.io.InputStream sigData)
throws CMSException
- base constructor - with encapsulated content
CMSSignedDataParser
public CMSSignedDataParser(org.bouncycastle.sasn1.cms.ContentInfoParser sigData)
throws CMSException
getSignerInfos
public SignerInformationStore getSignerInfos()
throws CMSException
- return the collection of signers that are associated with the
signatures for the message.
- Throws:
CmsException
-
getCertificatesAndCRLs
public org.bouncycastle.jce.cert.CertStore getCertificatesAndCRLs(java.lang.String type,
java.lang.String provider)
throws java.security.NoSuchAlgorithmException,
java.security.NoSuchProviderException,
CMSException
- return a CertStore containing the certificates and CRLs associated with
this message.
- Throws:
NoProviderException
- if the provider requested isn't available.java.security.NoSuchAlgorithmException
- if the cert store isn't available.
getSignedContent
public CMSTypedStream getSignedContent()