org.bouncycastle.cms
Class CMSSignedData
java.lang.Object
org.bouncycastle.cms.CMSSignedData
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.getCertificatesAndCRLs("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++;
}
}
X509Store | getAttributeCertificates(String type, String provider) - return a X509Store containing the attribute certificates, if any, contained
in this message.
|
X509Store | getCRLs(String type, String provider) - return a X509Store containing CRLs, if any, contained
in this message.
|
X509Store | getCertificates(String type, String provider) - return a X509Store containing the public key certificates, if any, contained
in this message.
|
CertStore | getCertificatesAndCRLs(String type, String provider) - return a CertStore containing the certificates and CRLs associated with
this message.
|
ContentInfo | getContentInfo() - return the ContentInfo
|
byte[] | getEncoded() - return the ASN.1 encoded representation of this object.
|
CMSProcessable | getSignedContent()
|
String | getSignedContentTypeOID() - Return the a string representation of the OID associated with the
encapsulated content info structure carried in the signed data.
|
SignerInformationStore | getSignerInfos() - return the collection of signers that are associated with the
signatures for the message.
|
int | getVersion() - Return the version number for this object
|
static CMSSignedData | replaceCertificatesAndCRLs(CMSSignedData signedData, CertStore certsAndCrls) - Replace the certificate and CRL information associated with this
CMSSignedData object with the new one passed in.
|
static CMSSignedData | replaceSigners(CMSSignedData signedData, SignerInformationStore signerInformationStore) - Replace the signerinformation store associated with this
CMSSignedData object with the new one passed in.
|
CMSSignedData
public CMSSignedData(ContentInfo sigData)
CMSSignedData
public CMSSignedData(InputStream sigData)
throws CMSException
base constructor - with encapsulated content
CMSSignedData
public CMSSignedData(Map hashes,
ContentInfo sigData)
CMSSignedData
public CMSSignedData(Map hashes,
byte[] sigBlock)
throws CMSException
Content with detached signature, digests precomputed
hashes
- a map of precomputed digests for content indexed by name of hash.sigBlock
- the signature object.
CMSSignedData
public CMSSignedData(byte[] sigBlock)
throws CMSException
CMSSignedData
public CMSSignedData(CMSProcessable signedContent,
ContentInfo sigData)
CMSSignedData
public CMSSignedData(CMSProcessable signedContent,
InputStream sigData)
throws CMSException
base constructor - content with detached signature.
signedContent
- the content that was signed.sigData
- the signature object.
getAttributeCertificates
public X509Store getAttributeCertificates(String type,
String provider)
throws NoSuchStoreException,
NoSuchProviderException,
CMSException
return a X509Store containing the attribute certificates, if any, contained
in this message.
type
- type of store to createprovider
- provider to use
- a store of attribute certificates
CMSException
- if a general exception prevents creation of the X509Store
getCRLs
public X509Store getCRLs(String type,
String provider)
throws NoSuchStoreException,
NoSuchProviderException,
CMSException
return a X509Store containing CRLs, if any, contained
in this message.
type
- type of store to createprovider
- provider to use
CMSException
- if a general exception prevents creation of the X509Store
getCertificates
public X509Store getCertificates(String type,
String provider)
throws NoSuchStoreException,
NoSuchProviderException,
CMSException
return a X509Store containing the public key certificates, if any, contained
in this message.
type
- type of store to createprovider
- provider to use
- a store of public key certificates
CMSException
- if a general exception prevents creation of the X509Store
getCertificatesAndCRLs
public CertStore getCertificatesAndCRLs(String type,
String provider)
throws NoSuchAlgorithmException,
NoSuchProviderException,
CMSException
return a CertStore containing the certificates and CRLs associated with
this message.
CMSException
- if a general exception prevents creation of the CertStore
getContentInfo
public ContentInfo getContentInfo()
return the ContentInfo
getEncoded
public byte[] getEncoded()
throws IOException
return the ASN.1 encoded representation of this object.
getSignedContentTypeOID
public String getSignedContentTypeOID()
Return the a string representation of the OID associated with the
encapsulated content info structure carried in the signed data.
- the OID for the content type.
getSignerInfos
public SignerInformationStore getSignerInfos()
return the collection of signers that are associated with the
signatures for the message.
getVersion
public int getVersion()
Return the version number for this object
replaceCertificatesAndCRLs
public static CMSSignedData replaceCertificatesAndCRLs(CMSSignedData signedData,
CertStore certsAndCrls)
throws CMSException
Replace the certificate and CRL information associated with this
CMSSignedData object with the new one passed in.
signedData
- the signed data object to be used as a base.certsAndCrls
- the new certificates and CRLs to be used.
- a new signed data object.
CMSException
- if there is an error processing the CertStore
replaceSigners
public static CMSSignedData replaceSigners(CMSSignedData signedData,
SignerInformationStore signerInformationStore)
Replace the signerinformation store associated with this
CMSSignedData object with the new one passed in. You would
probably only want to do this if you wanted to change the unsigned
attributes associated with a signer, or perhaps delete one.
signedData
- the signed data object to be used as a base.signerInformationStore
- the new signer information store to use.
- a new signed data object.