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>
14 using namespace css::uno
;
15 using namespace css::lang
;
16 using namespace css::xml::crypto
;
18 XMLSecurityContextGpg::XMLSecurityContextGpg()
19 : m_nDefaultEnvIndex(-1)
23 XMLSecurityContextGpg::~XMLSecurityContextGpg()
27 sal_Int32 SAL_CALL
XMLSecurityContextGpg::addSecurityEnvironment(
28 const Reference
< XSecurityEnvironment
>& aSecurityEnvironment
)
30 if(!aSecurityEnvironment
.is())
31 throw RuntimeException("Invalid SecurityEnvironment given!");
33 m_vSecurityEnvironments
.push_back(aSecurityEnvironment
);
34 return m_vSecurityEnvironments
.size() - 1 ;
38 sal_Int32 SAL_CALL
XMLSecurityContextGpg::getSecurityEnvironmentNumber()
40 return m_vSecurityEnvironments
.size();
43 Reference
< XSecurityEnvironment
> SAL_CALL
XMLSecurityContextGpg::getSecurityEnvironmentByIndex(sal_Int32 index
)
45 if (index
< 0 || index
>= static_cast<sal_Int32
>(m_vSecurityEnvironments
.size()))
46 throw RuntimeException("Invalid index");
48 return m_vSecurityEnvironments
[index
];
51 Reference
< XSecurityEnvironment
> SAL_CALL
XMLSecurityContextGpg::getSecurityEnvironment()
53 if (m_nDefaultEnvIndex
< 0 || m_nDefaultEnvIndex
>= static_cast<sal_Int32
>(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() {
71 return "com.sun.star.xml.security.gpg.XMLSecurityContext_GpgImpl";
75 sal_Bool SAL_CALL
XMLSecurityContextGpg::supportsService( const OUString
& serviceName
) {
76 return cppu::supportsService(this, serviceName
);
80 Sequence
< OUString
> SAL_CALL
XMLSecurityContextGpg::getSupportedServiceNames() {
81 return { OUString("com.sun.star.xml.crypto.XMLSecurityContext") };
84 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */