Update ooo320-m1
[ooovba.git] / xmlsecurity / source / framework / securityengine.hxx
blob5a30261b55818b3e43b9e4e972a6dd0fcbc14375
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: securityengine.hxx,v $
10 * $Revision: 1.5 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _SECURITYENGINE_HXX
32 #define _SECURITYENGINE_HXX
34 #include <com/sun/star/xml/crypto/sax/XReferenceResolvedListener.hpp>
35 #include <com/sun/star/xml/crypto/sax/XReferenceResolvedBroadcaster.hpp>
36 #include <com/sun/star/xml/crypto/sax/XKeyCollector.hpp>
37 #include <com/sun/star/xml/crypto/sax/XMissionTaker.hpp>
38 #include <com/sun/star/xml/crypto/sax/XSAXEventKeeper.hpp>
39 #include <com/sun/star/xml/crypto/XXMLSignature.hpp>
41 #include <cppuhelper/implbase3.hxx>
43 class SecurityEngine : public cppu::WeakImplHelper3
45 com::sun::star::xml::crypto::sax::XReferenceResolvedListener,
46 com::sun::star::xml::crypto::sax::XKeyCollector,
47 com::sun::star::xml::crypto::sax::XMissionTaker
49 /****** securityengine.hxx/CLASS SecurityEngine *******************************
51 * NAME
52 * SecurityEngine -- Base class of SignatureEngine and EncryptionEngine
54 * FUNCTION
55 * Maintains common members and methods related with security engine
56 * operation.
58 * HISTORY
59 * 05.01.2004 - Interface supported: XReferenceResolvedListener,
60 * XKeyCollector, and XMissionTaker
62 * AUTHOR
63 * Michael Mi
64 * Email: michael.mi@sun.com
65 ******************************************************************************/
67 protected:
68 com::sun::star::uno::Reference<
69 com::sun::star::lang::XMultiServiceFactory > mxMSF;
72 * A SAXEventKeeper internally maintians all resources that a security
73 * operation needs. The m_xSAXEventKeeper member is used to release
74 * those resources when the security operation finishes.
76 com::sun::star::uno::Reference<
77 com::sun::star::xml::crypto::sax::XSAXEventKeeper > m_xSAXEventKeeper;
80 * the id of ElementCollector of the template element.
81 * For a signature, the template element is the Signature element,
82 * for a encryption, the EncryptedData/EncryptedKey element is.
83 */
84 sal_Int32 m_nIdOfTemplateEC;
87 * remembers how many referenced elements have been bufferred completely,
88 * including the key element, template element, and referenced element of
89 * signature.
91 sal_Int32 m_nNumOfResolvedReferences;
94 * the id of ElementCollector of the key element.
95 * If a Signature element or EncryptedData/EncryptedKey element has
96 * an internal key sub-element, then this member should be -1
98 sal_Int32 m_nIdOfKeyEC;
101 * remembers whether the current opertion has finished.
103 bool m_bMissionDone;
106 * the Id of the security entity, a signature or encryption, which is used for
107 * the result listener to identify the entity.
109 sal_Int32 m_nSecurityId;
112 * the status of the operation
114 //bool m_bOperationSucceed;
115 com::sun::star::xml::crypto::SecurityOperationStatus m_nStatus;
118 * the result listener, which will receives the security operation result.
120 com::sun::star::uno::Reference<
121 com::sun::star::uno::XInterface >
122 m_xResultListener;
124 protected:
125 explicit SecurityEngine( const com::sun::star::uno::Reference<
126 com::sun::star::lang::XMultiServiceFactory >& rxMSF = NULL );
127 virtual ~SecurityEngine() {};
130 * perform the security operation.
131 * Any derived class will implement this method respectively.
133 virtual void tryToPerform( )
134 throw (com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException){};
137 * clear up all resources used by this operation.
138 * This method is called after the operation finishes, or a End-Your-Mission
139 * message is received.
140 * Any derived class will implement this method respectively.
142 virtual void clearUp( ) const {};
145 * notifies any possible result listener.
146 * When verify a signature or conduct a decryption, the operation result will
147 * be transferred to a listener by this method.
148 * Any derived class will implement this method respectively.
150 virtual void notifyResultListener() const
151 throw (com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException)
155 * checks whether everything is ready.
156 * Any derived class will implement this method respectively.
158 virtual bool checkReady() const { return true; };
160 public:
161 /* XReferenceResolvedListener */
162 virtual void SAL_CALL referenceResolved( sal_Int32 referenceId )
163 throw (com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException);
165 /* XKeyCollector */
166 virtual void SAL_CALL setKeyId( sal_Int32 id )
167 throw (com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException);
169 /* XMissionTaker */
170 virtual sal_Bool SAL_CALL endMission( )
171 throw (com::sun::star::uno::RuntimeException);
174 #endif