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 _SIGNATUREVERIFIERIMPL_HXX
25 #define _SIGNATUREVERIFIERIMPL_HXX
26 
27 #include <com/sun/star/xml/crypto/sax/XSignatureVerifyResultListener.hpp>
28 #include <com/sun/star/xml/crypto/sax/XSignatureVerifyResultBroadcaster.hpp>
29 #include <com/sun/star/xml/crypto/XXMLSecurityContext.hpp>
30 #include <com/sun/star/lang/XInitialization.hpp>
31 #include <com/sun/star/lang/XServiceInfo.hpp>
32 #include <cppuhelper/implbase3.hxx>
33 
34 #include "signatureengine.hxx"
35 
36 class SignatureVerifierImpl : public cppu::ImplInheritanceHelper3
37 <
38 	SignatureEngine,
39 	com::sun::star::xml::crypto::sax::XSignatureVerifyResultBroadcaster,
40 	com::sun::star::lang::XInitialization,
41 	com::sun::star::lang::XServiceInfo
42 >
43 /****** SignatureVerifier.hxx/CLASS SignatureVerifierImpl *********************
44  *
45  *   NAME
46  *	SignatureVerifierImpl -- verifies a signature
47  *
48  *   FUNCTION
49  *	Collects all resources for a signature verification, then verifies the
50  *	signature by invoking a xmlsec-based signature bridge component.
51  *
52  *   HISTORY
53  *	05.01.2004 -	Interface supported: XSignatureVerifyResultBroadcaster,
54  * 			XInitialization, XServiceInfo
55  *
56  *   AUTHOR
57  *	Michael Mi
58  *	Email: michael.mi@sun.com
59  ******************************************************************************/
60 {
61 private:
62 	/*
63 	 * the Id of the signature, which is used for the result listener to
64 	 * identify the signature.
65 	 */
66 	sal_Int32 m_nSignatureId;
67 
68 	/*
69 	 * the verify result
70 	 */
71 	bool      m_bVerifySucceed;
72 
73 	com::sun::star::uno::Reference<
74 		com::sun::star::xml::crypto::XXMLSecurityContext > m_xXMLSecurityContext;
75 
76 	virtual void notifyResultListener() const
77 		throw (com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException);
78 	virtual bool checkReady() const;
79 	virtual void startEngine( const com::sun::star::uno::Reference<
80 		com::sun::star::xml::crypto::XXMLSignatureTemplate >&
81 		xSignatureTemplate)
82 		throw (com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException);
83 
84 public:
85 	explicit SignatureVerifierImpl( const com::sun::star::uno::Reference<
86 		com::sun::star::lang::XMultiServiceFactory >& rxMSF);
87 	virtual ~SignatureVerifierImpl();
88 
89 	/* XSignatureVerifyResultBroadcaster */
90 	virtual void SAL_CALL addSignatureVerifyResultListener(
91 		const com::sun::star::uno::Reference<
92 			com::sun::star::xml::crypto::sax::XSignatureVerifyResultListener >&
93 			listener )
94 		throw (com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException);
95 	virtual void SAL_CALL removeSignatureVerifyResultListener(
96 		const com::sun::star::uno::Reference<
97 			com::sun::star::xml::crypto::sax::XSignatureVerifyResultListener >&
98 			listener )
99 		throw (com::sun::star::uno::RuntimeException);
100 
101 	/* XInitialization */
102 	virtual void SAL_CALL initialize(
103 		const com::sun::star::uno::Sequence< com::sun::star::uno::Any >& aArguments )
104 		throw (com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException);
105 
106 	/* XServiceInfo */
107 	virtual rtl::OUString SAL_CALL getImplementationName(  )
108 		throw (com::sun::star::uno::RuntimeException);
109 	virtual sal_Bool SAL_CALL supportsService( const rtl::OUString& ServiceName )
110 		throw (com::sun::star::uno::RuntimeException);
111 	virtual com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames(  )
112 		throw (com::sun::star::uno::RuntimeException);
113 };
114 
115 rtl::OUString SignatureVerifierImpl_getImplementationName()
116 	throw ( com::sun::star::uno::RuntimeException );
117 
118 sal_Bool SAL_CALL SignatureVerifierImpl_supportsService( const rtl::OUString& ServiceName )
119 	throw ( com::sun::star::uno::RuntimeException );
120 
121 com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL SignatureVerifierImpl_getSupportedServiceNames(  )
122 	throw ( com::sun::star::uno::RuntimeException );
123 
124 com::sun::star::uno::Reference< com::sun::star::uno::XInterface >
125 SAL_CALL SignatureVerifierImpl_createInstance(
126 	const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > & rSMgr)
127 	throw ( com::sun::star::uno::Exception );
128 
129 #endif
130 
131 
132