From 24ad0629ae9edad83514e329e7173b94a8680ea6 Mon Sep 17 00:00:00 2001 From: Tor Lillqvist Date: Mon, 16 Feb 2015 14:02:23 +0200 Subject: tdf#88427: Add GUI to enter and maintain a list of Time Stamping Authorities It is just a simple list of entered URLs, accessed from the Security page. No sanity checks for now. No selection of a "default" one for now. Implementation is much simpler this way. The actual selection of one TSA (or none) is done when exporting to PDF. Change-Id: I0392eabc9b9629a6f0a767d1b2337622a61c120f --- cui/Library_cui.mk | 1 + cui/UIConfig_cui.mk | 1 + cui/source/options/optinet2.cxx | 18 ++ cui/source/options/optinet2.hxx | 6 +- cui/source/options/tsaurls.cxx | 120 +++++++++++ cui/source/options/tsaurls.hxx | 40 ++++ cui/uiconfig/ui/optsecuritypage.ui | 75 +++++++ cui/uiconfig/ui/tsaurldialog.ui | 230 +++++++++++++++++++++ .../schema/org/openoffice/Office/Common.xcs | 5 + 9 files changed, 494 insertions(+), 2 deletions(-) create mode 100644 cui/source/options/tsaurls.cxx create mode 100644 cui/source/options/tsaurls.hxx create mode 100644 cui/uiconfig/ui/tsaurldialog.ui diff --git a/cui/Library_cui.mk b/cui/Library_cui.mk index 6df06f996b3b..833af3ccadc8 100644 --- a/cui/Library_cui.mk +++ b/cui/Library_cui.mk @@ -168,6 +168,7 @@ $(eval $(call gb_Library_add_exception_objects,cui,\ cui/source/options/sdbcdriverenum \ cui/source/options/securityoptions \ cui/source/options/treeopt \ + cui/source/options/tsaurls \ cui/source/options/webconninfo \ cui/source/tabpages/align \ cui/source/tabpages/autocdlg \ diff --git a/cui/UIConfig_cui.mk b/cui/UIConfig_cui.mk index d8cd1784dc75..36f59421afe8 100644 --- a/cui/UIConfig_cui.mk +++ b/cui/UIConfig_cui.mk @@ -197,6 +197,7 @@ $(eval $(call gb_UIConfig_add_uifiles,cui,\ cui/uiconfig/ui/textflowpage \ cui/uiconfig/ui/thesaurus \ cui/uiconfig/ui/transparencytabpage \ + cui/uiconfig/ui/tsaurldialog \ cui/uiconfig/ui/twolinespage \ cui/uiconfig/ui/wordcompletionpage \ cui/uiconfig/ui/zoomdialog \ diff --git a/cui/source/options/optinet2.cxx b/cui/source/options/optinet2.cxx index e7cd019bc665..50e853008ad7 100644 --- a/cui/source/options/optinet2.cxx +++ b/cui/source/options/optinet2.cxx @@ -85,6 +85,7 @@ #include "securityoptions.hxx" #include "webconninfo.hxx" #include "certpath.hxx" +#include "tsaurls.hxx" using namespace ::com::sun::star; using namespace ::com::sun::star::uno; @@ -601,6 +602,8 @@ SvxSecurityTabPage::SvxSecurityTabPage(vcl::Window* pParent, const SfxItemSet& r get(m_pMacroSecPB, "macro"); get(m_pCertFrame, "certificatepath"); get(m_pCertPathPB, "cert"); + get(m_pTSAURLsFrame, "tsaurls"); + get(m_pTSAURLsPB, "tsas"); m_sPasswordStoringDeactivateStr = get("nopasswordsave")->GetText(); InitControls(); @@ -612,6 +615,7 @@ SvxSecurityTabPage::SvxSecurityTabPage(vcl::Window* pParent, const SfxItemSet& r m_pShowConnectionsPB->SetClickHdl( LINK( this, SvxSecurityTabPage, ShowPasswordsHdl ) ); m_pMacroSecPB->SetClickHdl( LINK( this, SvxSecurityTabPage, MacroSecPBHdl ) ); m_pCertPathPB->SetClickHdl( LINK( this, SvxSecurityTabPage, CertPathPBHdl ) ); + m_pTSAURLsPB->SetClickHdl( LINK( this, SvxSecurityTabPage, TSAURLsPBHdl ) ); ActivatePage( rSet ); } @@ -782,6 +786,20 @@ IMPL_LINK_NOARG(SvxSecurityTabPage, CertPathPBHdl) return 0; } +IMPL_LINK_NOARG(SvxSecurityTabPage, TSAURLsPBHdl) +{ + // Unlike the mpCertPathDlg, we *don't* keep the same dialog object around between + // invocations. Seems clearer to my little brain that way. + + TSAURLsDialog* pTSAURLsDlg = new TSAURLsDialog(this); + + pTSAURLsDlg->Execute(); + + delete pTSAURLsDlg; + + return 0; +} + IMPL_LINK_NOARG(SvxSecurityTabPage, MacroSecPBHdl) { try diff --git a/cui/source/options/optinet2.hxx b/cui/source/options/optinet2.hxx index c7d81b756f12..5bb9c0547160 100644 --- a/cui/source/options/optinet2.hxx +++ b/cui/source/options/optinet2.hxx @@ -123,9 +123,7 @@ protected: // class SvxSecurityTabPage --------------------------------------------- class SvtSecurityOptions; - class CertPathDialog; - class SvxSecurityTabPage : public SfxTabPage { using TabPage::ActivatePage; @@ -147,6 +145,9 @@ private: VclContainer* m_pCertFrame; PushButton* m_pCertPathPB; + VclContainer* m_pTSAURLsFrame; + PushButton* m_pTSAURLsPB; + SvtSecurityOptions* mpSecOptions; svx::SecurityOptionsDialog* mpSecOptDlg; @@ -161,6 +162,7 @@ private: DECL_LINK(ShowPasswordsHdl, void *); DECL_LINK(MacroSecPBHdl, void* ); DECL_LINK(CertPathPBHdl, void* ); + DECL_LINK(TSAURLsPBHdl, void* ); void InitControls(); diff --git a/cui/source/options/tsaurls.cxx b/cui/source/options/tsaurls.cxx new file mode 100644 index 000000000000..9db380135ed7 --- /dev/null +++ b/cui/source/options/tsaurls.cxx @@ -0,0 +1,120 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include +#include +#include + +#include "tsaurls.hxx" + +#include + +using namespace ::com::sun::star; + +TSAURLsDialog::TSAURLsDialog(vcl::Window* pParent) + : ModalDialog(pParent, "TSAURLDialog", "cui/ui/tsaurldialog.ui") +{ + get(m_pAddBtn, "add"); + get(m_pDeleteBtn, "delete"); + get(m_pOKBtn, "ok"); + get(m_pURLListBox, "urls"); + + m_pURLListBox->SetDropDownLineCount(8); + m_pURLListBox->set_width_request(m_pURLListBox->approximate_char_width() * 32); + m_pOKBtn->Disable(); + + m_pAddBtn->SetClickHdl( LINK( this, TSAURLsDialog, AddHdl_Impl ) ); + m_pDeleteBtn->SetClickHdl( LINK( this, TSAURLsDialog, DeleteHdl_Impl ) ); + m_pOKBtn->SetClickHdl( LINK( this, TSAURLsDialog, OKHdl_Impl ) ); + + try + { + css::uno::Sequence aUserSetTSAURLs(officecfg::Office::Common::Security::Scripting::TSAURLs::get()); + + for (auto i = aUserSetTSAURLs.begin(); i != aUserSetTSAURLs.end(); ++i) + { + AddTSAURL(*i); + } + } + catch (const uno::Exception &e) + { + SAL_WARN("cui.options", "TSAURLsDialog::TSAURLsDialog(): caught exception" << e.Message); + } +} + +IMPL_LINK_NOARG(TSAURLsDialog, OKHdl_Impl) +{ + std::shared_ptr batch(comphelper::ConfigurationChanges::create()); + + css::uno::Sequence aNewValue(m_aURLs.size()); + size_t n(0); + + for (auto i = m_aURLs.cbegin(); i != m_aURLs.cend(); ++i) + aNewValue[n++] = *i; + officecfg::Office::Common::Security::Scripting::TSAURLs::set(aNewValue, batch); + batch->commit(); + + EndDialog(RET_OK); + + return 0; +} + +TSAURLsDialog::~TSAURLsDialog() +{ +} + +void TSAURLsDialog::AddTSAURL(const OUString& rURL) +{ + m_aURLs.insert(rURL); + + m_pURLListBox->SetUpdateMode(false); + m_pURLListBox->Clear(); + + for (auto i = m_aURLs.cbegin(); i != m_aURLs.cend(); ++i) + { + m_pURLListBox->InsertEntry(*i); + } + + m_pURLListBox->SetUpdateMode(true); +} + +IMPL_LINK_NOARG(TSAURLsDialog, AddHdl_Impl) +{ + OUString aURL; + OUString aDesc( get("enteraurl")->GetText() ); + + SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); + boost::scoped_ptr pDlg(pFact->CreateSvxNameDialog( m_pAddBtn, aURL, aDesc)); + + if ( pDlg->Execute() == RET_OK ) + { + pDlg->GetName( aURL ); + + AddTSAURL(aURL); + m_pOKBtn->Enable(); + } + + return 0; +} + +IMPL_LINK_NOARG(TSAURLsDialog, DeleteHdl_Impl) +{ + sal_Int32 nSel = m_pURLListBox->GetSelectEntryPos(); + + if (nSel == LISTBOX_ENTRY_NOTFOUND) + return 0; + + m_aURLs.erase(m_pURLListBox->GetEntry(nSel)); + m_pURLListBox->RemoveEntry(nSel); + m_pOKBtn->Enable(); + + return 0; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cui/source/options/tsaurls.hxx b/cui/source/options/tsaurls.hxx new file mode 100644 index 000000000000..aba749181ac5 --- /dev/null +++ b/cui/source/options/tsaurls.hxx @@ -0,0 +1,40 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#ifndef INCLUDED_CUI_SOURCE_OPTIONS_TSAURLS_HXX +#define INCLUDED_CUI_SOURCE_OPTIONS_TSAURLS_HXX + +#include +#include + +class TSAURLsDialog : public ModalDialog +{ +private: + ListBox* m_pURLListBox; + PushButton* m_pAddBtn; + PushButton* m_pDeleteBtn; + OKButton* m_pOKBtn; + + DECL_LINK(AddHdl_Impl, void *); + DECL_LINK(DeleteHdl_Impl, void *); + DECL_LINK(OKHdl_Impl, void *); + + std::set m_aURLs; + + void AddTSAURL(const OUString &rURL); + +public: + TSAURLsDialog(vcl::Window* pParent); + virtual ~TSAURLsDialog(); + +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cui/uiconfig/ui/optsecuritypage.ui b/cui/uiconfig/ui/optsecuritypage.ui index 007bbc6b2fb4..46b342a783b7 100644 --- a/cui/uiconfig/ui/optsecuritypage.ui +++ b/cui/uiconfig/ui/optsecuritypage.ui @@ -7,6 +7,81 @@ False 6 12 + + + True + False + True + 0 + none + + + True + False + True + 6 + 12 + + + True + False + True + 24 + + + True + False + True + 0 + Maintain a list of Time Stamping Authority (TSA) URLs to be optionally for digital signatures in PDF export. + True + 56 + + + 0 + 0 + 1 + 1 + + + + + _TSAs... + True + True + True + center + True + + + 1 + 0 + 1 + 1 + + + + + + + + + True + False + TSAs + + + + + + + + 0 + 4 + 1 + 1 + + True diff --git a/cui/uiconfig/ui/tsaurldialog.ui b/cui/uiconfig/ui/tsaurldialog.ui new file mode 100644 index 000000000000..37ed401cbe6c --- /dev/null +++ b/cui/uiconfig/ui/tsaurldialog.ui @@ -0,0 +1,230 @@ + + + + + + + False + 6 + Time Stamping Authority URLs + normal + + + False + vertical + 12 + + + False + end + + + gtk-ok + True + True + True + True + True + True + + + False + True + 0 + + + + + gtk-cancel + True + True + True + True + + + False + True + 1 + + + + + gtk-help + True + True + True + True + + + False + True + 2 + + + + + _Add... + True + True + True + True + True + True + + + False + True + 3 + True + + + + + _Delete... + True + True + True + True + True + True + + + False + True + 4 + True + + + + + False + True + end + 0 + + + + + True + False + True + True + 0 + none + + + True + False + True + True + 6 + 12 + + + True + False + True + True + 6 + + + True + False + 0 + 0 + Add or delete Time Stamp Authority URLs + True + True + paths + 60 + + + 0 + 0 + 1 + 1 + + + + + False + True + + + True + False + True + Enter a Time Stamp Authority URL + + + 2 + 0 + 1 + 1 + + + + + 0 + 1 + 1 + 1 + + + + + True + True + True + True + in + + + True + True + True + True + + + + + + 0 + 2 + 1 + 1 + + + + + + + + + + + True + False + TSA URL + + + + + + + + False + True + 1 + + + + + + ok + cancel + help + add + + + diff --git a/officecfg/registry/schema/org/openoffice/Office/Common.xcs b/officecfg/registry/schema/org/openoffice/Office/Common.xcs index 4140ca530117..d496c851baff 100644 --- a/officecfg/registry/schema/org/openoffice/Office/Common.xcs +++ b/officecfg/registry/schema/org/openoffice/Office/Common.xcs @@ -2510,6 +2510,11 @@ Contains the path to the users NSS certificate directory. + + + Contains the URLs or Time Stamping Authority servers. + + Specifies whether to warn when printing documents with -- cgit