Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*
3 : : * This file is part of the LibreOffice project.
4 : : *
5 : : * This Source Code Form is subject to the terms of the Mozilla Public
6 : : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : : *
9 : : * This file incorporates work covered by the following license notice:
10 : : *
11 : : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : : * contributor license agreements. See the NOTICE file distributed
13 : : * with this work for additional information regarding copyright
14 : : * ownership. The ASF licenses this file to you under the Apache
15 : : * License, Version 2.0 (the "License"); you may not use this file
16 : : * except in compliance with the License. You may obtain a copy of
17 : : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : : */
19 : :
20 : :
21 : : #include <sal/config.h>
22 : : #include <stdio.h>
23 : :
24 : : #include <osl/mutex.hxx>
25 : : #include <osl/thread.h>
26 : : #include <cppuhelper/factory.hxx>
27 : : #include <cppuhelper/implbase1.hxx>
28 : : #include <com/sun/star/lang/XSingleServiceFactory.hpp>
29 : : #include <com/sun/star/security/XSerialNumberAdapter.hpp>
30 : :
31 : : #include "xmlelementwrapper_xmlsecimpl.hxx"
32 : : #include "xmldocumentwrapper_xmlsecimpl.hxx"
33 : : #include "xmlsecurity/biginteger.hxx"
34 : :
35 : : using namespace ::rtl;
36 : : using namespace ::cppu;
37 : : using namespace ::com::sun::star::uno;
38 : : using namespace ::com::sun::star::lang;
39 : : using namespace ::com::sun::star::registry;
40 : :
41 : : namespace
42 : : {
43 [ # # ]: 0 : class SerialNumberAdapterImpl : public WeakImplHelper1<
44 : : ::com::sun::star::security::XSerialNumberAdapter >
45 : : {
46 : 0 : virtual OUString SAL_CALL toString( const Sequence< sal_Int8 >& rSerialNumber )
47 : : throw (RuntimeException)
48 : : {
49 [ # # ]: 0 : return bigIntegerToNumericString(rSerialNumber);
50 : : }
51 : 0 : virtual Sequence< sal_Int8 > SAL_CALL toSequence( const OUString& rSerialNumber )
52 : : throw (RuntimeException)
53 : : {
54 [ # # ]: 0 : return numericStringToBigInteger(rSerialNumber);
55 : : }
56 : : };
57 : :
58 : 3 : OUString SerialNumberAdapterImpl_getImplementationName()
59 : : throw (RuntimeException)
60 : : {
61 : 3 : return OUString( "com.sun.star.security.SerialNumberAdapter");
62 : : }
63 : :
64 : 0 : Sequence< OUString > SerialNumberAdapterImpl_getSupportedServiceNames()
65 : : throw (RuntimeException)
66 : : {
67 : 0 : Sequence < OUString > aRet(1);
68 [ # # ]: 0 : OUString* pArray = aRet.getArray();
69 : 0 : pArray[0] = OUString( "com.sun.star.security.SerialNumberAdapter" );
70 : 0 : return aRet;
71 : : }
72 : :
73 : 0 : Reference< XInterface > SerialNumberAdapterImpl_createInstance(
74 : : const Reference< XComponentContext > &) throw( Exception )
75 : : {
76 [ # # ]: 0 : return Reference< XInterface >( *new SerialNumberAdapterImpl() );
77 : : }
78 : :
79 : : }
80 : :
81 : : extern "C"
82 : : {
83 : :
84 : : extern void* nss_component_getFactory( const sal_Char*, void*, void* );
85 : :
86 : : #if defined( XMLSEC_CRYPTO_MSCRYPTO )
87 : : extern void* mscrypt_component_getFactory( const sal_Char*, void*, void* );
88 : : #endif
89 : :
90 : 3 : SAL_DLLPUBLIC_EXPORT void* SAL_CALL xsec_xmlsec_component_getFactory( const sal_Char* pImplName , void* pServiceManager , void* pRegistryKey )
91 : : {
92 : 3 : void* pRet = 0;
93 : 3 : Reference< XInterface > xFactory ;
94 : :
95 [ + - ][ + - ]: 3 : if( pImplName != NULL && pServiceManager != NULL ) {
96 [ + - ][ - + ]: 3 : if( XMLElementWrapper_XmlSecImpl_getImplementationName().equals( OUString::createFromAscii( pImplName ) ) )
97 : : {
98 : : xFactory = Reference< XSingleServiceFactory >( createSingleFactory(
99 : : reinterpret_cast< XMultiServiceFactory * >( pServiceManager ),
100 : : OUString::createFromAscii( pImplName ),
101 [ # # ][ # # ]: 0 : XMLElementWrapper_XmlSecImpl_createInstance, XMLElementWrapper_XmlSecImpl_getSupportedServiceNames() ) );
[ # # ][ # # ]
[ # # ]
102 : : }
103 [ + - ][ - + ]: 3 : else if( XMLDocumentWrapper_XmlSecImpl_getImplementationName().equals( OUString::createFromAscii( pImplName ) ) )
104 : : {
105 : : xFactory = Reference< XSingleServiceFactory >( createSingleFactory(
106 : : reinterpret_cast< XMultiServiceFactory * >( pServiceManager ),
107 : : OUString::createFromAscii( pImplName ),
108 [ # # ][ # # ]: 0 : XMLDocumentWrapper_XmlSecImpl_createInstance, XMLDocumentWrapper_XmlSecImpl_getSupportedServiceNames() ) );
[ # # ][ # # ]
[ # # ]
109 : : }
110 [ + - ][ - + ]: 3 : else if( SerialNumberAdapterImpl_getImplementationName().equals( OUString::createFromAscii( pImplName ) ) )
111 : : {
112 : : xFactory = ::cppu::createSingleComponentFactory(
113 : : SerialNumberAdapterImpl_createInstance,
114 : : OUString::createFromAscii( pImplName ),
115 [ # # ][ # # ]: 0 : SerialNumberAdapterImpl_getSupportedServiceNames() );
[ # # ][ # # ]
116 : : }
117 : : }
118 : :
119 [ - + ]: 3 : if( xFactory.is() ) {
120 [ # # ]: 0 : xFactory->acquire() ;
121 [ # # ]: 0 : pRet = xFactory.get() ;
122 : : } else {
123 [ + - ]: 3 : pRet = nss_component_getFactory( pImplName, pServiceManager, pRegistryKey ) ;
124 [ + - ]: 3 : if( pRet != NULL )
125 : 3 : return pRet ;
126 : :
127 : : #if defined( XMLSEC_CRYPTO_MSCRYPTO )
128 : : pRet = mscrypt_component_getFactory( pImplName, pServiceManager, pRegistryKey ) ;
129 : : if( pRet != NULL )
130 : : return pRet ;
131 : : #endif
132 : : }
133 : :
134 : 3 : return pRet ;
135 : : }
136 : :
137 : : }
138 : :
139 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|