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