1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_xmlsecurity.hxx"
26 
27 #include <stdio.h>
28 
29 #include <osl/mutex.hxx>
30 #include <osl/thread.h>
31 #include <cppuhelper/factory.hxx>
32 #include <com/sun/star/lang/XSingleServiceFactory.hpp>
33 
34 #include <decryptorimpl.hxx>
35 #include <encryptorimpl.hxx>
36 #include <signaturecreatorimpl.hxx>
37 #include <signatureverifierimpl.hxx>
38 #include <saxeventkeeperimpl.hxx>
39 #include <xmlencryptiontemplateimpl.hxx>
40 #include <xmlsignaturetemplateimpl.hxx>
41 
42 using namespace ::rtl;
43 using namespace ::cppu;
44 using namespace ::com::sun::star::uno;
45 using namespace ::com::sun::star::lang;
46 using namespace ::com::sun::star::registry;
47 
48 extern "C"
49 {
50 //==================================================================================================
component_getImplementationEnvironment(const sal_Char ** ppEnvTypeName,uno_Environment **)51 void SAL_CALL component_getImplementationEnvironment(
52 	const sal_Char ** ppEnvTypeName, uno_Environment **)
53 {
54 	*ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
55 }
56 
57 //==================================================================================================
component_getFactory(const sal_Char * pImplName,void * pServiceManager,void *)58 void * SAL_CALL component_getFactory(
59 	const sal_Char * pImplName, void * pServiceManager, void * /*pRegistryKey*/ )
60 {
61 	void * pRet = 0;
62 
63 	//Decryptor
64 	OUString implName = OUString::createFromAscii( pImplName );
65 	if ( pServiceManager && implName.equals(DecryptorImpl_getImplementationName()) )
66 	{
67 		Reference< XSingleServiceFactory > xFactory( createSingleFactory(
68 			reinterpret_cast< XMultiServiceFactory * >( pServiceManager ),
69 			OUString::createFromAscii( pImplName ),
70 			DecryptorImpl_createInstance, DecryptorImpl_getSupportedServiceNames() ) );
71 
72 		if (xFactory.is())
73 		{
74 			xFactory->acquire();
75 			pRet = xFactory.get();
76 		}
77 	}
78 
79 	//Encryptor
80 	if ( pServiceManager && implName.equals(EncryptorImpl_getImplementationName()) )
81 	{
82 		Reference< XSingleServiceFactory > xFactory( createSingleFactory(
83 			reinterpret_cast< XMultiServiceFactory * >( pServiceManager ),
84 			OUString::createFromAscii( pImplName ),
85 			EncryptorImpl_createInstance, EncryptorImpl_getSupportedServiceNames() ) );
86 
87 		if (xFactory.is())
88 		{
89 			xFactory->acquire();
90 			pRet = xFactory.get();
91 		}
92 	}
93 
94 	//SignatureCreator
95 	if ( pServiceManager && implName.equals(SignatureCreatorImpl_getImplementationName()) )
96 	{
97 		Reference< XSingleServiceFactory > xFactory( createSingleFactory(
98 			reinterpret_cast< XMultiServiceFactory * >( pServiceManager ),
99 			OUString::createFromAscii( pImplName ),
100 			SignatureCreatorImpl_createInstance, SignatureCreatorImpl_getSupportedServiceNames() ) );
101 
102 		if (xFactory.is())
103 		{
104 			xFactory->acquire();
105 			pRet = xFactory.get();
106 		}
107 	}
108 
109 	//SignatureVerifier
110 	if ( pServiceManager && implName.equals(SignatureVerifierImpl_getImplementationName()) )
111 	{
112 		Reference< XSingleServiceFactory > xFactory( createSingleFactory(
113 			reinterpret_cast< XMultiServiceFactory * >( pServiceManager ),
114 			OUString::createFromAscii( pImplName ),
115 			SignatureVerifierImpl_createInstance, SignatureVerifierImpl_getSupportedServiceNames() ) );
116 
117 		if (xFactory.is())
118 		{
119 			xFactory->acquire();
120 			pRet = xFactory.get();
121 		}
122 	}
123 
124 	//SAXEventKeeper
125 	if ( pServiceManager && implName.equals(SAXEventKeeperImpl_getImplementationName()) )
126 	{
127 		Reference< XSingleServiceFactory > xFactory( createSingleFactory(
128 			reinterpret_cast< XMultiServiceFactory * >( pServiceManager ),
129 			OUString::createFromAscii( pImplName ),
130 			SAXEventKeeperImpl_createInstance, SAXEventKeeperImpl_getSupportedServiceNames() ) );
131 
132 		if (xFactory.is())
133 		{
134 			xFactory->acquire();
135 			pRet = xFactory.get();
136 		}
137 	}
138 
139 	//XMLSignatureTemplate
140 	if ( pServiceManager && implName.equals( XMLSignatureTemplateImpl::impl_getImplementationName()) )
141 	{
142 		Reference< XSingleServiceFactory > xFactory = XMLSignatureTemplateImpl::impl_createFactory(
143 				reinterpret_cast< XMultiServiceFactory* >( pServiceManager ) ) ;
144 
145 		if (xFactory.is())
146 		{
147 			xFactory->acquire();
148 			pRet = xFactory.get();
149 		}
150 	}
151 
152 	//XMLEncryptionTemplate
153 	if ( pServiceManager && implName.equals( XMLEncryptionTemplateImpl::impl_getImplementationName()) )
154 	{
155 		Reference< XSingleServiceFactory > xFactory = XMLEncryptionTemplateImpl::impl_createFactory(
156 				reinterpret_cast< XMultiServiceFactory* >( pServiceManager ) ) ;
157 
158 		if (xFactory.is())
159 		{
160 			xFactory->acquire();
161 			pRet = xFactory.get();
162 		}
163 	}
164 
165 	return pRet;
166 }
167 }
168 
169 
170