Constructors Summary |
---|
private CMSSignedData(CMSSignedData c)
this.signedData = c.signedData;
this.contentInfo = c.contentInfo;
this.signedContent = c.signedContent;
this.certStore = c.certStore;
this.signerInfoStore = c.signerInfoStore;
|
public CMSSignedData(byte[] sigBlock)
this(CMSUtils.readContentInfo(sigBlock));
|
public CMSSignedData(CMSProcessable signedContent, byte[] sigBlock)
this(signedContent, CMSUtils.readContentInfo(sigBlock));
|
public CMSSignedData(Map hashes, byte[] sigBlock)Content with detached signature, digests precomputed
this(hashes, CMSUtils.readContentInfo(sigBlock));
|
public CMSSignedData(CMSProcessable signedContent, InputStream sigData)base constructor - content with detached signature.
this(signedContent, CMSUtils.readContentInfo(new ASN1InputStream(sigData)));
|
public CMSSignedData(InputStream sigData)base constructor - with encapsulated content
this(CMSUtils.readContentInfo(sigData));
|
public CMSSignedData(CMSProcessable signedContent, org.bouncycastle.asn1.cms.ContentInfo sigData)
this.signedContent = signedContent;
this.contentInfo = sigData;
this.signedData = SignedData.getInstance(contentInfo.getContent());
|
public CMSSignedData(Map hashes, org.bouncycastle.asn1.cms.ContentInfo sigData)
this.hashes = hashes;
this.contentInfo = sigData;
this.signedData = SignedData.getInstance(contentInfo.getContent());
|
public CMSSignedData(org.bouncycastle.asn1.cms.ContentInfo sigData)
this.contentInfo = sigData;
this.signedData = SignedData.getInstance(contentInfo.getContent());
//
// this can happen if the signed message is sent simply to send a
// certificate chain.
//
if (signedData.getEncapContentInfo().getContent() != null)
{
this.signedContent = new CMSProcessableByteArray(
((ASN1OctetString)(signedData.getEncapContentInfo()
.getContent())).getOctets());
}
else
{
this.signedContent = null;
}
|
Methods Summary |
---|
public org.bouncycastle.x509.X509Store | getAttributeCertificates(java.lang.String type, java.lang.String provider)return a X509Store containing the attribute certificates, if any, contained
in this message.
return getAttributeCertificates(type, CMSUtils.getProvider(provider));
|
public org.bouncycastle.x509.X509Store | getAttributeCertificates(java.lang.String type, java.security.Provider provider)return a X509Store containing the attribute certificates, if any, contained
in this message.
if (attributeStore == null)
{
attributeStore = HELPER.createAttributeStore(type, provider, signedData.getCertificates());
}
return attributeStore;
|
public org.bouncycastle.x509.X509Store | getCRLs(java.lang.String type, java.lang.String provider)return a X509Store containing CRLs, if any, contained
in this message.
return getCRLs(type, CMSUtils.getProvider(provider));
|
public org.bouncycastle.x509.X509Store | getCRLs(java.lang.String type, java.security.Provider provider)return a X509Store containing CRLs, if any, contained
in this message.
if (crlStore == null)
{
crlStore = HELPER.createCRLsStore(type, provider, signedData.getCRLs());
}
return crlStore;
|
public org.bouncycastle.x509.X509Store | getCertificates(java.lang.String type, java.lang.String provider)return a X509Store containing the public key certificates, if any, contained
in this message.
return getCertificates(type, CMSUtils.getProvider(provider));
|
public org.bouncycastle.x509.X509Store | getCertificates(java.lang.String type, java.security.Provider provider)return a X509Store containing the public key certificates, if any, contained
in this message.
if (certificateStore == null)
{
certificateStore = HELPER.createCertificateStore(type, provider, signedData.getCertificates());
}
return certificateStore;
|
public 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.
return getCertificatesAndCRLs(type, CMSUtils.getProvider(provider));
|
public java.security.cert.CertStore | getCertificatesAndCRLs(java.lang.String type, java.security.Provider provider)return a CertStore containing the certificates and CRLs associated with
this message.
if (certStore == null)
{
ASN1Set certSet = signedData.getCertificates();
ASN1Set crlSet = signedData.getCRLs();
certStore = HELPER.createCertStore(type, provider, certSet, crlSet);
}
return certStore;
|
public org.bouncycastle.asn1.cms.ContentInfo | getContentInfo()return the ContentInfo
return contentInfo;
|
public byte[] | getEncoded()return the ASN.1 encoded representation of this object.
return contentInfo.getEncoded();
|
public CMSProcessable | getSignedContent()
return signedContent;
|
public java.lang.String | getSignedContentTypeOID()Return the a string representation of the OID associated with the
encapsulated content info structure carried in the signed data.
return signedData.getEncapContentInfo().getContentType().getId();
|
public SignerInformationStore | getSignerInfos()return the collection of signers that are associated with the
signatures for the message.
if (signerInfoStore == null)
{
ASN1Set s = signedData.getSignerInfos();
List signerInfos = new ArrayList();
for (int i = 0; i != s.size(); i++)
{
if (hashes == null)
{
signerInfos.add(new SignerInformation(SignerInfo.getInstance(s.getObjectAt(i)), signedData.getEncapContentInfo().getContentType(), signedContent, null));
}
else
{
SignerInfo info = SignerInfo.getInstance(s.getObjectAt(i));
byte[] hash = (byte[])hashes.get(info.getDigestAlgorithm().getObjectId().getId());
signerInfos.add(new SignerInformation(info, signedData.getEncapContentInfo().getContentType(), null, new BaseDigestCalculator(hash)));
}
}
signerInfoStore = new SignerInformationStore(signerInfos);
}
return signerInfoStore;
|
public int | getVersion()Return the version number for this object
return signedData.getVersion().getValue().intValue();
|
private static org.bouncycastle.asn1.x509.AlgorithmIdentifier | makeAlgId(java.lang.String oid, byte[] params)
if (params != null)
{
return new AlgorithmIdentifier(
new DERObjectIdentifier(oid), makeObj(params));
}
else
{
return new AlgorithmIdentifier(
new DERObjectIdentifier(oid), new DERNull());
}
|
private static org.bouncycastle.asn1.DERObject | makeObj(byte[] encoding)
if (encoding == null)
{
return null;
}
ASN1InputStream aIn = new ASN1InputStream(encoding);
return aIn.readObject();
|
public static org.bouncycastle.cms.CMSSignedData | replaceCertificatesAndCRLs(org.bouncycastle.cms.CMSSignedData signedData, java.security.cert.CertStore certsAndCrls)Replace the certificate and CRL information associated with this
CMSSignedData object with the new one passed in.
//
// copy
//
CMSSignedData cms = new CMSSignedData(signedData);
//
// replace the store
//
cms.certStore = certsAndCrls;
//
// replace the certs and crls in the SignedData object
//
ASN1Set certs = null;
ASN1Set crls = null;
try
{
ASN1Set set = CMSUtils.createBerSetFromList(CMSUtils.getCertificatesFromStore(certsAndCrls));
if (set.size() != 0)
{
certs = set;
}
}
catch (CertStoreException e)
{
throw new CMSException("error getting certs from certStore", e);
}
try
{
ASN1Set set = CMSUtils.createBerSetFromList(CMSUtils.getCRLsFromStore(certsAndCrls));
if (set.size() != 0)
{
crls = set;
}
}
catch (CertStoreException e)
{
throw new CMSException("error getting crls from certStore", e);
}
//
// replace the CMS structure.
//
cms.signedData = new SignedData(signedData.signedData.getDigestAlgorithms(),
signedData.signedData.getEncapContentInfo(),
certs,
crls,
signedData.signedData.getSignerInfos());
//
// replace the contentInfo with the new one
//
cms.contentInfo = new ContentInfo(cms.contentInfo.getContentType(), cms.signedData);
return cms;
|
public static org.bouncycastle.cms.CMSSignedData | replaceSigners(org.bouncycastle.cms.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.
//
// copy
//
CMSSignedData cms = new CMSSignedData(signedData);
//
// replace the store
//
cms.signerInfoStore = signerInformationStore;
//
// replace the signers in the SignedData object
//
ASN1EncodableVector digestAlgs = new ASN1EncodableVector();
ASN1EncodableVector vec = new ASN1EncodableVector();
Iterator it = signerInformationStore.getSigners().iterator();
while (it.hasNext())
{
SignerInformation signer = (SignerInformation)it.next();
AlgorithmIdentifier digAlgId;
try
{
digAlgId = makeAlgId(signer.getDigestAlgOID(),
signer.getDigestAlgParams());
}
catch (IOException e)
{
throw new RuntimeException("encoding error.", e);
}
digestAlgs.add(digAlgId);
vec.add(signer.toSignerInfo());
}
ASN1Set digests = new DERSet(digestAlgs);
ASN1Set signers = new DERSet(vec);
ASN1Sequence sD = (ASN1Sequence)signedData.signedData.getDERObject();
vec = new ASN1EncodableVector();
//
// signers are the last item in the sequence.
//
vec.add(sD.getObjectAt(0)); // version
vec.add(digests);
for (int i = 2; i != sD.size() - 1; i++)
{
vec.add(sD.getObjectAt(i));
}
vec.add(signers);
cms.signedData = SignedData.getInstance(new BERSequence(vec));
//
// replace the contentInfo with the new one
//
cms.contentInfo = new ContentInfo(cms.contentInfo.getContentType(), cms.signedData);
return cms;
|