blob: 2566a40accfbd7ccecfb94ed649d398b3585dc39 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <sal/config.h>
#include <vector>
#include <cppuhelper/implbase.hxx>
#include <cppuhelper/supportsservice.hxx>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/xml/crypto/XXMLSecurityContext.hpp>
namespace com::sun::star::uno { class XComponentContext; }
using namespace ::com::sun::star;
using namespace ::com::sun::star::lang ;
using ::com::sun::star::xml::crypto::XSecurityEnvironment ;
using ::com::sun::star::xml::crypto::XXMLSecurityContext ;
namespace {
class XMLSecurityContext_NssImpl
: public ::cppu::WeakImplHelper<xml::crypto::XXMLSecurityContext, lang::XServiceInfo>
{
private:
std::vector<uno::Reference<xml::crypto::XSecurityEnvironment>> m_vSecurityEnvironments;
sal_Int32 m_nDefaultEnvIndex;
public:
XMLSecurityContext_NssImpl();
//XXMLSecurityContext
virtual sal_Int32 SAL_CALL addSecurityEnvironment(
const uno::Reference<xml::crypto::XSecurityEnvironment>& aSecurityEnvironment) override;
virtual ::sal_Int32 SAL_CALL getSecurityEnvironmentNumber() override;
virtual uno::Reference<xml::crypto::XSecurityEnvironment>
SAL_CALL getSecurityEnvironmentByIndex(::sal_Int32 index) override;
virtual uno::Reference<xml::crypto::XSecurityEnvironment>
SAL_CALL getSecurityEnvironment() override;
virtual ::sal_Int32 SAL_CALL getDefaultSecurityEnvironmentIndex() override;
virtual void SAL_CALL setDefaultSecurityEnvironmentIndex(sal_Int32 nDefaultEnvIndex) override;
//XServiceInfo
virtual OUString SAL_CALL getImplementationName() override;
virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override;
virtual uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override;
};
}
XMLSecurityContext_NssImpl::XMLSecurityContext_NssImpl()
: m_nDefaultEnvIndex(-1)
{
}
sal_Int32 SAL_CALL XMLSecurityContext_NssImpl::addSecurityEnvironment(
const uno::Reference< xml::crypto::XSecurityEnvironment >& aSecurityEnvironment)
{
if( !aSecurityEnvironment.is() )
{
throw uno::RuntimeException() ;
}
m_vSecurityEnvironments.push_back( aSecurityEnvironment );
return m_vSecurityEnvironments.size() - 1 ;
}
sal_Int32 SAL_CALL XMLSecurityContext_NssImpl::getSecurityEnvironmentNumber( )
{
return m_vSecurityEnvironments.size();
}
uno::Reference< xml::crypto::XSecurityEnvironment > SAL_CALL
XMLSecurityContext_NssImpl::getSecurityEnvironmentByIndex( sal_Int32 index )
{
if (index < 0 || index >= static_cast<sal_Int32>(m_vSecurityEnvironments.size()))
throw uno::RuntimeException();
uno::Reference< xml::crypto::XSecurityEnvironment > xSecurityEnvironment = m_vSecurityEnvironments[index];
return xSecurityEnvironment;
}
uno::Reference< xml::crypto::XSecurityEnvironment > SAL_CALL
XMLSecurityContext_NssImpl::getSecurityEnvironment( )
{
if (m_nDefaultEnvIndex < 0 || m_nDefaultEnvIndex >= static_cast<sal_Int32>(m_vSecurityEnvironments.size()))
throw uno::RuntimeException();
return getSecurityEnvironmentByIndex(m_nDefaultEnvIndex);
}
sal_Int32 SAL_CALL XMLSecurityContext_NssImpl::getDefaultSecurityEnvironmentIndex( )
{
return m_nDefaultEnvIndex ;
}
void SAL_CALL XMLSecurityContext_NssImpl::setDefaultSecurityEnvironmentIndex( sal_Int32 nDefaultEnvIndex )
{
m_nDefaultEnvIndex = nDefaultEnvIndex;
}
/* XServiceInfo */
OUString SAL_CALL XMLSecurityContext_NssImpl::getImplementationName() {
return "com.sun.star.xml.crypto.XMLSecurityContext";
}
/* XServiceInfo */
sal_Bool SAL_CALL XMLSecurityContext_NssImpl::supportsService( const OUString& serviceName) {
return cppu::supportsService(this, serviceName);
}
/* XServiceInfo */
uno::Sequence< OUString > SAL_CALL XMLSecurityContext_NssImpl::getSupportedServiceNames() {
uno::Sequence<OUString> seqServiceNames { "com.sun.star.xml.crypto.XMLSecurityContext" };
return seqServiceNames ;
}
extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface*
com_sun_star_xml_crypto_XMLSecurityContext_get_implementation(
uno::XComponentContext* /*pCtx*/, uno::Sequence<uno::Any> const& /*rSeq*/)
{
return cppu::acquire(new XMLSecurityContext_NssImpl);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|