libdigidocpp
OCSPException.cpp
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 #include <openssl/ocsp.h>
21 
22 #include "OCSPException.h"
23 
24 
32 digidoc::OCSPException::OCSPException(const std::string& file, int line, const std::string& msg, int responseStatusCode)
33  : Exception(file, line, msg)
34  , responseStatusCode(responseStatusCode)
35 {
36 }
37 
48 digidoc::OCSPException::OCSPException(const std::string& file, int line, const std::string& msg, const Exception& cause, int responseStatusCode)
49 : Exception(file, line, msg, cause)
50 , responseStatusCode(responseStatusCode)
51 {
52 }
53 
58 {
59  return responseStatusCode;
60 }
61 
66 {
67  return toResponseStatusMessage(responseStatusCode);
68 }
69 
76 std::string digidoc::OCSPException::toResponseStatusMessage(int responseStatusCode)
77 {
78  switch(responseStatusCode)
79  {
80  case OCSP_RESPONSE_STATUS_SUCCESSFUL: { return "Successful"; } break;
81  case OCSP_RESPONSE_STATUS_MALFORMEDREQUEST: { return "MalformedRequest"; } break;
82  case OCSP_RESPONSE_STATUS_INTERNALERROR: { return "InternalError"; } break;
83  case OCSP_RESPONSE_STATUS_TRYLATER: { return "TryLater"; } break;
84  case OCSP_RESPONSE_STATUS_SIGREQUIRED: { return "SigRequired"; } break;
85  case OCSP_RESPONSE_STATUS_UNAUTHORIZED: { return "Unauthorized"; } break;
86  }
87 
88  return "";
89 }