merged tag ooo/OOO330_m14
[LibreOffice.git] / xmlsecurity / source / helper / xsecctl.cxx
blobbdcb0658af1e2d9e867cdb919e4e3580db6c3c0e
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_xmlsecurity.hxx"
31 #include <xsecctl.hxx>
32 #include <tools/debug.hxx>
34 #include <com/sun/star/xml/crypto/sax/ElementMarkPriority.hpp>
35 #include <com/sun/star/xml/crypto/sax/XReferenceResolvedBroadcaster.hpp>
36 #include <com/sun/star/xml/crypto/sax/XMissionTaker.hpp>
37 #include <com/sun/star/xml/crypto/sax/XReferenceCollector.hpp>
38 #include <com/sun/star/xml/crypto/sax/XSAXEventKeeperStatusChangeBroadcaster.hpp>
39 #include <com/sun/star/xml/crypto/SecurityOperationStatus.hpp>
41 #include <xmloff/attrlist.hxx>
42 #include <rtl/math.hxx>
43 #include <tools/string.hxx>
45 namespace cssu = com::sun::star::uno;
46 namespace cssl = com::sun::star::lang;
47 namespace cssxc = com::sun::star::xml::crypto;
48 namespace cssxs = com::sun::star::xml::sax;
49 namespace cssxw = com::sun::star::xml::wrapper;
50 namespace cssb = com::sun::star::beans;
52 const sal_Int8 XML_MAXDIGITSCOUNT_TIME = 11;
53 const sal_Int8 XML_MAXDIGITSCOUNT_DATETIME = 6;
55 /* bridge component names */
56 #define XMLSIGNATURE_COMPONENT "com.sun.star.xml.crypto.XMLSignature"
57 #define XMLDOCUMENTWRAPPER_COMPONENT "com.sun.star.xml.wrapper.XMLDocumentWrapper"
59 /* xml security framework components */
60 #define SAXEVENTKEEPER_COMPONENT "com.sun.star.xml.crypto.sax.SAXEventKeeper"
62 /* string for package protocol */
63 #define PACKAGEPROTOCOL "vnd.sun.star.Package:"
65 XSecController::XSecController( const cssu::Reference<cssu::XComponentContext>& rxCtx )
66 :mxCtx(rxCtx),
67 m_nNextSecurityId(1),
68 m_bIsSAXEventKeeperConnected(false),
69 m_nStatusOfSecurityComponents(UNINITIALIZED),
70 m_bIsSAXEventKeeperSticky(false),
71 m_pErrorMessage(NULL),
72 m_pXSecParser(NULL)
76 XSecController::~XSecController()
82 * private methods
84 /** convert string to number with optional min and max values */
85 sal_Bool XSecController::convertNumber( sal_Int32& rValue,
86 const rtl::OUString& rString,
87 sal_Int32 /*nMin*/, sal_Int32 /*nMax*/ )
89 sal_Bool bNeg = sal_False;
90 rValue = 0;
92 sal_Int32 nPos = 0L;
93 sal_Int32 nLen = rString.getLength();
95 // skip white space
96 while( nPos < nLen && sal_Unicode(' ') == rString[nPos] )
97 nPos++;
99 if( nPos < nLen && sal_Unicode('-') == rString[nPos] )
101 bNeg = sal_True;
102 nPos++;
105 // get number
106 while( nPos < nLen &&
107 sal_Unicode('0') <= rString[nPos] &&
108 sal_Unicode('9') >= rString[nPos] )
110 // TODO: check overflow!
111 rValue *= 10;
112 rValue += (rString[nPos] - sal_Unicode('0'));
113 nPos++;
116 if( bNeg )
117 rValue *= -1;
119 return nPos == nLen;
122 /** convert util::DateTime to ISO Date String */
123 void XSecController::convertDateTime( ::rtl::OUStringBuffer& rBuffer,
124 const com::sun::star::util::DateTime& rDateTime )
126 String aString( String::CreateFromInt32( rDateTime.Year ) );
127 aString += '-';
128 if( rDateTime.Month < 10 )
129 aString += '0';
130 aString += String::CreateFromInt32( rDateTime.Month );
131 aString += '-';
132 if( rDateTime.Day < 10 )
133 aString += '0';
134 aString += String::CreateFromInt32( rDateTime.Day );
136 if( rDateTime.Seconds != 0 ||
137 rDateTime.Minutes != 0 ||
138 rDateTime.Hours != 0 )
140 aString += 'T';
141 if( rDateTime.Hours < 10 )
142 aString += '0';
143 aString += String::CreateFromInt32( rDateTime.Hours );
144 aString += ':';
145 if( rDateTime.Minutes < 10 )
146 aString += '0';
147 aString += String::CreateFromInt32( rDateTime.Minutes );
148 aString += ':';
149 if( rDateTime.Seconds < 10 )
150 aString += '0';
151 aString += String::CreateFromInt32( rDateTime.Seconds );
152 if ( rDateTime.HundredthSeconds > 0)
154 aString += ',';
155 if (rDateTime.HundredthSeconds < 10)
156 aString += '0';
157 aString += String::CreateFromInt32( rDateTime.HundredthSeconds );
161 rBuffer.append( aString );
164 /** convert ISO Date String to util::DateTime */
165 sal_Bool XSecController::convertDateTime( com::sun::star::util::DateTime& rDateTime,
166 const ::rtl::OUString& rString )
168 sal_Bool bSuccess = sal_True;
170 rtl::OUString aDateStr, aTimeStr, sHundredth;
171 sal_Int32 nPos = rString.indexOf( (sal_Unicode) 'T' );
172 sal_Int32 nPos2 = rString.indexOf( (sal_Unicode) ',' );
173 if ( nPos >= 0 )
175 aDateStr = rString.copy( 0, nPos );
176 if ( nPos2 >= 0 )
178 aTimeStr = rString.copy( nPos + 1, nPos2 - nPos - 1 );
180 //Get the fraction of a second with the accuracy of one hundreds second.
181 //The fraction part of the date could have different accuracies. To calculate
182 //the count of a hundredth units one could form a fractional number by appending
183 //the value of the time string to 0. Then multiply it by 100 and use only the whole number.
184 //For example: 5:27:46,1 -> 0,1 * 100 = 10
185 //5:27:46,01 -> 0,01 * 100 = 1
186 //5:27:46,001 -> 0,001 * 100 = 0
187 //Due to the inaccuracy of floating point numbers the result may not be the same on different
188 //platforms. We had the case where we had a value of 24 hundredth of second, which converted to
189 //23 on Linux and 24 on Solaris and Windows.
191 //we only support a hundredth second
192 //make ,1 -> 10 ,01 -> 1 ,001 -> only use first two diggits
193 sHundredth = rString.copy(nPos2 + 1);
194 sal_Int32 len = sHundredth.getLength();
195 if (len == 1)
196 sHundredth += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("0"));
197 if (len > 2)
198 sHundredth = sHundredth.copy(0, 2);
200 else
202 aTimeStr = rString.copy(nPos + 1);
203 sHundredth = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("0"));
206 else
207 aDateStr = rString; // no separator: only date part
209 sal_Int32 nYear = 1899;
210 sal_Int32 nMonth = 12;
211 sal_Int32 nDay = 30;
212 sal_Int32 nHour = 0;
213 sal_Int32 nMin = 0;
214 sal_Int32 nSec = 0;
216 const sal_Unicode* pStr = aDateStr.getStr();
217 sal_Int32 nDateTokens = 1;
218 while ( *pStr )
220 if ( *pStr == '-' )
221 nDateTokens++;
222 pStr++;
224 if ( nDateTokens > 3 || aDateStr.getLength() == 0 )
225 bSuccess = sal_False;
226 else
228 sal_Int32 n = 0;
229 if ( !convertNumber( nYear, aDateStr.getToken( 0, '-', n ), 0, 9999 ) )
230 bSuccess = sal_False;
231 if ( nDateTokens >= 2 )
232 if ( !convertNumber( nMonth, aDateStr.getToken( 0, '-', n ), 0, 12 ) )
233 bSuccess = sal_False;
234 if ( nDateTokens >= 3 )
235 if ( !convertNumber( nDay, aDateStr.getToken( 0, '-', n ), 0, 31 ) )
236 bSuccess = sal_False;
239 if ( aTimeStr.getLength() > 0 ) // time is optional
241 pStr = aTimeStr.getStr();
242 sal_Int32 nTimeTokens = 1;
243 while ( *pStr )
245 if ( *pStr == ':' )
246 nTimeTokens++;
247 pStr++;
249 if ( nTimeTokens > 3 )
250 bSuccess = sal_False;
251 else
253 sal_Int32 n = 0;
254 if ( !convertNumber( nHour, aTimeStr.getToken( 0, ':', n ), 0, 23 ) )
255 bSuccess = sal_False;
256 if ( nTimeTokens >= 2 )
257 if ( !convertNumber( nMin, aTimeStr.getToken( 0, ':', n ), 0, 59 ) )
258 bSuccess = sal_False;
259 if ( nTimeTokens >= 3 )
260 if ( !convertNumber( nSec, aTimeStr.getToken( 0, ':', n ), 0, 59 ) )
261 bSuccess = sal_False;
265 if (bSuccess)
267 rDateTime.Year = (sal_uInt16)nYear;
268 rDateTime.Month = (sal_uInt16)nMonth;
269 rDateTime.Day = (sal_uInt16)nDay;
270 rDateTime.Hours = (sal_uInt16)nHour;
271 rDateTime.Minutes = (sal_uInt16)nMin;
272 rDateTime.Seconds = (sal_uInt16)nSec;
273 // rDateTime.HundredthSeconds = sDoubleStr.toDouble() * 100;
274 rDateTime.HundredthSeconds = static_cast<sal_uInt16>(sHundredth.toInt32());
276 return bSuccess;
279 int XSecController::findSignatureInfor( sal_Int32 nSecurityId) const
280 /****** XSecController/findSignatureInfor *************************************
282 * NAME
283 * findSignatureInfor -- find SignatureInformation struct for a particular
284 * signature
286 * SYNOPSIS
287 * index = findSignatureInfor( nSecurityId );
289 * FUNCTION
290 * see NAME.
292 * INPUTS
293 * nSecurityId - the signature's id
295 * RESULT
296 * index - the index of the signature, or -1 when no such signature
297 * existing
299 * HISTORY
300 * 08.05.2004 - implemented
302 * AUTHOR
303 * Michael Mi
304 * Email: michael.mi@sun.com
305 ******************************************************************************/
307 int i;
308 int size = m_vInternalSignatureInformations.size();
310 for (i=0; i<size; ++i)
312 if (m_vInternalSignatureInformations[i].signatureInfor.nSecurityId == nSecurityId)
314 return i;
318 return -1;
321 void XSecController::createXSecComponent( )
322 /****** XSecController/createXSecComponent ************************************
324 * NAME
325 * bResult = createXSecComponent -- creates xml security components
327 * SYNOPSIS
328 * createXSecComponent( );
330 * FUNCTION
331 * Creates xml security components, including:
332 * 1. an xml signature bridge component ( Java based or C based)
333 * 2. an XMLDocumentWrapper component ( Java based or C based)
334 * 3. a SAXEventKeeper component
336 * INPUTS
337 * empty
339 * RESULT
340 * empty
342 * HISTORY
343 * 05.01.2004 - implemented
345 * AUTHOR
346 * Michael Mi
347 * Email: michael.mi@sun.com
348 ******************************************************************************/
350 rtl::OUString sSAXEventKeeper(rtl::OUString::createFromAscii( SAXEVENTKEEPER_COMPONENT ));
351 rtl::OUString sXMLSignature(rtl::OUString::createFromAscii( XMLSIGNATURE_COMPONENT ));
352 rtl::OUString sXMLDocument(rtl::OUString::createFromAscii( XMLDOCUMENTWRAPPER_COMPONENT ));
355 * marks all security components are not available.
357 m_nStatusOfSecurityComponents = FAILTOINITIALIZED;
358 m_xXMLSignature = NULL;
359 m_xXMLDocumentWrapper = NULL;
360 m_xSAXEventKeeper = NULL;
362 cssu::Reference< cssl::XMultiComponentFactory > xMCF( mxCtx->getServiceManager() );
364 m_xXMLSignature = cssu::Reference< cssxc::XXMLSignature >(
365 xMCF->createInstanceWithContext( sXMLSignature, mxCtx ),
366 cssu::UNO_QUERY );
368 bool bSuccess = (0!=m_xXMLSignature.is());
369 if ( bSuccess )
371 * XMLSignature created successfully.
374 m_xXMLDocumentWrapper = cssu::Reference< cssxw::XXMLDocumentWrapper >(
375 xMCF->createInstanceWithContext( sXMLDocument, mxCtx ),
376 cssu::UNO_QUERY );
379 bSuccess &= (0!=m_xXMLDocumentWrapper.is());
380 if ( bSuccess )
382 * XMLDocumentWrapper created successfully.
385 m_xSAXEventKeeper = cssu::Reference< cssxc::sax::XSecuritySAXEventKeeper >(
386 xMCF->createInstanceWithContext( sSAXEventKeeper, mxCtx ),
387 cssu::UNO_QUERY );
390 bSuccess &= (0!=m_xSAXEventKeeper.is());
392 if (bSuccess)
394 * SAXEventKeeper created successfully.
397 cssu::Reference< cssl::XInitialization > xInitialization(m_xSAXEventKeeper, cssu::UNO_QUERY);
399 cssu::Sequence <cssu::Any> arg(1);
400 arg[0] = cssu::makeAny(m_xXMLDocumentWrapper);
401 xInitialization->initialize(arg);
403 cssu::Reference<cssxc::sax::XSAXEventKeeperStatusChangeBroadcaster>
404 xSAXEventKeeperStatusChangeBroadcaster(m_xSAXEventKeeper, cssu::UNO_QUERY);
405 cssu::Reference< cssxc::sax::XSAXEventKeeperStatusChangeListener >
406 xStatusChangeListener = this;
408 xSAXEventKeeperStatusChangeBroadcaster
409 ->addSAXEventKeeperStatusChangeListener( xStatusChangeListener );
411 m_nStatusOfSecurityComponents = INITIALIZED;
415 bool XSecController::chainOn( bool bRetrievingLastEvent )
416 /****** XSecController/chainOn ************************************************
418 * NAME
419 * chainOn -- tyies to connect the SAXEventKeeper with the SAX chain.
421 * SYNOPSIS
422 * bJustChainingOn = chainOn( bRetrievingLastEvent );
424 * FUNCTION
425 * First, checks whether the SAXEventKeeper is on the SAX chain. If not,
426 * creates xml security components, and chains the SAXEventKeeper into
427 * the SAX chain.
428 * Before being chained in, the SAXEventKeeper needs to receive all
429 * missed key SAX events, which can promise the DOM tree bufferred by the
430 * SAXEventKeeper has the same structure with the original document.
432 * INPUTS
433 * bRetrievingLastEvent - whether to retrieve the last key SAX event from
434 * the ElementStackKeeper.
436 * RESULT
437 * bJustChainingOn - whether the SAXEventKeeper is just chained into the
438 * SAX chain.
440 * NOTES
441 * Sometimes, the last key SAX event can't be transferred to the
442 * SAXEventKeeper together.
443 * For instance, at the time an referenced element is detected, the
444 * startElement event has already been reserved by the ElementStackKeeper.
445 * Meanwhile, an ElementCollector needs to be created before the
446 * SAXEventKeeper receives that startElement event.
447 * So for the SAXEventKeeper, it needs to receive all missed key SAX
448 * events except that startElement event, then adds a new
449 * ElementCollector, then receives that startElement event.
451 * HISTORY
452 * 05.01.2004 - implemented
454 * AUTHOR
455 * Michael Mi
456 * Email: michael.mi@sun.com
457 ******************************************************************************/
459 bool rc = false;
461 if (!m_bIsSAXEventKeeperSticky && !m_bIsSAXEventKeeperConnected)
463 if ( m_nStatusOfSecurityComponents == UNINITIALIZED )
465 createXSecComponent();
468 if ( m_nStatusOfSecurityComponents == INITIALIZED )
470 * if all security components are ready, chains on the SAXEventKeeper
474 * disconnect the SAXEventKeeper with its current output handler,
475 * to make sure no SAX event is forwarded during the connecting
476 * phase.
478 m_xSAXEventKeeper->setNextHandler( NULL );
480 cssu::Reference< cssxs::XDocumentHandler > xSEKHandler(m_xSAXEventKeeper, cssu::UNO_QUERY);
483 * connects the previous document handler on the SAX chain
485 if ( m_xPreviousNodeOnSAXChain.is() )
487 if ( m_bIsPreviousNodeInitializable )
489 cssu::Reference< cssl::XInitialization > xInitialization
490 (m_xPreviousNodeOnSAXChain, cssu::UNO_QUERY);
492 cssu::Sequence<cssu::Any> aArgs( 1 );
493 aArgs[0] <<= xSEKHandler;
494 xInitialization->initialize(aArgs);
496 else
498 cssu::Reference< cssxs::XParser > xParser
499 (m_xPreviousNodeOnSAXChain, cssu::UNO_QUERY);
500 xParser->setDocumentHandler( xSEKHandler );
505 * get missed key SAX events
507 if (m_xElementStackKeeper.is())
509 m_xElementStackKeeper->retrieve(xSEKHandler, bRetrievingLastEvent);
512 * now the ElementStackKeeper can stop its work, because the
513 * SAXEventKeeper is on the SAX chain, no SAX events will be
514 * missed.
516 m_xElementStackKeeper->stop();
520 * connects the next document handler on the SAX chain
522 m_xSAXEventKeeper->setNextHandler( m_xNextNodeOnSAXChain );
524 m_bIsSAXEventKeeperConnected = true;
526 rc = true;
530 return rc;
533 void XSecController::chainOff()
534 /****** XSecController/chainOff ***********************************************
536 * NAME
537 * chainOff -- disconnects the SAXEventKeeper from the SAX chain.
539 * SYNOPSIS
540 * chainOff( );
542 * FUNCTION
543 * See NAME.
545 * INPUTS
546 * empty
548 * RESULT
549 * empty
551 * HISTORY
552 * 05.01.2004 - implemented
554 * AUTHOR
555 * Michael Mi
556 * Email: michael.mi@sun.com
557 ******************************************************************************/
559 if (!m_bIsSAXEventKeeperSticky )
561 if (m_bIsSAXEventKeeperConnected)
563 m_xSAXEventKeeper->setNextHandler( NULL );
565 if ( m_xPreviousNodeOnSAXChain.is() )
567 if ( m_bIsPreviousNodeInitializable )
569 cssu::Reference< cssl::XInitialization > xInitialization
570 (m_xPreviousNodeOnSAXChain, cssu::UNO_QUERY);
572 cssu::Sequence<cssu::Any> aArgs( 1 );
573 aArgs[0] <<= m_xNextNodeOnSAXChain;
574 xInitialization->initialize(aArgs);
576 else
578 cssu::Reference< cssxs::XParser > xParser(m_xPreviousNodeOnSAXChain, cssu::UNO_QUERY);
579 xParser->setDocumentHandler( m_xNextNodeOnSAXChain );
583 if (m_xElementStackKeeper.is())
586 * start the ElementStackKeeper to reserve any possible
587 * missed key SAX events
589 m_xElementStackKeeper->start();
592 m_bIsSAXEventKeeperConnected = false;
597 void XSecController::checkChainingStatus()
598 /****** XSecController/checkChainingStatus ************************************
600 * NAME
601 * checkChainingStatus -- connects or disconnects the SAXEventKeeper
602 * according to the current situation.
604 * SYNOPSIS
605 * checkChainingStatus( );
607 * FUNCTION
608 * The SAXEventKeeper is chained into the SAX chain, when:
609 * 1. some element is being collected, or
610 * 2. the SAX event stream is blocking.
611 * Otherwise, chain off the SAXEventKeeper.
613 * INPUTS
614 * empty
616 * RESULT
617 * empty
619 * HISTORY
620 * 05.01.2004 - implemented
622 * AUTHOR
623 * Michael Mi
624 * Email: michael.mi@sun.com
625 ******************************************************************************/
627 if ( m_bIsCollectingElement || m_bIsBlocking )
629 chainOn(true);
631 else
633 chainOff();
637 void XSecController::initializeSAXChain()
638 /****** XSecController/initializeSAXChain *************************************
640 * NAME
641 * initializeSAXChain -- initializes the SAX chain according to the
642 * current setting.
644 * SYNOPSIS
645 * initializeSAXChain( );
647 * FUNCTION
648 * Initializes the SAX chain, if the SAXEventKeeper is asked to be always
649 * on the SAX chain, chains it on. Otherwise, starts the
650 * ElementStackKeeper to reserve key SAX events.
652 * INPUTS
653 * empty
655 * RESULT
656 * empty
658 * HISTORY
659 * 05.01.2004 - implemented
661 * AUTHOR
662 * Michael Mi
663 * Email: michael.mi@sun.com
664 ******************************************************************************/
666 m_bIsSAXEventKeeperConnected = false;
667 m_bIsCollectingElement = false;
668 m_bIsBlocking = false;
670 if (m_xElementStackKeeper.is())
673 * starts the ElementStackKeeper
675 m_xElementStackKeeper->start();
678 chainOff();
681 cssu::Reference< com::sun::star::io::XInputStream >
682 XSecController::getObjectInputStream( const rtl::OUString& objectURL )
683 /****** XSecController/getObjectInputStream ************************************
685 * NAME
686 * getObjectInputStream -- get a XInputStream interface from a SvStorage
688 * SYNOPSIS
689 * xInputStream = getObjectInputStream( objectURL );
691 * FUNCTION
692 * See NAME.
694 * INPUTS
695 * objectURL - the object uri
697 * RESULT
698 * xInputStream - the XInputStream interface
700 * HISTORY
701 * 15.04.2004 - implemented
703 * AUTHOR
704 * Michael Mi
705 * Email: michael.mi@sun.com
706 ******************************************************************************/
708 cssu::Reference< com::sun::star::io::XInputStream > xObjectInputStream;
710 DBG_ASSERT( m_xUriBinding.is(), "Need XUriBinding!" );
712 xObjectInputStream = m_xUriBinding->getUriBinding(objectURL);
714 return xObjectInputStream;
717 #if 0
718 sal_Int32 XSecController::getFastPropertyIndex(sal_Int32 nHandle) const
719 /****** XSecController/getFastPropertyIndex ***********************************
721 * NAME
722 * getFastPropertyIndex -- gets the index of a particular fast property
724 * SYNOPSIS
725 * nIndex = getFastPropertyIndex( nHandle );
727 * FUNCTION
728 * See NAME.
730 * INPUTS
731 * nHandle - the key for the fast property
733 * RESULT
734 * nIndex - the index of the fast property, or -1
735 * if the key is not found.
737 * HISTORY
738 * 05.01.2004 - implemented
740 * AUTHOR
741 * Michael Mi
742 * Email: michael.mi@sun.com
743 ******************************************************************************/
745 std::vector< sal_Int32 >::const_iterator ii = m_vFastPropertyIndexs.begin();
746 sal_Int32 nIndex = 0;
748 bool bFound = false;
750 for( ; ii != m_vFastPropertyIndexs.end(); ++ii,++nIndex )
752 if ( nHandle == (*ii))
754 bFound = true;
755 break;
759 if (!bFound)
761 nIndex = -1;
764 return nIndex;
766 #endif
769 * public methods
772 sal_Int32 XSecController::getNewSecurityId( )
774 sal_Int32 nId = m_nNextSecurityId;
775 m_nNextSecurityId++;
776 return nId;
779 void XSecController::startMission(
780 const cssu::Reference< cssxc::XUriBinding >& xUriBinding,
781 const cssu::Reference< cssxc::XXMLSecurityContext >& xSecurityContext )
782 /****** XSecController/startMission *******************************************
784 * NAME
785 * startMission -- starts a new security mission.
787 * SYNOPSIS
788 * startMission( xUriBinding, xSecurityContect );
790 * FUNCTION
791 * get ready for a new mission.
793 * INPUTS
794 * xUriBinding - the Uri binding that provide maps between uris and
795 * XInputStreams
796 * xSecurityContext - the security context component which can provide
797 * cryptoken
799 * RESULT
800 * empty
802 * HISTORY
803 * 05.01.2004 - implemented
805 * AUTHOR
806 * Michael Mi
807 * Email: michael.mi@sun.com
808 ******************************************************************************/
810 m_xUriBinding = xUriBinding;
812 m_nStatusOfSecurityComponents = UNINITIALIZED;
813 m_xSecurityContext = xSecurityContext;
814 m_pErrorMessage = NULL;
816 m_vInternalSignatureInformations.clear();
818 m_bVerifyCurrentSignature = false;
821 void XSecController::setSAXChainConnector(
822 const cssu::Reference< cssl::XInitialization >& xInitialization,
823 const cssu::Reference< cssxs::XDocumentHandler >& xDocumentHandler,
824 const cssu::Reference< cssxc::sax::XElementStackKeeper >& xElementStackKeeper)
825 /****** XSecController/setSAXChainConnector ***********************************
827 * NAME
828 * setSAXChainConnector -- configures the components which will
829 * collaborate with the SAXEventKeeper on the SAX chain.
831 * SYNOPSIS
832 * setSAXChainConnector( xInitialization,
833 * xDocumentHandler,
834 * xElementStackKeeper );
836 * FUNCTION
837 * See NAME.
839 * INPUTS
840 * xInitialization - the previous node on the SAX chain
841 * xDocumentHandler - the next node on the SAX chain
842 * xElementStackKeeper - the ElementStackKeeper component which reserves
843 * missed key SAX events for the SAXEventKeeper
845 * RESULT
846 * empty
848 * HISTORY
849 * 05.01.2004 - implemented
851 * AUTHOR
852 * Michael Mi
853 * Email: michael.mi@sun.com
854 ******************************************************************************/
856 m_bIsPreviousNodeInitializable = true;
857 m_xPreviousNodeOnSAXChain = xInitialization;
858 m_xNextNodeOnSAXChain = xDocumentHandler;
859 m_xElementStackKeeper = xElementStackKeeper;
861 initializeSAXChain( );
864 void XSecController::setSAXChainConnector(
865 const cssu::Reference< cssxs::XParser >& xParser,
866 const cssu::Reference< cssxs::XDocumentHandler >& xDocumentHandler,
867 const cssu::Reference< cssxc::sax::XElementStackKeeper >& xElementStackKeeper)
868 /****** XSecController/setSAXChainConnector ***********************************
870 * NAME
871 * setSAXChainConnector -- configures the components which will
872 * collaborate with the SAXEventKeeper on the SAX chain.
874 * SYNOPSIS
875 * setSAXChainConnector( xParser, xDocumentHandler, xElementStackKeeper );
877 * FUNCTION
878 * See NAME.
880 * INPUTS
881 * xParser - the previous node on the SAX chain
882 * xDocumentHandler - the next node on the SAX chain
883 * xElementStackKeeper -the ElementStackKeeper component which reserves
884 * missed key SAX events for the SAXEventKeeper
886 * RESULT
887 * empty
889 * HISTORY
890 * 05.01.2004 - implemented
892 * AUTHOR
893 * Michael Mi
894 * Email: michael.mi@sun.com
895 ******************************************************************************/
897 m_bIsPreviousNodeInitializable = false;
898 m_xPreviousNodeOnSAXChain = xParser;
899 m_xNextNodeOnSAXChain = xDocumentHandler;
900 m_xElementStackKeeper = xElementStackKeeper;
902 initializeSAXChain( );
905 void XSecController::clearSAXChainConnector()
906 /****** XSecController/clearSAXChainConnector *********************************
908 * NAME
909 * clearSAXChainConnector -- resets the collaborating components.
911 * SYNOPSIS
912 * clearSAXChainConnector( );
914 * FUNCTION
915 * See NAME.
917 * INPUTS
918 * empty
920 * RESULT
921 * empty
923 * HISTORY
924 * 05.01.2004 - implemented
926 * AUTHOR
927 * Michael Mi
928 * Email: michael.mi@sun.com
929 ******************************************************************************/
932 * before reseting, if the ElementStackKeeper has kept something, then
933 * those kept key SAX events must be transferred to the SAXEventKeeper
934 * first. This is to promise the next node to the SAXEventKeeper on the
935 * SAX chain always receives a complete document.
937 if (m_xElementStackKeeper.is() && m_xSAXEventKeeper.is())
939 cssu::Reference< cssxs::XDocumentHandler > xSEKHandler(m_xSAXEventKeeper, cssu::UNO_QUERY);
940 m_xElementStackKeeper->retrieve(xSEKHandler, sal_True);
943 chainOff();
945 m_xPreviousNodeOnSAXChain = NULL;
946 m_xNextNodeOnSAXChain = NULL;
947 m_xElementStackKeeper = NULL;
950 void XSecController::endMission()
951 /****** XSecController/endMission *********************************************
953 * NAME
954 * endMission -- forces to end all missions
956 * SYNOPSIS
957 * endMission( );
959 * FUNCTION
960 * Deletes all signature information and forces all missions to an end.
962 * INPUTS
963 * empty
965 * RESULT
966 * empty
968 * HISTORY
969 * 05.01.2004 - implemented
971 * AUTHOR
972 * Michael Mi
973 * Email: michael.mi@sun.com
974 ******************************************************************************/
976 sal_Int32 size = m_vInternalSignatureInformations.size();
978 for (int i=0; i<size; ++i)
980 if ( m_nStatusOfSecurityComponents == INITIALIZED )
982 * ResolvedListener only exist when the security components are created.
985 cssu::Reference< cssxc::sax::XMissionTaker > xMissionTaker
986 ( m_vInternalSignatureInformations[i].xReferenceResolvedListener, cssu::UNO_QUERY );
989 * askes the SignatureCreator/SignatureVerifier to release
990 * all resouces it uses.
992 xMissionTaker->endMission();
996 m_xUriBinding = NULL;
997 m_xSecurityContext = NULL;
1000 * free the status change listener reference to this object
1002 if (m_xSAXEventKeeper.is())
1004 cssu::Reference<cssxc::sax::XSAXEventKeeperStatusChangeBroadcaster>
1005 xSAXEventKeeperStatusChangeBroadcaster(m_xSAXEventKeeper, cssu::UNO_QUERY);
1006 xSAXEventKeeperStatusChangeBroadcaster
1007 ->addSAXEventKeeperStatusChangeListener( NULL );
1011 const char* XSecController::getErrorMessage()
1012 /****** XSecController/getErrorMessage ****************************************
1014 * NAME
1015 * getErrorMessage -- get the last error message
1017 * SYNOPSIS
1018 * pErrorMessage = getErrorMessage( );
1020 * FUNCTION
1021 * see NAME.
1023 * INPUTS
1024 * empty
1026 * RESULT
1027 * empty
1029 * HISTORY
1030 * 22.04.2004 - implemented
1032 * AUTHOR
1033 * Michael Mi
1034 * Email: michael.mi@sun.com
1035 ******************************************************************************/
1037 return m_pErrorMessage;
1040 void XSecController::exportSignature(
1041 const cssu::Reference<cssxs::XDocumentHandler>& xDocumentHandler,
1042 const SignatureInformation& signatureInfo )
1043 /****** XSecController/exportSignature ****************************************
1045 * NAME
1046 * exportSignature -- export a signature structure to an XDocumentHandler
1048 * SYNOPSIS
1049 * exportSignature( xDocumentHandler, signatureInfo);
1051 * FUNCTION
1052 * see NAME.
1054 * INPUTS
1055 * xDocumentHandler - the document handler to receive the signature
1056 * signatureInfo - signature to be exported
1058 * RESULT
1059 * empty
1061 * HISTORY
1062 * 26.05.2004 - implemented
1064 * AUTHOR
1065 * Michael Mi
1066 * Email: michael.mi@sun.com
1067 ******************************************************************************/
1070 * defines all element tags in Signature element.
1072 rtl::OUString tag_Signature(RTL_CONSTASCII_USTRINGPARAM(TAG_SIGNATURE));
1073 rtl::OUString tag_SignedInfo(RTL_CONSTASCII_USTRINGPARAM(TAG_SIGNEDINFO));
1074 rtl::OUString tag_CanonicalizationMethod(RTL_CONSTASCII_USTRINGPARAM(TAG_CANONICALIZATIONMETHOD));
1075 rtl::OUString tag_SignatureMethod(RTL_CONSTASCII_USTRINGPARAM(TAG_SIGNATUREMETHOD));
1076 rtl::OUString tag_Reference(RTL_CONSTASCII_USTRINGPARAM(TAG_REFERENCE));
1077 rtl::OUString tag_Transforms(RTL_CONSTASCII_USTRINGPARAM(TAG_TRANSFORMS));
1078 rtl::OUString tag_Transform(RTL_CONSTASCII_USTRINGPARAM(TAG_TRANSFORM));
1079 rtl::OUString tag_DigestMethod(RTL_CONSTASCII_USTRINGPARAM(TAG_DIGESTMETHOD));
1080 rtl::OUString tag_DigestValue(RTL_CONSTASCII_USTRINGPARAM(TAG_DIGESTVALUE));
1081 rtl::OUString tag_SignatureValue(RTL_CONSTASCII_USTRINGPARAM(TAG_SIGNATUREVALUE));
1082 rtl::OUString tag_KeyInfo(RTL_CONSTASCII_USTRINGPARAM(TAG_KEYINFO));
1083 rtl::OUString tag_X509Data(RTL_CONSTASCII_USTRINGPARAM(TAG_X509DATA));
1084 rtl::OUString tag_X509IssuerSerial(RTL_CONSTASCII_USTRINGPARAM(TAG_X509ISSUERSERIAL));
1085 rtl::OUString tag_X509IssuerName(RTL_CONSTASCII_USTRINGPARAM(TAG_X509ISSUERNAME));
1086 rtl::OUString tag_X509SerialNumber(RTL_CONSTASCII_USTRINGPARAM(TAG_X509SERIALNUMBER));
1087 rtl::OUString tag_X509Certificate(RTL_CONSTASCII_USTRINGPARAM(TAG_X509CERTIFICATE));
1089 rtl::OUString tag_Object(RTL_CONSTASCII_USTRINGPARAM(TAG_OBJECT));
1090 rtl::OUString tag_SignatureProperties(RTL_CONSTASCII_USTRINGPARAM(TAG_SIGNATUREPROPERTIES));
1091 rtl::OUString tag_SignatureProperty(RTL_CONSTASCII_USTRINGPARAM(TAG_SIGNATUREPROPERTY));
1092 rtl::OUString tag_Date(RTL_CONSTASCII_USTRINGPARAM(TAG_DATE));
1093 #if 0
1094 rtl::OUString tag_Timestamp(RTL_CONSTASCII_USTRINGPARAM(TAG_TIMESTAMP));
1095 rtl::OUString tag_Date(RTL_CONSTASCII_USTRINGPARAM(TAG_DATE));
1096 rtl::OUString tag_Time(RTL_CONSTASCII_USTRINGPARAM(TAG_TIME));
1097 #endif
1099 const SignatureReferenceInformations& vReferenceInfors = signatureInfo.vSignatureReferenceInfors;
1100 SvXMLAttributeList *pAttributeList;
1103 * Write Signature element
1105 pAttributeList = new SvXMLAttributeList();
1106 pAttributeList->AddAttribute(
1107 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(ATTR_XMLNS)),
1108 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(NS_XMLDSIG)));
1110 if (signatureInfo.ouSignatureId.getLength()>0)
1112 pAttributeList->AddAttribute(
1113 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(ATTR_ID)),
1114 rtl::OUString(signatureInfo.ouSignatureId));
1117 xDocumentHandler->startElement( tag_Signature, cssu::Reference< cssxs::XAttributeList > (pAttributeList));
1119 /* Write SignedInfo element */
1120 xDocumentHandler->startElement(
1121 tag_SignedInfo,
1122 cssu::Reference< cssxs::XAttributeList > (new SvXMLAttributeList()));
1124 /* Write CanonicalizationMethod element */
1125 pAttributeList = new SvXMLAttributeList();
1126 pAttributeList->AddAttribute(
1127 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(ATTR_ALGORITHM)),
1128 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(ALGO_C14N)));
1129 xDocumentHandler->startElement( tag_CanonicalizationMethod, cssu::Reference< cssxs::XAttributeList > (pAttributeList) );
1130 xDocumentHandler->endElement( tag_CanonicalizationMethod );
1132 /* Write SignatureMethod element */
1133 pAttributeList = new SvXMLAttributeList();
1134 pAttributeList->AddAttribute(
1135 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(ATTR_ALGORITHM)),
1136 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(ALGO_RSASHA1)));
1137 xDocumentHandler->startElement( tag_SignatureMethod, cssu::Reference< cssxs::XAttributeList > (pAttributeList) );
1138 xDocumentHandler->endElement( tag_SignatureMethod );
1140 /* Write Reference element */
1141 int j;
1142 int refNum = vReferenceInfors.size();
1144 for(j=0; j<refNum; ++j)
1146 const SignatureReferenceInformation& refInfor = vReferenceInfors[j];
1148 pAttributeList = new SvXMLAttributeList();
1149 if ( refInfor.nType != TYPE_SAMEDOCUMENT_REFERENCE )
1151 * stream reference
1154 pAttributeList->AddAttribute(
1155 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(ATTR_URI)),
1156 refInfor.ouURI);
1158 else
1160 * same-document reference
1163 pAttributeList->AddAttribute(
1164 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(ATTR_URI)),
1165 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(CHAR_FRAGMENT))+refInfor.ouURI);
1168 xDocumentHandler->startElement( tag_Reference, cssu::Reference< cssxs::XAttributeList > (pAttributeList) );
1170 /* Write Transforms element */
1171 if (refInfor.nType == TYPE_XMLSTREAM_REFERENCE)
1173 * xml stream, so c14n transform is needed
1176 xDocumentHandler->startElement(
1177 tag_Transforms,
1178 cssu::Reference< cssxs::XAttributeList > (new SvXMLAttributeList()));
1180 pAttributeList = new SvXMLAttributeList();
1181 pAttributeList->AddAttribute(
1182 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(ATTR_ALGORITHM)),
1183 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(ALGO_C14N)));
1184 xDocumentHandler->startElement(
1185 tag_Transform,
1186 cssu::Reference< cssxs::XAttributeList > (pAttributeList) );
1187 xDocumentHandler->endElement( tag_Transform );
1189 xDocumentHandler->endElement( tag_Transforms );
1192 /* Write DigestMethod element */
1193 pAttributeList = new SvXMLAttributeList();
1194 pAttributeList->AddAttribute(
1195 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(ATTR_ALGORITHM)),
1196 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(ALGO_XMLDSIGSHA1)));
1197 xDocumentHandler->startElement(
1198 tag_DigestMethod,
1199 cssu::Reference< cssxs::XAttributeList > (pAttributeList) );
1200 xDocumentHandler->endElement( tag_DigestMethod );
1202 /* Write DigestValue element */
1203 xDocumentHandler->startElement(
1204 tag_DigestValue,
1205 cssu::Reference< cssxs::XAttributeList > (new SvXMLAttributeList()));
1206 xDocumentHandler->characters( refInfor.ouDigestValue );
1207 xDocumentHandler->endElement( tag_DigestValue );
1209 xDocumentHandler->endElement( tag_Reference );
1212 xDocumentHandler->endElement( tag_SignedInfo );
1214 /* Write SignatureValue element */
1215 xDocumentHandler->startElement(
1216 tag_SignatureValue,
1217 cssu::Reference< cssxs::XAttributeList > (new SvXMLAttributeList()));
1218 xDocumentHandler->characters( signatureInfo.ouSignatureValue );
1219 xDocumentHandler->endElement( tag_SignatureValue );
1221 /* Write KeyInfo element */
1222 xDocumentHandler->startElement(
1223 tag_KeyInfo,
1224 cssu::Reference< cssxs::XAttributeList > (new SvXMLAttributeList()));
1226 /* Write X509Data element */
1227 xDocumentHandler->startElement(
1228 tag_X509Data,
1229 cssu::Reference< cssxs::XAttributeList > (new SvXMLAttributeList()));
1231 /* Write X509IssuerSerial element */
1232 xDocumentHandler->startElement(
1233 tag_X509IssuerSerial,
1234 cssu::Reference< cssxs::XAttributeList > (new SvXMLAttributeList()));
1236 /* Write X509IssuerName element */
1237 xDocumentHandler->startElement(
1238 tag_X509IssuerName,
1239 cssu::Reference< cssxs::XAttributeList > (new SvXMLAttributeList()));
1240 xDocumentHandler->characters( signatureInfo.ouX509IssuerName );
1241 xDocumentHandler->endElement( tag_X509IssuerName );
1243 /* Write X509SerialNumber element */
1244 xDocumentHandler->startElement(
1245 tag_X509SerialNumber,
1246 cssu::Reference< cssxs::XAttributeList > (new SvXMLAttributeList()));
1247 xDocumentHandler->characters( signatureInfo.ouX509SerialNumber );
1248 xDocumentHandler->endElement( tag_X509SerialNumber );
1250 xDocumentHandler->endElement( tag_X509IssuerSerial );
1252 /* Write X509Certificate element */
1253 if (signatureInfo.ouX509Certificate.getLength()>0)
1255 xDocumentHandler->startElement(
1256 tag_X509Certificate,
1257 cssu::Reference< cssxs::XAttributeList > (new SvXMLAttributeList()));
1258 xDocumentHandler->characters( signatureInfo.ouX509Certificate );
1259 xDocumentHandler->endElement( tag_X509Certificate );
1262 xDocumentHandler->endElement( tag_X509Data );
1264 xDocumentHandler->endElement( tag_KeyInfo );
1266 /* Write Object element */
1267 xDocumentHandler->startElement(
1268 tag_Object,
1269 cssu::Reference< cssxs::XAttributeList > (new SvXMLAttributeList()));
1271 /* Write SignatureProperties element */
1272 xDocumentHandler->startElement(
1273 tag_SignatureProperties,
1274 cssu::Reference< cssxs::XAttributeList > (new SvXMLAttributeList()));
1276 /* Write SignatureProperty element */
1277 pAttributeList = new SvXMLAttributeList();
1278 pAttributeList->AddAttribute(
1279 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(ATTR_ID)),
1280 signatureInfo.ouPropertyId);
1281 pAttributeList->AddAttribute(
1282 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(ATTR_TARGET)),
1283 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(CHAR_FRAGMENT))+signatureInfo.ouSignatureId);
1284 xDocumentHandler->startElement(
1285 tag_SignatureProperty,
1286 cssu::Reference< cssxs::XAttributeList > (pAttributeList));
1288 /* Write timestamp element */
1290 pAttributeList = new SvXMLAttributeList();
1291 pAttributeList->AddAttribute(
1292 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(ATTR_XMLNS))
1293 +rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(":"))
1294 +rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(NSTAG_DC)),
1295 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(NS_DC)));
1297 xDocumentHandler->startElement(
1298 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(NSTAG_DC))
1299 +rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(":"))
1300 +tag_Date,
1301 cssu::Reference< cssxs::XAttributeList > (pAttributeList));
1303 ::rtl::OUStringBuffer buffer;
1304 //If the xml signature was already contained in the document,
1305 //then we use the original date and time string, rather then the
1306 //converted one. When the original string is converted to the DateTime
1307 //structure then information may be lost because it only holds a fractional
1308 //of a second with a accuracy of one hundredth of second. If the string contains
1309 //milli seconds (document was signed by an application other than OOo)
1310 //and the converted time is written back, then the string looks different
1311 //and the signature is broken.
1312 if (signatureInfo.ouDateTime.getLength() > 0)
1313 buffer = signatureInfo.ouDateTime;
1314 else
1315 convertDateTime( buffer, signatureInfo.stDateTime );
1316 xDocumentHandler->characters( buffer.makeStringAndClear() );
1318 xDocumentHandler->endElement(
1319 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(NSTAG_DC))
1320 +rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(":"))
1321 +tag_Date);
1323 xDocumentHandler->endElement( tag_SignatureProperty );
1325 xDocumentHandler->endElement( tag_SignatureProperties );
1327 xDocumentHandler->endElement( tag_Object );
1329 xDocumentHandler->endElement( tag_Signature );
1332 SignatureInformation XSecController::getSignatureInformation( sal_Int32 nSecurityId ) const
1334 SignatureInformation aInf( 0 );
1335 int nIndex = findSignatureInfor(nSecurityId);
1336 DBG_ASSERT( nIndex != -1, "getSignatureInformation - SecurityId is invalid!" );
1337 if ( nIndex != -1)
1339 aInf = m_vInternalSignatureInformations[nIndex].signatureInfor;
1341 return aInf;
1344 SignatureInformations XSecController::getSignatureInformations() const
1346 SignatureInformations vInfors;
1347 int sigNum = m_vInternalSignatureInformations.size();
1349 for (int i=0; i<sigNum; ++i)
1351 SignatureInformation si = m_vInternalSignatureInformations[i].signatureInfor;
1352 vInfors.push_back(si);
1355 return vInfors;
1359 * XSecurityController
1361 * no methods
1365 * XFastPropertySet
1368 void SAL_CALL XSecController::setFastPropertyValue(
1369 sal_Int32 nHandle,
1370 const cssu::Any& aValue )
1371 throw ( cssb::UnknownPropertyException,
1372 cssb::PropertyVetoException,
1373 cssl::IllegalArgumentException,
1374 cssl::WrappedTargetException,
1375 cssu::RuntimeException)
1377 sal_Int32 nIndex = getFastPropertyIndex(nHandle);
1378 if (nIndex == -1)
1380 m_vFastPropertyIndexs.push_back( nHandle );
1381 m_vFastPropertyValues.push_back( aValue );
1383 else
1385 m_vFastPropertyValues[nIndex] = aValue;
1389 cssu::Any SAL_CALL XSecController::getFastPropertyValue(
1390 sal_Int32 nHandle )
1391 throw (
1392 cssb::UnknownPropertyException,
1393 cssl::WrappedTargetException,
1394 cssu::RuntimeException)
1396 cssu::Any aValue;
1398 sal_Int32 nIndex = getFastPropertyIndex(nHandle);
1399 if (nIndex != -1)
1401 aValue = m_vFastPropertyValues[nIndex];
1404 return aValue;
1409 * XSAXEventKeeperStatusChangeListener
1412 void SAL_CALL XSecController::blockingStatusChanged( sal_Bool isBlocking )
1413 throw (cssu::RuntimeException)
1416 showMessageBox( rtl::OUString::createFromAscii((isBlocking?
1417 "Blocking Status => TRUE":
1418 "Blocking Status => FALSE")),
1419 rtl::OUString::createFromAscii("SAXEventKeeper Status"));
1422 this->m_bIsBlocking = isBlocking;
1423 checkChainingStatus();
1426 void SAL_CALL XSecController::collectionStatusChanged(
1427 sal_Bool isInsideCollectedElement )
1428 throw (cssu::RuntimeException)
1431 showMessageBox( rtl::OUString::createFromAscii((isInsideCollectedElement?
1432 "Collection Status => TRUE":
1433 "Collection Status => FALSE")),
1434 rtl::OUString::createFromAscii("SAXEventKeeper Status"));
1437 this->m_bIsCollectingElement = isInsideCollectedElement;
1438 checkChainingStatus();
1441 void SAL_CALL XSecController::bufferStatusChanged( sal_Bool /*isBufferEmpty*/)
1442 throw (cssu::RuntimeException)
1445 showMessageBox( rtl::OUString::createFromAscii((isBufferEmpty?
1446 "Buffer Empty => TRUE":
1447 "Buffer Empty => FALSE")),
1448 rtl::OUString::createFromAscii("SAXEventKeeper Status"));
1453 * XSignatureCreationResultListener
1455 void SAL_CALL XSecController::signatureCreated( sal_Int32 securityId, com::sun::star::xml::crypto::SecurityOperationStatus nResult )
1456 throw (com::sun::star::uno::RuntimeException)
1458 int index = findSignatureInfor(securityId);
1459 DBG_ASSERT( index != -1, "Signature Not Found!" );
1461 SignatureInformation& signatureInfor = m_vInternalSignatureInformations[index].signatureInfor;
1464 if (nResult == cssxc::sax::SignatureCreationResult_CREATIONSUCCEED)
1466 signatureInfor.nStatus = STATUS_CREATION_SUCCEED;
1468 else
1470 signatureInfor.nStatus = STATUS_CREATION_FAIL;
1473 signatureInfor.nStatus = nResult;
1477 * XSignatureVerifyResultListener
1479 void SAL_CALL XSecController::signatureVerified( sal_Int32 securityId, com::sun::star::xml::crypto::SecurityOperationStatus nResult )
1480 throw (com::sun::star::uno::RuntimeException)
1482 int index = findSignatureInfor(securityId);
1483 DBG_ASSERT( index != -1, "Signature Not Found!" );
1485 SignatureInformation& signatureInfor = m_vInternalSignatureInformations[index].signatureInfor;
1488 if (nResult == cssxc::sax::SignatureVerifyResult_VERIFYSUCCEED)
1490 signatureInfor.nStatus = STATUS_VERIFY_SUCCEED;
1492 else
1494 signatureInfor.nStatus = STATUS_VERIFY_FAIL;
1497 signatureInfor.nStatus = nResult;