1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/.
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"
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()
38 Reference
< XXMLSecurityContext
> SAL_CALL
SEInitializerGpg::createSecurityContext( const OUString
& )
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
);
51 catch( const uno::Exception
& )
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() ) ;
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: */