1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_xmlsecurity.hxx"
26
27 #include <sal/config.h>
28 #include <stdio.h>
29
30 #include <osl/mutex.hxx>
31 #include <osl/thread.h>
32 #include <cppuhelper/factory.hxx>
33 #include <com/sun/star/lang/XSingleServiceFactory.hpp>
34
35 #include "seinitializer_nssimpl.hxx"
36 #include "xmlsignature_nssimpl.hxx"
37 #include "xmlencryption_nssimpl.hxx"
38 #include "xmlsecuritycontext_nssimpl.hxx"
39 #include "securityenvironment_nssimpl.hxx"
40
41 using namespace ::rtl;
42 using namespace ::cppu;
43 using namespace ::com::sun::star::uno;
44 using namespace ::com::sun::star::lang;
45 using namespace ::com::sun::star::registry;
46
47 extern "C"
48 {
49
nss_component_getFactory(const sal_Char * pImplName,void * pServiceManager,void *)50 void* SAL_CALL nss_component_getFactory( const sal_Char* pImplName , void* pServiceManager , void* /*pRegistryKey*/ )
51 {
52 void* pRet = 0;
53 Reference< XSingleServiceFactory > xFactory ;
54
55 if( pImplName != NULL && pServiceManager != NULL )
56 {
57 #ifdef XMLSEC_CRYPTO_NSS
58 if( SEInitializer_NssImpl_getImplementationName().equals( OUString::createFromAscii( pImplName ) ) )
59 {
60 xFactory = Reference< XSingleServiceFactory >( createSingleFactory(
61 reinterpret_cast< XMultiServiceFactory * >( pServiceManager ),
62 OUString::createFromAscii( pImplName ),
63 SEInitializer_NssImpl_createInstance, SEInitializer_NssImpl_getSupportedServiceNames() ) );
64 }
65 else if( XMLSignature_NssImpl::impl_getImplementationName().equals( OUString::createFromAscii( pImplName ) ) )
66 {
67 xFactory = XMLSignature_NssImpl::impl_createFactory( reinterpret_cast< XMultiServiceFactory* >( pServiceManager ) ) ;
68 }
69 else if( XMLSecurityContext_NssImpl::impl_getImplementationName().equals( OUString::createFromAscii( pImplName ) ) )
70 {
71 xFactory = XMLSecurityContext_NssImpl::impl_createFactory( reinterpret_cast< XMultiServiceFactory* >( pServiceManager ) ) ;
72 }
73 else if( SecurityEnvironment_NssImpl::impl_getImplementationName().equals( OUString::createFromAscii( pImplName ) ) )
74 {
75 xFactory = SecurityEnvironment_NssImpl::impl_createFactory( reinterpret_cast< XMultiServiceFactory* >( pServiceManager ) ) ;
76 }
77 else if( XMLEncryption_NssImpl::impl_getImplementationName().equals( OUString::createFromAscii( pImplName ) ) )
78 {
79 xFactory = XMLEncryption_NssImpl::impl_createFactory( reinterpret_cast< XMultiServiceFactory* >( pServiceManager ) ) ;
80 }
81 #else
82 if( ONSSInitializer_getImplementationName().equals( OUString::createFromAscii( pImplName ) ) )
83 {
84 xFactory = Reference< XSingleServiceFactory >( createSingleFactory(
85 reinterpret_cast< XMultiServiceFactory * >( pServiceManager ),
86 OUString::createFromAscii( pImplName ),
87 ONSSInitializer_createInstance, ONSSInitializer_getSupportedServiceNames() ) );
88 }
89 #endif
90 }
91
92 if( xFactory.is() ) {
93 xFactory->acquire() ;
94 pRet = xFactory.get() ;
95 }
96
97 return pRet ;
98 }
99
100 }
101
102