libcryptosec
SmartcardModuleException.h
Go to the documentation of this file.
1 #ifndef SMARTCARDMODULEEXCEPTION_H_
2 #define SMARTCARDMODULEEXCEPTION_H_
3 
5 
7 {
8 public:
9  enum ErrorCode
10  {
11  UNKNOWN = 1,
17  INVALID_PIN = 0x000000A0,
19  BLOCKED_PIN = 0x000000A4,
21  };
23  {
24  this->where = where;
26  this->details = "";
27  }
29  {
30  this->where = where;
31  this->errorCode = errorCode;
32  this->details = "";
33  }
35  {
36  this->where = where;
37  this->errorCode = errorCode;
38  if (opensslDetails)
39  {
41  }
42  else
43  {
44  this->details = "";
45  }
46  }
47  virtual ~SmartcardModuleException() throw () {}
48  virtual std::string getMessage() const
49  {
51  }
52  virtual std::string toString() const
53  {
54  std::string ret;
56  {
57  ret = "SmartcardModuleException. Called by: " + this->where + ".";
58  }
59  else
60  {
61  ret = "SmartcardModuleException: " + SmartcardModuleException::errorCode2Message(this->errorCode) + ". Called by: " + this->where + ".";
62  }
63  if (this->details != "")
64  {
65  ret += " More details:\n" + this->details + ".";
66  }
67  return ret;
68  }
70  {
71  return this->errorCode;
72  }
74  {
75  std::string ret;
76  switch (errorCode)
77  {
79  ret = "Unknown error";
80  break;
82  ret = "Enumerating certificates";
83  break;
85  ret = "Enumerating private keys";
86  break;
88  ret = "Decrypting data";
89  break;
91  ret = "Smartcard not available";
92  break;
94  ret = "Smartcard reader not available";
95  break;
97  ret = "Invalid PIN";
98  break;
100  ret = "Invalid PKCS11 module";
101  break;
103  ret = "Blocked PIN";
104  break;
106  ret = "ID not found";
107  break;
108 // case SmartcardModuleException:::
109 // ret = "";
110 // break;
111  }
112  return ret;
113  }
114 protected:
116 };
117 
118 #endif /*SMARTCARDMODULEEXCEPTION_H_*/
Definition: SmartcardModuleException.h:14
SmartcardModuleException::ErrorCode errorCode
Definition: SmartcardModuleException.h:115
Definition: SmartcardModuleException.h:12
SmartcardModuleException(SmartcardModuleException::ErrorCode errorCode, std::string where, bool opensslDetails)
Definition: SmartcardModuleException.h:34
ErrorCode
Definition: SmartcardModuleException.h:9
virtual SmartcardModuleException::ErrorCode getErrorCode()
Definition: SmartcardModuleException.h:69
Definition: SmartcardModuleException.h:17
virtual std::string getMessage() const
Definition: SmartcardModuleException.h:48
Definition: SmartcardModuleException.h:13
Definition: SmartcardModuleException.h:11
Definition: SmartcardModuleException.h:16
virtual std::string toString() const
Definition: SmartcardModuleException.h:52
Definition: LibCryptoSecException.h:8
std::string where
Definition: LibCryptoSecException.h:23
std::string details
Definition: LibCryptoSecException.h:24
Definition: SmartcardModuleException.h:6
static std::string errorCode2Message(SmartcardModuleException::ErrorCode errorCode)
Definition: SmartcardModuleException.h:73
Definition: SmartcardModuleException.h:15
virtual ~SmartcardModuleException()
Definition: SmartcardModuleException.h:47
static std::string getErrors()
Definition: OpenSSLErrorHandler.cpp:56
SmartcardModuleException(std::string where)
Definition: SmartcardModuleException.h:22
SmartcardModuleException(SmartcardModuleException::ErrorCode errorCode, std::string where)
Definition: SmartcardModuleException.h:28
Definition: SmartcardModuleException.h:18
Definition: SmartcardModuleException.h:19
Definition: SmartcardModuleException.h:20