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 #ifndef _SIGNATURECREATORIMPL_HXX
29 #define _SIGNATURECREATORIMPL_HXX
30 
31 #include <com/sun/star/xml/crypto/sax/XBlockerMonitor.hpp>
32 #include <com/sun/star/xml/crypto/sax/XSignatureCreationResultListener.hpp>
33 #include <com/sun/star/xml/crypto/sax/XSignatureCreationResultBroadcaster.hpp>
34 #include <com/sun/star/xml/crypto/XSecurityEnvironment.hpp>
35 #include <com/sun/star/lang/XInitialization.hpp>
36 #include <com/sun/star/lang/XServiceInfo.hpp>
37 #include <cppuhelper/implbase4.hxx>
38 
39 #include "signatureengine.hxx"
40 
41 class SignatureCreatorImpl : public cppu::ImplInheritanceHelper4
42 <
43 	SignatureEngine,
44 	com::sun::star::xml::crypto::sax::XBlockerMonitor,
45 	com::sun::star::xml::crypto::sax::XSignatureCreationResultBroadcaster,
46 	com::sun::star::lang::XInitialization,
47 	com::sun::star::lang::XServiceInfo
48 >
49 /****** SignatureCreatorImpl.hxx/CLASS SignatureCreatorImpl *******************
50  *
51  *   NAME
52  *	SignatureCreatorImpl -- generates a signature
53  *
54  *   FUNCTION
55  *	Collects all resources for a signature generation, then generates the
56  *	signature by invoking a xmlsec-based signature bridge component.
57  *
58  *   HISTORY
59  *	05.01.2004 -	Interface supported: XBlockerMonitor,
60  * 			XInitialization, XServiceInfo
61  *
62  *   AUTHOR
63  *	Michael Mi
64  *	Email: michael.mi@sun.com
65  ******************************************************************************/
66 {
67 private:
68 	/*
69 	 * the Id of the signature, which is used for the result listener to
70 	 * identify the signature.
71 	 */
72 	sal_Int32 m_nSignatureId;
73 
74 	/*
75 	 * the Id of template blocker.
76 	 */
77 	sal_Int32 m_nIdOfBlocker;
78 
79 	/*
80 	 * the signature creation result
81 	 */
82 	bool      m_bCreationSucceed;
83 
84 	com::sun::star::uno::Reference<
85 		com::sun::star::xml::crypto::XSecurityEnvironment > m_xSecurityEnvironment;
86 
87 	virtual void notifyResultListener() const
88 		throw (com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException);
89 	virtual void clearUp( ) const;
90 	virtual bool checkReady() const;
91 	virtual void startEngine( const com::sun::star::uno::Reference<
92 		com::sun::star::xml::crypto::XXMLSignatureTemplate >&
93 		xSignatureTemplate)
94 		throw (com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException);
95 
96 public:
97 	explicit SignatureCreatorImpl( const com::sun::star::uno::Reference<
98 		com::sun::star::lang::XMultiServiceFactory >& rxMSF);
99 	virtual ~SignatureCreatorImpl();
100 
101 	/* XBlockerMonitor */
102 	virtual void SAL_CALL setBlockerId( sal_Int32 id )
103     		throw (com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException);
104 
105 	/* XSignatureCreationResultBroadcaster */
106 	void SAL_CALL addSignatureCreationResultListener(
107 		const com::sun::star::uno::Reference<
108 			com::sun::star::xml::crypto::sax::XSignatureCreationResultListener >& listener )
109 		throw (com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException);
110 
111 	void SAL_CALL removeSignatureCreationResultListener(
112 		const com::sun::star::uno::Reference<
113 			com::sun::star::xml::crypto::sax::XSignatureCreationResultListener >& listener )
114 		throw (com::sun::star::uno::RuntimeException);
115 
116 	/* XInitialization */
117 	virtual void SAL_CALL initialize(
118 		const com::sun::star::uno::Sequence< com::sun::star::uno::Any >& aArguments )
119 		throw (com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException);
120 
121 	/* XServiceInfo */
122 	virtual rtl::OUString SAL_CALL getImplementationName(  )
123 		throw (com::sun::star::uno::RuntimeException);
124 	virtual sal_Bool SAL_CALL supportsService( const rtl::OUString& ServiceName )
125 		throw (com::sun::star::uno::RuntimeException);
126 	virtual com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames(  )
127 		throw (com::sun::star::uno::RuntimeException);
128 };
129 
130 rtl::OUString SignatureCreatorImpl_getImplementationName()
131 	throw ( com::sun::star::uno::RuntimeException );
132 
133 sal_Bool SAL_CALL SignatureCreatorImpl_supportsService( const rtl::OUString& ServiceName )
134 	throw ( com::sun::star::uno::RuntimeException );
135 
136 com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL SignatureCreatorImpl_getSupportedServiceNames(  )
137 	throw ( com::sun::star::uno::RuntimeException );
138 
139 com::sun::star::uno::Reference< com::sun::star::uno::XInterface >
140 SAL_CALL SignatureCreatorImpl_createInstance(
141 	const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > & rSMgr)
142 	throw ( com::sun::star::uno::Exception );
143 
144 #endif
145 
146 
147 
148