Package eu.europa.esig.dss.asic.common
Class ASiCUtils
java.lang.Object
eu.europa.esig.dss.asic.common.ASiCUtils
public final class ASiCUtils extends Object
Contains utils for working with ASiC containers
-
Field Summary
Fields Modifier and Type Field Description static StringASIC_ARCHIVE_MANIFEST_FILENAMEThe ASiC Archive Manifest namestatic StringASIC_MANIFEST_FILENAMEThe ASiC Manifest namestatic StringCADES_SIGNATURE_EXTENSIONThe signature file extensionstatic StringMANIFEST_FILENAMEThe manifest namestatic StringMETA_INF_FOLDERThe META-INF folderstatic StringMIME_TYPEThe mimetype filenamestatic StringMIME_TYPE_COMMENTThe mimetype commentstatic StringPACKAGE_ZIPThe "package.zip" filenamestatic StringSIGNATURE_FILENAMEThe signature filenamestatic StringTIMESTAMP_FILENAMEThe timestamp filenamestatic StringTST_EXTENSIONThe timestamp file extensionstatic StringXML_EXTENSIONThe XML file extension -
Method Summary
Modifier and Type Method Description static booleanareFilesContainCorrectSignatureFileWithExtension(List<String> filenames, String extension)Checks if the list of filenames contains a signature with the expectedextensionstatic booleanareFilesContainSignatures(List<String> filenames)Checks if the list of filenames contains a signature(s)static booleanareFilesContainTimestamp(List<String> filenames)Checks if the list of filenames contains a timestampstatic ASiCContainerTypegetASiCContainerType(MimeType asicMimeType)Returns relatedASiCContainerTypefor the givenasicMimeTypestatic ASiCContainerTypegetContainerType(DSSDocument archive, DSSDocument mimetype, String zipComment, List<DSSDocument> signedDocuments)Returns target container typestatic 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 StringgetNextASiCEManifestName(String expectedManifestName, List<DSSDocument> existingManifests)Generates an unique name for a new ASiC-E Manifest file, avoiding any name collisionstatic StringgetPadNumber(int num)Transformsnumwith the pattern:"2 -> 002","10 -> 010", etc.static StringgetZipComment(ASiCParameters asicParameters)Returns a ZIP Comment String according to the given parametersstatic 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 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 booleanisASiCSArchive(DSSDocument document)Checks if the current document an ASiC-E ZIP specific archivestatic booleanisASiCWithCAdES(List<String> filenames)Checks if the extracted filenames represent an ASiC with CAdES contentstatic booleanisCAdES(String entryName)Checks if the entryName is a relevant CAdES signaturestatic 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 booleanisXAdES(String entryName)Checks if the entryName is a relevant XAdES signaturestatic booleanisZip(DSSDocument document)Checks if thedocumentis a ZIP container
-
Field Details
-
MANIFEST_FILENAME
The manifest name- See Also:
- Constant Field Values
-
ASIC_MANIFEST_FILENAME
The ASiC Manifest name- See Also:
- Constant Field Values
-
ASIC_ARCHIVE_MANIFEST_FILENAME
The ASiC Archive Manifest name- See Also:
- Constant Field Values
-
MIME_TYPE
The mimetype filename- See Also:
- Constant Field Values
-
MIME_TYPE_COMMENT
The mimetype comment- See Also:
- Constant Field Values
-
META_INF_FOLDER
The META-INF folder- See Also:
- Constant Field Values
-
PACKAGE_ZIP
The "package.zip" filename- See Also:
- Constant Field Values
-
SIGNATURE_FILENAME
The signature filename- See Also:
- Constant Field Values
-
TIMESTAMP_FILENAME
The timestamp filename- See Also:
- Constant Field Values
-
CADES_SIGNATURE_EXTENSION
The signature file extension- See Also:
- Constant Field Values
-
TST_EXTENSION
The timestamp file extension- See Also:
- Constant Field Values
-
XML_EXTENSION
The XML file extension- See Also:
- Constant Field Values
-
-
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 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
-
areFilesContainCorrectSignatureFileWithExtension
public static boolean areFilesContainCorrectSignatureFileWithExtension(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
-
areFilesContainSignatures
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
-
areFilesContainTimestamp
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
-
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
-
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
-
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
-
getContainerType
public static ASiCContainerType getContainerType(DSSDocument archive, DSSDocument mimetype, String zipComment, List<DSSDocument> signedDocuments)Returns target container type- Parameters:
archive-DSSDocumentarchivemimetype-DSSDocumentmimetype filezipComment-StringzipCommentsignedDocuments- a list ofDSSDocuments- Returns:
ASiCContainerType
-
getPadNumber
Transformsnumwith the pattern:"2 -> 002","10 -> 010", etc.- Parameters:
num- number to transform- Returns:
String
-
isArchiveManifest
Checks if the fileName matches to an Archive Manifest name standard- Parameters:
fileName-Stringto check- Returns:
- TRUE if the given name matches to and ASiC Archive Manifest filename, FALSE otherwise
-
getNextASiCEManifestName
public static String getNextASiCEManifestName(String expectedManifestName, List<DSSDocument> existingManifests)Generates an unique name for a new ASiC-E Manifest file, avoiding any name collision- Parameters:
expectedManifestName-Stringdefines the expected name of the file without extension (e.g. "ASiCmanifest")existingManifests- list of existingDSSDocumentmanifests of the type present in the container- Returns:
Stringnew manifest name
-
isASiCSArchive
Checks if the current document an ASiC-E ZIP specific archive- Parameters:
document-DSSDocumentto check- Returns:
- TRUE if the document if a "package.zip" archive, FALSE otherwise
-