1*ec61c6edSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*ec61c6edSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*ec61c6edSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*ec61c6edSAndrew Rist * distributed with this work for additional information 6*ec61c6edSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*ec61c6edSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*ec61c6edSAndrew Rist * "License"); you may not use this file except in compliance 9*ec61c6edSAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*ec61c6edSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*ec61c6edSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*ec61c6edSAndrew Rist * software distributed under the License is distributed on an 15*ec61c6edSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*ec61c6edSAndrew Rist * KIND, either express or implied. See the License for the 17*ec61c6edSAndrew Rist * specific language governing permissions and limitations 18*ec61c6edSAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*ec61c6edSAndrew Rist *************************************************************/ 21*ec61c6edSAndrew Rist 22*ec61c6edSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef _SIGNATUREENGINE_HXX 25cdf0e10cSrcweir #define _SIGNATUREENGINE_HXX 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <com/sun/star/xml/crypto/sax/XReferenceResolvedListener.hpp> 28cdf0e10cSrcweir #include <com/sun/star/xml/crypto/sax/XReferenceResolvedBroadcaster.hpp> 29cdf0e10cSrcweir #ifndef _COM_SUN_STAR_XML_CRYPTO_SAX_XSIGNATURECOLLECTOR_HPP_ 30cdf0e10cSrcweir #include <com/sun/star/xml/crypto/sax/XReferenceCollector.hpp> 31cdf0e10cSrcweir #endif 32cdf0e10cSrcweir #include <com/sun/star/xml/crypto/sax/XKeyCollector.hpp> 33cdf0e10cSrcweir #include <com/sun/star/xml/crypto/sax/XMissionTaker.hpp> 34cdf0e10cSrcweir #include <com/sun/star/xml/crypto/sax/XSAXEventKeeper.hpp> 35cdf0e10cSrcweir #include <com/sun/star/xml/crypto/XXMLSecurityContext.hpp> 36cdf0e10cSrcweir #include <com/sun/star/xml/crypto/XXMLSignature.hpp> 37cdf0e10cSrcweir #include <com/sun/star/xml/crypto/XUriBinding.hpp> 38cdf0e10cSrcweir #include <com/sun/star/io/XInputStream.hpp> 39cdf0e10cSrcweir 40cdf0e10cSrcweir #include <cppuhelper/implbase2.hxx> 41cdf0e10cSrcweir 42cdf0e10cSrcweir #include "securityengine.hxx" 43cdf0e10cSrcweir 44cdf0e10cSrcweir #ifndef INCLUDED_VECTOR 45cdf0e10cSrcweir #include <vector> 46cdf0e10cSrcweir #define INCLUDED_VECTOR 47cdf0e10cSrcweir #endif 48cdf0e10cSrcweir 49cdf0e10cSrcweir class SignatureEngine : public cppu::ImplInheritanceHelper2 50cdf0e10cSrcweir < 51cdf0e10cSrcweir SecurityEngine, 52cdf0e10cSrcweir com::sun::star::xml::crypto::sax::XReferenceCollector, 53cdf0e10cSrcweir com::sun::star::xml::crypto::XUriBinding 54cdf0e10cSrcweir > 55cdf0e10cSrcweir /****** signatureengine.hxx/CLASS SignatureEngine ***************************** 56cdf0e10cSrcweir * 57cdf0e10cSrcweir * NAME 58cdf0e10cSrcweir * SignatureEngine -- Base class of SignatureCreator and SignatureVerifier 59cdf0e10cSrcweir * 60cdf0e10cSrcweir * FUNCTION 61cdf0e10cSrcweir * Maintains common members and methods related with signature operation. 62cdf0e10cSrcweir * 63cdf0e10cSrcweir * HISTORY 64cdf0e10cSrcweir * 05.01.2004 - Interface supported: XReferenceCollector 65cdf0e10cSrcweir * 66cdf0e10cSrcweir * AUTHOR 67cdf0e10cSrcweir * Michael Mi 68cdf0e10cSrcweir * Email: michael.mi@sun.com 69cdf0e10cSrcweir ******************************************************************************/ 70cdf0e10cSrcweir { 71cdf0e10cSrcweir protected: 72cdf0e10cSrcweir 73cdf0e10cSrcweir /* 74cdf0e10cSrcweir * the Signature bridge component, which performs signature generation 75cdf0e10cSrcweir * and verification based on xmlsec library. 76cdf0e10cSrcweir */ 77cdf0e10cSrcweir com::sun::star::uno::Reference< 78cdf0e10cSrcweir com::sun::star::xml::crypto::XXMLSignature > m_xXMLSignature; 79cdf0e10cSrcweir 80cdf0e10cSrcweir /* 81cdf0e10cSrcweir * a collection of ElementCollector's ids. Each ElementCollector 82cdf0e10cSrcweir * represents one element signed by this signature. 83cdf0e10cSrcweir */ 84cdf0e10cSrcweir std::vector< sal_Int32 > m_vReferenceIds; 85cdf0e10cSrcweir 86cdf0e10cSrcweir /* 87cdf0e10cSrcweir * remembers how many references this signature has. 88cdf0e10cSrcweir */ 89cdf0e10cSrcweir sal_Int32 m_nTotalReferenceNumber; 90cdf0e10cSrcweir 91cdf0e10cSrcweir /* 92cdf0e10cSrcweir * a collection of Uri binding. 93cdf0e10cSrcweir * 94cdf0e10cSrcweir * the m_vUris is used to hold the Uri strings, and the m_vXInputStreams is used 95cdf0e10cSrcweir * to hold corresponding binded XInputStream interface. 96cdf0e10cSrcweir */ 97cdf0e10cSrcweir std::vector< rtl::OUString > m_vUris; 98cdf0e10cSrcweir std::vector< com::sun::star::uno::Reference< 99cdf0e10cSrcweir com::sun::star::io::XInputStream > > m_vXInputStreams; 100cdf0e10cSrcweir 101cdf0e10cSrcweir protected: 102cdf0e10cSrcweir SignatureEngine( ); ~SignatureEngine()103cdf0e10cSrcweir virtual ~SignatureEngine() {}; 104cdf0e10cSrcweir 105cdf0e10cSrcweir virtual void tryToPerform( ) 106cdf0e10cSrcweir throw (com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException); 107cdf0e10cSrcweir virtual void clearUp( ) const; 108cdf0e10cSrcweir virtual bool checkReady() const; 109cdf0e10cSrcweir 110cdf0e10cSrcweir /* 111cdf0e10cSrcweir * starts the main function. This method will be implemented by any sub-class. 112cdf0e10cSrcweir * For a SignatureCreator, it performs signing operation; 113cdf0e10cSrcweir * for a SignatureVerifier, verification operation is performed. 114cdf0e10cSrcweir */ startEngine(const com::sun::star::uno::Reference<com::sun::star::xml::crypto::XXMLSignatureTemplate> &)115cdf0e10cSrcweir virtual void startEngine( const com::sun::star::uno::Reference< 116cdf0e10cSrcweir com::sun::star::xml::crypto::XXMLSignatureTemplate >&) 117cdf0e10cSrcweir throw (com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException) 118cdf0e10cSrcweir {}; 119cdf0e10cSrcweir 120cdf0e10cSrcweir public: 121cdf0e10cSrcweir /* XReferenceCollector */ 122cdf0e10cSrcweir virtual void SAL_CALL setReferenceCount( sal_Int32 count ) 123cdf0e10cSrcweir throw (com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException); 124cdf0e10cSrcweir 125cdf0e10cSrcweir virtual void SAL_CALL setReferenceId( sal_Int32 id ) 126cdf0e10cSrcweir throw (com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException); 127cdf0e10cSrcweir 128cdf0e10cSrcweir /* XUriBinding */ 129cdf0e10cSrcweir virtual void SAL_CALL setUriBinding( 130cdf0e10cSrcweir const rtl::OUString& uri, 131cdf0e10cSrcweir const com::sun::star::uno::Reference< 132cdf0e10cSrcweir com::sun::star::io::XInputStream >& aInputStream ) 133cdf0e10cSrcweir throw (com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException); 134cdf0e10cSrcweir virtual com::sun::star::uno::Reference< com::sun::star::io::XInputStream > 135cdf0e10cSrcweir SAL_CALL getUriBinding( const rtl::OUString& uri ) 136cdf0e10cSrcweir throw (com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException); 137cdf0e10cSrcweir }; 138cdf0e10cSrcweir 139cdf0e10cSrcweir #endif 140cdf0e10cSrcweir 141