OCSPCertStatus.cpp
Go to the documentation of this file.00001
00010 #include "OCSPCertStatus.h"
00011
00012 #include "ASN1Helper.h"
00013 #include "OCSP.h"
00014
00015 #include "RevokedInfo.h"
00016 #include "ToolkitUtils.h"
00017
00018 #include "PKIFX509Extensions2.h"
00019
00020 using namespace std;
00021
00023 struct CPKIFOCSPCertStatusImpl
00024 {
00025 CPKIFRevokedInfoPtr m_revoked;
00026 CPKIFOCSPCertStatus::CertStatusChoice m_choice;
00027 };
00029
00037 CPKIFOCSPCertStatus::CPKIFOCSPCertStatus(void)
00038 :m_impl (new CPKIFOCSPCertStatusImpl)
00039 {
00040 LOG_STRING_DEBUG("CPKIFOCSPCertStatus::CPKIFOCSPCertStatus(void)", TOOLKIT_OCSP_ASN, 0, this);
00041
00042 m_impl->m_choice = CPKIFOCSPCertStatus::UNSET;
00043 }
00063 CPKIFOCSPCertStatus::CertStatusChoice CPKIFOCSPCertStatus::GetChoice() const
00064 {
00065 return m_impl->m_choice;
00066 }
00076 CPKIFOCSPCertStatus::CPKIFOCSPCertStatus(
00078 const CPKIFBufferPtr& cs)
00079 :m_impl (new CPKIFOCSPCertStatusImpl)
00080 {
00081 LOG_STRING_DEBUG("CPKIFOCSPCertStatus::CPKIFOCSPCertStatus(CertStatus& cs", TOOLKIT_OCSP_ASN, 0, this);
00082
00083 CACASNWRAPPER_CREATE(CertStatus, objPDU);
00084 objPDU.Decode(cs->GetBuffer(), cs->GetLength());
00085
00086 m_impl->m_choice = CPKIFOCSPCertStatus::UNSET;
00087
00088 switch(objPDU->t)
00089 {
00090 case 1:
00091 m_impl->m_choice = CPKIFOCSPCertStatus::GOOD;
00092 break;
00093 case 2:
00094 {
00095
00096 int reason = -1;
00097 if(objPDU->u.revoked->m.revocationReasonPresent)
00098 reason = objPDU->u.revoked->revocationReason;
00099 CPKIFRevokedInfoPtr tmpRI(new CPKIFRevokedInfo(objPDU->u.revoked->revocationTime, reason));
00100 m_impl->m_revoked = tmpRI;
00101 m_impl->m_choice = CPKIFOCSPCertStatus::REVOKED;
00102 }
00103 break;
00104 case 3:
00105 m_impl->m_choice = CPKIFOCSPCertStatus::UNKNOWN;
00106 break;
00107 }
00108 }
00116 CPKIFOCSPCertStatus::~CPKIFOCSPCertStatus(void)
00117 {
00118 LOG_STRING_DEBUG("CPKIFOCSPCertStatus::~CPKIFOCSPCertStatus(void)", TOOLKIT_OCSP_ASN, 0, this);
00119
00120 delete m_impl;
00121 m_impl = NULL;
00122 }
00130 void CPKIFOCSPCertStatus::SetRevokedInfo(
00132 CPKIFRevokedInfoPtr& ri)
00133 {
00134 m_impl->m_revoked = ri;
00135 }
00143 CPKIFRevokedInfoPtr CPKIFOCSPCertStatus::GetRevokedInfo() const
00144 {
00145 return m_impl->m_revoked;
00146 }