CACPathSettings.cpp
Go to the documentation of this file.00001
00009 #include "PKIFPathSettings.h"
00010
00011 #include "ToolkitUtils.h"
00012 #include "components.h"
00013
00014 #include "PKIFTime.h"
00015 #include "Duration.h"
00016 #include "OID.h"
00017 #include "PolicyInformation.h"
00018
00019 #include <iterator>
00021 struct CPKIFPathSettingsImp
00022 {
00023 std::bitset<3> m_indicators;
00024 CPKIFPolicyInformationListPtr m_initPolSet;
00025 bool m_bValidatorFilter;
00026 bool m_freshRevData;
00027 bool m_valTimeNesting;
00028
00029 bool m_bCheckRevStatus;
00030
00031
00032 CPKIFDurationPtr m_duration;
00033 bool m_bRequireSufficientlyRecent;
00034
00035 bool (*m_overrideCallback) (int, CPKIFCertificatePtr&,const CPKIFCertificatePath&);
00036 CPKIFTimePtr m_valTime;
00037
00038
00039 int m_depth;
00040 int m_maxCRLSize;
00041
00042 CPKIFGeneralSubtreeListPtr m_permSubtrees;
00043 CPKIFGeneralSubtreeListPtr m_exclSubtrees;
00044 };
00046
00056 void CPKIFPathSettings::SetUseValidatorFilterWhenBuilding(
00058 bool b)
00059 {
00060 m_impl->m_bValidatorFilter = b;
00061 }
00062
00072 bool CPKIFPathSettings::GetUseValidatorFilterWhenBuilding() const
00073 {
00074 return m_impl->m_bValidatorFilter;
00075 }
00099 CPKIFPathSettings::CPKIFPathSettings(void):m_impl (new CPKIFPathSettingsImp)
00100 {
00101 LOG_STRING_DEBUG("CPKIFPathSettings::CPKIFPathSettings(void)", TOOLKIT_PATH_MISC, 0, this);
00102
00103 m_impl->m_indicators.reset();
00104 m_impl->m_bValidatorFilter = true;
00105 m_impl->m_freshRevData = false;
00106 m_impl->m_overrideCallback = NULL;
00107
00108
00109 m_impl->m_bRequireSufficientlyRecent = false;
00110 CPKIFDurationPtr d(new CPKIFDuration);
00111 m_impl->m_duration = d;
00112 m_impl->m_duration->setSeconds(2592000);
00113
00114 m_impl->m_bCheckRevStatus = true;
00115
00116 m_impl->m_depth = 15;
00117 m_impl->m_maxCRLSize = 5000000;
00118
00119 m_impl->m_valTimeNesting = false;
00120 }
00129 CPKIFPathSettings::~CPKIFPathSettings(void)
00130 {
00131 LOG_STRING_DEBUG("CPKIFPathSettings::~CPKIFPathSettings(void)", TOOLKIT_PATH_MISC, 0, this);
00132 delete m_impl;
00133 m_impl = '\0';
00134 }
00135
00143 CPKIFPathSettings::CPKIFPathSettings(
00145 const CPKIFPathSettings& settings):m_impl (new CPKIFPathSettingsImp)
00146 {
00147 LOG_STRING_DEBUG("CPKIFPathSettings::CPKIFPathSettings(const CPKIFPathSettings& settings)", TOOLKIT_PATH_MISC, 0, this);
00148
00149
00150 m_impl->m_freshRevData = settings.m_impl->m_freshRevData;
00151 m_impl->m_overrideCallback = settings.m_impl->m_overrideCallback;
00152 m_impl->m_bCheckRevStatus = settings.m_impl->m_bCheckRevStatus;
00153
00154 m_impl->m_indicators = settings.m_impl->m_indicators;
00155 m_impl->m_bValidatorFilter = settings.m_impl->m_bValidatorFilter;
00156
00157
00158 CPKIFDurationPtr d(new CPKIFDuration);
00159 m_impl->m_duration = d;
00160 m_impl->m_duration->setSeconds(settings.GetDuration()->asSeconds());
00161
00162 m_impl->m_depth = settings.GetDepth();
00163 m_impl->m_bRequireSufficientlyRecent = settings.GetRequireSufficientlyRecent();
00164
00165
00166 m_impl->m_valTime = settings.m_impl->m_valTime;
00167
00168 if(settings.m_impl->m_initPolSet != (CPKIFPolicyInformationList*)NULL)
00169 {
00170 CPKIFPolicyInformationListPtr newRow(new CPKIFPolicyInformationList);
00171 copy(settings.m_impl->m_initPolSet->begin(),settings.m_impl->m_initPolSet->end(), back_inserter(*newRow));
00172 m_impl->m_initPolSet = newRow;
00173 }
00174 else
00175 {
00176 CPKIFPolicyInformationListPtr newRow;
00177 m_impl->m_initPolSet = newRow;
00178 }
00179
00180 if(settings.m_impl->m_permSubtrees != (CPKIFGeneralSubtreeList*)NULL)
00181 {
00182 CPKIFGeneralSubtreeListPtr newRow(new CPKIFGeneralSubtreeList);
00183 copy(settings.m_impl->m_permSubtrees->begin(),settings.m_impl->m_permSubtrees->end(), back_inserter(*newRow));
00184 m_impl->m_permSubtrees = newRow;
00185 }
00186 else
00187 {
00188 CPKIFGeneralSubtreeListPtr newRow;
00189 m_impl->m_permSubtrees = newRow;
00190 }
00191
00192 if(settings.m_impl->m_exclSubtrees != (CPKIFGeneralSubtreeList*)NULL)
00193 {
00194 CPKIFGeneralSubtreeListPtr newRow(new CPKIFGeneralSubtreeList);
00195 copy(settings.m_impl->m_exclSubtrees->begin(),settings.m_impl->m_exclSubtrees->end(), back_inserter(*newRow));
00196 m_impl->m_exclSubtrees = newRow;
00197 }
00198 else
00199 {
00200 CPKIFGeneralSubtreeListPtr newRow;
00201 m_impl->m_exclSubtrees = newRow;
00202 }
00203
00204 m_impl->m_valTimeNesting = settings.m_impl->m_valTimeNesting;
00205 }
00213 void CPKIFPathSettings::SetInitialExplicitPolicyIndicator() {m_impl->m_indicators.set(EXPLICIT_POLICY);}
00222 bool CPKIFPathSettings::GetInitialExplicitPolicyIndicator() {return m_impl->m_indicators[EXPLICIT_POLICY];}
00230 void CPKIFPathSettings::SetInitialPolicyMappingInhibitIndicator() {m_impl->m_indicators.set(POLICY_MAPPING);}
00231
00241 bool CPKIFPathSettings::GetInitialPolicyMappingInhibitIndicator() {return m_impl->m_indicators[POLICY_MAPPING];}
00242
00253 void CPKIFPathSettings::SetInitialInhibitAnyPolicyIndicator() {m_impl->m_indicators.set(ANY_POLICY);}
00254
00265 bool CPKIFPathSettings::GetInitialInhibitAnyPolicyIndicator() {return m_impl->m_indicators[ANY_POLICY];}
00278 void CPKIFPathSettings::SetInitialPolicySet(
00281 CPKIFPolicyInformationListPtr& initPolSet)
00282 {
00283 m_impl->m_initPolSet = initPolSet;
00284 }
00285
00294 void CPKIFPathSettings::SetInitialPermSubtrees(
00297 CPKIFGeneralSubtreeListPtr& permSubtrees)
00298 {
00299 m_impl->m_permSubtrees = permSubtrees;
00300 }
00301
00310 void CPKIFPathSettings::SetInitialExclSubtrees(
00313 CPKIFGeneralSubtreeListPtr& exclSubtrees)
00314 {
00315 m_impl->m_exclSubtrees = exclSubtrees;
00316 }
00317
00318
00327 void CPKIFPathSettings::SetSufficientlyRecent(
00331 int seconds)
00332 {
00333 m_impl->m_duration->setSeconds(seconds);
00334 }
00342 void CPKIFPathSettings::SetRequireSufficientlyRecent(
00344 bool requireSufficientlyRecent)
00345 {
00346 m_impl->m_bRequireSufficientlyRecent = requireSufficientlyRecent;
00347 }
00359 CPKIFDurationPtr CPKIFPathSettings::GetDuration()const
00360 {
00361 return m_impl->m_duration;
00362 }
00371 bool CPKIFPathSettings::GetRequireSufficientlyRecent()const
00372 {
00373 return m_impl->m_bRequireSufficientlyRecent;
00374 }
00386 void CPKIFPathSettings::SetRequireFreshRevocationData(
00388 bool b)
00389 {
00390 m_impl->m_freshRevData = b;
00391 }
00403 bool CPKIFPathSettings::GetRequireFreshRevocationData() const {return m_impl->m_freshRevData;}
00413 void CPKIFPathSettings::SetCheckRevocationStatus(
00416 bool checkRevStatus)
00417 {
00418 m_impl->m_bCheckRevStatus = checkRevStatus;
00419 }
00430 bool CPKIFPathSettings::GetCheckRevocationStatus() const {return m_impl->m_bCheckRevStatus;}
00431
00432
00443 void CPKIFPathSettings::SetValidationTime(
00445 CPKIFTimePtr& time)
00446 {
00447 m_impl->m_valTime = time;
00448
00449 SetRequireValidationTimeNesting(true);
00450 }
00464 CPKIFTimePtr CPKIFPathSettings::GetValidationTime() const
00465 {
00466
00467 if(m_impl->m_valTime == (CPKIFTime*)NULL)
00468 return CPKIFTime::CurrentTime();
00469 else
00470 return m_impl->m_valTime;
00471 }
00484 void CPKIFPathSettings::GetInitialPolicySet(
00487 CPKIFPolicyInformationListPtr& initPolSet,
00488 bool bReturnAnyPolicyWhenEmpty) const
00489 {
00490 LOG_STRING_DEBUG("CPKIFPathSettings::GetInitialPolicySet(CPKIFPolicyInformationListPtr& initPolSet)", TOOLKIT_PATH_MISC, 0, this);
00491
00492 if(m_impl->m_initPolSet == (CPKIFPolicyInformationList*)NULL && bReturnAnyPolicyWhenEmpty)
00493 {
00494 CPKIFPolicyInformationListPtr newList(new CPKIFPolicyInformationList);
00495 CPKIFOIDPtr anyPolicyOID(new CPKIFOID(CPKIFStringPtr(new std::string("2.5.29.32.0"))));
00496 CPKIFPolicyInformationPtr anyPolicy(new CPKIFPolicyInformation(anyPolicyOID));
00497 newList->push_back(anyPolicy);
00498
00499 CPKIFPathSettings* nonConst = const_cast<CPKIFPathSettings*>(this);
00500 nonConst->m_impl->m_initPolSet = newList;
00501 }
00502
00503 initPolSet = m_impl->m_initPolSet;
00504 }
00505
00514 void CPKIFPathSettings::GetInitialPermSubtrees(
00517 CPKIFGeneralSubtreeListPtr& permSubtrees)const
00518 {
00519 LOG_STRING_DEBUG("CPKIFPathSettings::GetInitialPermSubtrees(CPKIFGeneralSubtreeListPtr& permSubtrees)", TOOLKIT_PATH_MISC, 0, this);
00520
00521 permSubtrees = m_impl->m_permSubtrees;
00522 }
00523
00532 void CPKIFPathSettings::GetInitialExclSubtrees(
00535 CPKIFGeneralSubtreeListPtr& exclSubtrees)const
00536 {
00537 LOG_STRING_DEBUG("CPKIFPathSettings::GetInitialExclSubtrees(CPKIFGeneralSubtreeListPtr& exclSubtrees)", TOOLKIT_PATH_MISC, 0, this);
00538
00539 exclSubtrees = m_impl->m_exclSubtrees;
00540 }
00541
00542
00550 void CPKIFPathSettings::SetOverrideCallback(bool (* overrideCallback) (int, CPKIFCertificatePtr&,const CPKIFCertificatePath&))
00551 {
00552 m_impl->m_overrideCallback = overrideCallback;
00553 }
00561 bool (* CPKIFPathSettings::GetOverrideCallback()) (int, CPKIFCertificatePtr&,const CPKIFCertificatePath&)
00562 {
00563 return m_impl->m_overrideCallback;
00564 }
00574
00575 void CPKIFPathSettings::SetInitialExplicitPolicyIndicator(
00577 bool b)
00578 {
00579 if(b)
00580 m_impl->m_indicators.set(EXPLICIT_POLICY);
00581 else
00582 m_impl->m_indicators.reset(EXPLICIT_POLICY);
00583 }
00594 void CPKIFPathSettings::SetInitialPolicyMappingInhibitIndicator(
00596 bool b)
00597 {
00598 if(b)
00599 m_impl->m_indicators.set(POLICY_MAPPING);
00600 else
00601 m_impl->m_indicators.reset(POLICY_MAPPING);
00602 }
00613 void CPKIFPathSettings::SetInitialInhibitAnyPolicyIndicator(
00615 bool b)
00616 {
00617 if(b)
00618 m_impl->m_indicators.set(ANY_POLICY);
00619 else
00620 m_impl->m_indicators.reset(ANY_POLICY);
00621 }
00622
00623
00634 int CPKIFPathSettings::GetDepth() const
00635 {
00636 return m_impl->m_depth;
00637 }
00638
00649 void CPKIFPathSettings::SetDepth(
00651 int d)
00652 {
00653 m_impl->m_depth = d;
00654 }
00655
00656 void CPKIFPathSettings::SetRequireValidationTimeNesting(bool b)
00657 {
00658 m_impl->m_valTimeNesting = b;
00659 }
00660 bool CPKIFPathSettings::GetRequireValidationTimeNesting()
00661 {
00662 return m_impl->m_valTimeNesting;
00663 }