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