1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
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.
14  *
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).
20  *
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.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_xmlsecurity.hxx"
30 
31 #include <stdio.h>
32 
33 #include <osl/mutex.hxx>
34 #include <osl/thread.h>
35 #include <cppuhelper/factory.hxx>
36 #include <com/sun/star/lang/XSingleServiceFactory.hpp>
37 
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>
45 
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;
51 
52 extern "C"
53 {
54 //==================================================================================================
55 void SAL_CALL component_getImplementationEnvironment(
56 	const sal_Char ** ppEnvTypeName, uno_Environment **)
57 {
58 	*ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
59 }
60 
61 //==================================================================================================
62 void * SAL_CALL component_getFactory(
63 	const sal_Char * pImplName, void * pServiceManager, void * /*pRegistryKey*/ )
64 {
65 	void * pRet = 0;
66 
67 	//Decryptor
68 	OUString implName = OUString::createFromAscii( pImplName );
69 	if ( pServiceManager && implName.equals(DecryptorImpl_getImplementationName()) )
70 	{
71 		Reference< XSingleServiceFactory > xFactory( createSingleFactory(
72 			reinterpret_cast< XMultiServiceFactory * >( pServiceManager ),
73 			OUString::createFromAscii( pImplName ),
74 			DecryptorImpl_createInstance, DecryptorImpl_getSupportedServiceNames() ) );
75 
76 		if (xFactory.is())
77 		{
78 			xFactory->acquire();
79 			pRet = xFactory.get();
80 		}
81 	}
82 
83 	//Encryptor
84 	if ( pServiceManager && implName.equals(EncryptorImpl_getImplementationName()) )
85 	{
86 		Reference< XSingleServiceFactory > xFactory( createSingleFactory(
87 			reinterpret_cast< XMultiServiceFactory * >( pServiceManager ),
88 			OUString::createFromAscii( pImplName ),
89 			EncryptorImpl_createInstance, EncryptorImpl_getSupportedServiceNames() ) );
90 
91 		if (xFactory.is())
92 		{
93 			xFactory->acquire();
94 			pRet = xFactory.get();
95 		}
96 	}
97 
98 	//SignatureCreator
99 	if ( pServiceManager && implName.equals(SignatureCreatorImpl_getImplementationName()) )
100 	{
101 		Reference< XSingleServiceFactory > xFactory( createSingleFactory(
102 			reinterpret_cast< XMultiServiceFactory * >( pServiceManager ),
103 			OUString::createFromAscii( pImplName ),
104 			SignatureCreatorImpl_createInstance, SignatureCreatorImpl_getSupportedServiceNames() ) );
105 
106 		if (xFactory.is())
107 		{
108 			xFactory->acquire();
109 			pRet = xFactory.get();
110 		}
111 	}
112 
113 	//SignatureVerifier
114 	if ( pServiceManager && implName.equals(SignatureVerifierImpl_getImplementationName()) )
115 	{
116 		Reference< XSingleServiceFactory > xFactory( createSingleFactory(
117 			reinterpret_cast< XMultiServiceFactory * >( pServiceManager ),
118 			OUString::createFromAscii( pImplName ),
119 			SignatureVerifierImpl_createInstance, SignatureVerifierImpl_getSupportedServiceNames() ) );
120 
121 		if (xFactory.is())
122 		{
123 			xFactory->acquire();
124 			pRet = xFactory.get();
125 		}
126 	}
127 
128 	//SAXEventKeeper
129 	if ( pServiceManager && implName.equals(SAXEventKeeperImpl_getImplementationName()) )
130 	{
131 		Reference< XSingleServiceFactory > xFactory( createSingleFactory(
132 			reinterpret_cast< XMultiServiceFactory * >( pServiceManager ),
133 			OUString::createFromAscii( pImplName ),
134 			SAXEventKeeperImpl_createInstance, SAXEventKeeperImpl_getSupportedServiceNames() ) );
135 
136 		if (xFactory.is())
137 		{
138 			xFactory->acquire();
139 			pRet = xFactory.get();
140 		}
141 	}
142 
143 	//XMLSignatureTemplate
144 	if ( pServiceManager && implName.equals( XMLSignatureTemplateImpl::impl_getImplementationName()) )
145 	{
146 		Reference< XSingleServiceFactory > xFactory = XMLSignatureTemplateImpl::impl_createFactory(
147 				reinterpret_cast< XMultiServiceFactory* >( pServiceManager ) ) ;
148 
149 		if (xFactory.is())
150 		{
151 			xFactory->acquire();
152 			pRet = xFactory.get();
153 		}
154 	}
155 
156 	//XMLEncryptionTemplate
157 	if ( pServiceManager && implName.equals( XMLEncryptionTemplateImpl::impl_getImplementationName()) )
158 	{
159 		Reference< XSingleServiceFactory > xFactory = XMLEncryptionTemplateImpl::impl_createFactory(
160 				reinterpret_cast< XMultiServiceFactory* >( pServiceManager ) ) ;
161 
162 		if (xFactory.is())
163 		{
164 			xFactory->acquire();
165 			pRet = xFactory.get();
166 		}
167 	}
168 
169 	return pRet;
170 }
171 }
172 
173 
174