diff options
author | Katarina Behrens <Katarina.Behrens@cib.de> | 2017-08-23 00:06:21 +0200 |
---|---|---|
committer | Thorsten Behrens <Thorsten.Behrens@CIB.de> | 2017-09-03 01:10:11 +0200 |
commit | 9c165fe3084b7c054f9f04f3b065897abcbe2162 (patch) | |
tree | bf2a797ba716bd106fb724fd1526f0e5ec4eaf71 /xmlsecurity | |
parent | 4f6bf3d64cf3fcbe92be3ceb4b572ad038c131a8 (diff) |
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@libreoffice.org>
Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
Diffstat (limited to 'xmlsecurity')
5 files changed, 24 insertions, 3 deletions
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 ; |