PathProcessingAndRevCheckingPanel.cpp
Go to the documentation of this file.00001
00009 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) && defined(PKIFRESOURCES_ALLOW_GCC_PRAGMA)
00010 #pragma implementation "ColleagueSelectionPanel.cpp"
00011 #endif
00012
00013
00014 #include "PKIFdll.h"
00015
00016 #include "wx/wxprec.h"
00017
00018 #ifdef __BORLANDC__
00019 #pragma hdrstop
00020 #endif
00021
00022 #include "PathProcessingAndRevCheckingPanel.h"
00023 #include "PRStringUtils.h"
00024 #include "PKIFReversiblePathBuilder.h"
00025 #include "ScvpResponderEntryDlg.h"
00026 #include "PKIFAiaOrSiaRetrieval.h"
00027 #include "LibSCVPGuard.h"
00028 #ifdef __INCLUDE_SCVP_SUPPORT__
00029 #include "PKIFSCVP.h"
00030 #endif
00031
00032
00033 #include <iterator>
00034
00035 using namespace boost;
00036 using namespace std;
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047 BEGIN_EVENT_TABLE(CPKIFPathAndRevColleagueSelectionPanel,wxPanel)
00048 EVT_BUTTON( ID_BUTTON_ADD_SCVP, CPKIFPathAndRevColleagueSelectionPanel::OnAddScvpResponder )
00049 EVT_BUTTON( ID_BUTTON_EDIT_SCVP, CPKIFPathAndRevColleagueSelectionPanel::OnEditScvpResponder )
00050 EVT_BUTTON( ID_BUTTON_REMOVE_SCVP, CPKIFPathAndRevColleagueSelectionPanel::OnRemoveScvpResponder )
00051 END_EVENT_TABLE()
00059 CPKIFPathAndRevColleagueSelectionPanel::CPKIFPathAndRevColleagueSelectionPanel( wxWindow *parent, wxWindowID id,
00060 const wxPoint &position, const wxSize& size, long style ) :
00061 wxPanel( parent, id, position, size, style )
00062 {
00063
00064 PathProcessingAndRevCheckingPanel( this, TRUE );
00065
00066 wxSizer* sz = GetSizer();
00067 sz->Hide(g_NewBuilderComponents, true);
00068
00069 CLibSCVPGuard scvpGuard;
00070
00071 if(!scvpGuard.IsSCVPAvailable()) {
00072
00073
00074
00075
00076 sz->Hide(gScvpResponderGroupBox, true);
00077 }
00078
00079 Layout();
00080 }
00088 CPKIFPathAndRevColleagueSelectionPanel::~CPKIFPathAndRevColleagueSelectionPanel()
00089 {
00090 }
00091
00092
00100 void CPKIFPathAndRevColleagueSelectionPanel::OnRemoveScvpResponder( wxCommandEvent &event )
00101 {
00102 wxListBox* lb = GetListboxScvp();
00103 wxASSERT(lb);
00104 int sel = lb->GetSelection();
00105 if(wxNOT_FOUND != sel)
00106 {
00107 IPKIFScvpClientPtr ocsp = m_vScvp[sel];
00108 m_vScvp.erase(m_vScvp.begin()+sel);
00109
00110 UpdateScvp();
00111 }
00112 }
00120 void CPKIFPathAndRevColleagueSelectionPanel::OnEditScvpResponder( wxCommandEvent &event )
00121 {
00122 wxListBox* lb = GetListboxScvp();
00123 wxASSERT(lb);
00124 size_t sel = lb->GetSelection();
00125 wxASSERT(sel < m_vScvp.size());
00126 if(wxNOT_FOUND != sel)
00127 {
00128 CScvpResponderEntryDlg sred(this, -1, wxT("Enter SCVP responder information"));
00129 sred.Centre();
00130
00131 IPKIFScvpClientPtr scvp = m_vScvp[sel];
00132 sred.SetInitialScvpClient(scvp);
00133
00134 if(wxID_OK == sred.ShowModal())
00135 {
00136 m_vScvp[sel] = sred.GetScvpClient();
00137
00138 UpdateScvp();
00139 }
00140 }
00141 else
00142 {
00143 wxMessageBox(wxT("You must select an entry to edit."));
00144 }
00145 }
00153 void CPKIFPathAndRevColleagueSelectionPanel::OnAddScvpResponder( wxCommandEvent &event )
00154 {
00155 CScvpResponderEntryDlg sred(this, -1, wxT("Enter SCVP responder information"));
00156 sred.Centre();
00157 if(wxID_OK == sred.ShowModal())
00158 {
00159 IPKIFScvpClientPtr scvp = sred.GetScvpClient();
00160 m_vScvp.push_back(scvp);
00161 UpdateScvp();
00162 }
00163 }
00171 void CPKIFPathAndRevColleagueSelectionPanel::GetResponders(
00173 vector<IPKIFScvpClientPtr>& r) const
00174 {
00175 copy(m_vScvp.begin(), m_vScvp.end(), back_inserter(r));
00176 }
00184 void CPKIFPathAndRevColleagueSelectionPanel::LoadPathProcessingSettings()
00185 {
00186 CPKIFPathProcessingMediator2* pm = m_m->GetMediator<CPKIFPathProcessingMediator2>();
00187 if(NULL == pm) return;
00188
00189 std::vector<IPKIFColleaguePtr> c;
00190 pm->GetColleagues(c);
00191
00192 CPKIFPathBuilder2Ptr fpb;
00193 CPKIFReversiblePathBuilderPtr rpb;
00194 CPKIFReversiblePathBuilderPtr fpb2;
00195 CPKIFPathValidator2Ptr pv;
00196 CPKIFPathBuildAndValidatePtr bav;
00197
00198 std::vector<IPKIFColleaguePtr>::iterator pos;
00199 std::vector<IPKIFColleaguePtr>::iterator end = c.end();
00200 for(pos = c.begin(); pos != end; ++pos)
00201 {
00202 if(NULL != dynamic_pointer_cast<CPKIFPathBuilder2, IPKIFColleague>(*pos))
00203 fpb = dynamic_pointer_cast<CPKIFPathBuilder2, IPKIFColleague>(*pos);
00204 else if(NULL != dynamic_pointer_cast<CPKIFReversiblePathBuilder, IPKIFColleague>(*pos))
00205 {
00206 CPKIFReversiblePathBuilderPtr tmpPB = dynamic_pointer_cast<CPKIFReversiblePathBuilder, IPKIFColleague>(*pos);
00207 if(PBD_REVERSE == tmpPB->GetDirection())
00208 rpb = tmpPB;
00209 else
00210 fpb2 = tmpPB;
00211 }
00212 else if(NULL != dynamic_pointer_cast<CPKIFPathValidator2, IPKIFColleague>(*pos))
00213 pv = dynamic_pointer_cast<CPKIFPathValidator2, IPKIFColleague>(*pos);
00214 else if(NULL != dynamic_pointer_cast<CPKIFPathBuildAndValidate, IPKIFColleague>(*pos))
00215 bav = dynamic_pointer_cast<CPKIFPathBuildAndValidate, IPKIFColleague>(*pos);
00216 #ifdef __INCLUDE_SCVP_SUPPORT__
00217 else if(NULL != dynamic_pointer_cast<IPKIFScvpClient, IPKIFColleague>(*pos))
00218 {
00219 IPKIFScvpClientPtr scvpClient = dynamic_pointer_cast<IPKIFScvpClient, IPKIFColleague>(*pos);
00220 m_vScvp.push_back(scvpClient);
00221 }
00222 #endif
00223 }
00224
00225 UpdateScvp();
00226 GetCheckForward()->SetValue(NULL != fpb);
00227 GetCheckForward2()->SetValue(NULL != fpb2);
00228 GetCheckReverse()->SetValue(NULL != rpb);
00229 GetCheckLocalValidation()->SetValue(NULL != pv);
00230 GetCheckLocalBuildAndValidate()->SetValue(NULL != bav);
00231 }
00239 void CPKIFPathAndRevColleagueSelectionPanel::LoadRevocationStatusSettings()
00240 {
00241 CPKIFRevocationStatusMediator2* rm = m_m->GetMediator<CPKIFRevocationStatusMediator2>();
00242 if(NULL == rm) return;
00243
00244 std::vector<IPKIFColleaguePtr> c;
00245 rm->GetColleagues(c);
00246
00247 CPKIFX509CRLCheckerPtr crl;
00248 CPKIFOCSPCheckerPtr ocspAIA;
00249 CPKIFCRLDPRetrievalPtr crlDP;
00250 CPKIFAiaOrSiaRetrievalPtr siaAia;
00251
00252 std::vector<IPKIFColleaguePtr>::iterator pos;
00253 std::vector<IPKIFColleaguePtr>::iterator end = c.end();
00254 for(pos = c.begin(); pos != end; ++pos)
00255 {
00256 if(NULL != dynamic_pointer_cast<CPKIFX509CRLChecker, IPKIFColleague>(*pos))
00257 crl = dynamic_pointer_cast<CPKIFX509CRLChecker, IPKIFColleague>(*pos);
00258 else if(NULL != dynamic_pointer_cast<CPKIFOCSPChecker, IPKIFColleague>(*pos))
00259 {
00260 CPKIFOCSPCheckerPtr tmp = dynamic_pointer_cast<CPKIFOCSPChecker, IPKIFColleague>(*pos);
00261 if(tmp->GetHost() == (std::string*)NULL && tmp->GetURL() == (std::string*)NULL)
00262 ocspAIA = tmp;
00263 }
00264 }
00265
00266
00267 GetCheckOcspAia()->SetValue(NULL != ocspAIA);
00268 if(ocspAIA)
00269 {
00270 GetCheckCacheOcspAia()->SetValue(ocspAIA->GetCacheValidatedResponders());
00271 GetCheckGenerateNonceOcspAia()->SetValue(ocspAIA->GetGenerateNonce());
00272 GetCheckRequireNonceMatchOcspAia()->SetValue(ocspAIA->GetRequireNonceMatch());
00273 }
00274 else
00275 {
00276 GetCheckCacheOcspAia()->SetValue(false);
00277 GetCheckGenerateNonceOcspAia()->SetValue(false);
00278 GetCheckRequireNonceMatchOcspAia()->SetValue(false);
00279 }
00280
00281 GetCheckProcessCRLs()->SetValue(NULL != crl);
00282 GetCheckCacheRevStatus()->SetValue(rm->GetCacheCertStatus());
00283
00284 CPKIFCacheMediator2* sm = m_m->GetMediator<CPKIFCacheMediator2>();
00285 if(NULL == sm) return;
00286
00287 std::vector<IPKIFColleaguePtr> cc;
00288 sm->GetColleagues(cc);
00289
00290 std::vector<IPKIFColleaguePtr>::iterator cpos;
00291 std::vector<IPKIFColleaguePtr>::iterator cend = cc.end();
00292
00293 for(cpos = cc.begin(); cpos != cend; ++cpos)
00294 {
00295 if(NULL != dynamic_pointer_cast<CPKIFCRLDPRetrieval, IPKIFColleague>(*cpos))
00296 {
00297 crlDP = dynamic_pointer_cast<CPKIFCRLDPRetrieval, IPKIFColleague>(*cpos);
00298 }
00299 else if(NULL != dynamic_pointer_cast<CPKIFAiaOrSiaRetrieval, IPKIFColleague>(*cpos))
00300 siaAia = dynamic_pointer_cast<CPKIFAiaOrSiaRetrieval, IPKIFColleague>(*cpos);
00301 }
00302 GetCheckRetrieveFromCrldp()->SetValue(NULL != crlDP);
00303 GetCheckRetrieveSiaAia()->SetValue(NULL != siaAia);
00304 }
00312 void CPKIFPathAndRevColleagueSelectionPanel::OnInitDialog(wxInitDialogEvent& event)
00313 {
00314 if(NULL == m_m) return;
00315
00316 LoadPathProcessingSettings();
00317 LoadRevocationStatusSettings();
00318 }
00326 void CPKIFPathAndRevColleagueSelectionPanel::SetInitialMediator(
00328 IPKIFMediatorPtr& m)
00329 {
00330 m_m = m;
00331 }
00339 void CPKIFPathAndRevColleagueSelectionPanel::UpdateScvp()
00340 {
00341 #ifdef __INCLUDE_SCVP_SUPPORT__
00342 wxListBox* lb = GetListboxScvp();
00343 lb->Clear();
00344
00345 vector<IPKIFScvpClientPtr>::iterator pos;
00346 vector<IPKIFScvpClientPtr>::iterator end = m_vScvp.end();
00347 for(pos = m_vScvp.begin(); pos != end; ++pos)
00348 {
00349 wxString tmp((*pos)->GetResponderUrl(),wxConvUTF8);
00350 lb->InsertItems(1, &tmp, lb->GetCount());
00351 }
00352
00353 #endif
00354 }