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"
33 #include <osl/mutex.hxx>
34 #include <osl/thread.h>
35 #include <cppuhelper/factory.hxx>
36 #include <com/sun/star/lang/XSingleServiceFactory.hpp>
38 #include <decryptorimpl.hxx>
39 #include <encryptorimpl.hxx>
40 #include <signaturecreatorimpl.hxx>
41 #include <signatureverifierimpl.hxx>
42 #include <saxeventkeeperimpl.hxx>
43 #include <xmlencryptiontemplateimpl.hxx>
44 #include <xmlsignaturetemplateimpl.hxx>
46 using namespace ::rtl
;
47 using namespace ::cppu
;
48 using namespace ::com::sun::star::uno
;
49 using namespace ::com::sun::star::lang
;
50 using namespace ::com::sun::star::registry
;
54 //==================================================================================================
55 void SAL_CALL
component_getImplementationEnvironment(
56 const sal_Char
** ppEnvTypeName
, uno_Environment
**)
58 *ppEnvTypeName
= CPPU_CURRENT_LANGUAGE_BINDING_NAME
;
61 //==================================================================================================
62 sal_Bool SAL_CALL
component_writeInfo(
63 void * /*pServiceManager*/, void * pRegistryKey
)
71 Reference
< XRegistryKey
> xNewKey(
72 reinterpret_cast< XRegistryKey
* >( pRegistryKey
)->createKey( DecryptorImpl_getImplementationName() ) );
73 xNewKey
= xNewKey
->createKey( OUString::createFromAscii( "/UNO/SERVICES" ) );
75 const Sequence
< OUString
> & rSNL
= DecryptorImpl_getSupportedServiceNames();
76 const OUString
* pArray
= rSNL
.getConstArray();
77 for ( nPos
= rSNL
.getLength(); nPos
--; )
78 xNewKey
->createKey( pArray
[nPos
] );
81 xNewKey
= reinterpret_cast< XRegistryKey
* >( pRegistryKey
)->createKey( EncryptorImpl_getImplementationName() );
82 xNewKey
= xNewKey
->createKey( OUString::createFromAscii( "/UNO/SERVICES" ) );
83 const Sequence
< OUString
> & rSNL2
= EncryptorImpl_getSupportedServiceNames();
84 pArray
= rSNL2
.getConstArray();
85 for ( nPos
= rSNL2
.getLength(); nPos
--; )
86 xNewKey
->createKey( pArray
[nPos
] );
89 xNewKey
= reinterpret_cast< XRegistryKey
* >( pRegistryKey
)->createKey( SignatureCreatorImpl_getImplementationName() );
90 xNewKey
= xNewKey
->createKey( OUString::createFromAscii( "/UNO/SERVICES" ) );
91 const Sequence
< OUString
> & rSNL3
= SignatureCreatorImpl_getSupportedServiceNames();
92 pArray
= rSNL3
.getConstArray();
93 for ( nPos
= rSNL3
.getLength(); nPos
--; )
94 xNewKey
->createKey( pArray
[nPos
] );
97 xNewKey
= reinterpret_cast< XRegistryKey
* >( pRegistryKey
)->createKey( SignatureVerifierImpl_getImplementationName() );
98 xNewKey
= xNewKey
->createKey( OUString::createFromAscii( "/UNO/SERVICES" ) );
99 const Sequence
< OUString
> & rSNL4
= SignatureVerifierImpl_getSupportedServiceNames();
100 pArray
= rSNL4
.getConstArray();
101 for ( nPos
= rSNL4
.getLength(); nPos
--; )
102 xNewKey
->createKey( pArray
[nPos
] );
105 xNewKey
= reinterpret_cast< XRegistryKey
* >( pRegistryKey
)->createKey( SAXEventKeeperImpl_getImplementationName() );
106 xNewKey
= xNewKey
->createKey( OUString::createFromAscii( "/UNO/SERVICES" ) );
107 const Sequence
< OUString
> & rSNL5
= SAXEventKeeperImpl_getSupportedServiceNames();
108 pArray
= rSNL5
.getConstArray();
109 for ( nPos
= rSNL5
.getLength(); nPos
--; )
110 xNewKey
->createKey( pArray
[nPos
] );
112 //XMLSignatureTemplateImpl
113 xNewKey
= reinterpret_cast< XRegistryKey
* >( pRegistryKey
)->createKey( XMLSignatureTemplateImpl::impl_getImplementationName() );
114 xNewKey
= xNewKey
->createKey( OUString::createFromAscii( "/UNO/SERVICES" ) );
115 const Sequence
< OUString
> & rSNL6
= XMLSignatureTemplateImpl::impl_getSupportedServiceNames();
116 pArray
= rSNL6
.getConstArray();
117 for ( nPos
= rSNL6
.getLength(); nPos
--; )
118 xNewKey
->createKey( pArray
[nPos
] );
120 // XMLEncryptionTemplateImpl
121 xNewKey
= reinterpret_cast< XRegistryKey
* >( pRegistryKey
)->createKey( XMLEncryptionTemplateImpl::impl_getImplementationName() );
122 xNewKey
= xNewKey
->createKey( OUString::createFromAscii( "/UNO/SERVICES" ) );
123 const Sequence
< OUString
> & rSNL7
= XMLEncryptionTemplateImpl::impl_getSupportedServiceNames();
124 pArray
= rSNL7
.getConstArray();
125 for ( nPos
= rSNL7
.getLength(); nPos
--; )
126 xNewKey
->createKey( pArray
[nPos
] );
130 catch (InvalidRegistryException
&)
132 OSL_ENSURE( sal_False
, "### InvalidRegistryException!" );
138 //==================================================================================================
139 void * SAL_CALL
component_getFactory(
140 const sal_Char
* pImplName
, void * pServiceManager
, void * /*pRegistryKey*/ )
145 OUString implName
= OUString::createFromAscii( pImplName
);
146 if ( pServiceManager
&& implName
.equals(DecryptorImpl_getImplementationName()) )
148 Reference
< XSingleServiceFactory
> xFactory( createSingleFactory(
149 reinterpret_cast< XMultiServiceFactory
* >( pServiceManager
),
150 OUString::createFromAscii( pImplName
),
151 DecryptorImpl_createInstance
, DecryptorImpl_getSupportedServiceNames() ) );
156 pRet
= xFactory
.get();
161 if ( pServiceManager
&& implName
.equals(EncryptorImpl_getImplementationName()) )
163 Reference
< XSingleServiceFactory
> xFactory( createSingleFactory(
164 reinterpret_cast< XMultiServiceFactory
* >( pServiceManager
),
165 OUString::createFromAscii( pImplName
),
166 EncryptorImpl_createInstance
, EncryptorImpl_getSupportedServiceNames() ) );
171 pRet
= xFactory
.get();
176 if ( pServiceManager
&& implName
.equals(SignatureCreatorImpl_getImplementationName()) )
178 Reference
< XSingleServiceFactory
> xFactory( createSingleFactory(
179 reinterpret_cast< XMultiServiceFactory
* >( pServiceManager
),
180 OUString::createFromAscii( pImplName
),
181 SignatureCreatorImpl_createInstance
, SignatureCreatorImpl_getSupportedServiceNames() ) );
186 pRet
= xFactory
.get();
191 if ( pServiceManager
&& implName
.equals(SignatureVerifierImpl_getImplementationName()) )
193 Reference
< XSingleServiceFactory
> xFactory( createSingleFactory(
194 reinterpret_cast< XMultiServiceFactory
* >( pServiceManager
),
195 OUString::createFromAscii( pImplName
),
196 SignatureVerifierImpl_createInstance
, SignatureVerifierImpl_getSupportedServiceNames() ) );
201 pRet
= xFactory
.get();
206 if ( pServiceManager
&& implName
.equals(SAXEventKeeperImpl_getImplementationName()) )
208 Reference
< XSingleServiceFactory
> xFactory( createSingleFactory(
209 reinterpret_cast< XMultiServiceFactory
* >( pServiceManager
),
210 OUString::createFromAscii( pImplName
),
211 SAXEventKeeperImpl_createInstance
, SAXEventKeeperImpl_getSupportedServiceNames() ) );
216 pRet
= xFactory
.get();
220 //XMLSignatureTemplate
221 if ( pServiceManager
&& implName
.equals( XMLSignatureTemplateImpl::impl_getImplementationName()) )
223 Reference
< XSingleServiceFactory
> xFactory
= XMLSignatureTemplateImpl::impl_createFactory(
224 reinterpret_cast< XMultiServiceFactory
* >( pServiceManager
) ) ;
229 pRet
= xFactory
.get();
233 //XMLEncryptionTemplate
234 if ( pServiceManager
&& implName
.equals( XMLEncryptionTemplateImpl::impl_getImplementationName()) )
236 Reference
< XSingleServiceFactory
> xFactory
= XMLEncryptionTemplateImpl::impl_createFactory(
237 reinterpret_cast< XMultiServiceFactory
* >( pServiceManager
) ) ;
242 pRet
= xFactory
.get();