libdigidocpp
digidoc::WDoc Class Reference

#include <WDoc.h>

Inheritance diagram for digidoc::WDoc:
Inheritance graph
Collaboration diagram for digidoc::WDoc:
Collaboration graph

Public Member Functions

 WDoc ()
 WDoc (DocumentType type)
 WDoc (ADoc *doc)
 WDoc (const std::string &path) throw (IOException, BDocException)
 ~WDoc ()
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)
void setType (DocumentType type)
std::vector< unsigned char > getFileDigest (unsigned int id) throw (BDocException)
- Public Member Functions inherited from digidoc::ADoc
virtual ~ADoc ()
unsigned int newSignatureId () const

Private Attributes

ADocm_doc

Additional Inherited Members

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

Detailed Description

Implements wrapper 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 35 of file WDoc.h.

Constructor & Destructor Documentation

WDoc::WDoc ( )

Initialize container. Default type DDoc

Definition at line 33 of file WDoc.cpp.

References digidoc::ADoc::DDocType, and setType().

Here is the call graph for this function:

WDoc::WDoc ( DocumentType  type)

Initialize container.

Parameters
typespecify document type

Definition at line 39 of file WDoc.cpp.

References setType().

Here is the call graph for this function:

WDoc::WDoc ( ADoc doc)

Initialize container

Parameters
customdocument format

Definition at line 45 of file WDoc.cpp.

References m_doc.

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

Opens container from a file

Definition at line 59 of file WDoc.cpp.

WDoc::~WDoc ( )

Releases resources.

Definition at line 50 of file WDoc.cpp.

References m_doc.

Member Function Documentation

void WDoc::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 81 of file WDoc.cpp.

void WDoc::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 95 of file WDoc.cpp.

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

Implements digidoc::ADoc.

Definition at line 106 of file WDoc.cpp.

References digidoc::ADoc::documentCount(), and m_doc.

Here is the call graph for this function:

WDoc::DocumentType WDoc::documentType ( ) const
virtual
Returns
returns current document format

Reimplemented from digidoc::ADoc.

Definition at line 251 of file WDoc.cpp.

References digidoc::ADoc::documentType(), and m_doc.

Here is the call graph for this function:

Document WDoc::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 121 of file WDoc.cpp.

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

Returns file digest format

Implements digidoc::ADoc.

Definition at line 262 of file WDoc.cpp.

const Signature * WDoc::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 136 of file WDoc.cpp.

void WDoc::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 152 of file WDoc.cpp.

void WDoc::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 166 of file WDoc.cpp.

void WDoc::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 182 of file WDoc.cpp.

References m_doc, and digidoc::ADoc::save().

Here is the call graph for this function:

void WDoc::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 199 of file WDoc.cpp.

void WDoc::setType ( DocumentType  type)

Sets doucment type

Parameters
typedocument type

Definition at line 211 of file WDoc.cpp.

References digidoc::ADoc::BDocType, digidoc::ADoc::DDocType, and m_doc.

Referenced by WDoc().

Here is the caller graph for this function:

void WDoc::sign ( Signer signer) throw (BDocException)
virtual

Signs all documents in container.

Parameters
signersigner implementation.
profilesignature profile (e.g. BES, TM).
Exceptions
BDocExceptionexception is throws if signing the BDCO container failed.

Implements digidoc::ADoc.

Definition at line 229 of file WDoc.cpp.

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

Implements digidoc::ADoc.

Definition at line 240 of file WDoc.cpp.

References m_doc, and digidoc::ADoc::signatureCount().

Here is the call graph for this function:

Member Data Documentation

ADoc* digidoc::WDoc::m_doc
private

Definition at line 61 of file WDoc.h.

Referenced by documentCount(), documentType(), save(), setType(), signatureCount(), WDoc(), and ~WDoc().


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