libdigidocpp
SignatureBES.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 "Signature.h"
23 
24 #include "BDoc.h"
25 
26 namespace digidoc
27 {
29  {
30 
31  public:
32  SignatureBES(unsigned int id, const BDoc &bdoc);
33  SignatureBES(const std::string& path, const BDoc &bdoc) throw(SignatureException);
34  virtual ~SignatureBES();
35  virtual std::string getMediaType() const;
36  std::vector<std::string> referenceDigestMethods() const;
37  virtual void validateOffline() const throw(SignatureException);
38  virtual CertStatus validateOnline() const throw(SignatureException);
39 
40  static const std::string MEDIA_TYPE;
41 
42  protected:
43  std::vector<unsigned char> prepareSignedInfo(Signer *singer) throw(SignatureException, SignException);
44  virtual void sign(Signer* signer) throw(SignatureException, SignException);
45 
46  const BDoc &bdoc;
47 
48  private:
49  SignatureBES& operator=( SignatureBES const& that ); // undefine default
50 
51  // offline checks
52  void checkSignature() const throw(SignatureException);
53  void checkSignedInfo() const throw(SignatureException);
54  void checkSignatureMethod() const throw(SignatureException);
55  void checkReferences() const throw(SignatureException);
56  void checkSignatureValue() const throw(SignatureException);
57  void checkSigningCertificate() const throw(SignatureException);
58  void checkKeyInfo() const throw(SignatureException); // RSAKeyValue and X509Certificate
59  void checkQualifyingProperties() const throw(SignatureException);
60  void checkSignedSignatureProperties() const throw(SignatureException);
61 
62  bool isReferenceToSigProps(const digidoc::dsig::ReferenceType& refType) const throw(SignatureException);
63  void checkReferenceToSigProps(const digidoc::dsig::ReferenceType& refType) const throw(SignatureException);
64  void checkReferencesToDocs(dsig::SignedInfoType::ReferenceSequence& refSeq) const throw(SignatureException);
65  void checkDocumentRefDigest(Document& doc, const std::string& documentFileName, const dsig::ReferenceType& refType) const throw(SignatureException);
66 
67  };
68 }