LibreOffice Module xmlsecurity (master) 1
securityengine.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#pragma once
21
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>
28
30
31#include <xmlsecuritydllapi.h>
32
33class SAL_DLLPUBLIC_RTTI SecurityEngine : public cppu::WeakImplHelper
34<
35 css::xml::crypto::sax::XReferenceResolvedListener,
36 css::xml::crypto::sax::XKeyCollector,
37 css::xml::crypto::sax::XMissionTaker
38>
39/****** securityengine.hxx/CLASS SecurityEngine *******************************
40 *
41 * NAME
42 * SecurityEngine -- Base class of SignatureEngine and EncryptionEngine
43 *
44 * FUNCTION
45 * Maintains common members and methods related with security engine
46 * operation.
47 ******************************************************************************/
48{
49protected:
50
51 /*
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.
55 */
56 css::uno::Reference< css::xml::crypto::sax::XSAXEventKeeper > m_xSAXEventKeeper;
57
58 /*
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.
62 */
64
65 /*
66 * remembers how many referenced elements have been buffered completely,
67 * including the key element, template element, and referenced element of
68 * signature.
69 */
71
72 /*
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
76 */
77 sal_Int32 m_nIdOfKeyEC;
78
79 /*
80 * remembers whether the current operation has finished.
81 */
83
84 /*
85 * the Id of the security entity, a signature or encryption, which is used for
86 * the result listener to identify the entity.
87 */
88 sal_Int32 m_nSecurityId;
89
90 /*
91 * the status of the operation
92 */
93 css::xml::crypto::SecurityOperationStatus m_nStatus;
94
95 /*
96 * the result listener, which will receives the security operation result.
97 */
98 css::uno::Reference< css::uno::XInterface > m_xResultListener;
99
100protected:
101 explicit SecurityEngine();
102 virtual ~SecurityEngine() override {};
103
104 /*
105 * perform the security operation.
106 * Any derived class will implement this method respectively.
107 */
110 virtual void tryToPerform( ){};
111
112 /*
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.
117 */
118 virtual void clearUp( ) const {};
119
120 /*
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.
125 */
128 virtual void notifyResultListener() const
129 {};
130
131public:
132 /* XReferenceResolvedListener */
133 virtual void SAL_CALL referenceResolved( sal_Int32 referenceId ) override;
134
135 /* XKeyCollector */
136 virtual void SAL_CALL setKeyId( sal_Int32 id ) override;
137
138 /* XMissionTaker */
139 virtual sal_Bool SAL_CALL endMission( ) override;
140};
141
142/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_Int32 m_nIdOfKeyEC
sal_Int32 m_nNumOfResolvedReferences
css::xml::crypto::SecurityOperationStatus m_nStatus
virtual void notifyResultListener() const
virtual ~SecurityEngine() override
css::uno::Reference< css::uno::XInterface > m_xResultListener
virtual void clearUp() const
sal_Int32 m_nIdOfTemplateEC
virtual void tryToPerform()
css::uno::Reference< css::xml::crypto::sax::XSAXEventKeeper > m_xSAXEventKeeper
sal_Int32 m_nSecurityId
unsigned char sal_Bool