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

Katarina Behrens Katarina.Behrens at cib.de
Sat Sep 2 23:10:48 UTC 2017


 offapi/com/sun/star/xml/crypto/XSecurityEnvironment.idl               |    7 +++++
 xmlsecurity/source/dialogs/certificatechooser.cxx                     |    5 ++-
 xmlsecurity/source/gpg/SecurityEnvironment.cxx                        |   14 ++++++++--
 xmlsecurity/source/gpg/SecurityEnvironment.hxx                        |    4 ++
 xmlsecurity/source/xmlsec/mscrypt/securityenvironment_mscryptimpl.hxx |    2 +
 xmlsecurity/source/xmlsec/nss/securityenvironment_nssimpl.hxx         |    2 +
 6 files changed, 31 insertions(+), 3 deletions(-)

New commits:
commit 9c165fe3084b7c054f9f04f3b065897abcbe2162
Author: Katarina Behrens <Katarina.Behrens at cib.de>
Date:   Wed Aug 23 00:06:21 2017 +0200

    gpg4libre: When encrypting, show all available GPG keys
    
    (not only private ones)
    
    Change-Id: I3fd248f4cace1ea248267d5696da9cb70940744e
    Reviewed-on: https://gerrit.libreoffice.org/41508
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>

diff --git a/offapi/com/sun/star/xml/crypto/XSecurityEnvironment.idl b/offapi/com/sun/star/xml/crypto/XSecurityEnvironment.idl
index 7227a4e9ad4d..f3d1ddbf6f3e 100644
--- a/offapi/com/sun/star/xml/crypto/XSecurityEnvironment.idl
+++ b/offapi/com/sun/star/xml/crypto/XSecurityEnvironment.idl
@@ -99,6 +99,13 @@ interface XSecurityEnvironment : com::sun::star::uno::XInterface
      */
     string getSecurityEnvironmentInformation ( );
 
+    /**
+     * List all certificates, private (as returned by getPersonalCertificates) as well as those of other people/orgas
+     *
+     * @since LibreOffice 6.0
+     */
+    sequence< com::sun::star::security::XCertificate > getAllCertificates() raises( com::sun::star::uno::SecurityException ) ;
+
 } ;
 
 } ; } ; } ; } ; } ;
diff --git a/xmlsecurity/source/dialogs/certificatechooser.cxx b/xmlsecurity/source/dialogs/certificatechooser.cxx
index 52aa7e976e75..bf74d1b04292 100644
--- a/xmlsecurity/source/dialogs/certificatechooser.cxx
+++ b/xmlsecurity/source/dialogs/certificatechooser.cxx
@@ -182,7 +182,10 @@ void CertificateChooser::ImplInitialize()
         uno::Sequence< uno::Reference< security::XCertificate > > xCerts;
         try
         {
-            xCerts = secEnvironment->getPersonalCertificates();
+            if ( meAction == UserAction::Sign )
+                xCerts = secEnvironment->getPersonalCertificates();
+            else
+                xCerts = secEnvironment->getAllCertificates();
         }
         catch (security::NoPasswordException&)
         {
diff --git a/xmlsecurity/source/gpg/SecurityEnvironment.cxx b/xmlsecurity/source/gpg/SecurityEnvironment.cxx
index 367fa35e76a3..c3cd90565fe2 100644
--- a/xmlsecurity/source/gpg/SecurityEnvironment.cxx
+++ b/xmlsecurity/source/gpg/SecurityEnvironment.cxx
@@ -64,14 +64,14 @@ OUString SecurityEnvironmentGpg::getSecurityEnvironmentInformation()
     return OUString();
 }
 
-Sequence< Reference < XCertificate > > SecurityEnvironmentGpg::getPersonalCertificates()
+Sequence< Reference < XCertificate > > SecurityEnvironmentGpg::getCertificatesImpl( bool bPrivateOnly )
 {
     CertificateImpl* xCert;
     std::list< GpgME::Key > keyList;
     std::list< CertificateImpl* > certsList;
 
     m_ctx->setKeyListMode(GPGME_KEYLIST_MODE_LOCAL);
-    GpgME::Error err = m_ctx->startKeyListing("", true);
+    GpgME::Error err = m_ctx->startKeyListing("", bPrivateOnly );
     while (!err) {
         GpgME::Key k = m_ctx->nextKey(err);
         if (err)
@@ -99,6 +99,16 @@ Sequence< Reference < XCertificate > > SecurityEnvironmentGpg::getPersonalCertif
     return xCertificateSequence;
 }
 
+Sequence< Reference < XCertificate > > SecurityEnvironmentGpg::getPersonalCertificates()
+{
+    return getCertificatesImpl( true );
+}
+
+Sequence< Reference < XCertificate > > SecurityEnvironmentGpg::getAllCertificates()
+{
+    return getCertificatesImpl( false );
+}
+
 Reference< XCertificate > SecurityEnvironmentGpg::getCertificate( const OUString& keyId, const Sequence< sal_Int8 >& /*serialNumber*/ )
 {
     CertificateImpl* xCert=nullptr;
diff --git a/xmlsecurity/source/gpg/SecurityEnvironment.hxx b/xmlsecurity/source/gpg/SecurityEnvironment.hxx
index 2af512bc746b..fda9d706c6a6 100644
--- a/xmlsecurity/source/gpg/SecurityEnvironment.hxx
+++ b/xmlsecurity/source/gpg/SecurityEnvironment.hxx
@@ -67,6 +67,10 @@ public:
         const OUString& asciiCertificate ) override;
 
     GpgME::Context& getGpgContext() { return *m_ctx.get(); }
+    virtual css::uno::Sequence< css::uno::Reference< css::security::XCertificate > > SAL_CALL getAllCertificates() override;
+
+private:
+    css::uno::Sequence< css::uno::Reference< css::security::XCertificate > > getCertificatesImpl( bool bPrivateOnly );
 } ;
 
 #endif // INCLUDED_XMLSECURITY_SOURCE_GPG_SECURITYENVIRONMENT_HXX
diff --git a/xmlsecurity/source/xmlsec/mscrypt/securityenvironment_mscryptimpl.hxx b/xmlsecurity/source/xmlsec/mscrypt/securityenvironment_mscryptimpl.hxx
index 932f69cd89c7..4bed0b9005c5 100644
--- a/xmlsecurity/source/xmlsec/mscrypt/securityenvironment_mscryptimpl.hxx
+++ b/xmlsecurity/source/xmlsec/mscrypt/securityenvironment_mscryptimpl.hxx
@@ -84,6 +84,8 @@ class SecurityEnvironment_MSCryptImpl : public ::cppu::WeakImplHelper<
 
         //Methods from XSecurityEnvironment
         virtual css::uno::Sequence< css::uno::Reference< css::security::XCertificate > > SAL_CALL getPersonalCertificates() override;
+        virtual css::uno::Sequence< css::uno::Reference< css::security::XCertificate > > SAL_CALL getAllCertificates() override
+        { return css::uno::Sequence< css::uno::Reference< css::security::XCertificate > >(); }
 
         virtual css::uno::Reference< css::security::XCertificate > SAL_CALL getCertificate(
             const OUString& issuerName,
diff --git a/xmlsecurity/source/xmlsec/nss/securityenvironment_nssimpl.hxx b/xmlsecurity/source/xmlsec/nss/securityenvironment_nssimpl.hxx
index 46aba7bc0990..fc83a3eb1286 100644
--- a/xmlsecurity/source/xmlsec/nss/securityenvironment_nssimpl.hxx
+++ b/xmlsecurity/source/xmlsec/nss/securityenvironment_nssimpl.hxx
@@ -127,6 +127,8 @@ private:
         SECKEYPrivateKey* getPriKey( unsigned int position ) ;
 
         virtual css::uno::Sequence< css::uno::Reference< css::security::XCertificate > > SAL_CALL getPersonalCertificates() override ;
+        virtual css::uno::Sequence< css::uno::Reference< css::security::XCertificate > > SAL_CALL getAllCertificates() override
+        { return css::uno::Sequence< css::uno::Reference< css::security::XCertificate > >(); }
 
         virtual css::uno::Reference< css::security::XCertificate > SAL_CALL getCertificate( const OUString& issuerName, const css::uno::Sequence< sal_Int8 >& serialNumber ) override ;
 


More information about the Libreoffice-commits mailing list