Package eu.europa.esig.dss.asic.common
Class ASiCUtils
java.lang.Object
eu.europa.esig.dss.asic.common.ASiCUtils
Contains utils for working with ASiC containers
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe ASiC Archive Manifest namestatic final StringThe ASiC Manifest namestatic final StringThe ASiC-E with XAdES Manifest namestatic final StringThe default ASIC archive manifest filename for ASiC-E with CAdES containerstatic final StringThe default ASIC manifest filename for ASiC-E with CAdES containerstatic final StringThe default signature filename for ASiC-E with CAdES containerstatic final StringThe default timestamp filename for ASiC-E with CAdES containerstatic final StringThe default XML manifest filename (META-INF/manifest.xml)static final StringThe default signature filename for ASiC-E with XAdES containerstatic final StringThe signature file extensionstatic final StringThe manifest namestatic final StringThe META-INF folderstatic final StringThe mimetype filenamestatic final StringThe mimetype commentstatic final StringThe ASiC-E with XAdES for OpenDocument signature file name (META-INF/documentsignatures.xml)static final StringThe "package.zip" filenamestatic final StringThe signature filenamestatic final StringThe ASiC-S with CAdES signature document name (META-INF/signature.p7s)static final StringThe signature filenamestatic final StringThe ASiC-S with XAdES signature document name (META-INF/signatures.xml)static final StringThe timestamp filenamestatic final StringThe ASiC-S with CAdES timestamp document name (META-INF/timestamp.tst)static final StringThe timestamp file extensionstatic final StringThe XML file extension -
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddOrReplaceDocument(List<DSSDocument> documentList, DSSDocument newDocument) This method searches for a document in adocumentListwith a name ofnewDocumentVersionand replaces the found entry with the updated version or adds the document to the given list if no such entry has been foundstatic booleanareFilesContainMimetype(List<String> filenames) Checks if the list of filenames contains a mimetype filestatic booleancoversSignature(ManifestFile manifestFile) Checks if the manifestFile covers a signaturestatic ASiCContentensureMimeTypeAndZipComment(ASiCContent asicContent, ASiCParameters asicParameters) This method is used to ensure the mimetype file and zip-comment are present within the givenASiCContent.static booleanfilesContainCorrectSignatureFileWithExtension(List<String> filenames, String extension) Checks if the list of filenames contains a signature with the expectedextensionstatic booleanfilesContainSignatures(List<String> filenames) Checks if the list of filenames contains a signature(s)static booleanfilesContainTimestamps(List<String> filenames) Checks if the list of filenames contains a timestampstatic ASiCContainerTypegetASiCContainerType(MimeType asicMimeType) Returns relatedASiCContainerTypefor the givenasicMimeTypestatic ASiCContainerTypegetContainerType(ASiCContent asicContent) Returns container typestatic ASiCContainerTypegetContainerType(DSSDocument archiveContainer) This method verifies type of the provided container documentstatic MimeTypegetMimeType(ASiCParameters asicParameters) Returns a relevant MimeType for the provided parametersstatic MimeTypegetMimeType(DSSDocument mimeTypeDocument) Extracts and returns MimeType from the documentstatic StringgetMimeTypeString(ASiCParameters asicParameters) Returns the target MimeType stringstatic List<DSSDocument>getRootLevelDocuments(List<DSSDocument> documents) This method returns root-level documents across the provided list of documentsstatic List<DSSDocument>getRootLevelSignedDocuments(ASiCContent asicContent) This method retrieves signed document from a root level of the container (used for ASiC-E container)static StringgetZipComment(ASiCParameters asicParameters) Returns a ZIP Comment String according to the given parametersstatic StringgetZipComment(MimeType mimeType) Returns a ZIP Comment String from the providedMimeTypestatic StringgetZipComment(DSSDocument archiveContainer) Returns a zip commentStringfrom the ASiC containerstatic StringgetZipComment(String mimeTypeString) Returns a ZIP Comment String from the providedmimeTypeStringstatic booleanisArchiveManifest(String fileName) Checks if the fileName matches to an Archive Manifest name standardstatic booleanisASiCE(ASiCParameters asicParameters) Checks if the parameters are configured for ASiCE creationstatic booleanisASiCEContainer(ASiCContent asicContent) This method verifies whether the givenASiCContentis of ASiC-E format typestatic booleanisASiCEContainer(DSSDocument container) This method verifies whether the given container is of ASiC-E format typestatic booleanisAsicFileContent(List<String> filenames) Checks if the list of filenames represents an ASiC container contentstatic booleanisASiCMimeType(MimeType mimeType) Checks if the given MimeType is ASiC MimeTypestatic booleanisASiCS(ASiCParameters asicParameters) Checks if the parameters are configured for ASiCS creationstatic booleanisASiCSContainer(ASiCContent asicContent) This method verifies whether the givenASiCContentis of ASiC-S format typestatic booleanisASiCSContainer(DSSDocument container) This method verifies whether the given container is of ASiC-S format typestatic booleanisASiCWithCAdES(List<String> filenames) Checks if the extracted filenames represent an ASiC with CAdES contentstatic booleanisASiCWithXAdES(List<String> filenames) Checks if the extracted filenames represent an ASiC with XAdES contentstatic booleanChecks if the entryName is a relevant CAdES signaturestatic booleanisContainerOpenDocument(DSSDocument archiveContainer) Checks if the archive represents an OpenDocumentstatic booleanisManifest(String fileName) Checks if the fileName matches to a Manifest name standardstatic booleanisMimetype(String entryName) Checks if the given name is a "mimetype"static booleanisOpenDocument(DSSDocument mimeTypeDoc) Checks if the mimeType document defines an OpenDocumentstatic booleanisOpenDocumentMimeType(MimeType mimeType) Checks if the given MimeType is OpenDocument MimeTypestatic booleanisSignature(String entryName) Verifies if theentryNamerepresents a signature file namestatic booleanisTimestamp(String entryName) Verifies if theentryNamerepresents a timestamp file namestatic booleanChecks if the entryName is a relevant XAdES signaturestatic booleanisZip(DSSDocument document) Checks if thedocumentis a ZIP containerstatic booleanisZip(InputStream is) Checks if the givenInputStreamcontains a ZIP containerstatic List<ManifestEntry>toSimpleManifestEntries(List<DSSDocument> documents) Transforms a list of given documents to a list of "simple" (only basic information) manifest entries
-
Field Details
-
MANIFEST_FILENAME
The manifest name- See Also:
-
ASIC_MANIFEST_FILENAME
The ASiC Manifest name- See Also:
-
ASIC_ARCHIVE_MANIFEST_FILENAME
The ASiC Archive Manifest name- See Also:
-
ASIC_XAdES_MANIFEST_FILENAME
The ASiC-E with XAdES Manifest name- See Also:
-
MIME_TYPE
The mimetype filename- See Also:
-
MIME_TYPE_COMMENT
The mimetype comment- See Also:
-
META_INF_FOLDER
The META-INF folder- See Also:
-
PACKAGE_ZIP
The "package.zip" filename- See Also:
-
SIGNATURE_FILENAME
The signature filename- See Also:
-
SIGNATURES_FILENAME
The signature filename- See Also:
-
TIMESTAMP_FILENAME
The timestamp filename- See Also:
-
CADES_SIGNATURE_EXTENSION
The signature file extension- See Also:
-
TST_EXTENSION
The timestamp file extension- See Also:
-
XML_EXTENSION
The XML file extension- See Also:
-
SIGNATURES_XML
The ASiC-S with XAdES signature document name (META-INF/signatures.xml)- See Also:
-
OPEN_DOCUMENT_SIGNATURES
The ASiC-E with XAdES for OpenDocument signature file name (META-INF/documentsignatures.xml)- See Also:
-
ASICE_METAINF_MANIFEST
The default XML manifest filename (META-INF/manifest.xml)- See Also:
-
ASICE_METAINF_XADES_SIGNATURE
The default signature filename for ASiC-E with XAdES container- See Also:
-
ASICE_METAINF_CADES_SIGNATURE
The default signature filename for ASiC-E with CAdES container- See Also:
-
ASICE_METAINF_CADES_TIMESTAMP
The default timestamp filename for ASiC-E with CAdES container- See Also:
-
ASICE_METAINF_CADES_MANIFEST
The default ASIC manifest filename for ASiC-E with CAdES container- See Also:
-
ASICE_METAINF_CADES_ARCHIVE_MANIFEST
The default ASIC archive manifest filename for ASiC-E with CAdES container- See Also:
-
SIGNATURE_P7S
The ASiC-S with CAdES signature document name (META-INF/signature.p7s)- See Also:
-
TIMESTAMP_TST
The ASiC-S with CAdES timestamp document name (META-INF/timestamp.tst)- See Also:
-
-
Method Details
-
isSignature
Verifies if theentryNamerepresents a signature file name- Parameters:
entryName-Stringname to check- Returns:
- TRUE if the entryName represents a signature file name, FALSE otherwise
-
isTimestamp
Verifies if theentryNamerepresents a timestamp file name- Parameters:
entryName-Stringname to check- Returns:
- TRUE if the entryName represents a timestamp file name, FALSE otherwise
-
getMimeTypeString
Returns the target MimeType string- Parameters:
asicParameters-ASiCParameters- Returns:
StringMimeType
-
getZipComment
Returns a ZIP Comment String according to the given parameters- Parameters:
asicParameters-ASiCParameters- Returns:
Stringzip comment
-
getZipComment
Returns a ZIP Comment String from the providedMimeType -
getZipComment
Returns a ZIP Comment String from the providedmimeTypeString -
isASiCMimeType
Checks if the given MimeType is ASiC MimeType- Parameters:
mimeType-MimeTypeto check- Returns:
- TRUE if the given MimeType is ASiC MimeType, FALSE otherwise
-
isOpenDocumentMimeType
Checks if the given MimeType is OpenDocument MimeType- Parameters:
mimeType-MimeTypeto check- Returns:
- TRUE if the given MimeType is OpenDocument MimeType, FALSE otherwise
-
getASiCContainerType
Returns relatedASiCContainerTypefor the givenasicMimeType- Parameters:
asicMimeType-MimeTypeto getASiCContainerTypefor- Returns:
ASiCContainerType
-
isASiCE
Checks if the parameters are configured for ASiCE creation- Parameters:
asicParameters-ASiCParameters- Returns:
- TRUE if parameters are configured for ASiCE, FALSE otherwise
-
isASiCS
Checks if the parameters are configured for ASiCS creation- Parameters:
asicParameters-ASiCParameters- Returns:
- TRUE if parameters are configured for ASiCS, FALSE otherwise
-
getMimeType
Returns a relevant MimeType for the provided parameters- Parameters:
asicParameters-ASiCParameters- Returns:
MimeType
-
filesContainCorrectSignatureFileWithExtension
public static boolean filesContainCorrectSignatureFileWithExtension(List<String> filenames, String extension) Checks if the list of filenames contains a signature with the expectedextension- Parameters:
filenames- a list of file namesextension-Stringsignature file extension to find- Returns:
- TRUE if the list of filename contains the expected signature file, FALSE otherwise
-
filesContainSignatures
Checks if the list of filenames contains a signature(s)- Parameters:
filenames- a list of file names- Returns:
- TRUE if the list of filename contains a signature file(s)
-
isAsicFileContent
Checks if the list of filenames represents an ASiC container content- Parameters:
filenames- a list ofStringfile names- Returns:
- TRUE if the list of filenames represents an ASiC container content, FALSE otherwise
-
filesContainTimestamps
Checks if the list of filenames contains a timestamp- Parameters:
filenames- a list of filenames to check- Returns:
- TRUE if the list of filenames contains the expected timestamp file, FALSE otherwise
-
isZip
Checks if thedocumentis a ZIP container- Parameters:
document-DSSDocumentto check- Returns:
- TRUE if the
DSSDocumentis a ZIP container, FALSE otherwise
-
isZip
Checks if the givenInputStreamcontains a ZIP container- Parameters:
is-InputStreamto check- Returns:
- TRUE if the
InputStreamis a ZIP container, FALSE otherwise
-
isASiCWithXAdES
Checks if the extracted filenames represent an ASiC with XAdES content- Parameters:
filenames- a list ofStringfile names to check- Returns:
- TRUE if the filenames represent an ASiC with XAdES content, FALSE otherwise
-
isASiCWithCAdES
Checks if the extracted filenames represent an ASiC with CAdES content- Parameters:
filenames- a list ofStringfile names to check- Returns:
- TRUE if the filenames represent an ASiC with CAdES content, FALSE otherwise
-
isXAdES
Checks if the entryName is a relevant XAdES signature- Parameters:
entryName-Stringto check- Returns:
- TRUE if the entryName is a relevant XAdES signature, FALSE otherwise
-
isCAdES
Checks if the entryName is a relevant CAdES signature- Parameters:
entryName-Stringto check- Returns:
- TRUE if the entryName is a relevant CAdES signature, FALSE otherwise
-
isContainerOpenDocument
Checks if the archive represents an OpenDocument- Parameters:
archiveContainer-DSSDocumentan archive to verify- Returns:
- TRUE if the archive contains an OpenDocument mimetype, FALSE otherwise
-
isOpenDocument
Checks if the mimeType document defines an OpenDocument- Parameters:
mimeTypeDoc-DSSDocumentmimetype file extracted from an ASiC container- Returns:
- TRUE if the mimeTypeDoc file defines an OpenDocument, FALSE otherwise
-
areFilesContainMimetype
Checks if the list of filenames contains a mimetype file- Parameters:
filenames- a list of filenames to check- Returns:
- TRUE if the list of filenames contains a mimetype file, FALSE otherwise
-
isMimetype
Checks if the given name is a "mimetype"- Parameters:
entryName-Stringdocument name- Returns:
- TRUE if the name is a "mimetype", FALSE otherwise
-
getMimeType
Extracts and returns MimeType from the document- Parameters:
mimeTypeDocument-DSSDocumentto get a MimeType of- Returns:
MimeType
-
isASiCSContainer
This method verifies whether the given container is of ASiC-S format type- Parameters:
container-DSSDocumentto verify- Returns:
- TRUE if the container is of ASiC-S type, FALSE otherwise
-
isASiCEContainer
This method verifies whether the given container is of ASiC-E format type- Parameters:
container-DSSDocumentto verify- Returns:
- TRUE if the container is of ASiC-E type, FALSE otherwise
-
getContainerType
This method verifies type of the provided container document- Parameters:
archiveContainer-DSSDocumentto verify- Returns:
ASiCContainerType
-
isASiCSContainer
This method verifies whether the givenASiCContentis of ASiC-S format type- Parameters:
asicContent-ASiCContentto verify- Returns:
- TRUE if the ASiC Content is of ASiC-S type, FALSE otherwise
-
isASiCEContainer
This method verifies whether the givenASiCContentis of ASiC-E format type- Parameters:
asicContent-ASiCContentto verify- Returns:
- TRUE if the ASiC Content is of ASiC-E type, FALSE otherwise
-
getContainerType
Returns container type- Parameters:
asicContent-ASiCContent- Returns:
ASiCContainerType
-
isManifest
Checks if the fileName matches to a Manifest name standard- Parameters:
fileName-Stringto check- Returns:
- TRUE if the given name matches Manifest filename, FALSE otherwise
-
isArchiveManifest
Checks if the fileName matches to an Archive Manifest name standard- Parameters:
fileName-Stringto check- Returns:
- TRUE if the given name matches ASiC Archive Manifest filename, FALSE otherwise
-
coversSignature
Checks if the manifestFile covers a signature- Parameters:
manifestFile-ManifestFile- Returns:
- TRUE if manifest entries contain a signature, FALSE otherwise
-
addOrReplaceDocument
This method searches for a document in adocumentListwith a name ofnewDocumentVersionand replaces the found entry with the updated version or adds the document to the given list if no such entry has been found- Parameters:
documentList- a list ofDSSDocumentsnewDocument-DSSDocumentto add
-
ensureMimeTypeAndZipComment
public static ASiCContent ensureMimeTypeAndZipComment(ASiCContent asicContent, ASiCParameters asicParameters) This method is used to ensure the mimetype file and zip-comment are present within the givenASiCContent. If the entry is not defined, a new value if created fromASiCParameters.- Parameters:
asicContent-ASiCContentto ensure a valid structure inasicParameters-ASiCParametersto use to create missing entries- Returns:
ASiCContent
-
getRootLevelSignedDocuments
This method retrieves signed document from a root level of the container (used for ASiC-E container)- Parameters:
asicContent-ASiCContentrepresenting the container structure- Returns:
- a list of
DSSDocuments
-
getRootLevelDocuments
This method returns root-level documents across the provided list of documents- Parameters:
documents- list ofDSSDocumentto get root-level documents from- Returns:
- list of
DSSDocuments
-
getZipComment
Returns a zip commentStringfrom the ASiC container- Parameters:
archiveContainer-DSSDocumentrepresenting an Archive container- Returns:
Stringzip comment
-
toSimpleManifestEntries
Transforms a list of given documents to a list of "simple" (only basic information) manifest entries- Parameters:
documents- list ofDSSDocuments- Returns:
- list of
ManifestEntrys
-