libcryptosec
Pkcs7Exception.h
Go to the documentation of this file.
1 #ifndef PKCS7EXCEPTION_H_
2 #define PKCS7EXCEPTION_H_
3 
5 
7 {
8 public:
9  enum ErrorCode
10  {
20  };
21  Pkcs7Exception(std::string where)
22  {
23  this->where = where;
25  }
27  {
28  this->where = where;
29  this->errorCode = errorCode;
30  }
31  Pkcs7Exception(Pkcs7Exception::ErrorCode errorCode, std::string where, bool opensslDetails)
32  {
33  this->where = where;
34  this->errorCode = errorCode;
35  if (opensslDetails)
36  {
38  }
39  else
40  {
41  this->details = "";
42  }
43  }
44  virtual ~Pkcs7Exception() throw () {}
45  virtual std::string getMessage() const
46  {
48  }
49  virtual std::string toString() const
50  {
51  std::string ret;
53  {
54  ret = "Pkcs7Exception. Called by: " + this->where + ".";
55  }
56  else
57  {
58  ret = "Pkcs7Exception: " + Pkcs7Exception::errorCode2Message(this->errorCode) + ". Called by: " + this->where + ".";
59  }
60  if (this->details != "")
61  {
62  ret += " More details:\n" + this->details + ".";
63  }
64  return ret;
65  }
67  {
68  return this->errorCode;
69  }
71  {
72  std::string ret;
73  switch (errorCode)
74  {
76  ret = "Unknown error";
77  break;
79  ret = "Invalid pkcs7 structure";
80  break;
82  ret = "Invalid type";
83  break;
85  ret = "Decrypting";
86  break;
88  ret = "Internal error";
89  break;
91  ret = "Invalid symmetric cipher";
92  break;
94  ret = "Invalid certificate";
95  break;
97  ret = "Adding signer";
98  break;
100  ret = "Adding certificate";
101  break;
102 // case Pkcs7Exception:::
103 // ret = "";
104 // break;
105 // case Pkcs7Exception:::
106 // ret = "";
107 // break;
108  }
109  return ret;
110  }
111 
112 protected:
114 };
115 
116 #endif /*PKCS7EXCEPTION_H_*/
virtual std::string toString() const
Definition: Pkcs7Exception.h:49
Definition: Pkcs7Exception.h:15
Definition: Pkcs7Exception.h:16
virtual Pkcs7Exception::ErrorCode getErrorCode()
Definition: Pkcs7Exception.h:66
Definition: Pkcs7Exception.h:14
Pkcs7Exception(Pkcs7Exception::ErrorCode errorCode, std::string where)
Definition: Pkcs7Exception.h:26
virtual std::string getMessage() const
Definition: Pkcs7Exception.h:45
Definition: Pkcs7Exception.h:11
Definition: Pkcs7Exception.h:13
static std::string errorCode2Message(Pkcs7Exception::ErrorCode errorCode)
Definition: Pkcs7Exception.h:70
Pkcs7Exception(Pkcs7Exception::ErrorCode errorCode, std::string where, bool opensslDetails)
Definition: Pkcs7Exception.h:31
Definition: Pkcs7Exception.h:17
Definition: LibCryptoSecException.h:8
std::string where
Definition: LibCryptoSecException.h:23
std::string details
Definition: LibCryptoSecException.h:24
Definition: Pkcs7Exception.h:6
virtual ~Pkcs7Exception()
Definition: Pkcs7Exception.h:44
Definition: Pkcs7Exception.h:12
Definition: Pkcs7Exception.h:18
Pkcs7Exception(std::string where)
Definition: Pkcs7Exception.h:21
Pkcs7Exception::ErrorCode errorCode
Definition: Pkcs7Exception.h:113
Definition: Pkcs7Exception.h:19
static std::string getErrors()
Definition: OpenSSLErrorHandler.cpp:56
ErrorCode
Definition: Pkcs7Exception.h:9