Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Added SSLCertCollectionString to frmSSLCertificate & frmInvalidSSLCertificate
authorSteve Brokenshire <sbrokenshire@xestia.co.uk>
Fri, 19 Aug 2016 22:54:28 +0000 (23:54 +0100)
committerSteve Brokenshire <sbrokenshire@xestia.co.uk>
Fri, 19 Aug 2016 22:54:28 +0000 (23:54 +0100)
source/frmInvalidSSLCertificate.cpp
source/frmInvalidSSLCertificate.h
source/frmSSLCertificate.cpp
source/frmSSLCertificate.h

index 8937802..fb3a4e0 100644 (file)
@@ -53,7 +53,7 @@ void frmInvalidSSLCertificate::ViewCertificates( wxCommandEvent& event )
        
        frmSSLCertificate *frameSSLCert = new frmSSLCertificate ( this );
        frameSSLCert->StartCertFrom(0);
-       frameSSLCert->SetupCerts(CertData);
+       frameSSLCert->SetupCertsString(CertDataString);
        frameSSLCert->ShowModal();
                
        delete frameSSLCert;
@@ -103,6 +103,27 @@ void frmInvalidSSLCertificate::LoadDataNew(SSLCertCollection CertDataInc,
        
 }
 
+void frmInvalidSSLCertificate::LoadDataNew(SSLCertCollectionString CertDataInc, 
+                                       std::string DomainNameInc)
+{
+
+       // Load the invalid SSL certificate dialog for a new account.
+       
+       AccountName = DomainNameInc;
+       CertDataString = CertDataInc;
+       
+       wxString SSLTextLabel;
+       
+       SSLTextLabel.Append(wxString::Format(_("An invalid SSL certificate was received from the server for the '%s' account.\n\n"), AccountName));
+       SSLTextLabel.Append(_("Click on one of the following buttons:\n\n"));
+       SSLTextLabel.Append(_("- Accept to accept the SSL certificate for this session and future sessions until the certificate changes.\n"));
+       SSLTextLabel.Append(_("- Reject to not use this certificate and disconnect.\n"));
+       SSLTextLabel.Append(_("- View Certificates to review the certificates that were received."));
+       
+       lblSSLText->SetLabel(SSLTextLabel);
+       
+}
+
 int frmInvalidSSLCertificate::GetResult()
 {
 
index 18456b8..6a47166 100644 (file)
@@ -46,6 +46,7 @@ class frmInvalidSSLCertificate : public frmInvalidSSLCertificateADT
                void ViewCertificates( wxCommandEvent& event );
        private:
                SSLCertCollection CertData;
+               SSLCertCollectionString CertDataString;
                int intResult;
                wxString AccountName;
        public:
@@ -53,6 +54,7 @@ class frmInvalidSSLCertificate : public frmInvalidSSLCertificateADT
                frmInvalidSSLCertificate( wxWindow* parent );
                void LoadData(SSLCertCollection CertDataInc, wxString AccountNameInc);
                void LoadDataNew(SSLCertCollection CertDataInc, wxString DomainNameInc);
+               void LoadDataNew(SSLCertCollectionString CertDataInc, std::string DomainNameInc);
                int GetResult();
        //// end generated class members
        
index 3db6a15..fee0b59 100644 (file)
@@ -19,6 +19,8 @@
 #include "frmSSLCertificate.h"
 #include <wx/wx.h>
 
+using namespace std;
+
 frmSSLCertificate::frmSSLCertificate( wxWindow* parent )
 :
 frmSSLCertificateADT( parent )
@@ -159,6 +161,139 @@ void frmSSLCertificate::SetupCerts(SSLCertCollection SSLCertsInc)
 
 }
 
