00001 00009 #include "IssuingDistributionPoint.h" 00010 #include "DistributionPointName.h" 00011 #include "OID.h" 00012 #include "Buffer.h" 00013 #include "PKIFException.h" 00014 00015 #include "ASN1Helper.h" 00016 #include "PKIX1Implicit88.h" 00017 #include "PKIX1Explicit88.h" 00018 00020 00021 struct CPKIFIssuingDistributionPointImpl 00022 { 00023 bool m_bOnlyUserCerts; 00024 bool m_bOnlyAuthCerts; 00025 bool m_bOnlySomeReasons; 00026 bool m_bIndirectCRL; 00027 bool m_bOnlyAttrCerts; 00028 CPKIFReasonFlagsPtr m_reasons; 00029 CPKIFDistributionPointNamePtr m_dp; 00030 CPKIFBufferPtr m_value; 00031 bool m_extModified; 00032 }; 00033 00035 00036 char CPKIFIssuingDistributionPoint::extOID[] = "2.5.29.28"; 00037 00038 //DOCUMENT LATER 00046 CPKIFIssuingDistributionPoint::CPKIFIssuingDistributionPoint() 00047 : m_impl (new CPKIFIssuingDistributionPointImpl) 00048 { 00049 m_impl->m_bOnlyUserCerts = false; 00050 m_impl->m_bOnlyAuthCerts = false; 00051 m_impl->m_bOnlySomeReasons = false; 00052 m_impl->m_bIndirectCRL = false; 00053 m_impl->m_bOnlyAttrCerts = false; 00054 } 00065 //CPKIFIssuingDistributionPoint::CPKIFIssuingDistributionPoint( 00066 // //![in] Reference to an internal structure representation of the extension containing information used to construct the object 00067 // const CACX509V3Extension& ext) 00068 // : CPKIFX509Extension(ext), m_impl (new CPKIFIssuingDistributionPointImpl) 00069 //{ 00070 // CACASNWRAPPER_CREATE(CACX509V3IssuingDistributionPoint, objPDU); 00071 // objPDU.Decode(ext.extnValue.data, ext.extnValue.numocts); 00072 // 00073 // m_impl->m_bIndirectCRL = FALSE == objPDU->indirectCRL ? false : true; 00074 // m_impl->m_bOnlyUserCerts = FALSE == objPDU->onlyContainsUserCerts ? false : true; 00075 // m_impl->m_bOnlyAuthCerts = FALSE == objPDU->onlyContainsCACerts ? false : true; 00076 // m_impl->m_bOnlySomeReasons = objPDU->m.onlySomeReasonsPresent; 00077 // 00078 // //updated 12/3/2003 00079 // m_impl->m_bOnlyAttrCerts = FALSE == objPDU->onlyContainsAttributeCerts ? false : true; 00080 // 00081 // if(objPDU->m.distributionPointPresent) 00082 // { 00083 // CPKIFDistributionPointNamePtr tmp(new CPKIFDistributionPointName(objPDU->distributionPoint)); 00084 // m_impl->m_dp = tmp; 00085 // } 00086 //} 00087 00098 CPKIFIssuingDistributionPoint::CPKIFIssuingDistributionPoint( 00099 const bool& criticality, 00100 const CPKIFBufferPtr& ext) 00101 : CPKIFX509Extension (criticality, ext), m_impl (new CPKIFIssuingDistributionPointImpl) 00102 { 00103 CACASNWRAPPER_CREATE(CACX509V3IssuingDistributionPoint, objPDU); 00104 objPDU.Decode(ext->GetBuffer(), ext->GetLength()); 00105 00106 m_impl->m_bIndirectCRL = FALSE == objPDU->indirectCRL ? false : true; 00107 m_impl->m_bOnlyUserCerts = FALSE == objPDU->onlyContainsUserCerts ? false : true; 00108 m_impl->m_bOnlyAuthCerts = FALSE == objPDU->onlyContainsCACerts ? false : true; 00109 m_impl->m_bOnlySomeReasons = objPDU->m.onlySomeReasonsPresent; 00110 if(m_impl->m_bOnlySomeReasons) 00111 { 00112 CPKIFReasonFlagsPtr newRF(new CPKIFReasonFlags); 00113 if( objPDU->onlySomeReasons.data[BytXCACX509V3unused] & BitMCACX509V3unused ) 00114 newRF->SetUnused(); 00115 if( objPDU->onlySomeReasons.data[BytXCACX509V3keyCompromise ] & BitMCACX509V3keyCompromise) 00116 newRF->SetKeyCompromise(); 00117 if( objPDU->onlySomeReasons.data[BytXCACX509V3cACompromise ] & BitMCACX509V3cACompromise) 00118 newRF->SetCACompromise(); 00119 if( objPDU->onlySomeReasons.data[BytXCACX509V3affiliationChanged] & BitMCACX509V3affiliationChanged) 00120 newRF->SetAffiliationChanged(); 00121 if( objPDU->onlySomeReasons.data[BytXCACX509V3superseded] & BitMCACX509V3superseded ) 00122 newRF->SetSuperseded(); 00123 if( objPDU->onlySomeReasons.data[BytXCACX509V3cessationOfOperation] & BitMCACX509V3cessationOfOperation ) 00124 newRF->SetCessationOfOperation(); 00125 if( objPDU->onlySomeReasons.data[BytXCACX509V3certificateHold] & BitMCACX509V3certificateHold ) 00126 newRF->SetCertificateHold(); 00127 if( objPDU->onlySomeReasons.data[BytXCACX509V3privilegeWithdrawn] & BitMCACX509V3privilegeWithdrawn ) 00128 newRF->SetPrivilegeWithdrawn(); 00129 if(objPDU->onlySomeReasons.numbits > 8) 00130 { 00131 if( objPDU->onlySomeReasons.data[BytXCACX509V3aACompromise] & BitMCACX509V3aACompromise ) 00132 newRF->SetAACompromise(); 00133 } 00134 00135 m_impl->m_reasons = newRF; 00136 } 00137 00138 //updated 12/3/2003 00139 m_impl->m_bOnlyAttrCerts = FALSE == objPDU->onlyContainsAttributeCerts ? false : true; 00140 00141 if(objPDU->m.distributionPointPresent) 00142 { 00143 CPKIFBufferPtr tmpBuf(new CPKIFBuffer(objPDU->distributionPoint.data, objPDU->distributionPoint.numocts)); 00144 CPKIFDistributionPointNamePtr tmp(new CPKIFDistributionPointName(tmpBuf)); 00145 m_impl->m_dp = tmp; 00146 } 00147 00148 m_impl->m_value = ext; 00149 m_impl->m_extModified = false; 00150 } 00151 00159 CPKIFDistributionPointNamePtr CPKIFIssuingDistributionPoint::DistributionPoint() const {return m_impl->m_dp;} 00169 bool CPKIFIssuingDistributionPoint::OnlyContainsUserCerts() const {return m_impl->m_bOnlyUserCerts;} 00179 bool CPKIFIssuingDistributionPoint::OnlyContainsAuthorityCerts() const {return m_impl->m_bOnlyAuthCerts;} 00189 bool CPKIFIssuingDistributionPoint::OnlySomeReasons() const {return m_impl->m_bOnlySomeReasons;} 00199 bool CPKIFIssuingDistributionPoint::IndirectCRL() const {return m_impl->m_bIndirectCRL;} 00209 bool CPKIFIssuingDistributionPoint::OnlyContainsAttributeCerts() const {return m_impl->m_bOnlyAttrCerts;} 00217 bool CPKIFIssuingDistributionPoint::operator==( 00219 const CPKIFIssuingDistributionPoint& idp) 00220 { 00221 if(OnlyContainsUserCerts() != idp.OnlyContainsUserCerts()) 00222 return false; 00223 if(OnlyContainsAuthorityCerts() != idp.OnlyContainsAuthorityCerts()) 00224 return false; 00225 if(OnlySomeReasons() != idp.OnlySomeReasons()) 00226 return false; 00227 if(IndirectCRL() != idp.IndirectCRL()) 00228 return false; 00229 if(OnlyContainsAttributeCerts() != idp.OnlyContainsAttributeCerts()) 00230 return false; 00231 00232 CPKIFDistributionPointNamePtr rhsDP = idp.DistributionPoint(); 00233 if(m_impl->m_dp == (CPKIFDistributionPointName*)NULL && rhsDP != (CPKIFDistributionPointName*)NULL) 00234 return false; 00235 else if(m_impl->m_dp != (CPKIFDistributionPointName*)NULL && rhsDP == (CPKIFDistributionPointName*)NULL) 00236 return false; 00237 else if(m_impl->m_dp == (CPKIFDistributionPointName*)NULL && rhsDP == (CPKIFDistributionPointName*)NULL)//added 5/3/2004 00238 return true; 00239 else if(!(*m_impl->m_dp == *rhsDP)) 00240 return false; 00241 00242 return true; 00243 } 00251 CPKIFIssuingDistributionPoint::~CPKIFIssuingDistributionPoint() 00252 { 00253 if(m_impl) 00254 { 00255 delete m_impl; m_impl = NULL; 00256 } 00257 } 00265 const CPKIFOIDPtr CPKIFIssuingDistributionPoint::oid() const 00266 { 00267 //added static variable for copying instead of string creation each call 00268 static CPKIFOID staticOID(extOID); 00269 //CPKIFOIDPtr tmp(new CPKIFOID(new std::string(extOID))); 00270 static CPKIFOIDPtr tmp(new CPKIFOID(staticOID)); 00271 return tmp; 00272 } 00280 CPKIFReasonFlagsPtr CPKIFIssuingDistributionPoint::GetReasons() const 00281 { 00282 return m_impl->m_reasons; 00283 } 00284 00292 CPKIFBufferPtr CPKIFIssuingDistributionPoint::value() const 00293 { 00294 CPKIFBufferPtr rv = m_impl->m_value; 00295 if(m_impl->m_value == (CPKIFBuffer*)NULL || m_impl->m_extModified) 00296 { 00297 //XXX ENCODE HERE and set rv if necessary 00298 } 00299 00300 return rv; 00301 }