Class ContainerBuilder
- Direct Known Subclasses:
AsicEContainerBuilder
,AsicSContainerBuilder
,DDocContainerBuilder
,PadesContainerBuilder
Here's an example of creating a new container:
Container
container = ContainerBuilder
.
aContainer("BDOC")
.
withConfiguration(configuration)
. // Configuration settings
withDataFile("testFiles/legal_contract_1.txt", "text/plain")
. // Adding a document from a hard drive
withDataFile(inputStream, "legal_contract_2.txt", "text/plain")
. // Adding a document from a stream
withTimeStampToken(DigestAlgorithm digestAlgorithm)
. // (DEPRECATED) Adding timestamp token in case of ASICS
build()
;
Use ContainerBuilder.aContainer()
to create a new container builder, populate the builder with data and
finally call build()
to create the container with the populated data.
Use fromExistingFile(String)
or fromStream(InputStream)
to open an existing container.
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ContainerBuilder
Create a new ASICE container builder.static ContainerBuilder
aContainer
(String type) Create a new container builder based on a container type.static ContainerBuilder
Create a new container builder based on a container type.build()
Builds a new container or opens existing container from the parameters given to the builder.fromExistingFile
(String filePath) Open container from an existing file.fromStream
(InputStream containerInputStream) Open container from a stream.static void
Clear the list of custom container implementations and types and continue using the default container types and implementations.static <T extends Container>
voidsetContainerImplementation
(String containerType, Class<T> containerClass) Set a custom container implementation class to be used for the container type.abstract ContainerBuilder
usingTempDirectory
(String temporaryDirectoryPath) withConfiguration
(Configuration configuration) Specify configuration for the container.withDataFile
(File file, String mimeType) Add a data file to the container.withDataFile
(InputStream inputStream, String fileName, String mimeType) Add a data file from a stream to the container.withDataFile
(String filePath, String mimeType) Add a data file to the container.withDataFile
(DataFile dataFile) Add a data file to the container.withTimeStampToken
(eu.europa.esig.dss.enumerations.DigestAlgorithm digestAlgorithm) Deprecated.Deprecated for removal
-
Constructor Details
-
ContainerBuilder
public ContainerBuilder()
-
-
Method Details
-
aContainer
Create a new ASICE container builder.- Returns:
- builder for creating or opening a ASICE container.
-
aContainer
Create a new container builder based on a container type.- Parameters:
type
- a type of container to be created, e.g. "BDOC(ASICE)", "ASICS" or "DDOC".- Returns:
- builder for creating a container.
-
aContainer
Create a new container builder based on a container type.- Parameters:
type
- a type of container to be created, e.g. "BDOC(ASICE)", "ASICS" or "DDOC".- Returns:
- builder for creating a container.
-
build
Builds a new container or opens existing container from the parameters given to the builder.- Returns:
- fresh container.
-
withConfiguration
Specify configuration for the container.- Parameters:
configuration
- configuration to use for creating the container.- Returns:
- builder for creating or opening a container.
-
withDataFile
public ContainerBuilder withDataFile(String filePath, String mimeType) throws InvalidDataFileException Add a data file to the container.- Parameters:
filePath
- data file location on the disk.mimeType
- MIME type of the data file, for example 'text/plain' or 'application/msword'- Returns:
- builder for creating or opening a container.
- Throws:
InvalidDataFileException
-
withDataFile
public ContainerBuilder withDataFile(InputStream inputStream, String fileName, String mimeType) throws InvalidDataFileException Add a data file from a stream to the container.- Parameters:
inputStream
- stream of a data file to be added to the container.fileName
- name of the data file to be added.mimeType
- MIME type of the data file, for example 'text/plain' or 'application/msword'- Returns:
- builder for creating or opening a container.
- Throws:
InvalidDataFileException
-
withDataFile
Add a data file to the container.- Parameters:
file
- data file to be added to the container.mimeType
- MIME type of the data file, for example 'text/plain' or 'application/msword'- Returns:
- builder for creating or opening a container.
- Throws:
InvalidDataFileException
-
withDataFile
Add a data file to the container.- Parameters:
dataFile
- data file to be added to the container.- Returns:
- builder for creating or opening a container.
-
withTimeStampToken
@Deprecated public ContainerBuilder withTimeStampToken(eu.europa.esig.dss.enumerations.DigestAlgorithm digestAlgorithm) Deprecated.Deprecated for removalAdd time stamp token to container- Parameters:
digestAlgorithm
-- Returns:
- ContainerBuilder
-
fromExistingFile
Open container from an existing file.- Parameters:
filePath
- absolute path to the container file.- Returns:
- builder for creating or opening a container.
-
fromStream
Open container from a stream.- Parameters:
containerInputStream
- stream of the container file to be opened.- Returns:
- builder for creating or opening a container.
-
setContainerImplementation
public static <T extends Container> void setContainerImplementation(String containerType, Class<T> containerClass) Set a custom container implementation class to be used for the container type.- Type Parameters:
T
- container class extending the Container interface.- Parameters:
containerType
- container type name used when handling such containers.containerClass
- container implementation for handling such container types.- See Also:
-
removeCustomContainerImplementations
public static void removeCustomContainerImplementations()Clear the list of custom container implementations and types and continue using the default container types and implementations. -
usingTempDirectory
-