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 "XMLSecurityContext.hxx"
12 #include <cppuhelper/supportsservice.hxx>
13 #include <o3tl/safeint.hxx>
15 using namespace css::uno
;
16 using namespace css::lang
;
17 using namespace css::xml::crypto
;
19 XMLSecurityContextGpg::XMLSecurityContextGpg()
20 : m_nDefaultEnvIndex(-1)
24 XMLSecurityContextGpg::~XMLSecurityContextGpg() {}
26 sal_Int32 SAL_CALL
XMLSecurityContextGpg::addSecurityEnvironment(
27 const Reference
<XSecurityEnvironment
>& aSecurityEnvironment
)
29 if (!aSecurityEnvironment
.is())
30 throw RuntimeException("Invalid SecurityEnvironment given!");
32 m_vSecurityEnvironments
.push_back(aSecurityEnvironment
);
33 return m_vSecurityEnvironments
.size() - 1;
36 sal_Int32 SAL_CALL
XMLSecurityContextGpg::getSecurityEnvironmentNumber()
38 return m_vSecurityEnvironments
.size();
41 Reference
<XSecurityEnvironment
>
42 SAL_CALL
XMLSecurityContextGpg::getSecurityEnvironmentByIndex(sal_Int32 index
)
44 if (index
< 0 || o3tl::make_unsigned(index
) >= m_vSecurityEnvironments
.size())
45 throw RuntimeException("Invalid index");
47 return m_vSecurityEnvironments
[index
];
50 Reference
<XSecurityEnvironment
> SAL_CALL
XMLSecurityContextGpg::getSecurityEnvironment()
52 if (m_nDefaultEnvIndex
< 0
53 || o3tl::make_unsigned(m_nDefaultEnvIndex
) >= m_vSecurityEnvironments
.size())
54 throw RuntimeException("Invalid index");
56 return getSecurityEnvironmentByIndex(m_nDefaultEnvIndex
);
59 sal_Int32 SAL_CALL
XMLSecurityContextGpg::getDefaultSecurityEnvironmentIndex()
61 return m_nDefaultEnvIndex
;
64 void SAL_CALL
XMLSecurityContextGpg::setDefaultSecurityEnvironmentIndex(sal_Int32 nDefaultEnvIndex
)
66 m_nDefaultEnvIndex
= nDefaultEnvIndex
;
70 OUString SAL_CALL
XMLSecurityContextGpg::getImplementationName()
72 return "com.sun.star.xml.security.gpg.XMLSecurityContext_GpgImpl";
76 sal_Bool SAL_CALL
XMLSecurityContextGpg::supportsService(const OUString
& serviceName
)
78 return cppu::supportsService(this, serviceName
);
82 Sequence
<OUString
> SAL_CALL
XMLSecurityContextGpg::getSupportedServiceNames()
84 return { OUString("com.sun.star.xml.crypto.XMLSecurityContext") };
87 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */