Version 6.4.0.0.beta1, tag libreoffice-6.4.0.0.beta1
[LibreOffice.git] / xmlsecurity / source / gpg / SEInitializer.cxx
blobcb502e8c97934892270134a07aac5ac4888b7c56
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
10 #include <cppuhelper/supportsservice.hxx>
11 #include <gpg/SEInitializer.hxx>
12 #include "SecurityEnvironment.hxx"
13 #include "XMLSecurityContext.hxx"
15 #include <global.h>
17 namespace com::sun::star::uno { class XComponentContext; }
19 using namespace css;
20 using namespace css::lang;
21 using namespace css::uno;
22 using namespace css::xml::crypto;
24 SEInitializerGpg::SEInitializerGpg()
26 // Also init GpgME while we're at it
27 GpgME::initializeLibrary();
30 SEInitializerGpg::~SEInitializerGpg()
34 /* XSEInitializer */
35 Reference< XXMLSecurityContext > SAL_CALL SEInitializerGpg::createSecurityContext( const OUString& )
37 try
39 /* Build XML Security Context */
40 Reference< XXMLSecurityContext > xSecCtx(new XMLSecurityContextGpg());
42 Reference< XSecurityEnvironment > xSecEnv(new SecurityEnvironmentGpg());
43 sal_Int32 n = xSecCtx->addSecurityEnvironment(xSecEnv);
44 //originally the SecurityEnvironment with the internal slot was set as default
45 xSecCtx->setDefaultSecurityEnvironmentIndex( n );
46 return xSecCtx;
48 catch( const uno::Exception& )
50 return nullptr;
54 void SAL_CALL SEInitializerGpg::freeSecurityContext( const uno::Reference< XXMLSecurityContext >& )
58 /* XServiceInfo */
59 sal_Bool SAL_CALL SEInitializerGpg::supportsService( const OUString& rServiceName )
61 return cppu::supportsService(this, rServiceName);
64 uno::Sequence< OUString > SAL_CALL SEInitializerGpg::getSupportedServiceNames()
66 return {"com.sun.star.xml.crypto.GPGSEInitializer"};
69 OUString SAL_CALL SEInitializerGpg::getImplementationName()
71 return "com.sun.star.xml.security.SEInitializer_Gpg";
74 extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface*
75 com_sun_star_xml_security_SEInitializer_Gpg_get_implementation(
76 uno::XComponentContext* /*pCtx*/, uno::Sequence<uno::Any> const& /*rSeq*/)
78 return cppu::acquire(new SEInitializerGpg());
81 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */