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 .
22 #include <com/sun/star/xml/crypto/sax/XReferenceResolvedListener.hpp>
23 #include <com/sun/star/xml/crypto/sax/XReferenceResolvedBroadcaster.hpp>
24 #include <com/sun/star/xml/crypto/sax/XKeyCollector.hpp>
25 #include <com/sun/star/xml/crypto/sax/XMissionTaker.hpp>
26 #include <com/sun/star/xml/crypto/sax/XSAXEventKeeper.hpp>
27 #include <com/sun/star/xml/crypto/XXMLSignature.hpp>
29 #include <cppuhelper/implbase.hxx>
31 #include <xmlsecuritydllapi.h>
33 class SAL_DLLPUBLIC_RTTI SecurityEngine
: public cppu::WeakImplHelper
35 css::xml::crypto::sax::XReferenceResolvedListener
,
36 css::xml::crypto::sax::XKeyCollector
,
37 css::xml::crypto::sax::XMissionTaker
39 /****** securityengine.hxx/CLASS SecurityEngine *******************************
42 * SecurityEngine -- Base class of SignatureEngine and EncryptionEngine
45 * Maintains common members and methods related with security engine
47 ******************************************************************************/
52 * A SAXEventKeeper internally maintains all resources that a security
53 * operation needs. The m_xSAXEventKeeper member is used to release
54 * those resources when the security operation finishes.
56 css::uno::Reference
< css::xml::crypto::sax::XSAXEventKeeper
> m_xSAXEventKeeper
;
59 * the id of ElementCollector of the template element.
60 * For a signature, the template element is the Signature element,
61 * for an encryption, the EncryptedData/EncryptedKey element is.
63 sal_Int32 m_nIdOfTemplateEC
;
66 * remembers how many referenced elements have been buffered completely,
67 * including the key element, template element, and referenced element of
70 sal_Int32 m_nNumOfResolvedReferences
;
73 * the id of ElementCollector of the key element.
74 * If a Signature element or EncryptedData/EncryptedKey element has
75 * an internal key sub-element, then this member should be -1
77 sal_Int32 m_nIdOfKeyEC
;
80 * remembers whether the current operation has finished.
85 * the Id of the security entity, a signature or encryption, which is used for
86 * the result listener to identify the entity.
88 sal_Int32 m_nSecurityId
;
91 * the status of the operation
93 css::xml::crypto::SecurityOperationStatus m_nStatus
;
96 * the result listener, which will receives the security operation result.
98 css::uno::Reference
< css::uno::XInterface
> m_xResultListener
;
101 explicit SecurityEngine();
102 virtual ~SecurityEngine() override
{};
105 * perform the security operation.
106 * Any derived class will implement this method respectively.
108 /// @throws css::uno::Exception
109 /// @throws css::uno::RuntimeException
110 virtual void tryToPerform( ){};
113 * clear up all resources used by this operation.
114 * This method is called after the operation finishes, or a End-Your-Mission
115 * message is received.
116 * Any derived class will implement this method respectively.
118 virtual void clearUp( ) const {};
121 * notifies any possible result listener.
122 * When verify a signature or conduct a decryption, the operation result will
123 * be transferred to a listener by this method.
124 * Any derived class will implement this method respectively.
126 /// @throws css::uno::Exception
127 /// @throws css::uno::RuntimeException
128 virtual void notifyResultListener() const
132 /* XReferenceResolvedListener */
133 virtual void SAL_CALL
referenceResolved( sal_Int32 referenceId
) override
;
136 virtual void SAL_CALL
setKeyId( sal_Int32 id
) override
;
139 virtual sal_Bool SAL_CALL
endMission( ) override
;
142 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */