ResponseStatus.cpp

Go to the documentation of this file.
00001 
00010 #include "ResponseStatus.h"
00011 #include "components.h"
00012 #include "ToolkitUtils.h"
00013 #include "Buffer.h"
00014 #include "PKIFSCVPErrors.h"
00015 #include "SCVPException.h"
00016 #include "ASN1Helper.h"
00017 #include "SCVP.h"
00018 
00019 using namespace std;
00020 
00022 
00023 struct CPKIFResponseStatusImpl 
00024 {
00025     string m_errorMessage;
00026     int m_statusCode;
00027 };
00028 
00030 
00039 CPKIFResponseStatus::CPKIFResponseStatus() :m_impl(new CPKIFResponseStatusImpl)
00040 {
00041     LOG_STRING_DEBUG("CPKIFResponseStatus::CPKIFResponseStatus()", TOOLKIT_SCVP_ASN, 0, this);
00042 
00043     m_impl->m_statusCode = 0;
00044     m_impl->m_errorMessage = "";
00045 }
00046 
00054 CPKIFResponseStatus::CPKIFResponseStatus(
00056     std::string errorMessage, 
00058     int statusCode) :m_impl(new CPKIFResponseStatusImpl)
00059 {
00060     LOG_STRING_DEBUG("CPKIFResponseStatus::CPKIFResponseStatus()", TOOLKIT_SCVP_ASN, 0, this);
00061 
00062     m_impl->m_errorMessage = errorMessage;
00063     m_impl->m_statusCode = statusCode;
00064 }
00075 CPKIFResponseStatus::CPKIFResponseStatus(
00077     const CPKIFBufferPtr& respStatus)
00078   :m_impl (new CPKIFResponseStatusImpl)
00079 {
00080     if(respStatus == (CPKIFBuffer*)NULL || 0 == respStatus->GetLength())
00081     {
00082         throw CPKIFSCVPException(TOOLKIT_SCVP_ASN, COMMON_INVALID_INPUT);
00083     }
00084 
00085     CACASNWRAPPER_CREATE(ResponseStatus, objPDU);
00086     objPDU.Decode(respStatus->GetBuffer(), respStatus->GetLength());
00087 
00088     if(0 < objPDU->m.errorMessagePresent)
00089     {
00090         m_impl->m_errorMessage = objPDU->errorMessage;
00091     }
00092 
00093     if(0 < objPDU->m.statusCodePresent)
00094     {
00095         m_impl->m_statusCode = objPDU->statusCode;
00096     }
00097     else
00098         m_impl->m_statusCode = 0;
00099 
00100 
00101 }
00109 CPKIFResponseStatus::~CPKIFResponseStatus()
00110 {
00111     LOG_STRING_DEBUG("CPKIFResponseStatus::~CPKIFResponseStatus()", TOOLKIT_SCVP_ASN, 0, this);
00112 
00113     if (m_impl) {
00114       delete m_impl;
00115     }   
00116 }
00124 void CPKIFResponseStatus::SetErrorMessage(
00126     string errorMessage)
00127 {
00128     m_impl->m_errorMessage = errorMessage;
00129 }
00137 const string CPKIFResponseStatus::GetErrorMessage() const
00138 {
00139     return m_impl->m_errorMessage;
00140 }
00141 
00182 void CPKIFResponseStatus::SetStatusCode(
00184     int statusCode)
00185 {
00186     m_impl->m_statusCode = statusCode;
00187 }
00228 const int CPKIFResponseStatus::GetStatusCode() const
00229 {
00230     return m_impl->m_statusCode;
00231 }
00232 

Generated on Mon Nov 15 11:15:55 2010 for PublicKeyInfrastructureFramework(PKIF) by  doxygen 1.5.6