LibreOffice Module xmlsecurity (master) 1
signatureengine.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/XReferenceCollector.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/XUriBinding.hpp>
27
29
30#include <xmlsecuritydllapi.h>
32
33#include <vector>
34
35namespace com::sun::star::io { class XInputStream; }
36namespace com::sun::star::xml::crypto { class XXMLSignature; }
37namespace rtl { template <class reference_type> class Reference; }
38
40
41class SignatureEngine : public cppu::ImplInheritanceHelper
42<
43 SecurityEngine,
44 css::xml::crypto::sax::XReferenceCollector,
45 css::xml::crypto::XUriBinding
46>
47/****** signatureengine.hxx/CLASS SignatureEngine *****************************
48 *
49 * NAME
50 * SignatureEngine -- Base class of SignatureCreator and SignatureVerifier
51 *
52 * FUNCTION
53 * Maintains common members and methods related with signature operation.
54 ******************************************************************************/
55{
56protected:
57
58 /*
59 * the Signature bridge component, which performs signature generation
60 * and verification based on xmlsec library.
61 */
62 css::uno::Reference< css::xml::crypto::XXMLSignature > m_xXMLSignature;
63
64 /*
65 * a collection of ElementCollector's ids. Each ElementCollector
66 * represents one element signed by this signature.
67 */
68 std::vector< sal_Int32 > m_vReferenceIds;
69
70 /*
71 * remembers how many references this signature has.
72 */
74
75 /*
76 * a collection of Uri binding.
77 *
78 * the m_vUris is used to hold the Uri strings, and the m_vXInputStreams is used
79 * to hold corresponding bound XInputStream interface.
80 */
81 std::vector< OUString > m_vUris;
82 std::vector< css::uno::Reference< css::io::XInputStream > > m_vXInputStreams;
83
84protected:
85 explicit SignatureEngine();
86 virtual ~SignatureEngine() override {};
87
88 virtual void tryToPerform( ) override;
89 virtual void clearUp( ) const override;
90 bool checkReady() const;
91
92 /*
93 * starts the main function. This method will be implemented by any sub-class.
94 * For a SignatureCreator, it performs signing operation;
95 * for a SignatureVerifier, verification operation is performed.
96 */
100 {};
101
102public:
103 /* XReferenceCollector */
104 virtual void SAL_CALL setReferenceCount( sal_Int32 count ) override;
105
106 virtual void SAL_CALL setReferenceId( sal_Int32 id ) override;
107
108 /* XUriBinding */
109 virtual void SAL_CALL setUriBinding(
110 const OUString& uri,
111 const css::uno::Reference< css::io::XInputStream >& aInputStream ) override;
112 virtual css::uno::Reference< css::io::XInputStream >
113 SAL_CALL getUriBinding( const OUString& uri ) override;
114};
115
116/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual void clearUp() const override
bool checkReady() const
virtual void tryToPerform() override
virtual void SAL_CALL setReferenceId(sal_Int32 id) override
sal_Int32 m_nTotalReferenceNumber
css::uno::Reference< css::xml::crypto::XXMLSignature > m_xXMLSignature
virtual void startEngine(const rtl::Reference< XMLSignatureTemplateImpl > &)
virtual css::uno::Reference< css::io::XInputStream > SAL_CALL getUriBinding(const OUString &uri) override
std::vector< css::uno::Reference< css::io::XInputStream > > m_vXInputStreams
std::vector< OUString > m_vUris
virtual void SAL_CALL setReferenceCount(sal_Int32 count) override
std::vector< sal_Int32 > m_vReferenceIds
virtual ~SignatureEngine() override
virtual void SAL_CALL setUriBinding(const OUString &uri, const css::uno::Reference< css::io::XInputStream > &aInputStream) override
Reference