diff options
| author | Carl Hetherington <cth@carlh.net> | 2015-07-12 20:48:04 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2015-07-12 20:48:04 +0100 |
| commit | 12f80dfc3b6ad528903053d44b5810202f9f3227 (patch) | |
| tree | e363ec7a1feff125f6c41d442961c707f4489422 /src | |
| parent | 970f39ca6207666985f53d2bba6f8e60aeaad5a9 (diff) | |
Reload existing certificate chain's details when creating a new one.
Diffstat (limited to 'src')
| -rw-r--r-- | src/wx/config_dialog.cc | 20 | ||||
| -rw-r--r-- | src/wx/make_signer_chain_dialog.cc | 34 | ||||
| -rw-r--r-- | src/wx/make_signer_chain_dialog.h | 9 |
3 files changed, 55 insertions, 8 deletions
diff --git a/src/wx/config_dialog.cc b/src/wx/config_dialog.cc index f744ca83f..86ad2dbe1 100644 --- a/src/wx/config_dialog.cc +++ b/src/wx/config_dialog.cc @@ -731,7 +731,25 @@ private: void remake_certificates () { - MakeSignerChainDialog* d = new MakeSignerChainDialog (_panel); + dcp::CertificateChain chain = Config::instance()->signer()->certificates (); + + string intermediate_common_name; + if (chain.root_to_leaf().size() >= 3) { + dcp::CertificateChain::List all = chain.root_to_leaf (); + dcp::CertificateChain::List::iterator i = all.begin (); + ++i; + intermediate_common_name = i->subject_common_name (); + } + + MakeSignerChainDialog* d = new MakeSignerChainDialog ( + _panel, + chain.root().subject_organization_name (), + chain.root().subject_organizational_unit_name (), + chain.root().subject_common_name (), + intermediate_common_name, + chain.leaf().subject_common_name () + ); + if (d->ShowModal () == wxID_OK) { _signer.reset ( new dcp::Signer ( diff --git a/src/wx/make_signer_chain_dialog.cc b/src/wx/make_signer_chain_dialog.cc index 8df208934..df8b198e3 100644 --- a/src/wx/make_signer_chain_dialog.cc +++ b/src/wx/make_signer_chain_dialog.cc @@ -18,17 +18,39 @@ */ #include "make_signer_chain_dialog.h" +#include <boost/algorithm/string.hpp> -MakeSignerChainDialog::MakeSignerChainDialog (wxWindow* parent) +using std::string; + +MakeSignerChainDialog::MakeSignerChainDialog ( + wxWindow* parent, + string organisation, + string organisational_unit_name, + string root_common_name, + string intermediate_common_name, + string leaf_common_name + ) : TableDialog (parent, _("Make certificate chain"), 2, true) { wxTextValidator validator (wxFILTER_EXCLUDE_CHAR_LIST); validator.SetCharExcludes (wxT ("/")); + if (boost::algorithm::starts_with (root_common_name, ".")) { + root_common_name = root_common_name.substr (1); + } + + if (boost::algorithm::starts_with (intermediate_common_name, ".")) { + intermediate_common_name = intermediate_common_name.substr (1); + } + + if (boost::algorithm::starts_with (leaf_common_name, "CS.")) { + leaf_common_name = leaf_common_name.substr (3); + } + add (_("Organisation"), true); - add (_organisation = new wxTextCtrl (this, wxID_ANY, wxT (""), wxDefaultPosition, wxDefaultSize, 0, validator)); + add (_organisation = new wxTextCtrl (this, wxID_ANY, std_to_wx (organisation), wxDefaultPosition, wxDefaultSize, 0, validator)); add (_("Organisational unit"), true); - add (_organisational_unit = new wxTextCtrl (this, wxID_ANY, wxT (""), wxDefaultPosition, wxDefaultSize, 0, validator)); + add (_organisational_unit = new wxTextCtrl (this, wxID_ANY, std_to_wx (organisational_unit_name), wxDefaultPosition, wxDefaultSize, 0, validator)); add (_("Root common name"), true); @@ -36,7 +58,7 @@ MakeSignerChainDialog::MakeSignerChainDialog (wxWindow* parent) wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL); s->Add (new wxStaticText (this, wxID_ANY, wxT (".")), 0, wxALIGN_CENTER_VERTICAL); s->Add (_root_common_name = new wxTextCtrl ( - this, wxID_ANY, wxT (""), wxDefaultPosition, wxDefaultSize, 0, validator), 1, wxALIGN_CENTER_VERTICAL + this, wxID_ANY, std_to_wx (root_common_name), wxDefaultPosition, wxDefaultSize, 0, validator), 1, wxALIGN_CENTER_VERTICAL ); add (s); } @@ -47,7 +69,7 @@ MakeSignerChainDialog::MakeSignerChainDialog (wxWindow* parent) wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL); s->Add (new wxStaticText (this, wxID_ANY, wxT (".")), 0, wxALIGN_CENTER_VERTICAL); s->Add (_intermediate_common_name = new wxTextCtrl ( - this, wxID_ANY, wxT (""), wxDefaultPosition, wxDefaultSize, 0, validator), 1, wxALIGN_CENTER_VERTICAL + this, wxID_ANY, std_to_wx (intermediate_common_name), wxDefaultPosition, wxDefaultSize, 0, validator), 1, wxALIGN_CENTER_VERTICAL ); add (s); } @@ -58,7 +80,7 @@ MakeSignerChainDialog::MakeSignerChainDialog (wxWindow* parent) wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL); s->Add (new wxStaticText (this, wxID_ANY, wxT ("CS.")), 0, wxALIGN_CENTER_VERTICAL); s->Add (_leaf_common_name = new wxTextCtrl ( - this, wxID_ANY, wxT (""), wxDefaultPosition, wxDefaultSize, 0, validator), 1, wxALIGN_CENTER_VERTICAL + this, wxID_ANY, std_to_wx (leaf_common_name), wxDefaultPosition, wxDefaultSize, 0, validator), 1, wxALIGN_CENTER_VERTICAL ); add (s); } diff --git a/src/wx/make_signer_chain_dialog.h b/src/wx/make_signer_chain_dialog.h index d05b4381f..0ebffeb26 100644 --- a/src/wx/make_signer_chain_dialog.h +++ b/src/wx/make_signer_chain_dialog.h @@ -23,7 +23,14 @@ class MakeSignerChainDialog : public TableDialog { public: - MakeSignerChainDialog (wxWindow* parent); + MakeSignerChainDialog ( + wxWindow* parent, + std::string organisation, + std::string organisational_unit_name, + std::string root_common_name, + std::string intermediate_common_name, + std::string leaf_common_name + ); std::string organisation () const { return wx_to_std (_organisation->GetValue ()); |
