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