diff options
Diffstat (limited to 'xmlsecurity/tools/demo/performance.cxx')
-rw-r--r-- | xmlsecurity/tools/demo/performance.cxx | 730 |
1 files changed, 365 insertions, 365 deletions
diff --git a/xmlsecurity/tools/demo/performance.cxx b/xmlsecurity/tools/demo/performance.cxx index bcf0d203bfad..374e85428a17 100644 --- a/xmlsecurity/tools/demo/performance.cxx +++ b/xmlsecurity/tools/demo/performance.cxx @@ -2,7 +2,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -151,7 +151,7 @@ class XSecTester; * The XSecTester class is a C++ version of SecurityFramworkController.java * */ - + class SecurityEntity { private: @@ -159,58 +159,58 @@ private: rtl::OUString m_ouKeyURI; protected: - com::sun::star::uno::Reference< + com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > mxMSF; - - com::sun::star::uno::Reference< - com::sun::star::xml::crypto::sax::XReferenceResolvedListener > + + com::sun::star::uno::Reference< + com::sun::star::xml::crypto::sax::XReferenceResolvedListener > m_xReferenceListener; - - com::sun::star::uno::Reference< - com::sun::star::xml::crypto::sax::XSecuritySAXEventKeeper > + + com::sun::star::uno::Reference< + com::sun::star::xml::crypto::sax::XSecuritySAXEventKeeper > m_xSAXEventKeeper; - com::sun::star::uno::Reference< - com::sun::star::xml::crypto::XXMLSecurityContext > + com::sun::star::uno::Reference< + com::sun::star::xml::crypto::XXMLSecurityContext > m_xXMLSecurityContext; - com::sun::star::uno::Reference< - com::sun::star::xml::crypto::XXMLSignature > + com::sun::star::uno::Reference< + com::sun::star::xml::crypto::XXMLSignature > m_xXMLSignature; - + int m_nSecurityId; -private: +private: int getNextSecurityId() const; protected: SecurityEntity( - const com::sun::star::uno::Reference< - com::sun::star::xml::crypto::sax::XSecuritySAXEventKeeper >& + const com::sun::star::uno::Reference< + com::sun::star::xml::crypto::sax::XSecuritySAXEventKeeper >& xSAXEventKeeper, - const com::sun::star::uno::Reference< - com::sun::star::xml::crypto::XXMLSecurityContext >& + const com::sun::star::uno::Reference< + com::sun::star::xml::crypto::XXMLSecurityContext >& xXMLSecurityContext, - const com::sun::star::uno::Reference< - com::sun::star::xml::crypto::XXMLSignature >& + const com::sun::star::uno::Reference< + com::sun::star::xml::crypto::XXMLSignature >& xXMLSignature, - const com::sun::star::uno::Reference< + const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& rsMSF); - + public: void setKeyId(int nId); - + int getSecurityId() const; - - com::sun::star::uno::Reference< - com::sun::star::xml::crypto::sax::XReferenceResolvedListener > + + com::sun::star::uno::Reference< + com::sun::star::xml::crypto::sax::XReferenceResolvedListener > getReferenceListener() const; - + bool setKey( const rtl::OUString& ouUri, bool bIsExporting ); - + void setKeyURI(const rtl::OUString& ouUri); - + bool endMission(); }; @@ -225,12 +225,12 @@ private: public: SignatureEntity( - const com::sun::star::uno::Reference< + const com::sun::star::uno::Reference< com::sun::star::xml::crypto::sax::XSecuritySAXEventKeeper >& xSAXEventKeeper, - bool bIsExporting, + bool bIsExporting, XSecTester* pListener, - const com::sun::star::uno::Reference< + const com::sun::star::uno::Reference< com::sun::star::xml::crypto::XXMLSecurityContext >& xXMLSecurityContext, const com::sun::star::uno::Reference< @@ -240,7 +240,7 @@ public: com::sun::star::lang::XMultiServiceFactory >& rsMSF); ~SignatureEntity(){}; - + void setReferenceNumber() const; bool setReference( const rtl::OUString& ouUri, bool bIsExporting ) const; void addReferenceURI( const rtl::OUString& ouUri ); @@ -249,17 +249,17 @@ public: struct AncestorEvent { AncestorEvent( sal_Int32 nAttrNum ):aAttributeList(nAttrNum){}; - + bool bIsStartElement; rtl::OUString ouName; - - com::sun::star::uno::Sequence< + + com::sun::star::uno::Sequence< com::sun::star::xml::csax::XMLAttribute > aAttributeList; }; - + class XSecTester : public cppu::WeakImplHelper4 -< +< com::sun::star::xml::crypto::sax::XSignatureCreationResultListener, com::sun::star::xml::crypto::sax::XSignatureVerifyResultListener, com::sun::star::xml::crypto::sax::XSAXEventKeeperStatusChangeListener, @@ -268,160 +268,160 @@ class XSecTester : public cppu::WeakImplHelper4 { private: com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > mxMSF; - + sal_Int32 m_nTotalSignatureNumber; sal_Int32 m_nSuccessfulSignatureNumber; com::sun::star::uno::Reference< - com::sun::star::xml::sax::XDocumentHandler > + com::sun::star::xml::sax::XDocumentHandler > m_xExportHandler; - + com::sun::star::uno::Reference< com::sun::star::xml::crypto::sax::XSecuritySAXEventKeeper > m_xSAXEventKeeper; - + com::sun::star::uno::Reference< - com::sun::star::xml::wrapper::XXMLDocumentWrapper > + com::sun::star::xml::wrapper::XXMLDocumentWrapper > m_xXMLDocumentWrapper; - + com::sun::star::uno::Reference< - com::sun::star::xml::sax::XDocumentHandler > + com::sun::star::xml::sax::XDocumentHandler > m_xOutputHandler; - - com::sun::star::uno::Reference< + + com::sun::star::uno::Reference< com::sun::star::xml::sax::XParser > m_xSaxParser; std::stack< void* > m_stCurrentPath; std::stack< bool > m_stCurrentPathType; - + std::vector< AncestorEvent* > m_vAncestorEvents; std::vector< SignatureEntity* > m_vSignatureList; - + std::vector< rtl::OUString > m_vUnsolvedReferenceURIs; std::vector< int > m_vUnsolvedReferenceKeeperIds; std::vector< int > m_vUnsolvedReferenceRefNums; - + bool m_bIsExporting; bool m_bIsBlocking; - + bool m_bIsInsideCollectedElement; bool m_bIsSAXEventKeeperOnTheSAXChain; - + com::sun::star::uno::Reference< - com::sun::star::xml::crypto::XXMLSecurityContext > + com::sun::star::xml::crypto::XXMLSecurityContext > m_xXMLSecurityContext; - + com::sun::star::uno::Reference< - com::sun::star::xml::crypto::XXMLSignature > + com::sun::star::xml::crypto::XXMLSignature > m_xXMLSignature; - + rtl::OUString m_ouJavaCryptokenDir; rtl::OUString m_ouCCryptokenDir; rtl::OUString m_ouXMLDocumentWrapperComponentName; - + private: - com::sun::star::uno::Reference< - com::sun::star::io::XOutputStream > + com::sun::star::uno::Reference< + com::sun::star::io::XOutputStream > createOutputStream( const rtl::OUString& ouFile ); - + rtl::OUString parseFile( - const rtl::OUString& ouInputFileName, - const rtl::OUString& ouOutputFileName, + const rtl::OUString& ouInputFileName, + const rtl::OUString& ouOutputFileName, bool bIsExporting, bool bIsJavaBased); - + void changeOutput(); - + bool foundSecurityRelated(); - + void findKeyOrReference(SecurityEntity* pSecurityEntity, const rtl::OUString& ouUri, bool bIsFindKey); - + bool checkSecurityElement( const rtl::OUString& ouLocalName, const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttribs); - + void checkReference( const rtl::OUString& ouLocalName, const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttribs, const rtl::OUString& ouId); - + void endMission(); - + void addStartAncestorEvent( const rtl::OUString& ouName, const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttribs); - + void addEndAncestorEvent( const rtl::OUString& ouName ); - + void flushAncestorEvents( const com::sun::star::uno::Reference< com::sun::star::xml::sax::XDocumentHandler >& xDocumentHandler); - + void XSecTester::sendAncestorStartElementEvent( - const rtl::OUString& ouName, + const rtl::OUString& ouName, const com::sun::star::uno::Sequence< com::sun::star::xml::csax::XMLAttribute >& xAttrList, const com::sun::star::uno::Reference< com::sun::star::xml::sax::XDocumentHandler >& xDocumentHandler) const; - + void XSecTester::sendAncestorEndElementEvent( const rtl::OUString& ouName, const com::sun::star::uno::Reference< com::sun::star::xml::sax::XDocumentHandler >& xDocumentHandler) const; - - std::vector< AncestorEvent* >::const_iterator XSecTester::checkAncestorStartElementEvent( + + std::vector< AncestorEvent* >::const_iterator XSecTester::checkAncestorStartElementEvent( const std::vector< AncestorEvent* >::const_iterator& ii, const com::sun::star::uno::Reference< com::sun::star::xml::sax::XDocumentHandler >& xDocumentHandler) const; - + public: XSecTester(const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& rxMSF) :mxMSF( rxMSF ){}; virtual ~XSecTester(){}; - + /* XSignatureCreationResultListener */ - virtual void SAL_CALL signatureCreated( - sal_Int32 securityId, + virtual void SAL_CALL signatureCreated( + sal_Int32 securityId, com::sun::star::xml::crypto::SecurityOperationStatus creationResult ) throw (com::sun::star::uno::RuntimeException); /* XSignatureVerifyResultListener */ - virtual void SAL_CALL signatureVerified( - sal_Int32 securityId, + virtual void SAL_CALL signatureVerified( + sal_Int32 securityId, com::sun::star::xml::crypto::SecurityOperationStatus verifyResult ) throw (com::sun::star::uno::RuntimeException); - + /* XSAXEventKeeperStatusChangeListener */ virtual void SAL_CALL blockingStatusChanged( sal_Bool isBlocking ) throw (com::sun::star::uno::RuntimeException); - virtual void SAL_CALL collectionStatusChanged( + virtual void SAL_CALL collectionStatusChanged( sal_Bool isInsideCollectedElement ) throw (com::sun::star::uno::RuntimeException); virtual void SAL_CALL bufferStatusChanged( sal_Bool isBufferEmpty ) throw (com::sun::star::uno::RuntimeException); - + /* XXMLSecTester */ - virtual rtl::OUString SAL_CALL transfer_without_sec( - const rtl::OUString& inputFileName, + virtual rtl::OUString SAL_CALL transfer_without_sec( + const rtl::OUString& inputFileName, const rtl::OUString& outputFileName, sal_Bool isBridgeInvolved) throw (com::sun::star::uno::RuntimeException); virtual rtl::OUString SAL_CALL export_xml( - const rtl::OUString& inputFileName, + const rtl::OUString& inputFileName, const rtl::OUString& outputFileName, sal_Bool isJavaBased) throw (com::sun::star::uno::RuntimeException); virtual rtl::OUString SAL_CALL import_xml( - const rtl::OUString& inputFileName, + const rtl::OUString& inputFileName, const rtl::OUString& outputFileName, sal_Bool isJavaBased) throw (com::sun::star::uno::RuntimeException); - + virtual void SAL_CALL setCryptoDir( const rtl::OUString & javaDirName, const rtl::OUString & cDirName) @@ -439,7 +439,7 @@ public: virtual void SAL_CALL ignorableWhitespace(const rtl::OUString&) throw (com::sun::star::uno::RuntimeException); virtual void SAL_CALL startElement( - const rtl::OUString&, + const rtl::OUString&, const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList >&) throw (com::sun::star::uno::RuntimeException); virtual void SAL_CALL endElement(const rtl::OUString&) @@ -450,23 +450,23 @@ public: }; rtl::OUString XSecTester::parseFile( - const rtl::OUString& ouInputFileName, - const rtl::OUString& ouOutputFileName, + const rtl::OUString& ouInputFileName, + const rtl::OUString& ouOutputFileName, bool bIsExporting, bool bIsJavaBased) { rtl::OUString ouMessage; - + cssu::Reference<cssi::XInputStream> xInputStream = OpenInputStream(ouInputFileName); - - if (xInputStream != NULL ) + + if (xInputStream != NULL ) { /* initialization */ rtl::OUString SEInitializer_comp; rtl::OUString XMLSignature_comp; rtl::OUString tokenPath; cssu::Reference < cssxc::XSEInitializer > xSEInitializer; - + if (bIsJavaBased) { SEInitializer_comp = rtl::OUString::createFromAscii( SEINITIALIZER_JAVA_COMPONENT ); @@ -481,51 +481,51 @@ rtl::OUString XSecTester::parseFile( m_ouXMLDocumentWrapperComponentName = rtl::OUString::createFromAscii( XMLDOCUMENT_C_COMPONENT ); tokenPath = m_ouCCryptokenDir; } - + xSEInitializer = cssu::Reference < cssxc::XSEInitializer > ( mxMSF->createInstance( SEInitializer_comp ), - cssu::UNO_QUERY ); - + cssu::UNO_QUERY ); + m_xXMLSignature = cssu::Reference<cssxc::XXMLSignature> ( mxMSF->createInstance( XMLSignature_comp ), cssu::UNO_QUERY ); - + if ( xSEInitializer.is() && m_xXMLSignature.is()) { /* create SAX Parser */ - const rtl::OUString sSaxParser ( + const rtl::OUString sSaxParser ( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.xml.sax.Parser") ); m_xSaxParser = cssu::Reference < cssxs::XParser > ( mxMSF->createInstance( sSaxParser ), cssu::UNO_QUERY ); - + /* create SAX Writer */ - const rtl::OUString sSaxWriter ( + const rtl::OUString sSaxWriter ( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.xml.sax.Writer") ); cssu::Reference < cssi::XActiveDataSource > xSaxWriter ( mxMSF->createInstance( sSaxWriter ), cssu::UNO_QUERY ); - + cssu::Reference< cssi::XOutputStream > xOutputStream = OpenOutputStream(ouOutputFileName); xSaxWriter->setOutputStream( xOutputStream ); - + cssxs::InputSource aInput; aInput.sSystemId = ouInputFileName; aInput.aInputStream = xInputStream; - + cssu::Reference < cssxs::XDocumentHandler > xSaxWriterHandler( xSaxWriter, cssu::UNO_QUERY); - - m_xXMLSecurityContext = + + m_xXMLSecurityContext = xSEInitializer->createSecurityContext(tokenPath); - + m_bIsExporting = bIsExporting; m_xExportHandler = xSaxWriterHandler; m_xOutputHandler = xSaxWriterHandler; - + m_xXMLDocumentWrapper = NULL; m_xSAXEventKeeper = NULL; m_bIsSAXEventKeeperOnTheSAXChain = false; - + m_bIsBlocking = false; m_bIsInsideCollectedElement = false; - + OSL_ASSERT(m_vSignatureList.size() == 0); OSL_ASSERT(m_vUnsolvedReferenceURIs.size() == 0); OSL_ASSERT(m_vUnsolvedReferenceKeeperIds.size() == 0); @@ -533,51 +533,51 @@ rtl::OUString XSecTester::parseFile( OSL_ASSERT(m_stCurrentPath.empty()); OSL_ASSERT(m_stCurrentPathType.empty()); OSL_ASSERT(m_vAncestorEvents.empty()); - + changeOutput(); - + /* foundSecurityRelated(); */ - + /* Begin to parse */ TimeValue startTime, endTime; osl_getSystemTime( &startTime ); - + xSaxWriterHandler->startDocument(); - - if (m_bIsExporting) + + if (m_bIsExporting) { m_xSaxParser->setDocumentHandler(this); m_xSaxParser->parseStream(aInput); } - else + else { m_xSaxParser->setDocumentHandler(this); m_xSaxParser->parseStream(aInput); } - + endMission(); xSaxWriterHandler->endDocument(); - + osl_getSystemTime( &endTime ); - + flushAncestorEvents( NULL ); - + // Bug in SAXWriter, done in endDocument() // xOutputStream->closeOutput(); xInputStream->closeInput(); - - + + /* * Free the security context */ xSEInitializer->freeSecurityContext(m_xXMLSecurityContext); m_xXMLSecurityContext = NULL; - + /* Calculate the time */ double diff = ((double)((endTime.Nanosec + endTime.Seconds*1000000000.0) - - (startTime.Nanosec + startTime.Seconds*1000000000.0))) / + - (startTime.Nanosec + startTime.Seconds*1000000000.0))) / ((double)1000000000.0); - + char buf[32]; sprintf(buf, "%.2f", diff); ouMessage += rtl::OUString(RTL_ASCII_USTRINGPARAM(buf)); @@ -586,24 +586,24 @@ rtl::OUString XSecTester::parseFile( { ouMessage += rtl::OUString::createFromAscii( "N/A" ); } - + } else { ouMessage += rtl::OUString::createFromAscii( "-" ); } - + return ouMessage; } /* XSignatureCreationResultListener */ void SAL_CALL XSecTester::signatureCreated( - sal_Int32 securityId, + sal_Int32 securityId, cssxc::SecurityOperationStatus creationResult ) throw (cssu::RuntimeException) { m_nTotalSignatureNumber++; - if (creationResult == cssxc::SecurityOperationStatus_OPERATION_SUCCEEDED) + if (creationResult == cssxc::SecurityOperationStatus_OPERATION_SUCCEEDED) { m_nSuccessfulSignatureNumber++; } @@ -611,29 +611,29 @@ void SAL_CALL XSecTester::signatureCreated( /* XSignatureVerifyResultListener */ void SAL_CALL XSecTester::signatureVerified( - sal_Int32 securityId, + sal_Int32 securityId, cssxc::SecurityOperationStatus verifyResult ) throw (cssu::RuntimeException) { m_nTotalSignatureNumber++; - if (verifyResult == cssxc::SecurityOperationStatus_OPERATION_SUCCEEDED) + if (verifyResult == cssxc::SecurityOperationStatus_OPERATION_SUCCEEDED) { m_nSuccessfulSignatureNumber++; } } - + /* XSAXEventKeeperStatusChangeListener */ void SAL_CALL XSecTester::blockingStatusChanged( sal_Bool isBlocking ) throw (cssu::RuntimeException) { this->m_bIsBlocking = isBlocking; } - + void SAL_CALL XSecTester::collectionStatusChanged( sal_Bool isInsideCollectedElement ) throw (cssu::RuntimeException) { this->m_bIsInsideCollectedElement = isInsideCollectedElement; - + if ( !m_bIsInsideCollectedElement && !m_bIsBlocking) { m_bIsSAXEventKeeperOnTheSAXChain = false; @@ -644,14 +644,14 @@ void SAL_CALL XSecTester::collectionStatusChanged( sal_Bool isInsideCollectedEle } changeOutput(); } - + void SAL_CALL XSecTester::bufferStatusChanged( sal_Bool isBufferEmpty ) throw (cssu::RuntimeException) { if (isBufferEmpty) { m_xXMLDocumentWrapper = NULL; - + m_xSAXEventKeeper = NULL; m_bIsSAXEventKeeperOnTheSAXChain = false; changeOutput(); @@ -663,12 +663,12 @@ rtl::OUString SAL_CALL XSecTester::export_xml( const rtl::OUString& inputFileNam throw (cssu::RuntimeException) { rtl::OUString ouMessage; - + m_nTotalSignatureNumber = 0; m_nSuccessfulSignatureNumber = 0; - + ouMessage += parseFile(inputFileName, outputFileName, sal_True, isJavaBased); - + rtl::OUString ouRemark = rtl::OUString::valueOf(m_nSuccessfulSignatureNumber) + rtl::OUString(RTL_ASCII_USTRINGPARAM( "/" )) + rtl::OUString::valueOf(m_nTotalSignatureNumber); @@ -676,7 +676,7 @@ rtl::OUString SAL_CALL XSecTester::export_xml( const rtl::OUString& inputFileNam return ouMessage; } - + rtl::OUString SAL_CALL XSecTester::import_xml( const rtl::OUString& inputFileName, const rtl::OUString& outputFileName, sal_Bool isJavaBased) throw (cssu::RuntimeException) { @@ -695,31 +695,31 @@ rtl::OUString SAL_CALL XSecTester::import_xml( const rtl::OUString& inputFileNam return ouMessage; } -rtl::OUString SAL_CALL XSecTester::transfer_without_sec( - const rtl::OUString& inputFileName, +rtl::OUString SAL_CALL XSecTester::transfer_without_sec( + const rtl::OUString& inputFileName, const rtl::OUString& outputFileName, sal_Bool isBridgeInvolved) throw (cssu::RuntimeException) { rtl::OUString ouMessage; - + cssu::Reference< cssi::XInputStream > xInputStream = OpenInputStream(inputFileName); - - if (xInputStream != NULL ) + + if (xInputStream != NULL ) { /* create SAX Parser */ - const rtl::OUString sSaxParser ( + const rtl::OUString sSaxParser ( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.xml.sax.Parser") ); m_xSaxParser = cssu::Reference < cssxs::XParser > ( mxMSF->createInstance( sSaxParser ), cssu::UNO_QUERY ); /* create SAX Writer */ - const rtl::OUString sSaxWriter ( + const rtl::OUString sSaxWriter ( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.xml.sax.Writer") ); cssu::Reference < cssi::XActiveDataSource > xSaxWriter ( mxMSF->createInstance( sSaxWriter ), cssu::UNO_QUERY ); - cssu::Reference < cssxs::XDocumentHandler > xSaxWriterHandler( + cssu::Reference < cssxs::XDocumentHandler > xSaxWriterHandler( xSaxWriter, cssu::UNO_QUERY); - + if (!isBridgeInvolved) { /* connect the SAX Parser and the SAX Writer */ @@ -728,7 +728,7 @@ rtl::OUString SAL_CALL XSecTester::transfer_without_sec( else { /* create Java Flat Filter */ - const rtl::OUString sJavaFlatFilter( + const rtl::OUString sJavaFlatFilter( RTL_CONSTASCII_USTRINGPARAM( JAVAFLATFILTER_COMPONENT ) ); cssu::Reference < cssxs::XParser > xJavaFilterParser ( mxMSF->createInstance( sJavaFlatFilter ), cssu::UNO_QUERY ); @@ -742,7 +742,7 @@ rtl::OUString SAL_CALL XSecTester::transfer_without_sec( xJavaFilterParser->setDocumentHandler( xSaxWriterHandler ); m_xSaxParser->setDocumentHandler ( xJavaFilterHandler ); } - + /* set output stream */ cssu::Reference< cssi::XOutputStream > xOutputStream = @@ -753,17 +753,17 @@ rtl::OUString SAL_CALL XSecTester::transfer_without_sec( cssxs::InputSource aInput; aInput.sSystemId = inputFileName; aInput.aInputStream = xInputStream; - + TimeValue startTime, endTime; osl_getSystemTime( &startTime ); m_xSaxParser->parseStream ( aInput ); - + // xOutputStream->closeOutput(); xInputStream->closeInput(); - + osl_getSystemTime( &endTime ); - + double diff = ((double)((endTime.Nanosec + endTime.Seconds*1000000000.0) - (startTime.Nanosec + startTime.Seconds*1000000000.0)))/((double)1000000000.0); char buf[32]; @@ -782,7 +782,7 @@ void SAL_CALL XSecTester::setCryptoDir(const rtl::OUString & javaDirName, const } -cssu::Reference< cssu::XInterface > SAL_CALL XSecTester_createInstance( +cssu::Reference< cssu::XInterface > SAL_CALL XSecTester_createInstance( const cssu::Reference< cssl::XMultiServiceFactory > & rSMgr) throw( cssu::Exception ) { @@ -804,7 +804,7 @@ SecurityEntity::SecurityEntity( { m_nSecurityId = getNextSecurityId(); } - + int SecurityEntity::getNextSecurityId() const { int nId = m_nNextSecurityId++; @@ -836,16 +836,16 @@ int SecurityEntity::getSecurityId() const bool SecurityEntity::setKey(const rtl::OUString& ouUri, bool bIsExporting) { bool rc = false; - + if (m_ouKeyURI != rtl::OUString(RTL_ASCII_USTRINGPARAM("")) && m_ouKeyURI == ouUri) { int nKeeperId = m_xSAXEventKeeper->addSecurityElementCollector( bIsExporting ? (cssxc::sax::ElementMarkPriority_BEFOREMODIFY): - (cssxc::sax::ElementMarkPriority_AFTERMODIFY), + (cssxc::sax::ElementMarkPriority_AFTERMODIFY), true); - + setKeyId(nKeeperId); m_xSAXEventKeeper->setSecurityId(nKeeperId, m_nSecurityId); @@ -853,24 +853,24 @@ bool SecurityEntity::setKey(const rtl::OUString& ouUri, bool bIsExporting) (m_xSAXEventKeeper, cssu::UNO_QUERY); xReferenceResolvedBroadcaster->addReferenceResolvedListener(nKeeperId, m_xReferenceListener); - + rc = true; } - + return rc; } bool SecurityEntity::endMission() { - cssu::Reference<cssxc::sax::XMissionTaker> xMissionTaker + cssu::Reference<cssxc::sax::XMissionTaker> xMissionTaker (m_xReferenceListener, cssu::UNO_QUERY); - + return xMissionTaker->endMission(); } SignatureEntity::SignatureEntity( const cssu::Reference<cssxc::sax::XSecuritySAXEventKeeper>& xSAXEventKeeper, - bool bIsExporting, + bool bIsExporting, XSecTester* pListener, const cssu::Reference<cssxc::XXMLSecurityContext>& xXMLSecurityContext, const cssu::Reference<cssxc::XXMLSignature>& xXMLSignature, @@ -880,9 +880,9 @@ SignatureEntity::SignatureEntity( xXMLSignature, rsMSF) { - if (bIsExporting) + if (bIsExporting) { - m_nSignatureElementCollectorId = + m_nSignatureElementCollectorId = m_xSAXEventKeeper->addSecurityElementCollector( cssxc::sax::ElementMarkPriority_AFTERMODIFY, true); @@ -894,59 +894,59 @@ SignatureEntity::SignatureEntity( cssu::UNO_QUERY); cssu::Reference<cssl::XInitialization> xInitialization(m_xReferenceListener, cssu::UNO_QUERY); - + cssu::Sequence<cssu::Any> args(5); char buf[16]; - + sprintf(buf, "%d", m_nSecurityId); args[0] = cssu::makeAny(rtl::OUString(RTL_ASCII_USTRINGPARAM(buf))); args[1] = cssu::makeAny(m_xSAXEventKeeper); - + sprintf(buf, "%d", m_nSignatureElementCollectorId); args[2] = cssu::makeAny(rtl::OUString(RTL_ASCII_USTRINGPARAM(buf))); args[3] = cssu::makeAny(m_xXMLSecurityContext->getSecurityEnvironment()); args[4] = cssu::makeAny(m_xXMLSignature); - + xInitialization->initialize(args); - + int nBlockerId = m_xSAXEventKeeper->addBlocker(); m_xSAXEventKeeper->setSecurityId(nBlockerId, m_nSecurityId); - + cssu::Reference<cssxc::sax::XBlockerMonitor> xBlockerMonitor(m_xReferenceListener, cssu::UNO_QUERY); xBlockerMonitor->setBlockerId(nBlockerId); - + cssu::Reference< cssxc::sax::XSignatureCreationResultBroadcaster > xSignatureCreationResultBroadcaster (m_xReferenceListener, cssu::UNO_QUERY); xSignatureCreationResultBroadcaster->addSignatureCreationResultListener(pListener); } - else + else { - m_nSignatureElementCollectorId = + m_nSignatureElementCollectorId = m_xSAXEventKeeper->addSecurityElementCollector( cssxc::sax::ElementMarkPriority_BEFOREMODIFY, false); - + m_xSAXEventKeeper->setSecurityId(m_nSignatureElementCollectorId, m_nSecurityId); m_xReferenceListener = cssu::Reference< cssxc::sax::XReferenceResolvedListener >( mxMSF->createInstance( rtl::OUString::createFromAscii( SIGNATUREVERIFIER_COMPONENT )), - cssu::UNO_QUERY); - + cssu::UNO_QUERY); + cssu::Reference<cssl::XInitialization> xInitialization(m_xReferenceListener, cssu::UNO_QUERY); - + cssu::Sequence<cssu::Any> args(5); char buf[16]; - + sprintf(buf, "%d", m_nSecurityId); args[0] = cssu::makeAny(rtl::OUString(RTL_ASCII_USTRINGPARAM(buf))); args[1] = cssu::makeAny(m_xSAXEventKeeper); - + sprintf(buf, "%d", m_nSignatureElementCollectorId); args[2] = cssu::makeAny(rtl::OUString(RTL_ASCII_USTRINGPARAM(buf))); args[3] = cssu::makeAny(m_xXMLSecurityContext); args[4] = cssu::makeAny(m_xXMLSignature); xInitialization->initialize(args); - + cssu::Reference< cssxc::sax::XSignatureVerifyResultBroadcaster > xSignatureVerifyResultBroadcaster (m_xReferenceListener, cssu::UNO_QUERY); xSignatureVerifyResultBroadcaster->addSignatureVerifyResultListener(pListener); @@ -962,56 +962,56 @@ void SignatureEntity::addReferenceURI(const rtl::OUString& ouUri) { m_vReferenceIds.push_back(ouUri); } - + void SignatureEntity::setReferenceNumber() const { cssu::Reference<cssxc::sax::XReferenceCollector> xReferenceCollector (m_xReferenceListener, cssu::UNO_QUERY); xReferenceCollector->setReferenceCount(m_vReferenceIds.size()); } - + bool SignatureEntity::hasReference(const rtl::OUString& ouUri) const { bool rc = false; - + std::vector<const rtl::OUString>::const_iterator ii; - for (ii = m_vReferenceIds.begin(); ii != m_vReferenceIds.end(); ++ii) + for (ii = m_vReferenceIds.begin(); ii != m_vReferenceIds.end(); ++ii) { - if (ouUri == *ii) + if (ouUri == *ii) { rc = true; break; } } - + return rc; } - + bool SignatureEntity::setReference(const rtl::OUString& ouUri, bool bIsExporting) const { bool rc = false; - - if (hasReference(ouUri)) + + if (hasReference(ouUri)) { int nKeeperId = m_xSAXEventKeeper->addSecurityElementCollector( bIsExporting ? (cssxc::sax::ElementMarkPriority_AFTERMODIFY): (cssxc::sax::ElementMarkPriority_BEFOREMODIFY), false); - + m_xSAXEventKeeper->setSecurityId(nKeeperId, m_nSecurityId); - cssu::Reference<cssxc::sax::XReferenceResolvedBroadcaster> xReferenceResolvedBroadcaster + cssu::Reference<cssxc::sax::XReferenceResolvedBroadcaster> xReferenceResolvedBroadcaster (m_xSAXEventKeeper, cssu::UNO_QUERY); xReferenceResolvedBroadcaster->addReferenceResolvedListener(nKeeperId, m_xReferenceListener); - + cssu::Reference<cssxc::sax::XReferenceCollector> xReferenceCollector (m_xReferenceListener, cssu::UNO_QUERY); xReferenceCollector->setReferenceId(nKeeperId); - + rc = true; } - + return rc; } @@ -1049,45 +1049,45 @@ void SAL_CALL XSecTester::startElement(const rtl::OUString & name, const cssu::R { rtl::OUString ouIdAttr = xAttribs->getValueByName( rtl::OUString(RTL_ASCII_USTRINGPARAM("id"))); - - if (ouIdAttr == NULL) + + if (ouIdAttr == NULL) { ouIdAttr = xAttribs->getValueByName( rtl::OUString(RTL_ASCII_USTRINGPARAM("Id"))); } - + bool bHasIdAttr = (ouIdAttr != NULL && ouIdAttr.getLength() > 0 ); bool needResend = false; - - if (bHasIdAttr || name.equalsAscii( SIGNATURE_STR )) + + if (bHasIdAttr || name.equalsAscii( SIGNATURE_STR )) { - if (foundSecurityRelated() && ! m_bIsExporting) + if (foundSecurityRelated() && ! m_bIsExporting) { needResend = true; } } - + if ( !m_bIsSAXEventKeeperOnTheSAXChain ) { addStartAncestorEvent(name, xAttribs); } - + bool bSuppressingForwarding = checkSecurityElement(name, xAttribs); - + checkReference(name, xAttribs, ouIdAttr); - - if (needResend) + + if (needResend) { m_xSAXEventKeeper->setNextHandler(NULL); - - cssu::Reference<cssxs::XDocumentHandler> xSAXEventKeeperHandler + + cssu::Reference<cssxs::XDocumentHandler> xSAXEventKeeperHandler (m_xSAXEventKeeper, cssu::UNO_QUERY); - + xSAXEventKeeperHandler->startElement(name, xAttribs); m_xSAXEventKeeper->setNextHandler(this); } - - if (!bSuppressingForwarding) + + if (!bSuppressingForwarding) { m_xExportHandler->startElement(name, xAttribs); } @@ -1096,21 +1096,21 @@ void SAL_CALL XSecTester::startElement(const rtl::OUString & name, const cssu::R void SAL_CALL XSecTester::endElement(const rtl::OUString& name) throw (cssu::RuntimeException) { - if (!m_stCurrentPath.empty()) + if (!m_stCurrentPath.empty()) { void* pSignedInfo = m_stCurrentPath.top(); bool bIsStringType = m_stCurrentPathType.top(); - + m_stCurrentPath.pop(); m_stCurrentPathType.pop(); - + if (bIsStringType && !strcmp((const char *)pSignedInfo, SIGNEDINFO_STR)) { - if (!m_stCurrentPath.empty()) + if (!m_stCurrentPath.empty()) { void* pSignature = m_stCurrentPath.top(); bIsStringType = m_stCurrentPathType.top(); - + if (!bIsStringType && pSignature != NULL) { ((SignatureEntity *) pSignature)->setReferenceNumber(); @@ -1118,12 +1118,12 @@ void SAL_CALL XSecTester::endElement(const rtl::OUString& name) } } } - + if ( !m_bIsSAXEventKeeperOnTheSAXChain ) { addEndAncestorEvent(name); } - + m_xExportHandler->endElement(name); } @@ -1134,39 +1134,39 @@ void SAL_CALL XSecTester::setDocumentLocator( const cssu::Reference<cssxs::XLoca void XSecTester::changeOutput() { - if (m_bIsExporting) + if (m_bIsExporting) { - if (m_bIsSAXEventKeeperOnTheSAXChain) + if (m_bIsSAXEventKeeperOnTheSAXChain) { m_xExportHandler = cssu::Reference<cssxs::XDocumentHandler> (m_xSAXEventKeeper, cssu::UNO_QUERY); - + m_xSAXEventKeeper->setNextHandler(NULL); - + flushAncestorEvents(m_xExportHandler); m_xSAXEventKeeper->setNextHandler(m_xOutputHandler); } - else + else { m_xExportHandler = m_xOutputHandler; } } - else + else { - if (m_bIsSAXEventKeeperOnTheSAXChain) + if (m_bIsSAXEventKeeperOnTheSAXChain) { cssu::Reference<cssxs::XDocumentHandler> xSAXEventKeeperHandler (m_xSAXEventKeeper, cssu::UNO_QUERY); - + m_xSAXEventKeeper->setNextHandler(NULL); - + flushAncestorEvents(xSAXEventKeeperHandler); m_xSaxParser->setDocumentHandler(xSAXEventKeeperHandler); m_xSAXEventKeeper->setNextHandler(this); } - else + else { m_xSaxParser->setDocumentHandler(this); } @@ -1176,7 +1176,7 @@ void XSecTester::changeOutput() bool XSecTester::foundSecurityRelated() { - if (m_xSAXEventKeeper == NULL) + if (m_xSAXEventKeeper == NULL) { m_bIsBlocking = false; m_bIsInsideCollectedElement = false; @@ -1194,19 +1194,19 @@ bool XSecTester::foundSecurityRelated() cssu::Sequence <cssu::Any> arg(1); arg[0] = cssu::makeAny(m_xXMLDocumentWrapper); xInitialization->initialize(arg); - + cssu::Reference<cssxc::sax::XSAXEventKeeperStatusChangeBroadcaster> - xSAXEventKeeperStatusChangeBroadcaster(m_xSAXEventKeeper, cssu::UNO_QUERY); + xSAXEventKeeperStatusChangeBroadcaster(m_xSAXEventKeeper, cssu::UNO_QUERY); xSAXEventKeeperStatusChangeBroadcaster->addSAXEventKeeperStatusChangeListener(this); } - + bool rc = false; - - if (!m_bIsSAXEventKeeperOnTheSAXChain) + + if (!m_bIsSAXEventKeeperOnTheSAXChain) { rc = true; } - + m_bIsSAXEventKeeperOnTheSAXChain=true; changeOutput(); @@ -1222,15 +1222,15 @@ void XSecTester::findKeyOrReference(SecurityEntity* pSecurityEntity, const rtl:: for (ii_referenceURIs = m_vUnsolvedReferenceURIs.begin(), ii_referenceKeeperIds = m_vUnsolvedReferenceKeeperIds.begin(), ii_referenceRefNums = m_vUnsolvedReferenceRefNums.begin(); - ii_referenceURIs != m_vUnsolvedReferenceURIs.end(); ) + ii_referenceURIs != m_vUnsolvedReferenceURIs.end(); ) { rtl::OUString ouReferenceUri = *ii_referenceURIs; - - if (ouReferenceUri == ouUri) + + if (ouReferenceUri == ouUri) { int nKeeperId = *ii_referenceKeeperIds; int nRefNum = *ii_referenceRefNums; - + if ( bIsFindingKey ) { int nClonedKeeperId = m_xSAXEventKeeper->cloneElementCollector( @@ -1238,11 +1238,11 @@ void XSecTester::findKeyOrReference(SecurityEntity* pSecurityEntity, const rtl:: m_bIsExporting? (cssxc::sax::ElementMarkPriority_BEFOREMODIFY): (cssxc::sax::ElementMarkPriority_AFTERMODIFY)); - + pSecurityEntity->setKeyId(nClonedKeeperId); - + m_xSAXEventKeeper->setSecurityId(nClonedKeeperId, pSecurityEntity->getSecurityId()); - + cssu::Reference<cssxc::sax::XReferenceResolvedBroadcaster> xReferenceResolvedBroadcaster(m_xSAXEventKeeper, cssu::UNO_QUERY); xReferenceResolvedBroadcaster->addReferenceResolvedListener( @@ -1252,35 +1252,35 @@ void XSecTester::findKeyOrReference(SecurityEntity* pSecurityEntity, const rtl:: else { int nClonedKeeperId = m_xSAXEventKeeper->cloneElementCollector( - nKeeperId, + nKeeperId, m_bIsExporting? (cssxc::sax::ElementMarkPriority_AFTERMODIFY): (cssxc::sax::ElementMarkPriority_BEFOREMODIFY)); - + m_xSAXEventKeeper->setSecurityId(nClonedKeeperId, pSecurityEntity->getSecurityId()); - + cssu::Reference<cssxc::sax::XReferenceResolvedBroadcaster> - xReferenceResolvedBroadcaster + xReferenceResolvedBroadcaster (m_xSAXEventKeeper, cssu::UNO_QUERY); xReferenceResolvedBroadcaster->addReferenceResolvedListener( nClonedKeeperId, pSecurityEntity->getReferenceListener()); - - cssu::Reference<cssxc::sax::XReferenceCollector> xReferenceCollector + + cssu::Reference<cssxc::sax::XReferenceCollector> xReferenceCollector (pSecurityEntity->getReferenceListener(), cssu::UNO_QUERY); xReferenceCollector->setReferenceId(nClonedKeeperId); } nRefNum--; - if (nRefNum == 0) + if (nRefNum == 0) { m_xSAXEventKeeper->removeElementCollector(nKeeperId); - + ii_referenceURIs = m_vUnsolvedReferenceURIs.erase(ii_referenceURIs); ii_referenceKeeperIds = m_vUnsolvedReferenceKeeperIds.erase(ii_referenceKeeperIds); ii_referenceRefNums = m_vUnsolvedReferenceRefNums.erase(ii_referenceRefNums); } - else + else { (*ii_referenceRefNums) = nRefNum; @@ -1288,13 +1288,13 @@ void XSecTester::findKeyOrReference(SecurityEntity* pSecurityEntity, const rtl:: ii_referenceKeeperIds++; ii_referenceRefNums++; } - + if (bIsFindingKey) { break; } } - else + else { ii_referenceURIs++; ii_referenceKeeperIds++; @@ -1308,7 +1308,7 @@ bool XSecTester::checkSecurityElement( const cssu::Reference<cssxs::XAttributeList>& xAttribs) { bool rc = false; - + if (ouLocalName.equalsAscii(SIGNATURE_STR)) { SignatureEntity* pSignatureEntity = new SignatureEntity( @@ -1318,23 +1318,23 @@ bool XSecTester::checkSecurityElement( m_xXMLSecurityContext, m_xXMLSignature, mxMSF); - + m_vSignatureList.push_back(pSignatureEntity); - + m_stCurrentPath.push(pSignatureEntity); m_stCurrentPathType.push(false); } else if (ouLocalName.equalsAscii(REFERENCE_STR)) { - if (!m_stCurrentPath.empty()) + if (!m_stCurrentPath.empty()) { void* pSignedInfo = m_stCurrentPath.top(); bool bIsStringType = m_stCurrentPathType.top(); - + m_stCurrentPath.pop(); m_stCurrentPathType.pop(); - - if (bIsStringType && !m_stCurrentPath.empty()) + + if (bIsStringType && !m_stCurrentPath.empty()) { void* pSignature = m_stCurrentPath.top(); bool bIsStringType2 = m_stCurrentPathType.top(); @@ -1343,13 +1343,13 @@ bool XSecTester::checkSecurityElement( { rtl::OUString ouUri = xAttribs->getValueByName (rtl::OUString(RTL_ASCII_USTRINGPARAM( URI_ATTR_STR ))); - + if (ouUri.matchAsciiL("#", 1, 0)) { rtl::OUString uri = ouUri.copy(1); SignatureEntity* pSignatureEntity = (SignatureEntity *)pSignature; - - if (uri != NULL && uri.getLength()>0) + + if (uri != NULL && uri.getLength()>0) { pSignatureEntity->addReferenceURI(uri); findKeyOrReference(pSignatureEntity, uri, true); @@ -1363,82 +1363,82 @@ bool XSecTester::checkSecurityElement( m_stCurrentPath.push( (void *)REFERENCE_STR); m_stCurrentPathType.push(true); } - else if(ouLocalName.equalsAscii(KEYVALUE_STR) || - ouLocalName.equalsAscii(KEYNAME_STR) || - ouLocalName.equalsAscii(X509DATA_STR) || - ouLocalName.equalsAscii(ENCRYPTEDKEY_STR)) + else if(ouLocalName.equalsAscii(KEYVALUE_STR) || + ouLocalName.equalsAscii(KEYNAME_STR) || + ouLocalName.equalsAscii(X509DATA_STR) || + ouLocalName.equalsAscii(ENCRYPTEDKEY_STR)) { - if (!m_stCurrentPath.empty()) + if (!m_stCurrentPath.empty()) { void* pKeyInfo = m_stCurrentPath.top(); bool bIsStringType = m_stCurrentPathType.top(); - + m_stCurrentPath.pop(); m_stCurrentPathType.pop(); - - if (bIsStringType && !m_stCurrentPath.empty()) + + if (bIsStringType && !m_stCurrentPath.empty()) { bool bIsStringType2 = m_stCurrentPathType.top(); - + if (!bIsStringType2) { - SecurityEntity *pSecurityEntity = + SecurityEntity *pSecurityEntity = (SecurityEntity *) (m_stCurrentPath.top()); pSecurityEntity->setKeyId(0); } } - + m_stCurrentPath.push(pKeyInfo); m_stCurrentPathType.push(bIsStringType); } - + m_stCurrentPath.push((void *)KEYVALUE_STR); m_stCurrentPathType.push(true); } - else if(ouLocalName.equalsAscii(RETRIEVALMETHOD_STR)) + else if(ouLocalName.equalsAscii(RETRIEVALMETHOD_STR)) { - if (!m_stCurrentPath.empty()) + if (!m_stCurrentPath.empty()) { void* pKeyInfo = m_stCurrentPath.top(); bool bIsStringType = m_stCurrentPathType.top(); - + m_stCurrentPath.pop(); m_stCurrentPathType.pop(); - - if (bIsStringType && !m_stCurrentPath.empty()) + + if (bIsStringType && !m_stCurrentPath.empty()) { bool bIsStringType2 = m_stCurrentPathType.top(); - + if (!bIsStringType2) { - SecurityEntity *pSecurityEntity = + SecurityEntity *pSecurityEntity = (SecurityEntity *) m_stCurrentPath.top(); rtl::OUString ouUri = xAttribs->getValueByName( rtl::OUString(RTL_ASCII_USTRINGPARAM( URI_ATTR_STR ))); - - if (!strcmp((const char *)pKeyInfo, KEYINFO_STR) && - ouUri != NULL && ouUri.getLength()>0) + + if (!strcmp((const char *)pKeyInfo, KEYINFO_STR) && + ouUri != NULL && ouUri.getLength()>0) { pSecurityEntity->setKeyURI(ouUri); findKeyOrReference(pSecurityEntity, ouUri, true); } } - + } - + m_stCurrentPath.push(pKeyInfo); m_stCurrentPathType.push(bIsStringType); } - + m_stCurrentPath.push((void *)RETRIEVALMETHOD_STR); m_stCurrentPathType.push(true); } - else if(ouLocalName.equalsAscii(KEYINFO_STR)) + else if(ouLocalName.equalsAscii(KEYINFO_STR)) { m_stCurrentPath.push((void *)KEYINFO_STR); m_stCurrentPathType.push(true); } - else if(ouLocalName.equalsAscii(SIGNEDINFO_STR)) + else if(ouLocalName.equalsAscii(SIGNEDINFO_STR)) { m_stCurrentPath.push((void *)SIGNEDINFO_STR); m_stCurrentPathType.push(true); @@ -1448,7 +1448,7 @@ bool XSecTester::checkSecurityElement( m_stCurrentPath.push((void *)OTHER_ELEMENT_STR); m_stCurrentPathType.push(true); } - + return rc; } @@ -1457,38 +1457,38 @@ void XSecTester::checkReference( const cssu::Reference<cssxs::XAttributeList>& xAttribs, const rtl::OUString& ouId) { - rtl::OUString refNumStr = + rtl::OUString refNumStr = xAttribs->getValueByName(rtl::OUString(RTL_ASCII_USTRINGPARAM(REFNUM_ATTR_STR))); - - if (ouId != NULL && ouId.getLength()>0 ) + + if (ouId != NULL && ouId.getLength()>0 ) { int nRefNum = 999; - if (refNumStr != NULL && refNumStr.getLength()>0 ) + if (refNumStr != NULL && refNumStr.getLength()>0 ) { nRefNum = refNumStr.toInt32(); } - + int nLength = m_vSignatureList.size(); - for (int i = 0; i<nLength; ++i) + for (int i = 0; i<nLength; ++i) { SignatureEntity* pSignatureEntity = m_vSignatureList.at(i); - - if (pSignatureEntity->setReference(ouId, m_bIsExporting)) + + if (pSignatureEntity->setReference(ouId, m_bIsExporting)) { nRefNum--; } - - if (pSignatureEntity->setKey(ouId, m_bIsExporting)) + + if (pSignatureEntity->setKey(ouId, m_bIsExporting)) { nRefNum--; } } - - if (nRefNum>0) + + if (nRefNum>0) { int nKeeperId; - - if (ouLocalName.equalsAscii(ENCRYPTEDKEY_STR)) + + if (ouLocalName.equalsAscii(ENCRYPTEDKEY_STR)) { nKeeperId = m_xSAXEventKeeper->addSecurityElementCollector( m_bIsExporting ? @@ -1496,7 +1496,7 @@ void XSecTester::checkReference( (cssxc::sax::ElementMarkPriority_AFTERMODIFY), true); } - else + else { nKeeperId = m_xSAXEventKeeper->addSecurityElementCollector( m_bIsExporting? @@ -1504,7 +1504,7 @@ void XSecTester::checkReference( (cssxc::sax::ElementMarkPriority_BEFOREMODIFY), false); } - + m_vUnsolvedReferenceURIs.push_back(ouId); m_vUnsolvedReferenceKeeperIds.push_back(nKeeperId); m_vUnsolvedReferenceRefNums.push_back(nRefNum); @@ -1516,7 +1516,7 @@ void XSecTester::endMission() { while (m_vSignatureList.size() > 0) { - if (m_vSignatureList.size()>0) + if (m_vSignatureList.size()>0) { SignatureEntity * pSignatureEntity = m_vSignatureList.at(0); m_vSignatureList.erase(m_vSignatureList.begin()); @@ -1524,8 +1524,8 @@ void XSecTester::endMission() delete pSignatureEntity; } } - - while (m_vUnsolvedReferenceURIs.size()>0) + + while (m_vUnsolvedReferenceURIs.size()>0) { int nKeeperId = m_vUnsolvedReferenceKeeperIds.at(0); m_xSAXEventKeeper->removeElementCollector(nKeeperId); @@ -1541,31 +1541,31 @@ void XSecTester::addStartAncestorEvent( { sal_Int32 nLength = xAttribs->getLength(); AncestorEvent* ancestorEvent = new AncestorEvent( nLength ); - + ancestorEvent->bIsStartElement = true; ancestorEvent->ouName = ouName; - - for (int i = 0; i<nLength; ++i) + + for (int i = 0; i<nLength; ++i) { (ancestorEvent->aAttributeList[i]).sName = xAttribs->getNameByIndex((short)i); (ancestorEvent->aAttributeList[i]).sValue =xAttribs->getValueByIndex((short)i); } - + m_vAncestorEvents.push_back(ancestorEvent); } void XSecTester::addEndAncestorEvent(const rtl::OUString& ouName) { AncestorEvent* ancestorEvent = new AncestorEvent(0); - + ancestorEvent->bIsStartElement = false; ancestorEvent->ouName = ouName; - + m_vAncestorEvents.push_back(ancestorEvent); } void XSecTester::sendAncestorStartElementEvent( - const rtl::OUString& ouName, + const rtl::OUString& ouName, const cssu::Sequence< cssxcsax::XMLAttribute >& attrList, const cssu::Reference< cssxs::XDocumentHandler >& xDocumentHandler) const { @@ -1574,12 +1574,12 @@ void XSecTester::sendAncestorStartElementEvent( = cssu::Reference< cssxs::XAttributeList > (pAttributeList); sal_Int32 nLength = attrList.getLength(); - - for (int i = 0; i<nLength; ++i) + + for (int i = 0; i<nLength; ++i) { pAttributeList->AddAttribute( attrList[i].sName, attrList[i].sValue); } - + xDocumentHandler->startElement(ouName, xAttrList); } @@ -1590,12 +1590,12 @@ void XSecTester::sendAncestorEndElementEvent( xDocumentHandler->endElement(ouName); } -std::vector< AncestorEvent* >::const_iterator XSecTester::checkAncestorStartElementEvent( +std::vector< AncestorEvent* >::const_iterator XSecTester::checkAncestorStartElementEvent( const std::vector< AncestorEvent* >::const_iterator& ii, const cssu::Reference< cssxs::XDocumentHandler >& xDocumentHandler) const { std::vector< AncestorEvent* >::const_iterator next = ii+1; - + if (next == m_vAncestorEvents.end()) { sendAncestorStartElementEvent( @@ -1607,29 +1607,29 @@ std::vector< AncestorEvent* >::const_iterator XSecTester::checkAncestorStartElem { next = checkAncestorStartElementEvent(next, xDocumentHandler); } - + if (next != m_vAncestorEvents.end()) { next++; } } - + return next; } - + void XSecTester::flushAncestorEvents( const cssu::Reference< cssxs::XDocumentHandler >& xDocumentHandler) { std::vector< AncestorEvent* >::const_iterator ii; - + if (xDocumentHandler != NULL) { ii = m_vAncestorEvents.begin(); - + while (ii != m_vAncestorEvents.end()) { AncestorEvent* ancestorEvent = *ii; - + if (ancestorEvent->bIsStartElement) { ii = checkAncestorStartElementEvent(ii, xDocumentHandler); @@ -1641,11 +1641,11 @@ void XSecTester::flushAncestorEvents( } } } - + /* free the ancestor events list */ std::vector< AncestorEvent* >::iterator jj; - - while (m_vAncestorEvents.size()>0) + + while (m_vAncestorEvents.size()>0) { jj = m_vAncestorEvents.begin(); delete *jj; @@ -1676,8 +1676,8 @@ void outputHeader() /* * print the output on the screen as well as in the GNUPlot data file */ -void output(const rtl::OUString& ouInputFileName, - const rtl::OUString& ouTime_C, +void output(const rtl::OUString& ouInputFileName, + const rtl::OUString& ouTime_C, const rtl::OUString& ouTime_Java, const rtl::OUString& ouTime_NoSecurity, const rtl::OUString& ouTime_JavaForwardOnly, @@ -1696,16 +1696,16 @@ void output(const rtl::OUString& ouInputFileName, fprintf(stderr, "%4s", bIsExporting?"E":"I"); fprintf(stderr, "%7dK", nSize/1024); - fprintf(stderr, "%8s %3s", + fprintf(stderr, "%8s %3s", rtl::OString(ouTime_C, ouTime_C.getLength(), RTL_TEXTENCODING_ASCII_US).getStr(), rtl::OString(ouRemark_C, ouRemark_C.getLength(), RTL_TEXTENCODING_ASCII_US).getStr()); - fprintf(stderr, "%8s %3s", + fprintf(stderr, "%8s %3s", rtl::OString(ouTime_Java, ouTime_Java.getLength(), RTL_TEXTENCODING_ASCII_US).getStr(), rtl::OString(ouRemark_Java, ouRemark_Java.getLength(), RTL_TEXTENCODING_ASCII_US).getStr()); fprintf(stderr, "%12s", rtl::OString(ouTime_JavaForwardOnly, ouTime_JavaForwardOnly.getLength(), RTL_TEXTENCODING_ASCII_US).getStr()); fprintf(stderr, "%12s", rtl::OString(ouTime_NoSecurity, ouTime_NoSecurity.getLength(), RTL_TEXTENCODING_ASCII_US).getStr()); fprintf(stderr, "\n"); - + /* output the data as GNUPlot data file */ /* char str[32]; @@ -1723,7 +1723,7 @@ void output(const rtl::OUString& ouInputFileName, int main( int argc, char **argv ) { - if (argc < 3) + if (argc < 3) { fprintf(stderr, "Usage: testtool <exportbatchfile> <importbatchfile> [<cppcryptotoken>] [<javacryptotoken>]\n"); exit (-1); @@ -1738,15 +1738,15 @@ int main( int argc, char **argv ) if ( argc > 4 ) aJavaCryptoToken = rtl::OUString::createFromAscii(argv[4]); - try + try { uno::Reference< lang::XMultiServiceFactory > xMSF = CreateDemoServiceFactory(); XSecTester* pTester = new XSecTester( xMSF ); uno::Reference< xml::sax::XDocumentHandler > xKeepARef = pTester; - + pTester->setCryptoDir( aJavaCryptoToken, aCPPCryptoToken ); - + rtl::OUString ouTime_C, ouTime_Java, ouTime_NoSecurity, ouTime_JavaForwardOnly; rtl::OUString ouInputFileName; rtl::OUString outputFileName1; @@ -1761,17 +1761,17 @@ int main( int argc, char **argv ) const int MAX_LINE = 80; char line[MAX_LINE + 1]; - - while (batch_export.getline(line, MAX_LINE)) + + while (batch_export.getline(line, MAX_LINE)) { ouInputFileName = rtl::OUString::createFromAscii(line); int nPosition = ouInputFileName.lastIndexOf('.'); int nPosition1; - + /* * export the file with signautre/encryption (C++) */ - outputFileName1 = ouInputFileName.copy(0, nPosition) + + outputFileName1 = ouInputFileName.copy(0, nPosition) + rtl::OUString::createFromAscii("-ex.xml"); ouTime_C = pTester->export_xml(ouInputFileName, outputFileName1, sal_False); nPosition1 = ouTime_C.lastIndexOf('\t'); @@ -1781,27 +1781,27 @@ int main( int argc, char **argv ) /* * export the file with signautre/encryption (Java) */ - outputFileName1 = ouInputFileName.copy(0, nPosition) + + outputFileName1 = ouInputFileName.copy(0, nPosition) + rtl::OUString::createFromAscii("-ex2.xml"); ouTime_Java = pTester->export_xml(ouInputFileName, outputFileName1, sal_True); nPosition1 = ouTime_Java.lastIndexOf('\t'); ouRemark_Java = ouTime_Java.copy(nPosition1 + 1); ouTime_Java = ouTime_Java.copy(0, nPosition1); - + /* * export the file without signautre/encryption */ - outputFileName2 = ouInputFileName.copy(0, nPosition) + + outputFileName2 = ouInputFileName.copy(0, nPosition) + rtl::OUString::createFromAscii("-ex-no.xml"); ouTime_NoSecurity = pTester->transfer_without_sec(ouInputFileName, outputFileName2, sal_False); /* * export the file with Java Flat Filter */ - outputFileName2 = ouInputFileName.copy(0, nPosition) + + outputFileName2 = ouInputFileName.copy(0, nPosition) + rtl::OUString::createFromAscii("-ex-jf.xml"); ouTime_JavaForwardOnly = pTester->transfer_without_sec(ouInputFileName, outputFileName2, sal_True); - + /* * print output */ @@ -1812,16 +1812,16 @@ int main( int argc, char **argv ) batch_import.open(OUStringToOString( aImportBatchFile, RTL_TEXTENCODING_ASCII_US ).getStr()); - while (batch_import.getline(line, MAX_LINE)) + while (batch_import.getline(line, MAX_LINE)) { ouInputFileName = rtl::OUString::createFromAscii(line); int nPosition = ouInputFileName.lastIndexOf('.'); int nPosition1; - + /* * import the file with signautre/encryption (C++) */ - outputFileName1 = ouInputFileName.copy(0, nPosition) + + outputFileName1 = ouInputFileName.copy(0, nPosition) + rtl::OUString::createFromAscii("-im.xml"); ouTime_C = pTester->import_xml(ouInputFileName, outputFileName1, sal_False); nPosition1 = ouTime_C.lastIndexOf('\t'); @@ -1831,7 +1831,7 @@ int main( int argc, char **argv ) /* * import the file with signautre/encryption (Java) */ - outputFileName1 = ouInputFileName.copy(0, nPosition) + + outputFileName1 = ouInputFileName.copy(0, nPosition) + rtl::OUString::createFromAscii("-im2.xml"); ouTime_Java = pTester->import_xml(ouInputFileName, outputFileName1, sal_True); nPosition1 = ouTime_Java.lastIndexOf('\t'); @@ -1841,7 +1841,7 @@ int main( int argc, char **argv ) /* * import the file without signautre/encryption */ - outputFileName2 = ouInputFileName.copy(0, nPosition) + + outputFileName2 = ouInputFileName.copy(0, nPosition) + rtl::OUString::createFromAscii("-im-no.xml"); ouTime_NoSecurity = pTester->transfer_without_sec(ouInputFileName, outputFileName2, sal_False); @@ -1849,10 +1849,10 @@ int main( int argc, char **argv ) * import the file without signautre/encryption */ - outputFileName2 = ouInputFileName.copy(0, nPosition) + + outputFileName2 = ouInputFileName.copy(0, nPosition) + rtl::OUString::createFromAscii("-im-jf.xml"); ouTime_JavaForwardOnly = pTester->transfer_without_sec(ouInputFileName, outputFileName2, sal_True); - + /* * print output */ @@ -1863,9 +1863,9 @@ int main( int argc, char **argv ) fprintf(stderr, "\n"); } - catch( cssu::Exception& e ) + catch( cssu::Exception& e ) { - fprintf( stderr , "\nEXCEPTION! Error Message: %s\n" , + fprintf( stderr , "\nEXCEPTION! Error Message: %s\n" , rtl::OUStringToOString( e.Message, RTL_TEXTENCODING_ASCII_US ).getStr() ) ; } |