summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Repository.mk1
-rwxr-xr-xbin/update_pch1
-rw-r--r--compilerplugins/clang/plugin.cxx3
-rw-r--r--offapi/UnoApi_offapi.mk7
-rw-r--r--offapi/com/sun/star/xml/crypto/gpg/GpgSEInitializer.idl28
-rw-r--r--offapi/com/sun/star/xml/crypto/gpg/GpgSecurityEnvironment.idl28
-rw-r--r--offapi/com/sun/star/xml/crypto/gpg/GpgXMLEncryption.idl34
-rw-r--r--offapi/com/sun/star/xml/crypto/gpg/GpgXMLSecurityContext.idl28
-rw-r--r--offapi/com/sun/star/xml/crypto/gpg/GpgXMLSignature.idl34
-rw-r--r--postprocess/Rdb_services.mk1
-rw-r--r--xmlsecurity/Library_xmlsecurity.mk8
-rw-r--r--xmlsecurity/Library_xsec_gpg.mk58
-rw-r--r--xmlsecurity/Module_xmlsecurity.mk6
-rw-r--r--xmlsecurity/README2
-rw-r--r--xmlsecurity/inc/certificatechooser.hxx15
-rw-r--r--xmlsecurity/inc/documentsignaturemanager.hxx3
-rw-r--r--xmlsecurity/inc/pch/precompiled_xsec_gpg.cxx13
-rw-r--r--xmlsecurity/inc/pch/precompiled_xsec_gpg.hxx35
-rw-r--r--xmlsecurity/source/component/documentdigitalsignatures.cxx10
-rw-r--r--xmlsecurity/source/dialogs/certificatechooser.cxx110
-rw-r--r--xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx6
-rw-r--r--xmlsecurity/source/dialogs/resourcemanager.cxx16
-rw-r--r--xmlsecurity/source/gpg/CertificateImpl.cxx191
-rw-r--r--xmlsecurity/source/gpg/CertificateImpl.hxx107
-rw-r--r--xmlsecurity/source/gpg/CipherContext.cxx30
-rw-r--r--xmlsecurity/source/gpg/CipherContext.hxx33
-rw-r--r--xmlsecurity/source/gpg/DigestContext.cxx30
-rw-r--r--xmlsecurity/source/gpg/DigestContext.hxx31
-rw-r--r--xmlsecurity/source/gpg/GpgComponentFactory.cxx70
-rw-r--r--xmlsecurity/source/gpg/SEInitializer.cxx99
-rw-r--r--xmlsecurity/source/gpg/SEInitializer.hxx68
-rw-r--r--xmlsecurity/source/gpg/SecurityEnvironment.cxx198
-rw-r--r--xmlsecurity/source/gpg/SecurityEnvironment.hxx108
-rw-r--r--xmlsecurity/source/gpg/XMLEncryption.cxx86
-rw-r--r--xmlsecurity/source/gpg/XMLEncryption.hxx77
-rw-r--r--xmlsecurity/source/gpg/XMLSecurityContext.cxx122
-rw-r--r--xmlsecurity/source/gpg/XMLSecurityContext.hxx88
-rw-r--r--xmlsecurity/source/gpg/XMLSignature.cxx89
-rw-r--r--xmlsecurity/source/gpg/XMLSignature.hxx77
-rw-r--r--xmlsecurity/source/helper/documentsignaturemanager.cxx21
-rw-r--r--xmlsecurity/util/xsec_gpg.component36
41 files changed, 1940 insertions, 68 deletions
diff --git a/Repository.mk b/Repository.mk
index bf5f9a8698a4..6b169bfac328 100644
--- a/Repository.mk
+++ b/Repository.mk
@@ -624,6 +624,7 @@ $(eval $(call gb_Helper_register_libraries_for_install,PLAINLIBS_OOO,ooo, \
xmlsecurity \
xsec_fw \
xsec_xmlsec \
+ $(if $(filter-out MACOSX WNT,$(OS)),xsec_gpg) \
xstor \
$(if $(filter $(OS),MACOSX), \
macab1 \
diff --git a/bin/update_pch b/bin/update_pch
index aba7b2421ba1..7e789c1a1dda 100755
--- a/bin/update_pch
+++ b/bin/update_pch
@@ -124,6 +124,7 @@ DEFAULTS = \
'xmlsecurity.xmlsecurity' : ( 6, EXCLUDE, INCLUDE, INCLUDE), # 5.1
'xmlsecurity.xsec_fw' : ( 2, EXCLUDE, INCLUDE, EXCLUDE), # 2.7
'xmlsecurity.xsec_xmlsec' : ( 2, EXCLUDE, INCLUDE, INCLUDE), # 4.4
+ 'xmlsecurity.xsec_gpg' : ( 2, EXCLUDE, INCLUDE, INCLUDE), # ?
}
def remove_rare(raw, min_use=-1):
diff --git a/compilerplugins/clang/plugin.cxx b/compilerplugins/clang/plugin.cxx
index d5b2401c8bf9..85d76ccc9bcc 100644
--- a/compilerplugins/clang/plugin.cxx
+++ b/compilerplugins/clang/plugin.cxx
@@ -43,7 +43,8 @@ bool Plugin::ignoreLocation( SourceLocation loc )
const char* bufferName = compiler.getSourceManager().getPresumedLoc( expansionLoc ).getFilename();
if (bufferName == NULL
|| strncmp( bufferName, SRCDIR "/external/", strlen( SRCDIR "/external/" )) == 0
- || strcmp( bufferName, SRCDIR "/sdext/source/pdfimport/wrapper/keyword_list" ) == 0 )
+ || strcmp( bufferName, SRCDIR "/sdext/source/pdfimport/wrapper/keyword_list" ) == 0
+ || strncmp( bufferName, SRCDIR "/xmlsecurity/source/gpg", strlen( SRCDIR "/xmlsecurity/source/gpg" )) == 0 )
// workdir/CustomTarget/sdext/pdfimport/hash.cxx is generated from
// sdext/source/pdfimport/wrapper/keyword_list by gperf, which
// inserts various #line directives denoting the latter into the
diff --git a/offapi/UnoApi_offapi.mk b/offapi/UnoApi_offapi.mk
index 49602b9555e7..7ae02d6ba560 100644
--- a/offapi/UnoApi_offapi.mk
+++ b/offapi/UnoApi_offapi.mk
@@ -463,6 +463,13 @@ $(eval $(call gb_UnoApi_add_idlfiles_nohdl,offapi,com/sun/star/xml/crypto,\
SEInitializer \
XMLSecurityContext \
))
+$(eval $(call gb_UnoApi_add_idlfiles_nohdl,offapi,com/sun/star/xml/crypto/gpg,\
+ GpgSecurityEnvironment \
+ GpgSEInitializer \
+ GpgXMLEncryption \
+ GpgXMLSecurityContext \
+ GpgXMLSignature \
+))
$(eval $(call gb_UnoApi_add_idlfiles_nohdl,offapi,com/sun/star/xml/dom,\
DocumentBuilder \
SAXDocumentBuilder \
diff --git a/offapi/com/sun/star/xml/crypto/gpg/GpgSEInitializer.idl b/offapi/com/sun/star/xml/crypto/gpg/GpgSEInitializer.idl
new file mode 100644
index 000000000000..ac8fc58df9ad
--- /dev/null
+++ b/offapi/com/sun/star/xml/crypto/gpg/GpgSEInitializer.idl
@@ -0,0 +1,28 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef __com_sun_star_xml_crypto_gpg_GpgSEInitializer_idl_
+#define __com_sun_star_xml_crypto_gpg_GpgSEInitializer_idl_
+
+#include <com/sun/star/xml/crypto/XSEInitializer.idl>
+
+module com { module sun { module star { module xml { module crypto { module gpg {
+
+/**
+ * Service implementing XSEInitializer
+ *
+ * @since LibreOffice 5.4
+ */
+service GpgSEInitializer : XSEInitializer;
+
+} ; } ; } ; } ; } ; } ;
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/offapi/com/sun/star/xml/crypto/gpg/GpgSecurityEnvironment.idl b/offapi/com/sun/star/xml/crypto/gpg/GpgSecurityEnvironment.idl
new file mode 100644
index 000000000000..ef82d8dba10a
--- /dev/null
+++ b/offapi/com/sun/star/xml/crypto/gpg/GpgSecurityEnvironment.idl
@@ -0,0 +1,28 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef __com_sun_star_xml_crypto_gpg_GpgSecurityEnvironment_idl_
+#define __com_sun_star_xml_crypto_gpg_GpgSecurityEnvironment_idl_
+
+#include <com/sun/star/xml/crypto/XSecurityEnvironment.idl>
+
+module com { module sun { module star { module xml { module crypto { module gpg {
+
+/**
+ * Service implementing XSecurityEnvironment
+ *
+ * @since LibreOffice 5.4
+ */
+service GpgSecurityEnvironment : XSecurityEnvironment;
+
+} ; } ; } ; } ; } ; } ;
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/offapi/com/sun/star/xml/crypto/gpg/GpgXMLEncryption.idl b/offapi/com/sun/star/xml/crypto/gpg/GpgXMLEncryption.idl
new file mode 100644
index 000000000000..e9d00b253b7b
--- /dev/null
+++ b/offapi/com/sun/star/xml/crypto/gpg/GpgXMLEncryption.idl
@@ -0,0 +1,34 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef __com_sun_star_xml_crypto_gpg_GpgXMLEncryption_idl_
+#define __com_sun_star_xml_crypto_gpg_GpgXMLEncryption_idl_
+
+#include <com/sun/star/uno/XInterface.idl>
+#include <com/sun/star/uno/Exception.idl>
+#include <com/sun/star/xml/crypto/XXMLEncryption.idl>
+#include <com/sun/star/lang/XInitialization.idl>
+
+module com { module sun { module star { module xml { module crypto { module gpg {
+
+/**
+ * Service implementing XXMLEncryption
+ *
+ * @since LibreOffice 5.4
+ */
+service GpgXMLEncryption {
+ interface com::sun::star::xml::crypto::XXMLEncryption ;
+ interface com::sun::star::lang::XInitialization ;
+} ;
+
+} ; } ; } ; } ; } ; } ;
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/offapi/com/sun/star/xml/crypto/gpg/GpgXMLSecurityContext.idl b/offapi/com/sun/star/xml/crypto/gpg/GpgXMLSecurityContext.idl
new file mode 100644
index 000000000000..2ada16f9d1ef
--- /dev/null
+++ b/offapi/com/sun/star/xml/crypto/gpg/GpgXMLSecurityContext.idl
@@ -0,0 +1,28 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef __com_sun_star_xml_crypto_gpg_GpgXMLSecurityContext_idl_
+#define __com_sun_star_xml_crypto_gpg_GpgXMLSecurityContext_idl_
+
+#include <com/sun/star/xml/crypto/XXMLSecurityContext.idl>
+
+module com { module sun { module star { module xml { module crypto { module gpg {
+
+/**
+ * Service implementing XXMLSecurityContext
+ *
+ * @since LibreOffice 5.4
+ */
+service GpgXMLSecurityContext : XXMLSecurityContext;
+
+} ; } ; } ; } ; } ; } ;
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/offapi/com/sun/star/xml/crypto/gpg/GpgXMLSignature.idl b/offapi/com/sun/star/xml/crypto/gpg/GpgXMLSignature.idl
new file mode 100644
index 000000000000..eda73187126a
--- /dev/null
+++ b/offapi/com/sun/star/xml/crypto/gpg/GpgXMLSignature.idl
@@ -0,0 +1,34 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef __com_sun_star_xml_crypto_gpg_GpgXmlSignature_idl_
+#define __com_sun_star_xml_crypto_gpg_GpgXmlSignature_idl_
+
+#include <com/sun/star/uno/XInterface.idl>
+#include <com/sun/star/uno/Exception.idl>
+#include <com/sun/star/xml/crypto/XXMLSignature.idl>
+#include <com/sun/star/lang/XInitialization.idl>
+
+module com { module sun { module star { module xml { module crypto { module gpg {
+
+/**
+ * Service implementing XXMLSignature
+ *
+ * @since LibreOffice 5.4
+ */
+service GpgXMLSignature {
+ interface com::sun::star::xml::crypto::XXMLSignature ;
+ interface com::sun::star::lang::XInitialization ;
+} ;
+
+} ; } ; } ; } ; } ; } ;
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/postprocess/Rdb_services.mk b/postprocess/Rdb_services.mk
index a75315a85fac..4e67e89e2ee2 100644
--- a/postprocess/Rdb_services.mk
+++ b/postprocess/Rdb_services.mk
@@ -109,6 +109,7 @@ $(eval $(call gb_Rdb_add_components,services,\
xmloff/source/transform/xof \
xmloff/util/xo \
xmlscript/util/xmlscript \
+ $(if $(filter-out MACOSX WNT,$(OS)),xmlsecurity/util/xsec_gpg) \
$(if $(ENABLE_NSS), \
xmlsecurity/util/xmlsecurity \
xmlsecurity/util/xsec_xmlsec$(if $(filter WNT,$(OS)),.windows)) \
diff --git a/xmlsecurity/Library_xmlsecurity.mk b/xmlsecurity/Library_xmlsecurity.mk
index b814435327e3..3add46fa534b 100644
--- a/xmlsecurity/Library_xmlsecurity.mk
+++ b/xmlsecurity/Library_xmlsecurity.mk
@@ -20,7 +20,7 @@ $(eval $(call gb_Library_add_defs,xmlsecurity,\
-DXMLSECURITY_DLLIMPLEMENTATION \
))
-$(eval $(call gb_Library_use_external,xmlsecurity,boost_headers))
+$(eval $(call gb_Library_use_externals,xmlsecurity,boost_headers))
$(eval $(call gb_Library_set_precompiled_header,xmlsecurity,$(SRCDIR)/xmlsecurity/inc/pch/precompiled_xmlsecurity))
@@ -46,6 +46,12 @@ $(eval $(call gb_Library_use_libraries,xmlsecurity,\
$(gb_UWINAPI) \
))
+ifneq ($(filter-out WNT MACOSX,$(OS)),)
+$(eval $(call gb_Library_use_libraries,xmlsecurity,\
+ xsec_gpg \
+))
+endif
+
$(eval $(call gb_Library_add_exception_objects,xmlsecurity,\
xmlsecurity/source/component/certificatecontainer \
xmlsecurity/source/component/documentdigitalsignatures \
diff --git a/xmlsecurity/Library_xsec_gpg.mk b/xmlsecurity/Library_xsec_gpg.mk
new file mode 100644
index 000000000000..7f6e814e651a
--- /dev/null
+++ b/xmlsecurity/Library_xsec_gpg.mk
@@ -0,0 +1,58 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+
+$(eval $(call gb_Library_Library,xsec_gpg))
+
+$(eval $(call gb_Library_set_componentfile,xsec_gpg,xmlsecurity/util/xsec_gpg))
+
+$(eval $(call gb_Library_set_include,xsec_gpg,\
+ $$(INCLUDE) \
+ -I$(SRCDIR)/xmlsecurity/inc \
+ -I$(SRCDIR)/xmlsecurity/source/gpg \
+))
+
+$(eval $(call gb_Library_add_defs,xsec_gpg,\
+ -DXSECFW_DLLIMPLEMENTATION \
+ -DXMLSEC_CRYPTO_GPG \
+))
+
+$(eval $(call gb_Library_use_custom_headers,xsec_gpg,\
+ officecfg/registry \
+))
+
+$(eval $(call gb_Library_use_sdk_api,xsec_gpg))
+
+$(eval $(call gb_Library_set_precompiled_header,xsec_gpg,$(SRCDIR)/xmlsecurity/inc/pch/precompiled_xsec_gpg))
+
+$(eval $(call gb_Library_use_externals,xsec_gpg,gpgmepp))
+
+$(eval $(call gb_Library_use_libraries,xsec_gpg,\
+ comphelper \
+ cppu \
+ cppuhelper \
+ sal \
+ svl \
+ tl \
+ xo \
+ $(gb_UWINAPI) \
+))
+
+$(eval $(call gb_Library_add_exception_objects,xsec_gpg,\
+ xmlsecurity/source/gpg/CertificateImpl \
+ xmlsecurity/source/gpg/CipherContext \
+ xmlsecurity/source/gpg/DigestContext \
+ xmlsecurity/source/gpg/GpgComponentFactory \
+ xmlsecurity/source/gpg/SecurityEnvironment \
+ xmlsecurity/source/gpg/SEInitializer \
+ xmlsecurity/source/gpg/XMLEncryption \
+ xmlsecurity/source/gpg/XMLSecurityContext \
+ xmlsecurity/source/gpg/XMLSignature \
+))
+
+# vim: set noet sw=4 ts=4:
diff --git a/xmlsecurity/Module_xmlsecurity.mk b/xmlsecurity/Module_xmlsecurity.mk
index 4fca006effeb..d1642b959dae 100644
--- a/xmlsecurity/Module_xmlsecurity.mk
+++ b/xmlsecurity/Module_xmlsecurity.mk
@@ -19,6 +19,12 @@ $(eval $(call gb_Module_add_targets,xmlsecurity,\
Library_xsec_xmlsec \
))
+ifneq ($(filter-out WNT MACOSX,$(OS)),)
+$(eval $(call gb_Module_add_targets,xmlsecurity,\
+ Library_xsec_gpg \
+))
+endif
+
$(eval $(call gb_Module_add_slowcheck_targets,xmlsecurity,\
CppunitTest_xmlsecurity_signing \
CppunitTest_xmlsecurity_pdfsigning \
diff --git a/xmlsecurity/README b/xmlsecurity/README
index 5eec54acc765..52a479009403 100644
--- a/xmlsecurity/README
+++ b/xmlsecurity/README
@@ -1,4 +1,4 @@
Stuff for document signing.
-This code provides dialogs, and infrastructure wrapping libxmlsec that
+This code provides dialogs, and infrastructure wrapping libxmlsec and gpgme that
implements document signing.
diff --git a/xmlsecurity/inc/certificatechooser.hxx b/xmlsecurity/inc/certificatechooser.hxx
index 45453b23b3ec..efe1f40976f6 100644
--- a/xmlsecurity/inc/certificatechooser.hxx
+++ b/xmlsecurity/inc/certificatechooser.hxx
@@ -40,12 +40,19 @@ namespace xml { namespace crypto {
class HeaderBar;
+struct UserData
+{
+ css::uno::Reference<css::security::XCertificate> xCertificate;
+ css::uno::Reference<css::xml::crypto::XSecurityEnvironment> xSecurityEnvironment;
+};
+
class CertificateChooser : public ModalDialog
{
private:
css::uno::Reference< css::uno::XComponentContext > mxCtx;
- css::uno::Reference< css::xml::crypto::XSecurityEnvironment > mxSecurityEnvironment;
+ std::vector< css::uno::Reference< css::xml::crypto::XSecurityEnvironment > > mxSecurityEnvironments;
css::uno::Sequence< css::uno::Reference< css::security::XCertificate > > maCerts;
+ std::vector<std::shared_ptr<UserData>> mvUserData;
VclPtr<SvSimpleTable> m_pCertLB;
VclPtr<PushButton> m_pViewBtn;
@@ -54,8 +61,6 @@ private:
bool mbInitialized;
- sal_uInt16 GetSelectedEntryPos() const;
-
DECL_LINK(ViewButtonHdl, Button*, void);
DECL_LINK(CertificateHighlightHdl, SvTreeListBox*, void );
DECL_LINK(CertificateSelectHdl, SvTreeListBox*, bool );
@@ -66,7 +71,9 @@ private:
void HandleOneUsageBit(OUString& string, int& bits, int bit, const char *name);
public:
- CertificateChooser(vcl::Window* pParent, css::uno::Reference< css::uno::XComponentContext>& rxCtx, css::uno::Reference< css::xml::crypto::XSecurityEnvironment >& rxSecurityEnvironment);
+ CertificateChooser(vcl::Window* pParent,
+ css::uno::Reference< css::uno::XComponentContext>& rxCtx,
+ std::vector< css::uno::Reference< css::xml::crypto::XSecurityEnvironment > >& rxSecurityEnvironments);
virtual ~CertificateChooser() override;
virtual void dispose() override;
diff --git a/xmlsecurity/inc/documentsignaturemanager.hxx b/xmlsecurity/inc/documentsignaturemanager.hxx
index af3465462a5a..2039b7fe778f 100644
--- a/xmlsecurity/inc/documentsignaturemanager.hxx
+++ b/xmlsecurity/inc/documentsignaturemanager.hxx
@@ -49,6 +49,8 @@ public:
css::uno::Reference<css::embed::XStorage> mxTempSignatureStorage;
css::uno::Reference<css::xml::crypto::XSEInitializer> mxSEInitializer;
css::uno::Reference<css::xml::crypto::XXMLSecurityContext> mxSecurityContext;
+ css::uno::Reference<css::xml::crypto::XSEInitializer> mxGpgSEInitializer;
+ css::uno::Reference<css::xml::crypto::XXMLSecurityContext> mxGpgSecurityContext;
DocumentSignatureManager(const css::uno::Reference<css::uno::XComponentContext>& xContext, DocumentSignatureMode eMode);
~DocumentSignatureManager();
@@ -76,6 +78,7 @@ public:
bool init();
/// Get the security environment.
css::uno::Reference<css::xml::crypto::XSecurityEnvironment> getSecurityEnvironment();
+ css::uno::Reference<css::xml::crypto::XSecurityEnvironment> getGpgSecurityEnvironment();
};
#endif // INCLUDED_XMLSECURITY_INC_DOCUMENTSIGNATUREMANAGER_HXX
diff --git a/xmlsecurity/inc/pch/precompiled_xsec_gpg.cxx b/xmlsecurity/inc/pch/precompiled_xsec_gpg.cxx
new file mode 100644
index 000000000000..5093ea57fdae
--- /dev/null
+++ b/xmlsecurity/inc/pch/precompiled_xsec_gpg.cxx
@@ -0,0 +1,13 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include "precompiled_xsec_gpg.hxx"
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
+
diff --git a/xmlsecurity/inc/pch/precompiled_xsec_gpg.hxx b/xmlsecurity/inc/pch/precompiled_xsec_gpg.hxx
new file mode 100644
index 000000000000..1c6a9bf0cdb4
--- /dev/null
+++ b/xmlsecurity/inc/pch/precompiled_xsec_gpg.hxx
@@ -0,0 +1,35 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+/*
+ This file has been autogenerated by update_pch.sh. It is possible to edit it
+ manually (such as when an include file has been moved/renamed/removed). All such
+ manual changes will be rewritten by the next run of update_pch.sh (which presumably
+ also fixes all possible problems, so it's usually better to use it).
+
+ Generated on 2017-03-03 09:38:52 using:
+ ./bin/update_pch xmlsecurity/ xsec_gpg --cutoff=1 --exclude:system --include:module --include:local
+
+ If after updating build fails, use the following command to locate conflicting headers:
+ ./bin/update_pch_bisect ./xmlsecurity/inc/pch/precompiled_xsec_gpg.hxx "make xmlsecurity/.build" --find-conflicts
+*/
+
+#include <context.h>
+#include <gpgme.h>
+#include <key.h>
+#include <keylistresult.h>
+#include <list>
+#include <com/sun/star/xml/crypto/gpg/GpgSecurityEnvironment.hpp>
+#include <com/sun/star/xml/crypto/gpg/GpgXMLSecurityContext.hpp>
+#include <comphelper/processfactory.hxx>
+#include <comphelper/servicehelper.hxx>
+#include <cppuhelper/factory.hxx>
+#include <cppuhelper/supportsservice.hxx>
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmlsecurity/source/component/documentdigitalsignatures.cxx b/xmlsecurity/source/component/documentdigitalsignatures.cxx
index 54b084075fbc..34bce199d2fb 100644
--- a/xmlsecurity/source/component/documentdigitalsignatures.cxx
+++ b/xmlsecurity/source/component/documentdigitalsignatures.cxx
@@ -447,14 +447,16 @@ sal_Bool DocumentDigitalSignatures::isAuthorTrusted(
Reference< css::security::XCertificate > DocumentDigitalSignatures::chooseCertificate(OUString& rDescription)
{
- Reference< css::xml::crypto::XSecurityEnvironment > xSecEnv;
+ std::vector< Reference< css::xml::crypto::XSecurityEnvironment > > xSecEnvs;
DocumentSignatureMode eMode{};
DocumentSignatureManager aSignatureManager(mxCtx, eMode);
- if (aSignatureManager.init())
- xSecEnv = aSignatureManager.getSecurityEnvironment();
+ if (aSignatureManager.init()) {
+ xSecEnvs.push_back(aSignatureManager.getSecurityEnvironment());
+ xSecEnvs.push_back(aSignatureManager.getGpgSecurityEnvironment());
+ }
- ScopedVclPtrInstance< CertificateChooser > aChooser(nullptr, mxCtx, xSecEnv);
+ ScopedVclPtrInstance< CertificateChooser > aChooser(nullptr, mxCtx, xSecEnvs);
if (aChooser->Execute() != RET_OK)
return Reference< css::security::XCertificate >(nullptr);
diff --git a/xmlsecurity/source/dialogs/certificatechooser.cxx b/xmlsecurity/source/dialogs/certificatechooser.cxx
index 292f41e8d9ae..551c863f62d9 100644
--- a/xmlsecurity/source/dialogs/certificatechooser.cxx
+++ b/xmlsecurity/source/dialogs/certificatechooser.cxx
@@ -32,23 +32,13 @@
#include <vcl/msgbox.hxx>
#include <svtools/treelistentry.hxx>
-using namespace ::com::sun::star;
+using namespace css;
-#define INVAL_SEL 0xFFFF
-
-sal_uInt16 CertificateChooser::GetSelectedEntryPos() const
-{
- sal_uInt16 nSel = INVAL_SEL;
-
- SvTreeListEntry* pSel = m_pCertLB->FirstSelected();
- if( pSel )
- nSel = (sal_uInt16) reinterpret_cast<sal_uIntPtr>( pSel->GetUserData() );
-
- return (sal_uInt16) nSel;
-}
-
-CertificateChooser::CertificateChooser(vcl::Window* _pParent, uno::Reference<uno::XComponentContext>& _rxCtx, uno::Reference<xml::crypto::XSecurityEnvironment>& _rxSecurityEnvironment)
- : ModalDialog(_pParent, "SelectCertificateDialog", "xmlsec/ui/selectcertificatedialog.ui")
+CertificateChooser::CertificateChooser(vcl::Window* _pParent,
+ uno::Reference<uno::XComponentContext>& _rxCtx,
+ std::vector< css::uno::Reference< css::xml::crypto::XSecurityEnvironment > >& rxSecurityEnvironments)
+ : ModalDialog(_pParent, "SelectCertificateDialog", "xmlsec/ui/selectcertificatedialog.ui"),
+ mvUserData()
{
get(m_pOKBtn, "ok");
get(m_pViewBtn, "viewcert");
@@ -71,7 +61,7 @@ CertificateChooser::CertificateChooser(vcl::Window* _pParent, uno::Reference<uno
m_pViewBtn->SetClickHdl( LINK( this, CertificateChooser, ViewButtonHdl ) );
mxCtx = _rxCtx;
- mxSecurityEnvironment = _rxSecurityEnvironment;
+ mxSecurityEnvironments = rxSecurityEnvironments;
mbInitialized = false;
// disable buttons
@@ -89,6 +79,7 @@ void CertificateChooser::dispose()
m_pViewBtn.clear();
m_pOKBtn.clear();
m_pDescriptionED.clear();
+ mvUserData.clear();
ModalDialog::dispose();
}
@@ -159,36 +150,44 @@ void CertificateChooser::ImplInitialize()
if ( mbInitialized )
return;
- try
+ for (auto &secEnvironment : mxSecurityEnvironments)
{
- maCerts = mxSecurityEnvironment->getPersonalCertificates();
- }
- catch (security::NoPasswordException&)
- {
- }
-
- sal_Int32 nCertificates = maCerts.getLength();
- for( sal_Int32 nCert = nCertificates; nCert; )
- {
- uno::Reference< security::XCertificate > xCert = maCerts[ --nCert ];
- // Check if we have a private key for this...
- long nCertificateCharacters = mxSecurityEnvironment->getCertificateCharacters(xCert);
+ uno::Sequence< uno::Reference< security::XCertificate > > xCerts;
+ try
+ {
+ xCerts = secEnvironment->getPersonalCertificates();
+ }
+ catch (security::NoPasswordException&)
+ {
+ }
- if (!(nCertificateCharacters & security::CertificateCharacters::HAS_PRIVATE_KEY))
+ sal_Int32 nCertificates = xCerts.getLength();
+ for( sal_Int32 nCert = nCertificates; nCert; )
{
- ::comphelper::removeElementAt( maCerts, nCert );
- nCertificates = maCerts.getLength();
+ uno::Reference< security::XCertificate > xCert = xCerts[ --nCert ];
+ // Check if we have a private key for this...
+ long nCertificateCharacters = secEnvironment->getCertificateCharacters(xCert);
+
+ if (!(nCertificateCharacters & security::CertificateCharacters::HAS_PRIVATE_KEY))
+ {
+ ::comphelper::removeElementAt( xCerts, nCert );
+ nCertificates = xCerts.getLength();
+ }
}
- }
- // fill list of certificates; the first entry will be selected
- for ( sal_Int32 nC = 0; nC < nCertificates; ++nC )
- {
- SvTreeListEntry* pEntry = m_pCertLB->InsertEntry( XmlSec::GetContentPart( maCerts[ nC ]->getSubjectName() )
- + "\t" + XmlSec::GetContentPart( maCerts[ nC ]->getIssuerName() )
- + "\t" + UsageInClearText( maCerts[ nC ]->getCertificateUsage() )
- + "\t" + XmlSec::GetDateString( maCerts[ nC ]->getNotValidAfter() ) );
- pEntry->SetUserData( reinterpret_cast<void*>(nC) ); // missuse user data as index
+ // fill list of certificates; the first entry will be selected
+ for ( sal_Int32 nC = 0; nC < nCertificates; ++nC )
+ {
+ std::shared_ptr<UserData> userData = std::make_shared<UserData>();
+ userData->xCertificate = xCerts[ nC ];
+ userData->xSecurityEnvironment = secEnvironment;
+ mvUserData.push_back(userData);
+ SvTreeListEntry* pEntry = m_pCertLB->InsertEntry( XmlSec::GetContentPart( xCerts[ nC ]->getSubjectName() )
+ + "\t" + XmlSec::GetContentPart( xCerts[ nC ]->getIssuerName() )
+ + "\t" + UsageInClearText( xCerts[ nC ]->getCertificateUsage() )
+ + "\t" + XmlSec::GetDateString( xCerts[ nC ]->getNotValidAfter() ) );
+ pEntry->SetUserData( userData.get() );
+ }
}
// enable/disable buttons
@@ -199,10 +198,12 @@ void CertificateChooser::ImplInitialize()
uno::Reference< css::security::XCertificate > CertificateChooser::GetSelectedCertificate()
{
- uno::Reference< css::security::XCertificate > xCert;
- sal_uInt16 nSelected = GetSelectedEntryPos();
- if ( nSelected < maCerts.getLength() )
- xCert = maCerts[ nSelected ];
+ SvTreeListEntry* pSel = m_pCertLB->FirstSelected();
+ if( !pSel )
+ return uno::Reference< css::security::XCertificate >();
+
+ UserData* userData = static_cast<UserData*>(pSel->GetUserData());
+ uno::Reference<security::XCertificate> xCert = userData->xCertificate;
return xCert;
}
@@ -232,12 +233,17 @@ IMPL_LINK_NOARG(CertificateChooser, ViewButtonHdl, Button*, void)
void CertificateChooser::ImplShowCertificateDetails()
{
- uno::Reference< css::security::XCertificate > xCert = GetSelectedCertificate();
- if( xCert.is() )
- {
- ScopedVclPtrInstance< CertificateViewer > aViewer( this, mxSecurityEnvironment, xCert, true );
- aViewer->Execute();
- }
+ SvTreeListEntry* pSel = m_pCertLB->FirstSelected();
+ if( !pSel )
+ return;
+
+ UserData* userData = static_cast<UserData*>(pSel->GetUserData());
+
+ if (!userData->xSecurityEnvironment.is() || !userData->xCertificate.is())
+ return;
+
+ ScopedVclPtrInstance< CertificateViewer > aViewer( this, userData->xSecurityEnvironment, userData->xCertificate, true );
+ aViewer->Execute();
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx b/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx
index 2373fb21a735..24aeca30b6f2 100644
--- a/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx
+++ b/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx
@@ -383,9 +383,11 @@ IMPL_LINK_NOARG(DigitalSignaturesDialog, AddButtonHdl, Button*, void)
return;
try
{
- uno::Reference<xml::crypto::XSecurityEnvironment> xSecEnv = maSignatureManager.getSecurityEnvironment();
+ std::vector<uno::Reference<xml::crypto::XSecurityEnvironment>> xSecEnvs;
+ xSecEnvs.push_back(maSignatureManager.getSecurityEnvironment());
+ xSecEnvs.push_back(maSignatureManager.getGpgSecurityEnvironment());
- ScopedVclPtrInstance< CertificateChooser > aChooser( this, mxCtx, xSecEnv );
+ ScopedVclPtrInstance< CertificateChooser > aChooser( this, mxCtx, xSecEnvs );
if ( aChooser->Execute() == RET_OK )
{
sal_Int32 nSecurityId;
diff --git a/xmlsecurity/source/dialogs/resourcemanager.cxx b/xmlsecurity/source/dialogs/resourcemanager.cxx
index 57006192f6a6..e989af368b60 100644
--- a/xmlsecurity/source/dialogs/resourcemanager.cxx
+++ b/xmlsecurity/source/dialogs/resourcemanager.cxx
@@ -289,8 +289,22 @@ vector< pair< OUString, OUString> > parseDN(const OUString& rRawString)
OUString GetContentPart( const OUString& _rRawString )
{
char const * aIDs[] = { "CN", "OU", "O", "E", nullptr };
- OUString retVal;
+ bool shouldBeParsed = false;
int i = 0;
+ while ( aIDs[i] )
+ {
+ if (_rRawString.startsWith(OUString::createFromAscii(aIDs[i++])))
+ {
+ shouldBeParsed = true;
+ break;
+ }
+ }
+
+ if (!shouldBeParsed)
+ return _rRawString;
+
+ OUString retVal;
+ i = 0;
vector< pair< OUString, OUString > > vecAttrValueOfDN = parseDN(_rRawString);
while ( aIDs[i] )
{
diff --git a/xmlsecurity/source/gpg/CertificateImpl.cxx b/xmlsecurity/source/gpg/CertificateImpl.cxx
new file mode 100644
index 000000000000..8c12da6ddf29
--- /dev/null
+++ b/xmlsecurity/source/gpg/CertificateImpl.cxx
@@ -0,0 +1,191 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include "CertificateImpl.hxx"
+
+#include <comphelper/servicehelper.hxx>
+
+using namespace css;
+using namespace css::uno;
+using namespace css::security;
+using namespace css::util;
+
+CertificateImpl::CertificateImpl() :
+ m_pKey(nullptr)
+{
+}
+
+CertificateImpl::~CertificateImpl()
+{
+}
+
+//Methods from XCertificateImpl
+sal_Int16 SAL_CALL CertificateImpl::getVersion()
+ throw ( RuntimeException, std::exception)
+{
+ return 0;
+}
+
+Sequence< sal_Int8 > SAL_CALL CertificateImpl::getSerialNumber()
+ throw ( RuntimeException, std::exception)
+{
+ return Sequence< sal_Int8 > ();
+}
+
+OUString SAL_CALL CertificateImpl::getIssuerName()
+ throw ( RuntimeException, std::exception)
+{
+ return OStringToOUString(m_pKey.userID(0).name(), RTL_TEXTENCODING_UTF8);
+}
+
+OUString SAL_CALL CertificateImpl::getSubjectName()
+ throw ( RuntimeException, std::exception)
+{
+ return OUString("");
+}
+
+namespace {
+ DateTime convertUnixTimeToDateTime(time_t time)
+ {
+ DateTime dateTime;
+ struct tm *timeStruct = gmtime(&time);
+ dateTime.Year = timeStruct->tm_year + 1900;
+ dateTime.Month = timeStruct->tm_mon + 1;
+ dateTime.Day = timeStruct->tm_mday;
+ dateTime.Hours = timeStruct->tm_hour;
+ dateTime.Minutes = timeStruct->tm_min;
+ dateTime.Seconds = timeStruct->tm_sec;
+ return dateTime;
+ }
+}
+
+DateTime SAL_CALL CertificateImpl::getNotValidBefore()
+ throw ( RuntimeException, std::exception)
+{
+ const GpgME::Subkey subkey = m_pKey.subkey(0);
+ if (subkey.isNull())
+ return DateTime();
+
+ return convertUnixTimeToDateTime(m_pKey.subkey(0).creationTime());
+}
+
+DateTime SAL_CALL CertificateImpl::getNotValidAfter()
+ throw ( RuntimeException, std::exception)
+{
+ const GpgME::Subkey subkey = m_pKey.subkey(0);
+ if (subkey.isNull() || subkey.neverExpires())
+ return DateTime();
+
+ return convertUnixTimeToDateTime(m_pKey.subkey(0).expirationTime());
+}
+
+Sequence< sal_Int8 > SAL_CALL CertificateImpl::getIssuerUniqueID()
+ throw ( RuntimeException, std::exception)
+{
+ return Sequence< sal_Int8 > ();
+}
+
+Sequence< sal_Int8 > SAL_CALL CertificateImpl::getSubjectUniqueID()
+ throw ( RuntimeException, std::exception)
+{
+ return Sequence< sal_Int8 > ();
+}
+
+Sequence< Reference< XCertificateExtension > > SAL_CALL CertificateImpl::getExtensions()
+ throw ( RuntimeException, std::exception)
+{
+ return Sequence< Reference< XCertificateExtension > > ();
+}
+
+Reference< XCertificateExtension > SAL_CALL CertificateImpl::findCertificateExtension( const Sequence< sal_Int8 >& /*oid*/ )
+ throw (RuntimeException, std::exception)
+{
+ return Reference< XCertificateExtension > ();
+}
+
+Sequence< sal_Int8 > SAL_CALL CertificateImpl::getEncoded()
+ throw ( RuntimeException, std::exception)
+{
+ return Sequence< sal_Int8 > ();
+}
+
+OUString SAL_CALL CertificateImpl::getSubjectPublicKeyAlgorithm()
+ throw ( RuntimeException, std::exception)
+{
+ return OUString();
+}
+
+Sequence< sal_Int8 > SAL_CALL CertificateImpl::getSubjectPublicKeyValue()
+ throw ( RuntimeException, std::exception)
+{
+ return Sequence< sal_Int8 > ();
+}
+
+OUString SAL_CALL CertificateImpl::getSignatureAlgorithm()
+ throw ( RuntimeException, std::exception)
+{
+ return OUString();
+}
+
+Sequence< sal_Int8 > SAL_CALL CertificateImpl::getSHA1Thumbprint()
+ throw ( RuntimeException, std::exception)
+{
+ return Sequence< sal_Int8 > ();
+}
+
+uno::Sequence<sal_Int8> CertificateImpl::getSHA256Thumbprint()
+ throw (uno::RuntimeException, std::exception)
+{
+ return Sequence< sal_Int8 > ();
+}
+
+Sequence< sal_Int8 > SAL_CALL CertificateImpl::getMD5Thumbprint()
+ throw ( RuntimeException, std::exception)
+{
+ return Sequence< sal_Int8 > ();
+}
+
+sal_Int32 SAL_CALL CertificateImpl::getCertificateUsage()
+ throw ( RuntimeException, std::exception)
+{
+ return 0;
+}
+
+/* XUnoTunnel */
+sal_Int64 SAL_CALL CertificateImpl::getSomething(const Sequence< sal_Int8 >& aIdentifier)
+ throw( RuntimeException, std::exception )
+{
+ if( aIdentifier.getLength() == 16 && 0 == memcmp( getUnoTunnelId().getConstArray(), aIdentifier.getConstArray(), 16 ) ) {
+ return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_uIntPtr>(this));
+ }
+ return 0 ;
+}
+
+/* XUnoTunnel extension */
+
+namespace
+{
+ class CertificateImplUnoTunnelId : public rtl::Static< UnoTunnelIdInit, CertificateImplUnoTunnelId > {};
+}
+
+const Sequence< sal_Int8>& CertificateImpl::getUnoTunnelId() {
+ return CertificateImplUnoTunnelId::get().getSeq();
+}
+
+void CertificateImpl::setCertificate(GpgME::Key key)
+{
+ m_pKey = key;
+}
+
+const GpgME::Key* CertificateImpl::getCertificate() const
+{
+ return &m_pKey;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmlsecurity/source/gpg/CertificateImpl.hxx b/xmlsecurity/source/gpg/CertificateImpl.hxx
new file mode 100644
index 000000000000..8d4b08c2de62
--- /dev/null
+++ b/xmlsecurity/source/gpg/CertificateImpl.hxx
@@ -0,0 +1,107 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef INCLUDED_XMLSECURITY_SOURCE_GPG_X509CERTIFICATE_HXX
+#define INCLUDED_XMLSECURITY_SOURCE_GPG_X509CERTIFICATE_HXX
+
+#include <certificate.hxx>
+
+#include <sal/types.h>
+#include <sal/config.h>
+#include <rtl/ustring.hxx>
+#include <cppuhelper/factory.hxx>
+#include <cppuhelper/implbase.hxx>
+
+#include <com/sun/star/uno/Exception.hpp>
+#include <com/sun/star/uno/RuntimeException.hpp>
+#include <com/sun/star/uno/Sequence.hxx>
+#include <com/sun/star/lang/XUnoTunnel.hpp>
+#include <com/sun/star/uno/SecurityException.hpp>
+#include <com/sun/star/security/XCertificate.hpp>
+
+#include <key.h>
+
+class CertificateImpl : public cppu::WeakImplHelper< css::security::XCertificate,
+ css::lang::XUnoTunnel >,
+ public xmlsecurity::Certificate
+{
+private:
+ GpgME::Key m_pKey;
+
+public:
+ CertificateImpl();
+ virtual ~CertificateImpl() override;
+
+ //Methods from XCertificate
+ virtual sal_Int16 SAL_CALL getVersion()
+ throw ( css::uno::RuntimeException, std::exception) override;
+
+ virtual css::uno::Sequence< sal_Int8 > SAL_CALL getSerialNumber()
+ throw ( css::uno::RuntimeException, std::exception) override;
+
+ virtual OUString SAL_CALL getIssuerName()
+ throw ( css::uno::RuntimeException, std::exception) override;
+ virtual OUString SAL_CALL getSubjectName()
+ throw ( css::uno::RuntimeException, std::exception) override;
+
+ virtual css::util::DateTime SAL_CALL getNotValidBefore()
+ throw ( css::uno::RuntimeException, std::exception) override;
+ virtual css::util::DateTime SAL_CALL getNotValidAfter()
+ throw ( css::uno::RuntimeException, std::exception) override;
+
+ virtual css::uno::Sequence< sal_Int8 > SAL_CALL getIssuerUniqueID()
+ throw ( css::uno::RuntimeException, std::exception) override;
+ virtual css::uno::Sequence< sal_Int8 > SAL_CALL getSubjectUniqueID()
+ throw ( css::uno::RuntimeException, std::exception) override;
+
+ virtual css::uno::Sequence< css::uno::Reference< css::security::XCertificateExtension > > SAL_CALL getExtensions()
+ throw ( css::uno::RuntimeException, std::exception) override;
+
+ virtual css::uno::Reference< css::security::XCertificateExtension > SAL_CALL findCertificateExtension(const css::uno::Sequence< sal_Int8 >& oid)
+ throw (css::uno::RuntimeException, std::exception) override;
+
+ virtual css::uno::Sequence< sal_Int8 > SAL_CALL getEncoded()
+ throw ( css::uno::RuntimeException, std::exception) override;
+
+ virtual OUString SAL_CALL getSubjectPublicKeyAlgorithm()
+ throw ( css::uno::RuntimeException, std::exception) override;
+
+ virtual css::uno::Sequence< sal_Int8 > SAL_CALL getSubjectPublicKeyValue()
+ throw ( css::uno::RuntimeException, std::exception) override;
+
+ virtual OUString SAL_CALL getSignatureAlgorithm()
+ throw ( css::uno::RuntimeException, std::exception) override;
+
+ virtual css::uno::Sequence< sal_Int8 > SAL_CALL getSHA1Thumbprint()
+ throw ( css::uno::RuntimeException, std::exception) override;
+
+ virtual css::uno::Sequence< sal_Int8 > SAL_CALL getMD5Thumbprint()
+ throw ( css::uno::RuntimeException, std::exception) override;
+
+ virtual sal_Int32 SAL_CALL getCertificateUsage()
+ throw ( css::uno::RuntimeException, std::exception) override;
+
+ //Methods from XUnoTunnel
+ virtual sal_Int64 SAL_CALL getSomething(const css::uno::Sequence< sal_Int8 >& aIdentifier)
+ throw (css::uno::RuntimeException, std::exception) override;
+
+ static const css::uno::Sequence< sal_Int8 >& getUnoTunnelId();
+
+ /// @see xmlsecurity::Certificate::getSHA256Thumbprint().
+ virtual css::uno::Sequence<sal_Int8> getSHA256Thumbprint()
+ throw (css::uno::RuntimeException, std::exception) override;
+
+ // Helper methods
+ void setCertificate(GpgME::Key key);
+ const GpgME::Key* getCertificate() const;
+} ;
+
+#endif // INCLUDED_XMLSECURITY_SOURCE_GPG_X509CERTIFICATE_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmlsecurity/source/gpg/CipherContext.cxx b/xmlsecurity/source/gpg/CipherContext.cxx
new file mode 100644
index 000000000000..97d27dc36de0
--- /dev/null
+++ b/xmlsecurity/source/gpg/CipherContext.cxx
@@ -0,0 +1,30 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include "CipherContext.hxx"
+
+using namespace css;
+using namespace css::uno;
+using namespace css::lang;
+
+Sequence< sal_Int8 > SAL_CALL CipherContext::convertWithCipherContext( const Sequence< sal_Int8 >& /*aData*/ )
+ throw ( IllegalArgumentException, DisposedException, RuntimeException, std::exception)
+{
+ Sequence<sal_Int8>* seq = new Sequence< sal_Int8 >(0);
+ return *seq;
+}
+
+uno::Sequence< sal_Int8 > SAL_CALL CipherContext::finalizeCipherContextAndDispose()
+ throw (DisposedException, RuntimeException, std::exception)
+{
+ Sequence<sal_Int8>* seq = new Sequence< sal_Int8 >(0);
+ return *seq;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmlsecurity/source/gpg/CipherContext.hxx b/xmlsecurity/source/gpg/CipherContext.hxx
new file mode 100644
index 000000000000..f08d4397c268
--- /dev/null
+++ b/xmlsecurity/source/gpg/CipherContext.hxx
@@ -0,0 +1,33 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef INCLUDED_XMLSECURITY_SOURCE_GPG_CIPHERCONTEXT_HXX
+#define INCLUDED_XMLSECURITY_SOURCE_GPG_CIPHERCONTEXT_HXX
+
+#include <com/sun/star/xml/crypto/XCipherContext.hpp>
+#include <com/sun/star/lang/IllegalArgumentException.hpp>
+#include <com/sun/star/lang/DisposedException.hpp>
+
+#include <cppuhelper/implbase.hxx>
+
+class CipherContext : public cppu::WeakImplHelper< css::xml::crypto::XCipherContext >
+{
+private:
+
+public:
+ // XCipherContext
+ virtual css::uno::Sequence< ::sal_Int8 > SAL_CALL convertWithCipherContext(const css::uno::Sequence< ::sal_Int8 >& aData)
+ throw (css::lang::IllegalArgumentException, css::lang::DisposedException, css::uno::RuntimeException, std::exception) override;
+ virtual css::uno::Sequence< ::sal_Int8 > SAL_CALL finalizeCipherContextAndDispose()
+ throw (css::lang::DisposedException, css::uno::RuntimeException, std::exception) override;
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmlsecurity/source/gpg/DigestContext.cxx b/xmlsecurity/source/gpg/DigestContext.cxx
new file mode 100644
index 000000000000..5d86b7c44055
--- /dev/null
+++ b/xmlsecurity/source/gpg/DigestContext.cxx
@@ -0,0 +1,30 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+
+#include "DigestContext.hxx"
+
+using namespace css;
+using namespace css::uno;
+using namespace css::lang;
+
+
+void SAL_CALL DigestContext::updateDigest( const uno::Sequence< ::sal_Int8 >& /*aData*/ )
+ throw (DisposedException, RuntimeException, std::exception)
+{
+}
+
+uno::Sequence< sal_Int8 > SAL_CALL DigestContext::finalizeDigestAndDispose()
+ throw (DisposedException, RuntimeException, std::exception)
+{
+ Sequence<sal_Int8>* seq = new Sequence< sal_Int8 >(0);
+ return *seq;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmlsecurity/source/gpg/DigestContext.hxx b/xmlsecurity/source/gpg/DigestContext.hxx
new file mode 100644
index 000000000000..8ed2f03e2ed7
--- /dev/null
+++ b/xmlsecurity/source/gpg/DigestContext.hxx
@@ -0,0 +1,31 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef INCLUDED_XMLSECURITY_SOURCE_GPG_DIGESTCONTEXT_HXX
+#define INCLUDED_XMLSECURITY_SOURCE_GPG_DIGESTCONTEXT_HXX
+
+#include <com/sun/star/xml/crypto/XDigestContext.hpp>
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <com/sun/star/uno/RuntimeException.hpp>
+
+#include <cppuhelper/implbase.hxx>
+
+class DigestContext : public cppu::WeakImplHelper< css::xml::crypto::XDigestContext >
+{
+public:
+ // XDigestContext
+ virtual void SAL_CALL updateDigest( const css::uno::Sequence< ::sal_Int8 >& aData )
+ throw (css::lang::DisposedException, css::uno::RuntimeException, std::exception) override;
+ virtual css::uno::Sequence< ::sal_Int8 > SAL_CALL finalizeDigestAndDispose()
+ throw (css::lang::DisposedException, css::uno::RuntimeException, std::exception) override;
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmlsecurity/source/gpg/GpgComponentFactory.cxx b/xmlsecurity/source/gpg/GpgComponentFactory.cxx
new file mode 100644
index 000000000000..3f0f2d1ba8f3
--- /dev/null
+++ b/xmlsecurity/source/gpg/GpgComponentFactory.cxx
@@ -0,0 +1,70 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include "SecurityEnvironment.hxx"
+#include "SEInitializer.hxx"
+#include "XMLSignature.hxx"
+#include "XMLEncryption.hxx"
+#include "XMLSecurityContext.hxx"
+
+#include <cppuhelper/factory.hxx>
+
+using namespace cppu;
+using namespace css::uno;
+using namespace css::lang;
+using namespace css::registry;
+
+extern "C"
+{
+
+SAL_DLLPUBLIC_EXPORT void* SAL_CALL xsec_gpg_component_getFactory( const sal_Char* pImplName , void* pServiceManager , void* /*pRegistryKey*/ )
+{
+ void* pRet = nullptr;
+ Reference< XSingleServiceFactory > xFactory ;
+
+ if( pImplName != nullptr && pServiceManager != nullptr )
+ {
+#ifdef XMLSEC_CRYPTO_GPG
+ if( SEInitializer_getImplementationName().equalsAscii( pImplName ) )
+ {
+ xFactory.set( createSingleFactory(
+ static_cast< XMultiServiceFactory * >( pServiceManager ),
+ OUString::createFromAscii( pImplName ),
+ SEInitializer_createInstance, SEInitializer_getSupportedServiceNames() ) );
+ }
+ else if( XMLSignatureGpg::impl_getImplementationName().equalsAscii( pImplName ) )
+ {
+ xFactory = XMLSignatureGpg::impl_createFactory( static_cast< XMultiServiceFactory* >( pServiceManager ) ) ;
+ }
+ else if( XMLSecurityContextGpg::impl_getImplementationName().equalsAscii( pImplName ) )
+ {
+ xFactory = XMLSecurityContextGpg::impl_createFactory( static_cast< XMultiServiceFactory* >( pServiceManager ) ) ;
+ }
+ else if( SecurityEnvironmentGpg::impl_getImplementationName().equalsAscii( pImplName ) )
+ {
+ xFactory = SecurityEnvironmentGpg::impl_createFactory( static_cast< XMultiServiceFactory* >( pServiceManager ) ) ;
+ }
+ else if( XMLEncryptionGpg::impl_getImplementationName().equalsAscii( pImplName ) )
+ {
+ xFactory = XMLEncryptionGpg::impl_createFactory( static_cast< XMultiServiceFactory* >( pServiceManager ) ) ;
+ }
+#endif
+ }
+
+ if( xFactory.is() ) {
+ xFactory->acquire() ;
+ pRet = xFactory.get() ;
+ }
+
+ return pRet ;
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmlsecurity/source/gpg/SEInitializer.cxx b/xmlsecurity/source/gpg/SEInitializer.cxx
new file mode 100644
index 000000000000..e620ece7e32a
--- /dev/null
+++ b/xmlsecurity/source/gpg/SEInitializer.cxx
@@ -0,0 +1,99 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include "SEInitializer.hxx"
+#include "SecurityEnvironment.hxx"
+
+#include <comphelper/processfactory.hxx>
+#include <cppuhelper/supportsservice.hxx>
+
+#include <com/sun/star/xml/crypto/gpg/GpgSecurityEnvironment.hpp>
+#include <com/sun/star/xml/crypto/gpg/GpgXMLSecurityContext.hpp>
+
+using namespace css;
+using namespace css::lang;
+using namespace css::uno;
+using namespace css::xml::crypto;
+
+
+SEInitializerGpg::SEInitializerGpg( const css::uno::Reference< css::uno::XComponentContext > &rxContext )
+{
+ m_xContext = rxContext;
+}
+
+SEInitializerGpg::~SEInitializerGpg()
+{
+}
+
+/* XSEInitializer */
+Reference< XXMLSecurityContext > SAL_CALL SEInitializerGpg::createSecurityContext( const OUString& )
+ throw (RuntimeException, std::exception)
+{
+ try
+ {
+ /* Build XML Security Context */
+ Reference< XXMLSecurityContext > xSecCtx = xml::crypto::gpg::GpgXMLSecurityContext::create(m_xContext);
+
+ Reference< XSecurityEnvironment > xSecEnv = xml::crypto::gpg::GpgSecurityEnvironment::create(m_xContext);
+ Reference< XUnoTunnel > xSecEnvTunnel(xSecEnv, uno::UNO_QUERY_THROW);
+
+ sal_Int32 n = xSecCtx->addSecurityEnvironment(xSecEnv);
+ //originally the SecurityEnvironment with the internal slot was set as default
+ xSecCtx->setDefaultSecurityEnvironmentIndex( n );
+ return xSecCtx;
+ }
+ catch( const uno::Exception& )
+ {
+ return nullptr;
+ }
+}
+
+void SAL_CALL SEInitializerGpg::freeSecurityContext( const uno::Reference< XXMLSecurityContext >& )
+ throw (uno::RuntimeException, std::exception)
+{
+}
+
+OUString SEInitializer_getImplementationName()
+ throw (uno::RuntimeException)
+{
+ return OUString("com.sun.star.xml.security.SEInitializer_Gpg");
+}
+
+uno::Sequence< OUString > SAL_CALL SEInitializer_getSupportedServiceNames( )
+ throw (uno::RuntimeException)
+{
+ return {"com.sun.star.xml.crypto.gpg.GpgSEInitializer"};
+}
+
+uno::Reference< uno::XInterface > SAL_CALL SEInitializer_createInstance( const uno::Reference< lang::XMultiServiceFactory > & rxMSF)
+ throw( uno::Exception )
+{
+ return static_cast<cppu::OWeakObject*>(new SEInitializerGpg(comphelper::getComponentContext(rxMSF)));
+}
+
+/* XServiceInfo */
+OUString SAL_CALL SEInitializerGpg::getImplementationName()
+ throw (uno::RuntimeException, std::exception)
+{
+ return SEInitializer_getImplementationName();
+}
+
+sal_Bool SAL_CALL SEInitializerGpg::supportsService( const OUString& rServiceName )
+ throw (uno::RuntimeException, std::exception)
+{
+ return cppu::supportsService(this, rServiceName);
+}
+
+uno::Sequence< OUString > SAL_CALL SEInitializerGpg::getSupportedServiceNames()
+ throw (uno::RuntimeException, std::exception)
+{
+ return SEInitializer_getSupportedServiceNames();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmlsecurity/source/gpg/SEInitializer.hxx b/xmlsecurity/source/gpg/SEInitializer.hxx
new file mode 100644
index 000000000000..c087cc7f9346
--- /dev/null
+++ b/xmlsecurity/source/gpg/SEInitializer.hxx
@@ -0,0 +1,68 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef INCLUDED_XMLSECURITY_SOURCE_GPG_SEINITIALIZER_HXX
+#define INCLUDED_XMLSECURITY_SOURCE_GPG_SEINITIALIZER_HXX
+
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <com/sun/star/uno/Reference.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/xml/crypto/XXMLSecurityContext.hpp>
+#include <com/sun/star/xml/crypto/XSEInitializer.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+
+#include <cppuhelper/implbase.hxx>
+
+class SEInitializerGpg : public cppu::WeakImplHelper< css::xml::crypto::XSEInitializer,
+ css::lang::XServiceInfo >
+{
+protected:
+ css::uno::Reference< css::uno::XComponentContext > m_xContext;
+
+public:
+ explicit SEInitializerGpg(const css::uno::Reference<css::uno::XComponentContext > &rxContext);
+ virtual ~SEInitializerGpg() override;
+
+ /* XSEInitializer */
+ virtual css::uno::Reference< css::xml::crypto::XXMLSecurityContext >
+ SAL_CALL createSecurityContext( const OUString& )
+ throw (css::uno::RuntimeException, std::exception) override;
+
+ virtual void SAL_CALL freeSecurityContext( const css::uno::Reference<
+ css::xml::crypto::XXMLSecurityContext >& securityContext )
+ throw (css::uno::RuntimeException, std::exception) override;
+
+ /* XServiceInfo */
+ virtual OUString SAL_CALL getImplementationName( )
+ throw (css::uno::RuntimeException, std::exception) override;
+
+ virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName )
+ throw (css::uno::RuntimeException, std::exception) override;
+
+ virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( )
+ throw (css::uno::RuntimeException, std::exception) override;
+};
+
+/// @throws css::uno::RuntimeException
+OUString SEInitializer_getImplementationName()
+ throw ( css::uno::RuntimeException );
+
+/// @throws css::uno::RuntimeException
+css::uno::Sequence< OUString > SAL_CALL SEInitializer_getSupportedServiceNames()
+ throw ( css::uno::RuntimeException );
+
+/// @throws css::uno::Exception
+css::uno::Reference< css::uno::XInterface > SAL_CALL SEInitializer_createInstance(
+ const css::uno::Reference< css::lang::XMultiServiceFactory > & rxMSF)
+ throw ( css::uno::Exception );
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmlsecurity/source/gpg/SecurityEnvironment.cxx b/xmlsecurity/source/gpg/SecurityEnvironment.cxx
new file mode 100644
index 000000000000..3ea14799ac8c
--- /dev/null
+++ b/xmlsecurity/source/gpg/SecurityEnvironment.cxx
@@ -0,0 +1,198 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include "SecurityEnvironment.hxx"
+#include "CertificateImpl.hxx"
+
+#include <cppuhelper/supportsservice.hxx>
+#include <comphelper/servicehelper.hxx>
+#include <list>
+
+#include <gpgme.h>
+#include <context.h>
+#include <key.h>
+#include <keylistresult.h>
+
+using namespace css;
+using namespace css::security;
+using namespace css::uno;
+using namespace css::lang;
+
+SecurityEnvironmentGpg::SecurityEnvironmentGpg()
+{
+}
+
+SecurityEnvironmentGpg::~SecurityEnvironmentGpg()
+{
+}
+
+/* XServiceInfo */
+OUString SAL_CALL SecurityEnvironmentGpg::getImplementationName()
+ throw( RuntimeException, std::exception )
+{
+ return impl_getImplementationName();
+}
+
+/* XServiceInfo */
+sal_Bool SAL_CALL SecurityEnvironmentGpg::supportsService( const OUString& serviceName)
+ throw( RuntimeException, std::exception )
+{
+ return cppu::supportsService(this, serviceName);
+}
+
+/* XServiceInfo */
+Sequence< OUString > SAL_CALL SecurityEnvironmentGpg::getSupportedServiceNames()
+ throw( RuntimeException, std::exception )
+{
+ return impl_getSupportedServiceNames() ;
+}
+
+//Helper for XServiceInfo
+Sequence< OUString > SecurityEnvironmentGpg::impl_getSupportedServiceNames()
+{
+ return { "com.sun.star.xml.crypto.gpg.GpgSecurityEnvironment" } ;
+}
+
+OUString SecurityEnvironmentGpg::impl_getImplementationName()
+ throw( RuntimeException )
+{
+ return OUString("com.sun.star.xml.security.SecurityEnvironment_Gpg");
+}
+
+//Helper for registry
+Reference< XInterface > SAL_CALL SecurityEnvironmentGpg::impl_createInstance( const Reference< XMultiServiceFactory >& )
+ throw( RuntimeException )
+{
+ return Reference< XInterface >( *new SecurityEnvironmentGpg ) ;
+}
+
+Reference< XSingleServiceFactory > SecurityEnvironmentGpg::impl_createFactory( const Reference< XMultiServiceFactory >& aServiceManager ) {
+ return ::cppu::createSingleFactory( aServiceManager , impl_getImplementationName() , impl_createInstance , impl_getSupportedServiceNames() ) ;
+}
+
+/* XUnoTunnel */
+sal_Int64 SAL_CALL SecurityEnvironmentGpg::getSomething( const Sequence< sal_Int8 >& aIdentifier )
+ throw( RuntimeException, std::exception )
+{
+ if( aIdentifier.getLength() == 16 && 0 == memcmp( getUnoTunnelId().getConstArray(), aIdentifier.getConstArray(), 16 ) ) {
+ return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_uIntPtr>(this));
+ }
+ return 0 ;
+}
+
+/* XUnoTunnel extension */
+
+namespace
+{
+ class theSecurityEnvironmentUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theSecurityEnvironmentUnoTunnelId > {};
+}
+
+const Sequence< sal_Int8>& SecurityEnvironmentGpg::getUnoTunnelId() {
+ return theSecurityEnvironmentUnoTunnelId::get().getSeq();
+}
+
+OUString SecurityEnvironmentGpg::getSecurityEnvironmentInformation()
+ throw( RuntimeException, std::exception )
+{
+ return OUString("");
+}
+
+Sequence< Reference < XCertificate > > SecurityEnvironmentGpg::getPersonalCertificates()
+ throw( SecurityException , RuntimeException, std::exception )
+{
+ GpgME::initializeLibrary();
+ GpgME::Error err = GpgME::checkEngine(GpgME::OpenPGP);
+ if (err)
+ throw RuntimeException("The GpgME library failed to initialize for the OpenPGP protocol.");
+
+ std::shared_ptr<GpgME::Context> ctx(GpgME::Context::createForProtocol(GpgME::OpenPGP));
+ if (ctx == nullptr)
+ throw RuntimeException("The GpgME library failed to initialize for the OpenPGP protocol.");
+
+ CertificateImpl* xCert;
+ std::list< CertificateImpl* > certsList;
+
+ ctx->setKeyListMode(GPGME_KEYLIST_MODE_LOCAL);
+ err = ctx->startKeyListing();
+ while (!err) {
+ GpgME::Key k = ctx->nextKey(err);
+ if (err)
+ break;
+ if (!k.isInvalid() && k.canEncrypt() && (k.ownerTrust() == GpgME::Key::Ultimate)) {
+ xCert = new CertificateImpl();
+ xCert->setCertificate(k);
+ certsList.push_back(xCert);
+ }
+ }
+ ctx->endKeyListing();
+
+ 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 ;
+
+ return xCertificateSequence;
+}
+
+Reference< XCertificate > SecurityEnvironmentGpg::getCertificate( const OUString& /*issuerName*/, const Sequence< sal_Int8 >& /*serialNumber*/ )
+ throw( SecurityException , RuntimeException, std::exception )
+{
+ return nullptr;
+}
+
+Sequence< Reference < XCertificate > > SecurityEnvironmentGpg::buildCertificatePath( const Reference< XCertificate >& /*begin*/ )
+ throw( SecurityException , RuntimeException, std::exception )
+{
+ return Sequence< Reference < XCertificate > >();
+}
+
+Reference< XCertificate > SecurityEnvironmentGpg::createCertificateFromRaw( const Sequence< sal_Int8 >& /*rawCertificate*/ )
+ throw( SecurityException , RuntimeException, std::exception )
+{
+ return nullptr;
+}
+
+Reference< XCertificate > SecurityEnvironmentGpg::createCertificateFromAscii( const OUString& /*asciiCertificate*/ )
+ throw( SecurityException , RuntimeException, std::exception )
+{
+ return nullptr;
+}
+
+sal_Int32 SecurityEnvironmentGpg::verifyCertificate( const Reference< XCertificate >& /*aCert*/,
+ const Sequence< Reference< XCertificate > >& /*intermediateCerts*/ )
+ throw( SecurityException, RuntimeException, std::exception )
+{
+ return 0;
+}
+
+sal_Int32 SecurityEnvironmentGpg::getCertificateCharacters(
+ const Reference< XCertificate >& /*aCert*/)
+ throw( SecurityException, RuntimeException, std::exception )
+{
+// const CertificateImpl* xCert;
+// const GpgME::Key* key;
+//
+// Reference< XUnoTunnel > xCertTunnel(aCert, UNO_QUERY_THROW) ;
+// xCert = reinterpret_cast<CertificateImpl*>(sal::static_int_cast<sal_uIntPtr>(xCertTunnel->getSomething(CertificateImpl::getUnoTunnelId()))) ;
+// if (xCert == nullptr)
+// throw RuntimeException();
+//
+// key = xCert->getCertificate();
+//
+ sal_Int32 characters = 0x0;
+
+ // TODO There is a bug in gpgme, hasSecret() always returns false. Need to find a workaround.
+ //if (key->hasSecret())
+ characters |= CertificateCharacters::HAS_PRIVATE_KEY;
+
+ return characters;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmlsecurity/source/gpg/SecurityEnvironment.hxx b/xmlsecurity/source/gpg/SecurityEnvironment.hxx
new file mode 100644
index 000000000000..db778ab3cb69
--- /dev/null
+++ b/xmlsecurity/source/gpg/SecurityEnvironment.hxx
@@ -0,0 +1,108 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef INCLUDED_XMLSECURITY_SOURCE_GPG_SECURITYENVIRONMENT_HXX
+#define INCLUDED_XMLSECURITY_SOURCE_GPG_SECURITYENVIRONMENT_HXX
+
+#include <sal/config.h>
+#include <rtl/ustring.hxx>
+#include <cppuhelper/factory.hxx>
+#include <cppuhelper/implbase.hxx>
+#include <com/sun/star/uno/Exception.hpp>
+
+#include <com/sun/star/uno/Reference.hxx>
+#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/uno/SecurityException.hpp>
+#include <com/sun/star/xml/crypto/XSecurityEnvironment.hpp>
+#include <com/sun/star/security/XCertificate.hpp>
+#include <com/sun/star/security/CertificateCharacters.hpp>
+#include <com/sun/star/security/CertificateValidity.hpp>
+#include <com/sun/star/lang/XUnoTunnel.hpp>
+
+
+class SecurityEnvironmentGpg : public cppu::WeakImplHelper< css::xml::crypto::XSecurityEnvironment,
+ css::lang::XServiceInfo,
+ css::lang::XUnoTunnel >
+{
+private:
+ osl::Mutex m_mutex;
+
+public:
+ SecurityEnvironmentGpg();
+ virtual ~SecurityEnvironmentGpg() override;
+
+ //Methods from XSecurityEnvironment
+
+ //Methods from XServiceInfo
+ virtual OUString SAL_CALL getImplementationName()
+ throw( css::uno::RuntimeException, std::exception ) override;
+
+ virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName)
+ throw( css::uno::RuntimeException, std::exception ) override;
+
+ virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames()
+ throw( css::uno::RuntimeException, std::exception ) override;
+
+ //Helper for XServiceInfo
+ static css::uno::Sequence< OUString > impl_getSupportedServiceNames() ;
+
+ /// @throws css::uno::RuntimeException
+ static OUString impl_getImplementationName()
+ throw( css::uno::RuntimeException ) ;
+
+ //Helper for registry
+ /// @throws css::uno::RuntimeException
+ static css::uno::Reference< css::uno::XInterface > SAL_CALL impl_createInstance(const css::uno::Reference< css::lang::XMultiServiceFactory >& aServiceManager)
+ throw( css::uno::RuntimeException ) ;
+
+ static css::uno::Reference< css::lang::XSingleServiceFactory > impl_createFactory( const css::uno::Reference< css::lang::XMultiServiceFactory >& aServiceManager ) ;
+
+ virtual ::sal_Int32 SAL_CALL verifyCertificate(
+ const css::uno::Reference<
+ css::security::XCertificate >& xCert,
+ const css::uno::Sequence<
+ css::uno::Reference< css::security::XCertificate > > &
+ intermediateCerts)
+ throw (css::uno::SecurityException, css::uno::RuntimeException, std::exception) override;
+
+ virtual ::sal_Int32 SAL_CALL getCertificateCharacters( const css::uno::Reference< css::security::XCertificate >& xCert )
+ throw (css::uno::SecurityException, css::uno::RuntimeException, std::exception) override;
+
+ virtual OUString SAL_CALL getSecurityEnvironmentInformation()
+ throw (css::uno::RuntimeException, std::exception) override;
+
+ //Methods from XUnoTunnel
+ virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& aIdentifier )
+ throw (css::uno::RuntimeException, std::exception) override;
+
+ static const css::uno::Sequence< sal_Int8 >& getUnoTunnelId() ;
+
+ virtual css::uno::Sequence< css::uno::Reference< css::security::XCertificate > > SAL_CALL getPersonalCertificates()
+ throw( css::uno::SecurityException , css::uno::RuntimeException, std::exception ) override;
+
+ virtual css::uno::Reference< css::security::XCertificate > SAL_CALL getCertificate( const OUString& issuerName, const css::uno::Sequence< sal_Int8 >& serialNumber )
+ throw( css::uno::SecurityException , css::uno::RuntimeException, std::exception ) override;
+
+ virtual css::uno::Sequence< css::uno::Reference< css::security::XCertificate > > SAL_CALL buildCertificatePath(
+ const css::uno::Reference< css::security::XCertificate >& beginCert )
+ throw( css::uno::SecurityException , css::uno::RuntimeException, std::exception ) override;
+
+ virtual css::uno::Reference< css::security::XCertificate > SAL_CALL createCertificateFromRaw(
+ const css::uno::Sequence< sal_Int8 >& rawCertificate )
+ throw( css::uno::SecurityException , css::uno::RuntimeException, std::exception ) override;
+ virtual css::uno::Reference< css::security::XCertificate > SAL_CALL createCertificateFromAscii(
+ const OUString& asciiCertificate )
+ throw( css::uno::SecurityException , css::uno::RuntimeException, std::exception ) override;
+
+} ;
+
+#endif // INCLUDED_XMLSECURITY_SOURCE_GPG_SECURITYENVIRONMENT_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmlsecurity/source/gpg/XMLEncryption.cxx b/xmlsecurity/source/gpg/XMLEncryption.cxx
new file mode 100644
index 000000000000..e40de517fc1b
--- /dev/null
+++ b/xmlsecurity/source/gpg/XMLEncryption.cxx
@@ -0,0 +1,86 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include "XMLEncryption.hxx"
+
+#include <cppuhelper/supportsservice.hxx>
+
+using namespace css::uno;
+using namespace css::lang;
+using namespace css::xml::wrapper;
+using namespace css::xml::crypto;
+
+XMLEncryptionGpg::XMLEncryptionGpg() {
+}
+
+XMLEncryptionGpg::~XMLEncryptionGpg() {
+}
+
+/* XXMLEncryption */
+Reference< XXMLEncryptionTemplate > SAL_CALL XMLEncryptionGpg::encrypt(const Reference< XXMLEncryptionTemplate >& /*aTemplate*/,
+ const Reference< XSecurityEnvironment >& /*aEnvironment*/)
+ throw (XMLEncryptionException, SecurityException, RuntimeException, std::exception)
+{
+ return nullptr;
+}
+
+/* XXMLEncryption */
+Reference< XXMLEncryptionTemplate > SAL_CALL XMLEncryptionGpg::decrypt(const Reference< XXMLEncryptionTemplate >& /*aTemplate*/,
+ const Reference< XXMLSecurityContext >& /*aSecurityCtx*/)
+ throw (XMLEncryptionException, SecurityException, RuntimeException, std::exception)
+{
+ return nullptr;
+}
+
+/* XServiceInfo */
+OUString SAL_CALL XMLEncryptionGpg::getImplementationName()
+ throw( RuntimeException, std::exception )
+{
+ return impl_getImplementationName() ;
+}
+
+/* XServiceInfo */
+sal_Bool SAL_CALL XMLEncryptionGpg::supportsService( const OUString& serviceName)
+ throw( RuntimeException, std::exception )
+{
+ return cppu::supportsService(this, serviceName);
+}
+
+/* XServiceInfo */
+Sequence< OUString > SAL_CALL XMLEncryptionGpg::getSupportedServiceNames()
+ throw( RuntimeException, std::exception )
+{
+ return impl_getSupportedServiceNames() ;
+}
+
+//Helper for XServiceInfo
+Sequence< OUString > XMLEncryptionGpg::impl_getSupportedServiceNames()
+{
+ return {"com.sun.star.xml.crypto.gpg.GpgXMLEncryption"};
+}
+
+OUString XMLEncryptionGpg::impl_getImplementationName()
+ throw( RuntimeException )
+{
+ return OUString("com.sun.star.xml.security.XMLEncryption_Gpg");
+}
+
+//Helper for registry
+Reference< XInterface > SAL_CALL XMLEncryptionGpg::impl_createInstance( const Reference< XMultiServiceFactory >& )
+ throw( RuntimeException )
+{
+ return Reference< XInterface >(*new XMLEncryptionGpg);
+}
+
+Reference< XSingleServiceFactory > XMLEncryptionGpg::impl_createFactory( const Reference< XMultiServiceFactory >& aServiceManager )
+{
+ return ::cppu::createSingleFactory(aServiceManager, impl_getImplementationName(), impl_createInstance, impl_getSupportedServiceNames());
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmlsecurity/source/gpg/XMLEncryption.hxx b/xmlsecurity/source/gpg/XMLEncryption.hxx
new file mode 100644
index 000000000000..ff78e4b49ecf
--- /dev/null
+++ b/xmlsecurity/source/gpg/XMLEncryption.hxx
@@ -0,0 +1,77 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef INCLUDED_XMLSECURITY_SOURCE_GPG_XMLENCRYPTION_HXX
+#define INCLUDED_XMLSECURITY_SOURCE_GPG_XMLENCRYPTION_HXX
+
+#include <sal/config.h>
+#include <rtl/ustring.hxx>
+#include <cppuhelper/factory.hxx>
+#include <cppuhelper/implbase.hxx>
+#include <com/sun/star/uno/Exception.hpp>
+
+#include <com/sun/star/uno/Reference.hxx>
+#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/xml/crypto/XXMLEncryption.hpp>
+#include <com/sun/star/xml/crypto/XXMLEncryptionTemplate.hpp>
+#include <com/sun/star/xml/crypto/XXMLSecurityContext.hpp>
+#include <com/sun/star/xml/crypto/XMLEncryptionException.hpp>
+
+class XMLEncryptionGpg : public cppu::WeakImplHelper< css::xml::crypto::XXMLEncryption,
+ css::lang::XServiceInfo >
+{
+public:
+ explicit XMLEncryptionGpg();
+ virtual ~XMLEncryptionGpg() override;
+
+ // XXMLEncryption
+ virtual css::uno::Reference< css::xml::crypto::XXMLEncryptionTemplate > SAL_CALL encrypt(
+ const css::uno::Reference< css::xml::crypto::XXMLEncryptionTemplate >& aTemplate ,
+ const css::uno::Reference< css::xml::crypto::XSecurityEnvironment >& aEnvironment)
+ // ) throw( css::uno::Exception , css::uno::RuntimeException ) ;
+ throw (css::xml::crypto::XMLEncryptionException ,
+ css::uno::SecurityException,
+ css::uno::RuntimeException, std::exception) override;
+
+ virtual css::uno::Reference< css::xml::crypto::XXMLEncryptionTemplate > SAL_CALL decrypt(
+ const css::uno::Reference< css::xml::crypto::XXMLEncryptionTemplate >& aTemplate ,
+ const css::uno::Reference< css::xml::crypto::XXMLSecurityContext >& aContext
+ ) throw (css::xml::crypto::XMLEncryptionException ,
+ css::uno::SecurityException,
+ css::uno::RuntimeException, std::exception) override;
+
+ // XServiceInfo
+ virtual OUString SAL_CALL getImplementationName() throw( css::uno::RuntimeException, std::exception ) override;
+
+ virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName)
+ throw( css::uno::RuntimeException, std::exception ) override;
+
+ virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames()
+ throw( css::uno::RuntimeException, std::exception ) override;
+
+ // Helper for XServiceInfo
+ static css::uno::Sequence< OUString > impl_getSupportedServiceNames() ;
+
+ /// @throws css::uno::RuntimeException
+ static OUString impl_getImplementationName() throw( css::uno::RuntimeException ) ;
+
+ // Helper for registry
+ /// @throws css::uno::RuntimeException
+ static css::uno::Reference< css::uno::XInterface > SAL_CALL impl_createInstance(
+ const css::uno::Reference< css::lang::XMultiServiceFactory >& aServiceManager )
+ throw( css::uno::RuntimeException ) ;
+
+ static css::uno::Reference< css::lang::XSingleServiceFactory > impl_createFactory(
+ const css::uno::Reference< css::lang::XMultiServiceFactory >& aServiceManager ) ;
+} ;
+
+#endif // INCLUDED_XMLSECURITY_SOURCE_GPG_XMLENCRYPTION_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmlsecurity/source/gpg/XMLSecurityContext.cxx b/xmlsecurity/source/gpg/XMLSecurityContext.cxx
new file mode 100644
index 000000000000..8f9baf05af2b
--- /dev/null
+++ b/xmlsecurity/source/gpg/XMLSecurityContext.cxx
@@ -0,0 +1,122 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include "XMLSecurityContext.hxx"
+#include "SecurityEnvironment.hxx"
+
+#include <cppuhelper/supportsservice.hxx>
+
+using namespace css::uno;
+using namespace css::lang;
+using namespace css::xml::crypto;
+
+XMLSecurityContextGpg::XMLSecurityContextGpg()
+ : m_nDefaultEnvIndex(-1)
+{
+}
+
+XMLSecurityContextGpg::~XMLSecurityContextGpg()
+{
+}
+
+sal_Int32 SAL_CALL XMLSecurityContextGpg::addSecurityEnvironment(
+ const Reference< XSecurityEnvironment >& aSecurityEnvironment)
+ throw (css::security::SecurityInfrastructureException, RuntimeException, std::exception)
+{
+ if(!aSecurityEnvironment.is())
+ throw RuntimeException("Invalid SecurityEnvironment given!");
+
+ m_vSecurityEnvironments.push_back(aSecurityEnvironment);
+ return m_vSecurityEnvironments.size() - 1 ;
+}
+
+
+sal_Int32 SAL_CALL XMLSecurityContextGpg::getSecurityEnvironmentNumber()
+ throw (RuntimeException, std::exception)
+{
+ return m_vSecurityEnvironments.size();
+}
+
+Reference< XSecurityEnvironment > SAL_CALL XMLSecurityContextGpg::getSecurityEnvironmentByIndex(sal_Int32 index)
+ throw (RuntimeException, std::exception)
+{
+ if (index < 0 || index >= ( sal_Int32 )m_vSecurityEnvironments.size())
+ throw RuntimeException("Invalid index");
+
+ return m_vSecurityEnvironments[index];
+}
+
+Reference< XSecurityEnvironment > SAL_CALL XMLSecurityContextGpg::getSecurityEnvironment()
+ throw (RuntimeException, std::exception)
+{
+ if (m_nDefaultEnvIndex < 0 || m_nDefaultEnvIndex >= (sal_Int32) m_vSecurityEnvironments.size())
+ throw RuntimeException("Invalid index");
+
+ return getSecurityEnvironmentByIndex(m_nDefaultEnvIndex);
+}
+
+sal_Int32 SAL_CALL XMLSecurityContextGpg::getDefaultSecurityEnvironmentIndex()
+ throw (RuntimeException, std::exception)
+{
+ return m_nDefaultEnvIndex ;
+}
+
+void SAL_CALL XMLSecurityContextGpg::setDefaultSecurityEnvironmentIndex(sal_Int32 nDefaultEnvIndex)
+ throw (RuntimeException, std::exception)
+{
+ m_nDefaultEnvIndex = nDefaultEnvIndex;
+}
+
+/* XServiceInfo */
+OUString SAL_CALL XMLSecurityContextGpg::getImplementationName()
+ throw( RuntimeException, std::exception )
+{
+ return impl_getImplementationName() ;
+}
+
+/* XServiceInfo */
+sal_Bool SAL_CALL XMLSecurityContextGpg::supportsService( const OUString& serviceName)
+ throw( RuntimeException, std::exception )
+{
+ return cppu::supportsService(this, serviceName);
+}
+
+/* XServiceInfo */
+Sequence< OUString > SAL_CALL XMLSecurityContextGpg::getSupportedServiceNames()
+ throw( RuntimeException, std::exception )
+{
+ return impl_getSupportedServiceNames() ;
+}
+
+//Helper for XServiceInfo
+Sequence< OUString > XMLSecurityContextGpg::impl_getSupportedServiceNames()
+{
+ return {"com.sun.star.xml.crypto.gpg.GpgXMLSecurityContext"};
+}
+
+OUString XMLSecurityContextGpg::impl_getImplementationName()
+ throw( RuntimeException )
+{
+ return OUString("com.sun.star.xml.security.XMLSecurityContext_Gpg");
+}
+
+//Helper for registry
+Reference< XInterface > SAL_CALL XMLSecurityContextGpg::impl_createInstance( const Reference< XMultiServiceFactory >& )
+ throw( RuntimeException )
+{
+ return Reference< XInterface >( *new XMLSecurityContextGpg ) ;
+}
+
+Reference< XSingleServiceFactory > XMLSecurityContextGpg::impl_createFactory( const Reference< XMultiServiceFactory >& aServiceManager )
+{
+ return ::cppu::createSingleFactory( aServiceManager , impl_getImplementationName() , impl_createInstance , impl_getSupportedServiceNames() ) ;
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmlsecurity/source/gpg/XMLSecurityContext.hxx b/xmlsecurity/source/gpg/XMLSecurityContext.hxx
new file mode 100644
index 000000000000..9d761d635865
--- /dev/null
+++ b/xmlsecurity/source/gpg/XMLSecurityContext.hxx
@@ -0,0 +1,88 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef INCLUDED_XMLSECURITY_SOURCE_GPG_XMLSECURITYCONTEXT_HXX
+#define INCLUDED_XMLSECURITY_SOURCE_GPG_XMLSECURITYCONTEXT_HXX
+
+#include <sal/config.h>
+#include <rtl/ustring.hxx>
+#include <cppuhelper/factory.hxx>
+#include <cppuhelper/implbase.hxx>
+#include <com/sun/star/uno/Exception.hpp>
+
+#include <com/sun/star/uno/Reference.hxx>
+#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/lang/XUnoTunnel.hpp>
+#include <com/sun/star/xml/crypto/XSecurityEnvironment.hpp>
+#include <com/sun/star/security/SecurityInfrastructureException.hpp>
+#include <com/sun/star/xml/crypto/XXMLSecurityContext.hpp>
+
+#include <vector>
+
+class XMLSecurityContextGpg : public cppu::WeakImplHelper< css::xml::crypto::XXMLSecurityContext,
+ css::lang::XServiceInfo >
+{
+private:
+ std::vector< css::uno::Reference< css::xml::crypto::XSecurityEnvironment > > m_vSecurityEnvironments;
+
+ sal_Int32 m_nDefaultEnvIndex;
+
+public:
+ XMLSecurityContextGpg() ;
+ virtual ~XMLSecurityContextGpg() override;
+
+ // XXMLSecurityContext
+ virtual sal_Int32 SAL_CALL addSecurityEnvironment(
+ const css::uno::Reference< css::xml::crypto::XSecurityEnvironment >& aSecurityEnvironment
+ ) throw (css::security::SecurityInfrastructureException, css::uno::RuntimeException, std::exception) override;
+
+ virtual ::sal_Int32 SAL_CALL getSecurityEnvironmentNumber( )
+ throw (css::uno::RuntimeException, std::exception) override;
+
+ virtual css::uno::Reference<css::xml::crypto::XSecurityEnvironment > SAL_CALL getSecurityEnvironmentByIndex(sal_Int32 index)
+ throw (css::uno::RuntimeException, std::exception) override;
+
+ virtual css::uno::Reference<css::xml::crypto::XSecurityEnvironment > SAL_CALL getSecurityEnvironment()
+ throw (css::uno::RuntimeException, std::exception) override;
+
+ virtual sal_Int32 SAL_CALL getDefaultSecurityEnvironmentIndex( )
+ throw (css::uno::RuntimeException, std::exception) override;
+
+ virtual void SAL_CALL setDefaultSecurityEnvironmentIndex( sal_Int32 nDefaultEnvIndex )
+ throw (css::uno::RuntimeException, std::exception) override;
+
+ // XServiceInfo
+ virtual OUString SAL_CALL getImplementationName() throw( css::uno::RuntimeException, std::exception ) override;
+
+ virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName)
+ throw( css::uno::RuntimeException, std::exception ) override;
+
+ virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames()
+ throw( css::uno::RuntimeException, std::exception ) override;
+
+ // XServiceInfo
+ static css::uno::Sequence< OUString > impl_getSupportedServiceNames() ;
+
+ /// @throws css::uno::RuntimeException
+ static OUString impl_getImplementationName() throw( css::uno::RuntimeException ) ;
+
+ //Helper for registry
+ /// @throws css::uno::RuntimeException
+ static css::uno::Reference< css::uno::XInterface > SAL_CALL impl_createInstance(
+ const css::uno::Reference< css::lang::XMultiServiceFactory >& aServiceManager )
+ throw( css::uno::RuntimeException ) ;
+
+ static css::uno::Reference< css::lang::XSingleServiceFactory > impl_createFactory(
+ const css::uno::Reference< css::lang::XMultiServiceFactory >& aServiceManager ) ;
+} ;
+
+#endif // INCLUDED_XMLSECURITY_SOURCE_GPG_XMLSECURITYCONTEXT_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmlsecurity/source/gpg/XMLSignature.cxx b/xmlsecurity/source/gpg/XMLSignature.cxx
new file mode 100644
index 000000000000..abc955de2bf7
--- /dev/null
+++ b/xmlsecurity/source/gpg/XMLSignature.cxx
@@ -0,0 +1,89 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include "XMLSignature.hxx"
+#include "SecurityEnvironment.hxx"
+#include "XMLSecurityContext.hxx"
+
+#include <cppuhelper/supportsservice.hxx>
+
+using namespace css::uno;
+using namespace css::lang;
+using namespace css::xml::wrapper;
+using namespace css::xml::crypto;
+
+XMLSignatureGpg::XMLSignatureGpg()
+{
+}
+
+XMLSignatureGpg::~XMLSignatureGpg()
+{
+}
+
+/* XXMLSignature */
+Reference< XXMLSignatureTemplate > SAL_CALL XMLSignatureGpg::generate(const Reference< XXMLSignatureTemplate >& /*aTemplate*/,
+ const Reference< XSecurityEnvironment >& /*aEnvironment*/)
+ throw( css::xml::crypto::XMLSignatureException, css::uno::SecurityException, css::uno::RuntimeException, std::exception )
+{
+ return nullptr;
+}
+
+/* XXMLSignature */
+Reference< XXMLSignatureTemplate > SAL_CALL XMLSignatureGpg::validate(const Reference< XXMLSignatureTemplate >& /*aTemplate*/,
+ const Reference< XXMLSecurityContext >& /*aSecurityCtx*/)
+ throw(css::uno::RuntimeException, css::uno::SecurityException, css::xml::crypto::XMLSignatureException, std::exception)
+{
+ return nullptr;
+}
+
+/* XServiceInfo */
+OUString SAL_CALL XMLSignatureGpg::getImplementationName()
+ throw( RuntimeException, std::exception )
+{
+ return impl_getImplementationName() ;
+}
+
+/* XServiceInfo */
+sal_Bool SAL_CALL XMLSignatureGpg::supportsService( const OUString& serviceName)
+ throw( RuntimeException, std::exception )
+{
+ return cppu::supportsService(this, serviceName);
+}
+
+/* XServiceInfo */
+Sequence< OUString > SAL_CALL XMLSignatureGpg::getSupportedServiceNames() throw( RuntimeException, std::exception )
+{
+ return impl_getSupportedServiceNames() ;
+}
+
+//Helper for XServiceInfo
+Sequence< OUString > XMLSignatureGpg::impl_getSupportedServiceNames()
+{
+ return {"com.sun.star.xml.crypto.gpg.GpgXMLSignature"};
+}
+
+OUString XMLSignatureGpg::impl_getImplementationName()
+ throw( RuntimeException )
+{
+ return OUString("com.sun.star.xml.security.XMLSignature_Gpg");
+}
+
+//Helper for registry
+Reference< XInterface > SAL_CALL XMLSignatureGpg::impl_createInstance( const Reference< XMultiServiceFactory >& )
+ throw( RuntimeException )
+{
+ return Reference< XInterface >( *new XMLSignatureGpg ) ;
+}
+
+Reference< XSingleServiceFactory > XMLSignatureGpg::impl_createFactory( const Reference< XMultiServiceFactory >& aServiceManager )
+{
+ return cppu::createSingleFactory( aServiceManager , impl_getImplementationName() , impl_createInstance , impl_getSupportedServiceNames() ) ;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmlsecurity/source/gpg/XMLSignature.hxx b/xmlsecurity/source/gpg/XMLSignature.hxx
new file mode 100644
index 000000000000..119b5cbfa83c
--- /dev/null
+++ b/xmlsecurity/source/gpg/XMLSignature.hxx
@@ -0,0 +1,77 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef INCLUDED_XMLSECURITY_SOURCE_XMLSEC_GPG_XMLSIGNATURE_HXX
+#define INCLUDED_XMLSECURITY_SOURCE_XMLSEC_GPG_XMLSIGNATURE_HXX
+
+#include <sal/config.h>
+#include <rtl/ustring.hxx>
+#include <cppuhelper/factory.hxx>
+#include <cppuhelper/implbase.hxx>
+#include <com/sun/star/uno/Exception.hpp>
+
+#include <com/sun/star/uno/Reference.hxx>
+#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/xml/crypto/XXMLSignature.hpp>
+#include <com/sun/star/xml/crypto/XXMLSignatureTemplate.hpp>
+#include <com/sun/star/xml/crypto/XXMLSecurityContext.hpp>
+#include <com/sun/star/xml/crypto/XMLSignatureException.hpp>
+
+class XMLSignatureGpg : public cppu::WeakImplHelper< css::xml::crypto::XXMLSignature,
+ css::lang::XServiceInfo >
+{
+public:
+ explicit XMLSignatureGpg();
+ virtual ~XMLSignatureGpg() override;
+
+ // XXMLSignature
+ virtual css::uno::Reference< css::xml::crypto::XXMLSignatureTemplate > SAL_CALL generate(
+ const css::uno::Reference< css::xml::crypto::XXMLSignatureTemplate >& aTemplate ,
+ const css::uno::Reference< css::xml::crypto::XSecurityEnvironment >& aEnvironment
+ ) throw (css::xml::crypto::XMLSignatureException,
+ css::uno::SecurityException,
+ css::uno::RuntimeException, std::exception) override;
+
+ virtual css::uno::Reference< css::xml::crypto::XXMLSignatureTemplate > SAL_CALL validate(
+ const css::uno::Reference< css::xml::crypto::XXMLSignatureTemplate >& aTemplate ,
+ const css::uno::Reference< css::xml::crypto::XXMLSecurityContext >& aContext
+ ) throw(css::uno::RuntimeException,
+ css::uno::SecurityException,
+ css::xml::crypto::XMLSignatureException, std::exception) override;
+
+ // XServiceInfo
+ virtual OUString SAL_CALL getImplementationName()
+ throw( css::uno::RuntimeException, std::exception ) override;
+
+ virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName)
+ throw( css::uno::RuntimeException, std::exception ) override;
+
+ virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames()
+ throw( css::uno::RuntimeException, std::exception ) override;
+
+ // Helper for XServiceInfo
+ static css::uno::Sequence< OUString > impl_getSupportedServiceNames() ;
+
+ /// @throws css::uno::RuntimeException
+ static OUString impl_getImplementationName() throw( css::uno::RuntimeException ) ;
+
+ //Helper for registry
+ /// @throws css::uno::RuntimeException
+ static css::uno::Reference< css::uno::XInterface > SAL_CALL impl_createInstance(
+ const css::uno::Reference< css::lang::XMultiServiceFactory >& aServiceManager )
+ throw( css::uno::RuntimeException ) ;
+
+ static css::uno::Reference< css::lang::XSingleServiceFactory > impl_createFactory(
+ const css::uno::Reference< css::lang::XMultiServiceFactory >& aServiceManager ) ;
+} ;
+
+#endif // INCLUDED_XMLSECURITY_SOURCE_XMLSEC_GPG_XMLSIGNATURE_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmlsecurity/source/helper/documentsignaturemanager.cxx b/xmlsecurity/source/helper/documentsignaturemanager.cxx
index d97b1d11e0e6..e0a61e2ba377 100644
--- a/xmlsecurity/source/helper/documentsignaturemanager.cxx
+++ b/xmlsecurity/source/helper/documentsignaturemanager.cxx
@@ -25,6 +25,7 @@
#include <com/sun/star/io/XTruncate.hpp>
#include <com/sun/star/embed/XTransactedObject.hpp>
#include <com/sun/star/xml/crypto/SEInitializer.hpp>
+#include <com/sun/star/xml/crypto/gpg/GpgSEInitializer.hpp>
#include <comphelper/storagehelper.hxx>
#include <rtl/ustrbuf.hxx>
@@ -36,7 +37,7 @@
#include <certificate.hxx>
#include <biginteger.hxx>
-using namespace com::sun::star;
+using namespace css;
DocumentSignatureManager::DocumentSignatureManager(const uno::Reference<uno::XComponentContext>& xContext, DocumentSignatureMode eMode)
: mxContext(xContext),
@@ -51,13 +52,24 @@ bool DocumentSignatureManager::init()
{
SAL_WARN_IF(mxSEInitializer.is(), "xmlsecurity.helper", "DocumentSignatureManager::Init - mxSEInitializer already set!");
SAL_WARN_IF(mxSecurityContext.is(), "xmlsecurity.helper", "DocumentSignatureManager::Init - mxSecurityContext already set!");
+ SAL_WARN_IF(mxGpgSEInitializer.is(), "xmlsecurity.helper", "DocumentSignatureManager::Init - mxGpgSEInitializer already set!");
- mxSEInitializer = css::xml::crypto::SEInitializer::create(mxContext);
+ mxSEInitializer = xml::crypto::SEInitializer::create(mxContext);
+#if !defined(MACOSX) && !defined(WNT)
+ mxGpgSEInitializer = xml::crypto::gpg::GpgSEInitializer::create(mxContext);
+#endif
if (mxSEInitializer.is())
mxSecurityContext = mxSEInitializer->createSecurityContext(OUString());
+#if !defined(MACOSX) && !defined(WNT)
+ if (mxGpgSEInitializer.is())
+ mxGpgSecurityContext = mxGpgSEInitializer->createSecurityContext(OUString());
+
+ return mxSecurityContext.is() && mxGpgSecurityContext.is();
+#else
return mxSecurityContext.is();
+#endif
}
PDFSignatureHelper& DocumentSignatureManager::getPDFSignatureHelper()
@@ -504,4 +516,9 @@ uno::Reference<xml::crypto::XSecurityEnvironment> DocumentSignatureManager::getS
return mxSecurityContext.is() ? mxSecurityContext->getSecurityEnvironment() : uno::Reference<xml::crypto::XSecurityEnvironment>();
}
+uno::Reference<xml::crypto::XSecurityEnvironment> DocumentSignatureManager::getGpgSecurityEnvironment()
+{
+ return mxGpgSecurityContext.is() ? mxGpgSecurityContext->getSecurityEnvironment() : uno::Reference<xml::crypto::XSecurityEnvironment>();
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmlsecurity/util/xsec_gpg.component b/xmlsecurity/util/xsec_gpg.component
new file mode 100644
index 000000000000..0a684d164666
--- /dev/null
+++ b/xmlsecurity/util/xsec_gpg.component
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+-->
+
+<component loader="com.sun.star.loader.SharedLibrary" environment="@CPPU_ENV@"
+ prefix="xsec_gpg" xmlns="http://openoffice.org/2010/uno-components">
+ <implementation name="com.sun.star.xml.security.SEInitializer_Gpg">
+ <service name="com.sun.star.xml.crypto.gpg.GpgSEInitializer"/>
+ </implementation>
+ <implementation name="com.sun.star.xml.security.SecurityEnvironment_Gpg">
+ <service name="com.sun.star.xml.crypto.gpg.GpgSecurityEnvironment"/>
+ </implementation>
+ <!-- TODO Not implemented yet
+ <implementation name="com.sun.star.xml.security.XMLDocumentWrapper_Gpg">
+ <service name="com.sun.star.xml.wrapper.XMLDocumentWrapper"/>
+ </implementation>
+ <implementation name="com.sun.star.xml.security.XMLElementWrapper_Gpg">
+ <service name="com.sun.star.xml.wrapper.XMLElementWrapper"/>
+ </implementation>-->
+ <implementation name="com.sun.star.xml.security.XMLEncryption_Gpg">
+ <service name="com.sun.star.xml.crypto.gpg.GpgXMLEncryption"/>
+ </implementation>
+ <implementation name="com.sun.star.xml.security.XMLSecurityContext_Gpg">
+ <service name="com.sun.star.xml.crypto.gpg.GpgXMLSecurityContext"/>
+ </implementation>
+ <implementation name="com.sun.star.xml.security.XMLSignature_Gpg">
+ <service name="com.sun.star.xml.crypto.gpg.GpgXMLSignature"/>
+ </implementation>-->
+</component>
+