Package eu.europa.esig.dss.asic.common
Class ASiCUtils
java.lang.Object
eu.europa.esig.dss.asic.common.ASiCUtils
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
The ASiC Archive Manifest namestatic final String
The ASiC Archive Manifest namestatic final String
The ASiC Manifest namestatic final String
The ASiC-E with XAdES Manifest namestatic final String
The default ASIC archive manifest filename for ASiC-E with CAdES containerstatic final String
The default ERS evidence record filename for ASiC-E with CAdES containerstatic final String
The default XMLERS evidence record filename for ASiC-E with CAdES containerstatic final String
The default ASIC manifest filename for ASiC-E with CAdES containerstatic final String
The default signature filename for ASiC-E with CAdES containerstatic final String
The default timestamp filename for ASiC-E with CAdES containerstatic final String
The default ASIC evidence record manifest filename for ASiC-E containerstatic final String
The default XML manifest filename (META-INF/manifest.xml)static final String
The default signature filename for ASiC-E with XAdES containerstatic final String
The signature file extensionstatic final DSSResourcesHandlerBuilder
The default resources handler builder to be used across the codestatic final String
The evidence record IETF RFC 4998 file extensionstatic final String
The ASiC with XAdES evidence record ASN.1 document name (META-INF/evidencerecord.ers)static final String
The evidence record filenamestatic final String
The ASiC with XAdES evidence record ASN.1 document name (META-INF/evidencerecord.xml)static final String
The manifest namestatic final String
The META-INF folderstatic final String
The mimetype filenamestatic final String
The mimetype commentstatic final String
The ASiC-E with XAdES for OpenDocument signature file name (META-INF/documentsignatures.xml)static final String
The "package.zip" filenamestatic final String
The signature filenamestatic final String
The ASiC-S with CAdES signature document name (META-INF/signature.p7s)static final String
The signature filenamestatic final String
The ASiC-S with XAdES signature document name (META-INF/signatures.xml)static final String
The timestamp filenamestatic final String
The ASiC-S with CAdES timestamp document name (META-INF/timestamp.tst)static final String
The timestamp file extensionstatic final String
The XML file extensionstatic final byte[]
Identifies a first bytes of a zip archive document -
Method Summary
Modifier and TypeMethodDescriptionstatic void
addOrReplaceDocument
(List<DSSDocument> documentList, DSSDocument newDocument) This method searches for a document in adocumentList
with a name ofnewDocumentVersion
and replaces the found entry with the updated version or adds the document to the given list if no such entry has been foundstatic boolean
areFilesContainMimetype
(List<String> filenames) Checks if the list of filenames contains a mimetype filestatic boolean
coversSignature
(ManifestFile manifestFile) Checks if the manifestFile covers a signaturestatic ASiCContent
ensureMimeTypeAndZipComment
(ASiCContent asicContent, ASiCParameters asicParameters) This method is used to ensure the mimetype file and zip-comment are present within the givenASiCContent
.static boolean
filesContainCorrectSignatureFileWithExtension
(List<String> filenames, String extension) Checks if the list of filenames contains a signature with the expectedextension
static boolean
filesContainEvidenceRecords
(List<String> filenames) Checks if the list of filenames contains an evidence recordstatic boolean
filesContainSignatures
(List<String> filenames) Checks if the list of filenames contains a signature(s)static boolean
filesContainTimestamps
(List<String> filenames) Checks if the list of filenames contains a timestampstatic ASiCContainerType
getASiCContainerType
(MimeType asicMimeType) Returns relatedASiCContainerType
for the givenasicMimeType
static ASiCContainerType
getContainerType
(ASiCContent asicContent) Returns container typestatic ASiCContainerType
getContainerType
(DSSDocument archiveContainer) This method verifies type of the provided container documentstatic 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 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 String
getZipComment
(ASiCParameters asicParameters) Returns a ZIP Comment String according to the given parametersstatic String
getZipComment
(MimeType mimeType) Returns a ZIP Comment String from the providedMimeType
static String
getZipComment
(DSSDocument archiveContainer) Returns a zip commentString
from the ASiC containerstatic 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
isASiCEContainer
(ASiCContent asicContent) This method verifies whether the givenASiCContent
is of ASiC-E format typestatic boolean
isASiCEContainer
(DSSDocument container) This method verifies whether the given container is of ASiC-E format typestatic 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
isASiCSContainer
(ASiCContent asicContent) This method verifies whether the givenASiCContent
is of ASiC-S format typestatic boolean
isASiCSContainer
(DSSDocument container) This method verifies whether the given container is of ASiC-S format typestatic boolean
isASiCWithCAdES
(List<String> filenames) Checks if the extracted filenames represent an ASiC with CAdES content.static boolean
isASiCWithXAdES
(List<String> filenames) Checks if the extracted filenames represent an ASiC with XAdES content.static boolean
isAsn1EvidenceRecord
(String entryName) Verifies if theentryName
represents an ERS ASN.1 evidence record filenamestatic boolean
Checks if the entryName is a relevant CAdES signaturestatic boolean
isContainerOpenDocument
(DSSDocument archiveContainer) Checks if the archive represents an OpenDocumentstatic boolean
isEvidenceRecord
(String entryName) Verifies if theentryName
represents an evidence record filenamestatic boolean
isEvidenceRecordManifest
(String fileName) Checks if the fileName matches to an Evidence Record Manifest name standardstatic boolean
isManifest
(String fileName) Checks if the fileName matches to a Manifest name standardstatic 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
Checks if the entryName is a relevant XAdES signaturestatic boolean
isXmlEvidenceRecord
(String entryName) Verifies if theentryName
represents an XMLERS evidence record filenamestatic boolean
isZip
(DSSDocument document) Checks if thedocument
is a ZIP containerstatic boolean
isZip
(InputStream is) Checks if the givenInputStream
contains 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
-
ASIC_MANIFEST_FILENAME
-
ASIC_ARCHIVE_MANIFEST_FILENAME
-
ASIC_EVIDENCE_RECORD_MANIFEST_FILENAME
The ASiC Archive Manifest name- See Also:
-
ASIC_XAdES_MANIFEST_FILENAME
The ASiC-E with XAdES Manifest name- See Also:
-
MIME_TYPE
-
MIME_TYPE_COMMENT
-
META_INF_FOLDER
-
PACKAGE_ZIP
-
SIGNATURE_FILENAME
-
SIGNATURES_FILENAME
-
TIMESTAMP_FILENAME
-
EVIDENCE_RECORD_FILENAME
-
CADES_SIGNATURE_EXTENSION
-
TST_EXTENSION
-
ER_ASN1_EXTENSION
The evidence record IETF RFC 4998 file extension- See Also:
-
XML_EXTENSION
-
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_EVIDENCE_RECORD_ASN1
The default ERS evidence record filename for ASiC-E with CAdES container- See Also:
-
ASICE_METAINF_CADES_EVIDENCE_RECORD_XML
The default XMLERS evidence record 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:
-
ASICE_METAINF_EVIDENCE_RECORD_MANIFEST
The default ASIC evidence record manifest filename for ASiC-E 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:
-
EVIDENCE_RECORD_ERS
The ASiC with XAdES evidence record ASN.1 document name (META-INF/evidencerecord.ers)- See Also:
-
EVIDENCE_RECORD_XML
The ASiC with XAdES evidence record ASN.1 document name (META-INF/evidencerecord.xml)- See Also:
-
ZIP_PREFIX
public static final byte[] ZIP_PREFIXIdentifies a first bytes of a zip archive document -
DEFAULT_RESOURCES_HANDLER_BUILDER
The default resources handler builder to be used across the code
-
-
Method Details
-
isSignature
-
isTimestamp
-
isEvidenceRecord
-
isXmlEvidenceRecord
-
isAsn1EvidenceRecord
-
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
-
getZipComment
-
isASiCMimeType
-
isOpenDocumentMimeType
-
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
-
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
-String
signature file extension to find- Returns:
- TRUE if the list of filename contains the expected signature file, FALSE otherwise
-
filesContainSignatures
-
filesContainTimestamps
-
filesContainEvidenceRecords
-
isAsicFileContent
-
isZip
Checks if thedocument
is a ZIP container- Parameters:
document
-DSSDocument
to check- Returns:
- TRUE if the
DSSDocument
is a ZIP container, FALSE otherwise
-
isZip
Checks if the givenInputStream
contains a ZIP container- Parameters:
is
-InputStream
to check- Returns:
- TRUE if the
InputStream
is a ZIP container, FALSE otherwise
-
isASiCWithXAdES
Checks if the extracted filenames represent an ASiC with XAdES content. Note: The method looks for format specific documents. It returns FALSE for shared document formats between XAdES and CAdES (e.g. evidence records).- Parameters:
filenames
- a list ofString
file 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. Note: The method looks for format specific documents. It returns FALSE for shared document formats between XAdES and CAdES (e.g. evidence records).- Parameters:
filenames
- a list ofString
file names to check- Returns:
- TRUE if the filenames represent an ASiC with CAdES content, FALSE otherwise
-
isXAdES
-
isCAdES
-
isContainerOpenDocument
Checks if the archive represents an OpenDocument- Parameters:
archiveContainer
-DSSDocument
an 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
-DSSDocument
mimetype file extracted from an ASiC container- Returns:
- TRUE if the mimeTypeDoc file defines an OpenDocument, FALSE otherwise
-
areFilesContainMimetype
-
isMimetype
-
getMimeType
Extracts and returns MimeType from the document- Parameters:
mimeTypeDocument
-DSSDocument
to get a MimeType of- Returns:
MimeType
-
isASiCSContainer
This method verifies whether the given container is of ASiC-S format type- Parameters:
container
-DSSDocument
to 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
-DSSDocument
to 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
-DSSDocument
to verify- Returns:
ASiCContainerType
-
isASiCSContainer
This method verifies whether the givenASiCContent
is of ASiC-S format type- Parameters:
asicContent
-ASiCContent
to verify- Returns:
- TRUE if the ASiC Content is of ASiC-S type, FALSE otherwise
-
isASiCEContainer
This method verifies whether the givenASiCContent
is of ASiC-E format type- Parameters:
asicContent
-ASiCContent
to verify- Returns:
- TRUE if the ASiC Content is of ASiC-E type, FALSE otherwise
-
getContainerType
Returns container type- Parameters:
asicContent
-ASiCContent
- Returns:
ASiCContainerType
-
isManifest
-
isArchiveManifest
-
isEvidenceRecordManifest
-
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 adocumentList
with a name ofnewDocumentVersion
and 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 ofDSSDocument
snewDocument
-DSSDocument
to 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
-ASiCContent
to ensure a valid structure inasicParameters
-ASiCParameters
to 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
-ASiCContent
representing the container structure- Returns:
- a list of
DSSDocument
s
-
getRootLevelDocuments
This method returns root-level documents across the provided list of documents- Parameters:
documents
- list ofDSSDocument
to get root-level documents from- Returns:
- list of
DSSDocument
s
-
getZipComment
Returns a zip commentString
from the ASiC container- Parameters:
archiveContainer
-DSSDocument
representing an Archive container- Returns:
String
zip comment
-
toSimpleManifestEntries
Transforms a list of given documents to a list of "simple" (only basic information) manifest entries- Parameters:
documents
- list ofDSSDocument
s- Returns:
- list of
ManifestEntry
s
-