summaryrefslogtreecommitdiff
path: root/uui
diff options
context:
space:
mode:
authorSamuel Mehrbrodt <samuel.mehrbrodt@allotropia.de>2023-12-11 11:00:44 +0100
committerThorsten Behrens <thorsten.behrens@allotropia.de>2023-12-14 16:10:38 +0100
commit9b56334615d9cdb42542aba746caaa8985566001 (patch)
treead9cabb8ad8ca7dd17b5c65252be7d33bab36b3d /uui
parent83e4bc73e304d8e2eda06c768bf60ea7a3bcd963 (diff)
tdf#158576 Show warning when cert is not yet/no longer valid
Change-Id: I4f517a5e2b33d508d1a501323c4d97dc025edfbc Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160566 Tested-by: Jenkins Reviewed-by: Samuel Mehrbrodt <samuel.mehrbrodt@allotropia.de> (cherry picked from commit 69814fc26fe21a258cf32fca021945f5bc69f59c) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160751 Reviewed-by: Thorsten Behrens <thorsten.behrens@allotropia.de>
Diffstat (limited to 'uui')
-rw-r--r--uui/source/secmacrowarnings.cxx12
-rw-r--r--uui/source/secmacrowarnings.hxx2
-rw-r--r--uui/uiconfig/ui/macrowarnmedium.ui28
3 files changed, 40 insertions, 2 deletions
diff --git a/uui/source/secmacrowarnings.cxx b/uui/source/secmacrowarnings.cxx
index 6b4102632755..7e62c8556a66 100644
--- a/uui/source/secmacrowarnings.cxx
+++ b/uui/source/secmacrowarnings.cxx
@@ -23,7 +23,9 @@
#include <vcl/svapp.hxx>
#include <osl/file.hxx>
#include <rtl/ustrbuf.hxx>
+#include <tools/datetime.hxx>
#include <tools/debug.hxx>
+#include <unotools/datetime.hxx>
#include <unotools/securityoptions.hxx>
#include <tools/urlobj.hxx>
@@ -63,6 +65,8 @@ MacroWarning::MacroWarning(weld::Window* pParent, bool _bWithSignatures)
: MessageDialogController(pParent, "uui/ui/macrowarnmedium.ui", "MacroWarnMedium", "grid")
, mxGrid(m_xBuilder->weld_widget("grid"))
, mxSignsFI(m_xBuilder->weld_label("signsLabel"))
+ , mxNotYetValid(m_xBuilder->weld_label("certNotYetValidLabel"))
+ , mxNoLongerValid(m_xBuilder->weld_label("certNoLongerValidLabel"))
, mxViewSignsBtn(m_xBuilder->weld_button("viewSignsButton"))
, mxAlwaysTrustCB(m_xBuilder->weld_check_button("alwaysTrustCheckbutton"))
, mxEnableBtn(m_xBuilder->weld_button("ok"))
@@ -203,6 +207,14 @@ void MacroWarning::SetCertificate( const css::uno::Reference< css::security::XCe
{
OUString s( GetContentPart( mxCert->getSubjectName(), u"CN" ) );
mxSignsFI->set_label(s);
+
+ ::DateTime now( ::DateTime::SYSTEM );
+ DateTime aDateTimeStart( DateTime::EMPTY );
+ DateTime aDateTimeEnd( DateTime::EMPTY );
+ utl::typeConvert( mxCert->getNotValidBefore(), aDateTimeStart );
+ utl::typeConvert( mxCert->getNotValidAfter(), aDateTimeEnd );
+ mxNotYetValid->set_visible(now < aDateTimeStart);
+ mxNoLongerValid->set_visible(now > aDateTimeEnd);
mxViewSignsBtn->set_sensitive(true);
}
}
diff --git a/uui/source/secmacrowarnings.hxx b/uui/source/secmacrowarnings.hxx
index 300a5477bea5..1a6e7f0b7380 100644
--- a/uui/source/secmacrowarnings.hxx
+++ b/uui/source/secmacrowarnings.hxx
@@ -32,6 +32,8 @@ class MacroWarning : public weld::MessageDialogController
private:
std::unique_ptr<weld::Widget> mxGrid;
std::unique_ptr<weld::Label> mxSignsFI;
+ std::unique_ptr<weld::Label> mxNotYetValid;
+ std::unique_ptr<weld::Label> mxNoLongerValid;
std::unique_ptr<weld::Button> mxViewSignsBtn;
std::unique_ptr<weld::CheckButton> mxAlwaysTrustCB;
std::unique_ptr<weld::Button> mxEnableBtn;
diff --git a/uui/uiconfig/ui/macrowarnmedium.ui b/uui/uiconfig/ui/macrowarnmedium.ui
index d3a00f7a0d0a..810fbbb6d12b 100644
--- a/uui/uiconfig/ui/macrowarnmedium.ui
+++ b/uui/uiconfig/ui/macrowarnmedium.ui
@@ -75,7 +75,7 @@ Macros may contain viruses. Disabling macros for a document is always safe. If y
</packing>
</child>
<child>
- <!-- n-columns=1 n-rows=3 -->
+ <!-- n-columns=1 n-rows=5 -->
<object class="GtkGrid" id="grid">
<property name="visible">True</property>
<property name="can-focus">False</property>
@@ -104,7 +104,7 @@ Macros may contain viruses. Disabling macros for a document is always safe. If y
</object>
<packing>
<property name="left-attach">0</property>
- <property name="top-attach">2</property>
+ <property name="top-attach">4</property>
</packing>
</child>
<child>
@@ -146,6 +146,30 @@ Macros may contain viruses. Disabling macros for a document is always safe. If y
<property name="top-attach">1</property>
</packing>
</child>
+ <child>
+ <object class="GtkLabel" id="certNoLongerValidLabel">
+ <property name="can-focus">False</property>
+ <property name="halign">start</property>
+ <property name="hexpand">True</property>
+ <property name="label" translatable="yes" context="macrowarnmedium|certNoLongerValidLabel">Warning: The certificate is no longer valid.</property>
+ </object>
+ <packing>
+ <property name="left-attach">0</property>
+ <property name="top-attach">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="certNotYetValidLabel">
+ <property name="can-focus">False</property>
+ <property name="halign">start</property>
+ <property name="hexpand">True</property>
+ <property name="label" translatable="yes" context="macrowarnmedium|certNotYetValidLabel">Warning: The certificate is not yet valid.</property>
+ </object>
+ <packing>
+ <property name="left-attach">0</property>
+ <property name="top-attach">3</property>
+ </packing>
+ </child>
</object>
<packing>
<property name="expand">False</property>