Package eu.europa.esig.dss.asic.common
Class SecureContainerHandler
java.lang.Object
eu.europa.esig.dss.asic.common.SecureContainerHandler
- All Implemented Interfaces:
ZipContainerHandler
public class SecureContainerHandler extends Object implements ZipContainerHandler
The default implementation of
ZipContainerHandler, providing
utilities to prevent a denial of service attacks, such as zip-bombing-
Constructor Summary
Constructors Constructor Description SecureContainerHandler() -
Method Summary
Modifier and Type Method Description DSSDocumentcreateZipArchive(List<DSSDocument> containerEntries, Date creationTime, String zipComment)Creates a ZIP-Archive with the givencontainerEntriesList<DSSDocument>extractContainerContent(DSSDocument zipArchive)Extracts a list ofDSSDocumentfrom the given ZIP-archiveList<String>extractEntryNames(DSSDocument zipArchive)Returns a list of ZIP archive entry namesvoidsetMaxAllowedFilesAmount(int maxAllowedFilesAmount)Sets the maximum allowed amount of files inside a container Default : 1000voidsetMaxCompressionRatio(long maxCompressionRatio)Sets the maximum allowed compression ratio If the container compression ratio exceeds the value, an exception is being thrown Default : 100voidsetMaxMalformedFiles(int maxMalformedFiles)Sets the maximum allowed amount of malformed files Default : 100voidsetThreshold(long threshold)Sets the maximum allowed threshold after exceeding each the security checks are enforced Default : 1000000 (1 MB)
-
Constructor Details
-
SecureContainerHandler
public SecureContainerHandler()
-
-
Method Details
-
setThreshold
public void setThreshold(long threshold)Sets the maximum allowed threshold after exceeding each the security checks are enforced Default : 1000000 (1 MB)- Parameters:
threshold- in bytes
-
setMaxCompressionRatio
public void setMaxCompressionRatio(long maxCompressionRatio)Sets the maximum allowed compression ratio If the container compression ratio exceeds the value, an exception is being thrown Default : 100- Parameters:
maxCompressionRatio- the maximum compression ratio
-
setMaxAllowedFilesAmount
public void setMaxAllowedFilesAmount(int maxAllowedFilesAmount)Sets the maximum allowed amount of files inside a container Default : 1000- Parameters:
maxAllowedFilesAmount- the maximum number of allowed files
-
setMaxMalformedFiles
public void setMaxMalformedFiles(int maxMalformedFiles)Sets the maximum allowed amount of malformed files Default : 100- Parameters:
maxMalformedFiles- the maximum number of malformed files
-
extractContainerContent
Description copied from interface:ZipContainerHandlerExtracts a list ofDSSDocumentfrom the given ZIP-archive- Specified by:
extractContainerContentin interfaceZipContainerHandler- Parameters:
zipArchive-DSSDocument- Returns:
- a list of
DSSDocuments
-
extractEntryNames
Description copied from interface:ZipContainerHandlerReturns a list of ZIP archive entry names- Specified by:
extractEntryNamesin interfaceZipContainerHandler- Parameters:
zipArchive-DSSDocument- Returns:
- a list of
Stringentry names
-
createZipArchive
public DSSDocument createZipArchive(List<DSSDocument> containerEntries, Date creationTime, String zipComment)Description copied from interface:ZipContainerHandlerCreates a ZIP-Archive with the givencontainerEntries- Specified by:
createZipArchivein interfaceZipContainerHandler- Parameters:
containerEntries- a list ofDSSDocuments to embed into the new container instancecreationTime- (Optional)Datedefined time of an archive creation, will be set for all embedded files. If null, the local current time will be usedzipComment- (Optional)Stringdefined a zipComment- Returns:
DSSDocumentZIP-Archive
-