Bouncy Castle Cryptography 1.30

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"));
      }
 


Fields inherited from class org.bouncycastle.cms.CMSContentInfoParser
_contentInfo
 
Constructor Summary
CMSSignedDataParser(byte[] sigBlock)
           
CMSSignedDataParser(CMSTypedStream signedContent, byte[] sigBlock)
           
CMSSignedDataParser(CMSTypedStream signedContent, java.io.InputStream sigData)
          base constructor
CMSSignedDataParser(org.bouncycastle.sasn1.cms.ContentInfoParser sigData)
           
CMSSignedDataParser(java.io.InputStream sigData)
          base constructor - with encapsulated content
 
Method Summary
 org.bouncycastle.jce.cert.CertStore getCertificatesAndCRLs(java.lang.String type, java.lang.String provider)
          return a CertStore containing the certificates and CRLs associated with this message.
 CMSTypedStream getSignedContent()
           
 SignerInformationStore getSignerInfos()
          return the collection of signers that are associated with the signatures for the message.
 
Methods inherited from class org.bouncycastle.cms.CMSContentInfoParser
readContentInfo
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

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
Method Detail

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()

Bouncy Castle Cryptography 1.30