libdigidocpp
digidoc::DDoc Class Reference

#include <DDoc.h>

Inheritance diagram for digidoc::DDoc:
Inheritance graph
Collaboration diagram for digidoc::DDoc:
Collaboration graph

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 SignaturegetSignature (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)
- Public Member Functions inherited from digidoc::ADoc
virtual ~ADoc ()
unsigned int newSignatureId () const

Private Member Functions

void loadFile ()

Private Attributes

DDocPrivated

Additional Inherited Members

- Public Types inherited from digidoc::ADoc
enum  DocumentType { UnknownType = 0, BDocType = 1, DDocType = 2 }

Detailed Description

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.

Definition at line 67 of file DDoc.h.

Constructor & Destructor Documentation

DDoc::DDoc ( )
digidoc::DDoc::DDoc ( const std::string &  path) throw (IOException, BDocException)

Opens DDOC container from a file

Definition at line 497 of file DDoc.cpp.

DDoc::~DDoc ( )
virtual

Releases resources.

Definition at line 492 of file DDoc.cpp.

References d.

Member Function Documentation

void DDoc::addDocument ( const Document document) throw (BDocException)
virtual

Adds document to the container. Documents can be removed from container only after all signatures are removed.

Parameters
documenta document, which is added to the container.
Exceptions
BDocExceptionexception 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.

Definition at line 558 of file DDoc.cpp.

void DDoc::addSignature ( const std::vector< unsigned char > &  signature) throw (BDocException)
virtual

Adds signature to the container.

Parameters
signaturesignature, which is added to the container.
Exceptions
BDocExceptionthrows 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().

Here is the call graph for this function:

unsigned int DDoc::documentCount ( ) const
virtual
Returns
returns number of documents in container.

Implements digidoc::ADoc.

Definition at line 622 of file DDoc.cpp.

References d, and digidoc::DDocPrivate::documents.

ADoc::DocumentType DDoc::documentType ( ) const
virtual
Returns
returns container type.

Reimplemented from digidoc::ADoc.

Definition at line 627 of file DDoc.cpp.

References digidoc::ADoc::DDocType.

Document DDoc::getDocument ( unsigned int  id) const throw (BDocException)
virtual

Returns document referenced by document id.

Parameters
iddocument id.
Returns
returns document referenced by document id.
Exceptions
BDocExceptionthrows exception if the document id is incorrect.

Implements digidoc::ADoc.

Definition at line 636 of file DDoc.cpp.

std::vector< unsigned char > DDoc::getFileDigest ( unsigned int  id) throw (BDocException)
virtual

Returns file digest format

Implements digidoc::ADoc.

Definition at line 868 of file DDoc.cpp.

const Signature * DDoc::getSignature ( unsigned int  id) const throw (BDocException)
virtual

Returns signature referenced by signature id.

Parameters
idsignature id.
Returns
returns signature referenced by signature id.
Exceptions
BDocExceptionthrows exception if the signature id is incorrect.

Implements digidoc::ADoc.

Definition at line 658 of file DDoc.cpp.

void DDoc::removeDocument ( unsigned int  id) throw (BDocException)
virtual

Removes document from container by document id. Documents can be removed from container only after all signatures are removed.

Parameters
iddocument's id, which will be removed.
Exceptions
BDocExceptionthrows exception if the document id is incorrect or there are one or more signatures.

Implements digidoc::ADoc.

Definition at line 681 of file DDoc.cpp.

void DDoc::removeSignature ( unsigned int  id) throw (BDocException)
virtual

Removes signature from container by signature id.

Parameters
idsignature's id, which will be removed.
Exceptions
BDocExceptionthrows exception if the signature id is incorrect.

Implements digidoc::ADoc.

Definition at line 710 of file DDoc.cpp.

void DDoc::save ( ) throw (IOException, BDocException)
virtual

Saves the container using the serializer implementation provided in readFrom() method.

Exceptions
IOExceptionis thrown if there was a failure saving BDOC container. For example added document does not exist.
BDocExceptionis 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().

Here is the call graph for this function:

void DDoc::saveTo ( const std::string &  path) throw (IOException, BDocException)
virtual

Saves the container using the serializer implementation provided.

Parameters
pathfilepath, used to save data to BDOC container.
Exceptions
IOExceptionis thrown if there was a failure saving BDOC container. For example added document does not exist.
BDocExceptionis thrown if BDOC class is not correctly initialized.
See Also
save()

Implements digidoc::ADoc.

Definition at line 751 of file DDoc.cpp.

unsigned int DDoc::signatureCount ( ) const
virtual
Returns
returns number of signatures in container.

Implements digidoc::ADoc.

Definition at line 863 of file DDoc.cpp.

References d, and digidoc::DDocPrivate::signatures.

Member Data Documentation

DDocPrivate* digidoc::DDoc::d
private

Definition at line 89 of file DDoc.h.

Referenced by DDoc(), documentCount(), loadFile(), save(), signatureCount(), and ~DDoc().


The documentation for this class was generated from the following files: