00001
00010 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) && defined(PKIFRESOURCES_ALLOW_GCC_PRAGMA)
00011 #pragma implementation "PkiEnvironmentDefinitionNotebook.cpp"
00012 #endif
00013
00014
00015 #include "PKIFdll.h"
00016
00017 #include "wx/wxprec.h"
00018
00019 #ifdef __BORLANDC__
00020 #pragma hdrstop
00021 #endif
00022
00023 #include "PkiEnvironmentDefinitionNotebook.h"
00024 #include "pkif.h"
00025
00026 #include "PKIFAiaOrSiaRetrieval.h"
00027 #include "PKIFReversiblePathBuilder.h"
00028 #include "PKIFCryptoPP.h"
00029 #include "PKIFCryptoPPRaw.h"
00030 #include "PKIFNSSCertUpdate.h"
00031 #include "PKIFNSSCRLUpdate.h"
00032 #include "PKIFNSSRepository.h"
00033 #include "PKIFNSSTrustStore.h"
00034 #include "PKIFNSS.h"
00035 #include "PKIFNSSRaw.h"
00036 #include "HttpServerBlacklist.h"
00037
00038 #ifdef _WIN32
00039 #include "PKIFBCryptGuard.h"
00040 #include "PKIFCNGCAPI.h"
00041 #include "PKIFCNGCAPIRaw.h"
00042 #endif
00043
00044 #include "CSingletonLDAPConnection.h"
00045 #include "PKIFSynonymousSourceStore.h"
00046
00047 #include <sstream>
00048
00049 #include "PRColleagueInfo.h"
00050
00051 #ifdef __INCLUDE_SCVP_SUPPORT__
00052 #include "PKIFSCVP.h"
00053 #endif
00054
00055 using namespace boost;
00056 using namespace std;
00064 void SaveUnrecognizedColleagues(std::vector<IPKIFColleaguePtr> & allcolleagues, std::vector<CPRColleagueInfoPtr> unknown)
00065 {
00066
00067 std::vector<IPKIFColleaguePtr>::iterator i;
00068 std::vector<IPKIFColleaguePtr>::iterator begin = allcolleagues.begin();
00069 std::vector<IPKIFColleaguePtr>::iterator end = allcolleagues.end();
00070 for(i = begin; i != end; ++i)
00071 {
00072 if(dynamic_pointer_cast<CPKIFCRLDPRetrieval,IPKIFColleague>(*i))
00073 {
00074 continue;
00075 }
00076 else if(dynamic_pointer_cast<CPKIFCryptoPP,IPKIFColleague>(*i))
00077 {
00078 continue;
00079 }
00080 else if(dynamic_pointer_cast<CPKIFCryptoPPRaw,IPKIFColleague>(*i))
00081 {
00082 continue;
00083 }
00084 else if(dynamic_pointer_cast<CPKIFLDAPRepository,IPKIFColleague>(*i))
00085 {
00086 continue;
00087 }
00088 else if(dynamic_pointer_cast<CPKIFNSSCertUpdate,IPKIFColleague>(*i))
00089 {
00090 continue;
00091 }
00092 else if(dynamic_pointer_cast<CPKIFNSSCRLUpdate,IPKIFColleague>(*i))
00093 {
00094 continue;
00095 }
00096 else if(dynamic_pointer_cast<CPKIFNSS,IPKIFColleague>(*i))
00097 {
00098 continue;
00099 }
00100 else if(dynamic_pointer_cast<CPKIFNSSRaw,IPKIFColleague>(*i))
00101 {
00102 continue;
00103 }
00104 else if(dynamic_pointer_cast<CPKIFNSSRepository,IPKIFColleague>(*i))
00105 {
00106 continue;
00107 }
00108 else if(dynamic_pointer_cast<CPKIFNSSTrustStore,IPKIFColleague>(*i))
00109 {
00110 continue;
00111 }
00112 else if(dynamic_pointer_cast<CPKIFOCSPChecker,IPKIFColleague>(*i))
00113 {
00114 continue;
00115 }
00116 else if(dynamic_pointer_cast<CPKIFPathBuildAndValidate,IPKIFColleague>(*i))
00117 {
00118 continue;
00119 }
00120 else if(dynamic_pointer_cast<CPKIFPathBuilder2,IPKIFColleague>(*i))
00121 {
00122 continue;
00123 }
00124 else if(dynamic_pointer_cast<CPKIFPathValidator2,IPKIFColleague>(*i))
00125 {
00126 continue;
00127 }
00128 else if(dynamic_pointer_cast<CPKIFReversiblePathBuilder,IPKIFColleague>(*i))
00129 {
00130 continue;
00131 }
00132 #ifdef __INCLUDE_SCVP_SUPPORT__
00133 else if(dynamic_pointer_cast<CPKIFScvpPathBuild,IPKIFColleague>(*i))
00134 {
00135 continue;
00136 }
00137 #endif
00138 else if(dynamic_pointer_cast<CPKIFX509CRLChecker,IPKIFColleague>(*i))
00139 {
00140 continue;
00141 }
00142 else if(dynamic_pointer_cast<IPKIFCryptoKeyManagement,IPKIFColleague>(*i))
00143 {
00144 continue;
00145 }
00146 #ifdef __INCLUDE_SCVP_SUPPORT__
00147 else if(dynamic_pointer_cast<IPKIFScvpClient,IPKIFColleague>(*i))
00148 {
00149 continue;
00150 }
00151 #endif
00152 else if(dynamic_pointer_cast<SimpleCertCache,IPKIFColleague>(*i))
00153 {
00154 continue;
00155 }
00156 else if(dynamic_pointer_cast<SimpleCRLCache,IPKIFColleague>(*i))
00157 {
00158 continue;
00159 }
00160 else if(dynamic_pointer_cast<SimpleRootStore,IPKIFColleague>(*i))
00161 {
00162 continue;
00163 }
00164 #ifdef WIN32
00165 else if(dynamic_pointer_cast<CPKIFCAPI2,IPKIFColleague>(*i))
00166 {
00167 continue;
00168 }
00169 else if(dynamic_pointer_cast<CPKIFCAPICertUpdate2,IPKIFColleague>(*i))
00170 {
00171 continue;
00172 }
00173 else if(dynamic_pointer_cast<CPKIFCAPICRLUpdate2,IPKIFColleague>(*i))
00174 {
00175 continue;
00176 }
00177 else if(dynamic_pointer_cast<CPKIFCAPIRaw,IPKIFColleague>(*i))
00178 {
00179 continue;
00180 }
00181 else if(dynamic_pointer_cast<CPKIFCAPIRepository2,IPKIFColleague>(*i))
00182 {
00183 continue;
00184 }
00185 else if(dynamic_pointer_cast<CPKIFCAPITrustRootCRLRepository2,IPKIFColleague>(*i))
00186 {
00187 continue;
00188 }
00189 else if(dynamic_pointer_cast<CPKIFCAPITrustStore2,IPKIFColleague>(*i))
00190 {
00191 continue;
00192 }
00193 #endif
00194 else
00195 {
00196 unknown.push_back(CPRColleagueInfoPtr(new CPRColleagueInfo((*i),std::distance(begin,i))));
00197 }
00198 }
00199 }
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210 BEGIN_EVENT_TABLE(CPKIFPkiEnvironmentDefinitionNotebook,wxDialog)
00211 EVT_BUTTON( wxID_OK, CPKIFPkiEnvironmentDefinitionNotebook::OnOK )
00212 EVT_BUTTON( wxID_CANCEL, CPKIFPkiEnvironmentDefinitionNotebook::OnCancel )
00213 EVT_INIT_DIALOG( CPKIFPkiEnvironmentDefinitionNotebook::OnInitDialog )
00214 EVT_NOTEBOOK_PAGE_CHANGED(ID_NOTEBOOK_PKI_ENV, CPKIFPkiEnvironmentDefinitionNotebook::OnSelChange)
00215 END_EVENT_TABLE()
00223 CPKIFPkiEnvironmentDefinitionNotebook::CPKIFPkiEnvironmentDefinitionNotebook( wxWindow *parent, wxWindowID id, const wxString &title,
00224 const wxPoint &position, const wxSize& size, long style, bool enableBlacklists ) :
00225 wxDialog( parent, id, title, position, size, style )
00226 {
00227
00228 wxSizer* sizerTop = PkiEnvironmentDefinitionNotebook( this, TRUE, TRUE );
00229 SetSizer(sizerTop);
00230
00231 wxNotebook* pNotebook = static_cast<wxNotebook *>(this->FindWindow(ID_NOTEBOOK_PKI_ENV));
00232 wxASSERT(pNotebook);
00233
00234 wxPanel *colleaguePanel = new wxPanel( pNotebook, -1 );
00235 m_pColleaguePanel = new CPKIFColleagueSelectionPanel(colleaguePanel);
00236
00237 wxPanel *ldapAndOcspPanel = new wxPanel( pNotebook, -1 );
00238 m_pLdapAndOcspPanel = new CPKIFLdapAndOcspPanel(ldapAndOcspPanel, -1,wxDefaultPosition,wxDefaultSize,wxTAB_TRAVERSAL | wxNO_BORDER,enableBlacklists);
00239
00240 wxPanel *simplePanel = new wxPanel( pNotebook, -1 );
00241 m_pSimplePanel = new CPKIFSimpleCertAndCrlPanel(simplePanel);
00242
00243 wxPanel *pathAndRevPanel = new wxPanel( pNotebook, -1 );
00244 m_pPathAndRevPanel = new CPKIFPathAndRevColleagueSelectionPanel(pathAndRevPanel);
00245
00246 wxPanel *sRPanel = new wxPanel( pNotebook, -1 );
00247 m_pSRPanel = new CPKIFSRColleagueSelectionPanel(sRPanel);
00248
00249 pNotebook->AddPage( colleaguePanel, wxT("Cryptography") );
00250 pNotebook->AddPage( sRPanel, wxT("Cert/CRL Stores") );
00251 pNotebook->AddPage( ldapAndOcspPanel, wxT("LDAP/OCSP/Blacklist") );
00252 pNotebook->AddPage( simplePanel, wxT("Simple Stores") );
00253 pNotebook->AddPage( pathAndRevPanel, wxT("Path Processing") );
00254
00255 sizerTop->Layout();
00256 sizerTop->SetSizeHints(this);
00257 sizerTop->Fit(this);
00258 }
00266 CPKIFPkiEnvironmentDefinitionNotebook::~CPKIFPkiEnvironmentDefinitionNotebook()
00267 {
00268 if(m_pColleaguePanel)
00269 delete m_pColleaguePanel;
00270 if(m_pLdapAndOcspPanel)
00271 delete m_pLdapAndOcspPanel;
00272 if(m_pSimplePanel)
00273 delete m_pSimplePanel;
00274 }
00275
00276
00284 void CPKIFPkiEnvironmentDefinitionNotebook::AssembleCrypto(
00286 CPKIFCryptoMediator2Ptr& cm) const
00287 {
00288
00289 IPKIFColleaguePtr col;
00290 #if defined(WIN32) || defined(_WIN32)
00291 CPKIFBCryptGuard cngGuard;
00292 if(!cngGuard.IsCNGAvailable()) {
00293 if(m_pColleaguePanel->GetCheckCapiRawmisc()->IsChecked())
00294 {
00295 CPKIFCAPIRawPtr capiRaw(new CPKIFCAPIRaw);
00296 col = dynamic_pointer_cast<IPKIFColleague, CPKIFCAPIRaw>(capiRaw);
00297 cm->AddColleague(col);
00298 }
00299
00300 if(m_pColleaguePanel->GetCheckCapiHkcuStored()->IsChecked())
00301 {
00302 CPKIFCAPI2Ptr capiStored(new CPKIFCAPI2);
00303 col = dynamic_pointer_cast<IPKIFColleague, CPKIFCAPI2>(capiStored);
00304 cm->AddColleague(col);
00305 }
00306
00307 if(m_pColleaguePanel->GetCheckCapiHklmStored()->IsChecked())
00308 {
00309 CPKIFCAPI2Ptr capiStored(new CPKIFCAPI2(NULL, 0, CERT_SYSTEM_STORE_LOCAL_MACHINE));
00310 col = dynamic_pointer_cast<IPKIFColleague, CPKIFCAPI2>(capiStored);
00311 cm->AddColleague(col);
00312 }
00313 } else {
00314 if(m_pColleaguePanel->GetCheckCapiRawmisc()->IsChecked())
00315 {
00316 CPKIFCNGCAPIRawPtr capiRaw(new CPKIFCNGCAPIRaw);
00317 col = dynamic_pointer_cast<IPKIFColleague, CPKIFCNGCAPIRaw>(capiRaw);
00318 cm->AddColleague(col);
00319 }
00320
00321 if(m_pColleaguePanel->GetCheckCapiHkcuStored()->IsChecked())
00322 {
00323 CPKIFCNGCAPIPtr capiStored(new CPKIFCNGCAPI);
00324 col = dynamic_pointer_cast<IPKIFColleague, CPKIFCNGCAPI>(capiStored);
00325 cm->AddColleague(col);
00326 }
00327
00328 if(m_pColleaguePanel->GetCheckCapiHklmStored()->IsChecked())
00329 {
00330 CPKIFCNGCAPIPtr capiStored(new CPKIFCNGCAPI(NULL, 0, CERT_SYSTEM_STORE_LOCAL_MACHINE));
00331 col = dynamic_pointer_cast<IPKIFColleague, CPKIFCNGCAPI>(capiStored);
00332 cm->AddColleague(col);
00333 }
00334 }
00335 #endif
00336 if(m_pColleaguePanel->GetCheckNssStored()->IsChecked())
00337 {
00338 CPKIFNSSPtr nssStored;
00339 if(m_pColleaguePanel->GetTextNssDbdir()->GetValue() != wxT(""))
00340 {
00341 CPKIFNSSPtr tmp(new CPKIFNSS(string(m_pColleaguePanel->GetTextNssDbdir()->GetValue().mb_str())));
00342 nssStored = tmp;
00343
00344 col = dynamic_pointer_cast<IPKIFColleague, CPKIFNSS>(nssStored);
00345 cm->AddColleague(col);
00346 }
00347
00348 }
00349
00350 if(m_pColleaguePanel->GetCheckNssRawmisc()->IsChecked())
00351 {
00352 CPKIFNSSRawPtr nssRaw(new CPKIFNSSRaw(string(m_pColleaguePanel->GetTextNssDbdir()->GetValue().mb_str())));
00353 col = dynamic_pointer_cast<IPKIFColleague, CPKIFNSSRaw>(nssRaw);
00354 cm->AddColleague(col);
00355 }
00356
00357 if(m_pColleaguePanel->GetCheckCppStored()->IsChecked())
00358 {
00359 CPKIFCryptoPPPtr cppStored(new CPKIFCryptoPP);
00360 col = dynamic_pointer_cast<IPKIFColleague, CPKIFCryptoPP>(cppStored);
00361 cm->AddColleague(col);
00362 }
00363
00364 if(m_pColleaguePanel->GetCheckCppRaw()->IsChecked())
00365 {
00366 CPKIFCryptoPPRawPtr cppRaw(new CPKIFCryptoPPRaw);
00367 col = dynamic_pointer_cast<IPKIFColleague, CPKIFCryptoPPRaw>(cppRaw);
00368 cm->AddColleague(col);
00369 }
00370 }
00378 void CPKIFPkiEnvironmentDefinitionNotebook::AssembleStorageAndRetrieval(
00380 CPKIFCacheMediator2Ptr& sm) const
00381 {
00382
00383 IPKIFColleaguePtr col;
00384
00385 if(m_pPathAndRevPanel->GetCheckRetrieveSiaAia()->IsChecked())
00386 {
00387 CPKIFAiaOrSiaRetrievalPtr siaAia(new CPKIFAiaOrSiaRetrieval);
00388 col = dynamic_pointer_cast<IPKIFColleague, CPKIFAiaOrSiaRetrieval>(siaAia);
00389 sm->AddColleague(col);
00390 }
00391
00392 if(m_pSRPanel->GetCheckSimpleCert()->IsChecked())
00393 {
00394 SimpleCertCachePtr simpleCert(new SimpleCertCache);
00395 col = dynamic_pointer_cast<IPKIFColleague, SimpleCertCache>(simpleCert);
00396 sm->AddColleague(col);
00397
00398 std::vector<CPKIFCertificatePtr> certs;
00399 m_pSimplePanel->GetCertificates(certs);
00400
00401 std::vector<CPKIFCertificatePtr>::iterator pos;
00402 std::vector<CPKIFCertificatePtr>::iterator end = certs.end();
00403 for(pos = certs.begin(); pos != end; ++pos)
00404 simpleCert->AddCertificate(CA, *pos);
00405 }
00406
00407 if(m_pSRPanel->GetCheckSimpleCrl()->IsChecked())
00408 {
00409 SimpleCRLCachePtr simpleCrl(new SimpleCRLCache);
00410 col = dynamic_pointer_cast<IPKIFColleague, SimpleCRLCache>(simpleCrl);
00411 sm->AddColleague(col);
00412
00413 std::vector<CPKIFCRLPtr> crls;
00414 m_pSimplePanel->GetCrls(crls);
00415
00416 CPKIFGeneralNamePtr dummyDP;
00417 std::vector<CPKIFCRLPtr>::iterator pos;
00418 std::vector<CPKIFCRLPtr>::iterator end = crls.end();
00419 for(pos = crls.begin(); pos != end; ++pos)
00420 simpleCrl->AddCRL(*pos, dummyDP);
00421 }
00422
00423 if(m_pSRPanel->GetCheckTrustAnchors()->IsChecked())
00424 {
00425 SimpleRootStorePtr simpleRoot(new SimpleRootStore);
00426 col = dynamic_pointer_cast<IPKIFColleague, SimpleRootStore>(simpleRoot);
00427 sm->AddColleague(col);
00428
00429 std::vector<CPKIFCertificatePtr> tas;
00430 m_pSimplePanel->GetTrustAnchors(tas);
00431
00432 std::vector<CPKIFCertificatePtr>::iterator pos;
00433 std::vector<CPKIFCertificatePtr>::iterator end = tas.end();
00434 for(pos = tas.begin(); pos != end; ++pos)
00435 {
00436 CPKIFTrustRootPtr tmpRoot(new CPKIFTrustRoot);
00437 tmpRoot->SetCert(*pos);
00438 simpleRoot->AddTrustRoot(tmpRoot);
00439 }
00440 }
00441
00442 if(m_pSRPanel->GetCheckSiaAiaCrldpCache()->IsChecked())
00443 {
00444 CPKIFSynonymousSourceStorePtr sss(new CPKIFSynonymousSourceStore);
00445 col = dynamic_pointer_cast<IPKIFColleague, CPKIFSynonymousSourceStore>(sss);
00446 sm->AddColleague(col);
00447 }
00448
00449 #if defined(WIN32) || defined(_WIN32)
00450 if(m_pSRPanel->GetCheckCapiCertcrlHkcu()->IsChecked())
00451 {
00452 CPKIFCAPICertUpdate2Ptr certUp(new CPKIFCAPICertUpdate2());
00453 CPKIFCAPICRLUpdate2Ptr crlUp(new CPKIFCAPICRLUpdate2());
00454 CPKIFCAPIRepository2Ptr capiRep(new CPKIFCAPIRepository2());
00455
00456 col = dynamic_pointer_cast<IPKIFColleague, CPKIFCAPIRepository2>(capiRep);
00457 sm->AddColleague(col);
00458 col = dynamic_pointer_cast<IPKIFColleague, CPKIFCAPICertUpdate2>(certUp);
00459 sm->AddColleague(col);
00460 col = dynamic_pointer_cast<IPKIFColleague, CPKIFCAPICRLUpdate2>(crlUp);
00461 sm->AddColleague(col);
00462 }
00463
00464 if(m_pSRPanel->GetCheckCapiCertcrlHklm()->IsChecked())
00465 {
00466 CPKIFCAPICertUpdate2Ptr certUp(new CPKIFCAPICertUpdate2(CERT_SYSTEM_STORE_LOCAL_MACHINE));
00467 CPKIFCAPICRLUpdate2Ptr crlUp(new CPKIFCAPICRLUpdate2(CERT_SYSTEM_STORE_LOCAL_MACHINE));
00468 CPKIFCAPIRepository2Ptr capiRep(new CPKIFCAPIRepository2(CERT_SYSTEM_STORE_LOCAL_MACHINE));
00469
00470 col = dynamic_pointer_cast<IPKIFColleague, CPKIFCAPIRepository2>(capiRep);
00471 sm->AddColleague(col);
00472 col = dynamic_pointer_cast<IPKIFColleague, CPKIFCAPICertUpdate2>(certUp);
00473 sm->AddColleague(col);
00474 col = dynamic_pointer_cast<IPKIFColleague, CPKIFCAPICRLUpdate2>(crlUp);
00475 sm->AddColleague(col);
00476 }
00477 #endif
00478 if(m_pSRPanel->GetCheckNssCertcrl()->IsChecked())
00479 {
00480 CPKIFNSSCertUpdatePtr certUp;
00481 CPKIFNSSCRLUpdatePtr crlUp;
00482 CPKIFNSSRepositoryPtr capiRep;
00483
00484 if(m_pColleaguePanel->GetTextNssDbdir()->GetValue() != wxT(""))
00485 {
00486 CPKIFNSSCertUpdatePtr tmpcertUp(new CPKIFNSSCertUpdate(string(m_pColleaguePanel->GetTextNssDbdir()->GetValue().mb_str())));
00487 certUp = tmpcertUp;
00488 CPKIFNSSCRLUpdatePtr tmpcrlUp(new CPKIFNSSCRLUpdate(string(m_pColleaguePanel->GetTextNssDbdir()->GetValue().mb_str())));
00489 crlUp = tmpcrlUp;
00490 CPKIFNSSRepositoryPtr tmpcapiRep(new CPKIFNSSRepository(string(m_pColleaguePanel->GetTextNssDbdir()->GetValue().mb_str())));
00491 capiRep = tmpcapiRep;
00492
00493 col = dynamic_pointer_cast<IPKIFColleague, CPKIFNSSRepository>(capiRep);
00494 sm->AddColleague(col);
00495 col = dynamic_pointer_cast<IPKIFColleague, CPKIFNSSCertUpdate>(certUp);
00496 sm->AddColleague(col);
00497 col = dynamic_pointer_cast<IPKIFColleague, CPKIFNSSCRLUpdate>(crlUp);
00498 sm->AddColleague(col);
00499 }
00500
00501 }
00502
00503 if(m_pPathAndRevPanel->GetCheckRetrieveSiaAia()->IsChecked())
00504 {
00505 CPKIFAiaOrSiaRetrievalPtr siaAia(new CPKIFAiaOrSiaRetrieval);
00506 col = dynamic_pointer_cast<IPKIFColleague, CPKIFAiaOrSiaRetrieval>(siaAia);
00507 sm->AddColleague(col);
00508 }
00509
00510 if(m_pPathAndRevPanel->GetCheckRetrieveFromCrldp()->IsChecked())
00511 {
00512 CPKIFCRLDPRetrievalPtr crlDP(new CPKIFCRLDPRetrieval);
00513 col = dynamic_pointer_cast<IPKIFColleague, CPKIFCRLDPRetrieval>(crlDP);
00514 sm->AddColleague(col);
00515 }
00516 #if defined(WIN32) || defined(_WIN32)
00517 if(m_pSRPanel->GetCheckCapiTrustAnchorHkcu()->IsChecked())
00518 {
00519 CPKIFCAPITrustStore2Ptr ta(new CPKIFCAPITrustStore2);
00520 col = dynamic_pointer_cast<IPKIFColleague, CPKIFCAPITrustStore2>(ta);
00521 sm->AddColleague(col);
00522 }
00523
00524 if(m_pSRPanel->GetCheckCapiTrustAnchorHklm()->IsChecked())
00525 {
00526 CPKIFCAPITrustStore2Ptr ta(new CPKIFCAPITrustStore2(CERT_SYSTEM_STORE_LOCAL_MACHINE));
00527 col = dynamic_pointer_cast<IPKIFColleague, CPKIFCAPITrustStore2>(ta);
00528 sm->AddColleague(col);
00529
00530
00531 CPKIFCAPITrustRootCRLRepository2Ptr taCRLRep(new CPKIFCAPITrustRootCRLRepository2(CERT_SYSTEM_STORE_LOCAL_MACHINE));
00532 col = dynamic_pointer_cast<IPKIFColleague, CPKIFCAPITrustRootCRLRepository2>(taCRLRep);
00533 sm->AddColleague(col);
00534 }
00535 #endif
00536 if(m_pSRPanel->GetCheckNssTrustAnchors()->IsChecked())
00537 {
00538 CPKIFNSSTrustStorePtr ta;
00539 if(m_pColleaguePanel->GetTextNssDbdir()->GetValue() != wxT(""))
00540 {
00541 CPKIFNSSTrustStorePtr tatmp(new CPKIFNSSTrustStore(string(m_pColleaguePanel->GetTextNssDbdir()->GetValue().mb_str())));
00542 ta = tatmp;
00543
00544 col = dynamic_pointer_cast<IPKIFColleague, CPKIFNSSTrustStore>(ta);
00545 sm->AddColleague(col);
00546 }
00547
00548 }
00549
00550 std::vector<CPKIFLDAPRepositoryPtr> ldap;
00551 m_pLdapAndOcspPanel->GetDirectories(ldap);
00552
00553 std::vector<CPKIFLDAPRepositoryPtr>::iterator pos;
00554 std::vector<CPKIFLDAPRepositoryPtr>::iterator end = ldap.end();
00555 for(pos = ldap.begin(); pos != end; ++pos)
00556 {
00557 col = dynamic_pointer_cast<IPKIFColleague, CPKIFLDAPRepository>((*pos));
00558 sm->AddColleague(col);
00559 }
00560
00561 {
00562 vector<string> blacklist;
00563 m_pLdapAndOcspPanel->GetBlacklist(blacklist);
00564 PKIFLDAP::ClearServerBlacklist();
00565 vector<string>::iterator blend = blacklist.end();
00566 for(vector<string>::iterator i = blacklist.begin(); i != blend; ++i)
00567 {
00568 PKIFLDAP::AddBlacklistedServer((*i));
00569 }
00570 }
00571
00572 {
00573 vector<string> blacklist;
00574 m_pLdapAndOcspPanel->GetHttpBlacklist(blacklist);
00575 PKIFHTTP::ClearHttpServerBlacklist();
00576 vector<string>::iterator blend = blacklist.end();
00577 for(vector<string>::iterator i = blacklist.begin(); i != blend; ++i)
00578 {
00579 PKIFHTTP::AddBlacklistedHttpServer((*i));
00580 }
00581 }
00582 }
00590 void CPKIFPkiEnvironmentDefinitionNotebook::AssemblePathProcessing(
00592 CPKIFPathProcessingMediator2Ptr& pm) const
00593 {
00594 if(m_pPathAndRevPanel->GetCheckForward()->IsChecked())
00595 {
00596 CPKIFPathBuilder2Ptr pb(new CPKIFPathBuilder2);
00597 IPKIFColleaguePtr col = dynamic_pointer_cast<IPKIFColleague, CPKIFPathBuilder2>(pb);
00598 pm->AddColleague(col);
00599 }
00600 if(m_pPathAndRevPanel->GetCheckReverse()->IsChecked())
00601 {
00602 CPKIFReversiblePathBuilderPtr pb(new CPKIFReversiblePathBuilder(PBD_REVERSE));
00603 IPKIFColleaguePtr col = dynamic_pointer_cast<IPKIFColleague, CPKIFReversiblePathBuilder>(pb);
00604 pm->AddColleague(col);
00605 }
00606 if(m_pPathAndRevPanel->GetCheckForward2()->IsChecked())
00607 {
00608 CPKIFReversiblePathBuilderPtr pb(new CPKIFReversiblePathBuilder(PBD_FORWARD));
00609 IPKIFColleaguePtr col = dynamic_pointer_cast<IPKIFColleague, CPKIFReversiblePathBuilder>(pb);
00610 pm->AddColleague(col);
00611 }
00612 if(m_pPathAndRevPanel->GetCheckLocalValidation()->IsChecked())
00613 {
00614 CPKIFPathValidator2Ptr pv(new CPKIFPathValidator2);
00615 IPKIFColleaguePtr col = dynamic_pointer_cast<IPKIFColleague, CPKIFPathValidator2>(pv);
00616 pm->AddColleague(col);
00617 }
00618 if(m_pPathAndRevPanel->GetCheckLocalBuildAndValidate()->IsChecked())
00619 {
00620 CPKIFPathBuildAndValidatePtr pbav(new CPKIFPathBuildAndValidate);
00621 IPKIFColleaguePtr col = dynamic_pointer_cast<IPKIFColleague, CPKIFPathBuildAndValidate>(pbav);
00622 pm->AddColleague(col);
00623 }
00624
00625 #ifdef __INCLUDE_SCVP_SUPPORT__
00626 std::vector<IPKIFScvpClientPtr> scvp;
00627 m_pPathAndRevPanel->GetResponders(scvp);
00628 IPKIFColleaguePtr col;
00629
00630 std::vector<IPKIFScvpClientPtr>::iterator pos;
00631 std::vector<IPKIFScvpClientPtr>::iterator end = scvp.end();
00632 for(pos = scvp.begin(); pos != end; ++pos)
00633 {
00634 CPKIFScvpPathBuildPtr dpd = dynamic_pointer_cast<CPKIFScvpPathBuild, IPKIFScvpClient>((*pos));
00635 if(dpd)
00636 {
00637 col = dynamic_pointer_cast<IPKIFColleague, CPKIFScvpPathBuild>(dpd);
00638 pm->AddColleague(col);
00639 }
00640 else
00641 {
00642 CPKIFScvpPathBuildAndValidatePtr dpv = dynamic_pointer_cast<CPKIFScvpPathBuildAndValidate, IPKIFScvpClient>((*pos));
00643 if(dpv)
00644 {
00645 col = dynamic_pointer_cast<IPKIFColleague, CPKIFScvpPathBuildAndValidate>(dpv);
00646 pm->AddColleague(col);
00647 }
00648 }
00649 }
00650 #endif
00651 }
00659 void CPKIFPkiEnvironmentDefinitionNotebook::AssembleRevocationStatus(
00661 CPKIFRevocationStatusMediator2Ptr& rm) const
00662 {
00663
00664
00665 std::vector<CPKIFOCSPCheckerPtr> ocsp;
00666 m_pLdapAndOcspPanel->GetResponders(ocsp);
00667
00668 IPKIFColleaguePtr col;
00669
00670 rm->SetCacheCertStatus(m_pPathAndRevPanel->GetCheckCacheRevStatus()->IsChecked());
00671
00672 std::vector<CPKIFOCSPCheckerPtr>::iterator pos;
00673 std::vector<CPKIFOCSPCheckerPtr>::iterator end = ocsp.end();
00674 for(pos = ocsp.begin(); pos != end; ++pos)
00675 {
00676 col = dynamic_pointer_cast<IPKIFColleague, CPKIFOCSPChecker>((*pos));
00677 rm->AddColleague(col);
00678 }
00679
00680 if(m_pPathAndRevPanel->GetCheckOcspAia()->IsChecked())
00681 {
00682 CPKIFOCSPCheckerPtr ocspAIA(new CPKIFOCSPChecker);
00683
00684 if(m_pPathAndRevPanel->GetCheckCacheOcspAia()->IsChecked())
00685 {
00686 ocspAIA->SetCacheValidatedResponders(true);
00687 }
00688 else
00689 {
00690 ocspAIA->SetCacheValidatedResponders(false);
00691 }
00692 if(m_pPathAndRevPanel->GetCheckGenerateNonceOcspAia()->IsChecked())
00693 {
00694 ocspAIA->SetGenerateNonce(true);
00695 }
00696 else
00697 {
00698 ocspAIA->SetGenerateNonce(false);
00699 }
00700 if(m_pPathAndRevPanel->GetCheckRequireNonceMatchOcspAia()->IsChecked())
00701 {
00702 ocspAIA->SetRequireNonceMatch(true);
00703 }
00704 else
00705 {
00706 ocspAIA->SetRequireNonceMatch(false);
00707 }
00708
00709 col = dynamic_pointer_cast<IPKIFColleague, CPKIFOCSPChecker>(ocspAIA);
00710 rm->AddColleague(col);
00711 }
00712
00713 if(m_pPathAndRevPanel->GetCheckProcessCRLs()->IsChecked())
00714 {
00715 CPKIFX509CRLCheckerPtr crl(new CPKIFX509CRLChecker);
00716 col = dynamic_pointer_cast<IPKIFColleague, CPKIFX509CRLChecker>(crl);
00717 rm->AddColleague(col);
00718 }
00719 }
00727 IPKIFMediatorPtr CPKIFPkiEnvironmentDefinitionNotebook::GetMediator()
00728 {
00729 CPKIFPathProcessingMediator2Ptr pm(new CPKIFPathProcessingMediator2);
00730 CPKIFCryptoMediator2Ptr cm(new CPKIFCryptoMediator2);
00731 CPKIFCacheMediator2Ptr sm(new CPKIFCacheMediator2);
00732 CPKIFRevocationStatusMediator2Ptr rm(new CPKIFRevocationStatusMediator2);
00733
00734
00735
00736 {
00737 std::vector<CPRColleagueInfoPtr>::iterator begin = m_unrecognizedCrypto.begin();
00738 std::vector<CPRColleagueInfoPtr>::iterator end = m_unrecognizedCrypto.end();
00739 for(std::vector<CPRColleagueInfoPtr>::iterator i = begin; i != end; ++i)
00740 {
00741 if((*i)->GetPosition() == 0) {
00742 cm->AddColleague((*i)->GetColleague());
00743 }
00744 }
00745 }
00746 {
00747 std::vector<CPRColleagueInfoPtr>::iterator begin = m_unrecognizedSR.begin();
00748 std::vector<CPRColleagueInfoPtr>::iterator end = m_unrecognizedSR.end();
00749 for(std::vector<CPRColleagueInfoPtr>::iterator i = begin; i != end; ++i)
00750 {
00751 if((*i)->GetPosition() == 0) {
00752 sm->AddColleague((*i)->GetColleague());
00753 }
00754 }
00755 }
00756 {
00757 std::vector<CPRColleagueInfoPtr>::iterator begin = m_unrecognizedRevStatus.begin();
00758 std::vector<CPRColleagueInfoPtr>::iterator end = m_unrecognizedRevStatus.end();
00759 for(std::vector<CPRColleagueInfoPtr>::iterator i = begin; i != end; ++i)
00760 {
00761 if((*i)->GetPosition() == 0) {
00762 rm->AddColleague((*i)->GetColleague());
00763 }
00764 }
00765 }
00766 {
00767 std::vector<CPRColleagueInfoPtr>::iterator begin = m_unrecognizedPathProc.begin();
00768 std::vector<CPRColleagueInfoPtr>::iterator end = m_unrecognizedPathProc.end();
00769 for(std::vector<CPRColleagueInfoPtr>::iterator i = begin; i != end; ++i)
00770 {
00771 if((*i)->GetPosition() == 0) {
00772 pm->AddColleague((*i)->GetColleague());
00773 }
00774 }
00775 }
00776 AssembleCrypto(cm);
00777 AssembleStorageAndRetrieval(sm);
00778 AssemblePathProcessing(pm);
00779 AssembleRevocationStatus(rm);
00780
00781
00782
00783 {
00784 std::vector<CPRColleagueInfoPtr>::iterator begin = m_unrecognizedCrypto.begin();
00785 std::vector<CPRColleagueInfoPtr>::iterator end = m_unrecognizedCrypto.end();
00786 for(std::vector<CPRColleagueInfoPtr>::iterator i = begin; i != end; ++i)
00787 {
00788 if((*i)->GetPosition() != 0) {
00789 cm->AddColleague((*i)->GetColleague());
00790 }
00791 }
00792 }
00793 {
00794 std::vector<CPRColleagueInfoPtr>::iterator begin = m_unrecognizedSR.begin();
00795 std::vector<CPRColleagueInfoPtr>::iterator end = m_unrecognizedSR.end();
00796 for(std::vector<CPRColleagueInfoPtr>::iterator i = begin; i != end; ++i)
00797 {
00798 if((*i)->GetPosition() != 0) {
00799 sm->AddColleague((*i)->GetColleague());
00800 }
00801 }
00802 }
00803 {
00804 std::vector<CPRColleagueInfoPtr>::iterator begin = m_unrecognizedRevStatus.begin();
00805 std::vector<CPRColleagueInfoPtr>::iterator end = m_unrecognizedRevStatus.end();
00806 for(std::vector<CPRColleagueInfoPtr>::iterator i = begin; i != end; ++i)
00807 {
00808 if((*i)->GetPosition() != 0) {
00809 rm->AddColleague((*i)->GetColleague());
00810 }
00811 }
00812 }
00813 {
00814 std::vector<CPRColleagueInfoPtr>::iterator begin = m_unrecognizedPathProc.begin();
00815 std::vector<CPRColleagueInfoPtr>::iterator end = m_unrecognizedPathProc.end();
00816 for(std::vector<CPRColleagueInfoPtr>::iterator i = begin; i != end; ++i)
00817 {
00818 if((*i)->GetPosition() != 0) {
00819 pm->AddColleague((*i)->GetColleague());
00820 }
00821 }
00822 }
00823
00824 IPKIFMediatorPtr med = dynamic_pointer_cast<IPKIFMediator, CPKIFCacheMediator2>(sm);
00825 cm->AddMediator(med);
00826 med = dynamic_pointer_cast<IPKIFMediator, CPKIFPathProcessingMediator2>(pm);
00827 cm->AddMediator(med);
00828 med = dynamic_pointer_cast<IPKIFMediator, CPKIFRevocationStatusMediator2>(rm);
00829 cm->AddMediator(med);
00830
00831 return dynamic_pointer_cast<IPKIFMediator, CPKIFCryptoMediator2>(cm);
00832 }
00833
00841 void CPKIFPkiEnvironmentDefinitionNotebook::OnCancel( wxCommandEvent &event )
00842 {
00843 EndModal(wxID_CANCEL);
00844 }
00852 void CPKIFPkiEnvironmentDefinitionNotebook::OnOK( wxCommandEvent &event )
00853 {
00854 bool bSimple = false, bLdap = false, bColleague = false;
00855 bSimple = m_pSimplePanel->Validate();
00856 if(bSimple)
00857 bLdap = m_pLdapAndOcspPanel->Validate();
00858 if(bLdap)
00859 bColleague = m_pColleaguePanel->Validate();
00860
00861 bool bNSSOk = true;
00862 ostringstream oss;
00863 if(m_pSRPanel->GetCheckNssCertcrl()->IsChecked() && m_pColleaguePanel->GetTextNssDbdir()->GetValue() == wxT(""))
00864 {
00865 oss<<"Unable to create NSS Certificate and CRL storage and retrieval colleagues: No database specified.\n";
00866
00867
00868 bNSSOk = false;
00869 }
00870 if(m_pColleaguePanel->GetCheckNssStored()->IsChecked() && m_pColleaguePanel->GetTextNssDbdir()->GetValue() == wxT(""))
00871 {
00872 oss<<"Unable to create NSS Private Key Operations colleague: No database specified.\n";
00873
00874
00875 bNSSOk = false;
00876 }
00877 if(m_pSRPanel->GetCheckNssTrustAnchors()->IsChecked() && m_pColleaguePanel->GetTextNssDbdir()->GetValue() == wxT(""))
00878 {
00879 oss<<"Unable to create NSS Trust Anchor store colleague: No database specified.\n";
00880
00881
00882 bNSSOk = false;
00883 }
00884
00885 if(!bNSSOk)
00886 {
00887 wxString wxDesc(oss.str().c_str(),wxConvUTF8);
00888 wxMessageBox(wxDesc,wxT("Error"),wxICON_ERROR | wxOK);
00889 }
00890
00891 if(bSimple && bLdap && bColleague && bNSSOk)
00892 EndModal(wxID_OK);
00893 }
00901 void CPKIFPkiEnvironmentDefinitionNotebook::SetInitialMediator(IPKIFMediatorPtr& m)
00902 {
00903 m_m = m;
00904 m_pColleaguePanel->SetInitialMediator(m);
00905 m_pLdapAndOcspPanel->SetInitialMediator(m);
00906 m_pSimplePanel->SetInitialMediator(m);
00907 m_pPathAndRevPanel->SetInitialMediator(m);
00908 m_pSRPanel->SetInitialMediator(m);
00909 m_pSRPanel->SetCryptoColleaguePanel(m_pColleaguePanel);
00910 }
00918 void CPKIFPkiEnvironmentDefinitionNotebook::OnInitDialog(wxInitDialogEvent& event)
00919 {
00920 m_pColleaguePanel->OnInitDialog(event);
00921 m_pLdapAndOcspPanel->OnInitDialog(event);
00922 m_pSimplePanel->OnInitDialog(event);
00923 m_pPathAndRevPanel->OnInitDialog(event);
00924 m_pSRPanel->OnInitDialog(event);
00925 }
00934 void CPKIFPkiEnvironmentDefinitionNotebook::OnSelChange(wxNotebookEvent& event)
00935 {
00936 wxCheckBox* useSimpleCert = m_pSRPanel->GetCheckSimpleCert();
00937 if(useSimpleCert)
00938 {
00939 m_pSimplePanel->GetButtonAddCert()->Enable(useSimpleCert->IsChecked());
00940
00941 wxListBox* lb1 = m_pSimplePanel->GetListboxCerts();
00942 wxASSERT(lb1);
00943
00944 if(lb1->GetCount() > 0)
00945 {
00946 m_pSimplePanel->GetButtonViewCert()->Enable(useSimpleCert->IsChecked());
00947 }
00948 m_pSimplePanel->GetButtonRemoveCert()->Enable(useSimpleCert->IsChecked());
00949 }
00950
00951 wxCheckBox* useSimpleCrl = m_pSRPanel->GetCheckSimpleCrl();
00952 if(useSimpleCrl)
00953 {
00954 m_pSimplePanel->GetButtonAddCrl()->Enable(useSimpleCrl->IsChecked());
00955
00956 wxListBox* lb2 = m_pSimplePanel->GetListboxCrls();
00957 wxASSERT(lb2);
00958
00959 if(lb2->GetCount() > 0)
00960 {
00961 m_pSimplePanel->GetButtonViewCrl()->Enable(useSimpleCrl->IsChecked());
00962 }
00963 m_pSimplePanel->GetButtonRemoveCrl()->Enable(useSimpleCrl->IsChecked());
00964 }
00965
00966 wxCheckBox* useSimpleRoot = m_pSRPanel->GetCheckTrustAnchors();
00967 if(useSimpleRoot)
00968 {
00969 m_pSimplePanel->GetButtonAddTa()->Enable(useSimpleRoot->IsChecked());
00970
00971 wxListBox* lb3 = m_pSimplePanel->GetListboxTrustAnchors();
00972 wxASSERT(lb3);
00973
00974 if(lb3->GetCount() > 0)
00975 {
00976 m_pSimplePanel->GetButtonViewTa()->Enable(useSimpleRoot->IsChecked());
00977 }
00978 m_pSimplePanel->GetButtonRemoveTa()->Enable(useSimpleRoot->IsChecked());
00979 }
00980 }