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/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>
28 #include <cppuhelper/implbase.hxx>
30 #include <xmlsecuritydllapi.h>
31 #include <framework/securityengine.hxx>
35 namespace com::sun::star::io
{ class XInputStream
; }
36 namespace com::sun::star::xml::crypto
{ class XXMLSignature
; }
37 namespace rtl
{ template <class reference_type
> class Reference
; }
39 class XMLSignatureTemplateImpl
;
41 class SignatureEngine
: public cppu::ImplInheritanceHelper
44 css::xml::crypto::sax::XReferenceCollector
,
45 css::xml::crypto::XUriBinding
47 /****** signatureengine.hxx/CLASS SignatureEngine *****************************
50 * SignatureEngine -- Base class of SignatureCreator and SignatureVerifier
53 * Maintains common members and methods related with signature operation.
54 ******************************************************************************/
59 * the Signature bridge component, which performs signature generation
60 * and verification based on xmlsec library.
62 css::uno::Reference
< css::xml::crypto::XXMLSignature
> m_xXMLSignature
;
65 * a collection of ElementCollector's ids. Each ElementCollector
66 * represents one element signed by this signature.
68 std::vector
< sal_Int32
> m_vReferenceIds
;
71 * remembers how many references this signature has.
73 sal_Int32 m_nTotalReferenceNumber
;
76 * a collection of Uri binding.
78 * the m_vUris is used to hold the Uri strings, and the m_vXInputStreams is used
79 * to hold corresponding bound XInputStream interface.
81 std::vector
< OUString
> m_vUris
;
82 std::vector
< css::uno::Reference
< css::io::XInputStream
> > m_vXInputStreams
;
85 explicit SignatureEngine();
86 virtual ~SignatureEngine() override
{};
88 virtual void tryToPerform( ) override
;
89 virtual void clearUp( ) const override
;
90 bool checkReady() const;
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.
97 /// @throws css::uno::Exception
98 /// @throws css::uno::RuntimeException
99 virtual void startEngine( const rtl::Reference
<XMLSignatureTemplateImpl
>&)
103 /* XReferenceCollector */
104 virtual void SAL_CALL
setReferenceCount( sal_Int32 count
) override
;
106 virtual void SAL_CALL
setReferenceId( sal_Int32 id
) override
;
109 virtual void SAL_CALL
setUriBinding(
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
;
116 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */