ResponderID.cpp

Go to the documentation of this file.
00001 
00009 #include "ResponderID.h"
00010 #include "Name.h"
00011 #include "Buffer.h"
00012 #include "ASN1Helper.h"
00013 
00014 #include "ToolkitUtils.h"
00015 #include "components.h"
00016 
00017 #include "OCSP.h"
00018 
00019 using namespace std;
00020 
00022 struct CPKIFResponderIDImpl
00023 {
00024     CPKIFNamePtr m_name;
00025     CPKIFBufferPtr m_keyHash;
00026     CPKIFResponderID::ResponderIDType m_choice;
00027 };
00029 
00037 CPKIFResponderID::CPKIFResponderID(void)
00038     :m_impl (new CPKIFResponderIDImpl)
00039 {
00040     LOG_STRING_DEBUG("CPKIFResponderID::CPKIFResponderID(void)", TOOLKIT_OCSP_ASN, 0, this);
00041 
00042     m_impl->m_choice = UNSET;
00043 }
00052 //CPKIFResponderID::CPKIFResponderID(
00053 //  //![in] Reference to a ResponderID structure                               
00054 //  ResponderID& rid)
00055 //  :m_impl (new CPKIFResponderIDImpl)
00056 //{
00057 //  LOG_STRING_DEBUG("CPKIFResponderID::CPKIFResponderID(ResponderID& rid)", TOOLKIT_OCSP_ASN, 0, this);
00058 //
00059 //  m_impl->m_choice = CPKIFResponderID::UNSET;
00060 //
00061 //  switch(rid.t)
00062 //  {
00063 //  case 1:
00064 //      {
00065 //      CPKIFNamePtr tmpName(new CPKIFName(*rid.u.byName));
00066 //      m_impl->m_name = tmpName;
00067 //      m_impl->m_choice = CPKIFResponderID::NAME;
00068 //      }
00069 //      break;
00070 //  case 2:
00071 //      {
00072 //      CPKIFBufferPtr tmpBuf(new CPKIFBuffer(rid.u.byKey->data, rid.u.byKey->numocts));
00073 //      m_impl->m_keyHash = tmpBuf;
00074 //      m_impl->m_choice = CPKIFResponderID::KEYHASH;
00075 //      }
00076 //      break;
00077 //  }
00078 //}
00079 CPKIFResponderID::CPKIFResponderID(
00081     const CPKIFBufferPtr& rid)
00082     :m_impl (new CPKIFResponderIDImpl)
00083 {
00084     LOG_STRING_DEBUG("CPKIFResponderID::CPKIFResponderID(ResponderID& rid)", TOOLKIT_OCSP_ASN, 0, this);
00085 
00086     CACASNWRAPPER_CREATE(ResponderID, objPDU);
00087     objPDU.Decode(rid->GetBuffer(), rid->GetLength());
00088 
00089     m_impl->m_choice = CPKIFResponderID::UNSET;
00090 
00091     switch(objPDU->t)
00092     {
00093     case 1:
00094         {
00095         CACASNWRAPPER_CREATE(CACX509V3Name, objPDU2);
00096         ASN1OpenType* data1 = objPDU2.Encode(objPDU->u.byName);
00097         CPKIFBufferPtr tmpBuf;
00098         if(data1 != NULL)
00099         {
00100              tmpBuf = CPKIFBufferPtr(new CPKIFBuffer(data1->data, data1->numocts));
00101             delete data1;
00102         }
00103         //CPKIFNamePtr tmpName(new CPKIFName(*objPDU->u.byName));
00104         CPKIFNamePtr tmpName(new CPKIFName(tmpBuf));
00105         m_impl->m_name = tmpName;
00106         m_impl->m_choice = CPKIFResponderID::NAME;
00107         }
00108         break;
00109     case 2:
00110         {
00111         CPKIFBufferPtr tmpBuf(new CPKIFBuffer(objPDU->u.byKey->data, objPDU->u.byKey->numocts));
00112         m_impl->m_keyHash = tmpBuf;
00113         m_impl->m_choice = CPKIFResponderID::KEYHASH;
00114         }
00115         break;
00116     }
00117 }
00125 CPKIFResponderID::~CPKIFResponderID(void)
00126 {
00127     LOG_STRING_DEBUG("CPKIFResponderID::~CPKIFResponderID(void)", TOOLKIT_OCSP_ASN, 0, this);
00128 
00129     delete m_impl;
00130     m_impl = NULL;
00131 }
00150 CPKIFResponderID::ResponderIDType CPKIFResponderID::GetChoice() const
00151 {
00152     return m_impl->m_choice;
00153 }
00154 
00155 //name
00164 CPKIFNamePtr CPKIFResponderID::GetName() const
00165 {
00166     
00167     return m_impl->m_name;
00168 }
00176 void CPKIFResponderID::SetName(
00178     CPKIFNamePtr& name)
00179 {
00180     m_impl->m_name = name;
00181 }
00182 
00183 //key hash
00192 CPKIFBufferPtr CPKIFResponderID::GetHash() const
00193 {
00194     return m_impl->m_keyHash;
00195 }
00203 void CPKIFResponderID::SetHash(
00205     CPKIFBufferPtr& hash)
00206 {
00207     m_impl->m_keyHash = hash;
00208 }

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