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 <cppuhelper/supportsservice.hxx>
11 #include <gpg/SEInitializer.hxx>
12 #include "SecurityEnvironment.hxx"
13 #include "XMLSecurityContext.hxx"
17 namespace com::sun::star::uno
{ class XComponentContext
; }
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()
35 Reference
< XXMLSecurityContext
> SAL_CALL
SEInitializerGpg::createSecurityContext( const OUString
& )
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
);
48 catch( const uno::Exception
& )
54 void SAL_CALL
SEInitializerGpg::freeSecurityContext( const uno::Reference
< XXMLSecurityContext
>& )
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: */