1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_XMLSECURITY_SOURCE_FRAMEWORK_SECURITYENGINE_HXX
21 #define INCLUDED_XMLSECURITY_SOURCE_FRAMEWORK_SECURITYENGINE_HXX
23 #include <com/sun/star/xml/crypto/sax/XReferenceResolvedListener.hpp>
24 #include <com/sun/star/xml/crypto/sax/XReferenceResolvedBroadcaster.hpp>
25 #include <com/sun/star/xml/crypto/sax/XKeyCollector.hpp>
26 #include <com/sun/star/xml/crypto/sax/XMissionTaker.hpp>
27 #include <com/sun/star/xml/crypto/sax/XSAXEventKeeper.hpp>
28 #include <com/sun/star/xml/crypto/XXMLSignature.hpp>
30 #include <cppuhelper/implbase3.hxx>
32 class SecurityEngine
: public cppu::WeakImplHelper3
34 com::sun::star::xml::crypto::sax::XReferenceResolvedListener
,
35 com::sun::star::xml::crypto::sax::XKeyCollector
,
36 com::sun::star::xml::crypto::sax::XMissionTaker
38 /****** securityengine.hxx/CLASS SecurityEngine *******************************
41 * SecurityEngine -- Base class of SignatureEngine and EncryptionEngine
44 * Maintains common members and methods related with security engine
49 * Email: michael.mi@sun.com
50 ******************************************************************************/
55 * A SAXEventKeeper internally maintians all resources that a security
56 * operation needs. The m_xSAXEventKeeper member is used to release
57 * those resources when the security operation finishes.
59 com::sun::star::uno::Reference
<
60 com::sun::star::xml::crypto::sax::XSAXEventKeeper
> m_xSAXEventKeeper
;
63 * the id of ElementCollector of the template element.
64 * For a signature, the template element is the Signature element,
65 * for a encryption, the EncryptedData/EncryptedKey element is.
67 sal_Int32 m_nIdOfTemplateEC
;
70 * remembers how many referenced elements have been bufferred completely,
71 * including the key element, template element, and referenced element of
74 sal_Int32 m_nNumOfResolvedReferences
;
77 * the id of ElementCollector of the key element.
78 * If a Signature element or EncryptedData/EncryptedKey element has
79 * an internal key sub-element, then this member should be -1
81 sal_Int32 m_nIdOfKeyEC
;
84 * remembers whether the current opertion has finished.
89 * the Id of the security entity, a signature or encryption, which is used for
90 * the result listener to identify the entity.
92 sal_Int32 m_nSecurityId
;
95 * the status of the operation
97 com::sun::star::xml::crypto::SecurityOperationStatus m_nStatus
;
100 * the result listener, which will receives the security operation result.
102 com::sun::star::uno::Reference
<
103 com::sun::star::uno::XInterface
>
107 explicit SecurityEngine();
108 virtual ~SecurityEngine() {};
111 * perform the security operation.
112 * Any derived class will implement this method respectively.
114 virtual void tryToPerform( )
115 throw (com::sun::star::uno::Exception
, com::sun::star::uno::RuntimeException
){};
118 * clear up all resources used by this operation.
119 * This method is called after the operation finishes, or a End-Your-Mission
120 * message is received.
121 * Any derived class will implement this method respectively.
123 virtual void clearUp( ) const {};
126 * notifies any possible result listener.
127 * When verify a signature or conduct a decryption, the operation result will
128 * be transferred to a listener by this method.
129 * Any derived class will implement this method respectively.
131 virtual void notifyResultListener() const
132 throw (com::sun::star::uno::Exception
, com::sun::star::uno::RuntimeException
)
136 * checks whether everything is ready.
137 * Any derived class will implement this method respectively.
139 virtual bool checkReady() const { return true; };
142 /* XReferenceResolvedListener */
143 virtual void SAL_CALL
referenceResolved( sal_Int32 referenceId
)
144 throw (com::sun::star::uno::Exception
, com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
147 virtual void SAL_CALL
setKeyId( sal_Int32 id
)
148 throw (com::sun::star::uno::Exception
, com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
151 virtual sal_Bool SAL_CALL
endMission( )
152 throw (com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
157 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */