1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir #ifndef _XSEC_CTL_PARSER_HXX 29*cdf0e10cSrcweir #define _XSEC_CTL_PARSER_HXX 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #include <xsecctl.hxx> 32*cdf0e10cSrcweir 33*cdf0e10cSrcweir #include <com/sun/star/xml/sax/XParser.hpp> 34*cdf0e10cSrcweir #include <com/sun/star/lang/XInitialization.hpp> 35*cdf0e10cSrcweir #include <com/sun/star/xml/sax/XDocumentHandler.hpp> 36*cdf0e10cSrcweir #include <com/sun/star/xml/sax/XAttributeList.hpp> 37*cdf0e10cSrcweir 38*cdf0e10cSrcweir #include <cppuhelper/implbase2.hxx> 39*cdf0e10cSrcweir 40*cdf0e10cSrcweir class XSecParser: public cppu::WeakImplHelper2 41*cdf0e10cSrcweir < 42*cdf0e10cSrcweir com::sun::star::xml::sax::XDocumentHandler, 43*cdf0e10cSrcweir com::sun::star::lang::XInitialization 44*cdf0e10cSrcweir > 45*cdf0e10cSrcweir /****** XSecController.hxx/CLASS XSecParser *********************************** 46*cdf0e10cSrcweir * 47*cdf0e10cSrcweir * NAME 48*cdf0e10cSrcweir * XSecParser -- a SAX parser that can detect security elements 49*cdf0e10cSrcweir * 50*cdf0e10cSrcweir * FUNCTION 51*cdf0e10cSrcweir * The XSecParser object is connected on the SAX chain and detects 52*cdf0e10cSrcweir * security elements in the SAX event stream, then notifies 53*cdf0e10cSrcweir * the XSecController. 54*cdf0e10cSrcweir * 55*cdf0e10cSrcweir * HISTORY 56*cdf0e10cSrcweir * 05.01.2004 - Interface supported: XDocumentHandler, XInitialization 57*cdf0e10cSrcweir * 58*cdf0e10cSrcweir * NOTES 59*cdf0e10cSrcweir * This class is used when importing a document. 60*cdf0e10cSrcweir * 61*cdf0e10cSrcweir * AUTHOR 62*cdf0e10cSrcweir * Michael Mi 63*cdf0e10cSrcweir * Email: michael.mi@sun.com 64*cdf0e10cSrcweir ******************************************************************************/ 65*cdf0e10cSrcweir { 66*cdf0e10cSrcweir friend class XSecController; 67*cdf0e10cSrcweir private: 68*cdf0e10cSrcweir /* 69*cdf0e10cSrcweir * the following members are used to reserve the signature information, 70*cdf0e10cSrcweir * including X509IssuerName, X509SerialNumber, and X509Certificate,etc. 71*cdf0e10cSrcweir */ 72*cdf0e10cSrcweir rtl::OUString m_ouX509IssuerName; 73*cdf0e10cSrcweir rtl::OUString m_ouX509SerialNumber; 74*cdf0e10cSrcweir rtl::OUString m_ouX509Certificate; 75*cdf0e10cSrcweir rtl::OUString m_ouDigestValue; 76*cdf0e10cSrcweir rtl::OUString m_ouSignatureValue; 77*cdf0e10cSrcweir rtl::OUString m_ouDate; 78*cdf0e10cSrcweir //rtl::OUString m_ouTime; 79*cdf0e10cSrcweir 80*cdf0e10cSrcweir /* 81*cdf0e10cSrcweir * whether inside a particular element 82*cdf0e10cSrcweir */ 83*cdf0e10cSrcweir bool m_bInX509IssuerName; 84*cdf0e10cSrcweir bool m_bInX509SerialNumber; 85*cdf0e10cSrcweir bool m_bInX509Certificate; 86*cdf0e10cSrcweir bool m_bInDigestValue; 87*cdf0e10cSrcweir bool m_bInSignatureValue; 88*cdf0e10cSrcweir bool m_bInDate; 89*cdf0e10cSrcweir //bool m_bInTime; 90*cdf0e10cSrcweir 91*cdf0e10cSrcweir /* 92*cdf0e10cSrcweir * the XSecController collaborating with XSecParser 93*cdf0e10cSrcweir */ 94*cdf0e10cSrcweir XSecController* m_pXSecController; 95*cdf0e10cSrcweir 96*cdf0e10cSrcweir /* 97*cdf0e10cSrcweir * the next XDocumentHandler on the SAX chain 98*cdf0e10cSrcweir */ 99*cdf0e10cSrcweir com::sun::star::uno::Reference< 100*cdf0e10cSrcweir com::sun::star::xml::sax::XDocumentHandler > m_xNextHandler; 101*cdf0e10cSrcweir 102*cdf0e10cSrcweir /* 103*cdf0e10cSrcweir * this string is used to remember the current handled reference's URI, 104*cdf0e10cSrcweir * 105*cdf0e10cSrcweir * because it can be decided whether a stream reference is xml based or binary based 106*cdf0e10cSrcweir * only after the Transforms element is read in, so we have to reserve the reference's 107*cdf0e10cSrcweir * URI when the startElement event is met. 108*cdf0e10cSrcweir */ 109*cdf0e10cSrcweir rtl::OUString m_currentReferenceURI; 110*cdf0e10cSrcweir bool m_bReferenceUnresolved; 111*cdf0e10cSrcweir 112*cdf0e10cSrcweir private: 113*cdf0e10cSrcweir rtl::OUString getIdAttr(const com::sun::star::uno::Reference< 114*cdf0e10cSrcweir com::sun::star::xml::sax::XAttributeList >& xAttribs ); 115*cdf0e10cSrcweir 116*cdf0e10cSrcweir public: 117*cdf0e10cSrcweir XSecParser( XSecController* pXSecController, 118*cdf0e10cSrcweir const com::sun::star::uno::Reference< 119*cdf0e10cSrcweir com::sun::star::xml::sax::XDocumentHandler >& xNextHandler ); 120*cdf0e10cSrcweir ~XSecParser(){}; 121*cdf0e10cSrcweir 122*cdf0e10cSrcweir /* 123*cdf0e10cSrcweir * XDocumentHandler 124*cdf0e10cSrcweir */ 125*cdf0e10cSrcweir virtual void SAL_CALL startDocument( ) 126*cdf0e10cSrcweir throw (com::sun::star::xml::sax::SAXException, com::sun::star::uno::RuntimeException); 127*cdf0e10cSrcweir 128*cdf0e10cSrcweir virtual void SAL_CALL endDocument( ) 129*cdf0e10cSrcweir throw (com::sun::star::xml::sax::SAXException, com::sun::star::uno::RuntimeException); 130*cdf0e10cSrcweir 131*cdf0e10cSrcweir virtual void SAL_CALL startElement( 132*cdf0e10cSrcweir const rtl::OUString& aName, 133*cdf0e10cSrcweir const com::sun::star::uno::Reference< 134*cdf0e10cSrcweir com::sun::star::xml::sax::XAttributeList >& xAttribs ) 135*cdf0e10cSrcweir throw (com::sun::star::xml::sax::SAXException, com::sun::star::uno::RuntimeException); 136*cdf0e10cSrcweir 137*cdf0e10cSrcweir virtual void SAL_CALL endElement( const rtl::OUString& aName ) 138*cdf0e10cSrcweir throw (com::sun::star::xml::sax::SAXException, com::sun::star::uno::RuntimeException); 139*cdf0e10cSrcweir 140*cdf0e10cSrcweir virtual void SAL_CALL characters( const rtl::OUString& aChars ) 141*cdf0e10cSrcweir throw (com::sun::star::xml::sax::SAXException, com::sun::star::uno::RuntimeException); 142*cdf0e10cSrcweir 143*cdf0e10cSrcweir virtual void SAL_CALL ignorableWhitespace( const rtl::OUString& aWhitespaces ) 144*cdf0e10cSrcweir throw (com::sun::star::xml::sax::SAXException, com::sun::star::uno::RuntimeException); 145*cdf0e10cSrcweir 146*cdf0e10cSrcweir virtual void SAL_CALL processingInstruction( 147*cdf0e10cSrcweir const rtl::OUString& aTarget, 148*cdf0e10cSrcweir const rtl::OUString& aData ) 149*cdf0e10cSrcweir throw (com::sun::star::xml::sax::SAXException, com::sun::star::uno::RuntimeException); 150*cdf0e10cSrcweir 151*cdf0e10cSrcweir virtual void SAL_CALL setDocumentLocator( 152*cdf0e10cSrcweir const com::sun::star::uno::Reference< 153*cdf0e10cSrcweir com::sun::star::xml::sax::XLocator >& xLocator ) 154*cdf0e10cSrcweir throw (com::sun::star::xml::sax::SAXException, com::sun::star::uno::RuntimeException); 155*cdf0e10cSrcweir 156*cdf0e10cSrcweir /* 157*cdf0e10cSrcweir * XInitialization 158*cdf0e10cSrcweir */ 159*cdf0e10cSrcweir virtual void SAL_CALL initialize( 160*cdf0e10cSrcweir const com::sun::star::uno::Sequence< com::sun::star::uno::Any >& aArguments ) 161*cdf0e10cSrcweir throw(com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException); 162*cdf0e10cSrcweir }; 163*cdf0e10cSrcweir 164*cdf0e10cSrcweir #endif 165*cdf0e10cSrcweir 166