xref: /AOO41X/main/xmlsecurity/source/framework/signatureengine.hxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir #ifndef _SIGNATUREENGINE_HXX
29*cdf0e10cSrcweir #define _SIGNATUREENGINE_HXX
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include <com/sun/star/xml/crypto/sax/XReferenceResolvedListener.hpp>
32*cdf0e10cSrcweir #include <com/sun/star/xml/crypto/sax/XReferenceResolvedBroadcaster.hpp>
33*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_XML_CRYPTO_SAX_XSIGNATURECOLLECTOR_HPP_
34*cdf0e10cSrcweir #include <com/sun/star/xml/crypto/sax/XReferenceCollector.hpp>
35*cdf0e10cSrcweir #endif
36*cdf0e10cSrcweir #include <com/sun/star/xml/crypto/sax/XKeyCollector.hpp>
37*cdf0e10cSrcweir #include <com/sun/star/xml/crypto/sax/XMissionTaker.hpp>
38*cdf0e10cSrcweir #include <com/sun/star/xml/crypto/sax/XSAXEventKeeper.hpp>
39*cdf0e10cSrcweir #include <com/sun/star/xml/crypto/XXMLSecurityContext.hpp>
40*cdf0e10cSrcweir #include <com/sun/star/xml/crypto/XXMLSignature.hpp>
41*cdf0e10cSrcweir #include <com/sun/star/xml/crypto/XUriBinding.hpp>
42*cdf0e10cSrcweir #include <com/sun/star/io/XInputStream.hpp>
43*cdf0e10cSrcweir 
44*cdf0e10cSrcweir #include <cppuhelper/implbase2.hxx>
45*cdf0e10cSrcweir 
46*cdf0e10cSrcweir #include "securityengine.hxx"
47*cdf0e10cSrcweir 
48*cdf0e10cSrcweir #ifndef INCLUDED_VECTOR
49*cdf0e10cSrcweir #include <vector>
50*cdf0e10cSrcweir #define INCLUDED_VECTOR
51*cdf0e10cSrcweir #endif
52*cdf0e10cSrcweir 
53*cdf0e10cSrcweir class SignatureEngine : public cppu::ImplInheritanceHelper2
54*cdf0e10cSrcweir <
55*cdf0e10cSrcweir 	SecurityEngine,
56*cdf0e10cSrcweir 	com::sun::star::xml::crypto::sax::XReferenceCollector,
57*cdf0e10cSrcweir 	com::sun::star::xml::crypto::XUriBinding
58*cdf0e10cSrcweir >
59*cdf0e10cSrcweir /****** signatureengine.hxx/CLASS SignatureEngine *****************************
60*cdf0e10cSrcweir  *
61*cdf0e10cSrcweir  *   NAME
62*cdf0e10cSrcweir  *	SignatureEngine -- Base class of SignatureCreator and SignatureVerifier
63*cdf0e10cSrcweir  *
64*cdf0e10cSrcweir  *   FUNCTION
65*cdf0e10cSrcweir  *	Maintains common members and methods related with signature operation.
66*cdf0e10cSrcweir  *
67*cdf0e10cSrcweir  *   HISTORY
68*cdf0e10cSrcweir  *	05.01.2004 -	Interface supported: XReferenceCollector
69*cdf0e10cSrcweir  *
70*cdf0e10cSrcweir  *   AUTHOR
71*cdf0e10cSrcweir  *	Michael Mi
72*cdf0e10cSrcweir  *	Email: michael.mi@sun.com
73*cdf0e10cSrcweir  ******************************************************************************/
74*cdf0e10cSrcweir {
75*cdf0e10cSrcweir protected:
76*cdf0e10cSrcweir 
77*cdf0e10cSrcweir 	/*
78*cdf0e10cSrcweir 	 * the Signature bridge component, which performs signature generation
79*cdf0e10cSrcweir 	 * and verification based on xmlsec library.
80*cdf0e10cSrcweir 	 */
81*cdf0e10cSrcweir 	com::sun::star::uno::Reference<
82*cdf0e10cSrcweir 		com::sun::star::xml::crypto::XXMLSignature > m_xXMLSignature;
83*cdf0e10cSrcweir 
84*cdf0e10cSrcweir 	/*
85*cdf0e10cSrcweir 	 * a collection of ElementCollector's ids. Each ElementCollector
86*cdf0e10cSrcweir 	 * represents one element signed by this signature.
87*cdf0e10cSrcweir 	 */
88*cdf0e10cSrcweir 	std::vector< sal_Int32 > m_vReferenceIds;
89*cdf0e10cSrcweir 
90*cdf0e10cSrcweir 	/*
91*cdf0e10cSrcweir 	 * remembers how many references this signature has.
92*cdf0e10cSrcweir 	 */
93*cdf0e10cSrcweir 	sal_Int32 m_nTotalReferenceNumber;
94*cdf0e10cSrcweir 
95*cdf0e10cSrcweir 	/*
96*cdf0e10cSrcweir 	 * a collection of Uri binding.
97*cdf0e10cSrcweir 	 *
98*cdf0e10cSrcweir 	 * the m_vUris is used to hold the Uri strings, and the m_vXInputStreams is used
99*cdf0e10cSrcweir 	 * to hold corresponding binded XInputStream interface.
100*cdf0e10cSrcweir 	 */
101*cdf0e10cSrcweir 	std::vector< rtl::OUString > m_vUris;
102*cdf0e10cSrcweir 	std::vector< com::sun::star::uno::Reference<
103*cdf0e10cSrcweir 		com::sun::star::io::XInputStream > > m_vXInputStreams;
104*cdf0e10cSrcweir 
105*cdf0e10cSrcweir protected:
106*cdf0e10cSrcweir 	SignatureEngine( );
107*cdf0e10cSrcweir 	virtual ~SignatureEngine() {};
108*cdf0e10cSrcweir 
109*cdf0e10cSrcweir 	virtual void tryToPerform( )
110*cdf0e10cSrcweir 		throw (com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException);
111*cdf0e10cSrcweir 	virtual void clearUp( ) const;
112*cdf0e10cSrcweir 	virtual bool checkReady() const;
113*cdf0e10cSrcweir 
114*cdf0e10cSrcweir 	/*
115*cdf0e10cSrcweir 	 * starts the main function. This method will be implemented by any sub-class.
116*cdf0e10cSrcweir 	 * For a SignatureCreator, it performs signing operation;
117*cdf0e10cSrcweir 	 * for a SignatureVerifier, verification operation is performed.
118*cdf0e10cSrcweir 	 */
119*cdf0e10cSrcweir 	virtual void startEngine( const com::sun::star::uno::Reference<
120*cdf0e10cSrcweir                               com::sun::star::xml::crypto::XXMLSignatureTemplate >&)
121*cdf0e10cSrcweir 		throw (com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException)
122*cdf0e10cSrcweir 		{};
123*cdf0e10cSrcweir 
124*cdf0e10cSrcweir public:
125*cdf0e10cSrcweir 	/* XReferenceCollector */
126*cdf0e10cSrcweir 	virtual void SAL_CALL setReferenceCount( sal_Int32 count )
127*cdf0e10cSrcweir 		throw (com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException);
128*cdf0e10cSrcweir 
129*cdf0e10cSrcweir 	virtual void SAL_CALL setReferenceId( sal_Int32 id )
130*cdf0e10cSrcweir 		throw (com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException);
131*cdf0e10cSrcweir 
132*cdf0e10cSrcweir 	/* XUriBinding */
133*cdf0e10cSrcweir 	virtual void SAL_CALL setUriBinding(
134*cdf0e10cSrcweir 		const rtl::OUString& uri,
135*cdf0e10cSrcweir 		const com::sun::star::uno::Reference<
136*cdf0e10cSrcweir 			com::sun::star::io::XInputStream >& aInputStream )
137*cdf0e10cSrcweir 		throw (com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException);
138*cdf0e10cSrcweir 	virtual com::sun::star::uno::Reference< com::sun::star::io::XInputStream >
139*cdf0e10cSrcweir 		SAL_CALL getUriBinding( const rtl::OUString& uri )
140*cdf0e10cSrcweir 		throw (com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException);
141*cdf0e10cSrcweir };
142*cdf0e10cSrcweir 
143*cdf0e10cSrcweir #endif
144*cdf0e10cSrcweir 
145