libdigidocpp
BDoc.h
Go to the documentation of this file.
1 /*
2  * libdigidocpp
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  *
18  */
19 
20 #pragma once
21 
22 #include "ADoc.h"
23 
24 namespace digidoc
25 {
26  class BDocPrivate;
27  class Document;
28  class ISerialize;
29 
43  class EXP_DIGIDOC BDoc: public ADoc
44  {
45 
46  public:
47  enum Type { BES, TM };
48 
49  BDoc();
50  BDoc(const std::string &path) throw(IOException, BDocException);
51  BDoc(std::auto_ptr<ISerialize> serializer) throw(IOException, BDocException);
52  virtual ~BDoc();
53  void save() throw(IOException, BDocException);
54  void saveTo(const std::string &path) throw(IOException, BDocException);
55  void addDocument(const Document& document) throw(BDocException);
56  Document getDocument(unsigned int id) const throw(BDocException);
57  void removeDocument(unsigned int id) throw(BDocException);
58  unsigned int documentCount() const;
59  DocumentType documentType() const;
60  void addSignature(const std::vector<unsigned char> &signature) throw(BDocException);
61  void addSignature(const std::vector<unsigned char> &signature, Type profile = TM) throw(BDocException);
62  const Signature* getSignature(unsigned int id) const throw(BDocException);
63  void removeSignature(unsigned int id) throw(BDocException);
64  unsigned int signatureCount() const;
65  void sign(Signer* signer) throw(BDocException);
66  void sign(Signer* signer, Type profile = TM) throw(BDocException);
67  std::vector<unsigned char> getFileDigest( unsigned int ) throw(BDocException) { return std::vector<unsigned char>(); }
68 
69  private:
70  void readFrom(std::auto_ptr<ISerialize> serializer) throw(IOException, BDocException);
71  void addSignature(Signature* signature) throw(BDocException);
72  void setVersion(const std::string& version);
73  std::string getMimeType() const;
74  std::string createMimetype() throw(IOException);
75  std::string createManifest() throw(IOException);
76  void readMimetype(const std::string &path) throw(IOException, BDocException);
77  void parseManifestAndLoadFiles(const std::string &path) throw(IOException, BDocException);
78 
80  };
81 }