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/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <sal/config.h>
22 #include <com/sun/star/xml/crypto/XXMLSecurityContext.hpp>
23 #include "securityenvironment_mscryptimpl.hxx"
25 #include <xmlsec/xmlstreamio.hxx>
29 #include <cppuhelper/supportsservice.hxx>
31 using namespace ::com::sun::star
;
32 using namespace ::com::sun::star::lang
;
34 using ::com::sun::star::xml::crypto::XSecurityEnvironment
;
35 using ::com::sun::star::xml::crypto::XXMLSecurityContext
;
39 class XMLSecurityContext_MSCryptImpl
: public ::cppu::WeakImplHelper
<
40 css::xml::crypto::XXMLSecurityContext
,
41 css::lang::XServiceInfo
>
44 //xmlSecKeysMngrPtr m_pKeysMngr ;
45 css::uno::Reference
< css::xml::crypto::XSecurityEnvironment
> m_xSecurityEnvironment
;
48 XMLSecurityContext_MSCryptImpl();
50 //Methods from XXMLSecurityContext
51 virtual sal_Int32 SAL_CALL
addSecurityEnvironment(
52 const css::uno::Reference
< css::xml::crypto::XSecurityEnvironment
>& aSecurityEnvironment
55 virtual ::sal_Int32 SAL_CALL
getSecurityEnvironmentNumber( ) override
;
57 virtual css::uno::Reference
<
58 css::xml::crypto::XSecurityEnvironment
> SAL_CALL
59 getSecurityEnvironmentByIndex( ::sal_Int32 index
) override
;
61 virtual css::uno::Reference
<
62 css::xml::crypto::XSecurityEnvironment
> SAL_CALL
63 getSecurityEnvironment( ) override
;
65 virtual ::sal_Int32 SAL_CALL
getDefaultSecurityEnvironmentIndex( ) override
;
67 virtual void SAL_CALL
setDefaultSecurityEnvironmentIndex( sal_Int32 nDefaultEnvIndex
) override
;
70 //Methods from XServiceInfo
71 virtual OUString SAL_CALL
getImplementationName() override
;
73 virtual sal_Bool SAL_CALL
supportsService(
74 const OUString
& ServiceName
77 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() override
;
82 XMLSecurityContext_MSCryptImpl::XMLSecurityContext_MSCryptImpl()
86 sal_Int32 SAL_CALL
XMLSecurityContext_MSCryptImpl::addSecurityEnvironment(
87 const css::uno::Reference
< css::xml::crypto::XSecurityEnvironment
>& aSecurityEnvironment
)
89 if( !aSecurityEnvironment
.is() )
91 throw uno::RuntimeException() ;
94 m_xSecurityEnvironment
= aSecurityEnvironment
;
100 sal_Int32 SAL_CALL
XMLSecurityContext_MSCryptImpl::getSecurityEnvironmentNumber( )
105 css::uno::Reference
< css::xml::crypto::XSecurityEnvironment
> SAL_CALL
106 XMLSecurityContext_MSCryptImpl::getSecurityEnvironmentByIndex( sal_Int32 index
)
110 throw uno::RuntimeException() ;
112 return m_xSecurityEnvironment
;
115 css::uno::Reference
< css::xml::crypto::XSecurityEnvironment
> SAL_CALL
116 XMLSecurityContext_MSCryptImpl::getSecurityEnvironment( )
118 return m_xSecurityEnvironment
;
121 sal_Int32 SAL_CALL
XMLSecurityContext_MSCryptImpl::getDefaultSecurityEnvironmentIndex( )
126 void SAL_CALL
XMLSecurityContext_MSCryptImpl::setDefaultSecurityEnvironmentIndex( sal_Int32
/*nDefaultEnvIndex*/ )
132 OUString SAL_CALL
XMLSecurityContext_MSCryptImpl::getImplementationName() {
133 return "com.sun.star.xml.crypto.XMLSecurityContext" ;
137 sal_Bool SAL_CALL
XMLSecurityContext_MSCryptImpl::supportsService( const OUString
& serviceName
) {
138 return cppu::supportsService(this, serviceName
);
142 uno::Sequence
< OUString
> SAL_CALL
XMLSecurityContext_MSCryptImpl::getSupportedServiceNames() {
143 return { "com.sun.star.xml.crypto.XMLSecurityContext" };
146 extern "C" SAL_DLLPUBLIC_EXPORT
uno::XInterface
*
147 com_sun_star_xml_crypto_XMLSecurityContext_get_implementation(
148 uno::XComponentContext
* /*pCtx*/, uno::Sequence
<uno::Any
> const& /*rSeq*/)
150 return cppu::acquire(new XMLSecurityContext_MSCryptImpl
);
153 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */