libdigidocpp 4.1.0
|
Offers functionality for handling data files and signatures in a container. More...
#include <Container.h>
Public Member Functions | |
virtual | ~Container () |
virtual void | save (const std::string &path="")=0 |
virtual std::string | mediaType () const =0 |
virtual void | addDataFile (const std::string &path, const std::string &mediaType)=0 |
virtual DIGIDOCPP_DEPRECATED void | addDataFile (std::istream *is, const std::string &fileName, const std::string &mediaType) |
virtual std::vector< DataFile * > | dataFiles () const =0 |
virtual void | removeDataFile (unsigned int index)=0 |
void | addAdESSignature (const std::vector< unsigned char > &signature) |
virtual void | addAdESSignature (std::istream &signature)=0 |
virtual Signature * | prepareSignature (Signer *signer)=0 |
virtual std::vector< Signature * > | signatures () const =0 |
virtual void | removeSignature (unsigned int index)=0 |
virtual Signature * | sign (Signer *signer)=0 |
virtual void | addDataFile (std::unique_ptr< std::istream > is, const std::string &fileName, const std::string &mediaType) |
Static Public Member Functions | |
static DIGIDOCPP_DEPRECATED Container * | create (const std::string &path) |
static std::unique_ptr< Container > | createPtr (const std::string &path) |
static DIGIDOCPP_DEPRECATED Container * | open (const std::string &path) |
static std::unique_ptr< Container > | openPtr (const std::string &path) |
static std::unique_ptr< Container > | openPtr (const std::string &path, digidoc::ContainerOpenCB *cb) |
template<class T> | |
static void | addContainerImplementation () |
Protected Member Functions | |
Container () | |
unsigned int | newSignatureId () const |
Offers functionality for handling data files and signatures in a container.
Container can contain several files and all these files can be signed using signing certificates. Container can only be signed if it contains data files. data files can be added and removed from container only if the container is not signed. To add or remove data files from signed container remove all the signatures before modifying data files list in container.
|
virtualdefault |
Releases resources.
|
protecteddefault |
Create a new container object and specify the DigiDoc container type
References Container(), and newSignatureId().
Referenced by Container(), create(), open(), and sign().
void Container::addAdESSignature | ( | const std::vector< unsigned char > & | signature | ) |
Adds signature to the container.
signature | signature, which is added to the container. |
Exception | throws exception if there are no data files in container. |
References addAdESSignature().
Referenced by addAdESSignature(), and removeDataFile().
|
pure virtual |
Adds signature to the container.
signature | signature, which is added to the container. |
Exception | throws exception if there are no data files in container. |
|
static |
Adds container implementation
It must contain static members:
Referenced by digidoc::initialize(), and sign().
|
pure virtual |
Adds data file from file system to the container.
path | a data file, which is added to the container. |
mediaType | MIME type of the data file, for example “text/plain” or “application/msword” |
Exception | exception is thrown if the data file path is incorrect or a data file with same file name already exists. Also, no data file can be added if the container already has one or more signatures. |
References addDataFile(), and mediaType().
Referenced by addDataFile(), addDataFile(), and sign().
|
virtual |
Adds the data from an input stream (i.e. the data file contents can be read from internal memory buffer).
Takes ownership std::istream *is object.
is | input stream from where data is read |
fileName | data file name in the container |
mediaType | MIME type of the data file, for example “text/plain” or “application/msword” |
Exception | exception is thrown if the data file path is incorrect or a data file with same file name already exists. Also, no data file can be added if the container already has one or more signatures. |
References addDataFile(), and mediaType().
|
virtual |
Adds the data from an input stream (i.e. the data file contents can be read from internal memory buffer).
is | input stream from where data is read |
fileName | data file name in the container |
mediaType | MIME type of the data file, for example “text/plain” or “application/msword” |
Exception | exception is thrown if the data file path is incorrect or a data file with same file name already exists. Also, no data file can be added if the container already has one or more signatures. |
|
static |
Create a new container object and specify the DigiDoc container type
References Container(), and createPtr().
Referenced by createPtr(), and sign().
|
static |
|
pure virtual |
List of all the data files in the container
Container holds ownership of data files objects
|
pure virtual |
Returns current data file format
Referenced by addDataFile(), addDataFile(), and sign().
|
protected |
|
static |
Opens container from a file
This method gives ownership of object to caller
path |
Exception |
References Container(), and openPtr().
|
static |
|
static |
Opens container from a file
path | |
cb | Callback called when additional info is requested (digidoc::ContainerOpenCB::validateOnline) |
Exception |
References open().
Prepares Signature object that can later signed.
Container holds ownership of Signature object
signer | signer implementation. |
Exception | exception is thrown if signing the container failed. |
|
pure virtual |
Removes data file from container by data file index. Data files can be removed from container only after all signatures are removed.
index | data file's index, which will be removed. |
Exception | throws exception if the data file id is incorrect or there are one or more signatures. |
References addAdESSignature().
|
pure virtual |
Removes signature from container by signature index.
index | signature's index, which will be removed. |
Exception | throws exception if the signature id is incorrect. |
|
pure virtual |
Saves the container.
Exception | is thrown if there was a failure saving container. For example added data file does not exist. |
Signs all data files in container.
This method does not take ownership of signer object. Container holds ownership of Signature object.
signer | signer implementation. |
Exception | exception is thrown if signing the container failed. |
References addContainerImplementation(), addDataFile(), Container(), create(), createPtr(), mediaType(), open(), and openPtr().
|
pure virtual |
Returns list of all container's signatures.
Container holds ownership of signature objects
Referenced by newSignatureId().