SRColleaguesPanel.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 "SRColleaguesPanel.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 "SRColleaguesPanel.h"
00023 
00024 
00025 #include "PKIFCryptUtils.h"
00026 #include "PKIFNSSCertUpdate.h"
00027 #include "PKIFNSSCRLUpdate.h"
00028 #include "PKIFNSSRepository.h"
00029 #include "PKIFNSSTrustStore.h"
00030 #include "PKIFNSSHelper.h"
00031 #include "PKIFSynonymousSourceStore.h"
00032 
00033 using namespace boost;
00034 
00035 // WDR: class implementations
00036 
00037 //----------------------------------------------------------------------------
00038 // CPKIFSRColleagueSelectionPanel
00039 //----------------------------------------------------------------------------
00040 
00041 // WDR: event table for CPKIFSRColleagueSelectionPanel
00042 
00043 BEGIN_EVENT_TABLE(CPKIFSRColleagueSelectionPanel,wxPanel)
00044 END_EVENT_TABLE()
00052 CPKIFSRColleagueSelectionPanel::CPKIFSRColleagueSelectionPanel( wxWindow *parent, wxWindowID id,
00053     const wxPoint &position, const wxSize& size, long style ) :
00054     wxPanel( parent, id, position, size, style )
00055 {
00056     // WDR: dialog function SRColleaguesPanel for CPKIFSRColleagueSelectionPanel
00057     SRColleaguesPanel( this, TRUE ); 
00058 
00059     #if !defined(WIN32)
00060     GetCheckCapiCertcrlHkcu()->Enable(false);
00061     GetCheckCapiCertcrlHklm()->Enable(false);
00062     GetCheckCapiTrustAnchorHklm()->Enable(false);
00063     GetCheckCapiTrustAnchorHkcu()->Enable(false);
00064     GetStaticCapiHkcu()->Enable(false);
00065     GetStaticCapiHklm()->Enable(false);
00066     GetCheckCapiCertcrlHkcu()->Enable(false);
00067     GetCheckCapiCertcrlHklm()->Enable(false);
00068 
00069     #endif
00070     
00071     #if defined(WIN32) || defined(_WIN32)
00072     GetStaticCapiHkcu()->SetCheckBox(GetCheckCapiCertcrlHkcu());
00073     GetStaticCapiHklm()->SetCheckBox(GetCheckCapiCertcrlHklm());
00074     #endif
00075     GetStaticNssSr()->SetCheckBox(GetCheckNssCertcrl());
00076 
00077     if(!CPKIFNSSHelper::NSSAvaliable()) 
00078     {
00079         GetStaticNssSr()->Enable(false);
00080         GetCheckNssCertcrl()->Enable(false);
00081         GetCheckNssTrustAnchors()->Enable(false);
00082     }
00083 
00084 }
00092 CPKIFSRColleagueSelectionPanel::~CPKIFSRColleagueSelectionPanel()
00093 {
00094 }
00095 
00096 // WDR: handler implementations for CPKIFSRColleagueSelectionPanel
00104 void CPKIFSRColleagueSelectionPanel::LoadStorageAndRetrievalSettings()
00105 {
00106     CPKIFCacheMediator2* sm = m_m->GetMediator<CPKIFCacheMediator2>();
00107     if(NULL == sm) return;
00108 
00109     std::vector<IPKIFColleaguePtr> c;
00110     sm->GetColleagues(c);
00111 
00112     #if defined(WIN32) || defined(_WIN32)
00113     CPKIFCAPICertUpdate2Ptr capiCertUpHKCU;
00114     CPKIFCAPICRLUpdate2Ptr capiCrlUpHKCU;
00115     CPKIFCAPIRepository2Ptr capiRepHKCU;
00116     CPKIFCAPICertUpdate2Ptr capiCertUpHKLM;
00117     CPKIFCAPICRLUpdate2Ptr capiCrlUpHKLM;
00118     CPKIFCAPIRepository2Ptr capiRepHKLM;
00119     CPKIFCAPITrustStore2Ptr capiTAHKCU;
00120     CPKIFCAPITrustStore2Ptr capiTAHKLM;
00121     CPKIFCAPITrustRootCRLRepository2Ptr capiTACRLCU;
00122     CPKIFCAPITrustRootCRLRepository2Ptr capiTACRLLM;
00123     #endif
00124     CPKIFNSSCertUpdatePtr nssCertUp;
00125     CPKIFNSSCRLUpdatePtr nssCrlUp;
00126     CPKIFNSSRepositoryPtr nssRep;
00127     CPKIFNSSTrustStorePtr nssTA;
00128     CPKIFSynonymousSourceStorePtr sss;
00129 
00130 
00131     SimpleCertCachePtr simpleCert;
00132     SimpleCRLCachePtr simpleCRL;
00133     SimpleRootStorePtr simpleRoot;
00134 
00135     std::string nssDBDir;
00136     if(IsNSSDBInitialized())
00137     {
00138         nssDBDir = GetCurrentNSSDBDir();
00139         m_cryptoColPanel->GetDirLookUpButton()->Disable();
00140         m_cryptoColPanel->GetTextNssDbdir()->SetEditable(false);
00141     }
00142 
00143     std::vector<IPKIFColleaguePtr>::iterator pos;
00144     std::vector<IPKIFColleaguePtr>::iterator end = c.end();
00145     for(pos = c.begin(); pos != end; ++pos)
00146     {
00147         
00148         if(NULL != dynamic_pointer_cast<SimpleCertCache, IPKIFColleague>(*pos))
00149         {
00150             simpleCert = dynamic_pointer_cast<SimpleCertCache, IPKIFColleague>(*pos);
00151         }
00152         #if defined(WIN32) || defined(_WIN32)
00153         else if(NULL != dynamic_pointer_cast<CPKIFCAPICertUpdate2, IPKIFColleague>(*pos))
00154         {
00155             CPKIFCAPICertUpdate2Ptr tmp = dynamic_pointer_cast<CPKIFCAPICertUpdate2, IPKIFColleague>(*pos);
00156             const char* store = tmp->GetStore();
00157             int regLoc = tmp->GetRegLoc();
00158             if(0 == strcmp(store, g_defCACCAPIStore))
00159             {
00160                 if(CERT_SYSTEM_STORE_CURRENT_USER == regLoc)
00161                     capiCertUpHKCU = tmp;
00162                 else if(CERT_SYSTEM_STORE_LOCAL_MACHINE == regLoc)
00163                     capiCertUpHKLM = tmp;
00164             }
00165         }
00166         else if(NULL != dynamic_pointer_cast<CPKIFCAPICRLUpdate2, IPKIFColleague>(*pos))
00167         {
00168             CPKIFCAPICRLUpdate2Ptr tmp = dynamic_pointer_cast<CPKIFCAPICRLUpdate2, IPKIFColleague>(*pos);
00169             const char* store = tmp->GetStore();
00170             int regLoc = tmp->GetRegLoc();
00171             if(0 == strcmp(store, g_defCACCAPIStore))
00172             {
00173                 if(CERT_SYSTEM_STORE_CURRENT_USER == regLoc)
00174                     capiCrlUpHKCU = tmp;
00175                 else if(CERT_SYSTEM_STORE_LOCAL_MACHINE == regLoc)
00176                     capiCrlUpHKLM = tmp;
00177             }
00178         }
00179         else if(NULL != dynamic_pointer_cast<CPKIFCAPIRepository2, IPKIFColleague>(*pos))
00180         {
00181             CPKIFCAPIRepository2Ptr tmp = dynamic_pointer_cast<CPKIFCAPIRepository2, IPKIFColleague>(*pos);
00182             const char* store = tmp->GetStore();
00183             int regLoc = tmp->GetRegLoc();
00184             if(0 == strcmp(store, g_defCACCAPIStore))
00185             {
00186                 if(CERT_SYSTEM_STORE_CURRENT_USER == regLoc)
00187                     capiRepHKCU = tmp;
00188                 else if(CERT_SYSTEM_STORE_LOCAL_MACHINE == regLoc)
00189                     capiRepHKLM = tmp;
00190             }
00191         }
00192         else if(NULL != dynamic_pointer_cast<CPKIFCAPITrustStore2, IPKIFColleague>(*pos))
00193         {
00194             CPKIFCAPITrustStore2Ptr tmp = dynamic_pointer_cast<CPKIFCAPITrustStore2, IPKIFColleague>(*pos);
00195             const char* store = tmp->GetStore();
00196             int regLoc = tmp->GetRegLoc();
00197             if(0 == strcmp(store, g_defCACCAPITrustStore))
00198             {
00199                 if(CERT_SYSTEM_STORE_CURRENT_USER == regLoc)
00200                     capiTAHKCU = tmp;
00201                 else if(CERT_SYSTEM_STORE_LOCAL_MACHINE == regLoc)
00202                     capiTAHKLM = tmp;
00203             }
00204         }
00205         else if(NULL != dynamic_pointer_cast<CPKIFCAPITrustRootCRLRepository2, IPKIFColleague>(*pos))
00206         {
00207             CPKIFCAPITrustRootCRLRepository2Ptr tmp = dynamic_pointer_cast<CPKIFCAPITrustRootCRLRepository2, IPKIFColleague>(*pos);
00208             const char* store = tmp->GetStore();
00209             int regLoc = tmp->GetRegLoc();
00210             if(0 == strcmp(store, g_defCACCAPITrustStore))
00211             {
00212                 if(CERT_SYSTEM_STORE_CURRENT_USER == regLoc)
00213                     capiTACRLCU = tmp;
00214                 else if(CERT_SYSTEM_STORE_LOCAL_MACHINE == regLoc)
00215                     capiTACRLLM = tmp;
00216             }
00217             
00218         }
00219         #endif
00220         else if(NULL != dynamic_pointer_cast<SimpleCRLCache, IPKIFColleague>(*pos))
00221         {
00222             simpleCRL = dynamic_pointer_cast<SimpleCRLCache, IPKIFColleague>(*pos);
00223         }
00224         else if(NULL != dynamic_pointer_cast<SimpleRootStore, IPKIFColleague>(*pos))
00225         {
00226             simpleRoot = dynamic_pointer_cast<SimpleRootStore, IPKIFColleague>(*pos);
00227         }
00228         else if(NULL != dynamic_pointer_cast<CPKIFNSSRepository, IPKIFColleague>(*pos))
00229         {
00230             nssRep = dynamic_pointer_cast<CPKIFNSSRepository, IPKIFColleague>(*pos);
00231         }
00232         else if(NULL != dynamic_pointer_cast<CPKIFNSSCRLUpdate, IPKIFColleague>(*pos))
00233         {
00234             nssCrlUp = dynamic_pointer_cast<CPKIFNSSCRLUpdate, IPKIFColleague>(*pos);
00235         }
00236         else if(NULL != dynamic_pointer_cast<CPKIFNSSCertUpdate, IPKIFColleague>(*pos))
00237         {
00238             nssCertUp = dynamic_pointer_cast<CPKIFNSSCertUpdate, IPKIFColleague>(*pos);
00239         }
00240         else if(NULL != dynamic_pointer_cast<CPKIFNSSTrustStore, IPKIFColleague>(*pos))
00241         {
00242             nssTA = dynamic_pointer_cast<CPKIFNSSTrustStore, IPKIFColleague>(*pos);
00243         }
00244         else if(NULL != dynamic_pointer_cast<CPKIFSynonymousSourceStore, IPKIFColleague>(*pos))
00245         {
00246             sss = dynamic_pointer_cast<CPKIFSynonymousSourceStore, IPKIFColleague>(*pos);
00247         }
00248     }
00249     #if defined(WIN32) || defined(_WIN32)
00250     GetCheckCapiCertcrlHkcu()->SetValue(NULL != capiRepHKCU || NULL != capiCrlUpHKCU || NULL != capiRepHKCU);
00251     GetCheckCapiCertcrlHklm()->SetValue(NULL != capiRepHKLM || NULL != capiCrlUpHKLM || NULL != capiRepHKLM);
00252     GetCheckCapiTrustAnchorHklm()->SetValue(NULL != capiTAHKLM);
00253     GetCheckCapiTrustAnchorHkcu()->SetValue(NULL != capiTAHKCU);
00254     #endif
00255     GetCheckNssCertcrl()->SetValue(NULL != nssRep || NULL != nssCrlUp || NULL != nssCertUp);
00256     GetCheckSimpleCert()->SetValue(NULL != simpleCert);  
00257     GetCheckSimpleCrl()->SetValue(NULL != simpleCRL);
00258     GetCheckTrustAnchors()->SetValue(NULL != simpleRoot);
00259     GetCheckNssTrustAnchors()->SetValue(NULL != nssTA);
00260     GetCheckSiaAiaCrldpCache()->SetValue(NULL != sss);
00261 }
00262 
00270 void CPKIFSRColleagueSelectionPanel::OnInitDialog(wxInitDialogEvent& event)
00271 {
00272     if(NULL == m_m) return;
00273 
00274     LoadStorageAndRetrievalSettings();
00275 }
00283 void CPKIFSRColleagueSelectionPanel::SetInitialMediator(
00285     IPKIFMediatorPtr& m)
00286 {
00287     m_m = m;
00288 }
00289 
00297 void CPKIFSRColleagueSelectionPanel::SetCryptoColleaguePanel(
00299     CPKIFColleagueSelectionPanel* cryptoColPanel)
00300 {
00301     m_cryptoColPanel = cryptoColPanel;
00302 }
00303 

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