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
10*ec61c6edSAndrew Rist  *
11*ec61c6edSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*ec61c6edSAndrew Rist  *
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.
19*ec61c6edSAndrew Rist  *
20*ec61c6edSAndrew Rist  *************************************************************/
21*ec61c6edSAndrew Rist 
22*ec61c6edSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef _XSEC_CTL_PARSER_HXX
25cdf0e10cSrcweir #define _XSEC_CTL_PARSER_HXX
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <xsecctl.hxx>
28cdf0e10cSrcweir 
29cdf0e10cSrcweir #include <com/sun/star/xml/sax/XParser.hpp>
30cdf0e10cSrcweir #include <com/sun/star/lang/XInitialization.hpp>
31cdf0e10cSrcweir #include <com/sun/star/xml/sax/XDocumentHandler.hpp>
32cdf0e10cSrcweir #include <com/sun/star/xml/sax/XAttributeList.hpp>
33cdf0e10cSrcweir 
34cdf0e10cSrcweir #include <cppuhelper/implbase2.hxx>
35cdf0e10cSrcweir 
36cdf0e10cSrcweir class XSecParser: public cppu::WeakImplHelper2
37cdf0e10cSrcweir <
38cdf0e10cSrcweir 	com::sun::star::xml::sax::XDocumentHandler,
39cdf0e10cSrcweir 	com::sun::star::lang::XInitialization
40cdf0e10cSrcweir >
41cdf0e10cSrcweir /****** XSecController.hxx/CLASS XSecParser ***********************************
42cdf0e10cSrcweir  *
43cdf0e10cSrcweir  *   NAME
44cdf0e10cSrcweir  *	XSecParser -- a SAX parser that can detect security elements
45cdf0e10cSrcweir  *
46cdf0e10cSrcweir  *   FUNCTION
47cdf0e10cSrcweir  *	The XSecParser object is connected on the SAX chain and detects
48cdf0e10cSrcweir  *	security elements in the SAX event stream, then notifies
49cdf0e10cSrcweir  *	the XSecController.
50cdf0e10cSrcweir  *
51cdf0e10cSrcweir  *   HISTORY
52cdf0e10cSrcweir  *	05.01.2004 -	Interface supported: XDocumentHandler, XInitialization
53cdf0e10cSrcweir  *
54cdf0e10cSrcweir  *   NOTES
55cdf0e10cSrcweir  *	This class is used when importing a document.
56cdf0e10cSrcweir  *
57cdf0e10cSrcweir  *   AUTHOR
58cdf0e10cSrcweir  *	Michael Mi
59cdf0e10cSrcweir  *	Email: michael.mi@sun.com
60cdf0e10cSrcweir  ******************************************************************************/
61cdf0e10cSrcweir {
62cdf0e10cSrcweir 	friend class XSecController;
63cdf0e10cSrcweir private:
64cdf0e10cSrcweir 	/*
65cdf0e10cSrcweir 	 * the following members are used to reserve the signature information,
66cdf0e10cSrcweir 	 * including X509IssuerName, X509SerialNumber, and X509Certificate,etc.
67cdf0e10cSrcweir 	 */
68cdf0e10cSrcweir 	rtl::OUString m_ouX509IssuerName;
69cdf0e10cSrcweir 	rtl::OUString m_ouX509SerialNumber;
70cdf0e10cSrcweir 	rtl::OUString m_ouX509Certificate;
71cdf0e10cSrcweir 	rtl::OUString m_ouDigestValue;
72cdf0e10cSrcweir 	rtl::OUString m_ouSignatureValue;
73cdf0e10cSrcweir 	rtl::OUString m_ouDate;
74cdf0e10cSrcweir 	//rtl::OUString m_ouTime;
75cdf0e10cSrcweir 
76cdf0e10cSrcweir 	/*
77cdf0e10cSrcweir 	 * whether inside a particular element
78cdf0e10cSrcweir 	 */
79cdf0e10cSrcweir 	bool m_bInX509IssuerName;
80cdf0e10cSrcweir 	bool m_bInX509SerialNumber;
81cdf0e10cSrcweir 	bool m_bInX509Certificate;
82cdf0e10cSrcweir 	bool m_bInDigestValue;
83cdf0e10cSrcweir 	bool m_bInSignatureValue;
84cdf0e10cSrcweir 	bool m_bInDate;
85cdf0e10cSrcweir 	//bool m_bInTime;
86cdf0e10cSrcweir 
87cdf0e10cSrcweir 	/*
88cdf0e10cSrcweir 	 * the XSecController collaborating with XSecParser
89cdf0e10cSrcweir 	 */
90cdf0e10cSrcweir 	XSecController* m_pXSecController;
91cdf0e10cSrcweir 
92cdf0e10cSrcweir 	/*
93cdf0e10cSrcweir 	 * the next XDocumentHandler on the SAX chain
94cdf0e10cSrcweir 	 */
95cdf0e10cSrcweir 	com::sun::star::uno::Reference<
96cdf0e10cSrcweir 		com::sun::star::xml::sax::XDocumentHandler > m_xNextHandler;
97cdf0e10cSrcweir 
98cdf0e10cSrcweir 	/*
99cdf0e10cSrcweir 	 * this string is used to remember the current handled reference's URI,
100cdf0e10cSrcweir 	 *
101cdf0e10cSrcweir 	 * because it can be decided whether a stream reference is xml based or binary based
102cdf0e10cSrcweir 	 * only after the Transforms element is read in, so we have to reserve the reference's
103cdf0e10cSrcweir 	 * URI when the startElement event is met.
104cdf0e10cSrcweir 	 */
105cdf0e10cSrcweir 	rtl::OUString m_currentReferenceURI;
106cdf0e10cSrcweir 	bool m_bReferenceUnresolved;
107cdf0e10cSrcweir 
108cdf0e10cSrcweir private:
109cdf0e10cSrcweir 	rtl::OUString getIdAttr(const com::sun::star::uno::Reference<
110cdf0e10cSrcweir 			com::sun::star::xml::sax::XAttributeList >& xAttribs );
111cdf0e10cSrcweir 
112cdf0e10cSrcweir public:
113cdf0e10cSrcweir 	XSecParser( XSecController* pXSecController,
114cdf0e10cSrcweir 		const com::sun::star::uno::Reference<
115cdf0e10cSrcweir 			com::sun::star::xml::sax::XDocumentHandler >& xNextHandler );
~XSecParser()116cdf0e10cSrcweir 	~XSecParser(){};
117cdf0e10cSrcweir 
118cdf0e10cSrcweir 	/*
119cdf0e10cSrcweir 	 * XDocumentHandler
120cdf0e10cSrcweir 	 */
121cdf0e10cSrcweir 	virtual void SAL_CALL startDocument(  )
122cdf0e10cSrcweir 		throw (com::sun::star::xml::sax::SAXException, com::sun::star::uno::RuntimeException);
123cdf0e10cSrcweir 
124cdf0e10cSrcweir 	virtual void SAL_CALL endDocument(  )
125cdf0e10cSrcweir 		throw (com::sun::star::xml::sax::SAXException, com::sun::star::uno::RuntimeException);
126cdf0e10cSrcweir 
127cdf0e10cSrcweir 	virtual void SAL_CALL startElement(
128cdf0e10cSrcweir 		const rtl::OUString& aName,
129cdf0e10cSrcweir 		const com::sun::star::uno::Reference<
130cdf0e10cSrcweir 			com::sun::star::xml::sax::XAttributeList >& xAttribs )
131cdf0e10cSrcweir 		throw (com::sun::star::xml::sax::SAXException, com::sun::star::uno::RuntimeException);
132cdf0e10cSrcweir 
133cdf0e10cSrcweir 	virtual void SAL_CALL endElement( const rtl::OUString& aName )
134cdf0e10cSrcweir 		throw (com::sun::star::xml::sax::SAXException, com::sun::star::uno::RuntimeException);
135cdf0e10cSrcweir 
136cdf0e10cSrcweir 	virtual void SAL_CALL characters( const rtl::OUString& aChars )
137cdf0e10cSrcweir 		throw (com::sun::star::xml::sax::SAXException, com::sun::star::uno::RuntimeException);
138cdf0e10cSrcweir 
139cdf0e10cSrcweir 	virtual void SAL_CALL ignorableWhitespace( const rtl::OUString& aWhitespaces )
140cdf0e10cSrcweir 		throw (com::sun::star::xml::sax::SAXException, com::sun::star::uno::RuntimeException);
141cdf0e10cSrcweir 
142cdf0e10cSrcweir 	virtual void SAL_CALL processingInstruction(
143cdf0e10cSrcweir 		const rtl::OUString& aTarget,
144cdf0e10cSrcweir 		const rtl::OUString& aData )
145cdf0e10cSrcweir 		throw (com::sun::star::xml::sax::SAXException, com::sun::star::uno::RuntimeException);
146cdf0e10cSrcweir 
147cdf0e10cSrcweir 	virtual void SAL_CALL setDocumentLocator(
148cdf0e10cSrcweir 		const com::sun::star::uno::Reference<
149cdf0e10cSrcweir 			com::sun::star::xml::sax::XLocator >& xLocator )
150cdf0e10cSrcweir 		throw (com::sun::star::xml::sax::SAXException, com::sun::star::uno::RuntimeException);
151cdf0e10cSrcweir 
152cdf0e10cSrcweir 	/*
153cdf0e10cSrcweir 	 * XInitialization
154cdf0e10cSrcweir 	 */
155cdf0e10cSrcweir 	virtual void SAL_CALL initialize(
156cdf0e10cSrcweir 		const com::sun::star::uno::Sequence< com::sun::star::uno::Any >& aArguments )
157cdf0e10cSrcweir 		throw(com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException);
158cdf0e10cSrcweir };
159cdf0e10cSrcweir 
160cdf0e10cSrcweir #endif
161cdf0e10cSrcweir 
162