[Libreoffice-commits] core.git: 5 commits - xmlsecurity/source
Samuel Mehrbrodt
Samuel.Mehrbrodt at cib.de
Fri Jun 23 10:37:35 UTC 2017
xmlsecurity/source/gpg/CertificateImpl.cxx | 5 +++-
xmlsecurity/source/gpg/SecurityEnvironment.cxx | 21 +++++++++++------
xmlsecurity/source/gpg/xmlsignature_gpgimpl.cxx | 29 ++++++------------------
3 files changed, 26 insertions(+), 29 deletions(-)
New commits:
commit 9073a347f10aae5e7afb92371a0593c80fa89f97
Author: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
Date: Fri Jun 23 10:40:01 2017 +0200
XMLSignature_GpgImpl: Use cppu::supportsService
Change-Id: Ic093462c957aa445aab43f95ac22af3a3df1d709
diff --git a/xmlsecurity/source/gpg/xmlsignature_gpgimpl.cxx b/xmlsecurity/source/gpg/xmlsignature_gpgimpl.cxx
index 9972482bdaf1..48d2097dad0f 100644
--- a/xmlsecurity/source/gpg/xmlsignature_gpgimpl.cxx
+++ b/xmlsecurity/source/gpg/xmlsignature_gpgimpl.cxx
@@ -19,6 +19,7 @@
#include <sal/config.h>
#include <rtl/uuid.h>
+#include <cppuhelper/supportsservice.hxx>
#include "gpg/xmlsignature_gpgimpl.hxx"
#include <gpgme.h>
@@ -405,13 +406,7 @@ OUString SAL_CALL XMLSignature_GpgImpl::getImplementationName() {
/* XServiceInfo */
sal_Bool SAL_CALL XMLSignature_GpgImpl::supportsService( const OUString& serviceName) {
- Sequence< OUString > seqServiceNames = getSupportedServiceNames() ;
- const OUString* pArray = seqServiceNames.getConstArray() ;
- for( sal_Int32 i = 0 ; i < seqServiceNames.getLength() ; i ++ ) {
- if( *( pArray + i ) == serviceName )
- return true ;
- }
- return false ;
+ return cppu::supportsService(this, serviceName);
}
/* XServiceInfo */
commit e2fc3f0fb591ba044ad8862c14afea5f0dc6a069
Author: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
Date: Fri Jun 23 10:37:47 2017 +0200
XMLSignature_GpgImpl: Clean up namespaces
Change-Id: I34aa59171b5d440bdd6bdec80badf7a3eb42bd3f
diff --git a/xmlsecurity/source/gpg/xmlsignature_gpgimpl.cxx b/xmlsecurity/source/gpg/xmlsignature_gpgimpl.cxx
index 40248ee3a9e8..9972482bdaf1 100644
--- a/xmlsecurity/source/gpg/xmlsignature_gpgimpl.cxx
+++ b/xmlsecurity/source/gpg/xmlsignature_gpgimpl.cxx
@@ -35,18 +35,10 @@
#include "SecurityEnvironment.hxx"
#include "xmlsec-wrapper.h"
-using namespace ::com::sun::star::uno ;
-using namespace ::com::sun::star::lang ;
-using ::com::sun::star::lang::XMultiServiceFactory ;
-using ::com::sun::star::lang::XSingleServiceFactory ;
-
-using ::com::sun::star::xml::wrapper::XXMLElementWrapper ;
-using ::com::sun::star::xml::wrapper::XXMLDocumentWrapper ;
-using ::com::sun::star::xml::crypto::XSecurityEnvironment ;
-using ::com::sun::star::xml::crypto::XXMLSignature ;
-using ::com::sun::star::xml::crypto::XXMLSignatureTemplate ;
-using ::com::sun::star::xml::crypto::XXMLSecurityContext ;
-using ::com::sun::star::xml::crypto::XUriBinding ;
+using namespace css::uno;
+using namespace css::lang;
+using namespace css::xml::wrapper;
+using namespace css::xml::crypto;
XMLSignature_GpgImpl::XMLSignature_GpgImpl() {
}
@@ -223,7 +215,7 @@ SAL_CALL XMLSignature_GpgImpl::generate(
// TODO some assert would be good...
xmlNodeSetContentLen(cur, &buf2[0], len);
- aTemplate->setStatus(css::xml::crypto::SecurityOperationStatus_OPERATION_SUCCEEDED);
+ aTemplate->setStatus(SecurityOperationStatus_OPERATION_SUCCEEDED);
// done
xmlSecDSigCtxDestroy( pDsigCtx ) ;
@@ -392,7 +384,7 @@ SAL_CALL XMLSignature_GpgImpl::validate(
}
// TODO - also verify manifest (only relevant for ooxml)?
- aTemplate->setStatus(css::xml::crypto::SecurityOperationStatus_OPERATION_SUCCEEDED);
+ aTemplate->setStatus(SecurityOperationStatus_OPERATION_SUCCEEDED);
// done
xmlSecDSigCtxDestroy( pDsigCtx ) ;
commit 80bb0a4fe8953ab90dfaf75ad19e46aa5aad00a8
Author: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
Date: Fri Jun 23 10:27:05 2017 +0200
Gpg key listing: Use range based for loop
Change-Id: Idc7b39f751b2572f5ddd077aaad86a1f7b4b9a5d
diff --git a/xmlsecurity/source/gpg/SecurityEnvironment.cxx b/xmlsecurity/source/gpg/SecurityEnvironment.cxx
index bc7611fa7968..37abf31111a1 100644
--- a/xmlsecurity/source/gpg/SecurityEnvironment.cxx
+++ b/xmlsecurity/source/gpg/SecurityEnvironment.cxx
@@ -89,10 +89,10 @@ Sequence< Reference < XCertificate > > SecurityEnvironmentGpg::getPersonalCertif
}
Sequence< Reference< XCertificate > > xCertificateSequence(certsList.size());
- std::list< CertificateImpl* >::iterator xcertIt;
- int i;
- for (i = 0, xcertIt = certsList.begin(); xcertIt != certsList.end(); ++xcertIt, ++i)
- xCertificateSequence[i] = *xcertIt ;
+ int i = 0;
+ for (auto const& cert : certsList) {
+ xCertificateSequence[i++] = cert;
+ }
return xCertificateSequence;
}
commit 91ffe409e35479d024f629fe1b5ce474993a0f54
Author: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
Date: Fri Jun 23 10:18:01 2017 +0200
tdf#108692 gpg4libre: List all gpg keys
Change-Id: I7300da36215233fa91b7a04a42b1c9bf907ad78b
diff --git a/xmlsecurity/source/gpg/SecurityEnvironment.cxx b/xmlsecurity/source/gpg/SecurityEnvironment.cxx
index 9892ec6ac5c8..bc7611fa7968 100644
--- a/xmlsecurity/source/gpg/SecurityEnvironment.cxx
+++ b/xmlsecurity/source/gpg/SecurityEnvironment.cxx
@@ -65,6 +65,7 @@ OUString SecurityEnvironmentGpg::getSecurityEnvironmentInformation()
Sequence< Reference < XCertificate > > SecurityEnvironmentGpg::getPersonalCertificates()
{
CertificateImpl* xCert;
+ std::list< GpgME::Key > keyList;
std::list< CertificateImpl* > certsList;
m_ctx->setKeyListMode(GPGME_KEYLIST_MODE_LOCAL);
@@ -74,13 +75,19 @@ Sequence< Reference < XCertificate > > SecurityEnvironmentGpg::getPersonalCertif
if (err)
break;
if (!k.isInvalid()) {
- xCert = new CertificateImpl();
- xCert->setCertificate(m_ctx.get(),k);
- certsList.push_back(xCert);
+ // We can't create CertificateImpl here as CertificateImpl::setCertificate uses GpgME API
+ // which interrupts our key listing here. So first get the keys from GpgME, then create the CertificateImpls
+ keyList.push_back(k);
}
}
m_ctx->endKeyListing();
+ for (auto const& key : keyList) {
+ xCert = new CertificateImpl();
+ xCert->setCertificate(m_ctx.get(),key);
+ certsList.push_back(xCert);
+ }
+
Sequence< Reference< XCertificate > > xCertificateSequence(certsList.size());
std::list< CertificateImpl* >::iterator xcertIt;
int i;
commit 7add9c24af8ea965f0411d4b852491af337822df
Author: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
Date: Fri Jun 23 09:52:23 2017 +0200
gpg4libre: Handle error when retrieving public key
Change-Id: I9543e47fb3302a5ca146a606305b24733f015a5d
diff --git a/xmlsecurity/source/gpg/CertificateImpl.cxx b/xmlsecurity/source/gpg/CertificateImpl.cxx
index e40f59323a04..e87316e15005 100644
--- a/xmlsecurity/source/gpg/CertificateImpl.cxx
+++ b/xmlsecurity/source/gpg/CertificateImpl.cxx
@@ -211,7 +211,10 @@ void CertificateImpl::setCertificate(GpgME::Context* ctx, const GpgME::Key& key)
// extract key data, store into m_aBits
GpgME::Data data_out;
- ctx->exportPublicKeys(key.keyID(), data_out);
+ GpgME::Error err = ctx->exportPublicKeys(key.keyID(), data_out);
+
+ if (err)
+ throw RuntimeException("The GpgME library failed to retrieve the public key");
assert(data_out.seek(0,SEEK_SET) == 0);
int len=0, curr=0; char buf;
More information about the Libreoffice-commits
mailing list