RevocationInfo.cpp

Go to the documentation of this file.
00001 
00011 #include "CRL.h"
00012 #include "RevocationInfo.h"
00013 #include "PKIFSCVPErrors.h"
00014 #include "SCVPException.h"
00015 #include "ToolkitUtils.h"
00016 #include "ASN1Helper.h"
00017 #include "SCVP.h"
00018 
00020 
00021 struct CPKIFRevocationInfoImpl 
00022 {
00023     CPKIFCRLPtr m_crl;
00024     CPKIFCRLPtr m_deltaCRL;
00025     CPKIFBufferPtr m_ocsp;
00026     CPKIFOIDPtr m_riType;
00027     CPKIFBufferPtr m_riValue;
00028 };
00030 
00038 CPKIFRevocationInfo::CPKIFRevocationInfo() :m_impl(new CPKIFRevocationInfoImpl)
00039 {
00040     LOG_STRING_DEBUG("CPKIFRevocationInfo::CPKIFRevocationInfo()", TOOLKIT_SCVP_ASN, 0, this);
00041 
00042 }
00043 
00054 CPKIFRevocationInfo::CPKIFRevocationInfo(
00056     const CPKIFBufferPtr& revInfo)
00057   :m_impl (new CPKIFRevocationInfoImpl)
00058 {
00059     if(revInfo == (CPKIFBuffer*)NULL || 0 == revInfo->GetLength())
00060     {
00061         throw CPKIFSCVPException(TOOLKIT_SCVP_ASN, COMMON_INVALID_INPUT);
00062     }
00063 
00064     CACASNWRAPPER_CREATE(RevocationInfo, objPDU);
00065     objPDU.Decode(revInfo->GetBuffer(), revInfo->GetLength());
00066 
00067     if(objPDU->t == T_RevocationInfo_crl)
00068     {
00069         CACASNWRAPPER_CREATE(CACX509V3CertificateList, crlObjPDU);
00070         ASN1OpenType* crlEncoded = NULL;
00071         crlEncoded = crlObjPDU.Encode(objPDU->u.crl);
00072         
00073         CPKIFCRLPtr tmpCrl(new CPKIFCRL());
00074         tmpCrl->Decode(crlEncoded->data, crlEncoded->numocts);
00075 
00076 
00077         if(crlEncoded != NULL)
00078             delete crlEncoded;
00079         
00080 
00081         m_impl->m_crl = tmpCrl;
00082     }
00083     else if(objPDU->t == T_RevocationInfo_delta_crl)
00084     {
00085 
00086         CACASNWRAPPER_CREATE(CACX509V3CertificateList, deltacrlObjPDU);
00087         ASN1OpenType* deltacrlEncoded = NULL;
00088         deltacrlEncoded = deltacrlObjPDU.Encode(objPDU->u.delta_crl);
00089         
00090         CPKIFCRLPtr tmpCrl(new CPKIFCRL());
00091         tmpCrl->Decode(deltacrlEncoded->data, deltacrlEncoded->numocts);
00092 
00093 
00094         if(deltacrlEncoded != NULL)
00095             delete deltacrlEncoded;
00096         
00097         m_impl->m_deltaCRL = tmpCrl;
00098     }
00099     else if(objPDU->t == T_RevocationInfo_ocsp)
00100     {
00101 
00102         CACASNWRAPPER_CREATE(OCSPResponse, ocspRespObjPDU);
00103         ASN1OpenType* ocspRespEncoded = NULL;
00104         ocspRespEncoded = ocspRespObjPDU.Encode(objPDU->u.ocsp);
00105         
00106         CPKIFBufferPtr tmpBuf(new CPKIFBuffer(ocspRespEncoded->data, ocspRespEncoded->numocts));
00107         
00108         if(ocspRespEncoded != NULL)
00109             delete ocspRespEncoded;
00110                 
00111         m_impl->m_ocsp = tmpBuf;
00112     }
00113     else if(objPDU->t == T_RevocationInfo_other)
00114     {
00115         CPKIFOIDPtr tmpOID(new CPKIFOID(objPDU->u.other->riType.subid, objPDU->u.other->riType.numids));
00116         m_impl->m_riType = tmpOID;
00117         CPKIFBufferPtr tmpBuf(new CPKIFBuffer(objPDU->u.other->riValue.data, objPDU->u.other->riValue.numocts));
00118         m_impl->m_riValue = tmpBuf;
00119     }
00120 }
00121 
00122 
00130 CPKIFRevocationInfo::~CPKIFRevocationInfo()
00131 {
00132     LOG_STRING_DEBUG("CPKIFRevocationInfo::~CPKIFRevocationInfo()", TOOLKIT_SCVP_ASN, 0, this);
00133 
00134     if (m_impl) {
00135       delete m_impl;
00136     }   
00137 }
00138 
00146 void CPKIFRevocationInfo::SetCRL(
00148     CPKIFCRLPtr& crl)
00149 {
00150     m_impl->m_crl = crl;
00151 
00152     //Unset the other values
00153     CPKIFCRLPtr tmpcrl;
00154     m_impl->m_deltaCRL = tmpcrl;
00155     CPKIFBufferPtr tmpbuff;
00156     m_impl->m_ocsp = tmpbuff;
00157     CPKIFOIDPtr tmpoid;
00158     m_impl->m_riType = tmpoid;
00159     m_impl->m_riValue = tmpbuff;
00160 
00161 }
00169 CPKIFCRLPtr CPKIFRevocationInfo::GetCRL()
00170 {
00171     return m_impl->m_crl;
00172 }
00180 void CPKIFRevocationInfo::SetDeltaCRL(
00182     CPKIFCRLPtr& deltaCRL)
00183 {
00184     m_impl->m_deltaCRL = deltaCRL;
00185 
00186     //Unset the other values
00187     CPKIFCRLPtr tmpcrl;
00188     m_impl->m_crl = tmpcrl;
00189     CPKIFBufferPtr tmpbuff;
00190     m_impl->m_ocsp = tmpbuff;
00191     CPKIFOIDPtr tmpoid;
00192     m_impl->m_riType = tmpoid;
00193     m_impl->m_riValue = tmpbuff;
00194 }
00202 CPKIFCRLPtr CPKIFRevocationInfo::GetDeltaCRL()
00203 {
00204     return m_impl->m_deltaCRL;
00205 }
00213 void CPKIFRevocationInfo::SetOCSPResp(
00215     CPKIFBufferPtr& ocsp)
00216 {
00217     m_impl->m_ocsp = ocsp;
00218 
00219     //Unset the other values
00220     CPKIFCRLPtr tmpcrl;
00221     m_impl->m_crl = tmpcrl;
00222     m_impl->m_deltaCRL = tmpcrl;
00223     CPKIFBufferPtr tmpbuff;
00224     CPKIFOIDPtr tmpoid;
00225     m_impl->m_riType = tmpoid;
00226     m_impl->m_riValue = tmpbuff;
00227 }
00235 CPKIFBufferPtr CPKIFRevocationInfo::GetOCSPResp()
00236 {
00237     return m_impl->m_ocsp;
00238 }
00246 void CPKIFRevocationInfo::SetOtherRevInfo(
00248     CPKIFOIDPtr& riType, 
00250     CPKIFBufferPtr& riValue)
00251 {
00252     m_impl->m_riType = riType;
00253     m_impl->m_riValue = riValue;
00254 
00255     //Unset the other values
00256     CPKIFCRLPtr tmpcrl;
00257     m_impl->m_crl = tmpcrl;
00258     m_impl->m_deltaCRL = tmpcrl;
00259     CPKIFBufferPtr tmpbuff;
00260     m_impl->m_ocsp = tmpbuff;
00261 }
00269 void CPKIFRevocationInfo::GetOtherRevInfo(
00271     CPKIFOIDPtr& riType,
00273     CPKIFBufferPtr& riValue)
00274 {
00275     riType = m_impl->m_riType;
00276     riValue = m_impl->m_riValue;
00277 }
00278 
00286 REVINFOTYPE CPKIFRevocationInfo::GetRevInfoType()
00287 {
00288     if(m_impl->m_crl != (CPKIFCRL*)NULL)
00289     {
00290         return REVINFOTYPE_CRL;
00291     }
00292     else if(m_impl->m_deltaCRL != (CPKIFCRL*)NULL)
00293     {
00294         return REVINFOTYPE_DELTACRL;
00295     }
00296     else if(m_impl->m_ocsp != (CPKIFBuffer*)NULL)
00297     {
00298         return REVINFOTYPE_OCSPRESP;
00299     }
00300     else if(m_impl->m_riValue != (CPKIFBuffer*)NULL)
00301     {
00302         return REVINFOTYPE_OTHER;
00303     }
00304 
00305     return REVINFOTYPE_NONE;
00306 }

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