PathResults.cpp

Go to the documentation of this file.
00001 
00009 #include "PathResults.h"
00010 #include "ToolkitUtils.h"
00011 
00012 #include "PKIFCertificateNodeEntry.h"
00013 #include "PKIFCertStatus.h"
00014 #include "Certificate.h"
00015 #include "AlgorithmIdentifier.h"
00016 #include "OID.h"
00017 #include "PolicyInformation.h"
00018 
00019 #include "components.h"
00020 
00021 #include <map>
00022 using namespace std;
00024 struct CPKIFPathValidationResultsImpl
00025 {
00026     bool m_bBasicChecks;
00027     bool m_bExtensionHandlerChecks;
00028     bool m_bCertSignaturesVerified;
00029     RevocationStatus m_revStatus;
00030     //CPKIFCRLEntryPtr m_crlEntry;
00031     CPKIFCertStatusPtr m_certStatus;
00032 
00033     IPKIFTrustAnchorPtr m_trustAnchor;
00034 
00035     bool m_bTargetIsTrustAnchor;
00036 
00037     CPKIFAlgorithmIdentifierPtr m_wp;
00038 
00039     int m_nErrorCode;
00040     bool m_bExplicitPolicyIndicator;
00041 
00042     vector<CPKIFPolicyInformationListPtr>* m_authSet;
00043     CPKIFPolicyInformationListPtr m_userSet;
00044     CPKIFCertificateNodeEntryPtr m_cert;
00045 
00046     std::map<string, IPKIFExtHandlerDataPtr> m_extHandlerData;
00047 
00048     bool m_bPermittedSubtreesSet;
00049     CPKIFGeneralSubtreeListPtr m_permitted;
00050     bool m_bExcludedSubtreesSet;
00051     CPKIFGeneralSubtreeListPtr m_excluded;
00052     bool m_bPendingExplicitPolicySet;
00053     bool m_bPendingPolicyMappingSet;
00054     bool m_bPendingAnyPolicySet;
00055     bool m_bPendingPathLengthSet;
00056     int m_nPendingExplicitPolicy;
00057     int m_nPendingPolicyMapping;
00058     int m_nPendingAnyPolicy;
00059     int m_nPendingPathLength;
00060 };
00062 
00072 bool CPKIFPathValidationResults::GetBasicChecksSuccessfullyPerformed() const 
00073 {
00074     return m_impl->m_bBasicChecks;
00075 }
00076 
00085 void CPKIFPathValidationResults::SetBasicChecksSuccessfullyPerformed(
00087         bool b)
00088 {
00089     m_impl->m_bBasicChecks = b;
00090 }
00091 
00101 bool CPKIFPathValidationResults::GetCertSignaturesVerified() const 
00102 {
00103     return m_impl->m_bCertSignaturesVerified;
00104 }
00105 
00114 void CPKIFPathValidationResults::SetCertSignaturesVerified(
00116     bool b) 
00117 {
00118     m_impl->m_bCertSignaturesVerified = b;
00119 }
00128 bool CPKIFPathValidationResults::GetTargetIsTrustAnchor() const 
00129 {
00130     return m_impl->m_bTargetIsTrustAnchor;
00131 }
00141 void CPKIFPathValidationResults::SetTargetIsTrustAnchor(
00143     bool b) 
00144 {
00145     m_impl->m_bTargetIsTrustAnchor = b;
00146 }
00147 
00157 RevocationStatus CPKIFPathValidationResults::GetRevocationStatusMostSevere() const 
00158 {
00159     return m_impl->m_revStatus;
00160 }
00169 void CPKIFPathValidationResults::SetRevocationStatusMostSevere(
00172         RevocationStatus r) 
00173 {
00174     m_impl->m_revStatus = r;
00175 }
00176 
00188 CPKIFCertStatusPtr CPKIFPathValidationResults::GetCertStatus() const 
00189 {
00190     return m_impl->m_certStatus;
00191 }
00192 
00201 void CPKIFPathValidationResults::SetCertStatus(
00204     CPKIFCertStatusPtr& certStatus)
00205 {
00206     m_impl->m_certStatus = certStatus;
00207 }
00224 const vector<CPKIFPolicyInformationListPtr>* CPKIFPathValidationResults::GetAuthorityConstrainedSetTable() 
00225 {
00226     return m_impl->m_authSet;
00227 }
00239 void CPKIFPathValidationResults::GetUserConstrainedSet(
00241     CPKIFPolicyInformationListPtr& userSet) 
00242 {
00243     userSet = m_impl->m_userSet;
00244 }
00245 
00257 void CPKIFPathValidationResults::SetUserConstrainedSet(
00259     CPKIFPolicyInformationListPtr& userSet) 
00260 {
00261     m_impl->m_userSet = userSet;
00262 }
00272 bool CPKIFPathValidationResults::GetExplicitPolicyIndicator() const 
00273 {
00274     return m_impl->m_bExplicitPolicyIndicator;
00275 }
00285 void CPKIFPathValidationResults::SetExplicitPolicyIndicator(
00288     bool e) 
00289 {
00290     m_impl->m_bExplicitPolicyIndicator = e;
00291 }
00292 
00293 //  f) cert being processed when failure occurred
00294 
00303 void CPKIFPathValidationResults::SetCertificate(
00306     CPKIFCertificateNodeEntryPtr& cert) 
00307 {
00308     m_impl->m_cert = cert;
00309 }
00320 CPKIFCertificateNodeEntryPtr CPKIFPathValidationResults::GetCertificate() const 
00321 {
00322     return m_impl->m_cert;
00323 }
00324 
00325 //working parameters
00334 void CPKIFPathValidationResults::SetWorkingParams(
00337     CPKIFAlgorithmIdentifierPtr& wp) 
00338 {
00339     m_impl->m_wp = wp;
00340 }
00341 
00353 CPKIFAlgorithmIdentifierPtr CPKIFPathValidationResults::GetWorkingParams() const
00354 {
00355     return m_impl->m_wp;
00356 }
00357 
00367 void CPKIFPathValidationResults::SetExtHandlerData(const std::string& id, IPKIFExtHandlerDataPtr& data)
00368 {
00369     m_impl->m_extHandlerData[id] = data;
00370 }
00371 
00381 IPKIFExtHandlerDataPtr CPKIFPathValidationResults::GetExtHandlerData(const std::string& id) const
00382 {
00383     return m_impl->m_extHandlerData[id];
00384 }
00385 
00394 CPKIFPathValidationResults::CPKIFPathValidationResults()
00395 :m_impl(new CPKIFPathValidationResultsImpl)
00396 {
00397     LOG_STRING_DEBUG("CPKIFPathValidationResults::CPKIFPathValidationResults()", TOOLKIT_PATH_MISC, 0, this);
00398 
00399     m_impl->m_authSet = NULL; 
00400     m_impl->m_bExplicitPolicyIndicator=false;
00401     m_impl->m_nErrorCode=0;
00402     m_impl->m_bBasicChecks=false;
00403     m_impl->m_bExtensionHandlerChecks = true;   //assume these pass, since most of the time there aren't any
00404     m_impl->m_bCertSignaturesVerified = false;
00405     m_impl->m_revStatus = NOT_CHECKED;
00406 
00407     m_impl->m_bTargetIsTrustAnchor = false;
00408 
00409     m_impl->m_bPermittedSubtreesSet = false;
00410     m_impl->m_bExcludedSubtreesSet = false;
00411     m_impl->m_bPendingExplicitPolicySet = false;
00412     m_impl->m_bPendingPolicyMappingSet = false;
00413     m_impl->m_bPendingAnyPolicySet = false;
00414     m_impl->m_nPendingExplicitPolicy = -1;
00415     m_impl->m_nPendingPolicyMapping = -1;
00416     m_impl->m_nPendingAnyPolicy = -1;
00417 
00418     m_impl->m_nPendingPathLength = -1;
00419     m_impl->m_bPendingPathLengthSet = false;
00420 
00421 }
00429 CPKIFPathValidationResults::~CPKIFPathValidationResults()
00430 {
00431     LOG_STRING_DEBUG("CPKIFPathValidationResults::~CPKIFPathValidationResults()", TOOLKIT_PATH_MISC, 0, this);
00432 
00433     if(m_impl)
00434     {
00435         if(NULL != m_impl->m_authSet) 
00436             delete m_impl->m_authSet; 
00437         delete m_impl; m_impl = NULL;
00438     }
00439 }
00450 bool CPKIFPathValidationResults::PathSuccessfullyValidated() const 
00451 {
00452     return (GetBasicChecksSuccessfullyPerformed() && 
00453         GetCertSignaturesVerified() && 
00454         (NOT_REVOKED == GetRevocationStatusMostSevere()) &&
00455         GetExtensionHandlerChecksSuccessfullyPerformed()) || GetTargetIsTrustAnchor() ;
00456 }
00466 void CPKIFPathValidationResults::GetAuthorityConstrainedSet(
00470     CPKIFPolicyInformationListPtr& authSet)
00471 {
00472     LOG_STRING_DEBUG("CPKIFPathValidationResults::GetAuthorityConstrainedSet", TOOLKIT_PATH_MISC, 0, this);
00473 
00474     CPKIFPolicyInformationListPtr tmp(new CPKIFPolicyInformationList);
00475 
00476     CPKIFOIDPtr anyPolicyOID(new CPKIFOID(CPKIFStringPtr(new std::string("2.5.29.32.0"))));
00477     CPKIFPolicyInformationPtr anyPolicy(new CPKIFPolicyInformation(anyPolicyOID));
00478 
00479 
00480     if(NULL == m_impl->m_authSet || m_impl->m_authSet->empty())
00481     {
00482         authSet = tmp;
00483         return;
00484     }
00485     else if(*m_impl->m_authSet->front()->back() == *anyPolicy)
00486     {
00487         tmp->push_back(anyPolicy);
00488         authSet = tmp;
00489         return;
00490     }
00491     else
00492     {
00493         vector<CPKIFPolicyInformationListPtr>::const_iterator authSetPos;
00494         vector<CPKIFPolicyInformationListPtr>::const_iterator authSetEnd = m_impl->m_authSet->end();
00495         for(authSetPos = m_impl->m_authSet->begin(); authSetPos != authSetEnd; ++authSetPos)
00496         {
00497             CPKIFPolicyInformationList::const_iterator authSetPolPos;
00498             CPKIFPolicyInformationList::const_iterator authSetPolEnd = (*authSetPos)->end();
00499             for(authSetPolPos = (*authSetPos)->begin(); authSetPolPos != authSetPolEnd; ++authSetPolPos)
00500             {
00501                 if(!(*(*authSetPolPos) == *anyPolicy))
00502                 {
00503                     tmp->push_back(*authSetPolPos);
00504                     break;
00505                 }
00506             }
00507         }
00508 
00509         authSet = tmp;
00510         return;
00511     }
00512 }
00521 void CPKIFPathValidationResults::SetAuthorityConstrainedSet(
00525 
00526     vector<CPKIFPolicyInformationListPtr>* authSet) 
00527 {
00528     LOG_STRING_DEBUG("CPKIFPathValidationResults::SetAuthorityConstrainedSet", TOOLKIT_PATH_MISC, 0, this);
00529 
00530     if(NULL != m_impl->m_authSet) 
00531     {
00532         delete m_impl->m_authSet; m_impl->m_authSet = NULL;
00533     }
00534     m_impl->m_authSet = authSet;
00535 }
00545 int CPKIFPathValidationResults::DiagnosticCode() const
00546 {
00547     LOG_STRING_DEBUG("CPKIFPathValidationResults::DiagnosticCode()", TOOLKIT_PATH_MISC, 0, this);
00548 
00549     if(m_impl->m_cert == (CPKIFCertificateNodeEntry*)NULL)
00550         return 0;
00551 
00552     CPKIFCertStatusPtr status = m_impl->m_cert->GetStatus();
00553     if(status == (CPKIFCertStatus*)NULL)
00554         return 0;
00555 
00556     return status->GetDiagnosticCode();
00557 }
00558 
00569 bool CPKIFPathValidationResults::GetExtensionHandlerChecksSuccessfullyPerformed() const 
00570 {
00571     return m_impl->m_bExtensionHandlerChecks;
00572 }
00573 
00584 void CPKIFPathValidationResults::SetExtensionHandlerChecksSuccessfullyPerformed(
00586         bool b)
00587 {
00588     //only accept the new value if the previous value was true
00589     if(m_impl->m_bExtensionHandlerChecks)
00590         m_impl->m_bExtensionHandlerChecks = b;
00591 }
00592 
00601 IPKIFTrustAnchorPtr CPKIFPathValidationResults::GetTrustAnchor() const
00602 {
00603     return m_impl->m_trustAnchor;
00604 }
00605 
00614 void CPKIFPathValidationResults::SetTrustAnchor(IPKIFTrustAnchorPtr& ta)
00615 {
00616     m_impl->m_trustAnchor = ta;
00617 }
00618 
00619 bool CPKIFPathValidationResults::IsPermittedSubtreesSet()
00620 {
00621     return m_impl->m_bPermittedSubtreesSet;
00622 }
00623 
00624 CPKIFGeneralSubtreeListPtr CPKIFPathValidationResults::GetPermittedSubtrees() const
00625 {
00626     return m_impl->m_permitted;
00627 }
00628 
00629 void CPKIFPathValidationResults::SetPermittedSubtrees(CPKIFGeneralSubtreeListPtr& subtree)
00630 {
00631     m_impl->m_permitted = subtree;
00632     m_impl->m_bPermittedSubtreesSet = true;
00633 }
00634 bool CPKIFPathValidationResults::IsExcludedSubtreesSet()
00635 {
00636     return m_impl->m_bExcludedSubtreesSet;
00637 }
00638 
00639 CPKIFGeneralSubtreeListPtr CPKIFPathValidationResults::GetExcludedSubtrees() const
00640 {
00641     return m_impl->m_excluded;
00642 }
00643 
00644 void CPKIFPathValidationResults::SetExcludedSubtrees(CPKIFGeneralSubtreeListPtr& subtree)
00645 {
00646     m_impl->m_excluded = subtree;
00647     m_impl->m_bExcludedSubtreesSet = true;
00648 }
00649 
00650 bool CPKIFPathValidationResults::IsPendingExplicitPolicySet()
00651 {
00652     return m_impl->m_bPendingExplicitPolicySet;
00653 }
00654 
00655 int CPKIFPathValidationResults::GetPendingExplicitPolicy() const
00656 {
00657     return m_impl->m_nPendingExplicitPolicy;
00658 }
00659 
00660 void CPKIFPathValidationResults::SetPendingExplicitPolicy(int skipCerts)
00661 {
00662     m_impl->m_bPendingExplicitPolicySet = true;
00663     m_impl->m_nPendingExplicitPolicy = skipCerts;
00664 }
00665 
00666 bool CPKIFPathValidationResults::IsPendingPolicyMappingSet()
00667 {
00668     return m_impl->m_bPendingPolicyMappingSet;
00669 }
00670 
00671 int CPKIFPathValidationResults::GetPendingPolicyMapping() const
00672 {
00673     return m_impl->m_nPendingPolicyMapping;
00674 }
00675 
00676 void CPKIFPathValidationResults::SetPendingPolicyMapping(int skipCerts)
00677 {
00678     m_impl->m_nPendingPolicyMapping = skipCerts;
00679     m_impl->m_bPendingPolicyMappingSet = true;
00680 }
00681 
00682 bool CPKIFPathValidationResults::IsPendingAnyPolicySet()
00683 {
00684     return m_impl->m_bPendingAnyPolicySet;
00685 }
00686 
00687 int CPKIFPathValidationResults::GetPendingAnyPolicy() const
00688 {
00689     return m_impl->m_nPendingAnyPolicy;
00690 }
00691 
00692 void CPKIFPathValidationResults::SetPendingAnyPolicy(int skipCerts)
00693 {
00694     m_impl->m_nPendingAnyPolicy = skipCerts;
00695     m_impl->m_bPendingAnyPolicySet = true;
00696 }
00697 
00698 bool CPKIFPathValidationResults::IsPendingPathLengthSet()
00699 {
00700     return m_impl->m_bPendingPathLengthSet;
00701 }
00702 
00703 int CPKIFPathValidationResults::GetPendingPathLength() const
00704 {
00705     return m_impl->m_nPendingPathLength;
00706 }
00707 
00708 void CPKIFPathValidationResults::SetPendingPathLength(int skipCerts)
00709 {
00710     m_impl->m_nPendingPathLength = skipCerts;
00711     m_impl->m_bPendingPathLengthSet = true;
00712 }

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