[Libreoffice-commits] core.git: cui/source offapi/com xmlsecurity/inc xmlsecurity/source xmlsecurity/uiconfig

Samuel Mehrbrodt Samuel.Mehrbrodt at cib.de
Tue May 22 08:27:58 UTC 2018


 cui/source/dialogs/SignSignatureLineDialog.cxx              |    2 +-
 offapi/com/sun/star/security/XDocumentDigitalSignatures.idl |    7 +++++++
 xmlsecurity/inc/certificatechooser.hxx                      |    1 +
 xmlsecurity/source/component/documentdigitalsignatures.cxx  |   10 ++++++++++
 xmlsecurity/source/dialogs/certificatechooser.cxx           |   10 ++++++++--
 xmlsecurity/uiconfig/ui/selectcertificatedialog.ui          |    5 +++++
 6 files changed, 32 insertions(+), 3 deletions(-)

New commits:
commit 203d967c045c4bf4e83d18bdcb96e11f899e1056
Author: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
Date:   Fri Apr 13 13:08:03 2018 +0200

    Related tdf#83877 Select certificate ok button label doesn't match
    
    Change the button to "Select" instead of sign when we only want to
    select a certificate.
    
    Change-Id: Ifa896e502c8680497d71912ddd1058ab0b71542b
    Reviewed-on: https://gerrit.libreoffice.org/52823
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>

diff --git a/cui/source/dialogs/SignSignatureLineDialog.cxx b/cui/source/dialogs/SignSignatureLineDialog.cxx
index 641a4fb10c68..0c6059e75649 100644
--- a/cui/source/dialogs/SignSignatureLineDialog.cxx
+++ b/cui/source/dialogs/SignSignatureLineDialog.cxx
@@ -119,7 +119,7 @@ IMPL_LINK_NOARG(SignSignatureLineDialog, chooseCertificate, weld::Button&, void)
     Reference<XDocumentDigitalSignatures> xSigner(DocumentDigitalSignatures::createWithVersion(
         comphelper::getProcessComponentContext(), "1.2"));
     OUString aDescription;
-    Reference<XCertificate> xSignCertificate = xSigner->chooseSigningCertificate(aDescription);
+    Reference<XCertificate> xSignCertificate = xSigner->selectSigningCertificate(aDescription);
 
     if (xSignCertificate.is())
     {
diff --git a/offapi/com/sun/star/security/XDocumentDigitalSignatures.idl b/offapi/com/sun/star/security/XDocumentDigitalSignatures.idl
index 3b2e543d2fab..0e4d6c82d553 100644
--- a/offapi/com/sun/star/security/XDocumentDigitalSignatures.idl
+++ b/offapi/com/sun/star/security/XDocumentDigitalSignatures.idl
@@ -161,6 +161,13 @@ interface XDocumentDigitalSignatures : com::sun::star::uno::XInterface
      */
     com::sun::star::security::XCertificate chooseSigningCertificate( [out] string Description );
 
+    /**  This shows the certificate selection dialog and allows to only select the certificate
+         without actually signing the document.
+
+         @since LibreOffice 6.1
+     */
+    com::sun::star::security::XCertificate selectSigningCertificate( [out] string Description );
+
     /**  This method shows the CertificateChooser dialog with all certificates, private and
          other people's. Useful when choosing certificate/key for encryption
 
diff --git a/xmlsecurity/inc/certificatechooser.hxx b/xmlsecurity/inc/certificatechooser.hxx
index 6049eb4a3869..9e2406c4fd63 100644
--- a/xmlsecurity/inc/certificatechooser.hxx
+++ b/xmlsecurity/inc/certificatechooser.hxx
@@ -52,6 +52,7 @@ struct UserData
 enum class UserAction
 {
     Sign,
+    SelectSign, // Select signing certificate
     Encrypt
 };
 
diff --git a/xmlsecurity/source/component/documentdigitalsignatures.cxx b/xmlsecurity/source/component/documentdigitalsignatures.cxx
index 7b708b0c99aa..e814d681dd91 100644
--- a/xmlsecurity/source/component/documentdigitalsignatures.cxx
+++ b/xmlsecurity/source/component/documentdigitalsignatures.cxx
@@ -155,6 +155,8 @@ public:
         SAL_CALL chooseCertificate(OUString& rDescription) override;
     css::uno::Reference<css::security::XCertificate>
         SAL_CALL chooseSigningCertificate(OUString& rDescription) override;
+    css::uno::Reference<css::security::XCertificate>
+        SAL_CALL selectSigningCertificate(OUString& rDescription) override;
     css::uno::Sequence<css::uno::Reference<css::security::XCertificate>>
         SAL_CALL chooseEncryptionCertificate() override;
     css::uno::Reference<css::security::XCertificate> SAL_CALL chooseCertificateWithProps(
@@ -651,6 +653,14 @@ Reference< css::security::XCertificate > DocumentDigitalSignatures::chooseSignin
     return xCert;
 }
 
+Reference< css::security::XCertificate > DocumentDigitalSignatures::selectSigningCertificate(OUString& rDescription)
+{
+    std::map<OUString, OUString> aProperties;
+    Reference< css::security::XCertificate > xCert = chooseCertificatesImpl( aProperties, UserAction::SelectSign )[0];
+    rDescription = aProperties["Description"];
+    return xCert;
+}
+
 css::uno::Sequence< Reference< css::security::XCertificate > > DocumentDigitalSignatures::chooseEncryptionCertificate()
 {
     std::map<OUString, OUString> aProperties;
diff --git a/xmlsecurity/source/dialogs/certificatechooser.cxx b/xmlsecurity/source/dialogs/certificatechooser.cxx
index 2defc8e6a406..4900a8710d1f 100644
--- a/xmlsecurity/source/dialogs/certificatechooser.cxx
+++ b/xmlsecurity/source/dialogs/certificatechooser.cxx
@@ -168,6 +168,12 @@ void CertificateChooser::ImplInitialize()
             msPreferredKey = aUserOpts.GetSigningKey();
             break;
 
+        case UserAction::SelectSign:
+            m_pFTSign->Show();
+            m_pOKBtn->SetText( get<FixedText>("str_selectsign")->GetText() );
+            msPreferredKey = aUserOpts.GetSigningKey();
+            break;
+
         case UserAction::Encrypt:
             m_pFTEncrypt->Show();
             m_pFTDescription->Hide();
@@ -190,7 +196,7 @@ void CertificateChooser::ImplInitialize()
         uno::Sequence< uno::Reference< security::XCertificate > > xCerts;
         try
         {
-            if ( meAction == UserAction::Sign )
+            if ( meAction == UserAction::Sign || meAction == UserAction::SelectSign)
                 xCerts = secEnvironment->getPersonalCertificates();
             else
                 xCerts = secEnvironment->getAllCertificates();
@@ -235,7 +241,7 @@ void CertificateChooser::ImplInitialize()
             // only GPG has preferred keys
             if ( sIssuer == msPreferredKey )
             {
-                if ( meAction == UserAction::Sign )
+                if ( meAction == UserAction::Sign || meAction == UserAction::SelectSign )
                     m_pCertLB->Select( pEntry );
                 else if ( meAction == UserAction::Encrypt &&
                           aUserOpts.GetEncryptToSelf() )
diff --git a/xmlsecurity/uiconfig/ui/selectcertificatedialog.ui b/xmlsecurity/uiconfig/ui/selectcertificatedialog.ui
index cb2079263315..6bbc37546af4 100644
--- a/xmlsecurity/uiconfig/ui/selectcertificatedialog.ui
+++ b/xmlsecurity/uiconfig/ui/selectcertificatedialog.ui
@@ -188,6 +188,11 @@
                     <property name="hexpand">True</property>
                     <property name="label" translatable="yes" context="selectcertificatedialog|str_sign">Sign</property>
                   </object>
+                  <object class="GtkLabel" id="str_selectsign">
+                    <property name="can_focus">False</property>
+                    <property name="hexpand">True</property>
+                    <property name="label" translatable="yes" context="selectcertificatedialog|str_selectsign">Select</property>
+                  </object>
                   <object class="GtkLabel" id="str_encrypt">
                     <property name="can_focus">False</property>
                     <property name="hexpand">True</property>


More information about the Libreoffice-commits mailing list