ACReference.cpp
Go to the documentation of this file.00001
00010 #include "Buffer.h"
00011 #include "ACReference.h"
00012 #include "PKIFSCVPErrors.h"
00013 #include "SCVPException.h"
00014 #include "ToolkitUtils.h"
00015 #include "IPKIFHashContext.h"
00016 #include "SCVP.h"
00017 #include "ASN1Helper.h"
00018 #include "SCVPCertID.h"
00019
00021
00022 struct CPKIFACReferenceImpl
00023 {
00024 CPKIFBufferPtr m_acCert;
00025 CPKIFSCVPCertIDPtr m_sCVPCertID;
00026 };
00027
00029
00037 CPKIFACReference::CPKIFACReference() :m_impl(new CPKIFACReferenceImpl)
00038 {
00039 LOG_STRING_DEBUG("CPKIFACReference::CPKIFACReference()", TOOLKIT_SCVP_ASN, 0, this);
00040
00041 }
00052 CPKIFACReference::CPKIFACReference(
00054 const CPKIFBufferPtr& pkcRef)
00055 :m_impl (new CPKIFACReferenceImpl)
00056 {
00057 if(pkcRef == (CPKIFBuffer*)NULL || 0 == pkcRef->GetLength())
00058 {
00059 throw CPKIFSCVPException(TOOLKIT_SCVP_ASN, COMMON_INVALID_INPUT);
00060 }
00061
00062 CACASNWRAPPER_CREATE(ACReference, objPDU);
00063 objPDU.Decode(pkcRef->GetBuffer(), pkcRef->GetLength());
00064
00065
00066 if(objPDU->t == T_ACReference_attrCert)
00067 {
00068
00069 CACASNWRAPPER_CREATE(AttributeCertificate, acCertObjPDU);
00070 ASN1OpenType* acCertEncoded = NULL;
00071 acCertEncoded = acCertObjPDU.Encode(objPDU->u.attrCert);
00072
00073 CPKIFBufferPtr tmpACCert(new CPKIFBuffer(acCertEncoded->data, acCertEncoded->numocts));
00074
00075
00076 if(acCertEncoded != NULL)
00077 delete acCertEncoded;
00078
00079 m_impl->m_acCert = tmpACCert;
00080 }
00081 else if(objPDU->t == T_ACReference_acRef)
00082 {
00083 CACASNWRAPPER_CREATE(SCVPCertID, objPDU2);
00084 ASN1OpenType* data1 = objPDU2.Encode(objPDU->u.acRef);
00085 CPKIFBufferPtr tmpBuf(new CPKIFBuffer(data1->data, data1->numocts));
00086 CPKIFSCVPCertIDPtr tmpSCVPCertID(new CPKIFSCVPCertID(tmpBuf));
00087
00088 if(NULL != data1)
00089 delete data1;
00090
00091 }
00092
00093 }
00101 CPKIFACReference::~CPKIFACReference()
00102 {
00103 LOG_STRING_DEBUG("CPKIFACReference::~CPKIFACReference()", TOOLKIT_SCVP_ASN, 0, this);
00104
00105 if (m_impl) {
00106 delete m_impl;
00107 }
00108 }
00116 void CPKIFACReference::SetACCert(
00118 CPKIFBufferPtr& acCert)
00119 {
00120 m_impl->m_acCert = acCert;
00121 }
00129 CPKIFBufferPtr CPKIFACReference::GetACCert()
00130 {
00131 return m_impl->m_acCert;
00132 }
00140 void CPKIFACReference::SetSCVPCertID(
00142 CPKIFSCVPCertIDPtr& sCVPCertID)
00143 {
00144 m_impl->m_sCVPCertID = sCVPCertID;
00145 }
00153 CPKIFSCVPCertIDPtr CPKIFACReference::GetSCVPCertID()
00154 {
00155 return m_impl->m_sCVPCertID;
00156 }