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 String
ASIC_ARCHIVE_MANIFEST_FILENAME
The ASiC Archive Manifest namestatic String
ASIC_MANIFEST_FILENAME
The ASiC Manifest namestatic String
CADES_SIGNATURE_EXTENSION
The signature file extensionstatic String
MANIFEST_FILENAME
The manifest namestatic String
META_INF_FOLDER
The META-INF folderstatic String
MIME_TYPE
The mimetype filenamestatic String
MIME_TYPE_COMMENT
The mimetype commentstatic String
PACKAGE_ZIP
The "package.zip" filenamestatic String
SIGNATURE_FILENAME
The signature filenamestatic String
TIMESTAMP_FILENAME
The timestamp filenamestatic String
TST_EXTENSION
The timestamp file extensionstatic String
XML_EXTENSION
The XML file extension -
Method Summary
Modifier and Type Method Description static boolean
areFilesContainCorrectSignatureFileWithExtension(List<String> filenames, String extension)
Checks if the list of filenames contains a signature with the expectedextension
static boolean
areFilesContainSignatures(List<String> filenames)
Checks if the list of filenames contains a signature(s)static boolean
areFilesContainTimestamp(List<String> filenames)
Checks if the list of filenames contains a timestampstatic ASiCContainerType
getASiCContainerType(MimeType asicMimeType)
Returns relatedASiCContainerType
for the givenasicMimeType
static ASiCContainerType
getContainerType(DSSDocument archive, DSSDocument mimetype, String zipComment, List<DSSDocument> signedDocuments)
Returns target container typestatic MimeType
getMimeType(ASiCParameters asicParameters)
Returns a relevant MimeType for the provided parametersstatic MimeType
getMimeType(DSSDocument mimeTypeDocument)
Extracts and returns MimeType from the documentstatic String
getMimeTypeString(ASiCParameters asicParameters)
Returns the target MimeType stringstatic String
getNextASiCEManifestName(String expectedManifestName, List<DSSDocument> existingManifests)
Generates an unique name for a new ASiC-E Manifest file, avoiding any name collisionstatic String
getPadNumber(int num)
Transformsnum
with the pattern:"2 -> 002"
,"10 -> 010"
, etc.static String
getZipComment(ASiCParameters asicParameters)
Returns a ZIP Comment String according to the given parametersstatic String
getZipComment(String mimeTypeString)
Returns a ZIP Comment String from the providedmimeTypeString
static boolean
isArchiveManifest(String fileName)
Checks if the fileName matches to an Archive Manifest name standardstatic boolean
isASiCE(ASiCParameters asicParameters)
Checks if the parameters are configured for ASiCE creationstatic boolean
isAsicFileContent(List<String> filenames)
Checks if the list of filenames represents an ASiC container contentstatic boolean
isASiCMimeType(MimeType mimeType)
Checks if the given MimeType is ASiC MimeTypestatic boolean
isASiCS(ASiCParameters asicParameters)
Checks if the parameters are configured for ASiCS creationstatic boolean
isASiCSArchive(DSSDocument document)
Checks if the current document an ASiC-E ZIP specific archivestatic boolean
isASiCWithCAdES(List<String> filenames)
Checks if the extracted filenames represent an ASiC with CAdES contentstatic boolean
isCAdES(String entryName)
Checks if the entryName is a relevant CAdES signaturestatic boolean
isMimetype(String entryName)
Checks if the given name is a "mimetype"static boolean
isOpenDocument(DSSDocument mimeTypeDoc)
Checks if the mimeType document defines an OpenDocumentstatic boolean
isOpenDocumentMimeType(MimeType mimeType)
Checks if the given MimeType is OpenDocument MimeTypestatic boolean
isSignature(String entryName)
Verifies if theentryName
represents a signature file namestatic boolean
isTimestamp(String entryName)
Verifies if theentryName
represents a timestamp file namestatic boolean
isXAdES(String entryName)
Checks if the entryName is a relevant XAdES signaturestatic boolean
isZip(DSSDocument document)
Checks if thedocument
is 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 theentryName
represents a signature file name- Parameters:
entryName
-String
name to check- Returns:
- TRUE if the entryName represents a signature file name, FALSE otherwise
-
isTimestamp
Verifies if theentryName
represents a timestamp file name- Parameters:
entryName
-String
name to check- Returns:
- TRUE if the entryName represents a timestamp file name, FALSE otherwise
-
getMimeTypeString
Returns the target MimeType string- Parameters:
asicParameters
-ASiCParameters
- Returns:
String
MimeType
-
getZipComment
Returns a ZIP Comment String according to the given parameters- Parameters:
asicParameters
-ASiCParameters
- Returns:
String
zip comment
-
getZipComment
Returns a ZIP Comment String from the providedmimeTypeString
-
isASiCMimeType
Checks if the given MimeType is ASiC MimeType- Parameters:
mimeType
-MimeType
to check- Returns:
- TRUE if the given MimeType is ASiC MimeType, FALSE otherwise
-
isOpenDocumentMimeType
Checks if the given MimeType is OpenDocument MimeType- Parameters:
mimeType
-MimeType
to check- Returns:
- TRUE if the given MimeType is OpenDocument MimeType, FALSE otherwise
-
getASiCContainerType
Returns relatedASiCContainerType
for the givenasicMimeType
- Parameters:
asicMimeType
-MimeType
to getASiCContainerType
for- 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
-String
signature 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 ofString
file 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 thedocument
is a ZIP container- Parameters:
document
-DSSDocument
to check- Returns:
- TRUE if the
DSSDocument
is a ZIP container, FALSE otherwise
-
isASiCWithCAdES
Checks if the extracted filenames represent an ASiC with CAdES content- Parameters:
filenames
- a list ofString
file 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
-String
to 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
-String
to check- Returns:
- TRUE if the entryName is a relevant CAdES signature, FALSE otherwise
-
isOpenDocument
Checks if the mimeType document defines an OpenDocument- Parameters:
mimeTypeDoc
-DSSDocument
mimetype 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
-String
document name- Returns:
- TRUE if the name is a "mimetype", FALSE otherwise
-
getMimeType
Extracts and returns MimeType from the document- Parameters:
mimeTypeDocument
-DSSDocument
to 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
-DSSDocument
archivemimetype
-DSSDocument
mimetype filezipComment
-String
zipCommentsignedDocuments
- a list ofDSSDocument
s- Returns:
ASiCContainerType
-
getPadNumber
Transformsnum
with 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
-String
to 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
-String
defines the expected name of the file without extension (e.g. "ASiCmanifest")existingManifests
- list of existingDSSDocument
manifests of the type present in the container- Returns:
String
new manifest name
-
isASiCSArchive
Checks if the current document an ASiC-E ZIP specific archive- Parameters:
document
-DSSDocument
to check- Returns:
- TRUE if the document if a "package.zip" archive, FALSE otherwise
-