Bump version to 6.0-36
[LibreOffice.git] / xmlsecurity / source / gpg / SEInitializer.cxx
blobc1c9d450183a74f8f7e5d046fe9269aab4558342
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 <config_gpgme.h>
12 #include <comphelper/processfactory.hxx>
13 #include <cppuhelper/supportsservice.hxx>
14 #include <gpg/SEInitializer.hxx>
15 #include "SecurityEnvironment.hxx"
16 #include "XMLSecurityContext.hxx"
18 #include <gpgme.h>
19 #include <context.h>
21 using namespace css;
22 using namespace css::lang;
23 using namespace css::uno;
24 using namespace css::xml::crypto;
27 SEInitializerGpg::SEInitializerGpg()
29 // Also init GpgME while we're at it
30 GpgME::initializeLibrary();
33 SEInitializerGpg::~SEInitializerGpg()
37 /* XSEInitializer */
38 Reference< XXMLSecurityContext > SAL_CALL SEInitializerGpg::createSecurityContext( const OUString& )
40 try
42 /* Build XML Security Context */
43 Reference< XXMLSecurityContext > xSecCtx(new XMLSecurityContextGpg());
45 Reference< XSecurityEnvironment > xSecEnv(new SecurityEnvironmentGpg());
46 sal_Int32 n = xSecCtx->addSecurityEnvironment(xSecEnv);
47 //originally the SecurityEnvironment with the internal slot was set as default
48 xSecCtx->setDefaultSecurityEnvironmentIndex( n );
49 return xSecCtx;
51 catch( const uno::Exception& )
53 return nullptr;
57 void SAL_CALL SEInitializerGpg::freeSecurityContext( const uno::Reference< XXMLSecurityContext >& )
63 uno::Reference< uno::XInterface > SAL_CALL SEInitializerGpg::impl_createInstance( const uno::Reference< lang::XMultiServiceFactory > & /*rxMSF*/)
65 return static_cast<cppu::OWeakObject*>(new SEInitializerGpg());
68 uno::Reference< XSingleServiceFactory > SEInitializerGpg::impl_createFactory( const Reference< XMultiServiceFactory >& aServiceManager ) {
69 return cppu::createSingleFactory( aServiceManager, impl_getImplementationName(), impl_createInstance, impl_getSupportedServiceNames() ) ;
72 /* XServiceInfo */
73 OUString SEInitializerGpg::impl_getImplementationName()
75 return OUString("com.sun.star.xml.security.SEInitializer_Gpg");
78 uno::Sequence< OUString > SEInitializerGpg::impl_getSupportedServiceNames()
80 return {"com.sun.star.xml.crypto.GPGSEInitializer"};
83 sal_Bool SAL_CALL SEInitializerGpg::supportsService( const OUString& rServiceName )
85 return cppu::supportsService(this, rServiceName);
88 uno::Sequence< OUString > SAL_CALL SEInitializerGpg::getSupportedServiceNames()
90 return impl_getSupportedServiceNames();
93 OUString SAL_CALL SEInitializerGpg::getImplementationName()
95 return impl_getImplementationName();
98 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */