1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_xmlsecurity.hxx"
30 
31 #include <sal/config.h>
32 #include <stdio.h>
33 
34 #include <osl/mutex.hxx>
35 #include <osl/thread.h>
36 #include <cppuhelper/factory.hxx>
37 #include <com/sun/star/lang/XSingleServiceFactory.hpp>
38 
39 #include "seinitializer_nssimpl.hxx"
40 #include "xmlsignature_nssimpl.hxx"
41 #include "xmlencryption_nssimpl.hxx"
42 #include "xmlsecuritycontext_nssimpl.hxx"
43 #include "securityenvironment_nssimpl.hxx"
44 
45 using namespace ::rtl;
46 using namespace ::cppu;
47 using namespace ::com::sun::star::uno;
48 using namespace ::com::sun::star::lang;
49 using namespace ::com::sun::star::registry;
50 
51 extern "C"
52 {
53 
54 void* SAL_CALL nss_component_getFactory( const sal_Char* pImplName , void* pServiceManager , void* /*pRegistryKey*/ )
55 {
56     void* pRet = 0;
57     Reference< XSingleServiceFactory > xFactory ;
58 
59     if( pImplName != NULL && pServiceManager != NULL )
60     {
61 #ifdef XMLSEC_CRYPTO_NSS
62         if( SEInitializer_NssImpl_getImplementationName().equals( OUString::createFromAscii( pImplName ) ) )
63         {
64             xFactory = Reference< XSingleServiceFactory >( createSingleFactory(
65                 reinterpret_cast< XMultiServiceFactory * >( pServiceManager ),
66                 OUString::createFromAscii( pImplName ),
67                 SEInitializer_NssImpl_createInstance, SEInitializer_NssImpl_getSupportedServiceNames() ) );
68         }
69         else if( XMLSignature_NssImpl::impl_getImplementationName().equals( OUString::createFromAscii( pImplName ) ) )
70         {
71             xFactory = XMLSignature_NssImpl::impl_createFactory( reinterpret_cast< XMultiServiceFactory* >( pServiceManager ) ) ;
72         }
73         else if( XMLSecurityContext_NssImpl::impl_getImplementationName().equals( OUString::createFromAscii( pImplName ) ) )
74         {
75             xFactory = XMLSecurityContext_NssImpl::impl_createFactory( reinterpret_cast< XMultiServiceFactory* >( pServiceManager ) ) ;
76         }
77         else if( SecurityEnvironment_NssImpl::impl_getImplementationName().equals( OUString::createFromAscii( pImplName ) ) )
78         {
79             xFactory = SecurityEnvironment_NssImpl::impl_createFactory( reinterpret_cast< XMultiServiceFactory* >( pServiceManager ) ) ;
80         }
81         else if( XMLEncryption_NssImpl::impl_getImplementationName().equals( OUString::createFromAscii( pImplName ) ) )
82         {
83             xFactory = XMLEncryption_NssImpl::impl_createFactory( reinterpret_cast< XMultiServiceFactory* >( pServiceManager ) ) ;
84         }
85 #else
86         if( ONSSInitializer_getImplementationName().equals( OUString::createFromAscii( pImplName ) ) )
87         {
88             xFactory = Reference< XSingleServiceFactory >( createSingleFactory(
89                 reinterpret_cast< XMultiServiceFactory * >( pServiceManager ),
90                 OUString::createFromAscii( pImplName ),
91                 ONSSInitializer_createInstance, ONSSInitializer_getSupportedServiceNames() ) );
92         }
93 #endif
94     }
95 
96     if( xFactory.is() ) {
97         xFactory->acquire() ;
98         pRet = xFactory.get() ;
99     }
100 
101     return pRet ;
102 }
103 
104 }
105 
106