1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #ifndef _SIGNATUREENGINE_HXX 29 #define _SIGNATUREENGINE_HXX 30 31 #include <com/sun/star/xml/crypto/sax/XReferenceResolvedListener.hpp> 32 #include <com/sun/star/xml/crypto/sax/XReferenceResolvedBroadcaster.hpp> 33 #ifndef _COM_SUN_STAR_XML_CRYPTO_SAX_XSIGNATURECOLLECTOR_HPP_ 34 #include <com/sun/star/xml/crypto/sax/XReferenceCollector.hpp> 35 #endif 36 #include <com/sun/star/xml/crypto/sax/XKeyCollector.hpp> 37 #include <com/sun/star/xml/crypto/sax/XMissionTaker.hpp> 38 #include <com/sun/star/xml/crypto/sax/XSAXEventKeeper.hpp> 39 #include <com/sun/star/xml/crypto/XXMLSecurityContext.hpp> 40 #include <com/sun/star/xml/crypto/XXMLSignature.hpp> 41 #include <com/sun/star/xml/crypto/XUriBinding.hpp> 42 #include <com/sun/star/io/XInputStream.hpp> 43 44 #include <cppuhelper/implbase2.hxx> 45 46 #include "securityengine.hxx" 47 48 #ifndef INCLUDED_VECTOR 49 #include <vector> 50 #define INCLUDED_VECTOR 51 #endif 52 53 class SignatureEngine : public cppu::ImplInheritanceHelper2 54 < 55 SecurityEngine, 56 com::sun::star::xml::crypto::sax::XReferenceCollector, 57 com::sun::star::xml::crypto::XUriBinding 58 > 59 /****** signatureengine.hxx/CLASS SignatureEngine ***************************** 60 * 61 * NAME 62 * SignatureEngine -- Base class of SignatureCreator and SignatureVerifier 63 * 64 * FUNCTION 65 * Maintains common members and methods related with signature operation. 66 * 67 * HISTORY 68 * 05.01.2004 - Interface supported: XReferenceCollector 69 * 70 * AUTHOR 71 * Michael Mi 72 * Email: michael.mi@sun.com 73 ******************************************************************************/ 74 { 75 protected: 76 77 /* 78 * the Signature bridge component, which performs signature generation 79 * and verification based on xmlsec library. 80 */ 81 com::sun::star::uno::Reference< 82 com::sun::star::xml::crypto::XXMLSignature > m_xXMLSignature; 83 84 /* 85 * a collection of ElementCollector's ids. Each ElementCollector 86 * represents one element signed by this signature. 87 */ 88 std::vector< sal_Int32 > m_vReferenceIds; 89 90 /* 91 * remembers how many references this signature has. 92 */ 93 sal_Int32 m_nTotalReferenceNumber; 94 95 /* 96 * a collection of Uri binding. 97 * 98 * the m_vUris is used to hold the Uri strings, and the m_vXInputStreams is used 99 * to hold corresponding binded XInputStream interface. 100 */ 101 std::vector< rtl::OUString > m_vUris; 102 std::vector< com::sun::star::uno::Reference< 103 com::sun::star::io::XInputStream > > m_vXInputStreams; 104 105 protected: 106 SignatureEngine( ); 107 virtual ~SignatureEngine() {}; 108 109 virtual void tryToPerform( ) 110 throw (com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException); 111 virtual void clearUp( ) const; 112 virtual bool checkReady() const; 113 114 /* 115 * starts the main function. This method will be implemented by any sub-class. 116 * For a SignatureCreator, it performs signing operation; 117 * for a SignatureVerifier, verification operation is performed. 118 */ 119 virtual void startEngine( const com::sun::star::uno::Reference< 120 com::sun::star::xml::crypto::XXMLSignatureTemplate >&) 121 throw (com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException) 122 {}; 123 124 public: 125 /* XReferenceCollector */ 126 virtual void SAL_CALL setReferenceCount( sal_Int32 count ) 127 throw (com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException); 128 129 virtual void SAL_CALL setReferenceId( sal_Int32 id ) 130 throw (com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException); 131 132 /* XUriBinding */ 133 virtual void SAL_CALL setUriBinding( 134 const rtl::OUString& uri, 135 const com::sun::star::uno::Reference< 136 com::sun::star::io::XInputStream >& aInputStream ) 137 throw (com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException); 138 virtual com::sun::star::uno::Reference< com::sun::star::io::XInputStream > 139 SAL_CALL getUriBinding( const rtl::OUString& uri ) 140 throw (com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException); 141 }; 142 143 #endif 144 145