PKIFOCSPMemoryHelper.cpp
Go to the documentation of this file.00001
00009 #include "PKIFOCSPMemoryHelper.h"
00010
00011 #include "ToolkitUtils.h"
00012 #include "components.h"
00013
00014 #include "ASN1Helper.h"
00015 #include "OCSP.h"
00016
00017 using namespace std;
00025 void FreeRequestMembers(
00027 OCSPRequest* pRequest)
00028 {
00029 LOG_STRING_DEBUG("FreeRequestMembers", TOOLKIT_OCSP_ASN, 0, NULL);
00030
00031 if(!pRequest)
00032 return;
00033
00034
00035 if(pRequest->optionalSignature.signature.data)
00036 delete[] pRequest->optionalSignature.signature.data;
00037 if(pRequest->optionalSignature.m.certsPresent)
00038 {
00039
00040 delete pRequest->optionalSignature.certs.head->data;
00041 delete pRequest->optionalSignature.certs.head;
00042 }
00043 }
00044
00045
00046
00047
00048
00049
00050
00051
00059 void FreeTBSRequestMembers(
00061 TBSRequest* pTBSRequest)
00062 {
00063 LOG_STRING_DEBUG("FreeTBSRequestMembers", TOOLKIT_OCSP_ASN, 0, NULL);
00064
00065 if(!pTBSRequest)
00066 return;
00067
00068 DListNode* cur = NULL, *tmp = NULL;
00069 if(pTBSRequest->m.requestorNamePresent)
00070 {
00071 switch(pTBSRequest->requestorName.t)
00072 {
00073 case 9:
00074 break;
00075 case 8:
00076 break;
00077 case 7:
00078 break;
00079 case 6:
00080 break;
00081 case 5:
00082 if(NULL != pTBSRequest->requestorName.u.directoryName)
00083 {
00084 cur = NULL; tmp = NULL;
00085 if(NULL != pTBSRequest->requestorName.u.directoryName->u.rdnSequence)
00086 {
00087 cur = pTBSRequest->requestorName.u.directoryName->u.rdnSequence->head;
00088 while(NULL != cur)
00089 {
00090 ASN1OpenType* tmpOT = NULL;
00091
00092 if(NULL != cur->data)
00093 tmpOT = (ASN1OpenType*)cur->data;
00094 if(NULL != tmpOT->data)
00095 delete tmpOT->data;
00096 if(NULL != tmpOT)
00097 delete tmpOT;
00098
00099 tmp = cur->next;
00100 delete cur;
00101 cur = tmp;
00102 }
00103
00104 delete pTBSRequest->requestorName.u.directoryName->u.rdnSequence;
00105 pTBSRequest->requestorName.u.directoryName->u.rdnSequence = NULL;
00106 }
00107
00108 delete pTBSRequest->requestorName.u.directoryName;
00109 pTBSRequest->requestorName.u.directoryName = NULL;
00110 }
00111
00112 break;
00113 case 4:
00114 break;
00115 case 3:
00116 {
00117 if(NULL != pTBSRequest->requestorName.u.rfc822Name)
00118 delete[] pTBSRequest->requestorName.u.rfc822Name;
00119 pTBSRequest->requestorName.u.rfc822Name = NULL;
00120 }
00121 break;
00122 case 2:
00123 break;
00124 case 1:
00125 break;
00126 }
00127 }
00128
00129 cur = NULL; tmp = NULL;
00130 if(0 != pTBSRequest->requestList.count)
00131 {
00132 cur = pTBSRequest->requestList.head;
00133 while(NULL != cur)
00134 {
00135 Request* tmpReq = NULL;
00136
00137 if(NULL != cur->data)
00138 tmpReq = (Request*)cur->data;
00139 if(NULL != tmpReq)
00140 delete tmpReq;
00141
00142 tmp = cur->next;
00143 delete cur;
00144 cur = tmp;
00145 }
00146 }
00147
00148 cur = NULL; tmp = NULL;
00149 if(0 != pTBSRequest->m.requestExtensionsPresent)
00150 {
00151 cur = pTBSRequest->requestExtensions.head;
00152 while(NULL != cur)
00153 {
00154 CACX509V3Extension* tmpExt = NULL;
00155
00156 if(NULL != cur->data)
00157 tmpExt = (CACX509V3Extension*)cur->data;
00158 if(NULL != tmpExt)
00159 delete tmpExt;
00160
00161 tmp = cur->next;
00162 delete cur;
00163 cur = tmp;
00164 }
00165 }
00166 }
00176 PKIFOCSPMemoryHelper::PKIFOCSPMemoryHelper() : pRequest(NULL), pResponse(NULL), pTBSRequest(NULL)
00177 {
00178 LOG_STRING_DEBUG("PKIFOCSPMemoryHelper::PKIFOCSPMemoryHelper()", TOOLKIT_OCSP_ASN, 0, this);
00179 }
00187 PKIFOCSPMemoryHelper::~PKIFOCSPMemoryHelper()
00188 {
00189 LOG_STRING_DEBUG("PKIFOCSPMemoryHelper::~PKIFOCSPMemoryHelper()", TOOLKIT_OCSP_ASN, 0, this);
00190
00191
00192 if (pRequest)
00193 {
00194 FreeRequestMembers(pRequest);
00195 delete pRequest;
00196 }
00197 if (pResponse)
00198 {
00199
00200
00201
00202 delete pResponse;
00203 }
00204 if(pTBSRequest)
00205 {
00206 FreeTBSRequestMembers(pTBSRequest);
00207 delete pTBSRequest;
00208 }
00209 }