Update ooo320-m1
[ooovba.git] / xmlsecurity / source / helper / xsecctl.cxx
blob028867b9a5f9889982bd1c76c408e9f3227586d2
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: xsecctl.cxx,v $
10 * $Revision: 1.12 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_xmlsecurity.hxx"
34 #include <xsecctl.hxx>
35 #include <tools/debug.hxx>
37 #include <com/sun/star/xml/crypto/sax/ElementMarkPriority.hpp>
38 #include <com/sun/star/xml/crypto/sax/XReferenceResolvedBroadcaster.hpp>
39 #include <com/sun/star/xml/crypto/sax/XMissionTaker.hpp>
40 #include <com/sun/star/xml/crypto/sax/XReferenceCollector.hpp>
41 #include <com/sun/star/xml/crypto/sax/XSAXEventKeeperStatusChangeBroadcaster.hpp>
42 #include <com/sun/star/xml/crypto/SecurityOperationStatus.hpp>
44 #include <xmloff/attrlist.hxx>
45 #include <rtl/math.hxx>
46 #include <tools/string.hxx>
48 namespace cssu = com::sun::star::uno;
49 namespace cssl = com::sun::star::lang;
50 namespace cssxc = com::sun::star::xml::crypto;
51 namespace cssxs = com::sun::star::xml::sax;
52 namespace cssxw = com::sun::star::xml::wrapper;
53 namespace cssb = com::sun::star::beans;
55 const sal_Int8 XML_MAXDIGITSCOUNT_TIME = 11;
56 const sal_Int8 XML_MAXDIGITSCOUNT_DATETIME = 6;
58 /* bridge component names */
59 #define XMLSIGNATURE_COMPONENT "com.sun.star.xml.crypto.XMLSignature"
60 #define XMLDOCUMENTWRAPPER_COMPONENT "com.sun.star.xml.wrapper.XMLDocumentWrapper"
62 /* xml security framework components */
63 #define SAXEVENTKEEPER_COMPONENT "com.sun.star.xml.crypto.sax.SAXEventKeeper"
65 /* string for package protocol */
66 #define PACKAGEPROTOCOL "vnd.sun.star.Package:"
68 XSecController::XSecController( const cssu::Reference<cssu::XComponentContext>& rxCtx )
69 :mxCtx(rxCtx),
70 m_nNextSecurityId(1),
71 m_bIsSAXEventKeeperConnected(false),
72 m_nStatusOfSecurityComponents(UNINITIALIZED),
73 m_bIsSAXEventKeeperSticky(false),
74 m_pErrorMessage(NULL),
75 m_pXSecParser(NULL)
79 XSecController::~XSecController()
85 * private methods
87 /** convert string to number with optional min and max values */
88 sal_Bool XSecController::convertNumber( sal_Int32& rValue,
89 const rtl::OUString& rString,
90 sal_Int32 /*nMin*/, sal_Int32 /*nMax*/ )
92 sal_Bool bNeg = sal_False;
93 rValue = 0;
95 sal_Int32 nPos = 0L;
96 sal_Int32 nLen = rString.getLength();
98 // skip white space
99 while( nPos < nLen && sal_Unicode(' ') == rString[nPos] )
100 nPos++;
102 if( nPos < nLen && sal_Unicode('-') == rString[nPos] )
104 bNeg = sal_True;
105 nPos++;
108 // get number
109 while( nPos < nLen &&
110 sal_Unicode('0') <= rString[nPos] &&
111 sal_Unicode('9') >= rString[nPos] )
113 // TODO: check overflow!
114 rValue *= 10;
115 rValue += (rString[nPos] - sal_Unicode('0'));
116 nPos++;
119 if( bNeg )
120 rValue *= -1;
122 return nPos == nLen;
125 /** convert util::DateTime to ISO Date String */
126 void XSecController::convertDateTime( ::rtl::OUStringBuffer& rBuffer,
127 const com::sun::star::util::DateTime& rDateTime )
129 String aString( String::CreateFromInt32( rDateTime.Year ) );
130 aString += '-';
131 if( rDateTime.Month < 10 )
132 aString += '0';
133 aString += String::CreateFromInt32( rDateTime.Month );
134 aString += '-';
135 if( rDateTime.Day < 10 )
136 aString += '0';
137 aString += String::CreateFromInt32( rDateTime.Day );
139 if( rDateTime.Seconds != 0 ||
140 rDateTime.Minutes != 0 ||
141 rDateTime.Hours != 0 )
143 aString += 'T';
144 if( rDateTime.Hours < 10 )
145 aString += '0';
146 aString += String::CreateFromInt32( rDateTime.Hours );
147 aString += ':';
148 if( rDateTime.Minutes < 10 )
149 aString += '0';
150 aString += String::CreateFromInt32( rDateTime.Minutes );
151 aString += ':';
152 if( rDateTime.Seconds < 10 )
153 aString += '0';
154 aString += String::CreateFromInt32( rDateTime.Seconds );
155 if ( rDateTime.HundredthSeconds > 0)
157 aString += ',';
158 if (rDateTime.HundredthSeconds < 10)
159 aString += '0';
160 aString += String::CreateFromInt32( rDateTime.HundredthSeconds );
164 rBuffer.append( aString );
167 /** convert ISO Date String to util::DateTime */
168 sal_Bool XSecController::convertDateTime( com::sun::star::util::DateTime& rDateTime,
169 const ::rtl::OUString& rString )
171 sal_Bool bSuccess = sal_True;
173 rtl::OUString aDateStr, aTimeStr, sHundredth;
174 sal_Int32 nPos = rString.indexOf( (sal_Unicode) 'T' );
175 sal_Int32 nPos2 = rString.indexOf( (sal_Unicode) ',' );
176 if ( nPos >= 0 )
178 aDateStr = rString.copy( 0, nPos );
179 if ( nPos2 >= 0 )
181 aTimeStr = rString.copy( nPos + 1, nPos2 - nPos - 1 );
183 //Get the fraction of a second with the accuracy of one hundreds second.
184 //The fraction part of the date could have different accuracies. To calculate
185 //the count of a hundredth units one could form a fractional number by appending
186 //the value of the time string to 0. Then multiply it by 100 and use only the whole number.
187 //For example: 5:27:46,1 -> 0,1 * 100 = 10
188 //5:27:46,01 -> 0,01 * 100 = 1
189 //5:27:46,001 -> 0,001 * 100 = 0
190 //Due to the inaccuracy of floating point numbers the result may not be the same on different
191 //platforms. We had the case where we had a value of 24 hundredth of second, which converted to
192 //23 on Linux and 24 on Solaris and Windows.
194 //we only support a hundredth second
195 //make ,1 -> 10 ,01 -> 1 ,001 -> only use first two diggits
196 sHundredth = rString.copy(nPos2 + 1);
197 sal_Int32 len = sHundredth.getLength();
198 if (len == 1)
199 sHundredth += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("0"));
200 if (len > 2)
201 sHundredth = sHundredth.copy(0, 2);
203 else
205 aTimeStr = rString.copy(nPos + 1);
206 sHundredth = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("0"));
209 else
210 aDateStr = rString; // no separator: only date part
212 sal_Int32 nYear = 1899;
213 sal_Int32 nMonth = 12;
214 sal_Int32 nDay = 30;
215 sal_Int32 nHour = 0;
216 sal_Int32 nMin = 0;
217 sal_Int32 nSec = 0;
219 const sal_Unicode* pStr = aDateStr.getStr();
220 sal_Int32 nDateTokens = 1;
221 while ( *pStr )
223 if ( *pStr == '-' )
224 nDateTokens++;
225 pStr++;
227 if ( nDateTokens > 3 || aDateStr.getLength() == 0 )
228 bSuccess = sal_False;
229 else
231 sal_Int32 n = 0;
232 if ( !convertNumber( nYear, aDateStr.getToken( 0, '-', n ), 0, 9999 ) )
233 bSuccess = sal_False;
234 if ( nDateTokens >= 2 )
235 if ( !convertNumber( nMonth, aDateStr.getToken( 0, '-', n ), 0, 12 ) )
236 bSuccess = sal_False;
237 if ( nDateTokens >= 3 )
238 if ( !convertNumber( nDay, aDateStr.getToken( 0, '-', n ), 0, 31 ) )
239 bSuccess = sal_False;
242 if ( aTimeStr.getLength() > 0 ) // time is optional
244 pStr = aTimeStr.getStr();
245 sal_Int32 nTimeTokens = 1;
246 while ( *pStr )
248 if ( *pStr == ':' )
249 nTimeTokens++;
250 pStr++;
252 if ( nTimeTokens > 3 )
253 bSuccess = sal_False;
254 else
256 sal_Int32 n = 0;
257 if ( !convertNumber( nHour, aTimeStr.getToken( 0, ':', n ), 0, 23 ) )
258 bSuccess = sal_False;
259 if ( nTimeTokens >= 2 )
260 if ( !convertNumber( nMin, aTimeStr.getToken( 0, ':', n ), 0, 59 ) )
261 bSuccess = sal_False;
262 if ( nTimeTokens >= 3 )
263 if ( !convertNumber( nSec, aTimeStr.getToken( 0, ':', n ), 0, 59 ) )
264 bSuccess = sal_False;
268 if (bSuccess)
270 rDateTime.Year = (sal_uInt16)nYear;
271 rDateTime.Month = (sal_uInt16)nMonth;
272 rDateTime.Day = (sal_uInt16)nDay;
273 rDateTime.Hours = (sal_uInt16)nHour;
274 rDateTime.Minutes = (sal_uInt16)nMin;
275 rDateTime.Seconds = (sal_uInt16)nSec;
276 // rDateTime.HundredthSeconds = sDoubleStr.toDouble() * 100;
277 rDateTime.HundredthSeconds = static_cast<sal_uInt16>(sHundredth.toInt32());
279 return bSuccess;
282 int XSecController::findSignatureInfor( sal_Int32 nSecurityId) const
283 /****** XSecController/findSignatureInfor *************************************
285 * NAME
286 * findSignatureInfor -- find SignatureInformation struct for a particular
287 * signature
289 * SYNOPSIS
290 * index = findSignatureInfor( nSecurityId );
292 * FUNCTION
293 * see NAME.
295 * INPUTS
296 * nSecurityId - the signature's id
298 * RESULT
299 * index - the index of the signature, or -1 when no such signature
300 * existing
302 * HISTORY
303 * 08.05.2004 - implemented
305 * AUTHOR
306 * Michael Mi
307 * Email: michael.mi@sun.com
308 ******************************************************************************/
310 int i;
311 int size = m_vInternalSignatureInformations.size();
313 for (i=0; i<size; ++i)
315 if (m_vInternalSignatureInformations[i].signatureInfor.nSecurityId == nSecurityId)
317 return i;
321 return -1;
324 void XSecController::createXSecComponent( )
325 /****** XSecController/createXSecComponent ************************************
327 * NAME
328 * bResult = createXSecComponent -- creates xml security components
330 * SYNOPSIS
331 * createXSecComponent( );
333 * FUNCTION
334 * Creates xml security components, including:
335 * 1. an xml signature bridge component ( Java based or C based)
336 * 2. an XMLDocumentWrapper component ( Java based or C based)
337 * 3. a SAXEventKeeper component
339 * INPUTS
340 * empty
342 * RESULT
343 * empty
345 * HISTORY
346 * 05.01.2004 - implemented
348 * AUTHOR
349 * Michael Mi
350 * Email: michael.mi@sun.com
351 ******************************************************************************/
353 rtl::OUString sSAXEventKeeper(rtl::OUString::createFromAscii( SAXEVENTKEEPER_COMPONENT ));
354 rtl::OUString sXMLSignature(rtl::OUString::createFromAscii( XMLSIGNATURE_COMPONENT ));
355 rtl::OUString sXMLDocument(rtl::OUString::createFromAscii( XMLDOCUMENTWRAPPER_COMPONENT ));
358 * marks all security components are not available.
360 m_nStatusOfSecurityComponents = FAILTOINITIALIZED;
361 m_xXMLSignature = NULL;
362 m_xXMLDocumentWrapper = NULL;
363 m_xSAXEventKeeper = NULL;
365 cssu::Reference< cssl::XMultiComponentFactory > xMCF( mxCtx->getServiceManager() );
367 m_xXMLSignature = cssu::Reference< cssxc::XXMLSignature >(
368 xMCF->createInstanceWithContext( sXMLSignature, mxCtx ),
369 cssu::UNO_QUERY );
371 bool bSuccess = (0!=m_xXMLSignature.is());
372 if ( bSuccess )
374 * XMLSignature created successfully.
377 m_xXMLDocumentWrapper = cssu::Reference< cssxw::XXMLDocumentWrapper >(
378 xMCF->createInstanceWithContext( sXMLDocument, mxCtx ),
379 cssu::UNO_QUERY );
382 bSuccess &= (0!=m_xXMLDocumentWrapper.is());
383 if ( bSuccess )
385 * XMLDocumentWrapper created successfully.
388 m_xSAXEventKeeper = cssu::Reference< cssxc::sax::XSecuritySAXEventKeeper >(
389 xMCF->createInstanceWithContext( sSAXEventKeeper, mxCtx ),
390 cssu::UNO_QUERY );
393 bSuccess &= (0!=m_xSAXEventKeeper.is());
395 if (bSuccess)
397 * SAXEventKeeper created successfully.
400 cssu::Reference< cssl::XInitialization > xInitialization(m_xSAXEventKeeper, cssu::UNO_QUERY);
402 cssu::Sequence <cssu::Any> arg(1);
403 arg[0] = cssu::makeAny(m_xXMLDocumentWrapper);
404 xInitialization->initialize(arg);
406 cssu::Reference<cssxc::sax::XSAXEventKeeperStatusChangeBroadcaster>
407 xSAXEventKeeperStatusChangeBroadcaster(m_xSAXEventKeeper, cssu::UNO_QUERY);
408 cssu::Reference< cssxc::sax::XSAXEventKeeperStatusChangeListener >
409 xStatusChangeListener = this;
411 xSAXEventKeeperStatusChangeBroadcaster
412 ->addSAXEventKeeperStatusChangeListener( xStatusChangeListener );
414 m_nStatusOfSecurityComponents = INITIALIZED;
418 bool XSecController::chainOn( bool bRetrievingLastEvent )
419 /****** XSecController/chainOn ************************************************
421 * NAME
422 * chainOn -- tyies to connect the SAXEventKeeper with the SAX chain.
424 * SYNOPSIS
425 * bJustChainingOn = chainOn( bRetrievingLastEvent );
427 * FUNCTION
428 * First, checks whether the SAXEventKeeper is on the SAX chain. If not,
429 * creates xml security components, and chains the SAXEventKeeper into
430 * the SAX chain.
431 * Before being chained in, the SAXEventKeeper needs to receive all
432 * missed key SAX events, which can promise the DOM tree bufferred by the
433 * SAXEventKeeper has the same structure with the original document.
435 * INPUTS
436 * bRetrievingLastEvent - whether to retrieve the last key SAX event from
437 * the ElementStackKeeper.
439 * RESULT
440 * bJustChainingOn - whether the SAXEventKeeper is just chained into the
441 * SAX chain.
443 * NOTES
444 * Sometimes, the last key SAX event can't be transferred to the
445 * SAXEventKeeper together.
446 * For instance, at the time an referenced element is detected, the
447 * startElement event has already been reserved by the ElementStackKeeper.
448 * Meanwhile, an ElementCollector needs to be created before the
449 * SAXEventKeeper receives that startElement event.
450 * So for the SAXEventKeeper, it needs to receive all missed key SAX
451 * events except that startElement event, then adds a new
452 * ElementCollector, then receives that startElement event.
454 * HISTORY
455 * 05.01.2004 - implemented
457 * AUTHOR
458 * Michael Mi
459 * Email: michael.mi@sun.com
460 ******************************************************************************/
462 bool rc = false;
464 if (!m_bIsSAXEventKeeperSticky && !m_bIsSAXEventKeeperConnected)
466 if ( m_nStatusOfSecurityComponents == UNINITIALIZED )
468 createXSecComponent();
471 if ( m_nStatusOfSecurityComponents == INITIALIZED )
473 * if all security components are ready, chains on the SAXEventKeeper
477 * disconnect the SAXEventKeeper with its current output handler,
478 * to make sure no SAX event is forwarded during the connecting
479 * phase.
481 m_xSAXEventKeeper->setNextHandler( NULL );
483 cssu::Reference< cssxs::XDocumentHandler > xSEKHandler(m_xSAXEventKeeper, cssu::UNO_QUERY);
486 * connects the previous document handler on the SAX chain
488 if ( m_xPreviousNodeOnSAXChain.is() )
490 if ( m_bIsPreviousNodeInitializable )
492 cssu::Reference< cssl::XInitialization > xInitialization
493 (m_xPreviousNodeOnSAXChain, cssu::UNO_QUERY);
495 cssu::Sequence<cssu::Any> aArgs( 1 );
496 aArgs[0] <<= xSEKHandler;
497 xInitialization->initialize(aArgs);
499 else
501 cssu::Reference< cssxs::XParser > xParser
502 (m_xPreviousNodeOnSAXChain, cssu::UNO_QUERY);
503 xParser->setDocumentHandler( xSEKHandler );
508 * get missed key SAX events
510 if (m_xElementStackKeeper.is())
512 m_xElementStackKeeper->retrieve(xSEKHandler, bRetrievingLastEvent);
515 * now the ElementStackKeeper can stop its work, because the
516 * SAXEventKeeper is on the SAX chain, no SAX events will be
517 * missed.
519 m_xElementStackKeeper->stop();
523 * connects the next document handler on the SAX chain
525 m_xSAXEventKeeper->setNextHandler( m_xNextNodeOnSAXChain );
527 m_bIsSAXEventKeeperConnected = true;
529 rc = true;
533 return rc;
536 void XSecController::chainOff()
537 /****** XSecController/chainOff ***********************************************
539 * NAME
540 * chainOff -- disconnects the SAXEventKeeper from the SAX chain.
542 * SYNOPSIS
543 * chainOff( );
545 * FUNCTION
546 * See NAME.
548 * INPUTS
549 * empty
551 * RESULT
552 * empty
554 * HISTORY
555 * 05.01.2004 - implemented
557 * AUTHOR
558 * Michael Mi
559 * Email: michael.mi@sun.com
560 ******************************************************************************/
562 if (!m_bIsSAXEventKeeperSticky )
564 if (m_bIsSAXEventKeeperConnected)
566 m_xSAXEventKeeper->setNextHandler( NULL );
568 if ( m_xPreviousNodeOnSAXChain.is() )
570 if ( m_bIsPreviousNodeInitializable )
572 cssu::Reference< cssl::XInitialization > xInitialization
573 (m_xPreviousNodeOnSAXChain, cssu::UNO_QUERY);
575 cssu::Sequence<cssu::Any> aArgs( 1 );
576 aArgs[0] <<= m_xNextNodeOnSAXChain;
577 xInitialization->initialize(aArgs);
579 else
581 cssu::Reference< cssxs::XParser > xParser(m_xPreviousNodeOnSAXChain, cssu::UNO_QUERY);
582 xParser->setDocumentHandler( m_xNextNodeOnSAXChain );
586 if (m_xElementStackKeeper.is())
589 * start the ElementStackKeeper to reserve any possible
590 * missed key SAX events
592 m_xElementStackKeeper->start();
595 m_bIsSAXEventKeeperConnected = false;
600 void XSecController::checkChainingStatus()
601 /****** XSecController/checkChainingStatus ************************************
603 * NAME
604 * checkChainingStatus -- connects or disconnects the SAXEventKeeper
605 * according to the current situation.
607 * SYNOPSIS
608 * checkChainingStatus( );
610 * FUNCTION
611 * The SAXEventKeeper is chained into the SAX chain, when:
612 * 1. some element is being collected, or
613 * 2. the SAX event stream is blocking.
614 * Otherwise, chain off the SAXEventKeeper.
616 * INPUTS
617 * empty
619 * RESULT
620 * empty
622 * HISTORY
623 * 05.01.2004 - implemented
625 * AUTHOR
626 * Michael Mi
627 * Email: michael.mi@sun.com
628 ******************************************************************************/
630 if ( m_bIsCollectingElement || m_bIsBlocking )
632 chainOn(true);
634 else
636 chainOff();
640 void XSecController::initializeSAXChain()
641 /****** XSecController/initializeSAXChain *************************************
643 * NAME
644 * initializeSAXChain -- initializes the SAX chain according to the
645 * current setting.
647 * SYNOPSIS
648 * initializeSAXChain( );
650 * FUNCTION
651 * Initializes the SAX chain, if the SAXEventKeeper is asked to be always
652 * on the SAX chain, chains it on. Otherwise, starts the
653 * ElementStackKeeper to reserve key SAX events.
655 * INPUTS
656 * empty
658 * RESULT
659 * empty
661 * HISTORY
662 * 05.01.2004 - implemented
664 * AUTHOR
665 * Michael Mi
666 * Email: michael.mi@sun.com
667 ******************************************************************************/
669 m_bIsSAXEventKeeperConnected = false;
670 m_bIsCollectingElement = false;
671 m_bIsBlocking = false;
673 if (m_xElementStackKeeper.is())
676 * starts the ElementStackKeeper
678 m_xElementStackKeeper->start();
681 chainOff();
684 cssu::Reference< com::sun::star::io::XInputStream >
685 XSecController::getObjectInputStream( const rtl::OUString& objectURL )
686 /****** XSecController/getObjectInputStream ************************************
688 * NAME
689 * getObjectInputStream -- get a XInputStream interface from a SvStorage
691 * SYNOPSIS
692 * xInputStream = getObjectInputStream( objectURL );
694 * FUNCTION
695 * See NAME.
697 * INPUTS
698 * objectURL - the object uri
700 * RESULT
701 * xInputStream - the XInputStream interface
703 * HISTORY
704 * 15.04.2004 - implemented
706 * AUTHOR
707 * Michael Mi
708 * Email: michael.mi@sun.com
709 ******************************************************************************/
711 cssu::Reference< com::sun::star::io::XInputStream > xObjectInputStream;
713 DBG_ASSERT( m_xUriBinding.is(), "Need XUriBinding!" );
715 xObjectInputStream = m_xUriBinding->getUriBinding(objectURL);
717 return xObjectInputStream;
720 #if 0
721 sal_Int32 XSecController::getFastPropertyIndex(sal_Int32 nHandle) const
722 /****** XSecController/getFastPropertyIndex ***********************************
724 * NAME
725 * getFastPropertyIndex -- gets the index of a particular fast property
727 * SYNOPSIS
728 * nIndex = getFastPropertyIndex( nHandle );
730 * FUNCTION
731 * See NAME.
733 * INPUTS
734 * nHandle - the key for the fast property
736 * RESULT
737 * nIndex - the index of the fast property, or -1
738 * if the key is not found.
740 * HISTORY
741 * 05.01.2004 - implemented
743 * AUTHOR
744 * Michael Mi
745 * Email: michael.mi@sun.com
746 ******************************************************************************/
748 std::vector< sal_Int32 >::const_iterator ii = m_vFastPropertyIndexs.begin();
749 sal_Int32 nIndex = 0;
751 bool bFound = false;
753 for( ; ii != m_vFastPropertyIndexs.end(); ++ii,++nIndex )
755 if ( nHandle == (*ii))
757 bFound = true;
758 break;
762 if (!bFound)
764 nIndex = -1;
767 return nIndex;
769 #endif
772 * public methods
775 sal_Int32 XSecController::getNewSecurityId( )
777 sal_Int32 nId = m_nNextSecurityId;
778 m_nNextSecurityId++;
779 return nId;
782 void XSecController::startMission(
783 const cssu::Reference< cssxc::XUriBinding >& xUriBinding,
784 const cssu::Reference< cssxc::XXMLSecurityContext >& xSecurityContext )
785 /****** XSecController/startMission *******************************************
787 * NAME
788 * startMission -- starts a new security mission.
790 * SYNOPSIS
791 * startMission( xUriBinding, xSecurityContect );
793 * FUNCTION
794 * get ready for a new mission.
796 * INPUTS
797 * xUriBinding - the Uri binding that provide maps between uris and
798 * XInputStreams
799 * xSecurityContext - the security context component which can provide
800 * cryptoken
802 * RESULT
803 * empty
805 * HISTORY
806 * 05.01.2004 - implemented
808 * AUTHOR
809 * Michael Mi
810 * Email: michael.mi@sun.com
811 ******************************************************************************/
813 m_xUriBinding = xUriBinding;
815 m_nStatusOfSecurityComponents = UNINITIALIZED;
816 m_xSecurityContext = xSecurityContext;
817 m_pErrorMessage = NULL;
819 m_vInternalSignatureInformations.clear();
821 m_bVerifyCurrentSignature = false;
824 void XSecController::setSAXChainConnector(
825 const cssu::Reference< cssl::XInitialization >& xInitialization,
826 const cssu::Reference< cssxs::XDocumentHandler >& xDocumentHandler,
827 const cssu::Reference< cssxc::sax::XElementStackKeeper >& xElementStackKeeper)
828 /****** XSecController/setSAXChainConnector ***********************************
830 * NAME
831 * setSAXChainConnector -- configures the components which will
832 * collaborate with the SAXEventKeeper on the SAX chain.
834 * SYNOPSIS
835 * setSAXChainConnector( xInitialization,
836 * xDocumentHandler,
837 * xElementStackKeeper );
839 * FUNCTION
840 * See NAME.
842 * INPUTS
843 * xInitialization - the previous node on the SAX chain
844 * xDocumentHandler - the next node on the SAX chain
845 * xElementStackKeeper - the ElementStackKeeper component which reserves
846 * missed key SAX events for the SAXEventKeeper
848 * RESULT
849 * empty
851 * HISTORY
852 * 05.01.2004 - implemented
854 * AUTHOR
855 * Michael Mi
856 * Email: michael.mi@sun.com
857 ******************************************************************************/
859 m_bIsPreviousNodeInitializable = true;
860 m_xPreviousNodeOnSAXChain = xInitialization;
861 m_xNextNodeOnSAXChain = xDocumentHandler;
862 m_xElementStackKeeper = xElementStackKeeper;
864 initializeSAXChain( );
867 void XSecController::setSAXChainConnector(
868 const cssu::Reference< cssxs::XParser >& xParser,
869 const cssu::Reference< cssxs::XDocumentHandler >& xDocumentHandler,
870 const cssu::Reference< cssxc::sax::XElementStackKeeper >& xElementStackKeeper)
871 /****** XSecController/setSAXChainConnector ***********************************
873 * NAME
874 * setSAXChainConnector -- configures the components which will
875 * collaborate with the SAXEventKeeper on the SAX chain.
877 * SYNOPSIS
878 * setSAXChainConnector( xParser, xDocumentHandler, xElementStackKeeper );
880 * FUNCTION
881 * See NAME.
883 * INPUTS
884 * xParser - the previous node on the SAX chain
885 * xDocumentHandler - the next node on the SAX chain
886 * xElementStackKeeper -the ElementStackKeeper component which reserves
887 * missed key SAX events for the SAXEventKeeper
889 * RESULT
890 * empty
892 * HISTORY
893 * 05.01.2004 - implemented
895 * AUTHOR
896 * Michael Mi
897 * Email: michael.mi@sun.com
898 ******************************************************************************/
900 m_bIsPreviousNodeInitializable = false;
901 m_xPreviousNodeOnSAXChain = xParser;
902 m_xNextNodeOnSAXChain = xDocumentHandler;
903 m_xElementStackKeeper = xElementStackKeeper;
905 initializeSAXChain( );
908 void XSecController::clearSAXChainConnector()
909 /****** XSecController/clearSAXChainConnector *********************************
911 * NAME
912 * clearSAXChainConnector -- resets the collaborating components.
914 * SYNOPSIS
915 * clearSAXChainConnector( );
917 * FUNCTION
918 * See NAME.
920 * INPUTS
921 * empty
923 * RESULT
924 * empty
926 * HISTORY
927 * 05.01.2004 - implemented
929 * AUTHOR
930 * Michael Mi
931 * Email: michael.mi@sun.com
932 ******************************************************************************/
935 * before reseting, if the ElementStackKeeper has kept something, then
936 * those kept key SAX events must be transferred to the SAXEventKeeper
937 * first. This is to promise the next node to the SAXEventKeeper on the
938 * SAX chain always receives a complete document.
940 if (m_xElementStackKeeper.is() && m_xSAXEventKeeper.is())
942 cssu::Reference< cssxs::XDocumentHandler > xSEKHandler(m_xSAXEventKeeper, cssu::UNO_QUERY);
943 m_xElementStackKeeper->retrieve(xSEKHandler, sal_True);
946 chainOff();
948 m_xPreviousNodeOnSAXChain = NULL;
949 m_xNextNodeOnSAXChain = NULL;
950 m_xElementStackKeeper = NULL;
953 void XSecController::endMission()
954 /****** XSecController/endMission *********************************************
956 * NAME
957 * endMission -- forces to end all missions
959 * SYNOPSIS
960 * endMission( );
962 * FUNCTION
963 * Deletes all signature information and forces all missions to an end.
965 * INPUTS
966 * empty
968 * RESULT
969 * empty
971 * HISTORY
972 * 05.01.2004 - implemented
974 * AUTHOR
975 * Michael Mi
976 * Email: michael.mi@sun.com
977 ******************************************************************************/
979 sal_Int32 size = m_vInternalSignatureInformations.size();
981 for (int i=0; i<size; ++i)
983 if ( m_nStatusOfSecurityComponents == INITIALIZED )
985 * ResolvedListener only exist when the security components are created.
988 cssu::Reference< cssxc::sax::XMissionTaker > xMissionTaker
989 ( m_vInternalSignatureInformations[i].xReferenceResolvedListener, cssu::UNO_QUERY );
992 * askes the SignatureCreator/SignatureVerifier to release
993 * all resouces it uses.
995 xMissionTaker->endMission();
999 m_xUriBinding = NULL;
1000 m_xSecurityContext = NULL;
1003 * free the status change listener reference to this object
1005 if (m_xSAXEventKeeper.is())
1007 cssu::Reference<cssxc::sax::XSAXEventKeeperStatusChangeBroadcaster>
1008 xSAXEventKeeperStatusChangeBroadcaster(m_xSAXEventKeeper, cssu::UNO_QUERY);
1009 xSAXEventKeeperStatusChangeBroadcaster
1010 ->addSAXEventKeeperStatusChangeListener( NULL );
1014 const char* XSecController::getErrorMessage()
1015 /****** XSecController/getErrorMessage ****************************************
1017 * NAME
1018 * getErrorMessage -- get the last error message
1020 * SYNOPSIS
1021 * pErrorMessage = getErrorMessage( );
1023 * FUNCTION
1024 * see NAME.
1026 * INPUTS
1027 * empty
1029 * RESULT
1030 * empty
1032 * HISTORY
1033 * 22.04.2004 - implemented
1035 * AUTHOR
1036 * Michael Mi
1037 * Email: michael.mi@sun.com
1038 ******************************************************************************/
1040 return m_pErrorMessage;
1043 void XSecController::exportSignature(
1044 const cssu::Reference<cssxs::XDocumentHandler>& xDocumentHandler,
1045 const SignatureInformation& signatureInfo )
1046 /****** XSecController/exportSignature ****************************************
1048 * NAME
1049 * exportSignature -- export a signature structure to an XDocumentHandler
1051 * SYNOPSIS
1052 * exportSignature( xDocumentHandler, signatureInfo);
1054 * FUNCTION
1055 * see NAME.
1057 * INPUTS
1058 * xDocumentHandler - the document handler to receive the signature
1059 * signatureInfo - signature to be exported
1061 * RESULT
1062 * empty
1064 * HISTORY
1065 * 26.05.2004 - implemented
1067 * AUTHOR
1068 * Michael Mi
1069 * Email: michael.mi@sun.com
1070 ******************************************************************************/
1073 * defines all element tags in Signature element.
1075 rtl::OUString tag_Signature(RTL_CONSTASCII_USTRINGPARAM(TAG_SIGNATURE));
1076 rtl::OUString tag_SignedInfo(RTL_CONSTASCII_USTRINGPARAM(TAG_SIGNEDINFO));
1077 rtl::OUString tag_CanonicalizationMethod(RTL_CONSTASCII_USTRINGPARAM(TAG_CANONICALIZATIONMETHOD));
1078 rtl::OUString tag_SignatureMethod(RTL_CONSTASCII_USTRINGPARAM(TAG_SIGNATUREMETHOD));
1079 rtl::OUString tag_Reference(RTL_CONSTASCII_USTRINGPARAM(TAG_REFERENCE));
1080 rtl::OUString tag_Transforms(RTL_CONSTASCII_USTRINGPARAM(TAG_TRANSFORMS));
1081 rtl::OUString tag_Transform(RTL_CONSTASCII_USTRINGPARAM(TAG_TRANSFORM));
1082 rtl::OUString tag_DigestMethod(RTL_CONSTASCII_USTRINGPARAM(TAG_DIGESTMETHOD));
1083 rtl::OUString tag_DigestValue(RTL_CONSTASCII_USTRINGPARAM(TAG_DIGESTVALUE));
1084 rtl::OUString tag_SignatureValue(RTL_CONSTASCII_USTRINGPARAM(TAG_SIGNATUREVALUE));
1085 rtl::OUString tag_KeyInfo(RTL_CONSTASCII_USTRINGPARAM(TAG_KEYINFO));
1086 rtl::OUString tag_X509Data(RTL_CONSTASCII_USTRINGPARAM(TAG_X509DATA));
1087 rtl::OUString tag_X509IssuerSerial(RTL_CONSTASCII_USTRINGPARAM(TAG_X509ISSUERSERIAL));
1088 rtl::OUString tag_X509IssuerName(RTL_CONSTASCII_USTRINGPARAM(TAG_X509ISSUERNAME));
1089 rtl::OUString tag_X509SerialNumber(RTL_CONSTASCII_USTRINGPARAM(TAG_X509SERIALNUMBER));
1090 rtl::OUString tag_X509Certificate(RTL_CONSTASCII_USTRINGPARAM(TAG_X509CERTIFICATE));
1092 rtl::OUString tag_Object(RTL_CONSTASCII_USTRINGPARAM(TAG_OBJECT));
1093 rtl::OUString tag_SignatureProperties(RTL_CONSTASCII_USTRINGPARAM(TAG_SIGNATUREPROPERTIES));
1094 rtl::OUString tag_SignatureProperty(RTL_CONSTASCII_USTRINGPARAM(TAG_SIGNATUREPROPERTY));
1095 rtl::OUString tag_Date(RTL_CONSTASCII_USTRINGPARAM(TAG_DATE));
1096 #if 0
1097 rtl::OUString tag_Timestamp(RTL_CONSTASCII_USTRINGPARAM(TAG_TIMESTAMP));
1098 rtl::OUString tag_Date(RTL_CONSTASCII_USTRINGPARAM(TAG_DATE));
1099 rtl::OUString tag_Time(RTL_CONSTASCII_USTRINGPARAM(TAG_TIME));
1100 #endif
1102 const SignatureReferenceInformations& vReferenceInfors = signatureInfo.vSignatureReferenceInfors;
1103 SvXMLAttributeList *pAttributeList;
1106 * Write Signature element
1108 pAttributeList = new SvXMLAttributeList();
1109 pAttributeList->AddAttribute(
1110 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(ATTR_XMLNS)),
1111 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(NS_XMLDSIG)));
1113 if (signatureInfo.ouSignatureId.getLength()>0)
1115 pAttributeList->AddAttribute(
1116 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(ATTR_ID)),
1117 rtl::OUString(signatureInfo.ouSignatureId));
1120 xDocumentHandler->startElement( tag_Signature, cssu::Reference< cssxs::XAttributeList > (pAttributeList));
1122 /* Write SignedInfo element */
1123 xDocumentHandler->startElement(
1124 tag_SignedInfo,
1125 cssu::Reference< cssxs::XAttributeList > (new SvXMLAttributeList()));
1127 /* Write CanonicalizationMethod element */
1128 pAttributeList = new SvXMLAttributeList();
1129 pAttributeList->AddAttribute(
1130 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(ATTR_ALGORITHM)),
1131 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(ALGO_C14N)));
1132 xDocumentHandler->startElement( tag_CanonicalizationMethod, cssu::Reference< cssxs::XAttributeList > (pAttributeList) );
1133 xDocumentHandler->endElement( tag_CanonicalizationMethod );
1135 /* Write SignatureMethod element */
1136 pAttributeList = new SvXMLAttributeList();
1137 pAttributeList->AddAttribute(
1138 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(ATTR_ALGORITHM)),
1139 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(ALGO_RSASHA1)));
1140 xDocumentHandler->startElement( tag_SignatureMethod, cssu::Reference< cssxs::XAttributeList > (pAttributeList) );
1141 xDocumentHandler->endElement( tag_SignatureMethod );
1143 /* Write Reference element */
1144 int j;
1145 int refNum = vReferenceInfors.size();
1147 for(j=0; j<refNum; ++j)
1149 const SignatureReferenceInformation& refInfor = vReferenceInfors[j];
1151 pAttributeList = new SvXMLAttributeList();
1152 if ( refInfor.nType != TYPE_SAMEDOCUMENT_REFERENCE )
1154 * stream reference
1157 pAttributeList->AddAttribute(
1158 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(ATTR_URI)),
1159 refInfor.ouURI);
1161 else
1163 * same-document reference
1166 pAttributeList->AddAttribute(
1167 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(ATTR_URI)),
1168 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(CHAR_FRAGMENT))+refInfor.ouURI);
1171 xDocumentHandler->startElement( tag_Reference, cssu::Reference< cssxs::XAttributeList > (pAttributeList) );
1173 /* Write Transforms element */
1174 if (refInfor.nType == TYPE_XMLSTREAM_REFERENCE)
1176 * xml stream, so c14n transform is needed
1179 xDocumentHandler->startElement(
1180 tag_Transforms,
1181 cssu::Reference< cssxs::XAttributeList > (new SvXMLAttributeList()));
1183 pAttributeList = new SvXMLAttributeList();
1184 pAttributeList->AddAttribute(
1185 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(ATTR_ALGORITHM)),
1186 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(ALGO_C14N)));
1187 xDocumentHandler->startElement(
1188 tag_Transform,
1189 cssu::Reference< cssxs::XAttributeList > (pAttributeList) );
1190 xDocumentHandler->endElement( tag_Transform );
1192 xDocumentHandler->endElement( tag_Transforms );
1195 /* Write DigestMethod element */
1196 pAttributeList = new SvXMLAttributeList();
1197 pAttributeList->AddAttribute(
1198 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(ATTR_ALGORITHM)),
1199 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(ALGO_XMLDSIGSHA1)));
1200 xDocumentHandler->startElement(
1201 tag_DigestMethod,
1202 cssu::Reference< cssxs::XAttributeList > (pAttributeList) );
1203 xDocumentHandler->endElement( tag_DigestMethod );
1205 /* Write DigestValue element */
1206 xDocumentHandler->startElement(
1207 tag_DigestValue,
1208 cssu::Reference< cssxs::XAttributeList > (new SvXMLAttributeList()));
1209 xDocumentHandler->characters( refInfor.ouDigestValue );
1210 xDocumentHandler->endElement( tag_DigestValue );
1212 xDocumentHandler->endElement( tag_Reference );
1215 xDocumentHandler->endElement( tag_SignedInfo );
1217 /* Write SignatureValue element */
1218 xDocumentHandler->startElement(
1219 tag_SignatureValue,
1220 cssu::Reference< cssxs::XAttributeList > (new SvXMLAttributeList()));
1221 xDocumentHandler->characters( signatureInfo.ouSignatureValue );
1222 xDocumentHandler->endElement( tag_SignatureValue );
1224 /* Write KeyInfo element */
1225 xDocumentHandler->startElement(
1226 tag_KeyInfo,
1227 cssu::Reference< cssxs::XAttributeList > (new SvXMLAttributeList()));
1229 /* Write X509Data element */
1230 xDocumentHandler->startElement(
1231 tag_X509Data,
1232 cssu::Reference< cssxs::XAttributeList > (new SvXMLAttributeList()));
1234 /* Write X509IssuerSerial element */
1235 xDocumentHandler->startElement(
1236 tag_X509IssuerSerial,
1237 cssu::Reference< cssxs::XAttributeList > (new SvXMLAttributeList()));
1239 /* Write X509IssuerName element */
1240 xDocumentHandler->startElement(
1241 tag_X509IssuerName,
1242 cssu::Reference< cssxs::XAttributeList > (new SvXMLAttributeList()));
1243 xDocumentHandler->characters( signatureInfo.ouX509IssuerName );
1244 xDocumentHandler->endElement( tag_X509IssuerName );
1246 /* Write X509SerialNumber element */
1247 xDocumentHandler->startElement(
1248 tag_X509SerialNumber,
1249 cssu::Reference< cssxs::XAttributeList > (new SvXMLAttributeList()));
1250 xDocumentHandler->characters( signatureInfo.ouX509SerialNumber );
1251 xDocumentHandler->endElement( tag_X509SerialNumber );
1253 xDocumentHandler->endElement( tag_X509IssuerSerial );
1255 /* Write X509Certificate element */
1256 if (signatureInfo.ouX509Certificate.getLength()>0)
1258 xDocumentHandler->startElement(
1259 tag_X509Certificate,
1260 cssu::Reference< cssxs::XAttributeList > (new SvXMLAttributeList()));
1261 xDocumentHandler->characters( signatureInfo.ouX509Certificate );
1262 xDocumentHandler->endElement( tag_X509Certificate );
1265 xDocumentHandler->endElement( tag_X509Data );
1267 xDocumentHandler->endElement( tag_KeyInfo );
1269 /* Write Object element */
1270 xDocumentHandler->startElement(
1271 tag_Object,
1272 cssu::Reference< cssxs::XAttributeList > (new SvXMLAttributeList()));
1274 /* Write SignatureProperties element */
1275 xDocumentHandler->startElement(
1276 tag_SignatureProperties,
1277 cssu::Reference< cssxs::XAttributeList > (new SvXMLAttributeList()));
1279 /* Write SignatureProperty element */
1280 pAttributeList = new SvXMLAttributeList();
1281 pAttributeList->AddAttribute(
1282 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(ATTR_ID)),
1283 signatureInfo.ouPropertyId);
1284 pAttributeList->AddAttribute(
1285 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(ATTR_TARGET)),
1286 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(CHAR_FRAGMENT))+signatureInfo.ouSignatureId);
1287 xDocumentHandler->startElement(
1288 tag_SignatureProperty,
1289 cssu::Reference< cssxs::XAttributeList > (pAttributeList));
1291 /* Write timestamp element */
1293 pAttributeList = new SvXMLAttributeList();
1294 pAttributeList->AddAttribute(
1295 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(ATTR_XMLNS))
1296 +rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(":"))
1297 +rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(NSTAG_DC)),
1298 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(NS_DC)));
1300 xDocumentHandler->startElement(
1301 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(NSTAG_DC))
1302 +rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(":"))
1303 +tag_Date,
1304 cssu::Reference< cssxs::XAttributeList > (pAttributeList));
1306 ::rtl::OUStringBuffer buffer;
1307 //If the xml signature was already contained in the document,
1308 //then we use the original date and time string, rather then the
1309 //converted one. When the original string is converted to the DateTime
1310 //structure then information may be lost because it only holds a fractional
1311 //of a second with a accuracy of one hundredth of second. If the string contains
1312 //milli seconds (document was signed by an application other than OOo)
1313 //and the converted time is written back, then the string looks different
1314 //and the signature is broken.
1315 if (signatureInfo.ouDateTime.getLength() > 0)
1316 buffer = signatureInfo.ouDateTime;
1317 else
1318 convertDateTime( buffer, signatureInfo.stDateTime );
1319 xDocumentHandler->characters( buffer.makeStringAndClear() );
1321 xDocumentHandler->endElement(
1322 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(NSTAG_DC))
1323 +rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(":"))
1324 +tag_Date);
1326 xDocumentHandler->endElement( tag_SignatureProperty );
1328 xDocumentHandler->endElement( tag_SignatureProperties );
1330 xDocumentHandler->endElement( tag_Object );
1332 xDocumentHandler->endElement( tag_Signature );
1335 SignatureInformation XSecController::getSignatureInformation( sal_Int32 nSecurityId ) const
1337 SignatureInformation aInf( 0 );
1338 int nIndex = findSignatureInfor(nSecurityId);
1339 DBG_ASSERT( nIndex != -1, "getSignatureInformation - SecurityId is invalid!" );
1340 if ( nIndex != -1)
1342 aInf = m_vInternalSignatureInformations[nIndex].signatureInfor;
1344 return aInf;
1347 SignatureInformations XSecController::getSignatureInformations() const
1349 SignatureInformations vInfors;
1350 int sigNum = m_vInternalSignatureInformations.size();
1352 for (int i=0; i<sigNum; ++i)
1354 SignatureInformation si = m_vInternalSignatureInformations[i].signatureInfor;
1355 vInfors.push_back(si);
1358 return vInfors;
1362 * XSecurityController
1364 * no methods
1368 * XFastPropertySet
1371 void SAL_CALL XSecController::setFastPropertyValue(
1372 sal_Int32 nHandle,
1373 const cssu::Any& aValue )
1374 throw ( cssb::UnknownPropertyException,
1375 cssb::PropertyVetoException,
1376 cssl::IllegalArgumentException,
1377 cssl::WrappedTargetException,
1378 cssu::RuntimeException)
1380 sal_Int32 nIndex = getFastPropertyIndex(nHandle);
1381 if (nIndex == -1)
1383 m_vFastPropertyIndexs.push_back( nHandle );
1384 m_vFastPropertyValues.push_back( aValue );
1386 else
1388 m_vFastPropertyValues[nIndex] = aValue;
1392 cssu::Any SAL_CALL XSecController::getFastPropertyValue(
1393 sal_Int32 nHandle )
1394 throw (
1395 cssb::UnknownPropertyException,
1396 cssl::WrappedTargetException,
1397 cssu::RuntimeException)
1399 cssu::Any aValue;
1401 sal_Int32 nIndex = getFastPropertyIndex(nHandle);
1402 if (nIndex != -1)
1404 aValue = m_vFastPropertyValues[nIndex];
1407 return aValue;
1412 * XSAXEventKeeperStatusChangeListener
1415 void SAL_CALL XSecController::blockingStatusChanged( sal_Bool isBlocking )
1416 throw (cssu::RuntimeException)
1419 showMessageBox( rtl::OUString::createFromAscii((isBlocking?
1420 "Blocking Status => TRUE":
1421 "Blocking Status => FALSE")),
1422 rtl::OUString::createFromAscii("SAXEventKeeper Status"));
1425 this->m_bIsBlocking = isBlocking;
1426 checkChainingStatus();
1429 void SAL_CALL XSecController::collectionStatusChanged(
1430 sal_Bool isInsideCollectedElement )
1431 throw (cssu::RuntimeException)
1434 showMessageBox( rtl::OUString::createFromAscii((isInsideCollectedElement?
1435 "Collection Status => TRUE":
1436 "Collection Status => FALSE")),
1437 rtl::OUString::createFromAscii("SAXEventKeeper Status"));
1440 this->m_bIsCollectingElement = isInsideCollectedElement;
1441 checkChainingStatus();
1444 void SAL_CALL XSecController::bufferStatusChanged( sal_Bool /*isBufferEmpty*/)
1445 throw (cssu::RuntimeException)
1448 showMessageBox( rtl::OUString::createFromAscii((isBufferEmpty?
1449 "Buffer Empty => TRUE":
1450 "Buffer Empty => FALSE")),
1451 rtl::OUString::createFromAscii("SAXEventKeeper Status"));
1456 * XSignatureCreationResultListener
1458 void SAL_CALL XSecController::signatureCreated( sal_Int32 securityId, com::sun::star::xml::crypto::SecurityOperationStatus nResult )
1459 throw (com::sun::star::uno::RuntimeException)
1461 int index = findSignatureInfor(securityId);
1462 DBG_ASSERT( index != -1, "Signature Not Found!" );
1464 SignatureInformation& signatureInfor = m_vInternalSignatureInformations[index].signatureInfor;
1467 if (nResult == cssxc::sax::SignatureCreationResult_CREATIONSUCCEED)
1469 signatureInfor.nStatus = STATUS_CREATION_SUCCEED;
1471 else
1473 signatureInfor.nStatus = STATUS_CREATION_FAIL;
1476 signatureInfor.nStatus = nResult;
1480 * XSignatureVerifyResultListener
1482 void SAL_CALL XSecController::signatureVerified( sal_Int32 securityId, com::sun::star::xml::crypto::SecurityOperationStatus nResult )
1483 throw (com::sun::star::uno::RuntimeException)
1485 int index = findSignatureInfor(securityId);
1486 DBG_ASSERT( index != -1, "Signature Not Found!" );
1488 SignatureInformation& signatureInfor = m_vInternalSignatureInformations[index].signatureInfor;
1491 if (nResult == cssxc::sax::SignatureVerifyResult_VERIFYSUCCEED)
1493 signatureInfor.nStatus = STATUS_VERIFY_SUCCEED;
1495 else
1497 signatureInfor.nStatus = STATUS_VERIFY_FAIL;
1500 signatureInfor.nStatus = nResult;