Bump version to 6.0-36
[LibreOffice.git] / xmlsecurity / source / gpg / XMLSecurityContext.cxx
blob1a07648d1622b3966742e8ce6bf73fcb9f98217a
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 "XMLSecurityContext.hxx"
11 #include "SecurityEnvironment.hxx"
13 #include <cppuhelper/supportsservice.hxx>
15 #include <xmlsec/xmlstreamio.hxx>
16 #include <xmlsec-wrapper.h>
18 using namespace css::uno;
19 using namespace css::lang;
20 using namespace css::xml::crypto;
22 XMLSecurityContextGpg::XMLSecurityContextGpg()
23 : m_nDefaultEnvIndex(-1)
27 XMLSecurityContextGpg::~XMLSecurityContextGpg()
31 sal_Int32 SAL_CALL XMLSecurityContextGpg::addSecurityEnvironment(
32 const Reference< XSecurityEnvironment >& aSecurityEnvironment)
34 if(!aSecurityEnvironment.is())
35 throw RuntimeException("Invalid SecurityEnvironment given!");
37 m_vSecurityEnvironments.push_back(aSecurityEnvironment);
38 return m_vSecurityEnvironments.size() - 1 ;
42 sal_Int32 SAL_CALL XMLSecurityContextGpg::getSecurityEnvironmentNumber()
44 return m_vSecurityEnvironments.size();
47 Reference< XSecurityEnvironment > SAL_CALL XMLSecurityContextGpg::getSecurityEnvironmentByIndex(sal_Int32 index)
49 if (index < 0 || index >= ( sal_Int32 )m_vSecurityEnvironments.size())
50 throw RuntimeException("Invalid index");
52 return m_vSecurityEnvironments[index];
55 Reference< XSecurityEnvironment > SAL_CALL XMLSecurityContextGpg::getSecurityEnvironment()
57 if (m_nDefaultEnvIndex < 0 || m_nDefaultEnvIndex >= (sal_Int32) m_vSecurityEnvironments.size())
58 throw RuntimeException("Invalid index");
60 return getSecurityEnvironmentByIndex(m_nDefaultEnvIndex);
63 sal_Int32 SAL_CALL XMLSecurityContextGpg::getDefaultSecurityEnvironmentIndex()
65 return m_nDefaultEnvIndex ;
68 void SAL_CALL XMLSecurityContextGpg::setDefaultSecurityEnvironmentIndex(sal_Int32 nDefaultEnvIndex)
70 m_nDefaultEnvIndex = nDefaultEnvIndex;
73 /* XServiceInfo */
74 OUString SAL_CALL XMLSecurityContextGpg::getImplementationName() {
75 return OUString("com.sun.star.xml.security.gpg.XMLSecurityContext_GpgImpl");
78 /* XServiceInfo */
79 sal_Bool SAL_CALL XMLSecurityContextGpg::supportsService( const OUString& serviceName) {
80 return cppu::supportsService(this, serviceName);
83 /* XServiceInfo */
84 Sequence< OUString > SAL_CALL XMLSecurityContextGpg::getSupportedServiceNames() {
85 return { OUString("com.sun.star.xml.crypto.XMLSecurityContext") };
88 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */