Package eu.europa.esig.dss.cms.object
Class CMSObjectUtils
java.lang.Object
eu.europa.esig.dss.cms.object.CMSObjectUtils
- All Implemented Interfaces:
ICMSUtils
Implements
ICMSUtils using a eu.europa.esig.dss.cms.bc.CMSSignedDataWrapper processing-
Constructor Summary
Constructors -
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.static org.bouncycastle.asn1.cms.SignedDatagetSignedData(CMS cms) Gets SignedData element of the CMSparseToCMS(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 typestatic org.bouncycastle.util.Store<org.bouncycastle.util.Encodable> toCRLsStore(org.bouncycastle.util.Store<org.bouncycastle.cert.X509CRLHolder> crls, org.bouncycastle.util.Store<?> ocspResponses, org.bouncycastle.util.Store<?> ocspBasicResponses) Creates a new combined SignedData.crls store containing CRLs, OCSP responses and OCSP Basic responsesvoidwriteContentInfoEncoded(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.
-
Constructor Details
-
CMSObjectUtils
public CMSObjectUtils()Default constructor
-
-
Method Details
-
parseToCMS
Description copied from interface:ICMSUtilsParses the givenDSSDocumentto aCMSobject- Specified by:
parseToCMSin interfaceICMSUtils- Parameters:
document-DSSDocumentto parse- Returns:
CMS
-
parseToCMS
Description copied from interface:ICMSUtilsParses the given byte array to aCMSobject- Specified by:
parseToCMSin interfaceICMSUtils- Parameters:
binaries- byte array to parse- Returns:
CMS
-
writeToDSSDocument
Description copied from interface:ICMSUtilsCreates 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.- Specified by:
writeToDSSDocumentin interfaceICMSUtils- Parameters:
cms-CMSto create a document fromresourcesHandlerBuilder-DSSResourcesHandlerBuilder- Returns:
DSSDocument
-
recomputeSignerInformation
public org.bouncycastle.cms.SignerInformation recomputeSignerInformation(CMS cms, org.bouncycastle.cms.SignerId signerId, org.bouncycastle.operator.DigestCalculatorProvider digestCalculatorProvider, DSSResourcesHandlerBuilder resourcesHandlerBuilder) throws org.bouncycastle.cms.CMSException Description copied from interface:ICMSUtilsThis method re-created theSignerInformationwith a givensignerIdfromCMSby providing thedigestCalculatorProviderto the validation. The returnedSignerInformationcontains validated digest according to the provided document.- Specified by:
recomputeSignerInformationin interfaceICMSUtils- 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
Description copied from interface:ICMSUtilsReplaces the signers withincmswith thenewSignerStore- Specified by:
replaceSignersin interfaceICMSUtils- Parameters:
cms-CMSto replace signers innewSignerStore-SignerInformationStorerepresenting the new signers to be replaced with- Returns:
CMScontaining the new signers store
-
replaceCertificatesAndCRLs
public 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) Description copied from interface:ICMSUtilsReplaces SignedData content within theCMSwith the provided values- Specified by:
replaceCertificatesAndCRLsin interfaceICMSUtils- Parameters:
cms-CMSto replace content incertificates-StoreattributeCertificates-Storecrls-StoreocspResponsesStore-StoreocspBasicStore-Store- Returns:
CMS
-
toCRLsStore
public static org.bouncycastle.util.Store<org.bouncycastle.util.Encodable> toCRLsStore(org.bouncycastle.util.Store<org.bouncycastle.cert.X509CRLHolder> crls, org.bouncycastle.util.Store<?> ocspResponses, org.bouncycastle.util.Store<?> ocspBasicResponses) Creates a new combined SignedData.crls store containing CRLs, OCSP responses and OCSP Basic responses- Parameters:
crls-Storecontaining CRLsocspResponses-Storecontaining OCSP responsesocspBasicResponses-Storecontaining OCSP Basic responses- Returns:
Store
-
populateDigestAlgorithmSet
public CMS populateDigestAlgorithmSet(CMS cms, Collection<org.bouncycastle.asn1.x509.AlgorithmIdentifier> digestAlgorithmsToAdd) Description copied from interface:ICMSUtilsAdds digest algorithms toCMSSignedData- Specified by:
populateDigestAlgorithmSetin interfaceICMSUtils- Parameters:
cms-CMSto extenddigestAlgorithmsToAdd- a collection of digestAlgorithmIdentifiers to be included- Returns:
CMS
-
toCMS
Description copied from interface:ICMSUtilsConverts aTimeStampTokento aCMS -
getContentInfoEncoding
Description copied from interface:ICMSUtilsGets encoding of the ContentInfo of CMS- Specified by:
getContentInfoEncodingin interfaceICMSUtils- Parameters:
cms-CMSto check- Returns:
Stringencoding, e.g. 'DER' or 'BER'
-
writeSignedDataDigestAlgorithmsEncoded
Description copied from interface:ICMSUtilsWrites the encoded binaries of the SignedData.digestAlgorithms field to the givenOutputStreamNOTE: This method is used for evidence record hash computation- Specified by:
writeSignedDataDigestAlgorithmsEncodedin interfaceICMSUtils- Parameters:
cms-CMSos-OutputStream- Throws:
IOException- if an exception occurs on bytes writing
-
writeContentInfoEncoded
Description copied from interface:ICMSUtilsWrites the encoded binaries of the ContentInfo element to the givenOutputStreamNOTE: This method is used for archive-time-stamp-v2 message-imprint computation.- Specified by:
writeContentInfoEncodedin interfaceICMSUtils- Parameters:
cms-CMSos-OutputStream- Throws:
IOException- if an exception occurs on bytes writing
-
writeSignedDataCertificatesEncoded
Description copied from interface:ICMSUtilsWrites the encoded binaries of the SignedData.certificates field to the givenOutputStreamNOTE: This method is used for archive-time-stamp-v2 message-imprint computation.- Specified by:
writeSignedDataCertificatesEncodedin interfaceICMSUtils- Parameters:
cms-CMSos-OutputStream- Throws:
IOException- if an exception occurs on bytes writing
-
writeSignedDataCRLsEncoded
Description copied from interface:ICMSUtilsWrites the encoded binaries of the SignedData.crls field to the givenOutputStreamNOTE: This method is used for archive-time-stamp-v2 message-imprint computation.- Specified by:
writeSignedDataCRLsEncodedin interfaceICMSUtils- Parameters:
cms-CMSos-OutputStream- Throws:
IOException- if an exception occurs on bytes writing
-
writeSignedDataSignerInfosEncoded
Description copied from interface:ICMSUtilsWrites the encoded binaries of the SignedData.signerInfos field to the givenOutputStreamNOTE: This method is used for evidence record hash computation- Specified by:
writeSignedDataSignerInfosEncodedin interfaceICMSUtils- Parameters:
cms-CMSos-OutputStream- Throws:
IOException- if an exception occurs on bytes writing
-
getSignedData
Gets SignedData element of the CMS- Parameters:
cms-CMS- Returns:
SignedData
-
toCMSEncapsulatedContent
Description copied from interface:ICMSUtilsConverts aDSSDocumentto the correspondingCMSTypedDataobject type- Specified by:
toCMSEncapsulatedContentin interfaceICMSUtils- Parameters:
document-DSSDocument- Returns:
CMSTypedData
-
getDSSResourcesHandlerBuilder
public DSSResourcesHandlerBuilder getDSSResourcesHandlerBuilder(DSSResourcesHandlerBuilder dssResourcesHandlerBuilder) Description copied from interface:ICMSUtilsThis method is used to verify whether the providedDSSResourcesHandlerBuilderis supported by the current implementation. Returns the given value in case of success.- Specified by:
getDSSResourcesHandlerBuilderin interfaceICMSUtils- Parameters:
dssResourcesHandlerBuilder-DSSResourcesHandlerBuilder- Returns:
DSSResourcesHandlerBuilder
-
replaceUnsignedAttributes
public org.bouncycastle.cms.SignerInformation replaceUnsignedAttributes(org.bouncycastle.cms.SignerInformation signerInformation, org.bouncycastle.asn1.cms.AttributeTable unsignedAttributes) Description copied from interface:ICMSUtilsThis method replacesunsignedAttributeswithin the givensignerInformation- Specified by:
replaceUnsignedAttributesin interfaceICMSUtils- Parameters:
signerInformation-SignerInformationto replace unsigned attributes table intounsignedAttributes-AttributeTablecontaining the unsigned properties to be replaced with- Returns:
SignerInformationupdated
-
assertATSv2AugmentationSupported
public void assertATSv2AugmentationSupported()Description copied from interface:ICMSUtilsThis method checks whether the augmentation of signatures with an archive-time-stamp-v2 is supported by the current implementation- Specified by:
assertATSv2AugmentationSupportedin interfaceICMSUtils
-
assertEvidenceRecordEmbeddingSupported
public void assertEvidenceRecordEmbeddingSupported()Description copied from interface:ICMSUtilsThis method checks whether the embedding of existing Evidence Records within CMS is supported by the current implementation- Specified by:
assertEvidenceRecordEmbeddingSupportedin interfaceICMSUtils
-