libdigidocpp
|
#include <DDoc.h>
Public Member Functions | |
DDoc () | |
DDoc (const std::string &path) throw (IOException, BDocException) | |
virtual | ~DDoc () |
void | save () throw (IOException, BDocException) |
void | saveTo (const std::string &path) throw (IOException, BDocException) |
void | addDocument (const Document &document) throw (BDocException) |
Document | getDocument (unsigned int id) const throw (BDocException) |
void | removeDocument (unsigned int id) throw (BDocException) |
unsigned int | documentCount () const |
DocumentType | documentType () const |
void | addSignature (const std::vector< unsigned char > &signature) throw (BDocException) |
const Signature * | getSignature (unsigned int id) const throw (BDocException) |
void | removeSignature (unsigned int id) throw (BDocException) |
unsigned int | signatureCount () const |
void | sign (Signer *signer) throw (BDocException) |
std::vector< unsigned char > | getFileDigest (unsigned int id) throw (BDocException) |
![]() | |
virtual | ~ADoc () |
unsigned int | newSignatureId () const |
Private Member Functions | |
void | loadFile () |
Private Attributes | |
DDocPrivate * | d |
Additional Inherited Members | |
![]() | |
enum | DocumentType { UnknownType = 0, BDocType = 1, DDocType = 2 } |
Implements the DDOC specification of the signed digital document container. Container can contain several files and all these files can be signed using signing certificates. Container can only be signed if it contains documents. Documents can be added and removed from container only if the container is not signed. To add or remove documents from signed container remove all the signatures before modifying documents list in container.
DDoc::DDoc | ( | ) |
Initialize DDOC container.
Definition at line 480 of file DDoc.cpp.
References d, digidoc::DDocPrivate::doc, digidoc::DDocLibrary::f_SignedDoc_new, digidoc::DDocPrivate::lib, and digidoc::DDocLibrary::ready.
digidoc::DDoc::DDoc | ( | const std::string & | path | ) | throw (IOException, BDocException) |
|
virtual |
Adds document to the container. Documents can be removed from container only after all signatures are removed.
document | a document, which is added to the container. |
BDocException | exception is thrown if the document path is incorrect or document with same file name already exists. Also no document can be added if the container already has one or more signatures. |
Implements digidoc::ADoc.
|
virtual |
Adds signature to the container.
signature | signature, which is added to the container. |
BDocException | throws exception if there are no documents in container. |
Implements digidoc::ADoc.
Definition at line 580 of file DDoc.cpp.
References digidoc::util::File::encodeName(), i, and digidoc::util::File::tempFileName().
|
virtual |
Implements digidoc::ADoc.
Definition at line 622 of file DDoc.cpp.
References d, and digidoc::DDocPrivate::documents.
|
virtual |
Reimplemented from digidoc::ADoc.
Definition at line 627 of file DDoc.cpp.
References digidoc::ADoc::DDocType.
|
virtual |
Returns document referenced by document id.
id | document id. |
BDocException | throws exception if the document id is incorrect. |
Implements digidoc::ADoc.
|
virtual |
|
virtual |
Returns signature referenced by signature id.
id | signature id. |
BDocException | throws exception if the signature id is incorrect. |
Implements digidoc::ADoc.
|
private |
Parses file data
Definition at line 510 of file DDoc.cpp.
References digidoc::util::File::createTempDirectory(), d, digidoc::DDocPrivate::doc, digidoc::DDocPrivate::documents, digidoc::DDocLibrary::f_ddocSaxExtractDataFile, digidoc::DDocLibrary::f_ddocSaxReadSignedDocFromFile, digidoc::DDocLibrary::f_getCountOfDataFiles, digidoc::DDocLibrary::f_getDataFile, digidoc::DDocLibrary::f_SignedDoc_free, digidoc::DDocPrivate::filename, digidoc::Document::getFilePath(), i, digidoc::DDocPrivate::lib, digidoc::DDocPrivate::loadSignatures(), digidoc::util::File::path(), and digidoc::DDocPrivate::throwCodeError().
|
virtual |
Removes document from container by document id. Documents can be removed from container only after all signatures are removed.
id | document's id, which will be removed. |
BDocException | throws exception if the document id is incorrect or there are one or more signatures. |
Implements digidoc::ADoc.
|
virtual |
Removes signature from container by signature id.
id | signature's id, which will be removed. |
BDocException | throws exception if the signature id is incorrect. |
Implements digidoc::ADoc.
|
virtual |
Saves the container using the serializer
implementation provided in readFrom()
method.
IOException | is thrown if there was a failure saving BDOC container. For example added document does not exist. |
BDocException | is thrown if BDoc class is not correctly initialized. |
Implements digidoc::ADoc.
Definition at line 735 of file DDoc.cpp.
References d, digidoc::DDocPrivate::doc, digidoc::DDocLibrary::f_createSignedDoc, digidoc::DDocPrivate::filename, digidoc::DDocPrivate::lib, digidoc::DDocPrivate::throwCodeError(), and digidoc::DDocPrivate::throwDocOpenError().
|
virtual |
Saves the container using the serializer
implementation provided.
path | filepath, used to save data to BDOC container. |
IOException | is thrown if there was a failure saving BDOC container. For example added document does not exist. |
BDocException | is thrown if BDOC class is not correctly initialized. |
Implements digidoc::ADoc.
|
virtual |
Signs all documents in container.
signer | signer implementation. |
profile | signature profile (e.g. BES, TM). |
BDocException | exception is throws if signing the BDCO container failed. |
Implements digidoc::ADoc.
Definition at line 766 of file DDoc.cpp.
References digidoc::SignatureProductionPlace::city, digidoc::SignatureProductionPlace::countryName, e, digidoc::Conf::getInstance(), digidoc::X509Cert::getPaddingSize(), digidoc::Conf::getPKCS12Cert(), digidoc::Conf::getPKCS12Disable(), digidoc::Conf::getPKCS12Pass(), digidoc::Conf::getProxyHost(), digidoc::Conf::getProxyPass(), digidoc::Conf::getProxyPort(), digidoc::Conf::getProxyUser(), i, int(), digidoc::Signer::Signature::length, digidoc::SignatureProductionPlace::postalCode, digidoc::Signer::Signature::signature, and digidoc::SignatureProductionPlace::stateOrProvince.
|
virtual |
Implements digidoc::ADoc.
Definition at line 863 of file DDoc.cpp.
References d, and digidoc::DDocPrivate::signatures.
|
private |
Definition at line 89 of file DDoc.h.
Referenced by DDoc(), documentCount(), loadFile(), save(), signatureCount(), and ~DDoc().