1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
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.
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).
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.
26 ************************************************************************/
28 #ifndef _SECURITYENGINE_HXX
29 #define _SECURITYENGINE_HXX
31 #include <com/sun/star/xml/crypto/sax/XReferenceResolvedListener.hpp>
32 #include <com/sun/star/xml/crypto/sax/XReferenceResolvedBroadcaster.hpp>
33 #include <com/sun/star/xml/crypto/sax/XKeyCollector.hpp>
34 #include <com/sun/star/xml/crypto/sax/XMissionTaker.hpp>
35 #include <com/sun/star/xml/crypto/sax/XSAXEventKeeper.hpp>
36 #include <com/sun/star/xml/crypto/XXMLSignature.hpp>
38 #include <cppuhelper/implbase3.hxx>
40 class SecurityEngine
: public cppu::WeakImplHelper3
42 com::sun::star::xml::crypto::sax::XReferenceResolvedListener
,
43 com::sun::star::xml::crypto::sax::XKeyCollector
,
44 com::sun::star::xml::crypto::sax::XMissionTaker
46 /****** securityengine.hxx/CLASS SecurityEngine *******************************
49 * SecurityEngine -- Base class of SignatureEngine and EncryptionEngine
52 * Maintains common members and methods related with security engine
56 * 05.01.2004 - Interface supported: XReferenceResolvedListener,
57 * XKeyCollector, and XMissionTaker
61 * Email: michael.mi@sun.com
62 ******************************************************************************/
65 com::sun::star::uno::Reference
<
66 com::sun::star::lang::XMultiServiceFactory
> mxMSF
;
69 * A SAXEventKeeper internally maintians all resources that a security
70 * operation needs. The m_xSAXEventKeeper member is used to release
71 * those resources when the security operation finishes.
73 com::sun::star::uno::Reference
<
74 com::sun::star::xml::crypto::sax::XSAXEventKeeper
> m_xSAXEventKeeper
;
77 * the id of ElementCollector of the template element.
78 * For a signature, the template element is the Signature element,
79 * for a encryption, the EncryptedData/EncryptedKey element is.
81 sal_Int32 m_nIdOfTemplateEC
;
84 * remembers how many referenced elements have been bufferred completely,
85 * including the key element, template element, and referenced element of
88 sal_Int32 m_nNumOfResolvedReferences
;
91 * the id of ElementCollector of the key element.
92 * If a Signature element or EncryptedData/EncryptedKey element has
93 * an internal key sub-element, then this member should be -1
95 sal_Int32 m_nIdOfKeyEC
;
98 * remembers whether the current opertion has finished.
103 * the Id of the security entity, a signature or encryption, which is used for
104 * the result listener to identify the entity.
106 sal_Int32 m_nSecurityId
;
109 * the status of the operation
111 //bool m_bOperationSucceed;
112 com::sun::star::xml::crypto::SecurityOperationStatus m_nStatus
;
115 * the result listener, which will receives the security operation result.
117 com::sun::star::uno::Reference
<
118 com::sun::star::uno::XInterface
>
122 explicit SecurityEngine( const com::sun::star::uno::Reference
<
123 com::sun::star::lang::XMultiServiceFactory
>& rxMSF
= NULL
);
124 virtual ~SecurityEngine() {};
127 * perform the security operation.
128 * Any derived class will implement this method respectively.
130 virtual void tryToPerform( )
131 throw (com::sun::star::uno::Exception
, com::sun::star::uno::RuntimeException
){};
134 * clear up all resources used by this operation.
135 * This method is called after the operation finishes, or a End-Your-Mission
136 * message is received.
137 * Any derived class will implement this method respectively.
139 virtual void clearUp( ) const {};
142 * notifies any possible result listener.
143 * When verify a signature or conduct a decryption, the operation result will
144 * be transferred to a listener by this method.
145 * Any derived class will implement this method respectively.
147 virtual void notifyResultListener() const
148 throw (com::sun::star::uno::Exception
, com::sun::star::uno::RuntimeException
)
152 * checks whether everything is ready.
153 * Any derived class will implement this method respectively.
155 virtual bool checkReady() const { return true; };
158 /* XReferenceResolvedListener */
159 virtual void SAL_CALL
referenceResolved( sal_Int32 referenceId
)
160 throw (com::sun::star::uno::Exception
, com::sun::star::uno::RuntimeException
);
163 virtual void SAL_CALL
setKeyId( sal_Int32 id
)
164 throw (com::sun::star::uno::Exception
, com::sun::star::uno::RuntimeException
);
167 virtual sal_Bool SAL_CALL
endMission( )
168 throw (com::sun::star::uno::RuntimeException
);