CVResponse.cpp

Go to the documentation of this file.
00001 
00010 #include "CVResponse.h" 
00011 
00012 #include "ASN1Helper.h"
00013 #include "AlgorithmIdentifier.h"
00014 #include "Buffer.h"
00015 #include "OID.h"
00016 #include "Query.h" 
00017 #include "ResponseFlags.h"
00018 #include "PKIFTime.h"
00019 #include "Certificate.h"
00020 #include "ValidationPolicy.h"
00021 #include "KeyUsage.h"
00022 #include "PKCReference.h"
00023 #include "GeneralName.h"
00024 #include "Name.h"
00025 #include "RevocationInfo.h"
00026 #include "CRL.h"
00027 #include "ResponseStatus.h"
00028 #include "HashValue.h"
00029 #include "RequestReference.h"
00030 #include "CertReply.h"
00031 #include "ReplyCheck.h"
00032 #include "ReplyWantBack.h"
00033 #include "SCVPCertID.h"
00034 #include "ResponseStatus.h"
00035 #include "ACReference.h"
00036 #include "CertReference.h"
00037 
00038 
00039 #include "PKIFMessageErrors.h"
00040 #include "PKIFSCVPErrors.h"
00041 #include "PKIFX509Extensions2.h"
00042 #include "SCVP.h"
00043 #include "ToolkitUtils.h"
00044 #include "X509Extension.h"
00045 #include "SCVPException.h"
00046 #include "PolicyInformation.h"
00047 #include "private/PKIFSCVPMemoryHelper.h"
00048 #include "private/SCVPUtils.h"
00049 
00050 
00051 using namespace std;
00053 
00054 struct CPKIFCVResponseImpl
00055 {
00056     CPKIFCVResponse *m_parent;
00057 
00058     //function to process extensions
00059     void populateExtensionsVector();
00060 
00061     //convenience goo for auto-nonce generation
00062     bool m_bGenerateNonce;
00063     void GenerateNonce() const; //logical const
00064     IPKIFMediatorPtr m_mediator;
00065 
00066     //members for building
00067     int m_version;
00068     int m_serverConfigurationID;
00069     CPKIFTimePtr m_producedAt;
00070     CPKIFResponseStatusPtr m_responseStatus;
00071     CPKIFValidationPolicyPtr m_validationPolicy; 
00072     CPKIFRequestReferencePtr m_requestReference;
00073     CPKIFGeneralNameListPtr m_requestorRef;
00074     CPKIFGeneralNameListPtr m_requestorName;    
00075     CPKIFCertReplyListPtr m_replyObjects;
00076     CPKIFBufferPtr m_respNonce;
00077     CPKIFBufferPtr m_serverContextInfo;
00078     CPKIFStringPtr m_requestorText;
00079 
00080     std::vector<CPKIFX509ExtensionPtr> m_exts;
00081 
00082     //member for decoding
00083     CPKIFASNWrapper<CVResponse>* m_scvpresp;
00084 
00085     void ClearAllMembers();
00086     void MakeSCVPResp();
00087     void FreeSCVPResp();
00088 
00089     //member to maintain state when calling Set functions
00090     void CallingAllGets();
00091 
00092     CPKIFCVResponse * m_this;
00093 };
00094 
00102 void CPKIFCVResponseImpl::CallingAllGets()
00103 {
00104     LOG_STRING_DEBUG("CPKIFCVResponse::CallingAllGets()", TOOLKIT_SCVP_ASN, 0, this);
00105 
00106     m_parent->GetVersion();
00107     m_parent->GetNonce();
00108     populateExtensionsVector();
00109     FreeSCVPResp();
00110 }
00111 
00119 void CPKIFCVResponseImpl::MakeSCVPResp()
00120 {
00121     LOG_STRING_DEBUG("CPKIFCVResponse::MakeSCVPR()", TOOLKIT_SCVP_ASN, 0, this);
00122 
00123     FreeSCVPResp();
00124     m_scvpresp = new CPKIFASNWrapper<CVResponse>( BEREncCVResponse, BERDecCVResponse );
00125 }
00133 void CPKIFCVResponseImpl::FreeSCVPResp()
00134 {
00135     LOG_STRING_DEBUG("CPKIFCVResponse::FreeSCVPR()", TOOLKIT_SCVP_ASN, 0, this);
00136     if(NULL != m_scvpresp)
00137         delete m_scvpresp;
00138     m_scvpresp = NULL;
00139 }
00140 
00149 void CPKIFCVResponseImpl::ClearAllMembers()
00150 {
00151     LOG_STRING_DEBUG("CPKIFCVResponse::ClearAllMembers()", TOOLKIT_SCVP_ASN, 0, this);
00152 
00153     m_version = 1;
00154     
00155     CPKIFBufferPtr tmpStr;
00156     m_respNonce = tmpStr;
00157 
00158     m_serverConfigurationID = 0;
00159 
00160     FreeSCVPResp();
00161 }
00162 
00173 void CPKIFCVResponseImpl::populateExtensionsVector()
00174 {
00175     LOG_STRING_DEBUG("CPKIFCVResponse::populateExtensionsVector()", TOOLKIT_SCVP_ASN, 0, this);
00176 
00177     if(NULL == m_scvpresp || NULL == m_scvpresp->data())
00178         return;
00179 
00180     //if we've already populated the extensions vector then return
00181     if(!m_exts.empty())
00182         return;
00183 
00184     //if there are no extensions then return
00185     if(0 == (*m_scvpresp)->m.cvResponseExtensionsPresent)
00186     {
00187         m_exts.clear();
00188         return;
00189     }
00190 
00191     // get the one and only extension mediator, with any additions an app might
00192     // have made
00193     CPKIFX509ExtensionMediator2 * mediator = CPKIFX509ExtensionMediator2::GetInstance();
00194 
00195     m_this->IPKIFHasExtensions::GetExtensions (mediator, m_exts);
00196 }
00197 
00206 CPKIFCVResponse::CPKIFCVResponse()
00207   :m_impl(new CPKIFCVResponseImpl)
00208 {
00209     LOG_STRING_DEBUG("CPKIFTimeStampRequest::CPKIFTimeStampRequest()", TOOLKIT_SCVP_ASN, 0, this);
00210 
00211     m_impl->m_parent = this;
00212     m_impl->m_version = 1;
00213     m_impl->m_serverConfigurationID = 0;
00214 
00215     m_impl->m_scvpresp = NULL;
00216 
00217     m_impl->m_this = this;
00218 }
00226 CPKIFCVResponse::~CPKIFCVResponse()
00227 {
00228     LOG_STRING_DEBUG("CPKIFCVResponse::~CPKIFCVResponse()", TOOLKIT_SCVP_ASN, 0, this);
00229 
00230     m_impl->FreeSCVPResp();
00231 
00232     if (m_impl) 
00233     {
00234       delete m_impl;
00235     }
00236 }
00237 
00245 int CPKIFCVResponse::GetVersion() const
00246 {
00247     return m_impl->m_version;
00248 }
00256 void CPKIFCVResponse::SetVersion(int v)
00257 {
00258     m_impl->m_version = v;
00259 }
00260 
00268 void CPKIFCVResponse::GetEncodedExtensions (
00270     CPKIFBufferPtr& buf) 
00271 {
00272     try 
00273     {
00274         if ((*m_impl->m_scvpresp)->m.cvResponseExtensionsPresent)
00275         {
00276             CACASNWRAPPER_CREATE(CACX509V3Extensions, extsWrapper);
00277             ASN1OpenType *data = extsWrapper.Encode (&(*m_impl->m_scvpresp)->cvResponseExtensions);
00278             CPKIFBufferPtr tmp(new CPKIFBuffer(data->data, data->numocts));
00279             buf = tmp;
00280             delete data;
00281             return;
00282         }
00283     }
00284     catch (... /*CPKIFException& e*/)
00285     {
00286         // How do we want to handle the exception?
00287     }
00288 
00289     CPKIFBufferPtr nullExt;
00290     buf = nullExt;
00291 }
00292 
00301 bool CPKIFCVResponse::ExtensionsPresent() const
00302 {
00303     LOG_STRING_DEBUG("CPKIFCVResponse::ExtensionsPresent()", TOOLKIT_SCVP_ASN, 0, this);
00304 
00305     if(NULL != m_impl->m_scvpresp && (*m_impl->m_scvpresp)->m.cvResponseExtensionsPresent)
00306         return true;
00307     else
00308         return false;
00309 }
00310 
00319 void CPKIFCVResponse::GetExtensionByOID(
00321     const CPKIFOID& oid,    
00323     CPKIFX509ExtensionPtr& ref)
00324 {
00325     if(m_impl->m_exts.empty() && 0 != (*m_impl->m_scvpresp)->m.cvResponseExtensionsPresent)
00326     m_impl->populateExtensionsVector();
00327     
00328     std::vector<CPKIFX509ExtensionPtr>::iterator pos;
00329     std::vector<CPKIFX509ExtensionPtr>::iterator end = m_impl->m_exts.end();
00330     for(pos = m_impl->m_exts.begin(); pos != end; ++pos)
00331     {
00332     if(oid == (*pos)->oid())
00333     {
00334         ref = *pos;
00335         return;
00336     }
00337     }       
00338 }
00339 
00340 
00348 void CPKIFCVResponse::SetValidationPolicy(
00350     CPKIFValidationPolicyPtr& validationPolicy)
00351 {
00352     m_impl->m_validationPolicy = validationPolicy;
00353 }
00361 const CPKIFValidationPolicyPtr CPKIFCVResponse::GetValidationPolicy() const
00362 {
00363     return m_impl->m_validationPolicy;
00364 }
00365 
00373 void CPKIFCVResponse::SetNonce(
00375     CPKIFBufferPtr& nonce)
00376 {
00377     LOG_STRING_DEBUG("CPKIFCVResponse::SetNonce(CPKIFStringPtr& nonce)", TOOLKIT_SCVP_ASN, 0, this);
00378 
00379     m_impl->CallingAllGets();
00380     m_impl->m_respNonce = nonce;
00381 }
00389 const CPKIFBufferPtr CPKIFCVResponse::GetNonce() const
00390 {
00391     //corrected casting of NULL 6/16/2004
00392     //if(m_impl->m_nonce == (std::string*)NULL && NULL != m_impl->m_scvpr && (*m_impl->m_scvpr)->m.requestNoncePresent)
00393     //{
00394     //  LOG_STRING_DEBUG("CPKIFCVResponse::GetNonce()", TOOLKIT_SCVP_ASN, 0, this);
00395 
00396     //  CPKIFBufferPtr tmpBuf(new CPKIFBuffer((*m_impl->m_scvpr)->requestNonce.data, (*m_impl->m_scvpr)->requestNonce.numocts));
00397 
00398     //  CPKIFCVResponse* nonConst = const_cast<CPKIFCVResponse*>(this);
00399     //  nonConst->m_impl->m_nonce = tmpBuf;
00400     //}
00401 
00402     if(m_impl->m_respNonce == NULL)
00403     {
00404         CPKIFBufferPtr t;
00405         return t;
00406     }
00407     else
00408         return m_impl->m_respNonce;
00409 }
00410 
00418 void CPKIFCVResponse::SetProducedAt(
00420     CPKIFTimePtr& producedAt)
00421 {
00422     m_impl->m_producedAt = producedAt;
00423 }
00431 const CPKIFTimePtr CPKIFCVResponse::GetProducedAt() const
00432 {
00433     return m_impl->m_producedAt;
00434 }
00442 void CPKIFCVResponse::SetConfigurationID(
00444     int confID)
00445 {
00446     m_impl->m_serverConfigurationID = confID;
00447 }
00455 const int CPKIFCVResponse::GetConfigurationID() const
00456 {
00457     return m_impl->m_serverConfigurationID;
00458 }
00459 
00467 void CPKIFCVResponse::SetRequestorRef(
00470     CPKIFGeneralNameListPtr& requestorRef)
00471 {
00472     m_impl->m_requestorRef = requestorRef;
00473 }
00481 void CPKIFCVResponse::GetRequestorRef(
00484     CPKIFGeneralNameListPtr& requestorRef) const
00485 {
00486     requestorRef = m_impl->m_requestorRef;
00487 }
00488 
00497 void CPKIFCVResponse::SetRequestorName(
00500     CPKIFGeneralNameListPtr& requestorRef)
00501 {
00502     m_impl->m_requestorRef = requestorRef;
00503 }
00511 void CPKIFCVResponse::GetRequestorName(
00514     CPKIFGeneralNameListPtr& requestorRef) const
00515 {
00516     requestorRef = m_impl->m_requestorRef;
00517 }
00518 
00526 void CPKIFCVResponse::SetServerContextInfo( 
00528     CPKIFBufferPtr& serverContextInfo)
00529 {
00530     m_impl->m_serverContextInfo = serverContextInfo;
00531 }
00539 const CPKIFBufferPtr CPKIFCVResponse::GetServerContextInfo() const
00540 {
00541     return m_impl->m_serverContextInfo;
00542 }
00543 
00551 void CPKIFCVResponse::SetRequestorText(
00554     CPKIFStringPtr& requestorText)
00555 {
00556     m_impl->m_requestorText = requestorText;
00557 }
00565 const CPKIFStringPtr CPKIFCVResponse::GetRequestorText() const
00566 {
00567     return m_impl->m_requestorText;
00568 }
00576 void CPKIFCVResponse::SetResponseStatus(
00578     CPKIFResponseStatusPtr& responseStatus)
00579 {
00580     m_impl->m_responseStatus = responseStatus;
00581 }
00589 const CPKIFResponseStatusPtr CPKIFCVResponse::GetResponseStatus() const
00590 {
00591     return m_impl->m_responseStatus;
00592 }
00600 void CPKIFCVResponse::SetRequestReference(
00602     CPKIFRequestReferencePtr& requestReference)
00603 {
00604     m_impl->m_requestReference = requestReference;
00605 }
00613 const CPKIFRequestReferencePtr CPKIFCVResponse::GetRequestReference() const
00614 {
00615     return m_impl->m_requestReference;
00616 }
00624 void CPKIFCVResponse::SetReplyObjects(
00627     CPKIFCertReplyListPtr& replyObjects)
00628 {
00629     m_impl->m_replyObjects = replyObjects;
00630 }
00638 void CPKIFCVResponse::GetReplyObjects(
00641     CPKIFCertReplyListPtr& replyObjects) const
00642 {
00643     replyObjects = m_impl->m_replyObjects;
00644 }
00645 
00656 CPKIFBufferPtr CPKIFCVResponse::Encode() const
00657 {
00658     LOG_STRING_DEBUG("CPKIFCVResponse::Encode()", TOOLKIT_SCVP_ASN, 0, this);
00659 
00660     //Whether the message is being created or regenerated after parsing a previous message
00661     //always create and populate a new request object (use Getxxx functions to access fields).
00662     //throw bad_alloc
00663     PKIFSCVPMemoryHelper mhSCVPResponse;
00664     mhSCVPResponse.pResponse = new CVResponse;
00665     memset(mhSCVPResponse.pResponse, 0, sizeof(CVResponse));
00666 
00667     OOCTXT ctxt;
00668     initContext (&ctxt);
00669 
00670     //version - hardcode to 1 for the time being (no other versions are supported at this time)
00671     mhSCVPResponse.pResponse->cvResponseVersion = m_impl->m_version;
00672 
00673     const int confID = GetConfigurationID();
00674     if(0 == confID )
00675     {
00676         throw CPKIFSCVPException(TOOLKIT_SCVP, SCVP_MISSING_REQUIRED_FIELD, "Server Configuration ID value not specified.");
00677     }
00678     else
00679     {
00680         mhSCVPResponse.pResponse->serverConfigurationID = confID;
00681     }
00682 
00683     //producedAt Time
00684     CPKIFTimePtr producedAtTime = GetProducedAt();
00685     if(producedAtTime != (CPKIFTime*)NULL)
00686     {
00687         mhSCVPResponse.pResponse->producedAt = producedAtTime->GetTime();
00688     }
00689     else
00690     {
00691         producedAtTime = CPKIFTime::CurrentTime();
00692         mhSCVPResponse.pResponse->producedAt = producedAtTime->GetTime();
00693     }
00694 
00695     //Response Status
00696     CPKIFResponseStatusPtr responseStatus = GetResponseStatus();
00697     if(responseStatus != (CPKIFResponseStatus*)NULL)
00698     {
00699         int sc = responseStatus->GetStatusCode();
00700         string mess = responseStatus->GetErrorMessage();
00701 
00702         if(sc != 0)
00703         {
00704             mhSCVPResponse.pResponse->responseStatus.m.statusCodePresent = 1;
00705             mhSCVPResponse.pResponse->responseStatus.statusCode = sc;
00706         }
00707 
00708         if(mess != "")
00709         {
00710             mhSCVPResponse.pResponse->responseStatus.m.errorMessagePresent = 1;
00711             mhSCVPResponse.pResponse->responseStatus.errorMessage = strdup(mess.c_str());
00712         }   
00713     }
00714     //Validation Policy
00715     if(m_impl->m_validationPolicy == (CPKIFValidationPolicy*)NULL)
00716     {
00717         throw CPKIFSCVPException(TOOLKIT_SCVP, SCVP_MISSING_REQUIRED_FIELD, "Server validationPolicy value not specified.");
00718     }
00719     else
00720     {
00721         PopulateValidationPolicy(&mhSCVPResponse.pResponse->respValidationPolicy, m_impl->m_validationPolicy, ctxt);
00722         mhSCVPResponse.pResponse->m.respValidationPolicyPresent = 1;
00723     }
00724     //RequestReference
00725     CPKIFRequestReferencePtr requestRef = GetRequestReference();
00726     if(requestRef != (CPKIFRequestReference*)NULL)
00727     {   
00728         mhSCVPResponse.pResponse->m.requestRefPresent = 1;
00729         CPKIFHashValuePtr hashVal = requestRef->GetHashValue();
00730         if(hashVal != (CPKIFHashValue*)NULL)
00731         {
00732             mhSCVPResponse.pResponse->requestRef.t = T_RequestReference_requestHash;
00733             mhSCVPResponse.pResponse->requestRef.u.requestHash = new HashValue;
00734             CPKIFAlgorithmIdentifierPtr algID = hashVal->GetAlgID();
00735             if(algID != (CPKIFAlgorithmIdentifier*)NULL)
00736             {
00737                 CPKIFStringPtr str(new std::string(algID->oid()->ToString())); 
00738                 ASN1OBJID* tmpOid = ConvertStringToASN1OBJID(str);
00739                 CopyOID(&mhSCVPResponse.pResponse->requestRef.u.requestHash->algorithm.algorithm, tmpOid);
00740 
00741                 if(NULL != tmpOid)
00742                     delete tmpOid;
00743 
00744                 if(algID->hasParameters())
00745                 {
00746                     mhSCVPResponse.pResponse->requestRef.u.requestHash->algorithm.m.parametersPresent = 1;
00747 
00748                     mhSCVPResponse.pResponse->requestRef.u.requestHash->algorithm.parameters.data = algID->parameters()->GetBuffer();
00749                     mhSCVPResponse.pResponse->requestRef.u.requestHash->algorithm.parameters.numocts = algID->parameters()->GetLength();
00750                 }
00751 
00752                 mhSCVPResponse.pResponse->requestRef.u.requestHash->m.algorithmPresent = 1;
00753             }
00754 
00755         }
00756         CPKIFBufferPtr fullRequest = requestRef->GetFullRequest();
00757         if(fullRequest  != (CPKIFBuffer*)NULL)
00758         {
00759             mhSCVPResponse.pResponse->requestRef.t = T_RequestReference_fullRequest;
00760 
00761             mhSCVPResponse.pResponse->requestRef.u.fullRequest = new CVRequest;
00762             memset(mhSCVPResponse.pResponse->requestRef.u.fullRequest, 0, sizeof(CVRequest));
00763 
00764             setBERDecBufPtr(&ctxt, (unsigned char*)fullRequest->GetBuffer(), fullRequest->GetLength(), NULL, NULL);
00765             BERDecCVRequest(&ctxt, mhSCVPResponse.pResponse->requestRef.u.fullRequest, ASN1EXPL, NULL);
00766 
00767         }
00768     }
00769 
00770     //requestorRef
00771     CPKIFGeneralNameListPtr requestorRef;       
00772     GetRequestorRef(requestorRef);
00773     if(requestorRef != (CPKIFGeneralNameList*)NULL)
00774     {
00775         PopulateDListWithCACX509V3GeneralName(&mhSCVPResponse.pResponse->requestorRef, requestorRef);
00776         if(requestorRef->size() > 0)
00777         {
00778             mhSCVPResponse.pResponse->m.requestorRefPresent = 1;
00779         }
00780     }
00781     
00782 
00783     //requestorName
00784     CPKIFGeneralNameListPtr requestorName;      
00785     GetRequestorName(requestorName);
00786     if(requestorName != (CPKIFGeneralNameList*)NULL)
00787     {
00788         PopulateDListWithCACX509V3GeneralName(&mhSCVPResponse.pResponse->requestorName, requestorName);
00789         if(requestorName->size() > 0)
00790         {
00791             mhSCVPResponse.pResponse->m.requestorNamePresent = 1;
00792         }
00793     }
00794     
00795     //ReplyObjects
00796     PopulateReplyObjects(&mhSCVPResponse.pResponse->replyObjects, m_impl->m_replyObjects, ctxt);
00797 
00798     if(m_impl->m_replyObjects->size() > 0)
00799     {
00800         mhSCVPResponse.pResponse->m.replyObjectsPresent = 1; 
00801     }
00802 
00803 
00804     //respNonce This might need to chaange to read get the nonce from the request
00805     const CPKIFBufferPtr nonce = GetNonce();
00806     if(nonce != (CPKIFBuffer*)NULL)
00807     {
00808         mhSCVPResponse.pResponse->respNonce.data = nonce->GetBuffer();
00809         mhSCVPResponse.pResponse->respNonce.numocts = nonce->GetLength();
00810         mhSCVPResponse.pResponse->m.respNoncePresent = 1;
00811 
00812     }
00813 
00814     //respNonce This might need to chaange to read get the nonce from the request
00815     const CPKIFBufferPtr contextInfo = GetServerContextInfo();
00816     if(contextInfo != (CPKIFBuffer*)NULL)
00817     {
00818         mhSCVPResponse.pResponse->serverContextInfo.data = contextInfo->GetBuffer();
00819         mhSCVPResponse.pResponse->serverContextInfo.numocts = contextInfo->GetLength();
00820         mhSCVPResponse.pResponse->m.serverContextInfoPresent = 1;
00821 
00822     }
00823 
00824     //requestorText
00825     const CPKIFStringPtr text = GetRequestorText();
00826     if(text != NULL)
00827     {
00828         mhSCVPResponse.pResponse->requestorText = strdup(text->c_str());
00829         mhSCVPResponse.pResponse->m.requestorTextPresent = 1;
00830     }
00831 
00832     CACASNWRAPPER_CREATE(CVResponse, objPDU);
00833     ASN1OpenType* data1 = objPDU.Encode(mhSCVPResponse.pResponse);
00834     CPKIFBufferPtr tmp(new CPKIFBuffer(data1->data, data1->numocts));
00835     delete data1;
00836 
00837     freeEncodeBuffer(&ctxt);
00838     memFreeAll(&ctxt);
00839 
00840     return tmp;
00841 }
00842 
00853 void CPKIFCVResponse::Decode(
00855     CPKIFBufferPtr& msg)
00856 {
00857     m_impl->ClearAllMembers();
00858 
00859     //if the input is empty - fail now
00860     if(msg == (CPKIFBuffer*)NULL || 0 == msg->GetLength())
00861     {
00862         throw CPKIFSCVPException(TOOLKIT_SCVP_ASN, COMMON_INVALID_INPUT);
00863     }
00864 
00865     m_impl->MakeSCVPResp();
00866 
00867     try
00868     {
00869         (*m_impl->m_scvpresp).Decode(msg->GetBuffer(), msg->GetLength());
00870         
00871         //Version
00872         m_impl->m_version = (*m_impl->m_scvpresp)->cvResponseVersion;
00873 
00874         //serverConfigurationID
00875         m_impl->m_serverConfigurationID = (*m_impl->m_scvpresp)->serverConfigurationID;
00876 
00877         //ProducedAt
00878         CPKIFTimePtr tmpTime(new CPKIFTime((*m_impl->m_scvpresp)->producedAt));
00879         m_impl->m_producedAt = tmpTime;
00880 
00881         CACASNWRAPPER_CREATE(ResponseStatus, objPDU);
00882         ASN1OpenType* data1 = objPDU.Encode(&(*m_impl->m_scvpresp)->responseStatus);
00883         CPKIFBufferPtr tmpBuf(new CPKIFBuffer(data1->data, data1->numocts));
00884         CPKIFResponseStatusPtr tmpRS(new CPKIFResponseStatus(tmpBuf));
00885         m_impl->m_responseStatus = tmpRS;
00886 
00887         if(0 < (*m_impl->m_scvpresp)->m.respValidationPolicyPresent)
00888         {
00889             CACASNWRAPPER_CREATE(ValidationPolicy, objPDU);
00890             ASN1OpenType* data1 = objPDU.Encode(&(*m_impl->m_scvpresp)->respValidationPolicy);          
00891             CPKIFBufferPtr tmpBuf(new CPKIFBuffer(data1->data, data1->numocts));
00892             CPKIFValidationPolicyPtr tmpValPol(new CPKIFValidationPolicy(tmpBuf));
00893         
00894             m_impl->m_validationPolicy = tmpValPol;
00895         }
00896 
00897         if(0 < (*m_impl->m_scvpresp)->m.requestRefPresent)
00898         {
00899             CACASNWRAPPER_CREATE(RequestReference, objPDU);
00900             ASN1OpenType* data1 = objPDU.Encode(&(*m_impl->m_scvpresp)->requestRef);            
00901             CPKIFBufferPtr tmpBuf(new CPKIFBuffer(data1->data, data1->numocts));
00902             CPKIFRequestReferencePtr tmpReqRef(new CPKIFRequestReference(tmpBuf));
00903 
00904             m_impl->m_requestReference = tmpReqRef;
00905         }
00906 
00907         if(0 < (*m_impl->m_scvpresp)->m.requestorRefPresent)
00908         {
00909             m_impl->m_requestorRef = PopulatePKIFGeneralNameList(&(*m_impl->m_scvpresp)->requestorRef); 
00910 
00911         }
00912 
00913         if(0 < (*m_impl->m_scvpresp)->m.requestorNamePresent)
00914         {
00915             m_impl->m_requestorName = PopulatePKIFGeneralNameList(&(*m_impl->m_scvpresp)->requestorName);   
00916         }
00917 
00918         if(0 < (*m_impl->m_scvpresp)->m.respNoncePresent)
00919         {
00920             CPKIFBufferPtr tmpNonce(new CPKIFBuffer((*m_impl->m_scvpresp)->respNonce.data, 
00921                 (*m_impl->m_scvpresp)->respNonce.numocts));
00922 
00923             m_impl->m_respNonce = tmpNonce;
00924         }
00925 
00926         if(0 < (*m_impl->m_scvpresp)->m.serverContextInfoPresent)
00927         {
00928             CPKIFBufferPtr tmpBuf(new CPKIFBuffer((*m_impl->m_scvpresp)->serverContextInfo.data, 
00929                     (*m_impl->m_scvpresp)->serverContextInfo.numocts));
00930 
00931             m_impl->m_serverContextInfo = tmpBuf;
00932         }
00933 
00934         if(0 < (*m_impl->m_scvpresp)->m.requestorTextPresent)
00935         {
00936             CPKIFStringPtr tmpRequestorTest(new std::string((*m_impl->m_scvpresp)->requestorText));
00937             m_impl->m_requestorText = tmpRequestorTest;
00938         }
00939 
00940         if(0 < (*m_impl->m_scvpresp)->m.replyObjectsPresent)
00941         {
00942             CPKIFCertReplyListPtr tmpCertReplyList(new CPKIFCertReplyList());
00943             DListNode* cur = (*m_impl->m_scvpresp)->replyObjects.head;
00944             while(NULL != cur)
00945             {
00946                 CertReply* tmp = (CertReply*)cur->data;
00947                 CACASNWRAPPER_CREATE(CertReply, objPDU);
00948                 ASN1OpenType* data1 = objPDU.Encode(tmp);
00949                 CPKIFBufferPtr tmpBuf(new CPKIFBuffer(data1->data, data1->numocts));
00950                 CPKIFCertReplyPtr tmpCertReply(new CPKIFCertReply(tmpBuf));
00951 
00952                 if(NULL != data1)
00953                     delete data1;
00954 
00955                 tmpCertReplyList->push_back(tmpCertReply);
00956         
00957                 cur = cur->next;
00958             }
00959             m_impl->m_replyObjects = tmpCertReplyList;
00960         }
00961         m_impl->populateExtensionsVector();
00962     }
00963     catch(CPKIFException&)
00964     {
00965         throw CPKIFSCVPException(TOOLKIT_SCVP_ASN, MSG_DECODE_FAILED);
00966     }
00967 }
00968 
00976 bool CPKIFCVResponse::AreThereAnyUnprocessedCriticalExtensions()
00977 {
00978     LOG_STRING_DEBUG("CPKIFCVResponse::AreThereAnyUnprocessedCriticalExtensions()", TOOLKIT_OCSP_ASN, 0, this);
00979 
00980     std::vector<CPKIFX509ExtensionPtr>::iterator pos;
00981     std::vector<CPKIFX509ExtensionPtr>::iterator end = m_impl->m_exts.end();
00982     for(pos = m_impl->m_exts.begin(); pos != end; ++pos)
00983     {
00984         if((*pos)->isCritical())
00985             return true;
00986     }
00987 
00988     return false;
00989 }

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