1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
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.
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).
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.
26 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_xmlsecurity.hxx"
31 #include <sal/config.h>
34 #include <osl/mutex.hxx>
35 #include <osl/thread.h>
36 #include <cppuhelper/factory.hxx>
37 #include <com/sun/star/lang/XSingleServiceFactory.hpp>
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"
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
;
54 sal_Bool SAL_CALL
nss_component_writeInfo( void* /*pServiceManager*/ , void* pRegistryKey
)
56 sal_Bool result
= sal_False
;
59 Reference
< XRegistryKey
> xNewKey
;
60 Sequence
< OUString
> seqServices
;
61 Reference
< XRegistryKey
> xKey( reinterpret_cast< XRegistryKey
* >( pRegistryKey
) ) ;
65 // XMLSignature_NssImpl
66 sKeyName
= OUString( RTL_CONSTASCII_USTRINGPARAM( "/" ) ) ;
67 sKeyName
+= XMLSignature_NssImpl::impl_getImplementationName() ;
68 sKeyName
+= OUString::createFromAscii( "/UNO/SERVICES" ) ;
70 xNewKey
= xKey
->createKey( sKeyName
) ;
72 seqServices
= XMLSignature_NssImpl::impl_getSupportedServiceNames() ;
73 for( i
= seqServices
.getLength() ; i
-- ; )
74 xNewKey
->createKey( seqServices
.getConstArray()[i
] ) ;
77 // XMLEncryption_NssImpl
78 sKeyName
= OUString( RTL_CONSTASCII_USTRINGPARAM( "/" ) ) ;
79 sKeyName
+= XMLEncryption_NssImpl::impl_getImplementationName() ;
80 sKeyName
+= OUString::createFromAscii( "/UNO/SERVICES" ) ;
82 xNewKey
= xKey
->createKey( sKeyName
) ;
84 seqServices
= XMLEncryption_NssImpl::impl_getSupportedServiceNames() ;
85 for( i
= seqServices
.getLength() ; i
-- ; )
86 xNewKey
->createKey( seqServices
.getConstArray()[i
] ) ;
89 // XMLSecurityContext_NssImpl
90 sKeyName
= OUString( RTL_CONSTASCII_USTRINGPARAM( "/" ) ) ;
91 sKeyName
+= XMLSecurityContext_NssImpl::impl_getImplementationName() ;
92 sKeyName
+= OUString::createFromAscii( "/UNO/SERVICES" ) ;
94 xNewKey
= xKey
->createKey( sKeyName
) ;
96 seqServices
= XMLSecurityContext_NssImpl::impl_getSupportedServiceNames() ;
97 for( i
= seqServices
.getLength() ; i
-- ; )
98 xNewKey
->createKey( seqServices
.getConstArray()[i
] ) ;
101 // SecurityEnvironment_NssImpl
102 sKeyName
= OUString( RTL_CONSTASCII_USTRINGPARAM( "/" ) ) ;
103 sKeyName
+= SecurityEnvironment_NssImpl::impl_getImplementationName() ;
104 sKeyName
+= OUString::createFromAscii( "/UNO/SERVICES" ) ;
106 xNewKey
= xKey
->createKey( sKeyName
) ;
108 seqServices
= SecurityEnvironment_NssImpl::impl_getSupportedServiceNames() ;
109 for( i
= seqServices
.getLength() ; i
-- ; )
110 xNewKey
->createKey( seqServices
.getConstArray()[i
] ) ;
113 // SEInitializer_NssImpl
114 sKeyName
= OUString( RTL_CONSTASCII_USTRINGPARAM( "/" ) ) ;
115 sKeyName
+= SEInitializer_NssImpl_getImplementationName() ;
116 sKeyName
+= OUString::createFromAscii( "/UNO/SERVICES" ) ;
118 xNewKey
= xKey
->createKey( sKeyName
) ;
120 seqServices
= SEInitializer_NssImpl_getSupportedServiceNames() ;
121 for( i
= seqServices
.getLength() ; i
-- ; )
122 xNewKey
->createKey( seqServices
.getConstArray()[i
] ) ;
126 //} catch( InvalidRegistryException & ) {
127 // //we should not ignore exceptions
128 // return sal_False ;
134 void* SAL_CALL
nss_component_getFactory( const sal_Char
* pImplName
, void* pServiceManager
, void* /*pRegistryKey*/ )
137 Reference
< XSingleServiceFactory
> xFactory
;
139 if( pImplName
!= NULL
&& pServiceManager
!= NULL
) {
140 if( XMLSignature_NssImpl::impl_getImplementationName().equals( OUString::createFromAscii( pImplName
) ) ) {
141 xFactory
= XMLSignature_NssImpl::impl_createFactory( reinterpret_cast< XMultiServiceFactory
* >( pServiceManager
) ) ;
142 } else if( XMLSecurityContext_NssImpl::impl_getImplementationName().equals( OUString::createFromAscii( pImplName
) ) ) {
143 xFactory
= XMLSecurityContext_NssImpl::impl_createFactory( reinterpret_cast< XMultiServiceFactory
* >( pServiceManager
) ) ;
144 } else if( SecurityEnvironment_NssImpl::impl_getImplementationName().equals( OUString::createFromAscii( pImplName
) ) ) {
145 xFactory
= SecurityEnvironment_NssImpl::impl_createFactory( reinterpret_cast< XMultiServiceFactory
* >( pServiceManager
) ) ;
146 } else if( XMLEncryption_NssImpl::impl_getImplementationName().equals( OUString::createFromAscii( pImplName
) ) ) {
147 xFactory
= XMLEncryption_NssImpl::impl_createFactory( reinterpret_cast< XMultiServiceFactory
* >( pServiceManager
) ) ;
148 } else if( SEInitializer_NssImpl_getImplementationName().equals( OUString::createFromAscii( pImplName
) ) ) {
149 xFactory
= Reference
< XSingleServiceFactory
>( createSingleFactory(
150 reinterpret_cast< XMultiServiceFactory
* >( pServiceManager
),
151 OUString::createFromAscii( pImplName
),
152 SEInitializer_NssImpl_createInstance
, SEInitializer_NssImpl_getSupportedServiceNames() ) );
156 if( xFactory
.is() ) {
157 xFactory
->acquire() ;
158 pRet
= xFactory
.get() ;