| 1 |
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
| 2 |
/* |
| 3 |
* This file is part of the LibreOffice project. |
| 4 |
* |
| 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 |
* |
| 9 |
* This file incorporates work covered by the following license notice: |
| 10 |
* |
| 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 . |
| 18 |
*/ |
| 19 |
|
| 20 |
#include <sal/config.h> |
| 21 |
|
| 22 |
#include <com/sun/star/xml/crypto/XXMLSecurityContext.hpp> |
| 23 |
#include "securityenvironment_mscryptimpl.hxx" |
| 24 |
|
| 25 |
#include <xmlsec/xmlstreamio.hxx> |
| 26 |
|
| 27 |
#include "akmngr.hxx" |
| 28 |
|
| 29 |
#include <cppuhelper/supportsservice.hxx> |
| 30 |
|
| 31 |
using namespace ::com::sun::star; |
| 32 |
using namespace ::com::sun::star::lang ; |
| 33 |
|
| 34 |
using ::com::sun::star::xml::crypto::XSecurityEnvironment ; |
| 35 |
using ::com::sun::star::xml::crypto::XXMLSecurityContext ; |
| 36 |
|
| 37 |
namespace { |
| 38 |
|
| 39 |
class XMLSecurityContext_MSCryptImpl : public ::cppu::WeakImplHelper< |
| 40 |
css::xml::crypto::XXMLSecurityContext , |
| 41 |
css::lang::XServiceInfo > |
| 42 |
{ |
| 43 |
private: |
| 44 |
//xmlSecKeysMngrPtr m_pKeysMngr ; |
| 45 |
css::uno::Reference< css::xml::crypto::XSecurityEnvironment > m_xSecurityEnvironment ; |
| 46 |
|
| 47 |
public: |
| 48 |
XMLSecurityContext_MSCryptImpl(); |
| 49 |
|
| 50 |
//Methods from XXMLSecurityContext |
| 51 |
virtual sal_Int32 SAL_CALL addSecurityEnvironment( |
| 52 |
const css::uno::Reference< css::xml::crypto::XSecurityEnvironment >& aSecurityEnvironment |
| 53 |
) override; |
| 54 |
|
| 55 |
virtual ::sal_Int32 SAL_CALL getSecurityEnvironmentNumber( ) override; |
| 56 |
|
| 57 |
virtual css::uno::Reference< |
| 58 |
css::xml::crypto::XSecurityEnvironment > SAL_CALL |
| 59 |
getSecurityEnvironmentByIndex( ::sal_Int32 index ) override; |
| 60 |
|
| 61 |
virtual css::uno::Reference< |
| 62 |
css::xml::crypto::XSecurityEnvironment > SAL_CALL |
| 63 |
getSecurityEnvironment( ) override; |
| 64 |
|
| 65 |
virtual ::sal_Int32 SAL_CALL getDefaultSecurityEnvironmentIndex( ) override; |
| 66 |
|
| 67 |
virtual void SAL_CALL setDefaultSecurityEnvironmentIndex( sal_Int32 nDefaultEnvIndex ) override; |
| 68 |
|
| 69 |
|
| 70 |
//Methods from XServiceInfo |
| 71 |
virtual OUString SAL_CALL getImplementationName() override; |
| 72 |
|
| 73 |
virtual sal_Bool SAL_CALL supportsService( |
| 74 |
const OUString& ServiceName |
| 75 |
) override; |
| 76 |
|
| 77 |
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; |
| 78 |
}; |
| 79 |
|
| 80 |
} |
| 81 |
|
| 82 |
XMLSecurityContext_MSCryptImpl::XMLSecurityContext_MSCryptImpl() |
| 83 |
{ |
| 84 |
} |
| 85 |
|
| 86 |
sal_Int32 SAL_CALL XMLSecurityContext_MSCryptImpl::addSecurityEnvironment( |
| 87 |
const css::uno::Reference< css::xml::crypto::XSecurityEnvironment >& aSecurityEnvironment) |
| 88 |
{ |
| 89 |
if( !aSecurityEnvironment.is() ) |
| 90 |
{ |
| 91 |
throw uno::RuntimeException() ; |
| 92 |
} |
| 93 |
|
| 94 |
m_xSecurityEnvironment = aSecurityEnvironment; |
| 95 |
|
| 96 |
return 0; |
| 97 |
} |
| 98 |
|
| 99 |
|
| 100 |
sal_Int32 SAL_CALL XMLSecurityContext_MSCryptImpl::getSecurityEnvironmentNumber( ) |
| 101 |
{ |
| 102 |
return 1; |
| 103 |
} |
| 104 |
|
| 105 |
css::uno::Reference< css::xml::crypto::XSecurityEnvironment > SAL_CALL |
| 106 |
XMLSecurityContext_MSCryptImpl::getSecurityEnvironmentByIndex( sal_Int32 index ) |
| 107 |
{ |
| 108 |
if (index != 0) |
| 109 |
{ |
| 110 |
throw uno::RuntimeException() ; |
| 111 |
} |
| 112 |
return m_xSecurityEnvironment; |
| 113 |
} |
| 114 |
|
| 115 |
css::uno::Reference< css::xml::crypto::XSecurityEnvironment > SAL_CALL |
| 116 |
XMLSecurityContext_MSCryptImpl::getSecurityEnvironment( ) |
| 117 |
{ |
| 118 |
return m_xSecurityEnvironment; |
| 119 |
} |
| 120 |
|
| 121 |
sal_Int32 SAL_CALL XMLSecurityContext_MSCryptImpl::getDefaultSecurityEnvironmentIndex( ) |
| 122 |
{ |
| 123 |
return 0; |
| 124 |
} |
| 125 |
|
| 126 |
void SAL_CALL XMLSecurityContext_MSCryptImpl::setDefaultSecurityEnvironmentIndex( sal_Int32 /*nDefaultEnvIndex*/ ) |
| 127 |
{ |
| 128 |
//dummy |
| 129 |
} |
| 130 |
|
| 131 |
/* XServiceInfo */ |
| 132 |
OUString SAL_CALL XMLSecurityContext_MSCryptImpl::getImplementationName() { |
| 133 |
return "com.sun.star.xml.crypto.XMLSecurityContext" ; |
| 134 |
} |
| 135 |
|
| 136 |
/* XServiceInfo */ |
| 137 |
sal_Bool SAL_CALL XMLSecurityContext_MSCryptImpl::supportsService( const OUString& serviceName) { |
| 138 |
return cppu::supportsService(this, serviceName); |
| 139 |
} |
| 140 |
|
| 141 |
/* XServiceInfo */ |
| 142 |
uno::Sequence< OUString > SAL_CALL XMLSecurityContext_MSCryptImpl::getSupportedServiceNames() { |
| 143 |
return { "com.sun.star.xml.crypto.XMLSecurityContext" }; |
| 144 |
} |
| 145 |
|
| 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*/) |
| 149 |
{ |
| 150 |
return cppu::acquire(new XMLSecurityContext_MSCryptImpl); |
| 151 |
} |
| 152 |
|
| 153 |
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |