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 <tools/debug.hxx>
32 #include <com/sun/star/lang/XSingleServiceFactory.hpp>
34 #include <cppuhelper/factory.hxx>
37 #include <documentdigitalsignatures.hxx>
38 #include <certificatecontainer.hxx>
40 using namespace ::com::sun::star
;
44 void SAL_CALL
component_getImplementationEnvironment( const sal_Char
** ppEnvTypeName
, uno_Environment
** )
46 *ppEnvTypeName
= CPPU_CURRENT_LANGUAGE_BINDING_NAME
;
49 sal_Bool SAL_CALL
component_writeInfo( void* /*pServiceManager*/, void* pRegistryKey
)
56 // SERVICE DocumentDigitalSignatures
58 uno::Reference
< registry::XRegistryKey
> xNewKey(
59 reinterpret_cast< registry::XRegistryKey
* >( pRegistryKey
)->createKey( DocumentDigitalSignatures::GetImplementationName() ) );
61 xNewKey
= xNewKey
->createKey( rtl::OUString::createFromAscii( "/UNO/SERVICES" ) );
63 const uno::Sequence
< rtl::OUString
>& rSNL
= DocumentDigitalSignatures::GetSupportedServiceNames();
64 const rtl::OUString
* pArray
= rSNL
.getConstArray();
65 for ( nPos
= rSNL
.getLength(); nPos
--; )
66 xNewKey
->createKey( pArray
[nPos
] );
68 // SERVICE CertificateContainer
70 uno::Reference
< registry::XRegistryKey
> xNewKeyCertificateContainer(
71 reinterpret_cast< registry::XRegistryKey
* >( pRegistryKey
)->createKey( CertificateContainer::impl_getStaticImplementationName() ) );
72 xNewKeyCertificateContainer
= xNewKeyCertificateContainer
->createKey( rtl::OUString::createFromAscii( "/UNO/SERVICES" ) );
74 const uno::Sequence
< rtl::OUString
>& rSNLCertificateContainer
= CertificateContainer::impl_getStaticSupportedServiceNames();
75 const rtl::OUString
* pArrayCertificateContainer
= rSNLCertificateContainer
.getConstArray();
76 for ( nPos
= rSNLCertificateContainer
.getLength(); nPos
--; )
77 xNewKeyCertificateContainer
->createKey( pArrayCertificateContainer
[nPos
] );
79 //-----------------------------
83 catch (registry::InvalidRegistryException
&)
85 DBG_ERROR( "InvalidRegistryException!" );
91 void* SAL_CALL
component_getFactory( const sal_Char
* pImplName
, void * pServiceManager
, void * /*pRegistryKey*/ )
94 uno::Reference
< XInterface
> xFactory
;
97 rtl::OUString implName
= rtl::OUString::createFromAscii( pImplName
);
99 if ( pServiceManager
&& implName
.equals( DocumentDigitalSignatures::GetImplementationName() ) )
101 // DocumentDigitalSignatures
102 xFactory
= cppu::createSingleComponentFactory(
103 DocumentDigitalSignatures_CreateInstance
,
104 rtl::OUString::createFromAscii( pImplName
),
105 DocumentDigitalSignatures::GetSupportedServiceNames() );
107 else if ( pServiceManager
&& implName
.equals( CertificateContainer::impl_getStaticImplementationName() ))
109 // CertificateContainer
110 xFactory
= cppu::createOneInstanceFactory(
111 reinterpret_cast< lang::XMultiServiceFactory
* >( pServiceManager
),
112 rtl::OUString::createFromAscii( pImplName
),
113 CertificateContainer::impl_createInstance
,
114 CertificateContainer::impl_getStaticSupportedServiceNames() );
120 pRet
= xFactory
.get();