Bouncy Castle Cryptography 1.18

org.bouncycastle.cms
Class CMSSignedData

java.lang.Object
  |
  +--org.bouncycastle.cms.CMSSignedData
Direct Known Subclasses:
SMIMESigned

public class CMSSignedData
extends java.lang.Object

general class for handling a pkcs7-signature message. A simple example of usage - note, in the example below the validity of the certificate isn't verified, just the fact that one of the certs matches the given signer...

  CertStore               certs = s.getCertificates("Collection", "BC");
  SignerInformationStore  signers = s.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();
  
      if (signer.verify(cert.getPublicKey()))
      {
          verified++;
      }   
  }
 


Constructor Summary
CMSSignedData(byte[] sigBlock)
           
CMSSignedData(CMSProcessable signedContent, byte[] sigBlock)
           
CMSSignedData(CMSProcessable signedContent, ContentInfo sigData)
           
CMSSignedData(CMSProcessable signedContent, java.io.InputStream sigData)
          base constructor
CMSSignedData(ContentInfo sigData)
           
CMSSignedData(java.io.InputStream sigData)
          base constructor - with encapsulated content
 
Method Summary
 java.security.cert.CertStore getCertificatesAndCRLs(java.lang.String type, java.lang.String provider)
          return a CertStore containing the certificates and CRLs associated with this message.
 byte[] getEncoded()
          return the ASN.1 encoded representation of this object.
 CMSProcessable getSignedContent()
           
 SignerInformationStore getSignerInfos()
          return the collection of signers that are associated with the signatures for the message.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CMSSignedData

public CMSSignedData(byte[] sigBlock)
              throws CMSException

CMSSignedData

public CMSSignedData(CMSProcessable signedContent,
                     byte[] sigBlock)
              throws CMSException

CMSSignedData

public CMSSignedData(CMSProcessable signedContent,
                     java.io.InputStream sigData)
              throws CMSException
base constructor


CMSSignedData

public CMSSignedData(java.io.InputStream sigData)
              throws CMSException
base constructor - with encapsulated content


CMSSignedData

public CMSSignedData(CMSProcessable signedContent,
                     ContentInfo sigData)

CMSSignedData

public CMSSignedData(ContentInfo sigData)
Method Detail

getSignerInfos

public SignerInformationStore getSignerInfos()
return the collection of signers that are associated with the signatures for the message.


getCertificatesAndCRLs

public java.security.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.
java.security.NoSuchProviderException
CMSException

getSignedContent

public CMSProcessable getSignedContent()

getEncoded

public byte[] getEncoded()
                  throws java.io.IOException
return the ASN.1 encoded representation of this object.

java.io.IOException

Bouncy Castle Cryptography 1.18