00001 00009 #include "NodeNotInNodeListAndNotIgnoredAndIssuedBy.h" 00010 #include "Certificate.h" 00011 #include "PKIFCertificateNodeEntry.h" 00012 #include "PKIFPathSettings.h" 00013 #include "Name.h" 00014 #include "IPKIFNameAndKey.h" 00015 #include "PKIFNameAndKeyWithScore.h" 00016 00017 //implemented in BuilderUtils.cpp 00018 bool CheckPolicies(CPKIFCertificatePtr& subjectCert, CPKIFCertificatePtr& issuerCert, CPKIFPathSettingsPtr& settings); 00019 bool CheckKIDsAndSignatures(CPKIFCertificatePtr& subjectCert, CPKIFCertificatePtr& issuerCert); 00020 00028 bool NodeNotInNodeListAndNotIgnoredAndIssuedBy::operator ()( 00030 const CPKIFCertificateNodeEntryPtr& test) 00031 { 00032 //if the test node is ignored - return false now 00033 if(test->GetIgnore() || test->GetHardIgnore()) 00034 return false; 00035 00036 CPKIFCertificatePtr testCert = test->GetCert(); 00037 IPKIFNameAndKey* testNameAndKey = dynamic_cast<IPKIFNameAndKey*>(&(*testCert)); 00038 00039 //else walk the node list and see if the test node is in the list 00040 if(m_nodeList) 00041 { 00042 CPKIFCertificateNodeList::iterator currentNode; 00043 CPKIFCertificateNodeList::iterator end = m_nodeList->end(); 00044 for(currentNode = m_nodeList->begin(); currentNode != end; ++currentNode) 00045 { 00046 CPKIFCertificatePtr curCert = (*currentNode)->GetCert(); 00047 IPKIFNameAndKey* curNodeNameAndKey = dynamic_cast<IPKIFNameAndKey*>(&(*curCert)); 00048 00049 //if it is in the list - return false 00050 if(*curNodeNameAndKey == *testNameAndKey) 00051 { 00052 test->SetIgnore(); 00053 return false; 00054 } 00055 00056 if(testNameAndKey->SameDNSameKey(*curNodeNameAndKey)) 00057 { 00058 test->SetIgnore(); 00059 return false; 00060 } 00061 } 00062 } 00063 00064 //if the test node is not in the list see if it is issued by m_issuer 00065 if(*m_issuerName == *testNameAndKey->GetIssuerName()) 00066 { 00067 //XXX***TEMPORARILY COMMENTED OUT PENDING FURTHER WORK ON FILTERING 00068 //if(m_settings->GetUseValidatorFilterWhenBuilding()) 00069 //{ 00070 // if(!CheckPolicies(testCert, m_issuer, m_settings)) return false; //Avoid proceeding if policy checks are doomed 00071 // if(!CheckKIDsAndSignatures(testCert, m_issuer)) return false; //Avoid proceeding if signature checks are doomed 00072 //} 00073 return true; 00074 } 00075 else 00076 return false; 00077 } 00078 00086 bool NodeNotInNodeListAndNotIgnoredAndIssuedBy::operator()(const CPKIFNameAndKeyWithScorePtr& test) 00087 { 00088 //if the test node is ignored - return false now 00089 if(test->GetIgnore()) 00090 return false; 00091 00092 IPKIFNameAndKeyPtr testNameAndKey = test->GetNameAndKey(); 00093 00094 //else walk the node list and see if the test node is in the list 00095 if(m_nkNodeList) 00096 { 00097 CPKIFNameAndKeyWithScoreList::iterator currentNode; 00098 CPKIFNameAndKeyWithScoreList::iterator end = m_nkNodeList->end(); 00099 for(currentNode = m_nkNodeList->begin(); currentNode != end; ++currentNode) 00100 { 00101 //if it is in the list - return false 00102 if(*(*currentNode) == *testNameAndKey) 00103 return false; 00104 00105 if(testNameAndKey->SameDNSameKey(*(*currentNode)->GetNameAndKey())) 00106 return false; 00107 } 00108 } 00109 00110 //if the test node is not in the list see if it is issued by m_issuer 00111 if(*m_issuerName == *testNameAndKey->GetIssuerName()) 00112 { 00113 //XXX***TEMPORARILY COMMENTED OUT PENDING FURTHER WORK ON FILTERING 00114 //if(m_settings->GetUseValidatorFilterWhenBuilding()) 00115 //{ 00116 // if(!CheckPolicies(testCert, m_issuer, m_settings)) return false; //Avoid proceeding if policy checks are doomed 00117 // if(!CheckKIDsAndSignatures(testCert, m_issuer)) return false; //Avoid proceeding if signature checks are doomed 00118 //} 00119 return true; 00120 } 00121 else 00122 return false; 00123 } 00124 00132 void NodeNotInNodeListAndNotIgnoredAndIssuedBy::SetNodeList( 00134 CPKIFCertificateNodeList* nodeList) 00135 { 00136 m_nodeList = nodeList; 00137 } 00145 void NodeNotInNodeListAndNotIgnoredAndIssuedBy::SetNodeList( 00147 CPKIFNameAndKeyWithScoreList* nodeList) 00148 { 00149 m_nkNodeList = nodeList; 00150 } 00151 //void NodeNotInNodeListAndNotIgnoredAndIssuedBy::SetIssuer(CPKIFNamePtr& issuer){m_issuer = issuer;} 00159 void NodeNotInNodeListAndNotIgnoredAndIssuedBy::SetIssuer( 00161 IPKIFNameAndKey* issuer) 00162 { 00163 m_issuer = issuer; 00164 m_issuerName = m_issuer->GetSubjectName(); 00165 } 00173 void NodeNotInNodeListAndNotIgnoredAndIssuedBy::SetPathSettings( 00175 CPKIFPathSettingsPtr& settings) 00176 { 00177 m_settings = settings; 00178 } 00179