Package eu.europa.esig.dss.cms
Interface ICMSUtils
- All Known Implementing Classes:
CMSObjectUtils,CMSStreamUtils
public interface ICMSUtils
The interface of Utils class for processing
CMS-
Method Summary
Modifier and TypeMethodDescriptionvoidThis method checks whether the augmentation of signatures with an archive-time-stamp-v2 is supported by the current implementationvoidThis method checks whether the embedding of existing Evidence Records within CMS is supported by the current implementationGets encoding of the ContentInfo of CMSgetDSSResourcesHandlerBuilder(DSSResourcesHandlerBuilder dssResourcesHandlerBuilder) This method is used to verify whether the providedDSSResourcesHandlerBuilderis supported by the current implementation.parseToCMS(byte[] binaries) Parses the given byte array to aCMSobjectparseToCMS(DSSDocument document) Parses the givenDSSDocumentto aCMSobjectpopulateDigestAlgorithmSet(CMS cms, Collection<org.bouncycastle.asn1.x509.AlgorithmIdentifier> digestAlgorithmsToAdd) Adds digest algorithms toCMSSignedDataorg.bouncycastle.cms.SignerInformationrecomputeSignerInformation(CMS cms, org.bouncycastle.cms.SignerId signerId, org.bouncycastle.operator.DigestCalculatorProvider digestCalculatorProvider, DSSResourcesHandlerBuilder resourcesHandlerBuilder) This method re-created theSignerInformationwith a givensignerIdfromCMSby providing thedigestCalculatorProviderto the validation.replaceCertificatesAndCRLs(CMS cms, org.bouncycastle.util.Store<org.bouncycastle.cert.X509CertificateHolder> certificates, org.bouncycastle.util.Store<org.bouncycastle.cert.X509AttributeCertificateHolder> attributeCertificates, org.bouncycastle.util.Store<org.bouncycastle.cert.X509CRLHolder> crls, org.bouncycastle.util.Store<?> ocspResponsesStore, org.bouncycastle.util.Store<?> ocspBasicStore) Replaces SignedData content within theCMSwith the provided valuesreplaceSigners(CMS cms, org.bouncycastle.cms.SignerInformationStore newSignerStore) Replaces the signers withincmswith thenewSignerStoreorg.bouncycastle.cms.SignerInformationreplaceUnsignedAttributes(org.bouncycastle.cms.SignerInformation signerInformation, org.bouncycastle.asn1.cms.AttributeTable unsignedAttributes) This method replacesunsignedAttributeswithin the givensignerInformationtoCMS(org.bouncycastle.tsp.TimeStampToken timeStampToken) Converts aTimeStampTokento aCMSorg.bouncycastle.cms.CMSTypedDatatoCMSEncapsulatedContent(DSSDocument document) Converts aDSSDocumentto the correspondingCMSTypedDataobject typevoidwriteContentInfoEncoded(CMS cms, OutputStream os) Writes the encoded binaries of the ContentInfo element to the givenOutputStreamNOTE: This method is used for archive-time-stamp-v2 message-imprint computation.voidWrites the encoded binaries of the SignedData.certificates field to the givenOutputStreamNOTE: This method is used for archive-time-stamp-v2 message-imprint computation.voidwriteSignedDataCRLsEncoded(CMS cms, OutputStream os) Writes the encoded binaries of the SignedData.crls field to the givenOutputStreamNOTE: This method is used for archive-time-stamp-v2 message-imprint computation.voidWrites the encoded binaries of the SignedData.digestAlgorithms field to the givenOutputStreamNOTE: This method is used for evidence record hash computationvoidWrites the encoded binaries of the SignedData.signerInfos field to the givenOutputStreamNOTE: This method is used for evidence record hash computationwriteToDSSDocument(CMS cms, DSSResourcesHandlerBuilder resourcesHandlerBuilder) Creates aDSSDocumentfrom the givenCMSusing the implementation based coding.
-
Method Details
-
parseToCMS
Parses the givenDSSDocumentto aCMSobject- Parameters:
document-DSSDocumentto parse- Returns:
CMS
-
parseToCMS
Parses the given byte array to aCMSobject- Parameters:
binaries- byte array to parse- Returns:
CMS
-
writeToDSSDocument
Creates aDSSDocumentfrom the givenCMSusing the implementation based coding. This method uses aresourcesHandlerBuilderwhich defines the final document's implementation (e.g. in-memory document or a temporary document in a filesystem). NOTE: When used, the dss-cms-object implementation stores document using a DL coding, and dss-cms-stream stores documents using BER coding.- Parameters:
cms-CMSto create a document fromresourcesHandlerBuilder-DSSResourcesHandlerBuilder- Returns:
DSSDocument
-
recomputeSignerInformation
org.bouncycastle.cms.SignerInformation recomputeSignerInformation(CMS cms, org.bouncycastle.cms.SignerId signerId, org.bouncycastle.operator.DigestCalculatorProvider digestCalculatorProvider, DSSResourcesHandlerBuilder resourcesHandlerBuilder) throws org.bouncycastle.cms.CMSException This method re-created theSignerInformationwith a givensignerIdfromCMSby providing thedigestCalculatorProviderto the validation. The returnedSignerInformationcontains validated digest according to the provided document.- Parameters:
cms-CMScontaining a SignerInformation to be validatedsignerId-SignerIdto re-computedigestCalculatorProvider-DigestCalculatorProvidercontaining digest of the original signed documentresourcesHandlerBuilder-DSSResourcesHandlerBuilder- Returns:
SignerInformation- Throws:
org.bouncycastle.cms.CMSException- if an exception occurs on SignerInformation re-creation
-
replaceSigners
Replaces the signers withincmswith thenewSignerStore -
replaceCertificatesAndCRLs
CMS replaceCertificatesAndCRLs(CMS cms, org.bouncycastle.util.Store<org.bouncycastle.cert.X509CertificateHolder> certificates, org.bouncycastle.util.Store<org.bouncycastle.cert.X509AttributeCertificateHolder> attributeCertificates, org.bouncycastle.util.Store<org.bouncycastle.cert.X509CRLHolder> crls, org.bouncycastle.util.Store<?> ocspResponsesStore, org.bouncycastle.util.Store<?> ocspBasicStore) Replaces SignedData content within theCMSwith the provided values -
populateDigestAlgorithmSet
CMS populateDigestAlgorithmSet(CMS cms, Collection<org.bouncycastle.asn1.x509.AlgorithmIdentifier> digestAlgorithmsToAdd) Adds digest algorithms toCMSSignedData -
toCMS
Converts aTimeStampTokento aCMS- Parameters:
timeStampToken-TimeStampToken- Returns:
CMS
-
getContentInfoEncoding
Gets encoding of the ContentInfo of CMS -
writeSignedDataDigestAlgorithmsEncoded
Writes the encoded binaries of the SignedData.digestAlgorithms field to the givenOutputStreamNOTE: This method is used for evidence record hash computation- Parameters:
cms-CMSos-OutputStream- Throws:
IOException- if an exception occurs on bytes writing
-
writeContentInfoEncoded
Writes the encoded binaries of the ContentInfo element to the givenOutputStreamNOTE: This method is used for archive-time-stamp-v2 message-imprint computation.- Parameters:
cms-CMSos-OutputStream- Throws:
IOException- if an exception occurs on bytes writing
-
writeSignedDataCertificatesEncoded
Writes the encoded binaries of the SignedData.certificates field to the givenOutputStreamNOTE: This method is used for archive-time-stamp-v2 message-imprint computation.- Parameters:
cms-CMSos-OutputStream- Throws:
IOException- if an exception occurs on bytes writing
-
writeSignedDataCRLsEncoded
Writes the encoded binaries of the SignedData.crls field to the givenOutputStreamNOTE: This method is used for archive-time-stamp-v2 message-imprint computation.- Parameters:
cms-CMSos-OutputStream- Throws:
IOException- if an exception occurs on bytes writing
-
writeSignedDataSignerInfosEncoded
Writes the encoded binaries of the SignedData.signerInfos field to the givenOutputStreamNOTE: This method is used for evidence record hash computation- Parameters:
cms-CMSos-OutputStream- Throws:
IOException- if an exception occurs on bytes writing
-
toCMSEncapsulatedContent
Converts aDSSDocumentto the correspondingCMSTypedDataobject type- Parameters:
document-DSSDocument- Returns:
CMSTypedData
-
getDSSResourcesHandlerBuilder
DSSResourcesHandlerBuilder getDSSResourcesHandlerBuilder(DSSResourcesHandlerBuilder dssResourcesHandlerBuilder) This method is used to verify whether the providedDSSResourcesHandlerBuilderis supported by the current implementation. Returns the given value in case of success.- Parameters:
dssResourcesHandlerBuilder-DSSResourcesHandlerBuilder- Returns:
DSSResourcesHandlerBuilder
-
replaceUnsignedAttributes
org.bouncycastle.cms.SignerInformation replaceUnsignedAttributes(org.bouncycastle.cms.SignerInformation signerInformation, org.bouncycastle.asn1.cms.AttributeTable unsignedAttributes) This method replacesunsignedAttributeswithin the givensignerInformation- Parameters:
signerInformation-SignerInformationto replace unsigned attributes table intounsignedAttributes-AttributeTablecontaining the unsigned properties to be replaced with- Returns:
SignerInformationupdated
-
assertATSv2AugmentationSupported
void assertATSv2AugmentationSupported()This method checks whether the augmentation of signatures with an archive-time-stamp-v2 is supported by the current implementation -
assertEvidenceRecordEmbeddingSupported
void assertEvidenceRecordEmbeddingSupported()This method checks whether the embedding of existing Evidence Records within CMS is supported by the current implementation
-