libdigidocpp
PKCS11Signer.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 "Signer.h"
23 #include "../cert/X509Cert.h"
24 
25 namespace digidoc
26 {
27 
44  class PKCS11SignerPrivate;
46  {
47 
48  public:
49  struct PKCS11Token { std::string label, manufacturer, model, serialNr; };
50  struct PKCS11Cert { PKCS11Token token; std::string label; X509Cert cert; };
51 
52  PKCS11Signer() throw(SignException);
53  PKCS11Signer(const std::string& driver) throw(SignException);
54  virtual ~PKCS11Signer();
55  X509* getCert() const throw(SignException);
56  void sign(const Digest& digest, Signature& signature) throw(SignException);
57 
58  void loadDriver() throw(SignException);
59  void loadDriver(const std::string& driver) throw(SignException);
60  void unloadDriver();
61 
73  virtual std::string getPin(const PKCS11Cert &certificate) throw(SignException) = 0;
74 
75  protected:
76 
87  virtual PKCS11Cert selectSigningCertificate(const std::vector<PKCS11Cert> &certificates) const throw(SignException) = 0;
88 
89  private:
91  };
92 }