Line data Source code
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 : #ifndef _SIGNATUREENGINE_HXX
21 : #define _SIGNATUREENGINE_HXX
22 :
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/XReferenceCollector.hpp>
26 : #include <com/sun/star/xml/crypto/sax/XKeyCollector.hpp>
27 : #include <com/sun/star/xml/crypto/sax/XMissionTaker.hpp>
28 : #include <com/sun/star/xml/crypto/sax/XSAXEventKeeper.hpp>
29 : #include <com/sun/star/xml/crypto/XXMLSecurityContext.hpp>
30 : #include <com/sun/star/xml/crypto/XXMLSignature.hpp>
31 : #include <com/sun/star/xml/crypto/XUriBinding.hpp>
32 : #include <com/sun/star/io/XInputStream.hpp>
33 :
34 : #include <cppuhelper/implbase2.hxx>
35 :
36 : #include "securityengine.hxx"
37 :
38 : #include <vector>
39 :
40 : class SignatureEngine : public cppu::ImplInheritanceHelper2
41 : <
42 : SecurityEngine,
43 : com::sun::star::xml::crypto::sax::XReferenceCollector,
44 : com::sun::star::xml::crypto::XUriBinding
45 : >
46 : /****** signatureengine.hxx/CLASS SignatureEngine *****************************
47 : *
48 : * NAME
49 : * SignatureEngine -- Base class of SignatureCreator and SignatureVerifier
50 : *
51 : * FUNCTION
52 : * Maintains common members and methods related with signature operation.
53 : *
54 : * AUTHOR
55 : * Michael Mi
56 : * Email: michael.mi@sun.com
57 : ******************************************************************************/
58 : {
59 : protected:
60 :
61 : /*
62 : * the Signature bridge component, which performs signature generation
63 : * and verification based on xmlsec library.
64 : */
65 : com::sun::star::uno::Reference<
66 : com::sun::star::xml::crypto::XXMLSignature > m_xXMLSignature;
67 :
68 : /*
69 : * a collection of ElementCollector's ids. Each ElementCollector
70 : * represents one element signed by this signature.
71 : */
72 : std::vector< sal_Int32 > m_vReferenceIds;
73 :
74 : /*
75 : * remembers how many references this signature has.
76 : */
77 : sal_Int32 m_nTotalReferenceNumber;
78 :
79 : /*
80 : * a collection of Uri binding.
81 : *
82 : * the m_vUris is used to hold the Uri strings, and the m_vXInputStreams is used
83 : * to hold corresponding binded XInputStream interface.
84 : */
85 : std::vector< rtl::OUString > m_vUris;
86 : std::vector< com::sun::star::uno::Reference<
87 : com::sun::star::io::XInputStream > > m_vXInputStreams;
88 :
89 : protected:
90 : SignatureEngine( );
91 0 : virtual ~SignatureEngine() {};
92 :
93 : virtual void tryToPerform( )
94 : throw (com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException);
95 : virtual void clearUp( ) const;
96 : virtual bool checkReady() const;
97 :
98 : /*
99 : * starts the main function. This method will be implemented by any sub-class.
100 : * For a SignatureCreator, it performs signing operation;
101 : * for a SignatureVerifier, verification operation is performed.
102 : */
103 0 : virtual void startEngine( const com::sun::star::uno::Reference<
104 : com::sun::star::xml::crypto::XXMLSignatureTemplate >&)
105 : throw (com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException)
106 0 : {};
107 :
108 : public:
109 : /* XReferenceCollector */
110 : virtual void SAL_CALL setReferenceCount( sal_Int32 count )
111 : throw (com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException);
112 :
113 : virtual void SAL_CALL setReferenceId( sal_Int32 id )
114 : throw (com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException);
115 :
116 : /* XUriBinding */
117 : virtual void SAL_CALL setUriBinding(
118 : const rtl::OUString& uri,
119 : const com::sun::star::uno::Reference<
120 : com::sun::star::io::XInputStream >& aInputStream )
121 : throw (com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException);
122 : virtual com::sun::star::uno::Reference< com::sun::star::io::XInputStream >
123 : SAL_CALL getUriBinding( const rtl::OUString& uri )
124 : throw (com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException);
125 : };
126 :
127 : #endif
128 :
129 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|