PKIStatusInfo.cpp
Go to the documentation of this file.00001
00009 #include "ASN1Helper.h"
00010 #include "Buffer.h"
00011 #include "PKIStatusInfo.h"
00012 #include "PKIXTSP.h"
00013 #include "ToolkitUtils.h"
00014 #include "components.h"
00015
00016 #include <iterator>
00018
00019 struct CPKIFPKIStatusInfoImpl {
00020 PKIStatus m_status;
00021 CPKIFStringArray m_statusStrings;
00022 std::bitset<8> m_failInfo;
00023 };
00024
00026
00034 CPKIFPKIStatusInfo::CPKIFPKIStatusInfo()
00035 :m_impl (new CPKIFPKIStatusInfoImpl)
00036 {
00037 LOG_STRING_DEBUG("CPKIFPKIStatusInfo::CPKIFPKIStatusInfo()", TOOLKIT_TSP_ASN, 0, this);
00038
00039 m_impl->m_status = REJECTION;
00040 }
00051 CPKIFPKIStatusInfo::CPKIFPKIStatusInfo(
00054
00055 const CPKIFBufferPtr& psiBuf)
00056 :m_impl (new CPKIFPKIStatusInfoImpl)
00057 {
00058 LOG_STRING_DEBUG("CPKIFPKIStatusInfo::CPKIFPKIStatusInfo(PKIFTSPPKIStatusInfo& psi)", TOOLKIT_TSP_ASN, 0, this);
00059
00060 CACASNWRAPPER_CREATE(PKIFTSPPKIStatusInfo, PSIWrapper);
00061 PSIWrapper.Decode(psiBuf->GetBuffer(), psiBuf->GetLength());
00062
00063 m_impl->m_status = (PKIStatus)PSIWrapper->status;
00064
00065 if(PSIWrapper->m.statusStringPresent && PSIWrapper->statusString.count > 0)
00066 {
00067 DListNode* cur = PSIWrapper->statusString.head;
00068 while(NULL != cur)
00069 {
00070 ASN1UTF8String* s = (ASN1UTF8String*)cur->data;
00071 CPKIFStringPtr tmp(new std::string((char*)*s));
00072 m_impl->m_statusStrings.push_back(tmp);
00073 cur = cur->next;
00074 }
00075 }
00076
00077 if(PSIWrapper->m.failInfoPresent)
00078 {
00079 if( PSIWrapper->failInfo.data[BytXPKIFTSPbadAlg] & BitMPKIFTSPbadAlg )
00080 {
00081 m_impl->m_failInfo.set(BADALG);
00082 }
00083 else if( PSIWrapper->failInfo.data[BytXPKIFTSPbadRequest] & BitMPKIFTSPbadRequest )
00084 {
00085 m_impl->m_failInfo.set(BADREQUEST);
00086 }
00087 else if( PSIWrapper->failInfo.data[BytXPKIFTSPbadDataFormat] & BitMPKIFTSPbadDataFormat )
00088 {
00089 m_impl->m_failInfo.set(BADDATAFORMAT);
00090 }
00091 else if( PSIWrapper->failInfo.data[BytXPKIFTSPtimeNotAvailable] & BitMPKIFTSPtimeNotAvailable )
00092 {
00093 m_impl->m_failInfo.set(TIMENOTAVAILABLE);
00094 }
00095 else if( PSIWrapper->failInfo.data[BytXPKIFTSPunacceptedPolicy] & BitMPKIFTSPunacceptedPolicy )
00096 {
00097 m_impl->m_failInfo.set(UNACCEPTEDPOLICY);
00098 }
00099 else if( PSIWrapper->failInfo.data[BytXPKIFTSPunacceptedExtension] & BitMPKIFTSPunacceptedExtension )
00100 {
00101 m_impl->m_failInfo.set(UNACCEPTEDEXTENSION);
00102 }
00103 else if( PSIWrapper->failInfo.data[BytXPKIFTSPaddInfoNotAvailable] & BitMPKIFTSPaddInfoNotAvailable )
00104 {
00105 m_impl->m_failInfo.set(ADDINFONOTAVAILABLE);
00106 }
00107 else if( PSIWrapper->failInfo.data[BytXPKIFTSPsystemFailure] & BitMPKIFTSPsystemFailure )
00108 {
00109 m_impl->m_failInfo.set(SYSTEMFAILURE);
00110 }
00111 }
00112 }
00120 CPKIFPKIStatusInfo::~CPKIFPKIStatusInfo()
00121 {
00122 LOG_STRING_DEBUG("CPKIFPKIStatusInfo::~CPKIFPKIStatusInfo()", TOOLKIT_TSP_ASN, 0, this);
00123
00124 if (m_impl) {
00125 delete m_impl;
00126 }
00127 }
00135 void CPKIFPKIStatusInfo::SetStatus(
00137 PKIStatus status)
00138 {
00139 m_impl->m_status = status;
00140 }
00148 PKIStatus CPKIFPKIStatusInfo::GetStatus() const
00149 {
00150 return m_impl->m_status;
00151 }
00159 void CPKIFPKIStatusInfo::SetFailInfo(
00161 std::bitset<8>& failInfo)
00162 {
00163 m_impl->m_failInfo.reset();
00164 if(failInfo[BADALG])
00165 m_impl->m_failInfo.set(BADALG);
00166 if(failInfo[BADREQUEST])
00167 m_impl->m_failInfo.set(BADREQUEST);
00168 if(failInfo[BADDATAFORMAT])
00169 m_impl->m_failInfo.set(BADDATAFORMAT);
00170 if(failInfo[TIMENOTAVAILABLE])
00171 m_impl->m_failInfo.set(TIMENOTAVAILABLE);
00172 if(failInfo[UNACCEPTEDPOLICY])
00173 m_impl->m_failInfo.set(UNACCEPTEDPOLICY);
00174 if(failInfo[UNACCEPTEDEXTENSION])
00175 m_impl->m_failInfo.set(UNACCEPTEDEXTENSION);
00176 if(failInfo[ADDINFONOTAVAILABLE])
00177 m_impl->m_failInfo.set(ADDINFONOTAVAILABLE);
00178 if(failInfo[SYSTEMFAILURE])
00179 m_impl->m_failInfo.set(SYSTEMFAILURE);
00180 }
00188 void CPKIFPKIStatusInfo::GetFailInfo(
00190 std::bitset<8>& failInfo) const
00191 {
00192 failInfo.reset();
00193 if(m_impl->m_failInfo[BADALG])
00194 failInfo.set(BADALG);
00195 if(m_impl->m_failInfo[BADREQUEST])
00196 failInfo.set(BADREQUEST);
00197 if(m_impl->m_failInfo[BADDATAFORMAT])
00198 failInfo.set(BADDATAFORMAT);
00199 if(m_impl->m_failInfo[TIMENOTAVAILABLE])
00200 failInfo.set(TIMENOTAVAILABLE);
00201 if(m_impl->m_failInfo[UNACCEPTEDPOLICY])
00202 failInfo.set(UNACCEPTEDPOLICY);
00203 if(m_impl->m_failInfo[UNACCEPTEDEXTENSION])
00204 failInfo.set(UNACCEPTEDEXTENSION);
00205 if(m_impl->m_failInfo[ADDINFONOTAVAILABLE])
00206 failInfo.set(ADDINFONOTAVAILABLE);
00207 if(m_impl->m_failInfo[SYSTEMFAILURE])
00208 failInfo.set(SYSTEMFAILURE);
00209 }
00217 void CPKIFPKIStatusInfo::AddStatusString(
00219 CPKIFStringPtr& statusString)
00220 {
00221 m_impl->m_statusStrings.push_back(statusString);
00222 }
00230 void CPKIFPKIStatusInfo::GetStatusStrings(
00232 CPKIFStringArray& strings) const
00233 {
00234 copy(m_impl->m_statusStrings.begin(), m_impl->m_statusStrings.end(), back_inserter(strings));
00235 }