NodeInNodeList.cpp
Go to the documentation of this file.00001
00009 #include "NodeInNodeList.h"
00010 #include "PKIFCertificateNodeEntry.h"
00011 #include "Certificate.h"
00012 #include "Name.h"
00013 #include "PKIFNameAndKeyWithScore.h"
00015 struct NodeInNodeListImpl
00016 {
00017 CPKIFCertificateNodeList* m_nodeList;
00018 CPKIFNameAndKeyWithScoreList* m_nodeListNK;
00019 };
00021
00028 NodeInNodeList::NodeInNodeList () : m_impl (new NodeInNodeListImpl)
00029 {
00030 m_impl->m_nodeList = NULL;
00031 m_impl->m_nodeListNK = NULL;
00032 }
00040 NodeInNodeList::NodeInNodeList(const NodeInNodeList& ext)
00041 :m_impl(new NodeInNodeListImpl)
00042 {
00043 m_impl->m_nodeList = ext.m_impl->m_nodeList;
00044 m_impl->m_nodeListNK = ext.m_impl->m_nodeListNK;
00045 }
00053 NodeInNodeList::~NodeInNodeList ()
00054 {
00055 if(m_impl)
00056 {
00057 delete m_impl;
00058 m_impl = 0;
00059 }
00060 }
00061
00062
00071 bool NodeInNodeList::operator ()(const CPKIFCertificateNodeEntryPtr& testNode)
00072 {
00073 CPKIFCertificatePtr test = testNode->GetCert();
00074
00075 if(m_impl->m_nodeList)
00076 {
00077 CPKIFCertificateNodeList::iterator currentNode;
00078 CPKIFCertificateNodeList::iterator end = m_impl->m_nodeList->end();
00079 for(currentNode = m_impl->m_nodeList->begin(); currentNode != end; ++currentNode)
00080 {
00081 CPKIFCertificatePtr tmpCert = (*currentNode)->GetCert();
00082
00083 #ifdef _DEBUG
00084 const char* tmpCertSubject = tmpCert->Subject()->ToString();
00085 const char* testSubject = test->Subject()->ToString();
00086 #endif
00087
00088
00089 if(tmpCert->SameDNSameKey(*test))
00090 return true;
00091 }
00092 }
00093 else if(m_impl->m_nodeListNK)
00094 {
00095 CPKIFNameAndKeyWithScoreList::iterator currentNode;
00096 CPKIFNameAndKeyWithScoreList::iterator end = m_impl->m_nodeListNK->end();
00097 for(currentNode = m_impl->m_nodeListNK->begin(); currentNode != end; ++currentNode)
00098 {
00099 IPKIFNameAndKeyPtr tmpNK = (*currentNode)->GetNameAndKey();
00100
00101 #ifdef _DEBUG
00102 const char* tmpCertSubject = tmpNK->GetSubjectName()->ToString();
00103 const char* testSubject = test->Subject()->ToString();
00104 #endif
00105
00106
00107 if(tmpNK->SameDNSameKey(*test))
00108 return true;
00109 }
00110 }
00111
00112
00113 return false;
00114 }
00122 void NodeInNodeList::SetNodeList(
00124 CPKIFCertificateNodeList* nodeList)
00125 {
00126 m_impl->m_nodeList = nodeList;
00127 }
00128
00136 void NodeInNodeList::SetNodeList(
00138 CPKIFNameAndKeyWithScoreList* nodeList)
00139 {
00140 m_impl->m_nodeListNK = nodeList;
00141 }