CertID.cpp
Go to the documentation of this file.00001
00009 #include "CertID.h"
00010
00011 #include "AlgorithmIdentifier.h"
00012 #include "Buffer.h"
00013 #include "ASN1Helper.h"
00014 #include "OID.h"
00015
00016 #include "OCSP.h"
00017
00018 #include "ToolkitUtils.h"
00019
00020 #include "PKIFX509Extensions2.h"
00021 using namespace std;
00022
00024 struct CPKIFCertIDImpl
00025 {
00026 CPKIFAlgorithmIdentifierPtr m_hashAlg;
00027 CPKIFBufferPtr m_issuerNameHash;
00028 CPKIFBufferPtr m_issuerKeyHash;
00029 CPKIFStringPtr m_serialNumber;
00030 };
00032
00041 CPKIFCertID::CPKIFCertID()
00042 :m_impl (new CPKIFCertIDImpl)
00043 {
00044 LOG_STRING_DEBUG("CPKIFCertID::CPKIFCertID()", TOOLKIT_OCSP_ASN, 0, this);
00045 }
00054 CPKIFCertID::CPKIFCertID(
00056 const CPKIFBufferPtr& cid)
00057 :m_impl (new CPKIFCertIDImpl)
00058 {
00059 LOG_STRING_DEBUG("CPKIFCertID::CPKIFCertID(CertID& cid)", TOOLKIT_OCSP_ASN, 0, this);
00060
00061 CACASNWRAPPER_CREATE(CertID, objPDU);
00062 objPDU.Decode(cid->GetBuffer(), cid->GetLength());
00063
00064 CPKIFOIDPtr algOID(new CPKIFOID(objPDU->hashAlgorithm.algorithm.subid, objPDU->hashAlgorithm.algorithm.numids));
00065
00066 CPKIFBufferPtr paramBuf;
00067 if(objPDU->hashAlgorithm.m.parametersPresent)
00068 {
00069 paramBuf = CPKIFBufferPtr(new CPKIFBuffer(objPDU->hashAlgorithm.parameters.data, objPDU->hashAlgorithm.parameters.numocts));
00070
00071 }
00072
00073 CPKIFAlgorithmIdentifierPtr tmpHA(new CPKIFAlgorithmIdentifier(algOID, paramBuf));
00074
00075 m_impl->m_hashAlg = tmpHA;
00076
00077 CPKIFBufferPtr tmpINH(new CPKIFBuffer(objPDU->issuerNameHash.data, objPDU->issuerNameHash.numocts));
00078 m_impl->m_issuerNameHash = tmpINH;
00079
00080 CPKIFBufferPtr tmpIKH(new CPKIFBuffer(objPDU->issuerKeyHash.data, objPDU->issuerKeyHash.numocts));
00081 m_impl->m_issuerKeyHash = tmpIKH;
00082
00083 CPKIFStringPtr tmpSN(new std::string(objPDU->serialNumber));
00084 m_impl->m_serialNumber = tmpSN;
00085 }
00093 CPKIFCertID::~CPKIFCertID()
00094 {
00095 LOG_STRING_DEBUG("CPKIFCertID::~CPKIFCertID()", TOOLKIT_OCSP_ASN, 0, this);
00096
00097 delete m_impl;
00098 m_impl = NULL;
00099 }
00100
00108 CPKIFBufferPtr CPKIFCertID::GetIssuerNameHash() const
00109 {
00110 return m_impl->m_issuerNameHash;
00111 }
00119 void CPKIFCertID::SetIssuerNameHash(
00121 CPKIFBufferPtr& issuerNameHash)
00122 {
00123 m_impl->m_issuerNameHash = issuerNameHash;
00124 }
00125
00133 CPKIFBufferPtr CPKIFCertID::GetIssuerKeyHash() const
00134 {
00135 return m_impl->m_issuerKeyHash;
00136 }
00144 void CPKIFCertID::SetIssuerKeyHash(
00146 CPKIFBufferPtr& issuerKeyHash)
00147 {
00148 m_impl->m_issuerKeyHash = issuerKeyHash;
00149 }
00158 const char* CPKIFCertID::GetSerialNumber() const
00159 {
00160 if(m_impl->m_serialNumber == (std::string*)NULL)
00161 return NULL;
00162 else
00163 return m_impl->m_serialNumber->c_str();
00164 }
00173 void CPKIFCertID::SetSerialNumber(
00175 CPKIFStringPtr& serialNumber)
00176 {
00177 m_impl->m_serialNumber = serialNumber;
00178 }
00186 CPKIFAlgorithmIdentifierPtr CPKIFCertID::GetHashAlg() const
00187 {
00188 return m_impl->m_hashAlg;
00189 }
00197 void CPKIFCertID::SetHashAlg(
00199 CPKIFAlgorithmIdentifierPtr& hashAlg)
00200 {
00201 m_impl->m_hashAlg = hashAlg;
00202 }
00203