libdigidocpp
DDoc.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 #include "Signature.h"
24 
25 namespace digidoc
26 {
27 
28 class DDocPrivate;
29 class SignatureDDOCPrivate;
30 
35 {
36 public:
37  virtual ~SignatureDDOC();
38 
39  virtual std::string getMediaType() const;
40  std::vector<unsigned char> getNonce() const;
41  X509Cert getOCSPCertificate() const;
42  std::string getProducedAt() const;
43  std::string getResponderID() const;
44  void getRevocationOCSPRef(std::vector<unsigned char>& data, std::string& digestMethodUri) const throw(SignatureException);
45  virtual void validateOffline() const throw(SignatureException);
46  virtual CertStatus validateOnline() const throw(SignatureException);
47 
48 protected:
49  virtual void sign(Signer* signer) throw(SignatureException, SignException);
50 
51 private:
52  SignatureDDOC( int id, DDocPrivate *doc );
53 
55 
56  friend class DDocPrivate;
57 };
58 
67 class EXP_DIGIDOC DDoc: public ADoc
68 {
69 public:
70  DDoc();
71  DDoc(const std::string &path) throw(IOException, BDocException);
72  virtual ~DDoc();
73 
74  void save() throw(IOException, BDocException);
75  void saveTo(const std::string &path) throw(IOException, BDocException);
76  void addDocument(const Document& document) throw(BDocException);
77  Document getDocument(unsigned int id) const throw(BDocException);
78  void removeDocument(unsigned int id) throw(BDocException);
79  unsigned int documentCount() const;
80  DocumentType documentType() const;
81  void addSignature(const std::vector<unsigned char> &signature) throw(BDocException);
82  const Signature* getSignature(unsigned int id) const throw(BDocException);
83  void removeSignature(unsigned int id) throw(BDocException);
84  unsigned int signatureCount() const;
85  void sign(Signer* signer) throw(BDocException);
86  std::vector<unsigned char> getFileDigest( unsigned int id ) throw(BDocException);
87 
88 private:
90  void loadFile();
91 };
92 
93 }