EvidenceRecordVerifierDlg.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 "EvidenceRecordVerifier.cpp"
00011 #endif
00012 
00013 //Pick up PKIF windows SDK configuration macros instead of WX's 
00014 #include "PKIFdll.h"
00015 // For compilers that support precompilation, includes "wx/wx.h".
00016 #include "wx/wxprec.h"
00017 
00018 #ifdef __BORLANDC__
00019     #pragma hdrstop
00020 #endif
00021 
00022 #include "EvidenceRecordVerifierDlg.h"
00023 #include "SettingsWithTimePeriodDlg.h"
00024 
00025 #include "TMDClientData.h"
00026 
00027 #ifdef __INCLUDE_SCVP_SUPPORT__
00028 #include "EvidenceRecordVerifier.h"
00029 #endif
00030 #include "Validity.h"
00031 
00032 #include "PathSettingsNotebook.h"
00033 #include "PkiEnvironmentDefinitionNotebook.h"
00034 
00035 #include <sstream>
00036 using namespace std;
00037 
00038 //implemented in ScvpResponderEntryDlg.cpp
00039 const char* MakeTimePurty(CPKIFTimePtr& t, std::string& s);
00040 
00041 class TMDExMediator {
00042 public:
00043     TMDExMediator()
00044     {
00045     }
00046     #ifdef __INCLUDE_SCVP_SUPPORT__
00047     CPKIFExMediatorPtr m_med;
00048     #endif
00049 };
00050 
00051 #ifdef __INCLUDE_SCVP_SUPPORT__
00052 DECLARE_CLIENT_DATA(TMDExMediator);
00053 #endif
00054 class TMDExPathSettings {
00055 public:
00056     TMDExPathSettings()
00057     {
00058     }
00059     #ifdef __INCLUDE_SCVP_SUPPORT__
00060     CPKIFExPathSettingsPtr m_ps;
00061     #endif
00062 };
00063 #ifdef __INCLUDE_SCVP_SUPPORT__
00064 DECLARE_CLIENT_DATA(TMDExPathSettings);
00065 #endif
00066 // WDR: class implementations
00067 
00068 //----------------------------------------------------------------------------
00069 // CEvidenceRecordVerifierDlg
00070 //----------------------------------------------------------------------------
00071 
00072 // WDR: event table for CEvidenceRecordVerifierDlg
00073 
00074 BEGIN_EVENT_TABLE(CEvidenceRecordVerifierDlg,wxDialog)
00075     EVT_BUTTON( wxID_OK, CEvidenceRecordVerifierDlg::OnOk )
00076     EVT_BUTTON( wxID_CANCEL, CEvidenceRecordVerifierDlg::OnCancel )
00077     EVT_BUTTON( ID_BUTTON_CUR_MEDS, CEvidenceRecordVerifierDlg::OnClickCurMeds )
00078     EVT_BUTTON( ID_BUTTON_CUR_PP, CEvidenceRecordVerifierDlg::OnClickCurPathProcessing )
00079     EVT_BUTTON( ID_BUTTON_ARCH_MED_ADD, CEvidenceRecordVerifierDlg::OnClickAddArchMeds )
00080     EVT_BUTTON( ID_BUTTON_ARCH_MED_EDIT, CEvidenceRecordVerifierDlg::OnClickEditArchMeds )
00081     EVT_BUTTON( ID_BUTTON_ARCH_MED_REMOVE, CEvidenceRecordVerifierDlg::OnClickRemoveArchMeds )
00082     EVT_BUTTON( ID_BUTTON_ARCH_PP_ADD, CEvidenceRecordVerifierDlg::OnClickAddArchPathProcessing )
00083     EVT_BUTTON( ID_BUTTON_ARCH_PP_EDIT, CEvidenceRecordVerifierDlg::OnClickEditArchPathProcessing )
00084     EVT_BUTTON( ID_BUTTON_ARCH_PP_REMOVE, CEvidenceRecordVerifierDlg::OnClickRemoveArchPathProcessing )
00085 END_EVENT_TABLE()
00093 CEvidenceRecordVerifierDlg::CEvidenceRecordVerifierDlg( wxWindow *parent, wxWindowID id, const wxString &title,
00094     const wxPoint &position, const wxSize& size, long style ) :
00095     wxDialog( parent, id, title, position, size, style )
00096 {
00097     // WDR: dialog function EvidenceRecordVerifierDlg for CEvidenceRecordVerifierDlg
00098     EvidenceRecordVerifierDlg( this, TRUE ); 
00099 }
00107 CEvidenceRecordVerifierDlg::~CEvidenceRecordVerifierDlg()
00108 {
00109 }
00117 bool CEvidenceRecordVerifierDlg::Validate()
00118 {
00119     return TRUE;
00120 }
00121 #ifdef __INCLUDE_SCVP_SUPPORT__
00122 
00129 void CEvidenceRecordVerifierDlg::AddToPathSettingsListbox(CPKIFExPathSettingsPtr& ps)
00130 {
00131     string aString;
00132     ostringstream oss;
00133     CPKIFValidityPtr val = ps->first;
00134     CPKIFTimePtr notBefore = val->notBefore();
00135     oss << "Not before: " << MakeTimePurty(notBefore, aString);
00136     CPKIFTimePtr notAfter = val->notAfter();
00137     if(notAfter)
00138         oss << " Not after: " << MakeTimePurty(notAfter, aString);
00139 
00140     wxString wxDesc(oss.str().c_str(),wxConvUTF8);
00141 
00142     TMDExPathSettings* eps = new TMDExPathSettings;
00143     eps->m_ps = ps;
00144 
00145     GetListboxArchPp()->Append(wxDesc, new TMDExPathSettingsCD(eps));
00146 }
00154 void CEvidenceRecordVerifierDlg::AddToMediatorListbox(CPKIFExMediatorPtr& med)
00155 {
00156 
00157     string aString;
00158     ostringstream oss;
00159     CPKIFValidityPtr val = med->first;
00160     CPKIFTimePtr notBefore = val->notBefore();
00161     oss << "Not before: " << MakeTimePurty(notBefore, aString);
00162     CPKIFTimePtr notAfter = val->notAfter();
00163     if(notAfter)
00164         oss << " Not after: " << MakeTimePurty(notAfter, aString);
00165 
00166     wxString wxDesc(oss.str().c_str(),wxConvUTF8);
00167 
00168     TMDExMediator* em = new TMDExMediator;
00169     em->m_med = med;
00170 
00171     GetListboxArchMeds()->Append(wxDesc, new TMDExMediatorCD(em));
00172 
00173 }
00174 #endif
00175 
00182 bool CEvidenceRecordVerifierDlg::TransferDataToWindow()
00183 {
00184     #ifdef __INCLUDE_SCVP_SUPPORT__
00185     if(m_erv)
00186     {
00187         std::vector<CPKIFExPathSettingsPtr> exPaths;
00188         m_erv->GetArchivePathSettings(exPaths);
00189         
00190         std::vector<CPKIFExPathSettingsPtr>::iterator pos;
00191         std::vector<CPKIFExPathSettingsPtr>::iterator end = exPaths.end();
00192         for(pos = exPaths.begin(); pos != end; ++pos)
00193         {
00194             AddToPathSettingsListbox(*pos);
00195         }
00196         std::vector<CPKIFExMediatorPtr> exMeds;
00197         m_erv->GetArchiveMediators(exMeds);
00198         
00199         std::vector<CPKIFExMediatorPtr>::iterator posM;
00200         std::vector<CPKIFExMediatorPtr>::iterator endM = exMeds.end();
00201         for(posM = exMeds.begin(); posM != endM; ++posM)
00202         {
00203             AddToMediatorListbox(*posM);
00204         }
00205 
00206         m_curMed = m_erv->GetCurrentMediator();
00207         m_curPS = m_erv->GetCurrentPathSettings();
00208     }
00209 #endif
00210 
00211     return TRUE;
00212 }
00220 bool CEvidenceRecordVerifierDlg::TransferDataFromWindow()
00221 {
00222     #ifdef __INCLUDE_SCVP_SUPPORT__
00223     CPKIFEvidenceRecordVerifierPtr newErv(new CPKIFEvidenceRecordVerifier);
00224     m_erv = newErv;
00225 
00226     m_erv->SetCurrentMediator(m_curMed);
00227     m_erv->SetCurrentPathSettings(m_curPS);
00228 
00229     unsigned int ii = 0;
00230     wxListBox* lbMed = GetListboxArchMeds();
00231     for(ii = 0; ii < lbMed->GetCount(); ++ii)
00232     {
00233         TMDExMediator * med = GET_FROM_CONTROL(TMDExMediator,lbMed,ii);
00234         m_erv->AddArchiveMediator(med->m_med);
00235     }
00236 
00237     wxListBox* lbPS = GetListboxArchPp();
00238     for(ii = 0; ii < lbPS->GetCount(); ++ii)
00239     {
00240         TMDExPathSettings * ps = GET_FROM_CONTROL(TMDExPathSettings,lbPS,ii);
00241         m_erv->AddArchivePathSettings(ps->m_ps);
00242     }
00243     #endif
00244     return TRUE;
00245 }
00246 
00247 // WDR: handler implementations for CEvidenceRecordVerifierDlg
00255 void CEvidenceRecordVerifierDlg::OnClickRemoveArchPathProcessing( wxCommandEvent &event )
00256 {
00257     #ifdef __INCLUDE_SCVP_SUPPORT__
00258     int selection = GetListboxArchPp()->GetSelection();
00259     if(wxNOT_FOUND == selection){
00260         return;
00261     }
00262     GetListboxArchPp()->Delete(selection);
00263     #endif
00264 }
00272 void CEvidenceRecordVerifierDlg::OnClickEditArchPathProcessing( wxCommandEvent &event )
00273 {
00274     #ifdef __INCLUDE_SCVP_SUPPORT__
00275     int selection = GetListboxArchPp()->GetSelection();
00276     if(wxNOT_FOUND == selection)
00277     {
00278         return;
00279     }
00280     
00281     TMDExPathSettings * ps = GET_FROM_CONTROL(TMDExPathSettings,GetListboxArchPp(),selection);
00282 
00283     CSettingsWithTimePeriodDlg dlg(this, -1, wxT("Configure some settings and a time period"));
00284     dlg.SetWhatToDisplay(CSettingsWithTimePeriodDlg::DISPLAY_PP);
00285     dlg.SetPathSettings(ps->m_ps);
00286     if(wxID_OK == dlg.ShowModal())
00287     {
00288         ps->m_ps = dlg.GetPathSettings();
00289 
00290         string aString;
00291         ostringstream oss;
00292         CPKIFValidityPtr val = ps->m_ps->first;
00293         CPKIFTimePtr notBefore = val->notBefore();
00294         oss << "Not before: " << MakeTimePurty(notBefore, aString);
00295         CPKIFTimePtr notAfter = val->notAfter();
00296         if(notAfter)
00297             oss << " Not after: " << MakeTimePurty(notAfter, aString);
00298 
00299         wxString wxDesc(oss.str().c_str(),wxConvUTF8);
00300 
00301         GetListboxArchPp()->SetString(selection, wxDesc.c_str());
00302     }    
00303 #endif
00304 }
00312 void CEvidenceRecordVerifierDlg::OnClickAddArchPathProcessing( wxCommandEvent &event )
00313 {
00314     #ifdef __INCLUDE_SCVP_SUPPORT__
00315     CSettingsWithTimePeriodDlg dlg(this, -1, wxT("Configure some settings and a time period"));
00316     dlg.SetWhatToDisplay(CSettingsWithTimePeriodDlg::DISPLAY_PP);
00317     if(wxID_OK == dlg.ShowModal())
00318     {
00319         CPKIFExPathSettingsPtr exPS = dlg.GetPathSettings();
00320         AddToPathSettingsListbox(exPS);
00321     }
00322 #endif
00323 }
00331 void CEvidenceRecordVerifierDlg::OnClickRemoveArchMeds( wxCommandEvent &event )
00332 {
00333     #ifdef __INCLUDE_SCVP_SUPPORT__
00334     int selection = GetListboxArchMeds()->GetSelection();
00335     if(wxNOT_FOUND == selection){
00336         return;
00337     }
00338     GetListboxArchMeds()->Delete(selection);
00339     #endif
00340 }
00348 void CEvidenceRecordVerifierDlg::OnClickEditArchMeds( wxCommandEvent &event )
00349 {
00350     #ifdef __INCLUDE_SCVP_SUPPORT__
00351     int selection = GetListboxArchMeds()->GetSelection();
00352     if(wxNOT_FOUND == selection)
00353     {
00354         return;
00355     }
00356     
00357     TMDExMediator * med = GET_FROM_CONTROL(TMDExMediator,GetListboxArchMeds(),selection);
00358 
00359     CSettingsWithTimePeriodDlg dlg(this, -1, wxT("Configure some settings and a time period"));
00360     dlg.SetWhatToDisplay(CSettingsWithTimePeriodDlg::DISPLAY_MEDS);
00361     dlg.SetMediator(med->m_med);
00362     if(wxID_OK == dlg.ShowModal())
00363     {
00364         med->m_med = dlg.GetMediator();
00365 
00366         string aString;
00367         ostringstream oss;
00368         CPKIFValidityPtr val = med->m_med->first;
00369         CPKIFTimePtr notBefore = val->notBefore();
00370         oss << "Not before: " << MakeTimePurty(notBefore, aString);
00371         CPKIFTimePtr notAfter = val->notAfter();
00372         if(notAfter)
00373             oss << " Not after: " << MakeTimePurty(notAfter, aString);
00374 
00375         wxString wxDesc(oss.str().c_str(),wxConvUTF8);
00376 
00377         GetListboxArchMeds()->SetString(selection, wxDesc.c_str());
00378     }
00379 #endif
00380 }
00388 void CEvidenceRecordVerifierDlg::OnClickAddArchMeds( wxCommandEvent &event )
00389 {
00390     #ifdef __INCLUDE_SCVP_SUPPORT__
00391     CSettingsWithTimePeriodDlg dlg(this, -1, wxT("Configure some settings and a time period"));
00392     dlg.SetWhatToDisplay(CSettingsWithTimePeriodDlg::DISPLAY_MEDS);
00393     if(wxID_OK == dlg.ShowModal())
00394     {
00395         CPKIFExMediatorPtr exMed = dlg.GetMediator();
00396         AddToMediatorListbox(exMed);
00397     }
00398 #endif
00399 }
00407 void CEvidenceRecordVerifierDlg::OnClickCurPathProcessing( wxCommandEvent &event )
00408 {
00409     #ifdef __INCLUDE_SCVP_SUPPORT__
00410     CPKIFPathSettingsNotebook psn(NULL,-1,wxT("Path Validation Settings"),wxDefaultPosition,wxDefaultSize,
00411         wxDEFAULT_DIALOG_STYLE);
00412     psn.SetInitialPathSettings(m_curPS);
00413     psn.Center();
00414     wxButton * okButton = (wxButton *)psn.FindWindow(wxID_OK);
00415     if(okButton) okButton->SetLabel(wxT("Save"));
00416     if(wxID_OK == psn.ShowModal())
00417     {
00418         m_curPS = psn.GetPathSettings();
00419     }
00420 #endif
00421 }
00429 void CEvidenceRecordVerifierDlg::OnClickCurMeds( wxCommandEvent &event )
00430 {
00431     #ifdef __INCLUDE_SCVP_SUPPORT__
00432     CPKIFPkiEnvironmentDefinitionNotebook pedn(NULL,-1,wxT("PKI Environment Definition for SCVP Response Processing"),
00433         wxDefaultPosition,wxDefaultSize, wxDEFAULT_DIALOG_STYLE, false);
00434     pedn.SetInitialMediator(m_curMed);
00435     pedn.Center();
00436     wxButton * okButton = (wxButton *)pedn.FindWindow(wxID_OK);
00437     if(okButton) okButton->SetLabel(wxT("Save"));
00438     if(wxID_OK == pedn.ShowModal())
00439     {
00440         m_curMed = pedn.GetMediator();
00441     }
00442     #endif
00443 }
00444 
00452 void CEvidenceRecordVerifierDlg::OnOk(wxCommandEvent &event)
00453 {
00454     event.Skip();
00455 }
00463 void CEvidenceRecordVerifierDlg::OnCancel(wxCommandEvent &event)
00464 {
00465     event.Skip();
00466 }
00467 #ifdef __INCLUDE_SCVP_SUPPORT__
00468 //**********************************************************************************************
00469 // Post-display collection
00470 //**********************************************************************************************
00478 void CEvidenceRecordVerifierDlg::SetInitialEvidenceRecordVerifier(CPKIFEvidenceRecordVerifierPtr& erv)
00479 {
00480     
00481     m_erv = erv;
00482 }
00490 CPKIFEvidenceRecordVerifierPtr CEvidenceRecordVerifierDlg::GetEvidenceRecordVerifier()
00491 {
00492     return m_erv;
00493     
00494 }
00495 
00496 #endif
00497 

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