RequestReference.cpp
Go to the documentation of this file.00001
00010 #include "RequestReference.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 #include "HashValue.h"
00019
00020 using namespace std;
00021
00023
00024 struct CPKIFRequestReferenceImpl
00025 {
00026 CPKIFBufferPtr m_fullRequest;
00027 CPKIFHashValuePtr m_hashValue;
00028 };
00029
00031
00040 CPKIFRequestReference::CPKIFRequestReference() :m_impl(new CPKIFRequestReferenceImpl)
00041 {
00042 LOG_STRING_DEBUG("CPKIFRequestReference::CPKIFRequestReference()", TOOLKIT_SCVP_ASN, 0, this);
00043
00044 }
00055 CPKIFRequestReference::CPKIFRequestReference(
00057 const CPKIFBufferPtr& reqRef)
00058 :m_impl (new CPKIFRequestReferenceImpl)
00059 {
00060 if(reqRef == (CPKIFBuffer*)NULL || 0 == reqRef->GetLength())
00061 {
00062 throw CPKIFSCVPException(TOOLKIT_SCVP_ASN, COMMON_INVALID_INPUT);
00063 }
00064
00065 CACASNWRAPPER_CREATE(RequestReference, objPDU);
00066 objPDU.Decode(reqRef->GetBuffer(), reqRef->GetLength());
00067
00068 if(objPDU->t == T_RequestReference_requestHash)
00069 {
00070 CACASNWRAPPER_CREATE(HashValue, objPDU2);
00071 ASN1OpenType* data1 = objPDU2.Encode(objPDU->u.requestHash);
00072 CPKIFBufferPtr tmpBuf(new CPKIFBuffer(data1->data, data1->numocts));
00073 CPKIFHashValuePtr tmpRevInfo(new CPKIFHashValue(tmpBuf));
00074
00075 m_impl->m_hashValue = tmpRevInfo;
00076 }
00077 else
00078 {
00079 CACASNWRAPPER_CREATE(CVRequest, cvReqObjPDU);
00080 ASN1OpenType* cvReqEncoded = NULL;
00081 cvReqEncoded = cvReqObjPDU.Encode(objPDU->u.fullRequest);
00082
00083 CPKIFBufferPtr tmpBuf(new CPKIFBuffer(cvReqEncoded->data, cvReqEncoded->numocts));
00084
00085 if(cvReqEncoded != NULL)
00086 delete cvReqEncoded;
00087
00088 m_impl->m_fullRequest = tmpBuf;
00089 }
00090
00091
00092 }
00100 CPKIFRequestReference::~CPKIFRequestReference()
00101 {
00102 LOG_STRING_DEBUG("CPKIFRequestReference::~CPKIFRequestReference()", TOOLKIT_SCVP_ASN, 0, this);
00103
00104 if (m_impl) {
00105 delete m_impl;
00106 }
00107 }
00115 void CPKIFRequestReference::SetFullRequest(
00117 CPKIFBufferPtr& fullRequest)
00118 {
00119 m_impl->m_fullRequest = fullRequest;
00120
00121 CPKIFHashValuePtr tmp;
00122 m_impl->m_hashValue = tmp;
00123 }
00131 const CPKIFBufferPtr CPKIFRequestReference::GetFullRequest() const
00132 {
00133 return m_impl->m_fullRequest;
00134 }
00135
00143 void CPKIFRequestReference::SetHashValue(
00145 CPKIFHashValuePtr& hashValue)
00146 {
00147 m_impl->m_hashValue = hashValue;
00148
00149 CPKIFBufferPtr tmp;
00150 m_impl->m_fullRequest = tmp;
00151
00152 }
00160 const CPKIFHashValuePtr CPKIFRequestReference::GetHashValue() const
00161 {
00162 return m_impl->m_hashValue;
00163 }
00164
00172 REQUESTREV CPKIFRequestReference::GetRequestRefType()
00173 {
00174 if(m_impl->m_fullRequest != (CPKIFBuffer*)NULL)
00175 {
00176 return REQUESTREV_FULL;
00177 }
00178 else if(m_impl->m_hashValue != (CPKIFHashValue*)NULL)
00179 {
00180 return REQUESTREV_HASH;
00181 }
00182
00183 return REQUESTREV_NONE;
00184 }