solenv/sanitizers/ui/uui.suppr     |    2 ++
 uui/source/secmacrowarnings.cxx    |   12 ++++++++++++
 uui/source/secmacrowarnings.hxx    |    2 ++
 uui/uiconfig/ui/macrowarnmedium.ui |   28 ++++++++++++++++++++++++++--
 4 files changed, 42 insertions(+), 2 deletions(-)

New commits:
commit 9b56334615d9cdb42542aba746caaa8985566001
Author:     Samuel Mehrbrodt <samuel.mehrbr...@allotropia.de>
AuthorDate: Mon Dec 11 11:00:44 2023 +0100
Commit:     Thorsten Behrens <thorsten.behr...@allotropia.de>
CommitDate: Thu Dec 14 16:10:38 2023 +0100

    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.mehrbr...@allotropia.de>
    (cherry picked from commit 69814fc26fe21a258cf32fca021945f5bc69f59c)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160751
    Reviewed-by: Thorsten Behrens <thorsten.behr...@allotropia.de>

diff --git a/solenv/sanitizers/ui/uui.suppr b/solenv/sanitizers/ui/uui.suppr
index 96d00fc94920..3c7ab206bbe2 100644
--- a/solenv/sanitizers/ui/uui.suppr
+++ b/solenv/sanitizers/ui/uui.suppr
@@ -12,6 +12,8 @@ uui/uiconfig/ui/logindialog.ui://GtkLabel[@id='requestinfo'] 
orphan-label
 uui/uiconfig/ui/logindialog.ui://GtkLabel[@id='errorinfo'] orphan-label
 uui/uiconfig/ui/macrowarnmedium.ui://GtkLabel[@id='descr1Label'] orphan-label
 uui/uiconfig/ui/macrowarnmedium.ui://GtkLabel[@id='signsLabel'] orphan-label
+uui/uiconfig/ui/macrowarnmedium.ui://GtkLabel[@id='certNotYetValidLabel'] 
orphan-label
+uui/uiconfig/ui/macrowarnmedium.ui://GtkLabel[@id='certNoLongerValidLabel'] 
orphan-label
 uui/uiconfig/ui/setmasterpassworddlg.ui://GtkLabel[@id='label1'] orphan-label
 uui/uiconfig/ui/setmasterpassworddlg.ui://GtkLabel[@id='label4'] orphan-label
 uui/uiconfig/ui/simplenameclash.ui://GtkLabel[@id='warning'] orphan-label
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>

Reply via email to