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 #ifndef _ENCRYPTORIMPL_HXX
25 #define _ENCRYPTORIMPL_HXX
26 
27 #include <com/sun/star/xml/crypto/sax/XEncryptionResultBroadcaster.hpp>
28 #include <com/sun/star/xml/crypto/sax/XEncryptionResultListener.hpp>
29 #ifndef _COM_SUN_STAR_XML_CRYPTO_SAX_XSIGNATURECOLLECTOR_HPP_
30 #include <com/sun/star/xml/crypto/sax/XReferenceCollector.hpp>
31 #endif
32 #include <com/sun/star/xml/crypto/XSecurityEnvironment.hpp>
33 #include <com/sun/star/lang/XInitialization.hpp>
34 #include <com/sun/star/lang/XServiceInfo.hpp>
35 #include <cppuhelper/implbase4.hxx>
36 
37 #include "encryptionengine.hxx"
38 
39 class EncryptorImpl : public cppu::ImplInheritanceHelper4
40 <
41 	EncryptionEngine,
42 	com::sun::star::xml::crypto::sax::XEncryptionResultBroadcaster,
43 	com::sun::star::xml::crypto::sax::XReferenceCollector,
44 	com::sun::star::lang::XInitialization,
45 	com::sun::star::lang::XServiceInfo
46 >
47 /****** EncryptorImpl.hxx/CLASS EncryptorImpl *********************************
48  *
49  *   NAME
50  *	EncryptorImpl -- generates an encryption
51  *
52  *   FUNCTION
53  *	Collects all resources for an encryption generation, then generates the
54  *	encryption by invoking a xmlsec-based encryption bridge component.
55  *
56  *   HISTORY
57  *	05.01.2004 -	Interface supported: XInitialization, XServiceInfo
58  *
59  *   AUTHOR
60  *	Michael Mi
61  *	Email: michael.mi@sun.com
62  ******************************************************************************/
63 {
64 private:
65 	/*
66 	 * the Id of the encryption, which is used for the result listener to
67 	 * identify the encryption.
68 	 */
69 	sal_Int32 m_nEncryptionId;
70 
71 	/*
72 	 * the Id of the element to be encrypted.
73 	 */
74 	sal_Int32 m_nReferenceId;
75 
76 	/*
77 	 * the decryption result,
78 	 * remembers whether the encryption succeeds.
79 	 */
80 	bool      m_bEncryptionSucceed;
81 
82 	com::sun::star::uno::Reference<
83 		com::sun::star::xml::crypto::XSecurityEnvironment > m_xSecurityEnvironment;
84 
85 	virtual void notifyResultListener() const
86 		throw (com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException);
87 	virtual bool checkReady() const;
88 	virtual void startEngine( const com::sun::star::uno::Reference<
89 		com::sun::star::xml::crypto::XXMLEncryptionTemplate >&
90 		xEncryptionTemplate)
91 		throw (com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException);
92 
93 public:
94 	explicit EncryptorImpl( const com::sun::star::uno::Reference<
95 		com::sun::star::lang::XMultiServiceFactory >& rxMSF);
96 	virtual ~EncryptorImpl();
97 
98 	/* XEncryptionResultBroadcaster */
99 	virtual void SAL_CALL addEncryptionResultListener(
100 		const com::sun::star::uno::Reference<
101 			com::sun::star::xml::crypto::sax::XEncryptionResultListener >&
102 			listener )
103     		throw (com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException);
104     	virtual void SAL_CALL removeEncryptionResultListener(
105     		const com::sun::star::uno::Reference<
106     			com::sun::star::xml::crypto::sax::XEncryptionResultListener >&
107     			listener )
108     		throw (com::sun::star::uno::RuntimeException);
109 
110 	/* XReferenceCollector */
111 	virtual void SAL_CALL setReferenceCount( sal_Int32 count )
112 		throw (com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException);
113 
114 	virtual void SAL_CALL setReferenceId( sal_Int32 id )
115 		throw (com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException);
116 
117 	/* XInitialization */
118 	virtual void SAL_CALL initialize(
119 		const com::sun::star::uno::Sequence< com::sun::star::uno::Any >& aArguments )
120 		throw (com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException);
121 
122 	/* XServiceInfo */
123 	virtual rtl::OUString SAL_CALL getImplementationName(  )
124 		throw (com::sun::star::uno::RuntimeException);
125 	virtual sal_Bool SAL_CALL supportsService( const rtl::OUString& ServiceName )
126 		throw (com::sun::star::uno::RuntimeException);
127 	virtual com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames(  )
128 		throw (com::sun::star::uno::RuntimeException);
129 };
130 
131 rtl::OUString EncryptorImpl_getImplementationName()
132 	throw ( com::sun::star::uno::RuntimeException );
133 
134 sal_Bool SAL_CALL EncryptorImpl_supportsService( const rtl::OUString& ServiceName )
135 	throw ( com::sun::star::uno::RuntimeException );
136 
137 com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL EncryptorImpl_getSupportedServiceNames(  )
138 	throw ( com::sun::star::uno::RuntimeException );
139 
140 com::sun::star::uno::Reference< com::sun::star::uno::XInterface >
141 SAL_CALL EncryptorImpl_createInstance(
142 	const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& rSMgr)
143 	throw ( com::sun::star::uno::Exception );
144 
145 #endif
146 
147