+void frmSSLCertificate::SetupCertsString(SSLCertCollectionString SSLCertsInc)
+{
+
+       // Grab the certificates, start from the one requested and show.
+               
+       lblValidityStatus->Hide();
+       
+       std::map<int, struct SSLCertDataString>::iterator SCDIter;
+       SCDIter = SSLCertsInc.SSLCollection.find(StartFrom); 
+       
+       // Setup the summary tab.
+       
+       // Split the subject data down.
+       
+       std::map<string, string>::iterator SDIter = SCDIter->second.CertData.find("Subject");
+       std::map<string, string> SubjectData = GetSubjectData(SDIter->second);
+       
+       // Get the common name (CN).
+       
+       std::map<string, string>::iterator CNiter = SubjectData.find("CN");
+       
+       lblCertName->SetLabel(CNiter->second);
+       
+       // Split the issuer data down.
+       
+       // Attempt to grab the organisation name first then
+       // the common name if it doesn't exist.
+       
+       if (SubjectData.find("O") != SubjectData.end()){
+       
+               std::map<string, string>::iterator Oiter = SubjectData.find("O");
+               lblIssuedToData->SetLabel(Oiter->second);
+       
+       } else {
+       
+               lblIssuedToData->SetLabel(CNiter->second);
+       
+       }
+       
+       // Setup the valid from date.
+
+       std::map<string, string>::iterator Validiter = SCDIter->second.CertData.find("Start date");
+       
+       wxDateTime ValidFromDate;
+       ValidFromDate.ParseDate(Validiter->second);
+       
+       lblValidFromData->SetLabel(ValidFromDate.FormatDate());
+       
+       // Setup the expiry date.
+       
+       std::map<string, string>::iterator Expiryiter = SCDIter->second.CertData.find("Expire date");
+       
+       wxDateTime ExpiryDate;
+       ExpiryDate.ParseDate(Expiryiter->second);
+       
+       lblValidUntilData->SetLabel(ExpiryDate.FormatDate());
+       
+       // Setup the detail tab.
+
+       wxListItem ColumnDataName;
+       ColumnDataName.SetId(0);
+       ColumnDataName.SetText(_("Name"));
+       ColumnDataName.SetWidth(115);
+       lstValues->InsertColumn(0, ColumnDataName);
+
+       wxListItem ColumnDataValue;
+       ColumnDataValue.SetId(0);
+       ColumnDataValue.SetText(_("Value"));
+       ColumnDataValue.SetWidth(115);
+       lstValues->InsertColumn(0, ColumnDataValue);
+
+       int SSLIndex = 0;
+
+       for (std::map<string, string>::iterator iter = SCDIter->second.CertData.begin(); 
+       iter != SCDIter->second.CertData.end(); ++iter){
+       
+           // Ignore certificate data.
+       
+           if (iter->first == wxT("Cert")){
+           
+               continue;
+           
+           }
+       
+           wxListItem SSLInfo;
+      
+           SSLInfo.SetId(0);
+           SSLInfo.SetText(_("Mooo"));             
+           SSLIndex = lstValues->InsertItem(SSLInfo);
+    
+           lstValues->SetItem(SSLIndex, 0, iter->first);
+           lstValues->SetItem(SSLIndex, 1, iter->second);
+       
+       }
+       
+       // Setup the hierachy tab.
+       
+       wxTreeItemId CertTreeId;
+       wxTreeItemId PrevCertTreeId;
+       
+       for (std::map<int, struct SSLCertDataString>::reverse_iterator iter = SSLCertsInc.SSLCollection.rbegin(); 
+       iter != SSLCertsInc.SSLCollection.rend(); ++iter){
+       
+               if (iter->first < StartFrom){
+               
+                       continue;
+               
+               }
+       
+               // Get the common name of the certificate. (Fetch subject).
+               
+               std::map<string, string>::iterator CSDIter = iter->second.CertData.find("Subject");
+               std::map<string, string> CertSubjectData = GetSubjectData(CSDIter->second);
+       
+               // Get the common name (CN).
+       
+               std::map<string, string>::iterator CertCNiter = CertSubjectData.find("CN");
+       
+               // Add to the hierachy.
+               
+               SSLCertItemData *SSLCertID = new SSLCertItemData((iter->first + 1));
+               
+               CertTreeId = treHierarchy->AppendItem(PrevCertTreeId, CertCNiter->second, 0, -1, SSLCertID);
+               PrevCertTreeId = CertTreeId;
+       
+       }
+       
+       treHierarchy->ExpandAll();
+       
+       SSLCertDataString = SSLCertsInc;
+
+}
+
 std::map<wxString,wxString> frmSSLCertificate::GetSubjectData(wxString SubjectData)
 {
 
@@ -202,6 +337,49 @@ std::map<wxString,wxString> frmSSLCertificate::GetSubjectData(wxString SubjectDa
 
 }
 
+std::map<string,string> frmSSLCertificate::GetSubjectData(std::string SubjectData)
+{
+
+       // Get the subject data and put into a map<wxString,wxString>
+       
+       std::map<string,string> SubjectDataFinal;
+       wxStringTokenizer SubjectDataToken(wxString(SubjectData.c_str(), wxConvUTF8), wxT(";"));
+       wxString StringData;
+       wxString SettingName;
+       wxString SettingValue;
+       
+       while(SubjectDataToken.HasMoreTokens())
+       {
+       
+               StringData = SubjectDataToken.GetNextToken();
+       
+               // Split the data down between the equals sign.
+               
+               wxStringTokenizer DataSplitToken(StringData, wxT("="));
+       
+               while (DataSplitToken.HasMoreTokens()){
+               
+                       SettingName = DataSplitToken.GetNextToken();
+                       SettingValue = DataSplitToken.GetNextToken();
+                       SettingName.Trim(TRUE);
+                       SettingName.Trim(FALSE);
+                       SettingValue.Trim(TRUE);
+                       SettingValue.Trim(FALSE);
+                       
+                       SubjectDataFinal.insert(std::make_pair(SettingName.ToStdString(), SettingValue.ToStdString()));
+               
+               }
+               
+               StringData.Clear();
+               SettingName.Clear();
+               SettingValue.Clear();
+       
+       }
+       
+       return SubjectDataFinal;
+
+}
+
 void frmSSLCertificate::LoadValueData( wxListEvent& event )
 {
        
index db98341..95941fe 100644 (file)
@@ -43,13 +43,16 @@ class frmSSLCertificate : public frmSSLCertificateADT
                void CheckCertificate( wxTreeEvent& event );
        public:
                void SetupCerts(SSLCertCollection SSLCertInc);
+               void SetupCertsString(SSLCertCollectionString SSLCertInc);
                void StartCertFrom(int StartFromInc);
                /** Constructor */
                frmSSLCertificate( wxWindow* parent );
        private:
                int StartFrom = 0;
                SSLCertCollection SSLCertData;
+               SSLCertCollectionString SSLCertDataString;
                std::map<wxString,wxString> GetSubjectData(wxString SubjectData);
+               std::map<std::string,std::string> GetSubjectData(std::string SubjectData);
                class SSLCertItemData : public wxTreeItemData
                {
 
Xestia Software Development
Yn Maystri
© 2006 - 2019 Xestia Software Development
Software

Xestia Address Book
Xestia Calendar
Development

Xestia Gelforn
Everything else

About
News
Privacy Policy