1*06b3ce53SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*06b3ce53SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*06b3ce53SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*06b3ce53SAndrew Rist  * distributed with this work for additional information
6*06b3ce53SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*06b3ce53SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*06b3ce53SAndrew Rist  * "License"); you may not use this file except in compliance
9*06b3ce53SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*06b3ce53SAndrew Rist  *
11*06b3ce53SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*06b3ce53SAndrew Rist  *
13*06b3ce53SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*06b3ce53SAndrew Rist  * software distributed under the License is distributed on an
15*06b3ce53SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*06b3ce53SAndrew Rist  * KIND, either express or implied.  See the License for the
17*06b3ce53SAndrew Rist  * specific language governing permissions and limitations
18*06b3ce53SAndrew Rist  * under the License.
19*06b3ce53SAndrew Rist  *
20*06b3ce53SAndrew Rist  *************************************************************/
21*06b3ce53SAndrew Rist 
22*06b3ce53SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_xmlsecurity.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <xsecctl.hxx>
28cdf0e10cSrcweir #include <tools/debug.hxx>
29cdf0e10cSrcweir 
30cdf0e10cSrcweir #include <com/sun/star/xml/crypto/sax/ElementMarkPriority.hpp>
31cdf0e10cSrcweir #include <com/sun/star/xml/crypto/sax/XReferenceResolvedBroadcaster.hpp>
32cdf0e10cSrcweir #include <com/sun/star/xml/crypto/sax/XMissionTaker.hpp>
33cdf0e10cSrcweir #include <com/sun/star/xml/crypto/sax/XReferenceCollector.hpp>
34cdf0e10cSrcweir #include <com/sun/star/xml/crypto/sax/XSAXEventKeeperStatusChangeBroadcaster.hpp>
35cdf0e10cSrcweir #include <com/sun/star/xml/crypto/SecurityOperationStatus.hpp>
36cdf0e10cSrcweir 
37cdf0e10cSrcweir #include <xmloff/attrlist.hxx>
38cdf0e10cSrcweir #include <rtl/math.hxx>
39cdf0e10cSrcweir #include <tools/string.hxx>
40cdf0e10cSrcweir 
41cdf0e10cSrcweir namespace cssu = com::sun::star::uno;
42cdf0e10cSrcweir namespace cssl = com::sun::star::lang;
43cdf0e10cSrcweir namespace cssxc = com::sun::star::xml::crypto;
44cdf0e10cSrcweir namespace cssxs = com::sun::star::xml::sax;
45cdf0e10cSrcweir namespace cssxw = com::sun::star::xml::wrapper;
46cdf0e10cSrcweir namespace cssb = com::sun::star::beans;
47cdf0e10cSrcweir 
48cdf0e10cSrcweir const sal_Int8 XML_MAXDIGITSCOUNT_TIME = 11;
49cdf0e10cSrcweir const sal_Int8 XML_MAXDIGITSCOUNT_DATETIME = 6;
50cdf0e10cSrcweir 
51cdf0e10cSrcweir /* bridge component names */
52cdf0e10cSrcweir #define XMLSIGNATURE_COMPONENT "com.sun.star.xml.crypto.XMLSignature"
53cdf0e10cSrcweir #define XMLDOCUMENTWRAPPER_COMPONENT "com.sun.star.xml.wrapper.XMLDocumentWrapper"
54cdf0e10cSrcweir 
55cdf0e10cSrcweir /* xml security framework components */
56cdf0e10cSrcweir #define SAXEVENTKEEPER_COMPONENT "com.sun.star.xml.crypto.sax.SAXEventKeeper"
57cdf0e10cSrcweir 
58cdf0e10cSrcweir /* string for package protocol */
59cdf0e10cSrcweir #define PACKAGEPROTOCOL "vnd.sun.star.Package:"
60cdf0e10cSrcweir 
XSecController(const cssu::Reference<cssu::XComponentContext> & rxCtx)61cdf0e10cSrcweir XSecController::XSecController( const cssu::Reference<cssu::XComponentContext>& rxCtx )
62cdf0e10cSrcweir 	:mxCtx(rxCtx),
63cdf0e10cSrcweir 	 m_nNextSecurityId(1),
64cdf0e10cSrcweir  	 m_bIsSAXEventKeeperConnected(false),
65cdf0e10cSrcweir 	 m_nStatusOfSecurityComponents(UNINITIALIZED),
66cdf0e10cSrcweir  	 m_bIsSAXEventKeeperSticky(false),
67cdf0e10cSrcweir 	 m_pErrorMessage(NULL),
68cdf0e10cSrcweir 	 m_pXSecParser(NULL)
69cdf0e10cSrcweir {
70cdf0e10cSrcweir }
71cdf0e10cSrcweir 
~XSecController()72cdf0e10cSrcweir XSecController::~XSecController()
73cdf0e10cSrcweir {
74cdf0e10cSrcweir }
75cdf0e10cSrcweir 
76cdf0e10cSrcweir 
77cdf0e10cSrcweir /*
78cdf0e10cSrcweir  * private methods
79cdf0e10cSrcweir  */
80cdf0e10cSrcweir /** convert string to number with optional min and max values */
convertNumber(sal_Int32 & rValue,const rtl::OUString & rString,sal_Int32,sal_Int32)81cdf0e10cSrcweir sal_Bool XSecController::convertNumber( sal_Int32& rValue,
82cdf0e10cSrcweir                                         const rtl::OUString& rString,
83cdf0e10cSrcweir                                         sal_Int32 /*nMin*/, sal_Int32 /*nMax*/ )
84cdf0e10cSrcweir {
85cdf0e10cSrcweir     sal_Bool bNeg = sal_False;
86cdf0e10cSrcweir     rValue = 0;
87cdf0e10cSrcweir 
88cdf0e10cSrcweir     sal_Int32 nPos = 0L;
89cdf0e10cSrcweir     sal_Int32 nLen = rString.getLength();
90cdf0e10cSrcweir 
91cdf0e10cSrcweir     // skip white space
92cdf0e10cSrcweir     while( nPos < nLen && sal_Unicode(' ') == rString[nPos] )
93cdf0e10cSrcweir         nPos++;
94cdf0e10cSrcweir 
95cdf0e10cSrcweir     if( nPos < nLen && sal_Unicode('-') == rString[nPos] )
96cdf0e10cSrcweir     {
97cdf0e10cSrcweir         bNeg = sal_True;
98cdf0e10cSrcweir         nPos++;
99cdf0e10cSrcweir     }
100cdf0e10cSrcweir 
101cdf0e10cSrcweir     // get number
102cdf0e10cSrcweir     while( nPos < nLen &&
103cdf0e10cSrcweir            sal_Unicode('0') <= rString[nPos] &&
104cdf0e10cSrcweir            sal_Unicode('9') >= rString[nPos] )
105cdf0e10cSrcweir     {
106cdf0e10cSrcweir         // TODO: check overflow!
107cdf0e10cSrcweir         rValue *= 10;
108cdf0e10cSrcweir         rValue += (rString[nPos] - sal_Unicode('0'));
109cdf0e10cSrcweir         nPos++;
110cdf0e10cSrcweir     }
111cdf0e10cSrcweir 
112cdf0e10cSrcweir     if( bNeg )
113cdf0e10cSrcweir         rValue *= -1;
114cdf0e10cSrcweir 
115cdf0e10cSrcweir     return nPos == nLen;
116cdf0e10cSrcweir }
117cdf0e10cSrcweir 
118cdf0e10cSrcweir /** convert util::DateTime to ISO Date String */
convertDateTime(::rtl::OUStringBuffer & rBuffer,const com::sun::star::util::DateTime & rDateTime)119cdf0e10cSrcweir void XSecController::convertDateTime( ::rtl::OUStringBuffer& rBuffer,
120cdf0e10cSrcweir                                 const com::sun::star::util::DateTime& rDateTime )
121cdf0e10cSrcweir {
122cdf0e10cSrcweir     String aString( String::CreateFromInt32( rDateTime.Year ) );
123cdf0e10cSrcweir     aString += '-';
124cdf0e10cSrcweir     if( rDateTime.Month < 10 )
125cdf0e10cSrcweir         aString += '0';
126cdf0e10cSrcweir     aString += String::CreateFromInt32( rDateTime.Month );
127cdf0e10cSrcweir     aString += '-';
128cdf0e10cSrcweir     if( rDateTime.Day < 10 )
129cdf0e10cSrcweir         aString += '0';
130cdf0e10cSrcweir     aString += String::CreateFromInt32( rDateTime.Day );
131cdf0e10cSrcweir 
132cdf0e10cSrcweir     if( rDateTime.Seconds != 0 ||
133cdf0e10cSrcweir         rDateTime.Minutes != 0 ||
134cdf0e10cSrcweir         rDateTime.Hours   != 0 )
135cdf0e10cSrcweir     {
136cdf0e10cSrcweir         aString += 'T';
137cdf0e10cSrcweir         if( rDateTime.Hours < 10 )
138cdf0e10cSrcweir             aString += '0';
139cdf0e10cSrcweir         aString += String::CreateFromInt32( rDateTime.Hours );
140cdf0e10cSrcweir         aString += ':';
141cdf0e10cSrcweir         if( rDateTime.Minutes < 10 )
142cdf0e10cSrcweir             aString += '0';
143cdf0e10cSrcweir         aString += String::CreateFromInt32( rDateTime.Minutes );
144cdf0e10cSrcweir         aString += ':';
145cdf0e10cSrcweir         if( rDateTime.Seconds < 10 )
146cdf0e10cSrcweir             aString += '0';
147cdf0e10cSrcweir         aString += String::CreateFromInt32( rDateTime.Seconds );
148cdf0e10cSrcweir 		if ( rDateTime.HundredthSeconds > 0)
149cdf0e10cSrcweir 		{
150cdf0e10cSrcweir 	        aString += ',';
151cdf0e10cSrcweir 			if (rDateTime.HundredthSeconds < 10)
152cdf0e10cSrcweir 				aString += '0';
153cdf0e10cSrcweir 			aString += String::CreateFromInt32( rDateTime.HundredthSeconds );
154cdf0e10cSrcweir 		}
155cdf0e10cSrcweir     }
156cdf0e10cSrcweir 
157cdf0e10cSrcweir     rBuffer.append( aString );
158cdf0e10cSrcweir }
159cdf0e10cSrcweir 
160cdf0e10cSrcweir /** convert ISO Date String to util::DateTime */
convertDateTime(com::sun::star::util::DateTime & rDateTime,const::rtl::OUString & rString)161cdf0e10cSrcweir sal_Bool XSecController::convertDateTime( com::sun::star::util::DateTime& rDateTime,
162cdf0e10cSrcweir                                      const ::rtl::OUString& rString )
163cdf0e10cSrcweir {
164cdf0e10cSrcweir     sal_Bool bSuccess = sal_True;
165cdf0e10cSrcweir 
166cdf0e10cSrcweir     rtl::OUString aDateStr, aTimeStr, sHundredth;
167cdf0e10cSrcweir     sal_Int32 nPos = rString.indexOf( (sal_Unicode) 'T' );
168cdf0e10cSrcweir     sal_Int32 nPos2 = rString.indexOf( (sal_Unicode) ',' );
169cdf0e10cSrcweir     if ( nPos >= 0 )
170cdf0e10cSrcweir     {
171cdf0e10cSrcweir         aDateStr = rString.copy( 0, nPos );
172cdf0e10cSrcweir         if ( nPos2 >= 0 )
173cdf0e10cSrcweir         {
174cdf0e10cSrcweir             aTimeStr = rString.copy( nPos + 1, nPos2 - nPos - 1 );
175cdf0e10cSrcweir 
176cdf0e10cSrcweir 			//Get the fraction of a second with the accuracy of one hundreds second.
177cdf0e10cSrcweir 			//The fraction part of the date could have different accuracies. To calculate
178cdf0e10cSrcweir 			//the count of a hundredth units one could form a fractional number by appending
179cdf0e10cSrcweir 			//the value of the time string to 0. Then multiply it by 100 and use only the whole number.
180cdf0e10cSrcweir 			//For example: 5:27:46,1 -> 0,1 * 100 = 10
181cdf0e10cSrcweir 			//5:27:46,01 -> 0,01 * 100 = 1
182cdf0e10cSrcweir 			//5:27:46,001 -> 0,001 * 100 = 0
183cdf0e10cSrcweir 			//Due to the inaccuracy of floating point numbers the result may not be the same on different
184cdf0e10cSrcweir 			//platforms. We had the case where we had a value of 24 hundredth of second, which converted to
185cdf0e10cSrcweir 			//23 on Linux and 24 on Solaris and Windows.
186cdf0e10cSrcweir 
187cdf0e10cSrcweir 			//we only support a hundredth second
188cdf0e10cSrcweir 			//make ,1 -> 10   ,01 -> 1    ,001 -> only use first two diggits
189cdf0e10cSrcweir 			sHundredth = rString.copy(nPos2 + 1);
190cdf0e10cSrcweir 			sal_Int32 len = sHundredth.getLength();
191cdf0e10cSrcweir 			if (len == 1)
192cdf0e10cSrcweir 				sHundredth += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("0"));
193cdf0e10cSrcweir 			if (len > 2)
194cdf0e10cSrcweir 				sHundredth = sHundredth.copy(0, 2);
195cdf0e10cSrcweir         }
196cdf0e10cSrcweir         else
197cdf0e10cSrcweir         {
198cdf0e10cSrcweir             aTimeStr = rString.copy(nPos + 1);
199cdf0e10cSrcweir 			sHundredth = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("0"));
200cdf0e10cSrcweir         }
201cdf0e10cSrcweir     }
202cdf0e10cSrcweir     else
203cdf0e10cSrcweir         aDateStr = rString;         // no separator: only date part
204cdf0e10cSrcweir 
205cdf0e10cSrcweir     sal_Int32 nYear  = 1899;
206cdf0e10cSrcweir     sal_Int32 nMonth = 12;
207cdf0e10cSrcweir     sal_Int32 nDay   = 30;
208cdf0e10cSrcweir     sal_Int32 nHour  = 0;
209cdf0e10cSrcweir     sal_Int32 nMin   = 0;
210cdf0e10cSrcweir     sal_Int32 nSec   = 0;
211cdf0e10cSrcweir 
212cdf0e10cSrcweir     const sal_Unicode* pStr = aDateStr.getStr();
213cdf0e10cSrcweir     sal_Int32 nDateTokens = 1;
214cdf0e10cSrcweir     while ( *pStr )
215cdf0e10cSrcweir     {
216cdf0e10cSrcweir         if ( *pStr == '-' )
217cdf0e10cSrcweir             nDateTokens++;
218cdf0e10cSrcweir         pStr++;
219cdf0e10cSrcweir     }
220cdf0e10cSrcweir     if ( nDateTokens > 3 || aDateStr.getLength() == 0 )
221cdf0e10cSrcweir         bSuccess = sal_False;
222cdf0e10cSrcweir     else
223cdf0e10cSrcweir     {
224cdf0e10cSrcweir         sal_Int32 n = 0;
225cdf0e10cSrcweir         if ( !convertNumber( nYear, aDateStr.getToken( 0, '-', n ), 0, 9999 ) )
226cdf0e10cSrcweir             bSuccess = sal_False;
227cdf0e10cSrcweir         if ( nDateTokens >= 2 )
228cdf0e10cSrcweir             if ( !convertNumber( nMonth, aDateStr.getToken( 0, '-', n ), 0, 12 ) )
229cdf0e10cSrcweir                 bSuccess = sal_False;
230cdf0e10cSrcweir         if ( nDateTokens >= 3 )
231cdf0e10cSrcweir             if ( !convertNumber( nDay, aDateStr.getToken( 0, '-', n ), 0, 31 ) )
232cdf0e10cSrcweir                 bSuccess = sal_False;
233cdf0e10cSrcweir     }
234cdf0e10cSrcweir 
235cdf0e10cSrcweir     if ( aTimeStr.getLength() > 0 )           // time is optional
236cdf0e10cSrcweir     {
237cdf0e10cSrcweir         pStr = aTimeStr.getStr();
238cdf0e10cSrcweir         sal_Int32 nTimeTokens = 1;
239cdf0e10cSrcweir         while ( *pStr )
240cdf0e10cSrcweir         {
241cdf0e10cSrcweir             if ( *pStr == ':' )
242cdf0e10cSrcweir                 nTimeTokens++;
243cdf0e10cSrcweir             pStr++;
244cdf0e10cSrcweir         }
245cdf0e10cSrcweir         if ( nTimeTokens > 3 )
246cdf0e10cSrcweir             bSuccess = sal_False;
247cdf0e10cSrcweir         else
248cdf0e10cSrcweir         {
249cdf0e10cSrcweir             sal_Int32 n = 0;
250cdf0e10cSrcweir             if ( !convertNumber( nHour, aTimeStr.getToken( 0, ':', n ), 0, 23 ) )
251cdf0e10cSrcweir                 bSuccess = sal_False;
252cdf0e10cSrcweir             if ( nTimeTokens >= 2 )
253cdf0e10cSrcweir                 if ( !convertNumber( nMin, aTimeStr.getToken( 0, ':', n ), 0, 59 ) )
254cdf0e10cSrcweir                     bSuccess = sal_False;
255cdf0e10cSrcweir             if ( nTimeTokens >= 3 )
256cdf0e10cSrcweir                 if ( !convertNumber( nSec, aTimeStr.getToken( 0, ':', n ), 0, 59 ) )
257cdf0e10cSrcweir                     bSuccess = sal_False;
258cdf0e10cSrcweir         }
259cdf0e10cSrcweir     }
260cdf0e10cSrcweir 
261cdf0e10cSrcweir     if (bSuccess)
262cdf0e10cSrcweir     {
263cdf0e10cSrcweir         rDateTime.Year = (sal_uInt16)nYear;
264cdf0e10cSrcweir         rDateTime.Month = (sal_uInt16)nMonth;
265cdf0e10cSrcweir         rDateTime.Day = (sal_uInt16)nDay;
266cdf0e10cSrcweir         rDateTime.Hours = (sal_uInt16)nHour;
267cdf0e10cSrcweir         rDateTime.Minutes = (sal_uInt16)nMin;
268cdf0e10cSrcweir         rDateTime.Seconds = (sal_uInt16)nSec;
269cdf0e10cSrcweir  //       rDateTime.HundredthSeconds = sDoubleStr.toDouble() * 100;
270cdf0e10cSrcweir 		rDateTime.HundredthSeconds = static_cast<sal_uInt16>(sHundredth.toInt32());
271cdf0e10cSrcweir     }
272cdf0e10cSrcweir     return bSuccess;
273cdf0e10cSrcweir }
274cdf0e10cSrcweir 
findSignatureInfor(sal_Int32 nSecurityId) const275cdf0e10cSrcweir int XSecController::findSignatureInfor( sal_Int32 nSecurityId) const
276cdf0e10cSrcweir /****** XSecController/findSignatureInfor *************************************
277cdf0e10cSrcweir  *
278cdf0e10cSrcweir  *   NAME
279cdf0e10cSrcweir  *	findSignatureInfor -- find SignatureInformation struct for a particular
280cdf0e10cSrcweir  *	                      signature
281cdf0e10cSrcweir  *
282cdf0e10cSrcweir  *   SYNOPSIS
283cdf0e10cSrcweir  *	index = findSignatureInfor( nSecurityId );
284cdf0e10cSrcweir  *
285cdf0e10cSrcweir  *   FUNCTION
286cdf0e10cSrcweir  *	see NAME.
287cdf0e10cSrcweir  *
288cdf0e10cSrcweir  *   INPUTS
289cdf0e10cSrcweir  *	nSecurityId - the signature's id
290cdf0e10cSrcweir  *
291cdf0e10cSrcweir  *   RESULT
292cdf0e10cSrcweir  *	index - the index of the signature, or -1 when no such signature
293cdf0e10cSrcweir  *	        existing
294cdf0e10cSrcweir  *
295cdf0e10cSrcweir  *   HISTORY
296cdf0e10cSrcweir  *	08.05.2004 -	implemented
297cdf0e10cSrcweir  *
298cdf0e10cSrcweir  *   AUTHOR
299cdf0e10cSrcweir  *	Michael Mi
300cdf0e10cSrcweir  *	Email: michael.mi@sun.com
301cdf0e10cSrcweir  ******************************************************************************/
302cdf0e10cSrcweir {
303cdf0e10cSrcweir 	int i;
304cdf0e10cSrcweir 	int size = m_vInternalSignatureInformations.size();
305cdf0e10cSrcweir 
306cdf0e10cSrcweir 	for (i=0; i<size; ++i)
307cdf0e10cSrcweir 	{
308cdf0e10cSrcweir 		if (m_vInternalSignatureInformations[i].signatureInfor.nSecurityId == nSecurityId)
309cdf0e10cSrcweir 		{
310cdf0e10cSrcweir 			return i;
311cdf0e10cSrcweir 		}
312cdf0e10cSrcweir 	}
313cdf0e10cSrcweir 
314cdf0e10cSrcweir 	return -1;
315cdf0e10cSrcweir }
316cdf0e10cSrcweir 
createXSecComponent()317cdf0e10cSrcweir void XSecController::createXSecComponent( )
318cdf0e10cSrcweir /****** XSecController/createXSecComponent ************************************
319cdf0e10cSrcweir  *
320cdf0e10cSrcweir  *   NAME
321cdf0e10cSrcweir  *	bResult = createXSecComponent -- creates xml security components
322cdf0e10cSrcweir  *
323cdf0e10cSrcweir  *   SYNOPSIS
324cdf0e10cSrcweir  *	createXSecComponent( );
325cdf0e10cSrcweir  *
326cdf0e10cSrcweir  *   FUNCTION
327cdf0e10cSrcweir  *	Creates xml security components, including:
328cdf0e10cSrcweir  *	1. an xml signature bridge component ( Java based or C based)
329cdf0e10cSrcweir  *	2. an XMLDocumentWrapper component ( Java based or C based)
330cdf0e10cSrcweir  *	3. a SAXEventKeeper component
331cdf0e10cSrcweir  *
332cdf0e10cSrcweir  *   INPUTS
333cdf0e10cSrcweir  *	empty
334cdf0e10cSrcweir  *
335cdf0e10cSrcweir  *   RESULT
336cdf0e10cSrcweir  *	empty
337cdf0e10cSrcweir  *
338cdf0e10cSrcweir  *   HISTORY
339cdf0e10cSrcweir  *	05.01.2004 -	implemented
340cdf0e10cSrcweir  *
341cdf0e10cSrcweir  *   AUTHOR
342cdf0e10cSrcweir  *	Michael Mi
343cdf0e10cSrcweir  *	Email: michael.mi@sun.com
344cdf0e10cSrcweir  ******************************************************************************/
345cdf0e10cSrcweir {
346cdf0e10cSrcweir 	rtl::OUString sSAXEventKeeper(rtl::OUString::createFromAscii( SAXEVENTKEEPER_COMPONENT ));
347cdf0e10cSrcweir 	rtl::OUString sXMLSignature(rtl::OUString::createFromAscii( XMLSIGNATURE_COMPONENT ));
348cdf0e10cSrcweir 	rtl::OUString sXMLDocument(rtl::OUString::createFromAscii( XMLDOCUMENTWRAPPER_COMPONENT ));
349cdf0e10cSrcweir 
350cdf0e10cSrcweir 	/*
351cdf0e10cSrcweir 	 * marks all security components are not available.
352cdf0e10cSrcweir 	 */
353cdf0e10cSrcweir 	m_nStatusOfSecurityComponents = FAILTOINITIALIZED;
354cdf0e10cSrcweir 	m_xXMLSignature = NULL;
355cdf0e10cSrcweir 	m_xXMLDocumentWrapper = NULL;
356cdf0e10cSrcweir 	m_xSAXEventKeeper = NULL;
357cdf0e10cSrcweir 
358cdf0e10cSrcweir 	cssu::Reference< cssl::XMultiComponentFactory > xMCF( mxCtx->getServiceManager() );
359cdf0e10cSrcweir 
360cdf0e10cSrcweir 	m_xXMLSignature = cssu::Reference< cssxc::XXMLSignature >(
361cdf0e10cSrcweir 		xMCF->createInstanceWithContext( sXMLSignature, mxCtx ),
362cdf0e10cSrcweir 		cssu::UNO_QUERY );
363cdf0e10cSrcweir 
364cdf0e10cSrcweir 	bool bSuccess = (0!=m_xXMLSignature.is());
365cdf0e10cSrcweir 	if ( bSuccess )
366cdf0e10cSrcweir 	/*
367cdf0e10cSrcweir 	 * XMLSignature created successfully.
368cdf0e10cSrcweir 	 */
369cdf0e10cSrcweir 	{
370cdf0e10cSrcweir 		m_xXMLDocumentWrapper = cssu::Reference< cssxw::XXMLDocumentWrapper >(
371cdf0e10cSrcweir 			xMCF->createInstanceWithContext( sXMLDocument, mxCtx ),
372cdf0e10cSrcweir 			cssu::UNO_QUERY );
373cdf0e10cSrcweir 	}
374cdf0e10cSrcweir 
375cdf0e10cSrcweir 	bSuccess &= (0!=m_xXMLDocumentWrapper.is());
376cdf0e10cSrcweir 	if ( bSuccess )
377cdf0e10cSrcweir 	/*
378cdf0e10cSrcweir 	 * XMLDocumentWrapper created successfully.
379cdf0e10cSrcweir 	 */
380cdf0e10cSrcweir 	{
381cdf0e10cSrcweir 		m_xSAXEventKeeper = cssu::Reference< cssxc::sax::XSecuritySAXEventKeeper >(
382cdf0e10cSrcweir 			xMCF->createInstanceWithContext( sSAXEventKeeper, mxCtx ),
383cdf0e10cSrcweir 			cssu::UNO_QUERY );
384cdf0e10cSrcweir 	}
385cdf0e10cSrcweir 
386cdf0e10cSrcweir 	bSuccess &= (0!=m_xSAXEventKeeper.is());
387cdf0e10cSrcweir 
388cdf0e10cSrcweir 	if (bSuccess)
389cdf0e10cSrcweir 	/*
390cdf0e10cSrcweir 	 * SAXEventKeeper created successfully.
391cdf0e10cSrcweir 	 */
392cdf0e10cSrcweir 	{
393cdf0e10cSrcweir 		cssu::Reference< cssl::XInitialization > xInitialization(m_xSAXEventKeeper,  cssu::UNO_QUERY);
394cdf0e10cSrcweir 
395cdf0e10cSrcweir 		cssu::Sequence <cssu::Any> arg(1);
396cdf0e10cSrcweir 		arg[0] = cssu::makeAny(m_xXMLDocumentWrapper);
397cdf0e10cSrcweir 		xInitialization->initialize(arg);
398cdf0e10cSrcweir 
399cdf0e10cSrcweir 		cssu::Reference<cssxc::sax::XSAXEventKeeperStatusChangeBroadcaster>
400cdf0e10cSrcweir 			xSAXEventKeeperStatusChangeBroadcaster(m_xSAXEventKeeper, cssu::UNO_QUERY);
401cdf0e10cSrcweir 		cssu::Reference< cssxc::sax::XSAXEventKeeperStatusChangeListener >
402cdf0e10cSrcweir 			xStatusChangeListener = this;
403cdf0e10cSrcweir 
404cdf0e10cSrcweir 		xSAXEventKeeperStatusChangeBroadcaster
405cdf0e10cSrcweir 			->addSAXEventKeeperStatusChangeListener( xStatusChangeListener );
406cdf0e10cSrcweir 
407cdf0e10cSrcweir 		m_nStatusOfSecurityComponents = INITIALIZED;
408cdf0e10cSrcweir 	}
409cdf0e10cSrcweir }
410cdf0e10cSrcweir 
chainOn(bool bRetrievingLastEvent)411cdf0e10cSrcweir bool XSecController::chainOn( bool bRetrievingLastEvent )
412cdf0e10cSrcweir /****** XSecController/chainOn ************************************************
413cdf0e10cSrcweir  *
414cdf0e10cSrcweir  *   NAME
415cdf0e10cSrcweir  *	chainOn -- tyies to connect the SAXEventKeeper with the SAX chain.
416cdf0e10cSrcweir  *
417cdf0e10cSrcweir  *   SYNOPSIS
418cdf0e10cSrcweir  *	bJustChainingOn = chainOn( bRetrievingLastEvent );
419cdf0e10cSrcweir  *
420cdf0e10cSrcweir  *   FUNCTION
421cdf0e10cSrcweir  *	First, checks whether the SAXEventKeeper is on the SAX chain. If not,
422cdf0e10cSrcweir  *	creates xml security components, and chains the SAXEventKeeper into
423cdf0e10cSrcweir  *	the SAX chain.
424cdf0e10cSrcweir  *	Before being chained in, the SAXEventKeeper needs to receive all
425cdf0e10cSrcweir  *	missed key SAX events, which can promise the DOM tree bufferred by the
426cdf0e10cSrcweir  *	SAXEventKeeper has the same structure with the original document.
427cdf0e10cSrcweir  *
428cdf0e10cSrcweir  *   INPUTS
429cdf0e10cSrcweir  *	bRetrievingLastEvent - whether to retrieve the last key SAX event from
430cdf0e10cSrcweir  *	                       the ElementStackKeeper.
431cdf0e10cSrcweir  *
432cdf0e10cSrcweir  *   RESULT
433cdf0e10cSrcweir  *	bJustChainingOn - whether the SAXEventKeeper is just chained into the
434cdf0e10cSrcweir  *	                  SAX chain.
435cdf0e10cSrcweir  *
436cdf0e10cSrcweir  *   NOTES
437cdf0e10cSrcweir  *	Sometimes, the last key SAX event can't be transferred to the
438cdf0e10cSrcweir  *	SAXEventKeeper together.
439cdf0e10cSrcweir  *	For instance, at the time an referenced element is detected, the
440cdf0e10cSrcweir  *	startElement event has already been reserved by the ElementStackKeeper.
441cdf0e10cSrcweir  *	Meanwhile, an ElementCollector needs to be created before the
442cdf0e10cSrcweir  *	SAXEventKeeper receives that startElement event.
443cdf0e10cSrcweir  *	So for the SAXEventKeeper, it needs to receive all missed key SAX
444cdf0e10cSrcweir  *	events except that startElement event, then adds a new
445cdf0e10cSrcweir  *	ElementCollector, then receives that startElement event.
446cdf0e10cSrcweir  *
447cdf0e10cSrcweir  *   HISTORY
448cdf0e10cSrcweir  *	05.01.2004 -	implemented
449cdf0e10cSrcweir  *
450cdf0e10cSrcweir  *   AUTHOR
451cdf0e10cSrcweir  *	Michael Mi
452cdf0e10cSrcweir  *	Email: michael.mi@sun.com
453cdf0e10cSrcweir  ******************************************************************************/
454cdf0e10cSrcweir {
455cdf0e10cSrcweir 	bool rc = false;
456cdf0e10cSrcweir 
457cdf0e10cSrcweir 	if (!m_bIsSAXEventKeeperSticky && !m_bIsSAXEventKeeperConnected)
458cdf0e10cSrcweir 	{
459cdf0e10cSrcweir 		if ( m_nStatusOfSecurityComponents == UNINITIALIZED )
460cdf0e10cSrcweir 		{
461cdf0e10cSrcweir 			createXSecComponent();
462cdf0e10cSrcweir 		}
463cdf0e10cSrcweir 
464cdf0e10cSrcweir 		if ( m_nStatusOfSecurityComponents == INITIALIZED )
465cdf0e10cSrcweir 		/*
466cdf0e10cSrcweir 		 * if all security components are ready, chains on the SAXEventKeeper
467cdf0e10cSrcweir 		 */
468cdf0e10cSrcweir 		{
469cdf0e10cSrcweir 			/*
470cdf0e10cSrcweir 			 * disconnect the SAXEventKeeper with its current output handler,
471cdf0e10cSrcweir 			 * to make sure no SAX event is forwarded during the connecting
472cdf0e10cSrcweir 			 * phase.
473cdf0e10cSrcweir 			 */
474cdf0e10cSrcweir 			m_xSAXEventKeeper->setNextHandler( NULL );
475cdf0e10cSrcweir 
476cdf0e10cSrcweir 			cssu::Reference< cssxs::XDocumentHandler > xSEKHandler(m_xSAXEventKeeper, cssu::UNO_QUERY);
477cdf0e10cSrcweir 
478cdf0e10cSrcweir 			/*
479cdf0e10cSrcweir 			 * connects the previous document handler on the SAX chain
480cdf0e10cSrcweir 			 */
481cdf0e10cSrcweir 			if ( m_xPreviousNodeOnSAXChain.is() )
482cdf0e10cSrcweir 			{
483cdf0e10cSrcweir 				if ( m_bIsPreviousNodeInitializable )
484cdf0e10cSrcweir 				{
485cdf0e10cSrcweir 					cssu::Reference< cssl::XInitialization > xInitialization
486cdf0e10cSrcweir 						(m_xPreviousNodeOnSAXChain, cssu::UNO_QUERY);
487cdf0e10cSrcweir 
488cdf0e10cSrcweir 					cssu::Sequence<cssu::Any> aArgs( 1 );
489cdf0e10cSrcweir 					aArgs[0] <<= xSEKHandler;
490cdf0e10cSrcweir 					xInitialization->initialize(aArgs);
491cdf0e10cSrcweir 				}
492cdf0e10cSrcweir 				else
493cdf0e10cSrcweir 				{
494cdf0e10cSrcweir 					cssu::Reference< cssxs::XParser > xParser
495cdf0e10cSrcweir 						(m_xPreviousNodeOnSAXChain, cssu::UNO_QUERY);
496cdf0e10cSrcweir 					xParser->setDocumentHandler( xSEKHandler );
497cdf0e10cSrcweir 				}
498cdf0e10cSrcweir 			}
499cdf0e10cSrcweir 
500cdf0e10cSrcweir 			/*
501cdf0e10cSrcweir 			 * get missed key SAX events
502cdf0e10cSrcweir 			 */
503cdf0e10cSrcweir 			if (m_xElementStackKeeper.is())
504cdf0e10cSrcweir 			{
505cdf0e10cSrcweir 				m_xElementStackKeeper->retrieve(xSEKHandler, bRetrievingLastEvent);
506cdf0e10cSrcweir 
507cdf0e10cSrcweir 				/*
508cdf0e10cSrcweir 				 * now the ElementStackKeeper can stop its work, because the
509cdf0e10cSrcweir 				 * SAXEventKeeper is on the SAX chain, no SAX events will be
510cdf0e10cSrcweir 				 * missed.
511cdf0e10cSrcweir 				 */
512cdf0e10cSrcweir 				m_xElementStackKeeper->stop();
513cdf0e10cSrcweir 			}
514cdf0e10cSrcweir 
515cdf0e10cSrcweir 			/*
516cdf0e10cSrcweir 			 * connects the next document handler on the SAX chain
517cdf0e10cSrcweir 			 */
518cdf0e10cSrcweir 			m_xSAXEventKeeper->setNextHandler( m_xNextNodeOnSAXChain );
519cdf0e10cSrcweir 
520cdf0e10cSrcweir 			m_bIsSAXEventKeeperConnected = true;
521cdf0e10cSrcweir 
522cdf0e10cSrcweir 			rc = true;
523cdf0e10cSrcweir 		}
524cdf0e10cSrcweir 	}
525cdf0e10cSrcweir 
526cdf0e10cSrcweir 	return rc;
527cdf0e10cSrcweir }
528cdf0e10cSrcweir 
chainOff()529cdf0e10cSrcweir void XSecController::chainOff()
530cdf0e10cSrcweir /****** XSecController/chainOff ***********************************************
531cdf0e10cSrcweir  *
532cdf0e10cSrcweir  *   NAME
533cdf0e10cSrcweir  *	chainOff -- disconnects the SAXEventKeeper from the SAX chain.
534cdf0e10cSrcweir  *
535cdf0e10cSrcweir  *   SYNOPSIS
536cdf0e10cSrcweir  *	chainOff( );
537cdf0e10cSrcweir  *
538cdf0e10cSrcweir  *   FUNCTION
539cdf0e10cSrcweir  *	See NAME.
540cdf0e10cSrcweir  *
541cdf0e10cSrcweir  *   INPUTS
542cdf0e10cSrcweir  *	empty
543cdf0e10cSrcweir  *
544cdf0e10cSrcweir  *   RESULT
545cdf0e10cSrcweir  *	empty
546cdf0e10cSrcweir  *
547cdf0e10cSrcweir  *   HISTORY
548cdf0e10cSrcweir  *	05.01.2004 -	implemented
549cdf0e10cSrcweir  *
550cdf0e10cSrcweir  *   AUTHOR
551cdf0e10cSrcweir  *	Michael Mi
552cdf0e10cSrcweir  *	Email: michael.mi@sun.com
553cdf0e10cSrcweir  ******************************************************************************/
554cdf0e10cSrcweir {
555cdf0e10cSrcweir 	if (!m_bIsSAXEventKeeperSticky )
556cdf0e10cSrcweir 	{
557cdf0e10cSrcweir 		if (m_bIsSAXEventKeeperConnected)
558cdf0e10cSrcweir 		{
559cdf0e10cSrcweir 			m_xSAXEventKeeper->setNextHandler( NULL );
560cdf0e10cSrcweir 
561cdf0e10cSrcweir 			if ( m_xPreviousNodeOnSAXChain.is() )
562cdf0e10cSrcweir 			{
563cdf0e10cSrcweir 				if ( m_bIsPreviousNodeInitializable )
564cdf0e10cSrcweir 				{
565cdf0e10cSrcweir 					cssu::Reference< cssl::XInitialization > xInitialization
566cdf0e10cSrcweir 						(m_xPreviousNodeOnSAXChain, cssu::UNO_QUERY);
567cdf0e10cSrcweir 
568cdf0e10cSrcweir 					cssu::Sequence<cssu::Any> aArgs( 1 );
569cdf0e10cSrcweir 					aArgs[0] <<= m_xNextNodeOnSAXChain;
570cdf0e10cSrcweir 					xInitialization->initialize(aArgs);
571cdf0e10cSrcweir 				}
572cdf0e10cSrcweir 				else
573cdf0e10cSrcweir 				{
574cdf0e10cSrcweir 					cssu::Reference< cssxs::XParser > xParser(m_xPreviousNodeOnSAXChain, cssu::UNO_QUERY);
575cdf0e10cSrcweir 					xParser->setDocumentHandler( m_xNextNodeOnSAXChain );
576cdf0e10cSrcweir 				}
577cdf0e10cSrcweir 			}
578cdf0e10cSrcweir 
579cdf0e10cSrcweir 			if (m_xElementStackKeeper.is())
580cdf0e10cSrcweir 			{
581cdf0e10cSrcweir 				/*
582cdf0e10cSrcweir 				 * start the ElementStackKeeper to reserve any possible
583cdf0e10cSrcweir 				 * missed key SAX events
584cdf0e10cSrcweir 				 */
585cdf0e10cSrcweir 				m_xElementStackKeeper->start();
586cdf0e10cSrcweir 			}
587cdf0e10cSrcweir 
588cdf0e10cSrcweir 			m_bIsSAXEventKeeperConnected = false;
589cdf0e10cSrcweir 		}
590cdf0e10cSrcweir 	}
591cdf0e10cSrcweir }
592cdf0e10cSrcweir 
checkChainingStatus()593cdf0e10cSrcweir void XSecController::checkChainingStatus()
594cdf0e10cSrcweir /****** XSecController/checkChainingStatus ************************************
595cdf0e10cSrcweir  *
596cdf0e10cSrcweir  *   NAME
597cdf0e10cSrcweir  *	checkChainingStatus -- connects or disconnects the SAXEventKeeper
598cdf0e10cSrcweir  *	according to the current situation.
599cdf0e10cSrcweir  *
600cdf0e10cSrcweir  *   SYNOPSIS
601cdf0e10cSrcweir  *	checkChainingStatus( );
602cdf0e10cSrcweir  *
603cdf0e10cSrcweir  *   FUNCTION
604cdf0e10cSrcweir  *	The SAXEventKeeper is chained into the SAX chain, when:
605cdf0e10cSrcweir  *	1. some element is being collected, or
606cdf0e10cSrcweir  *	2. the SAX event stream is blocking.
607cdf0e10cSrcweir  *	Otherwise, chain off the SAXEventKeeper.
608cdf0e10cSrcweir  *
609cdf0e10cSrcweir  *   INPUTS
610cdf0e10cSrcweir  *	empty
611cdf0e10cSrcweir  *
612cdf0e10cSrcweir  *   RESULT
613cdf0e10cSrcweir  *	empty
614cdf0e10cSrcweir  *
615cdf0e10cSrcweir  *   HISTORY
616cdf0e10cSrcweir  *	05.01.2004 -	implemented
617cdf0e10cSrcweir  *
618cdf0e10cSrcweir  *   AUTHOR
619cdf0e10cSrcweir  *	Michael Mi
620cdf0e10cSrcweir  *	Email: michael.mi@sun.com
621cdf0e10cSrcweir  ******************************************************************************/
622cdf0e10cSrcweir {
623cdf0e10cSrcweir 	if ( m_bIsCollectingElement || m_bIsBlocking )
624cdf0e10cSrcweir 	{
625cdf0e10cSrcweir 		chainOn(true);
626cdf0e10cSrcweir 	}
627cdf0e10cSrcweir 	else
628cdf0e10cSrcweir 	{
629cdf0e10cSrcweir 		chainOff();
630cdf0e10cSrcweir 	}
631cdf0e10cSrcweir }
632cdf0e10cSrcweir 
initializeSAXChain()633cdf0e10cSrcweir void XSecController::initializeSAXChain()
634cdf0e10cSrcweir /****** XSecController/initializeSAXChain *************************************
635cdf0e10cSrcweir  *
636cdf0e10cSrcweir  *   NAME
637cdf0e10cSrcweir  *	initializeSAXChain -- initializes the SAX chain according to the
638cdf0e10cSrcweir  *	current setting.
639cdf0e10cSrcweir  *
640cdf0e10cSrcweir  *   SYNOPSIS
641cdf0e10cSrcweir  *	initializeSAXChain( );
642cdf0e10cSrcweir  *
643cdf0e10cSrcweir  *   FUNCTION
644cdf0e10cSrcweir  *	Initializes the SAX chain, if the SAXEventKeeper is asked to be always
645cdf0e10cSrcweir  *	on the SAX chain, chains it on. Otherwise, starts the
646cdf0e10cSrcweir  *	ElementStackKeeper to reserve key SAX events.
647cdf0e10cSrcweir  *
648cdf0e10cSrcweir  *   INPUTS
649cdf0e10cSrcweir  *	empty
650cdf0e10cSrcweir  *
651cdf0e10cSrcweir  *   RESULT
652cdf0e10cSrcweir  *	empty
653cdf0e10cSrcweir  *
654cdf0e10cSrcweir  *   HISTORY
655cdf0e10cSrcweir  *	05.01.2004 -	implemented
656cdf0e10cSrcweir  *
657cdf0e10cSrcweir  *   AUTHOR
658cdf0e10cSrcweir  *	Michael Mi
659cdf0e10cSrcweir  *	Email: michael.mi@sun.com
660cdf0e10cSrcweir  ******************************************************************************/
661cdf0e10cSrcweir {
662cdf0e10cSrcweir 	m_bIsSAXEventKeeperConnected = false;
663cdf0e10cSrcweir 	m_bIsCollectingElement = false;
664cdf0e10cSrcweir 	m_bIsBlocking = false;
665cdf0e10cSrcweir 
666cdf0e10cSrcweir 	if (m_xElementStackKeeper.is())
667cdf0e10cSrcweir 	{
668cdf0e10cSrcweir 		/*
669cdf0e10cSrcweir 		 * starts the ElementStackKeeper
670cdf0e10cSrcweir 		 */
671cdf0e10cSrcweir 		m_xElementStackKeeper->start();
672cdf0e10cSrcweir 	}
673cdf0e10cSrcweir 
674cdf0e10cSrcweir 	chainOff();
675cdf0e10cSrcweir }
676cdf0e10cSrcweir 
677cdf0e10cSrcweir cssu::Reference< com::sun::star::io::XInputStream >
getObjectInputStream(const rtl::OUString & objectURL)678cdf0e10cSrcweir 	XSecController::getObjectInputStream( const rtl::OUString& objectURL )
679cdf0e10cSrcweir /****** XSecController/getObjectInputStream ************************************
680cdf0e10cSrcweir  *
681cdf0e10cSrcweir  *   NAME
682cdf0e10cSrcweir  *	getObjectInputStream -- get a XInputStream interface from a SvStorage
683cdf0e10cSrcweir  *
684cdf0e10cSrcweir  *   SYNOPSIS
685cdf0e10cSrcweir  *	xInputStream = getObjectInputStream( objectURL );
686cdf0e10cSrcweir  *
687cdf0e10cSrcweir  *   FUNCTION
688cdf0e10cSrcweir  *	See NAME.
689cdf0e10cSrcweir  *
690cdf0e10cSrcweir  *   INPUTS
691cdf0e10cSrcweir  *	objectURL - the object uri
692cdf0e10cSrcweir  *
693cdf0e10cSrcweir  *   RESULT
694cdf0e10cSrcweir  *	xInputStream - the XInputStream interface
695cdf0e10cSrcweir  *
696cdf0e10cSrcweir  *   HISTORY
697cdf0e10cSrcweir  *	15.04.2004 -	implemented
698cdf0e10cSrcweir  *
699cdf0e10cSrcweir  *   AUTHOR
700cdf0e10cSrcweir  *	Michael Mi
701cdf0e10cSrcweir  *	Email: michael.mi@sun.com
702cdf0e10cSrcweir  ******************************************************************************/
703cdf0e10cSrcweir {
704cdf0e10cSrcweir         cssu::Reference< com::sun::star::io::XInputStream > xObjectInputStream;
705cdf0e10cSrcweir 
706cdf0e10cSrcweir 	DBG_ASSERT( m_xUriBinding.is(), "Need XUriBinding!" );
707cdf0e10cSrcweir 
708cdf0e10cSrcweir 	xObjectInputStream = m_xUriBinding->getUriBinding(objectURL);
709cdf0e10cSrcweir 
710cdf0e10cSrcweir 	return xObjectInputStream;
711cdf0e10cSrcweir }
712cdf0e10cSrcweir 
713cdf0e10cSrcweir #if 0
714cdf0e10cSrcweir sal_Int32 XSecController::getFastPropertyIndex(sal_Int32 nHandle) const
715cdf0e10cSrcweir /****** XSecController/getFastPropertyIndex ***********************************
716cdf0e10cSrcweir  *
717cdf0e10cSrcweir  *   NAME
718cdf0e10cSrcweir  *	getFastPropertyIndex -- gets the index of a particular fast property
719cdf0e10cSrcweir  *
720cdf0e10cSrcweir  *   SYNOPSIS
721cdf0e10cSrcweir  *	nIndex = getFastPropertyIndex( nHandle );
722cdf0e10cSrcweir  *
723cdf0e10cSrcweir  *   FUNCTION
724cdf0e10cSrcweir  *	See NAME.
725cdf0e10cSrcweir  *
726cdf0e10cSrcweir  *   INPUTS
727cdf0e10cSrcweir  *	nHandle - the key for the fast property
728cdf0e10cSrcweir  *
729cdf0e10cSrcweir  *   RESULT
730cdf0e10cSrcweir  *	nIndex - the index of the fast property, or -1
731cdf0e10cSrcweir  *	         if the key is not found.
732cdf0e10cSrcweir  *
733cdf0e10cSrcweir  *   HISTORY
734cdf0e10cSrcweir  *	05.01.2004 -	implemented
735cdf0e10cSrcweir  *
736cdf0e10cSrcweir  *   AUTHOR
737cdf0e10cSrcweir  *	Michael Mi
738cdf0e10cSrcweir  *	Email: michael.mi@sun.com
739cdf0e10cSrcweir  ******************************************************************************/
740cdf0e10cSrcweir {
741cdf0e10cSrcweir 	std::vector< sal_Int32 >::const_iterator ii = m_vFastPropertyIndexs.begin();
742cdf0e10cSrcweir 	sal_Int32 nIndex = 0;
743cdf0e10cSrcweir 
744cdf0e10cSrcweir 	bool bFound = false;
745cdf0e10cSrcweir 
746cdf0e10cSrcweir 	for( ; ii != m_vFastPropertyIndexs.end(); ++ii,++nIndex )
747cdf0e10cSrcweir 	{
748cdf0e10cSrcweir 		if ( nHandle == (*ii))
749cdf0e10cSrcweir 		{
750cdf0e10cSrcweir 			bFound = true;
751cdf0e10cSrcweir 			break;
752cdf0e10cSrcweir 		}
753cdf0e10cSrcweir 	}
754cdf0e10cSrcweir 
755cdf0e10cSrcweir 	if (!bFound)
756cdf0e10cSrcweir 	{
757cdf0e10cSrcweir 		nIndex = -1;
758cdf0e10cSrcweir 	}
759cdf0e10cSrcweir 
760cdf0e10cSrcweir 	return nIndex;
761cdf0e10cSrcweir }
762cdf0e10cSrcweir #endif
763cdf0e10cSrcweir 
764cdf0e10cSrcweir /*
765cdf0e10cSrcweir  * public methods
766cdf0e10cSrcweir  */
767cdf0e10cSrcweir 
getNewSecurityId()768cdf0e10cSrcweir sal_Int32 XSecController::getNewSecurityId(  )
769cdf0e10cSrcweir {
770cdf0e10cSrcweir 	sal_Int32 nId = m_nNextSecurityId;
771cdf0e10cSrcweir 	m_nNextSecurityId++;
772cdf0e10cSrcweir 	return nId;
773cdf0e10cSrcweir }
774cdf0e10cSrcweir 
startMission(const cssu::Reference<cssxc::XUriBinding> & xUriBinding,const cssu::Reference<cssxc::XXMLSecurityContext> & xSecurityContext)775cdf0e10cSrcweir void XSecController::startMission(
776cdf0e10cSrcweir 	const cssu::Reference< cssxc::XUriBinding >& xUriBinding,
777cdf0e10cSrcweir 	const cssu::Reference< cssxc::XXMLSecurityContext >& xSecurityContext )
778cdf0e10cSrcweir /****** XSecController/startMission *******************************************
779cdf0e10cSrcweir  *
780cdf0e10cSrcweir  *   NAME
781cdf0e10cSrcweir  *	startMission -- starts a new security mission.
782cdf0e10cSrcweir  *
783cdf0e10cSrcweir  *   SYNOPSIS
784cdf0e10cSrcweir  *	startMission( xUriBinding, xSecurityContect );
785cdf0e10cSrcweir  *
786cdf0e10cSrcweir  *   FUNCTION
787cdf0e10cSrcweir  *	get ready for a new mission.
788cdf0e10cSrcweir  *
789cdf0e10cSrcweir  *   INPUTS
790cdf0e10cSrcweir  *	xUriBinding       - the Uri binding that provide maps between uris and
791cdf0e10cSrcweir  *                          XInputStreams
792cdf0e10cSrcweir  *	xSecurityContext  - the security context component which can provide
793cdf0e10cSrcweir  *	                    cryptoken
794cdf0e10cSrcweir  *
795cdf0e10cSrcweir  *   RESULT
796cdf0e10cSrcweir  *	empty
797cdf0e10cSrcweir  *
798cdf0e10cSrcweir  *   HISTORY
799cdf0e10cSrcweir  *	05.01.2004 -	implemented
800cdf0e10cSrcweir  *
801cdf0e10cSrcweir  *   AUTHOR
802cdf0e10cSrcweir  *	Michael Mi
803cdf0e10cSrcweir  *	Email: michael.mi@sun.com
804cdf0e10cSrcweir  ******************************************************************************/
805cdf0e10cSrcweir {
806cdf0e10cSrcweir 	m_xUriBinding = xUriBinding;
807cdf0e10cSrcweir 
808cdf0e10cSrcweir 	m_nStatusOfSecurityComponents = UNINITIALIZED;
809cdf0e10cSrcweir 	m_xSecurityContext = xSecurityContext;
810cdf0e10cSrcweir 	m_pErrorMessage = NULL;
811cdf0e10cSrcweir 
812cdf0e10cSrcweir 	m_vInternalSignatureInformations.clear();
813cdf0e10cSrcweir 
814cdf0e10cSrcweir 	m_bVerifyCurrentSignature = false;
815cdf0e10cSrcweir }
816cdf0e10cSrcweir 
setSAXChainConnector(const cssu::Reference<cssl::XInitialization> & xInitialization,const cssu::Reference<cssxs::XDocumentHandler> & xDocumentHandler,const cssu::Reference<cssxc::sax::XElementStackKeeper> & xElementStackKeeper)817cdf0e10cSrcweir void XSecController::setSAXChainConnector(
818cdf0e10cSrcweir 	const cssu::Reference< cssl::XInitialization >& xInitialization,
819cdf0e10cSrcweir 	const cssu::Reference< cssxs::XDocumentHandler >& xDocumentHandler,
820cdf0e10cSrcweir 	const cssu::Reference< cssxc::sax::XElementStackKeeper >& xElementStackKeeper)
821cdf0e10cSrcweir /****** XSecController/setSAXChainConnector ***********************************
822cdf0e10cSrcweir  *
823cdf0e10cSrcweir  *   NAME
824cdf0e10cSrcweir  *	setSAXChainConnector -- configures the components which will
825cdf0e10cSrcweir  *	collaborate with the SAXEventKeeper on the SAX chain.
826cdf0e10cSrcweir  *
827cdf0e10cSrcweir  *   SYNOPSIS
828cdf0e10cSrcweir  *	setSAXChainConnector( xInitialization,
829cdf0e10cSrcweir  *	                      xDocumentHandler,
830cdf0e10cSrcweir  *	                      xElementStackKeeper );
831cdf0e10cSrcweir  *
832cdf0e10cSrcweir  *   FUNCTION
833cdf0e10cSrcweir  *	See NAME.
834cdf0e10cSrcweir  *
835cdf0e10cSrcweir  *   INPUTS
836cdf0e10cSrcweir  *	xInitialization     - the previous node on the SAX chain
837cdf0e10cSrcweir  *	xDocumentHandler    - the next node on the SAX chain
838cdf0e10cSrcweir  *	xElementStackKeeper - the ElementStackKeeper component which reserves
839cdf0e10cSrcweir  *	                      missed key SAX events for the SAXEventKeeper
840cdf0e10cSrcweir  *
841cdf0e10cSrcweir  *   RESULT
842cdf0e10cSrcweir  *	empty
843cdf0e10cSrcweir  *
844cdf0e10cSrcweir  *   HISTORY
845cdf0e10cSrcweir  *	05.01.2004 -	implemented
846cdf0e10cSrcweir  *
847cdf0e10cSrcweir  *   AUTHOR
848cdf0e10cSrcweir  *	Michael Mi
849cdf0e10cSrcweir  *	Email: michael.mi@sun.com
850cdf0e10cSrcweir  ******************************************************************************/
851cdf0e10cSrcweir {
852cdf0e10cSrcweir 	m_bIsPreviousNodeInitializable = true;
853cdf0e10cSrcweir 	m_xPreviousNodeOnSAXChain = xInitialization;
854cdf0e10cSrcweir 	m_xNextNodeOnSAXChain = xDocumentHandler;
855cdf0e10cSrcweir 	m_xElementStackKeeper = xElementStackKeeper;
856cdf0e10cSrcweir 
857cdf0e10cSrcweir 	initializeSAXChain( );
858cdf0e10cSrcweir }
859cdf0e10cSrcweir 
setSAXChainConnector(const cssu::Reference<cssxs::XParser> & xParser,const cssu::Reference<cssxs::XDocumentHandler> & xDocumentHandler,const cssu::Reference<cssxc::sax::XElementStackKeeper> & xElementStackKeeper)860cdf0e10cSrcweir void XSecController::setSAXChainConnector(
861cdf0e10cSrcweir 	const cssu::Reference< cssxs::XParser >& xParser,
862cdf0e10cSrcweir 	const cssu::Reference< cssxs::XDocumentHandler >& xDocumentHandler,
863cdf0e10cSrcweir 	const cssu::Reference< cssxc::sax::XElementStackKeeper >& xElementStackKeeper)
864cdf0e10cSrcweir /****** XSecController/setSAXChainConnector ***********************************
865cdf0e10cSrcweir  *
866cdf0e10cSrcweir  *   NAME
867cdf0e10cSrcweir  *	setSAXChainConnector -- configures the components which will
868cdf0e10cSrcweir  *	collaborate with the SAXEventKeeper on the SAX chain.
869cdf0e10cSrcweir  *
870cdf0e10cSrcweir  *   SYNOPSIS
871cdf0e10cSrcweir  *	setSAXChainConnector( xParser, xDocumentHandler, xElementStackKeeper );
872cdf0e10cSrcweir  *
873cdf0e10cSrcweir  *   FUNCTION
874cdf0e10cSrcweir  *	See NAME.
875cdf0e10cSrcweir  *
876cdf0e10cSrcweir  *   INPUTS
877cdf0e10cSrcweir  *	xParser             - the previous node on the SAX chain
878cdf0e10cSrcweir  *	xDocumentHandler    - the next node on the SAX chain
879cdf0e10cSrcweir  *	xElementStackKeeper -the ElementStackKeeper component which reserves
880cdf0e10cSrcweir  *	                      missed key SAX events for the SAXEventKeeper
881cdf0e10cSrcweir  *
882cdf0e10cSrcweir  *   RESULT
883cdf0e10cSrcweir  *	empty
884cdf0e10cSrcweir  *
885cdf0e10cSrcweir  *   HISTORY
886cdf0e10cSrcweir  *	05.01.2004 -	implemented
887cdf0e10cSrcweir  *
888cdf0e10cSrcweir  *   AUTHOR
889cdf0e10cSrcweir  *	Michael Mi
890cdf0e10cSrcweir  *	Email: michael.mi@sun.com
891cdf0e10cSrcweir  ******************************************************************************/
892cdf0e10cSrcweir {
893cdf0e10cSrcweir 	m_bIsPreviousNodeInitializable = false;
894cdf0e10cSrcweir 	m_xPreviousNodeOnSAXChain = xParser;
895cdf0e10cSrcweir 	m_xNextNodeOnSAXChain = xDocumentHandler;
896cdf0e10cSrcweir 	m_xElementStackKeeper = xElementStackKeeper;
897cdf0e10cSrcweir 
898cdf0e10cSrcweir 	initializeSAXChain( );
899cdf0e10cSrcweir }
900cdf0e10cSrcweir 
clearSAXChainConnector()901cdf0e10cSrcweir void XSecController::clearSAXChainConnector()
902cdf0e10cSrcweir /****** XSecController/clearSAXChainConnector *********************************
903cdf0e10cSrcweir  *
904cdf0e10cSrcweir  *   NAME
905cdf0e10cSrcweir  *	clearSAXChainConnector -- resets the collaborating components.
906cdf0e10cSrcweir  *
907cdf0e10cSrcweir  *   SYNOPSIS
908cdf0e10cSrcweir  *	clearSAXChainConnector( );
909cdf0e10cSrcweir  *
910cdf0e10cSrcweir  *   FUNCTION
911cdf0e10cSrcweir  *	See NAME.
912cdf0e10cSrcweir  *
913cdf0e10cSrcweir  *   INPUTS
914cdf0e10cSrcweir  *	empty
915cdf0e10cSrcweir  *
916cdf0e10cSrcweir  *   RESULT
917cdf0e10cSrcweir  *	empty
918cdf0e10cSrcweir  *
919cdf0e10cSrcweir  *   HISTORY
920cdf0e10cSrcweir  *	05.01.2004 -	implemented
921cdf0e10cSrcweir  *
922cdf0e10cSrcweir  *   AUTHOR
923cdf0e10cSrcweir  *	Michael Mi
924cdf0e10cSrcweir  *	Email: michael.mi@sun.com
925cdf0e10cSrcweir  ******************************************************************************/
926cdf0e10cSrcweir {
927cdf0e10cSrcweir 	/*
928cdf0e10cSrcweir 	 * before reseting, if the ElementStackKeeper has kept something, then
929cdf0e10cSrcweir 	 * those kept key SAX events must be transferred to the SAXEventKeeper
930cdf0e10cSrcweir 	 * first. This is to promise the next node to the SAXEventKeeper on the
931cdf0e10cSrcweir 	 * SAX chain always receives a complete document.
932cdf0e10cSrcweir 	 */
933cdf0e10cSrcweir 	if (m_xElementStackKeeper.is() && m_xSAXEventKeeper.is())
934cdf0e10cSrcweir 	{
935cdf0e10cSrcweir 		cssu::Reference< cssxs::XDocumentHandler > xSEKHandler(m_xSAXEventKeeper, cssu::UNO_QUERY);
936cdf0e10cSrcweir 		m_xElementStackKeeper->retrieve(xSEKHandler, sal_True);
937cdf0e10cSrcweir 	}
938cdf0e10cSrcweir 
939cdf0e10cSrcweir 	chainOff();
940cdf0e10cSrcweir 
941cdf0e10cSrcweir 	m_xPreviousNodeOnSAXChain = NULL;
942cdf0e10cSrcweir 	m_xNextNodeOnSAXChain = NULL;
943cdf0e10cSrcweir 	m_xElementStackKeeper = NULL;
944cdf0e10cSrcweir }
945cdf0e10cSrcweir 
endMission()946cdf0e10cSrcweir void XSecController::endMission()
947cdf0e10cSrcweir /****** XSecController/endMission *********************************************
948cdf0e10cSrcweir  *
949cdf0e10cSrcweir  *   NAME
950cdf0e10cSrcweir  *	endMission -- forces to end all missions
951cdf0e10cSrcweir  *
952cdf0e10cSrcweir  *   SYNOPSIS
953cdf0e10cSrcweir  *	endMission( );
954cdf0e10cSrcweir  *
955cdf0e10cSrcweir  *   FUNCTION
956cdf0e10cSrcweir  *	Deletes all signature information and forces all missions to an end.
957cdf0e10cSrcweir  *
958cdf0e10cSrcweir  *   INPUTS
959cdf0e10cSrcweir  *	empty
960cdf0e10cSrcweir  *
961cdf0e10cSrcweir  *   RESULT
962cdf0e10cSrcweir  *	empty
963cdf0e10cSrcweir  *
964cdf0e10cSrcweir  *   HISTORY
965cdf0e10cSrcweir  *	05.01.2004 -	implemented
966cdf0e10cSrcweir  *
967cdf0e10cSrcweir  *   AUTHOR
968cdf0e10cSrcweir  *	Michael Mi
969cdf0e10cSrcweir  *	Email: michael.mi@sun.com
970cdf0e10cSrcweir  ******************************************************************************/
971cdf0e10cSrcweir {
972cdf0e10cSrcweir 	sal_Int32 size = m_vInternalSignatureInformations.size();
973cdf0e10cSrcweir 
974cdf0e10cSrcweir 	for (int i=0; i<size; ++i)
975cdf0e10cSrcweir 	{
976cdf0e10cSrcweir 		if ( m_nStatusOfSecurityComponents == INITIALIZED )
977cdf0e10cSrcweir 		/*
978cdf0e10cSrcweir 		 * ResolvedListener only exist when the security components are created.
979cdf0e10cSrcweir 		 */
980cdf0e10cSrcweir 		{
981cdf0e10cSrcweir 			cssu::Reference< cssxc::sax::XMissionTaker > xMissionTaker
982cdf0e10cSrcweir 				( m_vInternalSignatureInformations[i].xReferenceResolvedListener, cssu::UNO_QUERY );
983cdf0e10cSrcweir 
984cdf0e10cSrcweir 			/*
985cdf0e10cSrcweir 			 * askes the SignatureCreator/SignatureVerifier to release
986cdf0e10cSrcweir 			 * all resouces it uses.
987cdf0e10cSrcweir 			 */
988cdf0e10cSrcweir 			xMissionTaker->endMission();
989cdf0e10cSrcweir 		}
990cdf0e10cSrcweir 	}
991cdf0e10cSrcweir 
992cdf0e10cSrcweir 	m_xUriBinding = NULL;
993cdf0e10cSrcweir 	m_xSecurityContext = NULL;
994cdf0e10cSrcweir 
995cdf0e10cSrcweir 	/*
996cdf0e10cSrcweir 	 * free the status change listener reference to this object
997cdf0e10cSrcweir 	 */
998cdf0e10cSrcweir 	if (m_xSAXEventKeeper.is())
999cdf0e10cSrcweir 	{
1000cdf0e10cSrcweir 		cssu::Reference<cssxc::sax::XSAXEventKeeperStatusChangeBroadcaster>
1001cdf0e10cSrcweir 			xSAXEventKeeperStatusChangeBroadcaster(m_xSAXEventKeeper, cssu::UNO_QUERY);
1002cdf0e10cSrcweir 		xSAXEventKeeperStatusChangeBroadcaster
1003cdf0e10cSrcweir 			->addSAXEventKeeperStatusChangeListener( NULL );
1004cdf0e10cSrcweir 	}
1005cdf0e10cSrcweir }
1006cdf0e10cSrcweir 
getErrorMessage()1007cdf0e10cSrcweir const char* XSecController::getErrorMessage()
1008cdf0e10cSrcweir /****** XSecController/getErrorMessage ****************************************
1009cdf0e10cSrcweir  *
1010cdf0e10cSrcweir  *   NAME
1011cdf0e10cSrcweir  *	getErrorMessage -- get the last error message
1012cdf0e10cSrcweir  *
1013cdf0e10cSrcweir  *   SYNOPSIS
1014cdf0e10cSrcweir  *	pErrorMessage = getErrorMessage( );
1015cdf0e10cSrcweir  *
1016cdf0e10cSrcweir  *   FUNCTION
1017cdf0e10cSrcweir  *	see NAME.
1018cdf0e10cSrcweir  *
1019cdf0e10cSrcweir  *   INPUTS
1020cdf0e10cSrcweir  *	empty
1021cdf0e10cSrcweir  *
1022cdf0e10cSrcweir  *   RESULT
1023cdf0e10cSrcweir  *	empty
1024cdf0e10cSrcweir  *
1025cdf0e10cSrcweir  *   HISTORY
1026cdf0e10cSrcweir  *	22.04.2004 -	implemented
1027cdf0e10cSrcweir  *
1028cdf0e10cSrcweir  *   AUTHOR
1029cdf0e10cSrcweir  *	Michael Mi
1030cdf0e10cSrcweir  *	Email: michael.mi@sun.com
1031cdf0e10cSrcweir  ******************************************************************************/
1032cdf0e10cSrcweir {
1033cdf0e10cSrcweir 	return m_pErrorMessage;
1034cdf0e10cSrcweir }
1035cdf0e10cSrcweir 
exportSignature(const cssu::Reference<cssxs::XDocumentHandler> & xDocumentHandler,const SignatureInformation & signatureInfo)1036cdf0e10cSrcweir void XSecController::exportSignature(
1037cdf0e10cSrcweir 	const cssu::Reference<cssxs::XDocumentHandler>& xDocumentHandler,
1038cdf0e10cSrcweir 	const SignatureInformation& signatureInfo )
1039cdf0e10cSrcweir /****** XSecController/exportSignature ****************************************
1040cdf0e10cSrcweir  *
1041cdf0e10cSrcweir  *   NAME
1042cdf0e10cSrcweir  *	exportSignature -- export a signature structure to an XDocumentHandler
1043cdf0e10cSrcweir  *
1044cdf0e10cSrcweir  *   SYNOPSIS
1045cdf0e10cSrcweir  *	exportSignature( xDocumentHandler, signatureInfo);
1046cdf0e10cSrcweir  *
1047cdf0e10cSrcweir  *   FUNCTION
1048cdf0e10cSrcweir  *	see NAME.
1049cdf0e10cSrcweir  *
1050cdf0e10cSrcweir  *   INPUTS
1051cdf0e10cSrcweir  *	xDocumentHandler    - the document handler to receive the signature
1052cdf0e10cSrcweir  *	signatureInfo       - signature to be exported
1053cdf0e10cSrcweir  *
1054cdf0e10cSrcweir  *   RESULT
1055cdf0e10cSrcweir  *	empty
1056cdf0e10cSrcweir  *
1057cdf0e10cSrcweir  *   HISTORY
1058cdf0e10cSrcweir  *	26.05.2004 -	implemented
1059cdf0e10cSrcweir  *
1060cdf0e10cSrcweir  *   AUTHOR
1061cdf0e10cSrcweir  *	Michael Mi
1062cdf0e10cSrcweir  *	Email: michael.mi@sun.com
1063cdf0e10cSrcweir  ******************************************************************************/
1064cdf0e10cSrcweir {
1065cdf0e10cSrcweir 	/*
1066cdf0e10cSrcweir 	 * defines all element tags in Signature element.
1067cdf0e10cSrcweir 	 */
1068cdf0e10cSrcweir 	rtl::OUString tag_Signature(RTL_CONSTASCII_USTRINGPARAM(TAG_SIGNATURE));
1069cdf0e10cSrcweir 		rtl::OUString tag_SignedInfo(RTL_CONSTASCII_USTRINGPARAM(TAG_SIGNEDINFO));
1070cdf0e10cSrcweir 			rtl::OUString tag_CanonicalizationMethod(RTL_CONSTASCII_USTRINGPARAM(TAG_CANONICALIZATIONMETHOD));
1071cdf0e10cSrcweir 			rtl::OUString tag_SignatureMethod(RTL_CONSTASCII_USTRINGPARAM(TAG_SIGNATUREMETHOD));
1072cdf0e10cSrcweir 			rtl::OUString tag_Reference(RTL_CONSTASCII_USTRINGPARAM(TAG_REFERENCE));
1073cdf0e10cSrcweir 				rtl::OUString tag_Transforms(RTL_CONSTASCII_USTRINGPARAM(TAG_TRANSFORMS));
1074cdf0e10cSrcweir 					rtl::OUString tag_Transform(RTL_CONSTASCII_USTRINGPARAM(TAG_TRANSFORM));
1075cdf0e10cSrcweir 				rtl::OUString tag_DigestMethod(RTL_CONSTASCII_USTRINGPARAM(TAG_DIGESTMETHOD));
1076cdf0e10cSrcweir 				rtl::OUString tag_DigestValue(RTL_CONSTASCII_USTRINGPARAM(TAG_DIGESTVALUE));
1077cdf0e10cSrcweir 		rtl::OUString tag_SignatureValue(RTL_CONSTASCII_USTRINGPARAM(TAG_SIGNATUREVALUE));
1078cdf0e10cSrcweir 		rtl::OUString tag_KeyInfo(RTL_CONSTASCII_USTRINGPARAM(TAG_KEYINFO));
1079cdf0e10cSrcweir 			rtl::OUString tag_X509Data(RTL_CONSTASCII_USTRINGPARAM(TAG_X509DATA));
1080cdf0e10cSrcweir 				rtl::OUString tag_X509IssuerSerial(RTL_CONSTASCII_USTRINGPARAM(TAG_X509ISSUERSERIAL));
1081cdf0e10cSrcweir 					rtl::OUString tag_X509IssuerName(RTL_CONSTASCII_USTRINGPARAM(TAG_X509ISSUERNAME));
1082cdf0e10cSrcweir 					rtl::OUString tag_X509SerialNumber(RTL_CONSTASCII_USTRINGPARAM(TAG_X509SERIALNUMBER));
1083cdf0e10cSrcweir 					rtl::OUString tag_X509Certificate(RTL_CONSTASCII_USTRINGPARAM(TAG_X509CERTIFICATE));
1084cdf0e10cSrcweir 
1085cdf0e10cSrcweir 		rtl::OUString tag_Object(RTL_CONSTASCII_USTRINGPARAM(TAG_OBJECT));
1086cdf0e10cSrcweir 			rtl::OUString tag_SignatureProperties(RTL_CONSTASCII_USTRINGPARAM(TAG_SIGNATUREPROPERTIES));
1087cdf0e10cSrcweir 				rtl::OUString tag_SignatureProperty(RTL_CONSTASCII_USTRINGPARAM(TAG_SIGNATUREPROPERTY));
1088cdf0e10cSrcweir 					rtl::OUString tag_Date(RTL_CONSTASCII_USTRINGPARAM(TAG_DATE));
1089cdf0e10cSrcweir #if 0
1090cdf0e10cSrcweir 					rtl::OUString tag_Timestamp(RTL_CONSTASCII_USTRINGPARAM(TAG_TIMESTAMP));
1091cdf0e10cSrcweir 						rtl::OUString tag_Date(RTL_CONSTASCII_USTRINGPARAM(TAG_DATE));
1092cdf0e10cSrcweir 						rtl::OUString tag_Time(RTL_CONSTASCII_USTRINGPARAM(TAG_TIME));
1093cdf0e10cSrcweir #endif
1094cdf0e10cSrcweir 
1095cdf0e10cSrcweir 	const SignatureReferenceInformations& vReferenceInfors = signatureInfo.vSignatureReferenceInfors;
1096cdf0e10cSrcweir 	SvXMLAttributeList *pAttributeList;
1097cdf0e10cSrcweir 
1098cdf0e10cSrcweir 	/*
1099cdf0e10cSrcweir 	 * Write Signature element
1100cdf0e10cSrcweir 	 */
1101cdf0e10cSrcweir 	pAttributeList = new SvXMLAttributeList();
1102cdf0e10cSrcweir 	pAttributeList->AddAttribute(
1103cdf0e10cSrcweir 		rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(ATTR_XMLNS)),
1104cdf0e10cSrcweir 		rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(NS_XMLDSIG)));
1105cdf0e10cSrcweir 
1106cdf0e10cSrcweir 	if (signatureInfo.ouSignatureId.getLength()>0)
1107cdf0e10cSrcweir 	{
1108cdf0e10cSrcweir 		pAttributeList->AddAttribute(
1109cdf0e10cSrcweir 			rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(ATTR_ID)),
1110cdf0e10cSrcweir 			rtl::OUString(signatureInfo.ouSignatureId));
1111cdf0e10cSrcweir 	}
1112cdf0e10cSrcweir 
1113cdf0e10cSrcweir 	xDocumentHandler->startElement( tag_Signature, cssu::Reference< cssxs::XAttributeList > (pAttributeList));
1114cdf0e10cSrcweir 	{
1115cdf0e10cSrcweir 		/* Write SignedInfo element */
1116cdf0e10cSrcweir 		xDocumentHandler->startElement(
1117cdf0e10cSrcweir 			tag_SignedInfo,
1118cdf0e10cSrcweir 			cssu::Reference< cssxs::XAttributeList > (new SvXMLAttributeList()));
1119cdf0e10cSrcweir 		{
1120cdf0e10cSrcweir 			/* Write CanonicalizationMethod element */
1121cdf0e10cSrcweir 			pAttributeList = new SvXMLAttributeList();
1122cdf0e10cSrcweir 			pAttributeList->AddAttribute(
1123cdf0e10cSrcweir 				rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(ATTR_ALGORITHM)),
1124cdf0e10cSrcweir 				rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(ALGO_C14N)));
1125cdf0e10cSrcweir 			xDocumentHandler->startElement( tag_CanonicalizationMethod, cssu::Reference< cssxs::XAttributeList > (pAttributeList) );
1126cdf0e10cSrcweir 			xDocumentHandler->endElement( tag_CanonicalizationMethod );
1127cdf0e10cSrcweir 
1128cdf0e10cSrcweir 			/* Write SignatureMethod element */
1129cdf0e10cSrcweir 			pAttributeList = new SvXMLAttributeList();
1130cdf0e10cSrcweir 			pAttributeList->AddAttribute(
1131cdf0e10cSrcweir 				rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(ATTR_ALGORITHM)),
1132cdf0e10cSrcweir 				rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(ALGO_RSASHA1)));
1133cdf0e10cSrcweir 			xDocumentHandler->startElement( tag_SignatureMethod, cssu::Reference< cssxs::XAttributeList > (pAttributeList) );
1134cdf0e10cSrcweir 			xDocumentHandler->endElement( tag_SignatureMethod );
1135cdf0e10cSrcweir 
1136cdf0e10cSrcweir 			/* Write Reference element */
1137cdf0e10cSrcweir 			int j;
1138cdf0e10cSrcweir 			int refNum = vReferenceInfors.size();
1139cdf0e10cSrcweir 
1140cdf0e10cSrcweir 			for(j=0; j<refNum; ++j)
1141cdf0e10cSrcweir 			{
1142cdf0e10cSrcweir 				const SignatureReferenceInformation& refInfor = vReferenceInfors[j];
1143cdf0e10cSrcweir 
1144cdf0e10cSrcweir 				pAttributeList = new SvXMLAttributeList();
1145cdf0e10cSrcweir 				if ( refInfor.nType != TYPE_SAMEDOCUMENT_REFERENCE )
1146cdf0e10cSrcweir 				/*
1147cdf0e10cSrcweir 				 * stream reference
1148cdf0e10cSrcweir 				 */
1149cdf0e10cSrcweir 				{
1150cdf0e10cSrcweir 					pAttributeList->AddAttribute(
1151cdf0e10cSrcweir 						rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(ATTR_URI)),
1152cdf0e10cSrcweir 						refInfor.ouURI);
1153cdf0e10cSrcweir 				}
1154cdf0e10cSrcweir 				else
1155cdf0e10cSrcweir 				/*
1156cdf0e10cSrcweir 				 * same-document reference
1157cdf0e10cSrcweir 				 */
1158cdf0e10cSrcweir 				{
1159cdf0e10cSrcweir 					pAttributeList->AddAttribute(
1160cdf0e10cSrcweir 						rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(ATTR_URI)),
1161cdf0e10cSrcweir 						rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(CHAR_FRAGMENT))+refInfor.ouURI);
1162cdf0e10cSrcweir 				}
1163cdf0e10cSrcweir 
1164cdf0e10cSrcweir 				xDocumentHandler->startElement( tag_Reference, cssu::Reference< cssxs::XAttributeList > (pAttributeList) );
1165cdf0e10cSrcweir 				{
1166cdf0e10cSrcweir 					/* Write Transforms element */
1167cdf0e10cSrcweir 					if (refInfor.nType == TYPE_XMLSTREAM_REFERENCE)
1168cdf0e10cSrcweir 					/*
1169cdf0e10cSrcweir 					 * xml stream, so c14n transform is needed
1170cdf0e10cSrcweir 					 */
1171cdf0e10cSrcweir 					{
1172cdf0e10cSrcweir 						xDocumentHandler->startElement(
1173cdf0e10cSrcweir 							tag_Transforms,
1174cdf0e10cSrcweir 							cssu::Reference< cssxs::XAttributeList > (new SvXMLAttributeList()));
1175cdf0e10cSrcweir 						{
1176cdf0e10cSrcweir 							pAttributeList = new SvXMLAttributeList();
1177cdf0e10cSrcweir 							pAttributeList->AddAttribute(
1178cdf0e10cSrcweir 								rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(ATTR_ALGORITHM)),
1179cdf0e10cSrcweir 								rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(ALGO_C14N)));
1180cdf0e10cSrcweir 							xDocumentHandler->startElement(
1181cdf0e10cSrcweir 								tag_Transform,
1182cdf0e10cSrcweir 								cssu::Reference< cssxs::XAttributeList > (pAttributeList) );
1183cdf0e10cSrcweir 							xDocumentHandler->endElement( tag_Transform );
1184cdf0e10cSrcweir 						}
1185cdf0e10cSrcweir 						xDocumentHandler->endElement( tag_Transforms );
1186cdf0e10cSrcweir 					}
1187cdf0e10cSrcweir 
1188cdf0e10cSrcweir 					/* Write DigestMethod element */
1189cdf0e10cSrcweir 					pAttributeList = new SvXMLAttributeList();
1190cdf0e10cSrcweir 					pAttributeList->AddAttribute(
1191cdf0e10cSrcweir 						rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(ATTR_ALGORITHM)),
1192cdf0e10cSrcweir 						rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(ALGO_XMLDSIGSHA1)));
1193cdf0e10cSrcweir 					xDocumentHandler->startElement(
1194cdf0e10cSrcweir 						tag_DigestMethod,
1195cdf0e10cSrcweir 						cssu::Reference< cssxs::XAttributeList > (pAttributeList) );
1196cdf0e10cSrcweir 					xDocumentHandler->endElement( tag_DigestMethod );
1197cdf0e10cSrcweir 
1198cdf0e10cSrcweir 					/* Write DigestValue element */
1199cdf0e10cSrcweir 					xDocumentHandler->startElement(
1200cdf0e10cSrcweir 						tag_DigestValue,
1201cdf0e10cSrcweir 						cssu::Reference< cssxs::XAttributeList > (new SvXMLAttributeList()));
1202cdf0e10cSrcweir 					xDocumentHandler->characters( refInfor.ouDigestValue );
1203cdf0e10cSrcweir 					xDocumentHandler->endElement( tag_DigestValue );
1204cdf0e10cSrcweir 				}
1205cdf0e10cSrcweir 				xDocumentHandler->endElement( tag_Reference );
1206cdf0e10cSrcweir 			}
1207cdf0e10cSrcweir 		}
1208cdf0e10cSrcweir 		xDocumentHandler->endElement( tag_SignedInfo );
1209cdf0e10cSrcweir 
1210cdf0e10cSrcweir 		/* Write SignatureValue element */
1211cdf0e10cSrcweir 		xDocumentHandler->startElement(
1212cdf0e10cSrcweir 			tag_SignatureValue,
1213cdf0e10cSrcweir 			cssu::Reference< cssxs::XAttributeList > (new SvXMLAttributeList()));
1214cdf0e10cSrcweir 		xDocumentHandler->characters( signatureInfo.ouSignatureValue );
1215cdf0e10cSrcweir 		xDocumentHandler->endElement( tag_SignatureValue );
1216cdf0e10cSrcweir 
1217cdf0e10cSrcweir 		/* Write KeyInfo element */
1218cdf0e10cSrcweir 		xDocumentHandler->startElement(
1219cdf0e10cSrcweir 			tag_KeyInfo,
1220cdf0e10cSrcweir 			cssu::Reference< cssxs::XAttributeList > (new SvXMLAttributeList()));
1221cdf0e10cSrcweir 		{
1222cdf0e10cSrcweir 			/* Write X509Data element */
1223cdf0e10cSrcweir 			xDocumentHandler->startElement(
1224cdf0e10cSrcweir 				tag_X509Data,
1225cdf0e10cSrcweir 				cssu::Reference< cssxs::XAttributeList > (new SvXMLAttributeList()));
1226cdf0e10cSrcweir 			{
1227cdf0e10cSrcweir 				/* Write X509IssuerSerial element */
1228cdf0e10cSrcweir 				xDocumentHandler->startElement(
1229cdf0e10cSrcweir 					tag_X509IssuerSerial,
1230cdf0e10cSrcweir 					cssu::Reference< cssxs::XAttributeList > (new SvXMLAttributeList()));
1231cdf0e10cSrcweir 				{
1232cdf0e10cSrcweir 					/* Write X509IssuerName element */
1233cdf0e10cSrcweir 					xDocumentHandler->startElement(
1234cdf0e10cSrcweir 						tag_X509IssuerName,
1235cdf0e10cSrcweir 						cssu::Reference< cssxs::XAttributeList > (new SvXMLAttributeList()));
1236cdf0e10cSrcweir 					xDocumentHandler->characters( signatureInfo.ouX509IssuerName );
1237cdf0e10cSrcweir 					xDocumentHandler->endElement( tag_X509IssuerName );
1238cdf0e10cSrcweir 
1239cdf0e10cSrcweir 					/* Write X509SerialNumber element */
1240cdf0e10cSrcweir 					xDocumentHandler->startElement(
1241cdf0e10cSrcweir 						tag_X509SerialNumber,
1242cdf0e10cSrcweir 						cssu::Reference< cssxs::XAttributeList > (new SvXMLAttributeList()));
1243cdf0e10cSrcweir 					xDocumentHandler->characters( signatureInfo.ouX509SerialNumber );
1244cdf0e10cSrcweir 					xDocumentHandler->endElement( tag_X509SerialNumber );
1245cdf0e10cSrcweir 				}
1246cdf0e10cSrcweir 				xDocumentHandler->endElement( tag_X509IssuerSerial );
1247cdf0e10cSrcweir 
1248cdf0e10cSrcweir 				/* Write X509Certificate element */
1249cdf0e10cSrcweir 				if (signatureInfo.ouX509Certificate.getLength()>0)
1250cdf0e10cSrcweir 				{
1251cdf0e10cSrcweir 					xDocumentHandler->startElement(
1252cdf0e10cSrcweir 						tag_X509Certificate,
1253cdf0e10cSrcweir 						cssu::Reference< cssxs::XAttributeList > (new SvXMLAttributeList()));
1254cdf0e10cSrcweir 					xDocumentHandler->characters( signatureInfo.ouX509Certificate );
1255cdf0e10cSrcweir 					xDocumentHandler->endElement( tag_X509Certificate );
1256cdf0e10cSrcweir 				}
1257cdf0e10cSrcweir 			}
1258cdf0e10cSrcweir 			xDocumentHandler->endElement( tag_X509Data );
1259cdf0e10cSrcweir 		}
1260cdf0e10cSrcweir 		xDocumentHandler->endElement( tag_KeyInfo );
1261cdf0e10cSrcweir 
1262cdf0e10cSrcweir 		/* Write Object element */
1263cdf0e10cSrcweir 		xDocumentHandler->startElement(
1264cdf0e10cSrcweir 			tag_Object,
1265cdf0e10cSrcweir 			cssu::Reference< cssxs::XAttributeList > (new SvXMLAttributeList()));
1266cdf0e10cSrcweir 		{
1267cdf0e10cSrcweir 			/* Write SignatureProperties element */
1268cdf0e10cSrcweir 			xDocumentHandler->startElement(
1269cdf0e10cSrcweir 				tag_SignatureProperties,
1270cdf0e10cSrcweir 				cssu::Reference< cssxs::XAttributeList > (new SvXMLAttributeList()));
1271cdf0e10cSrcweir 			{
1272cdf0e10cSrcweir 				/* Write SignatureProperty element */
1273cdf0e10cSrcweir 				pAttributeList = new SvXMLAttributeList();
1274cdf0e10cSrcweir 				pAttributeList->AddAttribute(
1275cdf0e10cSrcweir 					rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(ATTR_ID)),
1276cdf0e10cSrcweir 					signatureInfo.ouPropertyId);
1277cdf0e10cSrcweir 				pAttributeList->AddAttribute(
1278cdf0e10cSrcweir 					rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(ATTR_TARGET)),
1279cdf0e10cSrcweir 					rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(CHAR_FRAGMENT))+signatureInfo.ouSignatureId);
1280cdf0e10cSrcweir 				xDocumentHandler->startElement(
1281cdf0e10cSrcweir 					tag_SignatureProperty,
1282cdf0e10cSrcweir 					cssu::Reference< cssxs::XAttributeList > (pAttributeList));
1283cdf0e10cSrcweir 				{
1284cdf0e10cSrcweir 					/* Write timestamp element */
1285cdf0e10cSrcweir 
1286cdf0e10cSrcweir 					pAttributeList = new SvXMLAttributeList();
1287cdf0e10cSrcweir 					pAttributeList->AddAttribute(
1288cdf0e10cSrcweir 						rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(ATTR_XMLNS))
1289cdf0e10cSrcweir 							+rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(":"))
1290cdf0e10cSrcweir 							+rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(NSTAG_DC)),
1291cdf0e10cSrcweir 						rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(NS_DC)));
1292cdf0e10cSrcweir 
1293cdf0e10cSrcweir 					xDocumentHandler->startElement(
1294cdf0e10cSrcweir 						rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(NSTAG_DC))
1295cdf0e10cSrcweir 							+rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(":"))
1296cdf0e10cSrcweir 							+tag_Date,
1297cdf0e10cSrcweir 						cssu::Reference< cssxs::XAttributeList > (pAttributeList));
1298cdf0e10cSrcweir 
1299cdf0e10cSrcweir 					::rtl::OUStringBuffer buffer;
1300cdf0e10cSrcweir 					//If the xml signature was already contained in the document,
1301cdf0e10cSrcweir 					//then we use the original date and time string, rather then the
1302cdf0e10cSrcweir 					//converted one. When the original string is converted to the DateTime
1303cdf0e10cSrcweir 					//structure then information may be lost because it only holds a fractional
1304cdf0e10cSrcweir 					//of a second with a accuracy of one hundredth of second. If the string contains
1305cdf0e10cSrcweir 					//milli seconds (document was signed by an application other than OOo)
1306cdf0e10cSrcweir 					//and the converted time is written back, then the string looks different
1307cdf0e10cSrcweir 					//and the signature is broken.
1308cdf0e10cSrcweir 					if (signatureInfo.ouDateTime.getLength() > 0)
1309cdf0e10cSrcweir 						buffer = signatureInfo.ouDateTime;
1310cdf0e10cSrcweir 					else
1311cdf0e10cSrcweir 						convertDateTime( buffer, signatureInfo.stDateTime );
1312cdf0e10cSrcweir 					xDocumentHandler->characters( buffer.makeStringAndClear() );
1313cdf0e10cSrcweir 
1314cdf0e10cSrcweir 					xDocumentHandler->endElement(
1315cdf0e10cSrcweir 						rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(NSTAG_DC))
1316cdf0e10cSrcweir 							+rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(":"))
1317cdf0e10cSrcweir 							+tag_Date);
1318cdf0e10cSrcweir 				}
1319cdf0e10cSrcweir 				xDocumentHandler->endElement( tag_SignatureProperty );
1320cdf0e10cSrcweir 			}
1321cdf0e10cSrcweir 			xDocumentHandler->endElement( tag_SignatureProperties );
1322cdf0e10cSrcweir 		}
1323cdf0e10cSrcweir 		xDocumentHandler->endElement( tag_Object );
1324cdf0e10cSrcweir 	}
1325cdf0e10cSrcweir 	xDocumentHandler->endElement( tag_Signature );
1326cdf0e10cSrcweir }
1327cdf0e10cSrcweir 
getSignatureInformation(sal_Int32 nSecurityId) const1328cdf0e10cSrcweir SignatureInformation XSecController::getSignatureInformation( sal_Int32 nSecurityId ) const
1329cdf0e10cSrcweir {
1330cdf0e10cSrcweir     SignatureInformation aInf( 0 );
1331cdf0e10cSrcweir 	int nIndex = findSignatureInfor(nSecurityId);
1332cdf0e10cSrcweir 	DBG_ASSERT( nIndex != -1, "getSignatureInformation - SecurityId is invalid!" );
1333cdf0e10cSrcweir 	if ( nIndex != -1)
1334cdf0e10cSrcweir 	{
1335cdf0e10cSrcweir 		aInf = m_vInternalSignatureInformations[nIndex].signatureInfor;
1336cdf0e10cSrcweir 	}
1337cdf0e10cSrcweir 	return aInf;
1338cdf0e10cSrcweir }
1339cdf0e10cSrcweir 
getSignatureInformations() const1340cdf0e10cSrcweir SignatureInformations XSecController::getSignatureInformations() const
1341cdf0e10cSrcweir {
1342cdf0e10cSrcweir 	SignatureInformations vInfors;
1343cdf0e10cSrcweir 	int sigNum = m_vInternalSignatureInformations.size();
1344cdf0e10cSrcweir 
1345cdf0e10cSrcweir 	for (int i=0; i<sigNum; ++i)
1346cdf0e10cSrcweir 	{
1347cdf0e10cSrcweir 		SignatureInformation si = m_vInternalSignatureInformations[i].signatureInfor;
1348cdf0e10cSrcweir 		vInfors.push_back(si);
1349cdf0e10cSrcweir 	}
1350cdf0e10cSrcweir 
1351cdf0e10cSrcweir 	return vInfors;
1352cdf0e10cSrcweir }
1353cdf0e10cSrcweir 
1354cdf0e10cSrcweir /*
1355cdf0e10cSrcweir  * XSecurityController
1356cdf0e10cSrcweir  *
1357cdf0e10cSrcweir  * no methods
1358cdf0e10cSrcweir  */
1359cdf0e10cSrcweir 
1360cdf0e10cSrcweir /*
1361cdf0e10cSrcweir  * XFastPropertySet
1362cdf0e10cSrcweir  */
1363cdf0e10cSrcweir /*
1364cdf0e10cSrcweir void SAL_CALL XSecController::setFastPropertyValue(
1365cdf0e10cSrcweir 	sal_Int32 nHandle,
1366cdf0e10cSrcweir 	const cssu::Any& aValue )
1367cdf0e10cSrcweir 	throw (	cssb::UnknownPropertyException,
1368cdf0e10cSrcweir 		cssb::PropertyVetoException,
1369cdf0e10cSrcweir 		cssl::IllegalArgumentException,
1370cdf0e10cSrcweir 		cssl::WrappedTargetException,
1371cdf0e10cSrcweir 		cssu::RuntimeException)
1372cdf0e10cSrcweir {
1373cdf0e10cSrcweir 	sal_Int32 nIndex = getFastPropertyIndex(nHandle);
1374cdf0e10cSrcweir 	if (nIndex == -1)
1375cdf0e10cSrcweir 	{
1376cdf0e10cSrcweir 		m_vFastPropertyIndexs.push_back( nHandle );
1377cdf0e10cSrcweir 		m_vFastPropertyValues.push_back( aValue );
1378cdf0e10cSrcweir 	}
1379cdf0e10cSrcweir 	else
1380cdf0e10cSrcweir 	{
1381cdf0e10cSrcweir 		m_vFastPropertyValues[nIndex] = aValue;
1382cdf0e10cSrcweir 	}
1383cdf0e10cSrcweir }
1384cdf0e10cSrcweir 
1385cdf0e10cSrcweir cssu::Any SAL_CALL XSecController::getFastPropertyValue(
1386cdf0e10cSrcweir 	sal_Int32 nHandle )
1387cdf0e10cSrcweir 	throw (
1388cdf0e10cSrcweir 		cssb::UnknownPropertyException,
1389cdf0e10cSrcweir 		cssl::WrappedTargetException,
1390cdf0e10cSrcweir 		cssu::RuntimeException)
1391cdf0e10cSrcweir {
1392cdf0e10cSrcweir 	cssu::Any aValue;
1393cdf0e10cSrcweir 
1394cdf0e10cSrcweir 	sal_Int32 nIndex = getFastPropertyIndex(nHandle);
1395cdf0e10cSrcweir 	if (nIndex != -1)
1396cdf0e10cSrcweir 	{
1397cdf0e10cSrcweir 		aValue = m_vFastPropertyValues[nIndex];
1398cdf0e10cSrcweir 	}
1399cdf0e10cSrcweir 
1400cdf0e10cSrcweir 	return aValue;
1401cdf0e10cSrcweir }
1402cdf0e10cSrcweir */
1403cdf0e10cSrcweir 
1404cdf0e10cSrcweir /*
1405cdf0e10cSrcweir  * XSAXEventKeeperStatusChangeListener
1406cdf0e10cSrcweir  */
1407cdf0e10cSrcweir 
blockingStatusChanged(sal_Bool isBlocking)1408cdf0e10cSrcweir void SAL_CALL XSecController::blockingStatusChanged( sal_Bool isBlocking )
1409cdf0e10cSrcweir 	throw (cssu::RuntimeException)
1410cdf0e10cSrcweir {
1411cdf0e10cSrcweir 	/*
1412cdf0e10cSrcweir 	showMessageBox( rtl::OUString::createFromAscii((isBlocking?
1413cdf0e10cSrcweir 						"Blocking Status => TRUE":
1414cdf0e10cSrcweir 						"Blocking Status => FALSE")),
1415cdf0e10cSrcweir 			rtl::OUString::createFromAscii("SAXEventKeeper Status"));
1416cdf0e10cSrcweir 	*/
1417cdf0e10cSrcweir 
1418cdf0e10cSrcweir 	this->m_bIsBlocking = isBlocking;
1419cdf0e10cSrcweir 	checkChainingStatus();
1420cdf0e10cSrcweir }
1421cdf0e10cSrcweir 
collectionStatusChanged(sal_Bool isInsideCollectedElement)1422cdf0e10cSrcweir void SAL_CALL XSecController::collectionStatusChanged(
1423cdf0e10cSrcweir 	sal_Bool isInsideCollectedElement )
1424cdf0e10cSrcweir 	throw (cssu::RuntimeException)
1425cdf0e10cSrcweir {
1426cdf0e10cSrcweir 	/*
1427cdf0e10cSrcweir 	showMessageBox(	rtl::OUString::createFromAscii((isInsideCollectedElement?
1428cdf0e10cSrcweir 						"Collection Status => TRUE":
1429cdf0e10cSrcweir 						"Collection Status => FALSE")),
1430cdf0e10cSrcweir 			rtl::OUString::createFromAscii("SAXEventKeeper Status"));
1431cdf0e10cSrcweir 	*/
1432cdf0e10cSrcweir 
1433cdf0e10cSrcweir 	this->m_bIsCollectingElement = isInsideCollectedElement;
1434cdf0e10cSrcweir 	checkChainingStatus();
1435cdf0e10cSrcweir }
1436cdf0e10cSrcweir 
bufferStatusChanged(sal_Bool)1437cdf0e10cSrcweir void SAL_CALL XSecController::bufferStatusChanged( sal_Bool /*isBufferEmpty*/)
1438cdf0e10cSrcweir 	throw (cssu::RuntimeException)
1439cdf0e10cSrcweir {
1440cdf0e10cSrcweir 	/*
1441cdf0e10cSrcweir 	showMessageBox(	rtl::OUString::createFromAscii((isBufferEmpty?
1442cdf0e10cSrcweir 						"Buffer Empty => TRUE":
1443cdf0e10cSrcweir 						"Buffer Empty => FALSE")),
1444cdf0e10cSrcweir 			rtl::OUString::createFromAscii("SAXEventKeeper Status"));
1445cdf0e10cSrcweir 	*/
1446cdf0e10cSrcweir }
1447cdf0e10cSrcweir 
1448cdf0e10cSrcweir /*
1449cdf0e10cSrcweir  * XSignatureCreationResultListener
1450cdf0e10cSrcweir  */
signatureCreated(sal_Int32 securityId,com::sun::star::xml::crypto::SecurityOperationStatus nResult)1451cdf0e10cSrcweir void SAL_CALL XSecController::signatureCreated( sal_Int32 securityId, com::sun::star::xml::crypto::SecurityOperationStatus nResult )
1452cdf0e10cSrcweir 		throw (com::sun::star::uno::RuntimeException)
1453cdf0e10cSrcweir {
1454cdf0e10cSrcweir 	int index = findSignatureInfor(securityId);
1455cdf0e10cSrcweir 	DBG_ASSERT( index != -1, "Signature Not Found!" );
1456cdf0e10cSrcweir 
1457cdf0e10cSrcweir 	SignatureInformation& signatureInfor = m_vInternalSignatureInformations[index].signatureInfor;
1458cdf0e10cSrcweir 
1459cdf0e10cSrcweir 	/*
1460cdf0e10cSrcweir 	if (nResult == cssxc::sax::SignatureCreationResult_CREATIONSUCCEED)
1461cdf0e10cSrcweir 	{
1462cdf0e10cSrcweir 		signatureInfor.nStatus = STATUS_CREATION_SUCCEED;
1463cdf0e10cSrcweir 	}
1464cdf0e10cSrcweir 	else
1465cdf0e10cSrcweir 	{
1466cdf0e10cSrcweir 		signatureInfor.nStatus = STATUS_CREATION_FAIL;
1467cdf0e10cSrcweir 	}
1468cdf0e10cSrcweir 	*/
1469cdf0e10cSrcweir 	signatureInfor.nStatus = nResult;
1470cdf0e10cSrcweir }
1471cdf0e10cSrcweir 
1472cdf0e10cSrcweir /*
1473cdf0e10cSrcweir  * XSignatureVerifyResultListener
1474cdf0e10cSrcweir  */
signatureVerified(sal_Int32 securityId,com::sun::star::xml::crypto::SecurityOperationStatus nResult)1475cdf0e10cSrcweir void SAL_CALL XSecController::signatureVerified( sal_Int32 securityId, com::sun::star::xml::crypto::SecurityOperationStatus nResult )
1476cdf0e10cSrcweir 		throw (com::sun::star::uno::RuntimeException)
1477cdf0e10cSrcweir {
1478cdf0e10cSrcweir 	int index = findSignatureInfor(securityId);
1479cdf0e10cSrcweir 	DBG_ASSERT( index != -1, "Signature Not Found!" );
1480cdf0e10cSrcweir 
1481cdf0e10cSrcweir 	SignatureInformation& signatureInfor = m_vInternalSignatureInformations[index].signatureInfor;
1482cdf0e10cSrcweir 
1483cdf0e10cSrcweir 	/*
1484cdf0e10cSrcweir 	if (nResult == cssxc::sax::SignatureVerifyResult_VERIFYSUCCEED)
1485cdf0e10cSrcweir 	{
1486cdf0e10cSrcweir 		signatureInfor.nStatus = STATUS_VERIFY_SUCCEED;
1487cdf0e10cSrcweir 	}
1488cdf0e10cSrcweir 	else
1489cdf0e10cSrcweir 	{
1490cdf0e10cSrcweir 		signatureInfor.nStatus = STATUS_VERIFY_FAIL;
1491cdf0e10cSrcweir 	}
1492cdf0e10cSrcweir 	*/
1493cdf0e10cSrcweir 	signatureInfor.nStatus = nResult;
1494cdf0e10cSrcweir }
1495