Bump version to 6.0-36
[LibreOffice.git] / xmlsecurity / source / xmlsec / mscrypt / xmlsecuritycontext_mscryptimpl.cxx
blob925da9eba35c086b513f095b24255b24f2ad7021
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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>
21 #include "securityenvironment_mscryptimpl.hxx"
23 #include "xmlsecuritycontext_mscryptimpl.hxx"
24 #include <xmlsec/xmlstreamio.hxx>
25 #include "akmngr.hxx"
27 #include <xmlsec-wrapper.h>
29 using namespace ::com::sun::star::uno ;
30 using namespace ::com::sun::star::lang ;
31 using ::com::sun::star::lang::XMultiServiceFactory ;
32 using ::com::sun::star::lang::XSingleServiceFactory ;
34 using ::com::sun::star::xml::crypto::XSecurityEnvironment ;
35 using ::com::sun::star::xml::crypto::XXMLSecurityContext ;
37 XMLSecurityContext_MSCryptImpl::XMLSecurityContext_MSCryptImpl()
38 ://m_pKeysMngr( NULL ) ,
39 m_xSecurityEnvironment( nullptr )
43 XMLSecurityContext_MSCryptImpl::~XMLSecurityContext_MSCryptImpl()
47 sal_Int32 SAL_CALL XMLSecurityContext_MSCryptImpl::addSecurityEnvironment(
48 const css::uno::Reference< css::xml::crypto::XSecurityEnvironment >& aSecurityEnvironment)
50 if( !aSecurityEnvironment.is() )
52 throw RuntimeException() ;
55 m_xSecurityEnvironment = aSecurityEnvironment;
57 return 0;
61 sal_Int32 SAL_CALL XMLSecurityContext_MSCryptImpl::getSecurityEnvironmentNumber( )
63 return 1;
66 css::uno::Reference< css::xml::crypto::XSecurityEnvironment > SAL_CALL
67 XMLSecurityContext_MSCryptImpl::getSecurityEnvironmentByIndex( sal_Int32 index )
69 if (index != 0)
71 throw RuntimeException() ;
73 return m_xSecurityEnvironment;
76 css::uno::Reference< css::xml::crypto::XSecurityEnvironment > SAL_CALL
77 XMLSecurityContext_MSCryptImpl::getSecurityEnvironment( )
79 return m_xSecurityEnvironment;
82 sal_Int32 SAL_CALL XMLSecurityContext_MSCryptImpl::getDefaultSecurityEnvironmentIndex( )
84 return 0;
87 void SAL_CALL XMLSecurityContext_MSCryptImpl::setDefaultSecurityEnvironmentIndex( sal_Int32 /*nDefaultEnvIndex*/ )
89 //dummy
92 /* XServiceInfo */
93 OUString SAL_CALL XMLSecurityContext_MSCryptImpl::getImplementationName() {
94 return impl_getImplementationName() ;
97 /* XServiceInfo */
98 sal_Bool SAL_CALL XMLSecurityContext_MSCryptImpl::supportsService( const OUString& serviceName) {
99 Sequence< OUString > seqServiceNames = getSupportedServiceNames() ;
100 const OUString* pArray = seqServiceNames.getConstArray() ;
101 for( sal_Int32 i = 0 ; i < seqServiceNames.getLength() ; i ++ ) {
102 if( *( pArray + i ) == serviceName )
103 return true ;
105 return false ;
108 /* XServiceInfo */
109 Sequence< OUString > SAL_CALL XMLSecurityContext_MSCryptImpl::getSupportedServiceNames() {
110 return impl_getSupportedServiceNames() ;
113 //Helper for XServiceInfo
114 Sequence< OUString > XMLSecurityContext_MSCryptImpl::impl_getSupportedServiceNames() {
115 ::osl::Guard< ::osl::Mutex > aGuard( ::osl::Mutex::getGlobalMutex() ) ;
116 Sequence<OUString> seqServiceNames { "com.sun.star.xml.crypto.XMLSecurityContext" };
117 return seqServiceNames ;
120 OUString XMLSecurityContext_MSCryptImpl::impl_getImplementationName() {
121 return OUString("com.sun.star.xml.security.bridge.xmlsec.XMLSecurityContext_MSCryptImpl") ;
124 //Helper for registry
125 Reference< XInterface > SAL_CALL XMLSecurityContext_MSCryptImpl::impl_createInstance( const Reference< XMultiServiceFactory >& ) {
126 return Reference< XInterface >( *new XMLSecurityContext_MSCryptImpl ) ;
129 Reference< XSingleServiceFactory > XMLSecurityContext_MSCryptImpl::impl_createFactory( const Reference< XMultiServiceFactory >& aServiceManager ) {
130 //Reference< XSingleServiceFactory > xFactory ;
131 //xFactory = ::cppu::createSingleFactory( aServiceManager , impl_getImplementationName , impl_createInstance , impl_getSupportedServiceNames ) ;
132 //return xFactory ;
133 return ::cppu::createSingleFactory( aServiceManager , impl_getImplementationName() , impl_createInstance , impl_getSupportedServiceNames() ) ;
136 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */