Package eu.europa.esig.dss.asic.common
Class ASiCUtils
java.lang.Object
eu.europa.esig.dss.asic.common.ASiCUtils
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe ASiC Archive Manifest namestatic 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 ERS evidence record filename for ASiC-E with CAdES containerstatic final StringThe default XMLERS evidence record 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 ASIC evidence record manifest filename for ASiC-E 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 DSSResourcesHandlerBuilderThe default resources handler builder to be used across the codestatic final StringThe evidence record IETF RFC 4998 file extensionstatic final StringThe ASiC with XAdES evidence record ASN.1 document name (META-INF/evidencerecord.ers)static final StringThe evidence record filenamestatic final StringThe ASiC with XAdES evidence record ASN.1 document name (META-INF/evidencerecord.xml)static 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 extensionstatic final byte[]Identifies a first bytes of a zip archive document -
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 booleanfilesContainEvidenceRecords(List<String> filenames) Checks if the list of filenames contains an evidence recordstatic 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 content.static booleanisASiCWithXAdES(List<String> filenames) Checks if the extracted filenames represent an ASiC with XAdES content.static booleanisAsn1EvidenceRecord(String entryName) Verifies if theentryNamerepresents an ERS ASN.1 evidence record filenamestatic booleanChecks if the entryName is a relevant CAdES signaturestatic booleanisContainerOpenDocument(DSSDocument archiveContainer) Checks if the archive represents an OpenDocumentstatic booleanisEvidenceRecord(String entryName) Verifies if theentryNamerepresents an evidence record filenamestatic booleanisEvidenceRecordManifest(String fileName) Checks if the fileName matches to an Evidence Record Manifest name standardstatic 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 booleanisXmlEvidenceRecord(String entryName) Verifies if theentryNamerepresents an XMLERS evidence record filenamestatic 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
-
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:
StringMimeType
-
getZipComment
Returns a ZIP Comment String according to the given parameters- Parameters:
asicParameters-ASiCParameters- Returns:
Stringzip comment
-
getZipComment
-
getZipComment
-
isASiCMimeType
-
isOpenDocumentMimeType
-
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
-
filesContainTimestamps
-
filesContainEvidenceRecords
-
isAsicFileContent
-
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. 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 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. 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 ofStringfile 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-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
-
isMimetype
-
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
-
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 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
-