diff options
Diffstat (limited to 'xmlsecurity/tools')
41 files changed, 1313 insertions, 1313 deletions
diff --git a/xmlsecurity/tools/demo/JavaFlatFilter.java b/xmlsecurity/tools/demo/JavaFlatFilter.java index 331ace804072..5df9027e9a0c 100644 --- a/xmlsecurity/tools/demo/JavaFlatFilter.java +++ b/xmlsecurity/tools/demo/JavaFlatFilter.java @@ -1,7 +1,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 @@ -53,92 +53,92 @@ public class JavaFlatFilter extends Object implements XDocumentHandler, XParser, XTypeProvider, XServiceInfo { XDocumentHandler m_xDocumentHandler; - + /* XDocumentHandler */ - public void startDocument() - throws com.sun.star.xml.sax.SAXException + public void startDocument() + throws com.sun.star.xml.sax.SAXException { m_xDocumentHandler.startDocument(); } - + public void endDocument() - throws com.sun.star.xml.sax.SAXException + throws com.sun.star.xml.sax.SAXException { m_xDocumentHandler.endDocument(); } - - public void startElement (String aName, com.sun.star.xml.sax.XAttributeList xAttribs ) - throws com.sun.star.xml.sax.SAXException + + public void startElement (String aName, com.sun.star.xml.sax.XAttributeList xAttribs ) + throws com.sun.star.xml.sax.SAXException { m_xDocumentHandler.startElement(aName, xAttribs); } - - public void endElement ( String aName ) - throws com.sun.star.xml.sax.SAXException + + public void endElement ( String aName ) + throws com.sun.star.xml.sax.SAXException { m_xDocumentHandler.endElement(aName); } - - public void characters ( String aChars ) - throws com.sun.star.xml.sax.SAXException + + public void characters ( String aChars ) + throws com.sun.star.xml.sax.SAXException { m_xDocumentHandler.characters(aChars); } - - public void ignorableWhitespace ( String aWhitespaces ) - throws com.sun.star.xml.sax.SAXException + + public void ignorableWhitespace ( String aWhitespaces ) + throws com.sun.star.xml.sax.SAXException { m_xDocumentHandler.ignorableWhitespace(aWhitespaces); } - - public void processingInstruction ( String aTarget, String aData ) - throws com.sun.star.xml.sax.SAXException + + public void processingInstruction ( String aTarget, String aData ) + throws com.sun.star.xml.sax.SAXException { m_xDocumentHandler.processingInstruction(aTarget, aData); } - - public void setDocumentLocator (com.sun.star.xml.sax.XLocator xLocator ) + + public void setDocumentLocator (com.sun.star.xml.sax.XLocator xLocator ) throws com.sun.star.xml.sax.SAXException { m_xDocumentHandler.setDocumentLocator(xLocator); } - + /* XParser */ public void parseStream(InputSource strucInputSource) { } - + public void setDocumentHandler(XDocumentHandler xDocumentHandler) { m_xDocumentHandler = xDocumentHandler; } - + public void setDTDHandler(XDTDHandler xHandler) { } - + public void setEntityResolver(XEntityResolver xResolver) { } - + public void setErrorHandler(XErrorHandler xHandler) { } - + public void setLocale(Locale locale) { } - + /* * XTypeProvider implementation * maintain a static implementation id for all instances of JavaFlatFilter * initialized by the first call to getImplementationId() */ protected static byte[] _implementationId; - public com.sun.star.uno.Type[] getTypes() + public com.sun.star.uno.Type[] getTypes() { com.sun.star.uno.Type[] retValue = new com.sun.star.uno.Type[4]; - + /* * instantiate Type instances for each interface you support and add them to Type[] array * this object implements XServiceInfo, XTypeProvider and XSignFilter @@ -147,15 +147,15 @@ public class JavaFlatFilter extends Object retValue[1]= new com.sun.star.uno.Type( XTypeProvider.class); retValue[2]= new com.sun.star.uno.Type( XDocumentHandler.class); retValue[3]= new com.sun.star.uno.Type( XParser.class); - + /* * XInterface is not needed for Java components, the UnoRuntime does its job */ - + return retValue; } - - synchronized public byte[] getImplementationId() + + synchronized public byte[] getImplementationId() { if (_implementationId == null) { _implementationId= new byte[16]; @@ -166,42 +166,42 @@ public class JavaFlatFilter extends Object _implementationId[3] = (byte)((hash >>>24) & 0xff); } return _implementationId; - } - - + } + + /* * XServiceInfo implementation * hold the service name in a private static member variable of the class */ protected static final String __serviceName = "com.sun.star.xml.crypto.eval.JavaFlatFilter"; - public String getImplementationName( ) + public String getImplementationName( ) { return getClass().getName(); } - - public boolean supportsService(String serviceName) + + public boolean supportsService(String serviceName) { boolean rc = false; - + if ( serviceName.equals( __serviceName)) { rc = true; } - + return rc; } - - public String[] getSupportedServiceNames( ) + + public String[] getSupportedServiceNames( ) { String[] retValue= new String[0]; retValue[0]= __serviceName; return retValue; } - + /* static __getServiceFactory() implementation */ public static XSingleServiceFactory __getServiceFactory(String implName, XMultiServiceFactory multiFactory, - com.sun.star.registry.XRegistryKey regKey) + com.sun.star.registry.XRegistryKey regKey) { com.sun.star.lang.XSingleServiceFactory xSingleServiceFactory = null; if (implName.equals( JavaFlatFilter.class.getName()) ) @@ -211,15 +211,15 @@ public class JavaFlatFilter extends Object multiFactory, regKey); } - + return xSingleServiceFactory; - } - + } + /* static __writeRegistryServiceInfo implementation */ - public static boolean __writeRegistryServiceInfo(XRegistryKey regKey) + public static boolean __writeRegistryServiceInfo(XRegistryKey regKey) { return FactoryHelper.writeRegistryServiceInfo( JavaFlatFilter.class.getName(), __serviceName, regKey); - } + } } diff --git a/xmlsecurity/tools/demo/mozprofile.cxx b/xmlsecurity/tools/demo/mozprofile.cxx index 4c08e3a82e5a..a6326018ff80 100644 --- a/xmlsecurity/tools/demo/mozprofile.cxx +++ b/xmlsecurity/tools/demo/mozprofile.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 @@ -52,14 +52,14 @@ int SAL_CALL main( int argc, char **argv ) fprintf( stdout, "\n\nERROR: Can't create Service Factory\n" ); exit (-1); } - + uno::Reference<mozilla::XMozillaBootstrap> xMozillaBootstrap( xMSF->createInstance(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.mozilla.MozillaBootstrap" ) ) ), uno::UNO_QUERY ); if ( !xMozillaBootstrap.is() ) { fprintf( stdout, "\n\nERROR: Can't create Mozilla Bootstrap Service\n" ); exit (-1); } - + int nProducts = 4; mozilla::MozillaProductType productTypes[4] = { mozilla::MozillaProductType_Thunderbird, mozilla::MozillaProductType_Mozilla, mozilla::MozillaProductType_Firefox, mozilla::MozillaProductType_Default }; for ( int i = 0; i < nProducts; i++) @@ -84,12 +84,12 @@ int SAL_CALL main( int argc, char **argv ) fprintf( stdout, "NOT FOUND" ); } } - + /* * creates a signature helper */ XMLSignatureHelper aSignatureHelper( xMSF ); - + /* * creates a security context. */ @@ -102,7 +102,7 @@ int SAL_CALL main( int argc, char **argv ) else { fprintf( stdout, "\n\nSecurity environment can be initialized successfully.\n\n" ); - } + } return 0; } diff --git a/xmlsecurity/tools/demo/multisigdemo.cxx b/xmlsecurity/tools/demo/multisigdemo.cxx index 356616451ed6..f5d2b95650ca 100644 --- a/xmlsecurity/tools/demo/multisigdemo.cxx +++ b/xmlsecurity/tools/demo/multisigdemo.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 @@ -55,7 +55,7 @@ long startVerifyHandler( void *, void * ) int SAL_CALL main( int argc, char **argv ) { - if( argc < 5 ) + if( argc < 5 ) { fprintf( stderr, "Usage: %s <signature file 1> <signature file 2> <xml stream file> <binary stream file> [<cryptoken>]\n" , argv[0] ) ; return -1 ; @@ -77,7 +77,7 @@ int SAL_CALL main( int argc, char **argv ) bool bDone; SignatureInformations signatureInformations; uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler> xDocumentHandler; - + // -------- START ------- XMLSignatureHelper aSignatureHelper( xMSF ); @@ -88,11 +88,11 @@ int SAL_CALL main( int argc, char **argv ) fprintf( stderr, "Error initializing security context!\n" ); return -1; } - + fprintf( stdout, "\n\nTEST MISSION 1: Create the first signature file\n"); - + aSignatureHelper.StartMission(); - + /* * select a private key certificate */ @@ -127,14 +127,14 @@ int SAL_CALL main( int argc, char **argv ) fprintf( stdout, "\nSTATUS MISSION 1: Signature successfully created!\n" ); aSignatureHelper.EndMission(); - - + + fprintf( stdout, "\n\nTEST MISSION 2: Transfer the second signature to a new signature file\n"); - + /* * You can use an uninitialized SignatureHelper to perform this mission. */ - + /* * configures the start-verify handler. Don't need to verify for transfering... */ @@ -149,16 +149,16 @@ int SAL_CALL main( int argc, char **argv ) fprintf( stderr, "\nSTATUS MISSION 2: Error in reading Signature!\n" ); else fprintf( stdout, "\nSTATUS MISSION 2: Signature successfully transfered!\n" ); - + /* * get all signature information */ signatureInformations = aSignatureHelper.GetSignatureInformations(); - + /* * write the first signature into the second signature file. - */ - + */ + xOutputStream = OpenOutputStream( aSIGFileName2 ); xDocumentHandler = aSignatureHelper.CreateDocumentHandlerWithHeader( xOutputStream); aSignatureHelper.ExportSignature( xDocumentHandler, signatureInformations[1]); @@ -168,7 +168,7 @@ int SAL_CALL main( int argc, char **argv ) fprintf( stdout, "\n\nTEST MISSION 3: Insert a new signature to the first signature file\n"); aSignatureHelper.StartMission(); - + nSecurityId = aSignatureHelper.GetNewSecurityId(); // Select certificate... @@ -181,10 +181,10 @@ int SAL_CALL main( int argc, char **argv ) aSignatureHelper.AddForSigning( nSecurityId, aBINFileName, aBINFileName, sal_True ); aSignatureHelper.SetDateTime( nSecurityId, Date(), Time() ); - + xOutputStream = OpenOutputStream( aSIGFileName ); xDocumentHandler = aSignatureHelper.CreateDocumentHandlerWithHeader( xOutputStream); - + aSignatureHelper.ExportSignature( xDocumentHandler, signatureInformations[0]); bDone = aSignatureHelper.CreateAndWriteSignature( xDocumentHandler ); aSignatureHelper.ExportSignature( xDocumentHandler, signatureInformations[1]); @@ -198,7 +198,7 @@ int SAL_CALL main( int argc, char **argv ) aSignatureHelper.EndMission(); fprintf( stdout, "\n\nTEST MISSION 4 : Verify the first signature file\n"); - + aSignatureHelper.SetStartVerifySignatureHdl( Link( NULL, startVerifyHandler ) ); aSignatureHelper.StartMission(); @@ -206,7 +206,7 @@ int SAL_CALL main( int argc, char **argv ) xInputStream = OpenInputStream( aSIGFileName ); bDone = aSignatureHelper.ReadAndVerifySignature( xInputStream ); xInputStream->closeInput(); - + if ( !bDone ) fprintf( stderr, "\nSTATUS MISSION 4: Error verifying Signatures!\n" ); else @@ -217,13 +217,13 @@ int SAL_CALL main( int argc, char **argv ) QueryPrintSignatureDetails( aSignatureHelper.GetSignatureInformations(), aSignatureHelper.GetSecurityEnvironment() ); fprintf( stdout, "\n\nTEST MISSION 5: Verify the second signature file\n"); - + aSignatureHelper.StartMission(); xInputStream = OpenInputStream( aSIGFileName2 ); bDone = aSignatureHelper.ReadAndVerifySignature( xInputStream ); xInputStream->closeInput(); - + if ( !bDone ) fprintf( stderr, "\nSTATUS MISSION 5: Error verifying Signatures!\n" ); else 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() ) ; } diff --git a/xmlsecurity/tools/demo/signdemo.cxx b/xmlsecurity/tools/demo/signdemo.cxx index a3c59345cfba..723a8df0bfe1 100644 --- a/xmlsecurity/tools/demo/signdemo.cxx +++ b/xmlsecurity/tools/demo/signdemo.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 @@ -44,7 +44,7 @@ using namespace ::com::sun::star; int SAL_CALL main( int argc, char **argv ) { - if( argc < 4 ) + if( argc < 4 ) { fprintf( stderr, "Usage: %s <signature file> <xml stream file> <binary stream file> [<cryptoken>]\n" , argv[0] ) ; return -1 ; @@ -56,14 +56,14 @@ int SAL_CALL main( int argc, char **argv ) rtl::OUString aCryptoToken; if ( argc >= 5 ) aCryptoToken = rtl::OUString::createFromAscii(argv[4]); - + uno::Reference< lang::XMultiServiceFactory > xMSF = CreateDemoServiceFactory(); - + /* * creates a signature helper */ XMLSignatureHelper aSignatureHelper( xMSF ); - + /* * creates a security context. */ @@ -73,30 +73,30 @@ int SAL_CALL main( int argc, char **argv ) fprintf( stderr, "Error initializing security context!\n" ); return -1; } - + aSignatureHelper.StartMission(); - + /* * select a private key certificate */ sal_Int32 i; sal_Int32 nEnvCount = aSignatureHelper.GetSecurityEnvironmentNumber(); - if( nEnvCount == 0 ) + if( nEnvCount == 0 ) { fprintf( stdout, "\nNo SecurityEnvironment found!\n" ) ; return -1; } - + uno::Sequence< uno::Reference< xml::crypto::XSecurityEnvironment > > xSecurityEnvironments(nEnvCount) ; for( i=0; i < nEnvCount; i++ ) xSecurityEnvironments[i] = aSignatureHelper.GetSecurityEnvironmentByIndex(i); fprintf( stdout, "\nSelect a SecurityEnvironment:\n" ) ; - for( i = 0; i < nEnvCount; i ++ ) + for( i = 0; i < nEnvCount; i ++ ) fprintf( stdout, "\n[%d] %s", i+1, rtl::OUStringToOString( xSecurityEnvironments[i]->getSecurityEnvironmentInformation() ,RTL_TEXTENCODING_ASCII_US ).getStr()); sal_Int32 nEnvIndex = QuerySelectNumber( 1, nEnvCount ) -1; - + uno::Reference< ::com::sun::star::security::XCertificate > xPersonalCert = getCertificateFromEnvironment(xSecurityEnvironments[nEnvIndex], true); if ( !xPersonalCert.is() ) @@ -109,7 +109,7 @@ int SAL_CALL main( int argc, char **argv ) * creates a new signature id */ sal_Int32 nSecurityId = aSignatureHelper.GetNewSecurityId(); - + /* * configures the X509 certificate */ @@ -123,23 +123,23 @@ int SAL_CALL main( int argc, char **argv ) * configures date/time */ aSignatureHelper.SetDateTime( nSecurityId, Date(), Time()); - + /* * signs the xml stream */ aSignatureHelper.AddForSigning( nSecurityId, aXMLFileName, aXMLFileName, sal_False ); - + /* * signs the binary stream */ aSignatureHelper.AddForSigning( nSecurityId, aBINFileName, aBINFileName, sal_True ); - + /* * creates signature */ uno::Reference< io::XOutputStream > xOutputStream = OpenOutputStream( aSIGFileName ); bool bDone = aSignatureHelper.CreateAndWriteSignature( xOutputStream ); - + if ( !bDone ) { fprintf( stderr, "\nSTATUS: Error creating Signature!\n" ); diff --git a/xmlsecurity/tools/demo/util.cxx b/xmlsecurity/tools/demo/util.cxx index b81724f15c4e..f495db978512 100644 --- a/xmlsecurity/tools/demo/util.cxx +++ b/xmlsecurity/tools/demo/util.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 @@ -50,13 +50,13 @@ cssu::Reference< cssl::XMultiServiceFactory > CreateDemoServiceFactory() { cssu::Reference< cssl::XMultiServiceFactory > xMSF; - try + try { cssu::Reference< cssl::XMultiComponentFactory > xLocalServiceManager = NULL ; cssu::Reference< cssu::XComponentContext > xLocalComponentContext = NULL ; - cssu::Reference< ::com::sun::star::registry::XSimpleRegistry > xSimpleRegistry - = ::cppu::createSimpleRegistry(); + cssu::Reference< ::com::sun::star::registry::XSimpleRegistry > xSimpleRegistry + = ::cppu::createSimpleRegistry(); OSL_ENSURE( xSimpleRegistry.is(), "serviceManager - " "Cannot create simple registry" ) ; @@ -77,7 +77,7 @@ cssu::Reference< cssl::XMultiServiceFactory > CreateDemoServiceFactory() "Cannot create intial service manager" ) ; xMSF = cssu::Reference< cssl::XMultiServiceFactory >(xLocalServiceManager, cssu::UNO_QUERY) ; - + ::comphelper::setProcessServiceFactory( xMSF ); } catch( cssu::Exception& e ) diff --git a/xmlsecurity/tools/demo/util.hxx b/xmlsecurity/tools/demo/util.hxx index 080f62458fc5..48916a11275a 100644 --- a/xmlsecurity/tools/demo/util.hxx +++ b/xmlsecurity/tools/demo/util.hxx @@ -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 @@ -48,6 +48,6 @@ long QueryVerifySignature(); ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream > OpenOutputStream( const ::rtl::OUString& rStreamName ); ::rtl::OUString getSignatureInformations( const SignatureInformations& SignatureInformations, ::com::sun::star::uno::Reference< ::com::sun::star::xml::crypto::XSecurityEnvironment > xSecurityEnvironment ); -::com::sun::star::uno::Reference< ::com::sun::star::security::XCertificate > getCertificateFromEnvironment( ::com::sun::star::uno::Reference< ::com::sun::star::xml::crypto::XSecurityEnvironment > xSecurityEnvironment, BOOL nType); +::com::sun::star::uno::Reference< ::com::sun::star::security::XCertificate > getCertificateFromEnvironment( ::com::sun::star::uno::Reference< ::com::sun::star::xml::crypto::XSecurityEnvironment > xSecurityEnvironment, BOOL nType); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/xmlsecurity/tools/demo/util2.cxx b/xmlsecurity/tools/demo/util2.cxx index d40506bc498e..b5a44ce67e51 100644 --- a/xmlsecurity/tools/demo/util2.cxx +++ b/xmlsecurity/tools/demo/util2.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 @@ -30,7 +30,7 @@ #include "precompiled_xmlsecurity.hxx" #include <rtl/locale.h> -#include <osl/nlsupport.h> +#include <osl/nlsupport.h> #include <osl/process.h> #include <util.hxx> @@ -100,20 +100,20 @@ void convertDateTime( ::rtl::OUStringBuffer& rBuffer, { int length = data.getLength(); ::rtl::OUString result; - + char number[4]; for (int j=0; j<length; j++) { sprintf(number, "%02X ", (unsigned char)data[j]); result += rtl::OUString::createFromAscii( number ); } - + return result; } -::rtl::OUString getSignatureInformation( - const SignatureInformation& infor, +::rtl::OUString getSignatureInformation( + const SignatureInformation& infor, cssu::Reference< ::com::sun::star::xml::crypto::XSecurityEnvironment >& xSecurityEnvironment ) { char* status[50] = { @@ -167,9 +167,9 @@ void convertDateTime( ::rtl::OUStringBuffer& rBuffer, "DSIG_NO_REFERENCES", "DSIG_INVALID_REFERENCE", "ASSERTION"}; - + rtl::OUString result; - + result += rtl::OUString::createFromAscii( "Security Id : " ) +rtl::OUString::valueOf(infor.nSecurityId) +rtl::OUString::createFromAscii( "\n" ); @@ -178,11 +178,11 @@ void convertDateTime( ::rtl::OUStringBuffer& rBuffer, +rtl::OUString::createFromAscii( "] " ) +rtl::OUString::createFromAscii(status[infor.nStatus]) +rtl::OUString::createFromAscii( "\n" ); - + const SignatureReferenceInformations& rInfors = infor.vSignatureReferenceInfors; int i; int size = rInfors.size(); - + result += rtl::OUString::createFromAscii( "--References :\n" ); for (i=0; i<size; i++) { @@ -207,7 +207,7 @@ void convertDateTime( ::rtl::OUStringBuffer& rBuffer, result += infor.ouX509SerialNumber; result += rtl::OUString::createFromAscii( "\n" ); } - + if (infor.ouX509Certificate.getLength()>0) { result += rtl::OUString::createFromAscii( "--X509Certificate :\n" ); @@ -223,7 +223,7 @@ void convertDateTime( ::rtl::OUStringBuffer& rBuffer, } result += rtl::OUString::createFromAscii( "--Date :\n" ); - + ::rtl::OUStringBuffer buffer; convertDateTime( buffer, infor.stDateTime ); result += buffer.makeStringAndClear(); @@ -234,7 +234,7 @@ void convertDateTime( ::rtl::OUStringBuffer& rBuffer, result += rtl::OUString::createFromAscii( "--Certificate Path :\n" ); cssu::Reference< ::com::sun::star::security::XCertificate > xCert = xSecurityEnvironment->getCertificate( infor.ouX509IssuerName, numericStringToBigInteger(infor.ouX509SerialNumber) ); cssu::Sequence < cssu::Reference< ::com::sun::star::security::XCertificate > > xCertPath; - if(! xCert.is() ) + if(! xCert.is() ) { fprintf(stdout , " xCert is NULL , so can not buildCertificatePath\n"); return result ; @@ -243,8 +243,8 @@ void convertDateTime( ::rtl::OUStringBuffer& rBuffer, { xCertPath = xSecurityEnvironment->buildCertificatePath( xCert ) ; } - - for( int i = 0; i < xCertPath.getLength(); i++ ) + + for( int i = 0; i < xCertPath.getLength(); i++ ) { result += xCertPath[i]->getSubjectName(); result += rtl::OUString::createFromAscii( "\n Subject public key algorithm : " ); @@ -266,10 +266,10 @@ void convertDateTime( ::rtl::OUStringBuffer& rBuffer, result += rtl::OUString::createFromAscii( "\n <<\n" ); } - + result += rtl::OUString::createFromAscii( "\n Key Usage : " ); sal_Int32 usage = xCert->getCertificateUsage(); - + if (usage & ::com::sun::star::security::KeyUsage::DIGITAL_SIGNATURE) { result += rtl::OUString::createFromAscii( "DIGITAL_SIGNATURE " ); @@ -279,27 +279,27 @@ void convertDateTime( ::rtl::OUStringBuffer& rBuffer, { result += rtl::OUString::createFromAscii( "NON_REPUDIATION " ); } - + if (usage & ::com::sun::star::security::KeyUsage::KEY_ENCIPHERMENT) { result += rtl::OUString::createFromAscii( "KEY_ENCIPHERMENT " ); } - + if (usage & ::com::sun::star::security::KeyUsage::DATA_ENCIPHERMENT) { result += rtl::OUString::createFromAscii( "DATA_ENCIPHERMENT " ); } - + if (usage & ::com::sun::star::security::KeyUsage::KEY_AGREEMENT) { result += rtl::OUString::createFromAscii( "KEY_AGREEMENT " ); } - + if (usage & ::com::sun::star::security::KeyUsage::KEY_CERT_SIGN) { result += rtl::OUString::createFromAscii( "KEY_CERT_SIGN " ); } - + if (usage & ::com::sun::star::security::KeyUsage::CRL_SIGN) { result += rtl::OUString::createFromAscii( "CRL_SIGN " ); @@ -307,32 +307,32 @@ void convertDateTime( ::rtl::OUStringBuffer& rBuffer, result += rtl::OUString::createFromAscii( "\n" ); } - + result += rtl::OUString::createFromAscii( "\n" ); return result; } -::rtl::OUString getSignatureInformations( +::rtl::OUString getSignatureInformations( const SignatureInformations& SignatureInformations, - cssu::Reference< ::com::sun::star::xml::crypto::XSecurityEnvironment > xSecurityEnvironment ) + cssu::Reference< ::com::sun::star::xml::crypto::XSecurityEnvironment > xSecurityEnvironment ) { rtl::OUString result; int i; int size = SignatureInformations.size(); - + for (i=0; i<size; i++) { const SignatureInformation& infor = SignatureInformations[i]; result += getSignatureInformation( infor, xSecurityEnvironment ); } - + result += rtl::OUString::createFromAscii( "\n" ); - + return result; } -::com::sun::star::uno::Reference< ::com::sun::star::security::XCertificate > - getCertificateFromEnvironment( ::com::sun::star::uno::Reference< ::com::sun::star::xml::crypto::XSecurityEnvironment > xSecurityEnvironment , BOOL nType) +::com::sun::star::uno::Reference< ::com::sun::star::security::XCertificate > + getCertificateFromEnvironment( ::com::sun::star::uno::Reference< ::com::sun::star::xml::crypto::XSecurityEnvironment > xSecurityEnvironment , BOOL nType) { cssu::Sequence< cssu::Reference< ::com::sun::star::security::XCertificate > > xPersonalCerts ; int length = 0; @@ -347,18 +347,18 @@ void convertDateTime( ::rtl::OUStringBuffer& rBuffer, if( nType != FALSE ) xPersonalCerts = xSecurityEnvironment->getPersonalCertificates() ; - else + else return NULL; // not support then; length = xPersonalCerts.getLength(); - if(length == 0) + if(length == 0) { fprintf( stdout, "\nNo certificate found!\n" ) ; return NULL; } fprintf( stdout, "\nSelect a certificate:\n" ) ; - for( i = 0; i < length; i ++ ) + for( i = 0; i < length; i ++ ) { rtl::OUString xxxIssuer; rtl::OUString xxxSubject; @@ -376,7 +376,7 @@ void convertDateTime( ::rtl::OUStringBuffer& rBuffer, yyySubject.getStr(), yyyIssuer.getStr()); } - + int sel = QuerySelectNumber( 1, length ) -1; return xPersonalCerts[sel] ; } @@ -394,13 +394,13 @@ void QueryPrintSignatureDetails( const SignatureInformations& SignatureInformati sal_uInt16 encoding = osl_getTextEncodingFromLocale( pLocale ) ; fprintf( stdout, "------------- Signature details START -------------\n" ); - fprintf( stdout, "%s", + fprintf( stdout, "%s", rtl::OUStringToOString( getSignatureInformations( SignatureInformations, rSecEnv), encoding).getStr()); fprintf( stdout, "------------- Signature details END -------------\n" ); - } + } } int QuerySelectNumber( int nMin, int nMax ) diff --git a/xmlsecurity/tools/demo/verifydemo.cxx b/xmlsecurity/tools/demo/verifydemo.cxx index d96d539cee10..f4af57ab70aa 100644 --- a/xmlsecurity/tools/demo/verifydemo.cxx +++ b/xmlsecurity/tools/demo/verifydemo.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 @@ -45,7 +45,7 @@ long startVerifyHandler( void *, void * ) int SAL_CALL main( int argc, char **argv ) { - if( argc < 2 ) + if( argc < 2 ) { fprintf( stderr, "Usage: %s <signature file> [<cryptoken>]\n" , argv[0] ) ; return -1 ; @@ -58,7 +58,7 @@ int SAL_CALL main( int argc, char **argv ) uno::Reference< lang::XMultiServiceFactory > xMSF = CreateDemoServiceFactory(); - + /* * creates a signature helper */ @@ -86,12 +86,12 @@ int SAL_CALL main( int argc, char **argv ) */ uno::Reference< io::XInputStream > xInputStream = OpenInputStream( aSIGFileName ); bool bDone = aSignatureHelper.ReadAndVerifySignature( xInputStream ); - + /* * closes the signature stream */ xInputStream->closeInput(); - + if ( !bDone ) { fprintf( stderr, "\nSTATUS: Error verifying Signature!\n" ); diff --git a/xmlsecurity/tools/examples/enc-1.xml b/xmlsecurity/tools/examples/enc-1.xml index bfd2f11195e8..8d6551421d33 100644 --- a/xmlsecurity/tools/examples/enc-1.xml +++ b/xmlsecurity/tools/examples/enc-1.xml @@ -1,6 +1,6 @@ <?xml version="1.0"?> -<!-- -XML Security Library example: Simple encryption template file for encrypt1 example. +<!-- +XML Security Library example: Simple encryption template file for encrypt1 example. --> <Envelope xmlns="urn:envelope"> The encrypted data is <Data>Hello, World!</Data> @@ -16,12 +16,12 @@ XML Security Library example: Simple encryption template file for encrypt1 examp <X509SerialNumber>123450001</X509SerialNumber> </X509IssuerSerial> </X509Data> - </KeyInfo> + </KeyInfo> <CipherData> <CipherValue/> </CipherData> </EncryptedKey> - </KeyInfo> + </KeyInfo> <CipherData> <CipherValue></CipherValue> </CipherData> diff --git a/xmlsecurity/tools/examples/enc-2.xml b/xmlsecurity/tools/examples/enc-2.xml index 98fc553c0c08..e56d2300ab51 100644 --- a/xmlsecurity/tools/examples/enc-2.xml +++ b/xmlsecurity/tools/examples/enc-2.xml @@ -1,6 +1,6 @@ <?xml version="1.0"?> -<!-- -XML Security Library example: Simple encryption template file for encrypt1 example. +<!-- +XML Security Library example: Simple encryption template file for encrypt1 example. --> <Envelope xmlns="urn:envelope"> The encrypted data is <Data>Hello, World!</Data> @@ -16,12 +16,12 @@ XML Security Library example: Simple encryption template file for encrypt1 examp <X509SerialNumber>123450001</X509SerialNumber> </X509IssuerSerial> </X509Data> - </KeyInfo> + </KeyInfo> <CipherData> <CipherValue/> </CipherData> </EncryptedKey> - </KeyInfo> + </KeyInfo> <CipherData> <CipherValue/> </CipherData> @@ -40,19 +40,19 @@ XML Security Library example: Simple encryption template file for encrypt1 examp <X509SerialNumber>123450001</X509SerialNumber> </X509IssuerSerial> </X509Data> - </KeyInfo> + </KeyInfo> <CipherData> <CipherValue/> </CipherData> </EncryptedKey> - </KeyInfo> + </KeyInfo> <CipherData> <CipherValue></CipherValue> </CipherData> </EncryptedData> <Data> This is an embeded encryption! - </Data> - </Data> + </Data> + </Data> </Envelope> diff --git a/xmlsecurity/tools/examples/s-in-e-1.xml b/xmlsecurity/tools/examples/s-in-e-1.xml index d4c0c0eba80c..c08839a1b717 100644 --- a/xmlsecurity/tools/examples/s-in-e-1.xml +++ b/xmlsecurity/tools/examples/s-in-e-1.xml @@ -1,6 +1,6 @@ <?xml version="1.0"?> -<!-- -XML Security Library example: Simple encryption template file for encrypt1 example. +<!-- +XML Security Library example: Simple encryption template file for encrypt1 example. --> <Envelope xmlns="urn:envelope"> a signature in an encryption. @@ -16,12 +16,12 @@ XML Security Library example: Simple encryption template file for encrypt1 examp <X509SerialNumber>123450001</X509SerialNumber> </X509IssuerSerial> </X509Data> - </KeyInfo> + </KeyInfo> <CipherData> <CipherValue/> </CipherData> </EncryptedKey> - </KeyInfo> + </KeyInfo> <CipherData> <CipherValue/> </CipherData> @@ -48,6 +48,6 @@ XML Security Library example: Simple encryption template file for encrypt1 examp </KeyInfo> </Signature> <Data id="target" refNum="1">Signed Data</Data> - </Data> + </Data> </Envelope> diff --git a/xmlsecurity/tools/examples/s-in-e-2.xml b/xmlsecurity/tools/examples/s-in-e-2.xml index fd3ba0cb5f9c..29e3e45df754 100644 --- a/xmlsecurity/tools/examples/s-in-e-2.xml +++ b/xmlsecurity/tools/examples/s-in-e-2.xml @@ -1,6 +1,6 @@ <?xml version="1.0"?> -<!-- -XML Security Library example: Simple encryption template file for encrypt1 example. +<!-- +XML Security Library example: Simple encryption template file for encrypt1 example. --> <Envelope xmlns="urn:envelope"> a signature in an encryption. @@ -16,12 +16,12 @@ XML Security Library example: Simple encryption template file for encrypt1 examp <X509SerialNumber>123450001</X509SerialNumber> </X509IssuerSerial> </X509Data> - </KeyInfo> + </KeyInfo> <CipherData> <CipherValue/> </CipherData> </EncryptedKey> - </KeyInfo> + </KeyInfo> <CipherData> <CipherValue/> </CipherData> @@ -47,7 +47,7 @@ XML Security Library example: Simple encryption template file for encrypt1 examp </X509Data> </KeyInfo> </Signature> - </Data> + </Data> <SignData id="target" refNum="1">Signed Data</SignData> </Envelope> diff --git a/xmlsecurity/tools/standalone/csfit/certmngr.cxx b/xmlsecurity/tools/standalone/csfit/certmngr.cxx index 5c6d78c89d9a..b5763e6079e1 100644 --- a/xmlsecurity/tools/standalone/csfit/certmngr.cxx +++ b/xmlsecurity/tools/standalone/csfit/certmngr.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 @@ -71,8 +71,8 @@ using namespace ::com::sun::star::xml::crypto ; int SAL_CALL main( int argc, char **argv ) { - CERTCertDBHandle* certHandle ; - PK11SlotInfo* slot ; + CERTCertDBHandle* certHandle ; + PK11SlotInfo* slot ; if( argc != 3 ) { fprintf( stderr, "Usage: %s < CertDir > <rdb file>\n\n" , argv[0] ) ; @@ -148,7 +148,7 @@ int SAL_CALL main( int argc, char **argv ) fprintf( stdout, "\tCertificate Serial Number[%s]\n", OUStringToOString( bigIntegerToNumericString( xPersonalCerts[i]->getSerialNumber() ), RTL_TEXTENCODING_ASCII_US ).getStr() ) ; fprintf( stdout, "\tCertificate Subject[%s]\n", OUStringToOString( xPersonalCerts[i]->getSubjectName(), RTL_TEXTENCODING_ASCII_US ).getStr() ) ; - //build the certificate path + //build the certificate path xCertPath = pSecEnv->buildCertificatePath( xPersonalCerts[i] ) ; //Print the certificate path. fprintf( stdout, "\tCertificate Path\n" ) ; diff --git a/xmlsecurity/tools/standalone/csfit/decrypter.cxx b/xmlsecurity/tools/standalone/csfit/decrypter.cxx index b1177efe58d1..b196e2625ca0 100644 --- a/xmlsecurity/tools/standalone/csfit/decrypter.cxx +++ b/xmlsecurity/tools/standalone/csfit/decrypter.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 @@ -38,7 +38,7 @@ #include "libxslt/xslt.h" #endif - + #include "securityenvironment_nssimpl.hxx" #include "xmlelementwrapper_xmlsecimpl.hxx" @@ -82,12 +82,12 @@ using namespace ::com::sun::star::xml::crypto ; int SAL_CALL main( int argc, char **argv ) { - CERTCertDBHandle* certHandle = NULL ; - PK11SlotInfo* slot = NULL ; - xmlDocPtr doc = NULL ; - xmlNodePtr tplNode ; - xmlNodePtr tarNode ; - FILE* dstFile = NULL ; + CERTCertDBHandle* certHandle = NULL ; + PK11SlotInfo* slot = NULL ; + xmlDocPtr doc = NULL ; + xmlNodePtr tplNode ; + xmlNodePtr tarNode ; + FILE* dstFile = NULL ; if( argc != 5 ) { @@ -102,7 +102,7 @@ int SAL_CALL main( int argc, char **argv ) xmlSubstituteEntitiesDefault(1); #ifndef XMLSEC_NO_XSLT - xmlIndentTreeOutput = 1; + xmlIndentTreeOutput = 1; #endif // XMLSEC_NO_XSLT @@ -264,7 +264,7 @@ done: /* Shutdown libxslt/libxml */ #ifndef XMLSEC_NO_XSLT - xsltCleanupGlobals(); + xsltCleanupGlobals(); #endif /* XMLSEC_NO_XSLT */ xmlCleanupParser(); diff --git a/xmlsecurity/tools/standalone/csfit/encrypter.cxx b/xmlsecurity/tools/standalone/csfit/encrypter.cxx index ce6e4c15ccdf..34e2dafa0d09 100644 --- a/xmlsecurity/tools/standalone/csfit/encrypter.cxx +++ b/xmlsecurity/tools/standalone/csfit/encrypter.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 @@ -79,13 +79,13 @@ using namespace ::com::sun::star::xml::crypto ; int SAL_CALL main( int argc, char **argv ) { - CERTCertDBHandle* certHandle ; - PK11SlotInfo* slot = NULL ; - PK11SymKey* symKey = NULL ; - xmlDocPtr doc = NULL ; - xmlNodePtr tplNode ; - xmlNodePtr tarNode ; - FILE* dstFile = NULL ; + CERTCertDBHandle* certHandle ; + PK11SlotInfo* slot = NULL ; + PK11SymKey* symKey = NULL ; + xmlDocPtr doc = NULL ; + xmlNodePtr tplNode ; + xmlNodePtr tarNode ; + FILE* dstFile = NULL ; if( argc != 7 ) { fprintf( stderr, "Usage: %s < CertDir > <file_url of template> <file_url of result> <target element name> <target element namespace> <rdb file>\n\n" , argv[0] ) ; @@ -99,7 +99,7 @@ int SAL_CALL main( int argc, char **argv ) xmlSubstituteEntitiesDefault(1); #ifndef XMLSEC_NO_XSLT - xmlIndentTreeOutput = 1; + xmlIndentTreeOutput = 1; #endif // XMLSEC_NO_XSLT //Initialize NSPR and NSS @@ -301,7 +301,7 @@ done: /* Shutdown libxslt/libxml */ #ifndef XMLSEC_NO_XSLT - xsltCleanupGlobals(); + xsltCleanupGlobals(); #endif /* XMLSEC_NO_XSLT */ xmlCleanupParser(); diff --git a/xmlsecurity/tools/standalone/csfit/helper.cxx b/xmlsecurity/tools/standalone/csfit/helper.cxx index fb2b6b0933c5..62f44cf9dff1 100644 --- a/xmlsecurity/tools/standalone/csfit/helper.cxx +++ b/xmlsecurity/tools/standalone/csfit/helper.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 @@ -48,7 +48,7 @@ Reference< XInputStream > createStreamFromFile( const OUString sFile ) if( pcFile != NULL ) { FILE *f = fopen( pcFile , "rb" ); Reference< XInputStream > r; - + if( f ) { fseek( f , 0 , SEEK_END ); int nLength = ftell( f ); @@ -58,7 +58,7 @@ Reference< XInputStream > createStreamFromFile( const OUString sFile ) fread( seqIn.getArray() , nLength , 1 , f ); r = Reference< XInputStream > ( new OInputStream( seqIn ) ); - fclose( f ); + fclose( f ); } return r; } else { @@ -103,7 +103,7 @@ Reference< XMultiComponentFactory > serviceManager( Reference< XComponentContext "No rdb URI specified" ) ; if( sUnoUrl.equalsAscii( "local" ) ) { - Reference< XSimpleRegistry > xSimpleRegistry = createSimpleRegistry(); + Reference< XSimpleRegistry > xSimpleRegistry = createSimpleRegistry(); OSL_ENSURE( xSimpleRegistry.is() , "serviceManager - " "Cannot create simple registry" ) ; diff --git a/xmlsecurity/tools/standalone/csfit/helper.hxx b/xmlsecurity/tools/standalone/csfit/helper.hxx index 108ebf73358a..79e8b48f895f 100644 --- a/xmlsecurity/tools/standalone/csfit/helper.hxx +++ b/xmlsecurity/tools/standalone/csfit/helper.hxx @@ -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 @@ -88,7 +88,7 @@ class OInputStream : public WeakImplHelper1 < XInputStream > { public: OInputStream( const Sequence< sal_Int8 >&seq ) : m_seq( seq ), nPos( 0 ) {} - + virtual sal_Int32 SAL_CALL readBytes( Sequence< sal_Int8 >& aData , sal_Int32 nBytesToRead @@ -199,7 +199,7 @@ class OUriBinding : public WeakImplHelper1 < ::com::sun::star::xml::crypto::XUri virtual void SAL_CALL setUriBinding( const ::rtl::OUString& aUri , - const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& aInputStream + const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& aInputStream ) throw( ::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException ) { m_vUris.push_back( aUri ) ; m_vStreams.push_back( aInputStream ) ; @@ -215,7 +215,7 @@ class OUriBinding : public WeakImplHelper1 < ::com::sun::star::xml::crypto::XUri break; } } - + return xInputStream; } diff --git a/xmlsecurity/tools/standalone/csfit/signer.cxx b/xmlsecurity/tools/standalone/csfit/signer.cxx index 40e6a64a2b78..4e3a2cf37991 100644 --- a/xmlsecurity/tools/standalone/csfit/signer.cxx +++ b/xmlsecurity/tools/standalone/csfit/signer.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 @@ -77,18 +77,18 @@ using namespace ::com::sun::star::xml::crypto ; int SAL_CALL main( int argc, char **argv ) { - CERTCertDBHandle* certHandle ; - PK11SlotInfo* slot ; - xmlDocPtr doc ; - xmlNodePtr tplNode ; - xmlNodePtr tarNode ; - xmlAttrPtr idAttr ; - xmlChar* idValue ; - xmlAttrPtr uriAttr ; - xmlChar* uriValue ; - OUString* uri ; - Reference< XUriBinding > xUriBinding ; - FILE* dstFile ; + CERTCertDBHandle* certHandle ; + PK11SlotInfo* slot ; + xmlDocPtr doc ; + xmlNodePtr tplNode ; + xmlNodePtr tarNode ; + xmlAttrPtr idAttr ; + xmlChar* idValue ; + xmlAttrPtr uriAttr ; + xmlChar* uriValue ; + OUString* uri ; + Reference< XUriBinding > xUriBinding ; + FILE* dstFile ; if( argc != 5 ) { fprintf( stderr, "Usage: %s < CertDir > <file_url of template> <file_url of result> <rdb file>\n\n" , argv[0] ) ; @@ -109,7 +109,7 @@ int SAL_CALL main( int argc, char **argv ) xmlSubstituteEntitiesDefault(1); #ifndef XMLSEC_NO_XSLT - xmlIndentTreeOutput = 1; + xmlIndentTreeOutput = 1; #endif // XMLSEC_NO_XSLT @@ -202,7 +202,7 @@ int SAL_CALL main( int argc, char **argv ) if( strchr( ( const char* )uriValue, '/' ) != NULL && strchr( ( const char* )uriValue, '#' ) == NULL ) { fprintf( stdout , "### Find a stream URI [%s]\n", uriValue ) ; - // uri = new ::rtl::OUString( ( const sal_Unicode* )uriValue ) ; + // uri = new ::rtl::OUString( ( const sal_Unicode* )uriValue ) ; uri = new ::rtl::OUString( ( const sal_Char* )uriValue, xmlStrlen( uriValue ), RTL_TEXTENCODING_ASCII_US ) ; } @@ -360,7 +360,7 @@ done: /* Shutdown libxslt/libxml */ #ifndef XMLSEC_NO_XSLT - xsltCleanupGlobals(); + xsltCleanupGlobals(); #endif /* XMLSEC_NO_XSLT */ xmlCleanupParser(); diff --git a/xmlsecurity/tools/standalone/csfit/verifier.cxx b/xmlsecurity/tools/standalone/csfit/verifier.cxx index a109b63931fe..ca97fcdca9cf 100644 --- a/xmlsecurity/tools/standalone/csfit/verifier.cxx +++ b/xmlsecurity/tools/standalone/csfit/verifier.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 @@ -80,17 +80,17 @@ using namespace ::com::sun::star::xml::crypto ; int SAL_CALL main( int argc, char **argv ) { - CERTCertDBHandle* certHandle = NULL ; - PK11SlotInfo* slot = NULL ; - xmlDocPtr doc = NULL ; - xmlNodePtr tplNode ; - xmlNodePtr tarNode ; - xmlAttrPtr idAttr ; - xmlChar* idValue ; - xmlAttrPtr uriAttr ; - xmlChar* uriValue ; - OUString* uri = NULL ; - Reference< XUriBinding > xUriBinding ; + CERTCertDBHandle* certHandle = NULL ; + PK11SlotInfo* slot = NULL ; + xmlDocPtr doc = NULL ; + xmlNodePtr tplNode ; + xmlNodePtr tarNode ; + xmlAttrPtr idAttr ; + xmlChar* idValue ; + xmlAttrPtr uriAttr ; + xmlChar* uriValue ; + OUString* uri = NULL ; + Reference< XUriBinding > xUriBinding ; if( argc != 4 ) { fprintf( stderr, "Usage: %s < CertDir > <file_url> <rdb file>\n" , argv[0] ) ; @@ -104,7 +104,7 @@ int SAL_CALL main( int argc, char **argv ) xmlSubstituteEntitiesDefault(1); #ifndef XMLSEC_NO_XSLT - xmlIndentTreeOutput = 1; + xmlIndentTreeOutput = 1; #endif // XMLSEC_NO_XSLT @@ -138,7 +138,7 @@ int SAL_CALL main( int argc, char **argv ) if( tarNode == NULL ) { tarNode = xmlSecFindNode( xmlDocGetRootElement( doc ), ( xmlChar* )"document", NULL ) ; } - + //Find the "id" attrbute in the element if( tarNode != NULL ) { if( ( idAttr = xmlHasProp( tarNode, ( xmlChar* )"id" ) ) != NULL ) { @@ -149,7 +149,7 @@ int SAL_CALL main( int argc, char **argv ) idAttr = NULL ; } } - + //Add ID to DOM if( idAttr != NULL ) { idValue = xmlNodeListGetString( tarNode->doc, idAttr->children, 1 ) ; @@ -157,7 +157,7 @@ int SAL_CALL main( int argc, char **argv ) fprintf( stderr , "### the ID value is NULL!\n" ) ; goto done ; } - + if( xmlAddID( NULL, doc, idValue, idAttr ) == NULL ) { fprintf( stderr , "### Can not add the ID value!\n" ) ; goto done ; @@ -188,7 +188,7 @@ int SAL_CALL main( int argc, char **argv ) if( strchr( ( const char* )uriValue, '/' ) != NULL && strchr( ( const char* )uriValue, '#' ) == NULL ) { fprintf( stdout , "### Find a stream URI [%s]\n", uriValue ) ; - // uri = new ::rtl::OUString( ( const sal_Unicode* )uriValue ) ; + // uri = new ::rtl::OUString( ( const sal_Unicode* )uriValue ) ; uri = new ::rtl::OUString( ( const sal_Char* )uriValue, xmlStrlen( uriValue ), RTL_TEXTENCODING_ASCII_US ) ; } @@ -332,7 +332,7 @@ done : /* Shutdown libxslt/libxml */ #ifndef XMLSEC_NO_XSLT - xsltCleanupGlobals(); + xsltCleanupGlobals(); #endif /* XMLSEC_NO_XSLT */ xmlCleanupParser(); diff --git a/xmlsecurity/tools/standalone/mscsfit/certmngr.cxx b/xmlsecurity/tools/standalone/mscsfit/certmngr.cxx index 2856967cbd26..c9fa5261a00e 100644 --- a/xmlsecurity/tools/standalone/mscsfit/certmngr.cxx +++ b/xmlsecurity/tools/standalone/mscsfit/certmngr.cxx @@ -113,7 +113,7 @@ int SAL_CALL main( int argc, char **argv ) fprintf( stdout, "\tCertificate Serial Number[%s]\n", OUStringToOString( bigIntegerToNumericString( xPersonalCerts[i]->getSerialNumber() ), RTL_TEXTENCODING_ASCII_US ).getStr() ) ; fprintf( stdout, "\tCertificate Subject[%s]\n", OUStringToOString( xPersonalCerts[i]->getSubjectName(), RTL_TEXTENCODING_ASCII_US ).getStr() ) ; - //build the certificate path + //build the certificate path xCertPath = pSecEnv->buildCertificatePath( xPersonalCerts[i] ) ; //Print the certificate path. fprintf( stdout, "\tCertificate Path\n" ) ; diff --git a/xmlsecurity/tools/standalone/mscsfit/decrypter.cxx b/xmlsecurity/tools/standalone/mscsfit/decrypter.cxx index 1b0015c6d92e..a36f6a30b628 100644 --- a/xmlsecurity/tools/standalone/mscsfit/decrypter.cxx +++ b/xmlsecurity/tools/standalone/mscsfit/decrypter.cxx @@ -12,7 +12,7 @@ #include "libxslt/xslt.h" #endif - + #include "securityenvironment_mscryptimpl.hxx" #include "xmlelementwrapper_xmlsecimpl.hxx" @@ -56,12 +56,12 @@ using namespace ::com::sun::star::xml::crypto ; int SAL_CALL main( int argc, char **argv ) { - CERTCertDBHandle* certHandle = NULL ; - PK11SlotInfo* slot = NULL ; - xmlDocPtr doc = NULL ; - xmlNodePtr tplNode ; - xmlNodePtr tarNode ; - FILE* dstFile = NULL ; + CERTCertDBHandle* certHandle = NULL ; + PK11SlotInfo* slot = NULL ; + xmlDocPtr doc = NULL ; + xmlNodePtr tplNode ; + xmlNodePtr tarNode ; + FILE* dstFile = NULL ; if( argc != 5 ) { @@ -76,7 +76,7 @@ int SAL_CALL main( int argc, char **argv ) xmlSubstituteEntitiesDefault(1); #ifndef XMLSEC_NO_XSLT - xmlIndentTreeOutput = 1; + xmlIndentTreeOutput = 1; #endif // XMLSEC_NO_XSLT @@ -238,7 +238,7 @@ done: /* Shutdown libxslt/libxml */ #ifndef XMLSEC_NO_XSLT - xsltCleanupGlobals(); + xsltCleanupGlobals(); #endif /* XMLSEC_NO_XSLT */ xmlCleanupParser(); diff --git a/xmlsecurity/tools/standalone/mscsfit/encrypter.cxx b/xmlsecurity/tools/standalone/mscsfit/encrypter.cxx index d580649ed0e6..3bf6831459a5 100644 --- a/xmlsecurity/tools/standalone/mscsfit/encrypter.cxx +++ b/xmlsecurity/tools/standalone/mscsfit/encrypter.cxx @@ -45,16 +45,16 @@ using namespace ::com::sun::star::xml::crypto ; int SAL_CALL main( int argc, char **argv ) { - const char* n_pCertStore ; - HCERTSTORE n_hStoreHandle ; + const char* n_pCertStore ; + HCERTSTORE n_hStoreHandle ; - xmlDocPtr doc = NULL ; - xmlNodePtr tplNode ; - xmlNodePtr tarNode ; - FILE* dstFile = NULL ; + xmlDocPtr doc = NULL ; + xmlNodePtr tplNode ; + xmlNodePtr tarNode ; + FILE* dstFile = NULL ; - HCRYPTPROV hCryptProv = NULL ; - HCRYPTKEY symKey = NULL ; + HCRYPTPROV hCryptProv = NULL ; + HCRYPTKEY symKey = NULL ; if( argc != 6 && argc != 7 ) { fprintf( stderr, "Usage: %s <file_url of template> <file_url of result> <target element name> <target element namespace> <rdb file>\n\n" , argv[0] ) ; @@ -69,7 +69,7 @@ int SAL_CALL main( int argc, char **argv ) xmlSubstituteEntitiesDefault(1); #ifndef XMLSEC_NO_XSLT - xmlIndentTreeOutput = 1; + xmlIndentTreeOutput = 1; #endif // XMLSEC_NO_XSLT //Initialize the crypto engine @@ -258,8 +258,8 @@ int SAL_CALL main( int argc, char **argv ) OSL_ENSURE( xTemplate.is() , "Encryptor - " "Cannot encrypt the xml document" ) ; - - + + com::sun::star::xml::crypto::SecurityOperationStatus m_nStatus = xTemplate->getStatus(); if (m_nStatus == SecurityOperationStatus_OPERATION_SUCCEEDED) { @@ -300,7 +300,7 @@ done: /* Shutdown libxslt/libxml */ #ifndef XMLSEC_NO_XSLT - xsltCleanupGlobals(); + xsltCleanupGlobals(); #endif /* XMLSEC_NO_XSLT */ xmlCleanupParser(); diff --git a/xmlsecurity/tools/standalone/mscsfit/helper.cxx b/xmlsecurity/tools/standalone/mscsfit/helper.cxx index 631ae1c397b7..e4c497558514 100644 --- a/xmlsecurity/tools/standalone/mscsfit/helper.cxx +++ b/xmlsecurity/tools/standalone/mscsfit/helper.cxx @@ -16,7 +16,7 @@ Reference< XInputStream > createStreamFromFile( const OUString sFile ) if( pcFile != NULL ) { FILE *f = fopen( pcFile , "rb" ); Reference< XInputStream > r; - + if( f ) { fseek( f , 0 , SEEK_END ); int nLength = ftell( f ); @@ -26,7 +26,7 @@ Reference< XInputStream > createStreamFromFile( const OUString sFile ) fread( seqIn.getArray() , nLength , 1 , f ); r = Reference< XInputStream > ( new OInputStream( seqIn ) ); - fclose( f ); + fclose( f ); } return r; } else { @@ -71,7 +71,7 @@ Reference< XMultiComponentFactory > serviceManager( Reference< XComponentContext "No rdb URI specified" ) ; if( sUnoUrl.equalsAscii( "local" ) ) { - Reference< XSimpleRegistry > xSimpleRegistry = createSimpleRegistry(); + Reference< XSimpleRegistry > xSimpleRegistry = createSimpleRegistry(); OSL_ENSURE( xSimpleRegistry.is() , "serviceManager - " "Cannot create simple registry" ) ; diff --git a/xmlsecurity/tools/standalone/mscsfit/helper.hxx b/xmlsecurity/tools/standalone/mscsfit/helper.hxx index 928c9415e997..fa782b387707 100644 --- a/xmlsecurity/tools/standalone/mscsfit/helper.hxx +++ b/xmlsecurity/tools/standalone/mscsfit/helper.hxx @@ -57,7 +57,7 @@ class OInputStream : public WeakImplHelper1 < XInputStream > { public: OInputStream( const Sequence< sal_Int8 >&seq ) : m_seq( seq ), nPos( 0 ) {} - + virtual sal_Int32 SAL_CALL readBytes( Sequence< sal_Int8 >& aData , sal_Int32 nBytesToRead @@ -168,7 +168,7 @@ class OUriBinding : public WeakImplHelper1 < ::com::sun::star::xml::crypto::XUri virtual void SAL_CALL setUriBinding( const ::rtl::OUString& aUri , - const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& aInputStream + const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& aInputStream ) throw( ::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException ) { m_vUris.push_back( aUri ) ; m_vStreams.push_back( aInputStream ) ; @@ -184,7 +184,7 @@ class OUriBinding : public WeakImplHelper1 < ::com::sun::star::xml::crypto::XUri break; } } - + return xInputStream; } diff --git a/xmlsecurity/tools/standalone/mscsfit/signer.cxx b/xmlsecurity/tools/standalone/mscsfit/signer.cxx index ffa88577444a..84fa6aa93ce2 100644 --- a/xmlsecurity/tools/standalone/mscsfit/signer.cxx +++ b/xmlsecurity/tools/standalone/mscsfit/signer.cxx @@ -43,19 +43,19 @@ using namespace ::com::sun::star::xml::crypto ; int SAL_CALL main( int argc, char **argv ) { - const char* n_pCertStore ; - HCERTSTORE n_hStoreHandle ; - - xmlDocPtr doc = NULL ; - xmlNodePtr tplNode ; - xmlNodePtr tarNode ; - xmlAttrPtr idAttr ; - xmlChar* idValue ; - xmlAttrPtr uriAttr ; - xmlChar* uriValue ; - OUString* uri = NULL ; - Reference< XUriBinding > xUriBinding ; - FILE* dstFile = NULL ; + const char* n_pCertStore ; + HCERTSTORE n_hStoreHandle ; + + xmlDocPtr doc = NULL ; + xmlNodePtr tplNode ; + xmlNodePtr tarNode ; + xmlAttrPtr idAttr ; + xmlChar* idValue ; + xmlAttrPtr uriAttr ; + xmlChar* uriValue ; + OUString* uri = NULL ; + Reference< XUriBinding > xUriBinding ; + FILE* dstFile = NULL ; if( argc !=4 && argc != 5 ) { fprintf( stderr, "Usage: %s <file_url of template> <file_url of result> <rdb file>\n" , argv[0] ) ; @@ -72,7 +72,7 @@ int SAL_CALL main( int argc, char **argv ) xmlSubstituteEntitiesDefault(1); #ifndef XMLSEC_NO_XSLT - xmlIndentTreeOutput = 1; + xmlIndentTreeOutput = 1; #endif // XMLSEC_NO_XSLT //Initialize the crypto engine @@ -159,7 +159,7 @@ int SAL_CALL main( int argc, char **argv ) if( strchr( ( const char* )uriValue, '/' ) != NULL && strchr( ( const char* )uriValue, '#' ) == NULL ) { fprintf( stdout , "### Find a stream URI [%s]\n", uriValue ) ; - // uri = new ::rtl::OUString( ( const sal_Unicode* )uriValue ) ; + // uri = new ::rtl::OUString( ( const sal_Unicode* )uriValue ) ; uri = new ::rtl::OUString( ( const sal_Char* )uriValue, xmlStrlen( uriValue ), RTL_TEXTENCODING_ASCII_US ) ; } @@ -289,10 +289,10 @@ int SAL_CALL main( int argc, char **argv ) xTemplate = xSigner->generate( xTemplate , xSecEnv ) ; OSL_ENSURE( xTemplate.is() , "Signer - " - "Cannot generate the xml signature" ) ; - + "Cannot generate the xml signature" ) ; + SecurityOperationStatus m_nStatus = xTemplate->getStatus(); - + if (m_nStatus == SecurityOperationStatus_OPERATION_SUCCEEDED) { fprintf( stdout, "Operation succeeds.\n") ; @@ -332,7 +332,7 @@ done: /* Shutdown libxslt/libxml */ #ifndef XMLSEC_NO_XSLT - xsltCleanupGlobals(); + xsltCleanupGlobals(); #endif /* XMLSEC_NO_XSLT */ xmlCleanupParser(); diff --git a/xmlsecurity/tools/standalone/mscsfit/verifier.cxx b/xmlsecurity/tools/standalone/mscsfit/verifier.cxx index c66233eebdf6..d7eac01a6e2c 100644 --- a/xmlsecurity/tools/standalone/mscsfit/verifier.cxx +++ b/xmlsecurity/tools/standalone/mscsfit/verifier.cxx @@ -46,19 +46,19 @@ using namespace ::com::sun::star::xml::crypto ; int SAL_CALL main( int argc, char **argv ) { - const char* n_pCertStore ; - HCERTSTORE n_hStoreHandle ; - - xmlDocPtr doc = NULL ; - xmlNodePtr tplNode ; - xmlNodePtr tarNode ; - xmlAttrPtr idAttr ; - xmlChar* idValue ; - xmlAttrPtr uriAttr ; - xmlChar* uriValue ; - OUString* uri = NULL ; - Reference< XUriBinding > xUriBinding ; - FILE* dstFile = NULL ; + const char* n_pCertStore ; + HCERTSTORE n_hStoreHandle ; + + xmlDocPtr doc = NULL ; + xmlNodePtr tplNode ; + xmlNodePtr tarNode ; + xmlAttrPtr idAttr ; + xmlChar* idValue ; + xmlAttrPtr uriAttr ; + xmlChar* uriValue ; + OUString* uri = NULL ; + Reference< XUriBinding > xUriBinding ; + FILE* dstFile = NULL ; if( argc !=3 && argc != 4 ) { fprintf( stderr, "Usage: %s <file_url> <rdb file>\n" , argv[0] ) ; @@ -75,7 +75,7 @@ int SAL_CALL main( int argc, char **argv ) xmlSubstituteEntitiesDefault(1); #ifndef XMLSEC_NO_XSLT - xmlIndentTreeOutput = 1; + xmlIndentTreeOutput = 1; #endif // XMLSEC_NO_XSLT //Initialize the crypto engine @@ -111,7 +111,7 @@ int SAL_CALL main( int argc, char **argv ) if( tarNode == NULL ) { tarNode = xmlSecFindNode( xmlDocGetRootElement( doc ), ( xmlChar* )"document", NULL ) ; } - + //Find the "id" attrbute in the element if( tarNode != NULL ) { if( ( idAttr = xmlHasProp( tarNode, ( xmlChar* )"id" ) ) != NULL ) { @@ -122,7 +122,7 @@ int SAL_CALL main( int argc, char **argv ) idAttr = NULL ; } } - + //Add ID to DOM if( idAttr != NULL ) { idValue = xmlNodeListGetString( tarNode->doc, idAttr->children, 1 ) ; @@ -130,7 +130,7 @@ int SAL_CALL main( int argc, char **argv ) fprintf( stderr , "### the ID value is NULL!\n" ) ; goto done ; } - + if( xmlAddID( NULL, doc, idValue, idAttr ) == NULL ) { fprintf( stderr , "### Can not add the ID value!\n" ) ; goto done ; @@ -161,7 +161,7 @@ int SAL_CALL main( int argc, char **argv ) if( strchr( ( const char* )uriValue, '/' ) != NULL && strchr( ( const char* )uriValue, '#' ) == NULL ) { fprintf( stdout , "### Find a stream URI [%s]\n", uriValue ) ; - // uri = new ::rtl::OUString( ( const sal_Unicode* )uriValue ) ; + // uri = new ::rtl::OUString( ( const sal_Unicode* )uriValue ) ; uri = new ::rtl::OUString( ( const sal_Char* )uriValue, xmlStrlen( uriValue ), RTL_TEXTENCODING_ASCII_US ) ; } @@ -288,9 +288,9 @@ int SAL_CALL main( int argc, char **argv ) //perform validation xTemplate = xSigner->validate( xTemplate , xSecCtx ) ; - + com::sun::star::xml::crypto::SecurityOperationStatus m_nStatus = xTemplate->getStatus(); - + if (m_nStatus == SecurityOperationStatus_OPERATION_SUCCEEDED) { fprintf( stdout, "Operation succeeds.\n") ; @@ -318,7 +318,7 @@ done : /* Shutdown libxslt/libxml */ #ifndef XMLSEC_NO_XSLT - xsltCleanupGlobals(); + xsltCleanupGlobals(); #endif /* XMLSEC_NO_XSLT */ xmlCleanupParser(); diff --git a/xmlsecurity/tools/uno/AdapterNode.java b/xmlsecurity/tools/uno/AdapterNode.java index bed8e2a3631c..b42b7a3b32ef 100644 --- a/xmlsecurity/tools/uno/AdapterNode.java +++ b/xmlsecurity/tools/uno/AdapterNode.java @@ -1,7 +1,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 @@ -37,11 +37,11 @@ import org.w3c.dom.NamedNodeMap; * display in the tree. It also returns children, index values, * and child counts. */ -class AdapterNode -{ +class AdapterNode +{ private Node m_domNode; static final int ELEMENT_TYPE = Node.ELEMENT_NODE; - + /* * An array of names for DOM node-types */ @@ -60,105 +60,105 @@ class AdapterNode "DocFragment", "Notation", }; - + protected Node getNode() { return m_domNode; } - + /* * Construct an Adapter node from a DOM node */ - protected AdapterNode(org.w3c.dom.Node node) + protected AdapterNode(org.w3c.dom.Node node) { m_domNode = node; } - + /* * Return children, index, and count values */ - protected int index(AdapterNode child) + protected int index(AdapterNode child) { int count = childCount(); - for (int i=0; i<count; ++i) + for (int i=0; i<count; ++i) { AdapterNode n = this.child(i); if (child.m_domNode == n.m_domNode) return i; } return -1; } - - protected AdapterNode child(int searchIndex) + + protected AdapterNode child(int searchIndex) { if (m_domNode == null) return null; - + /* - * Note: JTree index is zero-based. + * Note: JTree index is zero-based. */ - org.w3c.dom.Node node = + org.w3c.dom.Node node = m_domNode.getChildNodes().item(searchIndex); - - return new AdapterNode(node); + + return new AdapterNode(node); } - - protected int childCount() + + protected int childCount() { int rc = 0; - + if (m_domNode != null) { rc = m_domNode.getChildNodes().getLength(); } - + return rc; } - + /* * Return a string that identifies this node in the tree */ - public String toString() + public String toString() { String rc = null; - + if (m_domNode != null) { String s = typeName[m_domNode.getNodeType()]; String nodeName = m_domNode.getNodeName(); - - if (! nodeName.startsWith("#")) + + if (! nodeName.startsWith("#")) { s += ": " + nodeName; } - - if (m_domNode.getNodeValue() != null) + + if (m_domNode.getNodeValue() != null) { - if (s.startsWith("ProcInstr")) + if (s.startsWith("ProcInstr")) { - s += ", "; + s += ", "; } - else + else { s += ": "; } - + String t = m_domNode.getNodeValue(); s += t; } - + if (m_domNode.getNodeType() == ELEMENT_TYPE) { NamedNodeMap attrs = m_domNode.getAttributes(); - + int length = attrs.getLength(); for (int i=0; i<length; ++i) { Attr attr = (Attr)(attrs.item(i)); - s += " "+ attr.getName()+"='"+attr.getValue() + "'"; + s += " "+ attr.getName()+"='"+attr.getValue() + "'"; } } rc = s; } - + return rc; } } diff --git a/xmlsecurity/tools/uno/AttributeListHelper.java b/xmlsecurity/tools/uno/AttributeListHelper.java index c95067bcecb6..7eb92b647201 100644 --- a/xmlsecurity/tools/uno/AttributeListHelper.java +++ b/xmlsecurity/tools/uno/AttributeListHelper.java @@ -1,7 +1,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 @@ -40,7 +40,7 @@ import com.sun.star.xml.sax.XAttributeList; public class AttributeListHelper implements com.sun.star.xml.sax.XAttributeList { private Vector m_AttributeList; - + public AttributeListHelper() { m_AttributeList = new Vector(); @@ -55,7 +55,7 @@ public class AttributeListHelper implements com.sun.star.xml.sax.XAttributeList { int nLength = m_AttributeList.size(); boolean bFound = false; - + for (int i=0; i<nLength; ++i) { if (getNameByIndex((short)i).equals(name)) @@ -67,7 +67,7 @@ public class AttributeListHelper implements com.sun.star.xml.sax.XAttributeList break; } } - + if (!bFound) { Vector attribute = new Vector(); @@ -81,22 +81,22 @@ public class AttributeListHelper implements com.sun.star.xml.sax.XAttributeList public String getAttributeItem(short index, int itemIndex) { String item = null; - + if (index>=0 && index<getLength()) { Vector attribute = (Vector)m_AttributeList.get(index); item = (String)(attribute.get(itemIndex)); } - + return item; } - + /* XAttributeList */ public short getLength() { return (short)m_AttributeList.size(); } - + public String getNameByIndex(short i) { return getAttributeItem(i, 0); @@ -111,12 +111,12 @@ public class AttributeListHelper implements com.sun.star.xml.sax.XAttributeList { return getAttributeItem(i, 2); } - + public String getTypeByName(String aName) { int nLength = m_AttributeList.size(); String type = null; - + for (int i=0; i<nLength; ++i) { if (getNameByIndex((short)i).equals(aName)) @@ -125,15 +125,15 @@ public class AttributeListHelper implements com.sun.star.xml.sax.XAttributeList break; } } - + return type; } - + public String getValueByName(String aName) { int nLength = m_AttributeList.size(); String value = null; - + for (int i=0; i<nLength; ++i) { if (getNameByIndex((short)i).equals(aName)) diff --git a/xmlsecurity/tools/uno/DomToTreeModelAdapter.java b/xmlsecurity/tools/uno/DomToTreeModelAdapter.java index 709d0efa9515..9ca44256ad12 100644 --- a/xmlsecurity/tools/uno/DomToTreeModelAdapter.java +++ b/xmlsecurity/tools/uno/DomToTreeModelAdapter.java @@ -1,7 +1,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 @@ -35,11 +35,11 @@ import java.util.Enumeration; import java.util.Vector; /* - * This adapter converts the current Document (a DOM) into - * a JTree model. + * This adapter converts the current Document (a DOM) into + * a JTree model. */ -class DomToTreeModelAdapter - implements javax.swing.tree.TreeModel +class DomToTreeModelAdapter + implements javax.swing.tree.TreeModel { private Document m_document; private Vector m_listenerList = new Vector(); @@ -50,50 +50,50 @@ class DomToTreeModelAdapter } /* - * Basic TreeModel operations + * Basic TreeModel operations */ - public Object getRoot() + public Object getRoot() { return new AdapterNode(m_document); } - public boolean isLeaf(Object aNode) + public boolean isLeaf(Object aNode) { boolean rc = true; - + /* * Determines whether the icon shows up to the left. * Return true for any node with no children. */ AdapterNode node = (AdapterNode) aNode; - + if (node.childCount() > 0) { rc = false; } - + return rc; } - - public int getChildCount(Object parent) + + public int getChildCount(Object parent) { AdapterNode node = (AdapterNode) parent; return node.childCount(); } - - public Object getChild(Object parent, int index) + + public Object getChild(Object parent, int index) { AdapterNode node = (AdapterNode) parent; return node.child(index); } - - public int getIndexOfChild(Object parent, Object child) + + public int getIndexOfChild(Object parent, Object child) { AdapterNode node = (AdapterNode) parent; return node.index((AdapterNode) child); } - - public void valueForPathChanged(TreePath path, Object newValue) + + public void valueForPathChanged(TreePath path, Object newValue) { /* * Null. We won't be making changes in the GUI @@ -102,60 +102,60 @@ class DomToTreeModelAdapter */ } - public void addTreeModelListener(TreeModelListener listener) + public void addTreeModelListener(TreeModelListener listener) { - if ( listener != null - && ! m_listenerList.contains( listener ) ) + if ( listener != null + && ! m_listenerList.contains( listener ) ) { m_listenerList.addElement( listener ); } } - - public void removeTreeModelListener(TreeModelListener listener) + + public void removeTreeModelListener(TreeModelListener listener) { - if ( listener != null ) + if ( listener != null ) { m_listenerList.removeElement( listener ); } } - - public void fireTreeNodesChanged( TreeModelEvent e ) + + public void fireTreeNodesChanged( TreeModelEvent e ) { Enumeration listeners = m_listenerList.elements(); - while ( listeners.hasMoreElements() ) + while ( listeners.hasMoreElements() ) { - TreeModelListener listener = + TreeModelListener listener = (TreeModelListener) listeners.nextElement(); listener.treeNodesChanged( e ); } - } + } - public void fireTreeNodesInserted( TreeModelEvent e ) + public void fireTreeNodesInserted( TreeModelEvent e ) { Enumeration listeners = m_listenerList.elements(); - while ( listeners.hasMoreElements() ) + while ( listeners.hasMoreElements() ) { TreeModelListener listener = (TreeModelListener) listeners.nextElement(); listener.treeNodesInserted( e ); } - } + } - public void fireTreeNodesRemoved( TreeModelEvent e ) + public void fireTreeNodesRemoved( TreeModelEvent e ) { Enumeration listeners = m_listenerList.elements(); - while ( listeners.hasMoreElements() ) + while ( listeners.hasMoreElements() ) { - TreeModelListener listener = + TreeModelListener listener = (TreeModelListener) listeners.nextElement(); listener.treeNodesRemoved( e ); } - } + } - public void fireTreeStructureChanged( TreeModelEvent e ) + public void fireTreeStructureChanged( TreeModelEvent e ) { Enumeration listeners = m_listenerList.elements(); - while ( listeners.hasMoreElements() ) + while ( listeners.hasMoreElements() ) { TreeModelListener listener = (TreeModelListener) listeners.nextElement(); diff --git a/xmlsecurity/tools/uno/EncryptionEntity.java b/xmlsecurity/tools/uno/EncryptionEntity.java index 51f14b2bbf6b..49e1c8630618 100644 --- a/xmlsecurity/tools/uno/EncryptionEntity.java +++ b/xmlsecurity/tools/uno/EncryptionEntity.java @@ -1,7 +1,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 @@ -42,7 +42,7 @@ import com.sun.star.xml.crypto.sax.*; class EncryptionEntity extends SecurityEntity { private int m_nEncryptionElementCollectorId; - + EncryptionEntity( XSecuritySAXEventKeeper xSAXEventKeeper, boolean isExporting, @@ -55,13 +55,13 @@ class EncryptionEntity extends SecurityEntity { super(xSAXEventKeeper, xXMLSecurityContext, xXMLSignature, xXMLEncryption, xRemoteServiceManager, xRemoteContext); - + m_nEncryptionElementCollectorId = m_xSAXEventKeeper.addSecurityElementCollector( ElementMarkPriority.AFTERMODIFY, true); - + m_xSAXEventKeeper.setSecurityId(m_nEncryptionElementCollectorId, m_nSecurityId); - + if (isExporting) { try @@ -71,11 +71,11 @@ class EncryptionEntity extends SecurityEntity */ Object encryptor = m_xRemoteServiceManager.createInstanceWithContext( TestTool.ENCRYPTOR_COMPONENT, m_xRemoteContext); - - m_xReferenceResolvedListener = + + m_xReferenceResolvedListener = (XReferenceResolvedListener)UnoRuntime.queryInterface( - XReferenceResolvedListener.class, encryptor); - + XReferenceResolvedListener.class, encryptor); + /* * initializes the Encryptor. */ @@ -89,11 +89,11 @@ class EncryptionEntity extends SecurityEntity args[3] = m_xXMLSecurityContext.getSecurityEnvironment(); args[4] = m_xXMLEncryption; xInitialization.initialize(args); - + /* * sets encryption result listener. */ - XEncryptionResultBroadcaster m_xEncryptionResultBroadcaster = + XEncryptionResultBroadcaster m_xEncryptionResultBroadcaster = (XEncryptionResultBroadcaster)UnoRuntime.queryInterface( XEncryptionResultBroadcaster.class, m_xReferenceResolvedListener); m_xEncryptionResultBroadcaster.addEncryptionResultListener( @@ -113,11 +113,11 @@ class EncryptionEntity extends SecurityEntity */ Object decryptor = m_xRemoteServiceManager.createInstanceWithContext( TestTool.DECRYPTOR_COMPONENT, m_xRemoteContext); - - m_xReferenceResolvedListener = + + m_xReferenceResolvedListener = (XReferenceResolvedListener)UnoRuntime.queryInterface( - XReferenceResolvedListener.class, decryptor); - + XReferenceResolvedListener.class, decryptor); + /* * initializes the Decryptor. */ @@ -129,11 +129,11 @@ class EncryptionEntity extends SecurityEntity args[3] = m_xXMLSecurityContext; args[4] = m_xXMLEncryption; xInitialization.initialize(args); - + /* * sets decryption result listener. */ - XDecryptionResultBroadcaster m_xDecryptionResultBroadcaster = + XDecryptionResultBroadcaster m_xDecryptionResultBroadcaster = (XDecryptionResultBroadcaster)UnoRuntime.queryInterface( XDecryptionResultBroadcaster.class, m_xReferenceResolvedListener); m_xDecryptionResultBroadcaster.addDecryptionResultListener( @@ -145,13 +145,13 @@ class EncryptionEntity extends SecurityEntity e.printStackTrace(); } } - + /* * creates a Blocker. */ int blockerId = m_xSAXEventKeeper.addBlocker(); m_xSAXEventKeeper.setSecurityId(blockerId, m_nSecurityId); - + try { XBlockerMonitor xBlockerMonitor = (XBlockerMonitor)UnoRuntime.queryInterface( @@ -166,12 +166,12 @@ class EncryptionEntity extends SecurityEntity /* * configures the resolve listener for the encryption template. */ - XReferenceResolvedBroadcaster xReferenceResolvedBroadcaster = + XReferenceResolvedBroadcaster xReferenceResolvedBroadcaster = (XReferenceResolvedBroadcaster)UnoRuntime.queryInterface( XReferenceResolvedBroadcaster.class, m_xSAXEventKeeper); xReferenceResolvedBroadcaster.addReferenceResolvedListener(m_nEncryptionElementCollectorId, m_xReferenceResolvedListener); } - + /* * add the reference to this encryption. * @@ -185,23 +185,23 @@ class EncryptionEntity extends SecurityEntity protected boolean setReference(boolean isExporting) { boolean rc = false; - + int referenceId = m_xSAXEventKeeper.addSecurityElementCollector( isExporting? (ElementMarkPriority.AFTERMODIFY):(ElementMarkPriority.BEFOREMODIFY), true); - + m_xSAXEventKeeper.setSecurityId(referenceId, m_nSecurityId); - XReferenceResolvedBroadcaster xReferenceResolvedBroadcaster = + XReferenceResolvedBroadcaster xReferenceResolvedBroadcaster = (XReferenceResolvedBroadcaster)UnoRuntime.queryInterface( XReferenceResolvedBroadcaster.class, m_xSAXEventKeeper); xReferenceResolvedBroadcaster.addReferenceResolvedListener( referenceId, m_xReferenceResolvedListener); - + try { - XReferenceCollector xReferenceCollector = + XReferenceCollector xReferenceCollector = (XReferenceCollector)UnoRuntime.queryInterface( XReferenceCollector.class, m_xReferenceResolvedListener); xReferenceCollector.setReferenceId(referenceId); @@ -211,7 +211,7 @@ class EncryptionEntity extends SecurityEntity e.printStackTrace(); rc = false; } - + return rc; } } diff --git a/xmlsecurity/tools/uno/ParsingThread.java b/xmlsecurity/tools/uno/ParsingThread.java index f4bfea4a442e..adffbb271979 100644 --- a/xmlsecurity/tools/uno/ParsingThread.java +++ b/xmlsecurity/tools/uno/ParsingThread.java @@ -1,7 +1,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 @@ -41,33 +41,33 @@ class ParsingThread * the Node which will be handled with in the next step */ private Node m_node; - + /* * the event to be handled in the next step. * true means endElement event, false otherwise. */ private boolean m_bIsEndEvent; - + /* * the document handler which receives generated SAX events */ private XDocumentHandler m_xDocumentHandler; - + /* * the TestTool which receives UI feedbacks */ private TestTool m_testTool; - - - ParsingThread(Node node, XDocumentHandler xDocumentHandler, TestTool testTool) + + + ParsingThread(Node node, XDocumentHandler xDocumentHandler, TestTool testTool) { m_node = node; m_xDocumentHandler = xDocumentHandler; m_testTool = testTool; - + m_bIsEndEvent = false; } - + /* * changes the document handler. */ @@ -75,7 +75,7 @@ class ParsingThread { this.m_xDocumentHandler = xDocumentHandler; } - + /* * sends the next SAX event. * when there is no further step, then false is returned, @@ -84,7 +84,7 @@ class ParsingThread protected boolean nextStep() { boolean rc = true; - + try { String message; @@ -103,11 +103,11 @@ class ParsingThread break; case Node.ELEMENT_NODE: /* startElement */ String nodeName = m_node.getNodeName(); - message = "startElement:"+nodeName; + message = "startElement:"+nodeName; NamedNodeMap attrs = m_node.getAttributes(); - + AttributeListHelper attributeListHelper = new AttributeListHelper(); - + int length = attrs.getLength(); for (int i=0; i<length; ++i) { @@ -115,10 +115,10 @@ class ParsingThread attributeListHelper.setAttribute(attr.getName(), "CDATA", attr.getValue()); message += " "+attr.getName()+"='"+attr.getValue()+"'"; } - + m_testTool.updatesCurrentSAXEventInformation(message); m_xDocumentHandler.startElement(m_node.getNodeName(), attributeListHelper); - + m_testTool.updatesUIs(); break; case Node.TEXT_NODE: /* characters */ @@ -138,16 +138,16 @@ class ParsingThread m_testTool.updatesUIs(); break; } - + /* * figures out the event for the next step. */ - switch (type) + switch (type) { - case Node.DOCUMENT_NODE: + case Node.DOCUMENT_NODE: case Node.ELEMENT_NODE: - if (m_node.hasChildNodes()) - /* + if (m_node.hasChildNodes()) + /* * for a Document node or an Element node, * if the node has children, then the next event will be for its * first child node. @@ -155,27 +155,27 @@ class ParsingThread { m_node = m_node.getFirstChild(); } - else + else /* * otherwise, the next event will be endElement. */ { - m_bIsEndEvent = true; + m_bIsEndEvent = true; } - break; + break; case Node.TEXT_NODE: case Node.PROCESSING_INSTRUCTION_NODE: - case Node.COMMENT_NODE: + case Node.COMMENT_NODE: Node nextNode = m_node.getNextSibling(); - if (nextNode != null) + if (nextNode != null) /* * for other kinds of node, * if it has a next sibling, then the next event will be for that * sibling. */ { - m_node = nextNode; - } + m_node = nextNode; + } else /* * otherwise, the next event will be the endElement for the node's @@ -183,9 +183,9 @@ class ParsingThread */ { m_node = m_node.getParentNode(); - m_bIsEndEvent = true; + m_bIsEndEvent = true; } - break; + break; } } else @@ -196,20 +196,20 @@ class ParsingThread switch (type) { case Node.DOCUMENT_NODE: /* endDocument */ - m_testTool.updatesCurrentSAXEventInformation("endDocument"); - m_xDocumentHandler.endDocument(); + m_testTool.updatesCurrentSAXEventInformation("endDocument"); + m_xDocumentHandler.endDocument(); m_testTool.updatesUIs(); - + /* * no further steps. */ rc = false; break; case Node.ELEMENT_NODE: /* endElement */ - m_testTool.updatesCurrentSAXEventInformation("endElement:"+m_node.getNodeName()); - m_xDocumentHandler.endElement(m_node.getNodeName()); + m_testTool.updatesCurrentSAXEventInformation("endElement:"+m_node.getNodeName()); + m_xDocumentHandler.endElement(m_node.getNodeName()); m_testTool.updatesUIs(); - + Node nextNode = m_node.getNextSibling(); if (nextNode != null) /* @@ -235,13 +235,13 @@ class ParsingThread catch( com.sun.star.xml.sax.SAXException e) { e.printStackTrace(); - + /* * forces to end. */ rc = false; } - + return rc; } } diff --git a/xmlsecurity/tools/uno/SAXEventCollector.java b/xmlsecurity/tools/uno/SAXEventCollector.java index e94c55252083..cb796515bcb1 100644 --- a/xmlsecurity/tools/uno/SAXEventCollector.java +++ b/xmlsecurity/tools/uno/SAXEventCollector.java @@ -1,7 +1,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 @@ -27,10 +27,10 @@ package com.sun.star.xml.security.uno; -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; - + import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; @@ -51,73 +51,73 @@ class SAXEventCollector implements XDocumentHandler * the document which keeps received SAX events */ private Document m_document; - + /* * the current Element to which the next received * SAX event will be added. */ private Node m_currentElement; - + /* * the TestTool which receives UI feedbacks */ private TestTool m_testTool; - + /* * whether displays information on console. */ private boolean m_systemDisplay; - + SAXEventCollector(TestTool testTool) { this(testTool, false); } - + SAXEventCollector(TestTool testTool, boolean sysDis) { m_systemDisplay = sysDis; m_testTool = testTool; - + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); - - try + + try { DocumentBuilder builder = factory.newDocumentBuilder(); m_document = builder.newDocument(); - + m_currentElement = m_document; } catch (ParserConfigurationException pce) { pce.printStackTrace(); } } - + protected Document getDocument() { return m_document; } - + protected Node getCurrentElement() { return m_currentElement; } - + /* * XDocumentHandler */ - public void startDocument () + public void startDocument () { } - + public void endDocument() { } - + public void startElement (String str, com.sun.star.xml.sax.XAttributeList xattribs) { Element newElement = m_document.createElement(str); - + if (xattribs !=null) { int length = xattribs.getLength(); @@ -128,15 +128,15 @@ class SAXEventCollector implements XDocumentHandler xattribs.getValueByIndex(i)); } } - + if (m_systemDisplay) { System.out.println("startElement:"+m_currentElement.toString()); } - + m_currentElement.appendChild(newElement); m_currentElement = newElement; - + if (m_testTool != null) { m_testTool.updatesUIs(); @@ -149,19 +149,19 @@ class SAXEventCollector implements XDocumentHandler { System.out.println("endElement:"+str+" "+m_currentElement.toString()); } - + m_currentElement = m_currentElement.getParentNode(); if (m_systemDisplay) { System.out.println("----> "+m_currentElement.toString()); } - + if (m_testTool != null) { m_testTool.updatesUIs(); } } - + public void characters(String str) { Text newText = m_document.createTextNode(str); @@ -171,14 +171,14 @@ class SAXEventCollector implements XDocumentHandler m_testTool.updatesUIs(); } } - + public void ignorableWhitespace(String str) { } - + public void processingInstruction(String aTarget, String aData) { - ProcessingInstruction newPI + ProcessingInstruction newPI = m_document.createProcessingInstruction(aTarget, aData); m_currentElement.appendChild(newPI); if (m_testTool != null) @@ -187,7 +187,7 @@ class SAXEventCollector implements XDocumentHandler } } - public void setDocumentLocator (com.sun.star.xml.sax.XLocator xLocator ) + public void setDocumentLocator (com.sun.star.xml.sax.XLocator xLocator ) throws com.sun.star.xml.sax.SAXException { } diff --git a/xmlsecurity/tools/uno/SAXEventPrinter.java b/xmlsecurity/tools/uno/SAXEventPrinter.java index d841926bdd13..7dc518a3f731 100644 --- a/xmlsecurity/tools/uno/SAXEventPrinter.java +++ b/xmlsecurity/tools/uno/SAXEventPrinter.java @@ -1,7 +1,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 @@ -48,25 +48,25 @@ class SAXEventPrinter implements XDocumentHandler * how many spaces as the indent of line */ private int m_nIndent; - + /* - * whether a NEW LINE character need to be appended to + * whether a NEW LINE character need to be appended to * each line */ private boolean m_bIsFormatted; - + /* * the output stream to write */ private FileOutputStream m_fileOutputStream; - + SAXEventPrinter(FileOutputStream fileOutputStream, boolean isFormatted) { m_nIndent = 0; m_fileOutputStream = fileOutputStream; m_bIsFormatted = isFormatted; } - + protected static void outputIndent(int m_nIndent, FileOutputStream fileOutputStream) throws IOException { @@ -75,7 +75,7 @@ class SAXEventPrinter implements XDocumentHandler fileOutputStream.write(" ".getBytes()); } } - + /* * displays the tree of a Node. */ @@ -88,67 +88,67 @@ class SAXEventPrinter implements XDocumentHandler String message; NodeList children; int i, length; - + switch (type) { case Node.DOCUMENT_NODE: children = node.getChildNodes(); - length = children.getLength(); + length = children.getLength(); for (i=0; i<length; ++i) { display(children.item(i), indent+2, fileOutputStream, isFormatted); } - + break; - + case Node.ELEMENT_NODE: message = new String("<"+node.getNodeName()); NamedNodeMap attrs = node.getAttributes(); - + length = attrs.getLength(); for (i=0; i<length; ++i) { Attr attr = (Attr)attrs.item(i); message += " "+attr.getNodeName()+"=\""+attr.getNodeValue()+"\""; } - + message += ">"; - + if (isFormatted) { outputIndent(indent, fileOutputStream); } - + fileOutputStream.write(message.getBytes("UTF-8")); - + if (isFormatted) { fileOutputStream.write("\n".getBytes()); } - + children = node.getChildNodes(); length = children.getLength(); for (i=0; i<length; ++i) { display(children.item(i), indent+2, fileOutputStream, isFormatted); } - + if (isFormatted) { outputIndent(indent, fileOutputStream); } - + fileOutputStream.write("</".getBytes()); fileOutputStream.write(node.getNodeName().getBytes("UTF-8")); fileOutputStream.write(">".getBytes()); - + if (isFormatted) { fileOutputStream.write("\n".getBytes()); } - + break; - + case Node.TEXT_NODE: message = node.getNodeValue(); if (message != null ) @@ -157,32 +157,32 @@ class SAXEventPrinter implements XDocumentHandler { outputIndent(indent, fileOutputStream); } - + fileOutputStream.write(node.getNodeValue().getBytes("UTF-8")); - + if (isFormatted) { fileOutputStream.write("\n".getBytes()); } } break; - + case Node.PROCESSING_INSTRUCTION_NODE: if (isFormatted) { outputIndent(indent, fileOutputStream); } - + fileOutputStream.write("<?".getBytes()); fileOutputStream.write(node.getNodeName().getBytes("UTF-8")); fileOutputStream.write(node.getNodeValue().getBytes("UTF-8")); fileOutputStream.write("?>".getBytes()); - + if (isFormatted) { fileOutputStream.write("\n".getBytes()); } - + break; default: break; @@ -193,20 +193,20 @@ class SAXEventPrinter implements XDocumentHandler /* * XDocumentHandler */ - public void startDocument () + public void startDocument () { } - + public void endDocument() { } - + public void startElement (String str, com.sun.star.xml.sax.XAttributeList xattribs) { try { String message; - + message = new String("<"+str); if (xattribs !=null) { @@ -217,19 +217,19 @@ class SAXEventPrinter implements XDocumentHandler } } message += ">"; - + if (m_bIsFormatted) { outputIndent(m_nIndent, m_fileOutputStream); } - + m_fileOutputStream.write(message.getBytes("UTF-8")); - + if (m_bIsFormatted) { m_fileOutputStream.write("\n".getBytes()); } - + m_nIndent += 2; } catch (IOException e) @@ -247,11 +247,11 @@ class SAXEventPrinter implements XDocumentHandler { outputIndent(m_nIndent, m_fileOutputStream); } - + m_fileOutputStream.write("</".getBytes()); m_fileOutputStream.write(str.getBytes("UTF-8")); m_fileOutputStream.write(">".getBytes()); - + if (m_bIsFormatted) { m_fileOutputStream.write("\n".getBytes()); @@ -262,7 +262,7 @@ class SAXEventPrinter implements XDocumentHandler e.printStackTrace(); } } - + public void characters(String str) { try @@ -271,9 +271,9 @@ class SAXEventPrinter implements XDocumentHandler { outputIndent(m_nIndent, m_fileOutputStream); } - + m_fileOutputStream.write(str.getBytes("UTF-8")); - + if (m_bIsFormatted) { m_fileOutputStream.write("\n".getBytes()); @@ -284,11 +284,11 @@ class SAXEventPrinter implements XDocumentHandler e.printStackTrace(); } } - + public void ignorableWhitespace(String str) { } - + public void processingInstruction(String aTarget, String aData) { try @@ -297,11 +297,11 @@ class SAXEventPrinter implements XDocumentHandler { outputIndent(m_nIndent, m_fileOutputStream); } - + m_fileOutputStream.write("<?".getBytes()); m_fileOutputStream.write(aTarget.getBytes("UTF-8")); m_fileOutputStream.write("?>".getBytes()); - + if (m_bIsFormatted) { m_fileOutputStream.write("\n".getBytes()); @@ -313,7 +313,7 @@ class SAXEventPrinter implements XDocumentHandler } } - public void setDocumentLocator (com.sun.star.xml.sax.XLocator xLocator ) + public void setDocumentLocator (com.sun.star.xml.sax.XLocator xLocator ) throws com.sun.star.xml.sax.SAXException { } diff --git a/xmlsecurity/tools/uno/SecurityEntity.java b/xmlsecurity/tools/uno/SecurityEntity.java index 85ef5ed49891..8f6e66551437 100644 --- a/xmlsecurity/tools/uno/SecurityEntity.java +++ b/xmlsecurity/tools/uno/SecurityEntity.java @@ -1,7 +1,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 @@ -46,7 +46,7 @@ class SecurityEntity */ private static int m_nNextSecurityId = 1; protected int m_nSecurityId; - + /* * xml security related components */ @@ -62,7 +62,7 @@ class SecurityEntity * the uri of the key material of this security entity */ private String m_keyURI; - + SecurityEntity( XSecuritySAXEventKeeper xSAXEventKeeper, XXMLSecurityContext xXMLSecurityContext, @@ -77,7 +77,7 @@ class SecurityEntity m_xXMLEncryption = xXMLEncryption; m_xRemoteServiceManager = xRemoteServiceManager; m_xRemoteContext = xRemoteContext; - + m_nSecurityId = getNextSecurityId(); m_keyURI = null; } @@ -85,7 +85,7 @@ class SecurityEntity /************************************************************************************** * private methods **************************************************************************************/ - + /* * generates a new security id. */ @@ -98,7 +98,7 @@ class SecurityEntity /************************************************************************************** * protected methods **************************************************************************************/ - + /* * notifies the key collector about the key id, this key id * is used to ask the SAXEventKeeper to release the bufferred @@ -110,7 +110,7 @@ class SecurityEntity { try { - XKeyCollector xKeyCollector = + XKeyCollector xKeyCollector = (XKeyCollector)UnoRuntime.queryInterface( XKeyCollector.class, m_xReferenceResolvedListener); xKeyCollector.setKeyId(id); @@ -120,7 +120,7 @@ class SecurityEntity e.printStackTrace(); } } - + /* * set the key uri, which will be the value of the id attribute * of the key element @@ -129,17 +129,17 @@ class SecurityEntity { m_keyURI = new String(uri); } - + protected XReferenceResolvedListener getReferenceListener() { return m_xReferenceResolvedListener; } - + protected int getSecurityId() { return m_nSecurityId; } - + /* * configures the key material to the security entity. * @@ -154,7 +154,7 @@ class SecurityEntity protected boolean setKey(String uri, boolean isExporting) { boolean rc = false; - + if (m_keyURI != null && m_keyURI.equals(uri)) { @@ -162,40 +162,40 @@ class SecurityEntity isExporting? (ElementMarkPriority.BEFOREMODIFY):(ElementMarkPriority.AFTERMODIFY), false ); - + setKeyId(referenceId); m_xSAXEventKeeper.setSecurityId(referenceId, m_nSecurityId); - XReferenceResolvedBroadcaster xReferenceResolvedBroadcaster = + XReferenceResolvedBroadcaster xReferenceResolvedBroadcaster = (XReferenceResolvedBroadcaster)UnoRuntime.queryInterface( XReferenceResolvedBroadcaster.class, m_xSAXEventKeeper); - + xReferenceResolvedBroadcaster.addReferenceResolvedListener(referenceId, m_xReferenceResolvedListener); - + rc = true; } - + return rc; } - + /* * ends this misstion, asks the security engine to clear up all * resources. */ protected boolean endMission() { - XMissionTaker xMissionTaker = + XMissionTaker xMissionTaker = (XMissionTaker)UnoRuntime.queryInterface( XMissionTaker.class, m_xReferenceResolvedListener); - + boolean rc = xMissionTaker.endMission(); - + m_xXMLSecurityContext = null; m_xXMLSignature = null; m_xXMLEncryption = null; m_xReferenceResolvedListener = null; m_xSAXEventKeeper = null; - + return rc; } } diff --git a/xmlsecurity/tools/uno/SignatureEntity.java b/xmlsecurity/tools/uno/SignatureEntity.java index d02ad3ee74d7..da69beeb4407 100644 --- a/xmlsecurity/tools/uno/SignatureEntity.java +++ b/xmlsecurity/tools/uno/SignatureEntity.java @@ -1,7 +1,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 @@ -37,7 +37,7 @@ import com.sun.star.uno.XComponentContext; import com.sun.star.xml.crypto.*; import com.sun.star.xml.crypto.sax.*; - + /* * this class maintains the data for a signature operation. */ @@ -45,10 +45,10 @@ class SignatureEntity extends SecurityEntity { private Vector m_vReferenceIds; private int m_nSignatureElementCollectorId; - + SignatureEntity( XSecuritySAXEventKeeper xSAXEventKeeper, - boolean isExporting, + boolean isExporting, Object resultListener, XXMLSecurityContext xXMLSecurityContext, XXMLSignature xXMLSignature, @@ -58,9 +58,9 @@ class SignatureEntity extends SecurityEntity { super(xSAXEventKeeper, xXMLSecurityContext, xXMLSignature, xXMLEncryption, xRemoteServiceManager, xRemoteContext); - + m_vReferenceIds = new Vector(); - + if (isExporting) { m_nSignatureElementCollectorId = m_xSAXEventKeeper.addSecurityElementCollector( @@ -70,24 +70,24 @@ class SignatureEntity extends SecurityEntity m_xSAXEventKeeper.setSecurityId(m_nSignatureElementCollectorId, m_nSecurityId); try - { + { /* * creates a SignatureCreator. */ Object signatureCreator = m_xRemoteServiceManager.createInstanceWithContext( TestTool.SIGNATURECREATOR_COMPONENT, m_xRemoteContext); - - m_xReferenceResolvedListener = + + m_xReferenceResolvedListener = (XReferenceResolvedListener)UnoRuntime.queryInterface( - XReferenceResolvedListener.class, signatureCreator); - + XReferenceResolvedListener.class, signatureCreator); + /* * initializes the SignatureCreator. */ - XInitialization xInitialization = + XInitialization xInitialization = (XInitialization)UnoRuntime.queryInterface( XInitialization.class, m_xReferenceResolvedListener); - + Object args[]=new Object[5]; args[0] = new Integer(m_nSecurityId).toString(); args[1] = m_xSAXEventKeeper; @@ -95,21 +95,21 @@ class SignatureEntity extends SecurityEntity args[3] = m_xXMLSecurityContext.getSecurityEnvironment(); args[4] = m_xXMLSignature; xInitialization.initialize(args); - + /* * creates a Blocker. */ int blockerId = m_xSAXEventKeeper.addBlocker(); m_xSAXEventKeeper.setSecurityId(blockerId, m_nSecurityId); - + XBlockerMonitor xBlockerMonitor = (XBlockerMonitor)UnoRuntime.queryInterface( XBlockerMonitor.class, m_xReferenceResolvedListener); xBlockerMonitor.setBlockerId(blockerId); - + /* * sets signature creation result listener. */ - XSignatureCreationResultBroadcaster xSignatureCreationResultBroadcaster = + XSignatureCreationResultBroadcaster xSignatureCreationResultBroadcaster = (XSignatureCreationResultBroadcaster)UnoRuntime.queryInterface( XSignatureCreationResultBroadcaster.class, m_xReferenceResolvedListener); xSignatureCreationResultBroadcaster.addSignatureCreationResultListener( @@ -120,15 +120,15 @@ class SignatureEntity extends SecurityEntity { e.printStackTrace(); } - + } else { m_nSignatureElementCollectorId = m_xSAXEventKeeper.addSecurityElementCollector( ElementMarkPriority.BEFOREMODIFY, false); - + m_xSAXEventKeeper.setSecurityId(m_nSignatureElementCollectorId, m_nSecurityId); - + try { /* @@ -136,15 +136,15 @@ class SignatureEntity extends SecurityEntity */ Object signatureVerifier = m_xRemoteServiceManager.createInstanceWithContext( TestTool.SIGNATUREVERIFIER_COMPONENT, m_xRemoteContext); - - m_xReferenceResolvedListener = + + m_xReferenceResolvedListener = (XReferenceResolvedListener)UnoRuntime.queryInterface( - XReferenceResolvedListener.class, signatureVerifier); - + XReferenceResolvedListener.class, signatureVerifier); + /* * initializes the SignatureVerifier. */ - XInitialization xInitialization = + XInitialization xInitialization = (XInitialization)UnoRuntime.queryInterface( XInitialization.class, m_xReferenceResolvedListener); Object args[]=new Object[5]; @@ -154,11 +154,11 @@ class SignatureEntity extends SecurityEntity args[3] = m_xXMLSecurityContext; args[4] = m_xXMLSignature; xInitialization.initialize(args); - + /* * sets signature verify result listener. */ - XSignatureVerifyResultBroadcaster xSignatureVerifyResultBroadcaster = + XSignatureVerifyResultBroadcaster xSignatureVerifyResultBroadcaster = (XSignatureVerifyResultBroadcaster)UnoRuntime.queryInterface( XSignatureVerifyResultBroadcaster.class, m_xReferenceResolvedListener); xSignatureVerifyResultBroadcaster.addSignatureVerifyResultListener( @@ -174,7 +174,7 @@ class SignatureEntity extends SecurityEntity /* * configures the resolve listener for the signature template. */ - XReferenceResolvedBroadcaster xReferenceResolvedBroadcaster = + XReferenceResolvedBroadcaster xReferenceResolvedBroadcaster = (XReferenceResolvedBroadcaster)UnoRuntime.queryInterface( XReferenceResolvedBroadcaster.class, m_xSAXEventKeeper); xReferenceResolvedBroadcaster.addReferenceResolvedListener( @@ -192,7 +192,7 @@ class SignatureEntity extends SecurityEntity private boolean hasReference(String id) { boolean rc = false; - + int length = m_vReferenceIds.size(); for (int i=0; i<length; ++i) { @@ -202,15 +202,15 @@ class SignatureEntity extends SecurityEntity break; } } - + return rc; } - + /************************************************************************************** * protected methods **************************************************************************************/ - + /* * adds a new reference id. */ @@ -218,7 +218,7 @@ class SignatureEntity extends SecurityEntity { m_vReferenceIds.add(referenceId); } - + /* * notifies how many reference in this signature. */ @@ -226,7 +226,7 @@ class SignatureEntity extends SecurityEntity { try { - XReferenceCollector xReferenceCollector = + XReferenceCollector xReferenceCollector = (XReferenceCollector)UnoRuntime.queryInterface( XReferenceCollector.class, m_xReferenceResolvedListener); xReferenceCollector.setReferenceCount(m_vReferenceIds.size()); @@ -236,7 +236,7 @@ class SignatureEntity extends SecurityEntity e.printStackTrace(); } } - + /* * tries to add a reference to this signature. * @@ -251,25 +251,25 @@ class SignatureEntity extends SecurityEntity protected boolean setReference(String id, boolean isExporting) { boolean rc = false; - + if (hasReference(id)) { int referenceId = m_xSAXEventKeeper.addSecurityElementCollector( isExporting? (ElementMarkPriority.AFTERMODIFY):(ElementMarkPriority.BEFOREMODIFY), false ); - + m_xSAXEventKeeper.setSecurityId(referenceId, m_nSecurityId); - XReferenceResolvedBroadcaster xReferenceResolvedBroadcaster = + XReferenceResolvedBroadcaster xReferenceResolvedBroadcaster = (XReferenceResolvedBroadcaster)UnoRuntime.queryInterface( XReferenceResolvedBroadcaster.class, m_xSAXEventKeeper); xReferenceResolvedBroadcaster.addReferenceResolvedListener( referenceId, m_xReferenceResolvedListener); - + try { - XReferenceCollector xReferenceCollector = + XReferenceCollector xReferenceCollector = (XReferenceCollector)UnoRuntime.queryInterface( XReferenceCollector.class, m_xReferenceResolvedListener); xReferenceCollector.setReferenceId(referenceId); @@ -278,7 +278,7 @@ class SignatureEntity extends SecurityEntity { e.printStackTrace(); } - + rc = true; } diff --git a/xmlsecurity/tools/uno/TestTool.java b/xmlsecurity/tools/uno/TestTool.java index 6c87b34bbb43..4be3370f59f6 100644 --- a/xmlsecurity/tools/uno/TestTool.java +++ b/xmlsecurity/tools/uno/TestTool.java @@ -1,7 +1,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 @@ -27,8 +27,8 @@ package com.sun.star.xml.security.uno; -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import java.io.File; @@ -93,7 +93,7 @@ import com.sun.star.xml.sax.XDocumentHandler; import com.sun.star.xml.crypto.*; import com.sun.star.xml.crypto.sax.*; - + public class TestTool extends JFrame implements ActionListener { /* @@ -104,7 +104,7 @@ public class TestTool extends JFrame implements ActionListener public static String ENCRYPTOR_COMPONENT = "com.sun.star.xml.crypto.sax.Encryptor"; public static String DECRYPTOR_COMPONENT = "com.sun.star.xml.crypto.sax.Decryptor"; public static String SAXEVENTKEEPER_COMPONENT = "com.sun.star.xml.crypto.sax.SAXEventKeeper"; - + /* * Java-based component names */ @@ -112,7 +112,7 @@ public class TestTool extends JFrame implements ActionListener public static String XMLSIGNATURE_COMPONENT_JAVA = "com.sun.star.xml.security.bridge.jxsec.XMLSignature_JxsecImpl"; public static String XMLENCRYPTION_COMPONENT_JAVA = "com.sun.star.xml.security.bridge.jxsec.XMLEncryption_JxsecImpl"; public static String XMLDOCUMENTWRAPPER_COMPONENT_JAVA = "com.sun.star.xml.security.bridge.jxsec.XMLDocumentWrapper_JxsecImpl"; - + /* * C-based component names */ @@ -120,19 +120,19 @@ public class TestTool extends JFrame implements ActionListener public static String XMLSIGNATURE_COMPONENT_C = "com.sun.star.xml.crypto.XMLSignature"; public static String XMLENCRYPTION_COMPONENT_C = "com.sun.star.xml.crypto.XMLEncryption"; public static String XMLDOCUMENTWRAPPER_COMPONENT_C = "com.sun.star.xml.wrapper.XMLDocumentWrapper"; - + /* url resolver name */ public static String UNOURLRESOLVER = "com.sun.star.bridge.UnoUrlResolver"; - + /* * connection URL */ private String m_unoURL = "uno:socket,host=localhost,port=2002;urp;StarOffice.ServiceManager"; - + /* key file */ private String m_javaTokenFile = null; private String m_nssTokenPath = null; - + /* User Interfaces */ private JButton m_goButton; private JButton m_stepButton; @@ -151,21 +151,21 @@ public class TestTool extends JFrame implements ActionListener private JLabel m_saxChainLabel; private JTextField m_saxEventText; private JTable m_unsolvedReferenceTable; - + /* - * whether a batch file is running, - * if so, no message box is popped up + * whether a batch file is running, + * if so, no message box is popped up */ private boolean m_bIsBatchRunning = false; - - /* + + /* * whether the UI needs to be updated. * when user click the "go" button, the UI needs * not to be updated step by step for performance * reason */ private boolean m_bIsUIUpdateSuppressed = false; - + /* * three DOM tree adapter */ @@ -174,33 +174,33 @@ public class TestTool extends JFrame implements ActionListener private DomToTreeModelAdapter m_rightTreeModelAdapter; /* - * the current directory, which reserves the default + * the current directory, which reserves the default * location when user open/save a file. */ private File m_currentDirectory = null; - + /* * the log file */ private FileOutputStream m_logFileOutputStream = null; - + /* * the thread which is parsing the current XML * file */ private ParsingThread m_parsingThread; - + /* * whether is exporting or importing */ private boolean m_bIsExporting; - + /* * whether java based component or c based component * is used now */ private boolean m_bIsJavaBased; - + /* * XML security component interface */ @@ -221,10 +221,10 @@ public class TestTool extends JFrame implements ActionListener * security framework controller */ private XMLSecurityFrameworkController m_xmlSecurityFrameworkController = null; - + /* org.w3c.dom.Document */ private Document m_document; - + /* represents whether "Go" or "Step" */ private boolean stepMode = true; @@ -245,55 +245,55 @@ public class TestTool extends JFrame implements ActionListener m_leftTreeModelAdapter = new DomToTreeModelAdapter(m_document); m_middleTreeModelAdapter = new DomToTreeModelAdapter(m_document); m_rightTreeModelAdapter = new DomToTreeModelAdapter(m_document); - + m_parsingThread = null; - + m_leftTree.setModel(m_leftTreeModelAdapter); m_middleTree.setModel(m_middleTreeModelAdapter); m_rightTree.setModel(m_rightTreeModelAdapter); } - + /* * constructs the user interface. */ private Container buildUI(int width, int height) { JPanel mainPanel = new JPanel(); - + int frameHeight = height-40; int leftWindowWidth = (width-40)/3; int middleWindowWidth = leftWindowWidth; int rightWindowWidth = leftWindowWidth; int leftPaneWidth = leftWindowWidth+middleWindowWidth; int frameWidth = leftPaneWidth + rightWindowWidth; - + /* Make a nice border */ EmptyBorder emptyBorder = new EmptyBorder(5,5,5,5); BevelBorder bevelBorder = new BevelBorder(BevelBorder.LOWERED); CompoundBorder compoundBorder = new CompoundBorder(emptyBorder,bevelBorder); mainPanel.setBorder(new CompoundBorder(compoundBorder,emptyBorder)); - + /* Set up the tree */ m_leftTreeModelAdapter = new DomToTreeModelAdapter(m_document); m_middleTreeModelAdapter = new DomToTreeModelAdapter(m_document); m_rightTreeModelAdapter = new DomToTreeModelAdapter(m_document); - + m_leftTree = new JTree(m_leftTreeModelAdapter); m_leftTextArea = new JTextArea(); m_middleTree = new JTree(m_middleTreeModelAdapter); m_rightTree = new JTree(m_rightTreeModelAdapter); - + ToolTipManager.sharedInstance().registerComponent(m_leftTree); ToolTipManager.sharedInstance().registerComponent(m_middleTree); ToolTipManager.sharedInstance().registerComponent(m_rightTree); - + /* Builds left tab pane */ JScrollPane leftTreePane = new JScrollPane(m_leftTree); JScrollPane leftTextPane = new JScrollPane(m_leftTextArea); m_leftTabPane= new JTabbedPane(); m_leftTabPane.add("Tree View",leftTreePane); m_leftTabPane.add("Text View",leftTextPane); - + /* Builds middle tree pane */ JScrollPane middleTreePane = new JScrollPane(m_middleTree); @@ -302,17 +302,17 @@ public class TestTool extends JFrame implements ActionListener rightTreePane.setBorder(BorderFactory.createCompoundBorder( BorderFactory.createTitledBorder("Result"), BorderFactory.createEmptyBorder(8,8,8,8))); - - m_leftTabPane.setPreferredSize( + + m_leftTabPane.setPreferredSize( new Dimension( leftWindowWidth, frameHeight )); - middleTreePane.setPreferredSize( + middleTreePane.setPreferredSize( new Dimension( middleWindowWidth, frameHeight )); - rightTreePane.setPreferredSize( + rightTreePane.setPreferredSize( new Dimension( rightWindowWidth, frameHeight )); /* Builds the SAX event text box */ m_saxEventText = new JTextField(); - + /* Builds the unsolved reference table */ m_unsolvedReferenceTable = new JTable( new UnsolvedReferenceTableModel(this)); @@ -322,93 +322,93 @@ public class TestTool extends JFrame implements ActionListener /* Builds the SAX chain information label */ m_saxChainLabel = new JLabel(); - + /* Builds the left pane */ JPanel tabPaneWithSaxEventPane = new JPanel(); tabPaneWithSaxEventPane.setLayout(new BorderLayout()); tabPaneWithSaxEventPane.add("Center",m_leftTabPane); tabPaneWithSaxEventPane.add("South",new JScrollPane(m_saxEventText)); - - JSplitPane leftPane = + + JSplitPane leftPane = new JSplitPane( JSplitPane.VERTICAL_SPLIT, tabPaneWithSaxEventPane, new JScrollPane(m_unsolvedReferenceTable)); leftPane.setBorder(BorderFactory.createCompoundBorder( BorderFactory.createTitledBorder("Original"), BorderFactory.createEmptyBorder(8,8,8,8))); - + leftPane.setContinuousLayout( true ); leftPane.setDividerLocation( frameHeight*2/3 ); - leftPane.setPreferredSize( + leftPane.setPreferredSize( new Dimension( leftWindowWidth, frameHeight )); - + /* Builds the middle pane */ JPanel bufferNodeWithSaxChainPane = new JPanel(); bufferNodeWithSaxChainPane.setLayout(new BorderLayout()); bufferNodeWithSaxChainPane.add("Center",m_bufferNodeTextArea); bufferNodeWithSaxChainPane.add("South",new JScrollPane(m_saxChainLabel)); - - JSplitPane middlePane = + + JSplitPane middlePane = new JSplitPane( JSplitPane.VERTICAL_SPLIT, middleTreePane, new JScrollPane(bufferNodeWithSaxChainPane)); - + middlePane.setBorder(BorderFactory.createCompoundBorder( BorderFactory.createTitledBorder("Insight SAXEventKeeper"), BorderFactory.createEmptyBorder(8,8,8,8))); - + middlePane.setContinuousLayout( true ); middlePane.setDividerLocation( frameHeight/2+5 ); - middlePane.setPreferredSize( + middlePane.setPreferredSize( new Dimension( middleWindowWidth, frameHeight )); /* Builds the whole frame pane */ - JSplitPane leftWithMiddlePane = + JSplitPane leftWithMiddlePane = new JSplitPane( JSplitPane.HORIZONTAL_SPLIT, leftPane, middlePane ); leftWithMiddlePane.setContinuousLayout( true ); leftWithMiddlePane.setDividerLocation( leftWindowWidth ); - leftWithMiddlePane.setPreferredSize( + leftWithMiddlePane.setPreferredSize( new Dimension( leftPaneWidth + 10, frameHeight+10 )); - - JSplitPane framePane = + + JSplitPane framePane = new JSplitPane( JSplitPane.HORIZONTAL_SPLIT, leftWithMiddlePane, rightTreePane ); - - + + framePane.setContinuousLayout( true ); framePane.setDividerLocation(leftPaneWidth+10 ); - framePane.setPreferredSize( + framePane.setPreferredSize( new Dimension( frameWidth + 20, frameHeight+10 )); - + /* Adds all GUI components to the main panel */ mainPanel.setLayout(new BorderLayout()); mainPanel.add("Center", framePane ); - + m_openButton = new JButton("Open..."); m_openButton.addActionListener(this); - + m_goButton = new JButton("Go!"); m_goButton.addActionListener(this); - + m_stepButton = new JButton("Step"); m_stepButton.addActionListener(this); - + m_startButton = new JButton("Start"); m_startButton.addActionListener(this); m_startButton.setEnabled(false); - + m_isExportingButton = new JCheckBox("export, not import", true); m_isJavaComponentButton = new JCheckBox("use java component", false); - + m_saveButton = new JButton("Save..."); m_saveButton.addActionListener(this); m_batchButton = new JButton("Batch..."); m_batchButton.addActionListener(this); - + JPanel buttonPanel = new JPanel(); buttonPanel.add(m_batchButton); buttonPanel.add(m_openButton); @@ -418,11 +418,11 @@ public class TestTool extends JFrame implements ActionListener buttonPanel.add(m_isExportingButton); buttonPanel.add(m_isJavaComponentButton); buttonPanel.add(m_saveButton); - + mainPanel.add("South", buttonPanel); - + enableGoButton(false); - + return mainPanel; } @@ -434,7 +434,7 @@ public class TestTool extends JFrame implements ActionListener m_goButton.setEnabled(enabled); m_stepButton.setEnabled(enabled); } - + /* * updates the unsolved reference information. */ @@ -442,7 +442,7 @@ public class TestTool extends JFrame implements ActionListener { m_unsolvedReferenceTable.setModel(new UnsolvedReferenceTableModel(this)); } - + /* * adjusts the view of the tree in order to make the * particular Node into the focus tree leaf. @@ -451,23 +451,23 @@ public class TestTool extends JFrame implements ActionListener { int i=0; int currentLine = 0; - + while (i<tree.getRowCount()) { TreePath treePath = tree.getPathForRow(i); tree.expandPath(treePath); - + AdapterNode adapterNode = (AdapterNode)treePath.getLastPathComponent(); - + if (node == adapterNode.getNode()) { tree.addSelectionPath(treePath); currentLine = i; } - + ++i; } - + tree.setCellRenderer(new XMLTreeCellRanderer(node)); tree.scrollRowToVisible(currentLine); } @@ -475,7 +475,7 @@ public class TestTool extends JFrame implements ActionListener /****************************************************************************** * action listener related methods. ******************************************************************************/ - + /* * reads in a document, either the document is a file or * is a text paragraph. @@ -493,7 +493,7 @@ public class TestTool extends JFrame implements ActionListener else { String text = m_leftTextArea.getText(); - + try { parseStream(new ByteArrayInputStream(text.getBytes("UTF-8"))); @@ -502,11 +502,11 @@ public class TestTool extends JFrame implements ActionListener { e.printStackTrace(); } - + m_leftTabPane.setSelectedIndex(0); } } - + /* * save the result tree to a file. */ @@ -514,10 +514,10 @@ public class TestTool extends JFrame implements ActionListener { saveFile(); } - + /* * selects a batch file to excute. - */ + */ private void openBatch() { File f = openFile(); @@ -534,21 +534,21 @@ public class TestTool extends JFrame implements ActionListener { enableGoButton(false); m_parsingThread = null; - + if (m_xmlSecurityFrameworkController != null) { m_xmlSecurityFrameworkController.endMission(); } - + updatesUIs(); - + m_xmlSecurityFrameworkController = null; freeComponents(); - + System.gc(); } - - + + /****************************************************************************** * UNO component related methods ******************************************************************************/ @@ -562,7 +562,7 @@ public class TestTool extends JFrame implements ActionListener { m_unoURL = new String(unoUrlString); } - + try { m_xRemoteServiceManager = getRemoteServiceManager(m_unoURL); @@ -572,7 +572,7 @@ public class TestTool extends JFrame implements ActionListener e.printStackTrace(); } } - + /* * creates UNO components. */ @@ -584,7 +584,7 @@ public class TestTool extends JFrame implements ActionListener String XMLSignature_comp; String XMLEncryption_comp; String tokenPath; - + if (m_bIsJavaBased) { SEInitializer_comp = SEINITIALIZER_COMPONENT_JAVA; @@ -599,24 +599,24 @@ public class TestTool extends JFrame implements ActionListener XMLEncryption_comp = XMLENCRYPTION_COMPONENT_C; tokenPath = m_nssTokenPath; } - + Object seInitializerObj = m_xRemoteServiceManager.createInstanceWithContext( SEInitializer_comp, m_xRemoteContext); - + if (seInitializerObj == null) { freeComponents(); return false; } - + m_xSEInitializer = (XSEInitializer)UnoRuntime.queryInterface( - XSEInitializer.class, seInitializerObj); - + XSEInitializer.class, seInitializerObj); + m_xXMLSecurityContext = m_xSEInitializer.createSecurityContext(tokenPath); - + Object xmlSignatureObj = m_xRemoteServiceManager.createInstanceWithContext( XMLSignature_comp, m_xRemoteContext); - + if (xmlSignatureObj == null) { freeComponents(); @@ -624,11 +624,11 @@ public class TestTool extends JFrame implements ActionListener } m_xXMLSignature = (XXMLSignature)UnoRuntime.queryInterface( - XXMLSignature.class, xmlSignatureObj); - + XXMLSignature.class, xmlSignatureObj); + Object xmlEncryptionObj = m_xRemoteServiceManager.createInstanceWithContext( XMLEncryption_comp, m_xRemoteContext); - + if (xmlEncryptionObj == null) { freeComponents(); @@ -636,8 +636,8 @@ public class TestTool extends JFrame implements ActionListener } m_xXMLEncryption = (XXMLEncryption)UnoRuntime.queryInterface( - XXMLEncryption.class, xmlEncryptionObj); - + XXMLEncryption.class, xmlEncryptionObj); + return true; } catch(Exception e) @@ -647,7 +647,7 @@ public class TestTool extends JFrame implements ActionListener return false; } } - + /* * frees UNO components. */ @@ -660,7 +660,7 @@ public class TestTool extends JFrame implements ActionListener m_xSEInitializer.freeSecurityContext(m_xXMLSecurityContext); m_xXMLSecurityContext = null; } - + m_xXMLSignature = null; m_xXMLEncryption = null; m_xSEInitializer = null; @@ -670,13 +670,13 @@ public class TestTool extends JFrame implements ActionListener e.printStackTrace(); } } - + /* * getRemoteServiceManager */ - private XMultiComponentFactory getRemoteServiceManager(String unoUrl) throws java.lang.Exception + private XMultiComponentFactory getRemoteServiceManager(String unoUrl) throws java.lang.Exception { - if (m_xRemoteContext == null) + if (m_xRemoteContext == null) { /* * First step: create local component context, get local servicemanager and @@ -692,7 +692,7 @@ public class TestTool extends JFrame implements ActionListener */ XUnoUrlResolver xUnoUrlResolver = (XUnoUrlResolver) UnoRuntime.queryInterface( XUnoUrlResolver.class, urlResolver ); - + /* * Second step: use xUrlResolver interface to import the remote StarOffice.ServiceManager, * retrieve its property DefaultContext and get the remote servicemanager @@ -706,21 +706,21 @@ public class TestTool extends JFrame implements ActionListener } return m_xRemoteContext.getServiceManager(); } - + /****************************************************************************** * XML related methods ******************************************************************************/ /* - * removes all empty text node inside the particular element + * removes all empty text node inside the particular element */ private void removeEmptyText(Node node) { int type = node.getNodeType(); NodeList children; int i; - + switch (type) { case Node.DOCUMENT_NODE: @@ -730,9 +730,9 @@ public class TestTool extends JFrame implements ActionListener { Node nextSibling = child.getNextSibling(); int childType = child.getNodeType(); - + if (childType==Node.TEXT_NODE) - { + { String message = child.getNodeValue().trim(); if (message == null || message.length()<=0) { @@ -743,7 +743,7 @@ public class TestTool extends JFrame implements ActionListener { removeEmptyText(child); } - + child = nextSibling; } break; @@ -762,22 +762,22 @@ public class TestTool extends JFrame implements ActionListener m_document = null; m_startButton.setEnabled(false); initUI(); - + /* factory.setValidating(true); */ /* factory.setNamespaceAware(true); */ - - try + + try { DocumentBuilder builder = factory.newDocumentBuilder(); m_document = builder.parse(is); m_startButton.setEnabled(true); initUI(); } - catch (ParserConfigurationException pce) + catch (ParserConfigurationException pce) { pce.printStackTrace(); } - catch (IOException ioe) + catch (IOException ioe) { ioe.printStackTrace(); } @@ -792,7 +792,7 @@ public class TestTool extends JFrame implements ActionListener /****************************************************************************** * file operation related methods ******************************************************************************/ - + /* * opens a file, and parses it into the original tree. */ @@ -810,21 +810,21 @@ public class TestTool extends JFrame implements ActionListener } } - + /* * selects a file to open */ private File openFile() { File rc = null; - + JFileChooser fileChooser= new JFileChooser(); - + fileChooser.setDialogTitle("Select File To Open"); fileChooser.setDialogType(JFileChooser.OPEN_DIALOG); - + fileChooser.setApproveButtonText("Ok"); - + if (m_currentDirectory == null) { fileChooser.rescanCurrentDirectory(); @@ -833,7 +833,7 @@ public class TestTool extends JFrame implements ActionListener { fileChooser.setCurrentDirectory(m_currentDirectory); } - + fileChooser.setFileFilter(new XMLFileFilter()); int result = fileChooser.showDialog(this,null); @@ -842,19 +842,19 @@ public class TestTool extends JFrame implements ActionListener m_currentDirectory = fileChooser.getCurrentDirectory(); rc = fileChooser.getSelectedFile(); } - + return rc; } - + private void saveFile() { JFileChooser fileChooser= new JFileChooser(); - + fileChooser.setDialogTitle("Select File To Save"); fileChooser.setDialogType(JFileChooser.SAVE_DIALOG); - + fileChooser.setApproveButtonText("Ok"); - + if (m_currentDirectory == null) { fileChooser.rescanCurrentDirectory(); @@ -863,7 +863,7 @@ public class TestTool extends JFrame implements ActionListener { fileChooser.setCurrentDirectory(m_currentDirectory); } - + fileChooser.setFileFilter(new XMLFileFilter()); int result = fileChooser.showDialog(this,null); @@ -888,20 +888,20 @@ public class TestTool extends JFrame implements ActionListener private void runBatch(File f) { FileInputStream fis = null; - + try { fis = new FileInputStream(f); StringBuffer commandBuffer = new StringBuffer(); - + m_logFileOutputStream = new FileOutputStream("TestTool-log.txt"); m_bIsBatchRunning = true; int ch = 0; - + while (ch != -1) { ch = fis.read(); - + if (ch != 0x0a && ch != -1) { if (ch != 0x0d) @@ -943,7 +943,7 @@ public class TestTool extends JFrame implements ActionListener { m_isExportingButton.setSelected(false); } - + startsUp(); if (m_parsingThread != null) { @@ -957,7 +957,7 @@ public class TestTool extends JFrame implements ActionListener System.out.println("exception happen during batch:"+e); e.printStackTrace(); } - + m_bIsUIUpdateSuppressed = false; updatesUIs(); } @@ -970,15 +970,15 @@ public class TestTool extends JFrame implements ActionListener saveFile(new File(fileName)); m_logFileOutputStream.write("command end \n\n".getBytes()); } - + commandBuffer = new StringBuffer(); } } - + m_bIsBatchRunning = false; m_logFileOutputStream.close(); m_logFileOutputStream = null; - + fis.close(); fis = null; } @@ -1007,7 +1007,7 @@ public class TestTool extends JFrame implements ActionListener /****************************************************************************** * others ******************************************************************************/ - + /* * starts up the operation. */ @@ -1017,20 +1017,20 @@ public class TestTool extends JFrame implements ActionListener { m_parsingThread = null; } - + m_bIsExporting = m_isExportingButton.isSelected(); m_bIsJavaBased = m_isJavaComponentButton.isSelected(); - + if (createComponents()) { m_rightTreeEventCollector = new SAXEventCollector(this); - + m_parsingThread = new ParsingThread( m_document, null, this); - - m_xmlSecurityFrameworkController = + + m_xmlSecurityFrameworkController = new XMLSecurityFrameworkController( this, m_bIsExporting, @@ -1042,7 +1042,7 @@ public class TestTool extends JFrame implements ActionListener m_xXMLEncryption, m_xRemoteServiceManager, m_xRemoteContext); - + enableGoButton(true); } else @@ -1050,15 +1050,15 @@ public class TestTool extends JFrame implements ActionListener showMessage("Error in creating XML Security Components!"); } } - + /************************************************************************************** * protected methods **************************************************************************************/ - + /****************************************************************************** * UI related methods ******************************************************************************/ - + /* * updates the sax chain information. */ @@ -1074,7 +1074,7 @@ public class TestTool extends JFrame implements ActionListener { m_saxEventText.setText(event); } - + /* * updates all information in the UI. */ @@ -1084,7 +1084,7 @@ public class TestTool extends JFrame implements ActionListener { m_leftTree.clearSelection(); updatesTree(null, m_leftTree); - + if (m_xmlSecurityFrameworkController != null) { String bufferNodeTreeText = m_xmlSecurityFrameworkController.getBufferNodeTreeInformation(); @@ -1097,7 +1097,7 @@ public class TestTool extends JFrame implements ActionListener { m_middleTreeEventCollector = new SAXEventCollector(null); m_xmlSecurityFrameworkController.getDocument(m_middleTreeEventCollector); - + m_middleTreeModelAdapter = new DomToTreeModelAdapter(m_middleTreeEventCollector.getDocument()); m_middleTree.setModel(m_middleTreeModelAdapter); updatesTree(null, m_middleTree); @@ -1110,18 +1110,18 @@ public class TestTool extends JFrame implements ActionListener m_middleTree.setVisible(false); m_bufferNodeTextArea.setText("No XMLImporter/XMLExporter"); } - + if (m_rightTreeEventCollector != null) { m_rightTreeModelAdapter = new DomToTreeModelAdapter((Document)m_rightTreeEventCollector.getDocument()); m_rightTree.setModel(m_rightTreeModelAdapter); updatesTree((Node)m_rightTreeEventCollector.getCurrentElement(), m_rightTree); } - + updatesUnsolvedReferencesInformation(); } } - + /* * shows a message. */ @@ -1135,7 +1135,7 @@ public class TestTool extends JFrame implements ActionListener { byte [] b = msg.getBytes(); m_logFileOutputStream.write(" ".getBytes()); - + for (int i=0; i<b.length; ++i) { m_logFileOutputStream.write(b[i]); @@ -1162,7 +1162,7 @@ public class TestTool extends JFrame implements ActionListener else { Object[] options = { "OK", "Go back to step mode" }; - if (1 == JOptionPane.showOptionDialog(this, msg, "TestTool Notification", + if (1 == JOptionPane.showOptionDialog(this, msg, "TestTool Notification", JOptionPane.DEFAULT_OPTION, JOptionPane.PLAIN_MESSAGE, null, options, options[0])) { @@ -1185,7 +1185,7 @@ public class TestTool extends JFrame implements ActionListener protected Vector getUnsolvedReferenceIds() { Vector rc; - + if (m_xmlSecurityFrameworkController == null) { rc = new Vector(); @@ -1195,10 +1195,10 @@ public class TestTool extends JFrame implements ActionListener rc = ((XMLSecurityFrameworkController)m_xmlSecurityFrameworkController). getUnsolvedReferenceIds(); } - + return rc; } - + /* * gets all unsolved reference keeper ids. * a reference keeper id is the id which the SAXEventKeeper uses @@ -1207,7 +1207,7 @@ public class TestTool extends JFrame implements ActionListener protected Vector getUnsolvedReferenceKeeperIds() { Vector rc; - + if (m_xmlSecurityFrameworkController == null) { rc = new Vector(); @@ -1217,7 +1217,7 @@ public class TestTool extends JFrame implements ActionListener rc = ((XMLSecurityFrameworkController)m_xmlSecurityFrameworkController). getUnsolvedReferenceKeeperIds(); } - + return rc; } @@ -1229,7 +1229,7 @@ public class TestTool extends JFrame implements ActionListener protected Vector getUnsolvedReferenceRefNum() { Vector rc; - + if (m_xmlSecurityFrameworkController == null) { rc = new Vector(); @@ -1239,7 +1239,7 @@ public class TestTool extends JFrame implements ActionListener rc = ((XMLSecurityFrameworkController)m_xmlSecurityFrameworkController). getUnsolvedReferenceRefNum(); } - + return rc; } @@ -1272,7 +1272,7 @@ public class TestTool extends JFrame implements ActionListener { if (stepMode) break; } - + if (!notOver) endMission(); } } @@ -1299,14 +1299,14 @@ public class TestTool extends JFrame implements ActionListener openBatch(); } } - + /* * void-consturctor method */ public TestTool() { getRootPane().putClientProperty("defeatSystemEventQueueCheck", Boolean.TRUE); - + try { m_currentDirectory = new File(System.getProperty("user.dir")); @@ -1316,7 +1316,7 @@ public class TestTool extends JFrame implements ActionListener System.out.println("getProperty error :"+e); } } - + /* * consturctor method with a specific connection URL */ @@ -1325,24 +1325,24 @@ public class TestTool extends JFrame implements ActionListener this(); m_unoURL = new String(connecturl); } - + public static void main(String argv[]) { - Dimension screenSize = + Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); - + TestTool tt; - + if (argv.length < 1) { System.out.println("Usage: java TestTool [javaTokenFile] [nssTokenPath] [xml file]?"); return; } - + boolean hasFile = false; boolean hasBatch = false; String fileName = null; - + if (argv.length >= 3) { if (argv[2].startsWith("-b")) @@ -1356,25 +1356,25 @@ public class TestTool extends JFrame implements ActionListener hasFile = true; } } - + tt = new TestTool(); tt.m_javaTokenFile = new String(argv[0]); tt.m_nssTokenPath = new String(argv[1]); tt.connectSO(null); - + /* Set up a GUI framework */ JFrame myFrame = new JFrame("XML Security Components Tester"); myFrame.addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent e) {System.exit(0);} - } + } ); - + myFrame.setContentPane(tt.buildUI(screenSize.width, screenSize.height)); myFrame.pack(); int w = screenSize.width-30; int h = screenSize.height-30; - myFrame.setLocation(screenSize.width/2 - w/2, + myFrame.setLocation(screenSize.width/2 - w/2, screenSize.height/2 - h/2); myFrame.setSize(w, h); myFrame.setVisible(true); diff --git a/xmlsecurity/tools/uno/UnsolvedReferenceTableModel.java b/xmlsecurity/tools/uno/UnsolvedReferenceTableModel.java index 21f17de8877d..a5a38c3939b3 100644 --- a/xmlsecurity/tools/uno/UnsolvedReferenceTableModel.java +++ b/xmlsecurity/tools/uno/UnsolvedReferenceTableModel.java @@ -1,7 +1,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 @@ -30,39 +30,39 @@ package com.sun.star.xml.security.uno; import javax.swing.table.AbstractTableModel; /* - * this class is used to maintain the unsolved reference + * this class is used to maintain the unsolved reference * table. */ class UnsolvedReferenceTableModel extends AbstractTableModel { - private String[] m_columnNames = {"id", + private String[] m_columnNames = {"id", "refNum", "EC's id"}; - + private TestTool m_testTool; - + UnsolvedReferenceTableModel(TestTool testTool) { m_testTool = testTool; } - - public String getColumnName(int col) - { - return m_columnNames[col].toString(); + + public String getColumnName(int col) + { + return m_columnNames[col].toString(); } - - public int getRowCount() + + public int getRowCount() { - return m_testTool.getUnsolvedReferenceIds().size(); + return m_testTool.getUnsolvedReferenceIds().size(); } - - public int getColumnCount() + + public int getColumnCount() { - return m_columnNames.length; + return m_columnNames.length; } - - public Object getValueAt(int row, int col) - { + + public Object getValueAt(int row, int col) + { if (col == 0) { return (String)m_testTool.getUnsolvedReferenceIds().elementAt(row); @@ -80,10 +80,10 @@ class UnsolvedReferenceTableModel extends AbstractTableModel return null; } } - + public boolean isCellEditable(int row, int col) { - return false; + return false; } } diff --git a/xmlsecurity/tools/uno/XMLFileFilter.java b/xmlsecurity/tools/uno/XMLFileFilter.java index b9436cacfbda..765de1fc5935 100644 --- a/xmlsecurity/tools/uno/XMLFileFilter.java +++ b/xmlsecurity/tools/uno/XMLFileFilter.java @@ -1,7 +1,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 @@ -36,31 +36,31 @@ import javax.swing.filechooser.FileFilter; */ class XMLFileFilter extends FileFilter { - public static String getExtension(File f) + public static String getExtension(File f) { String ext = null; String s = f.getName(); int i = s.lastIndexOf('.'); - + if (i > 0 && i < s.length() - 1) { ext = s.substring(i+1).toLowerCase(); } - + return ext; } - - public boolean accept(File f) + + public boolean accept(File f) { boolean rc = false; - - if (f.isDirectory()) + + if (f.isDirectory()) { rc = true; } else { String extension = getExtension(f); - if (extension != null) + if (extension != null) { if (extension.equals("xml") || extension.equals("txt")) { @@ -68,10 +68,10 @@ class XMLFileFilter extends FileFilter } } } - + return rc; } - + public String getDescription() { return "XML and batch files (.xml,.txt)"; diff --git a/xmlsecurity/tools/uno/XMLSecurityFrameworkController.java b/xmlsecurity/tools/uno/XMLSecurityFrameworkController.java index 058981b460b0..ed512ed083bc 100644 --- a/xmlsecurity/tools/uno/XMLSecurityFrameworkController.java +++ b/xmlsecurity/tools/uno/XMLSecurityFrameworkController.java @@ -1,7 +1,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 @@ -46,7 +46,7 @@ import com.sun.star.xml.wrapper.*; /* * the XMLSecurityFrameworkController class is used to controll the xml security framework. */ -public class XMLSecurityFrameworkController +public class XMLSecurityFrameworkController implements XDocumentHandler, XSignatureCreationResultListener, XSignatureVerifyResultListener, XEncryptionResultListener, XDecryptionResultListener, XSAXEventKeeperStatusChangeListener { @@ -55,7 +55,7 @@ public class XMLSecurityFrameworkController */ private XMultiComponentFactory m_xRemoteServiceManager; private XComponentContext m_xRemoteContext; - + /* * xml security related UNO components */ @@ -65,62 +65,62 @@ public class XMLSecurityFrameworkController private XXMLSecurityContext m_xXMLSecurityContext; private XXMLSignature m_xXMLSignature; private XXMLEncryption m_xXMLEncryption; - + /* * used to reserve the current SAX ancestor path */ private Stack m_currentPath; - + /* * maintains all SignatureEntities. */ private Vector m_signatureList; - + /* * maintains all EncryptionEntities. */ private Vector m_encryptionList; - + /* * maintains all unsolved reference Ids. * These ids are strings which is the value of the id attribute * of the referenced element. */ private Vector m_vUnsolvedReferenceIds; - + /* * maintains all unsolved reference keeper ids. * The keeper id is used to uniquely identify a bufferred element * by the SAXEventKeeper. */ private Vector m_vUnsolvedReferencedKeeperIds; - + /* - * maintains the left time that each unsolved reference can be + * maintains the left time that each unsolved reference can be * claimed. */ private Vector m_vUnsolvedReferenceRefNum; - + /* * whether exporting or importing */ private boolean m_bIsExporting; - + /* * whether java or c */ private boolean m_bIsJavaBased; - + /* * whether the SAXEventKeeper is blocking */ private boolean m_bIsBlocking; - + /* * whether it is collecting a bufferred element */ private boolean m_bIsInsideCollectedElement; - + /* * whether a SAXEventKeeper is in the SAX chain */ @@ -130,7 +130,7 @@ public class XMLSecurityFrameworkController * the ParsingThread used to parse the document */ private ParsingThread m_parsingThread; - + /* * the next document handler that will receives SAX events * from the parsing thread. @@ -139,18 +139,18 @@ public class XMLSecurityFrameworkController * variable will be the xOutputHandler. */ private XDocumentHandler m_xExportHandler; - + /* * the TestTool used to feedback information */ private TestTool m_testTool; - + /* * for encryption target */ private boolean m_bIsEncryptionTarget; private EncryptionEntity m_EncryptionForTarget; - + XMLSecurityFrameworkController( TestTool testTool, boolean bIsExporting, @@ -165,45 +165,45 @@ public class XMLSecurityFrameworkController { m_bIsExporting = bIsExporting; m_bIsJavaBased = bIsJavaBased; - + m_xOutputHandler = xOutputHandler; m_xXMLSecurityContext = xXMLSecurityContext; m_xXMLSignature = xXMLSignature; m_xXMLEncryption = xXMLEncryption; m_xRemoteServiceManager = xRemoteServiceManager; m_xRemoteContext = xRemoteContext; - + m_testTool = testTool; m_parsingThread = parsingThread; - + m_signatureList = new Vector(); m_encryptionList = new Vector(); - + m_vUnsolvedReferenceIds = new Vector(); m_vUnsolvedReferencedKeeperIds = new Vector(); m_vUnsolvedReferenceRefNum = new Vector(); - + m_xXMLDocumentWrapper = null; m_xSAXEventKeeper = null; - + m_bSAXEventKeeperIncluded = false; m_bIsBlocking = false; m_bIsInsideCollectedElement = false; - + m_bIsEncryptionTarget = false; m_EncryptionForTarget = null; changeOutput(); - + m_currentPath = new Stack(); - + foundSecurityRelated(); } - + /************************************************************************************** * private methods **************************************************************************************/ - + /* * changes the output document handler. */ @@ -212,7 +212,7 @@ public class XMLSecurityFrameworkController if (m_bIsExporting) { m_parsingThread.setHandler(this); - + /* * If the SAXEventKeeper is in the SAX chain, then redirects output * to the SAXEventKeeper, otherwise, to the m_xOutputHandler @@ -222,7 +222,7 @@ public class XMLSecurityFrameworkController m_xExportHandler = (XDocumentHandler)UnoRuntime.queryInterface( XDocumentHandler.class, m_xSAXEventKeeper); m_xSAXEventKeeper.setNextHandler(m_xOutputHandler); - + m_testTool.updatesSAXChainInformation("XMLExporter -> SAXEventKeeper -> SAXWriter"); } else @@ -248,14 +248,14 @@ public class XMLSecurityFrameworkController m_xExportHandler = m_xOutputHandler; } } - + /* * handles the situation when a security related element is found. * if the SAXEventKeeper is not initialized, then creates a * SAXEventKeeper. * the return value represents whether the SAXEventKeeper is newly * created. - */ + */ private boolean foundSecurityRelated() { if (m_xSAXEventKeeper == null) @@ -263,7 +263,7 @@ public class XMLSecurityFrameworkController m_testTool.showMessage("Message from : "+ (m_bIsExporting?"XMLExporter":"XMLImporter")+ "\n\nA security related content found, a SAXEventKeeper is created.\n "); - + m_bIsBlocking = false; m_bIsInsideCollectedElement = false; @@ -273,7 +273,7 @@ public class XMLSecurityFrameworkController * creates an XMLDocumentWrapper component. */ Object xmlDocumentObj = null; - + if (m_bIsJavaBased) { xmlDocumentObj = m_xRemoteServiceManager.createInstanceWithContext( @@ -284,24 +284,24 @@ public class XMLSecurityFrameworkController xmlDocumentObj = m_xRemoteServiceManager.createInstanceWithContext( TestTool.XMLDOCUMENTWRAPPER_COMPONENT_C, m_xRemoteContext); } - + m_xXMLDocumentWrapper = (XXMLDocumentWrapper)UnoRuntime.queryInterface( XXMLDocumentWrapper.class, xmlDocumentObj); - + /* * creates a SAXEventKeeper component. */ Object saxEventKeeperObj = m_xRemoteServiceManager.createInstanceWithContext( TestTool.SAXEVENTKEEPER_COMPONENT, m_xRemoteContext); - m_xSAXEventKeeper = + m_xSAXEventKeeper = (XSecuritySAXEventKeeper)UnoRuntime.queryInterface( - XSecuritySAXEventKeeper.class, saxEventKeeperObj); - + XSecuritySAXEventKeeper.class, saxEventKeeperObj); + /* * initializes the SAXEventKeeper component with the XMLDocumentWrapper component. */ - XInitialization xInitialization = + XInitialization xInitialization = (XInitialization)UnoRuntime.queryInterface( XInitialization.class, m_xSAXEventKeeper); Object args[]=new Object[1]; @@ -312,18 +312,18 @@ public class XMLSecurityFrameworkController { e.printStackTrace(); } - + /* * configures the SAXEventKeeper's status change listener. */ - XSAXEventKeeperStatusChangeBroadcaster xSaxEventKeeperStatusChangeBroadcaster = + XSAXEventKeeperStatusChangeBroadcaster xSaxEventKeeperStatusChangeBroadcaster = (XSAXEventKeeperStatusChangeBroadcaster)UnoRuntime.queryInterface( - XSAXEventKeeperStatusChangeBroadcaster.class, m_xSAXEventKeeper); + XSAXEventKeeperStatusChangeBroadcaster.class, m_xSAXEventKeeper); xSaxEventKeeperStatusChangeBroadcaster.addSAXEventKeeperStatusChangeListener(this); } - + boolean rc = !m_bSAXEventKeeperIncluded; - + /* * changes the export document handler. */ @@ -339,16 +339,16 @@ public class XMLSecurityFrameworkController private void findKeyOrReference(SecurityEntity signatureEntity, String uriStr, boolean isFindingKey) { int i=0; - + while (i<m_vUnsolvedReferenceIds.size()) { String id = (String)m_vUnsolvedReferenceIds.elementAt(i); - + if (id.equals(uriStr)) { int refNum = ((Integer)m_vUnsolvedReferenceRefNum.elementAt(i)).intValue(); int keeperId = ((Integer)m_vUnsolvedReferencedKeeperIds.elementAt(i)).intValue(); - + if (isFindingKey) { /* @@ -358,17 +358,17 @@ public class XMLSecurityFrameworkController keeperId, m_bIsExporting? (ElementMarkPriority.BEFOREMODIFY):(ElementMarkPriority.AFTERMODIFY)); - + /* * notifies the key keeper id. */ signatureEntity.setKeyId(cloneKeeperId); - + /* * sets the security id for the key. */ m_xSAXEventKeeper.setSecurityId(cloneKeeperId, signatureEntity.getSecurityId()); - + /* * sets the resolve listener. */ @@ -385,15 +385,15 @@ public class XMLSecurityFrameworkController * clones a new ElementCollector for the referenced element. */ int cloneKeeperId = m_xSAXEventKeeper.cloneElementCollector( - keeperId, + keeperId, m_bIsExporting? (ElementMarkPriority.AFTERMODIFY):(ElementMarkPriority.BEFOREMODIFY)); - + /* * sets the security id. */ m_xSAXEventKeeper.setSecurityId(cloneKeeperId, signatureEntity.getSecurityId()); - + /* * sets the resolve listener. */ @@ -402,7 +402,7 @@ public class XMLSecurityFrameworkController XReferenceResolvedBroadcaster.class, m_xSAXEventKeeper); xReferenceResolvedBroadcaster.addReferenceResolvedListener(cloneKeeperId, signatureEntity.getReferenceListener()); - + try{ XReferenceCollector xReferenceCollector = (XReferenceCollector)UnoRuntime.queryInterface( @@ -414,7 +414,7 @@ public class XMLSecurityFrameworkController e.printStackTrace(); } } - + /* * if this unsolved reference reaches its max reference number, remove this reference * from all vectors. @@ -432,7 +432,7 @@ public class XMLSecurityFrameworkController m_vUnsolvedReferenceRefNum.setElementAt(new Integer(refNum),(i)); ++i; } - + /* * If it is find a key, then no further search is needed, one * signature has one key at most. @@ -448,7 +448,7 @@ public class XMLSecurityFrameworkController } } } - + /* * checks whether a startElement event represents any security related information. * return true if this event can't be forwarded into the SAX chain. @@ -456,7 +456,7 @@ public class XMLSecurityFrameworkController private boolean checkSecurityElement(String localName, com.sun.star.xml.sax.XAttributeList xattribs) { boolean rc = false; - + if (localName.equals("Signature")) /* * this element is a Signature element. @@ -480,23 +480,23 @@ public class XMLSecurityFrameworkController if (!m_currentPath.empty()) { Object signedInfo = m_currentPath.pop(); - + if (!m_currentPath.empty()) { Object objSignature = m_currentPath.peek(); - + if ((objSignature instanceof SignatureEntity) && signedInfo.toString().equals("SignedInfo")) /* * this element is a Reference element in a signature. */ { String uriStr = xattribs.getValueByName("URI"); - + if (uriStr.charAt(0) == '#') { uriStr = uriStr.substring(1); SignatureEntity signatureEntity = (SignatureEntity)objSignature; - + if (uriStr != null && uriStr.length()>0) { signatureEntity.addReferenceId(uriStr); @@ -509,7 +509,7 @@ public class XMLSecurityFrameworkController } m_currentPath.push(localName); } - else if(localName.equals("KeyValue") || + else if(localName.equals("KeyValue") || localName.equals("KeyName") || localName.equals("X509Data") || localName.equals("EncryptedKey")) @@ -517,11 +517,11 @@ public class XMLSecurityFrameworkController if (!m_currentPath.empty()) { Object keyInfo = m_currentPath.pop(); - + if (!m_currentPath.empty()) { Object objSorE = m_currentPath.peek(); - + if ((objSorE instanceof SignatureEntity) && keyInfo.toString().equals("KeyInfo")) /* * this element is the key element of a signature. @@ -541,7 +541,7 @@ public class XMLSecurityFrameworkController } m_currentPath.push(keyInfo); } - + m_currentPath.push(localName); } else if(localName.equals("RetrievalMethod")) @@ -549,11 +549,11 @@ public class XMLSecurityFrameworkController if (!m_currentPath.empty()) { Object keyInfo = m_currentPath.pop(); - + if (!m_currentPath.empty()) { Object objSorE = m_currentPath.peek(); - + if ((objSorE instanceof SignatureEntity) && keyInfo.toString().equals("KeyInfo")) /* * this element is the RetrievalMethod element in a signature, @@ -562,7 +562,7 @@ public class XMLSecurityFrameworkController { String uriStr = xattribs.getValueByName("URI"); SignatureEntity signatureEntity = (SignatureEntity)objSorE; - + if (uriStr != null && uriStr.length()>0) { signatureEntity.setKeyURI(uriStr); @@ -577,7 +577,7 @@ public class XMLSecurityFrameworkController { String uriStr = xattribs.getValueByName("URI"); EncryptionEntity theEncryption = (EncryptionEntity)objSorE; - + if (uriStr != null && uriStr.length()>0) { theEncryption.setKeyURI(uriStr); @@ -603,9 +603,9 @@ public class XMLSecurityFrameworkController m_xXMLEncryption, m_xRemoteServiceManager, m_xRemoteContext); - + m_encryptionList.add(theEncryption); - + if (m_bIsExporting) { m_currentPath.push(theEncryption); @@ -622,7 +622,7 @@ public class XMLSecurityFrameworkController { theEncryption.setKeyId(0); } - + rc = true; } } @@ -633,23 +633,23 @@ public class XMLSecurityFrameworkController { m_currentPath.push(localName); } - + return rc; } - + /* * checks whether a startElement event is referenced by any security entity. */ private void checkReference(String localName, com.sun.star.xml.sax.XAttributeList xattribs, String id) { String refNumStr = xattribs.getValueByName("refNum"); - + if ( m_bIsEncryptionTarget ) { m_EncryptionForTarget.setReference(m_bIsExporting); m_bIsEncryptionTarget = false; } - + if (id != null && id.length()>0 ) /* * only if this element has id attribute, then it can be referenced by @@ -662,14 +662,14 @@ public class XMLSecurityFrameworkController * referencing number to 999. */ int refNum = 999; - + if (refNumStr != null && refNumStr.length()>0 ) { refNum = new Integer(refNumStr).intValue(); } - + int length; - + /* * searches the signature list to check whether any sigture has * reference on this element. @@ -678,18 +678,18 @@ public class XMLSecurityFrameworkController for (int i=0; i<length; ++i) { SignatureEntity signatureEntity = (SignatureEntity)m_signatureList.elementAt(i); - + if (signatureEntity.setReference(id, m_bIsExporting)) { refNum--; } - + if (signatureEntity.setKey(id, m_bIsExporting)) { refNum--; } } - + /* * searches the encryption list for reference. */ @@ -697,13 +697,13 @@ public class XMLSecurityFrameworkController for (int i=0; i<length; ++i) { EncryptionEntity theEncryption = (EncryptionEntity)m_encryptionList.elementAt(i); - + if (theEncryption.setKey(id, m_bIsExporting)) { refNum--; } } - + /* * if the max referencing number is not reached, then add this element * into the unsolved reference list. @@ -711,7 +711,7 @@ public class XMLSecurityFrameworkController if (refNum>0) { int keeperId; - + if (localName.equals("EncryptedKey")) { keeperId = m_xSAXEventKeeper.addSecurityElementCollector( @@ -726,14 +726,14 @@ public class XMLSecurityFrameworkController (ElementMarkPriority.AFTERMODIFY):(ElementMarkPriority.BEFOREMODIFY), false); } - + m_vUnsolvedReferenceIds.add(id); m_vUnsolvedReferencedKeeperIds.add(new Integer(keeperId)); m_vUnsolvedReferenceRefNum.add(new Integer(refNum)); } } } - + /* * configures the output handler. */ @@ -742,12 +742,12 @@ public class XMLSecurityFrameworkController m_xOutputHandler = handler; changeOutput(); } - - + + /************************************************************************************** * protected methods **************************************************************************************/ - + /* * methods used to transfer unsolved reference information. */ @@ -755,7 +755,7 @@ public class XMLSecurityFrameworkController { return m_vUnsolvedReferenceIds; } - + protected Vector getUnsolvedReferenceKeeperIds() { return m_vUnsolvedReferencedKeeperIds; @@ -765,7 +765,7 @@ public class XMLSecurityFrameworkController { return m_vUnsolvedReferenceRefNum; } - + protected String getBufferNodeTreeInformation() { if (m_xSAXEventKeeper != null) @@ -777,7 +777,7 @@ public class XMLSecurityFrameworkController return null; } } - + protected void getDocument(XDocumentHandler handler) { if (m_xXMLDocumentWrapper != null) @@ -792,7 +792,7 @@ public class XMLSecurityFrameworkController } } } - + protected void endMission() { while (m_signatureList.size()>0 || m_encryptionList.size()>0) @@ -810,7 +810,7 @@ public class XMLSecurityFrameworkController theEncryption.endMission(); } } - + while (m_vUnsolvedReferenceIds.size()>0) { int keeperId = ((Integer)m_vUnsolvedReferencedKeeperIds.elementAt(0)).intValue(); @@ -819,21 +819,21 @@ public class XMLSecurityFrameworkController m_vUnsolvedReferencedKeeperIds.remove(0); m_vUnsolvedReferenceRefNum.remove(0); } - + m_xSAXEventKeeper.setNextHandler(null); - - XSAXEventKeeperStatusChangeBroadcaster xSaxEventKeeperStatusChangeBroadcaster = + + XSAXEventKeeperStatusChangeBroadcaster xSaxEventKeeperStatusChangeBroadcaster = (XSAXEventKeeperStatusChangeBroadcaster)UnoRuntime.queryInterface( - XSAXEventKeeperStatusChangeBroadcaster.class, m_xSAXEventKeeper); + XSAXEventKeeperStatusChangeBroadcaster.class, m_xSAXEventKeeper); xSaxEventKeeperStatusChangeBroadcaster.addSAXEventKeeperStatusChangeListener(null); - + m_xSAXEventKeeper = null; m_xXMLDocumentWrapper = null; m_xOutputHandler = null; m_xXMLSecurityContext = null; m_xXMLSignature = null; m_xXMLEncryption = null; - + m_xExportHandler = null; m_parsingThread.setHandler(null); } @@ -854,7 +854,7 @@ public class XMLSecurityFrameworkController { e.printStackTrace(); } - + } public void endDocument() @@ -867,7 +867,7 @@ public class XMLSecurityFrameworkController e.printStackTrace(); } } - + public void startElement (String str, com.sun.star.xml.sax.XAttributeList xattribs) { try{ @@ -876,10 +876,10 @@ public class XMLSecurityFrameworkController { idAttr = xattribs.getValueByName("Id"); } - + boolean hasIdAttr = (idAttr != null && idAttr.length()>0 ); boolean needResend = false; - + if (hasIdAttr || (str.equals("Signature")||str.equals("EncryptedData")))/* || str.equals("EncryptedKey"))) */ { @@ -888,16 +888,16 @@ public class XMLSecurityFrameworkController needResend = true; } } - + boolean suppressToNext = checkSecurityElement(str, xattribs); - + checkReference(str, xattribs, idAttr); - + if (needResend) { m_xSAXEventKeeper.setNextHandler(null); - - XDocumentHandler saxEventKeeperHandler = + + XDocumentHandler saxEventKeeperHandler = (XDocumentHandler)UnoRuntime.queryInterface( XDocumentHandler.class, m_xSAXEventKeeper); saxEventKeeperHandler.startElement(str, xattribs); @@ -920,7 +920,7 @@ public class XMLSecurityFrameworkController if (!m_currentPath.empty()) { Object obj = m_currentPath.pop(); - + if (obj.toString().equals("SignedInfo")) { if (!m_currentPath.empty()) @@ -939,7 +939,7 @@ public class XMLSecurityFrameworkController } } - + try{ m_xExportHandler.endElement(str); } @@ -948,7 +948,7 @@ public class XMLSecurityFrameworkController e.printStackTrace(); } } - + public void characters(String str) { try{ @@ -959,11 +959,11 @@ public class XMLSecurityFrameworkController e.printStackTrace(); } } - + public void ignorableWhitespace(String str) { } - + public void processingInstruction(String aTarget, String aData) { try{ @@ -975,12 +975,12 @@ public class XMLSecurityFrameworkController } } - public void setDocumentLocator (com.sun.star.xml.sax.XLocator xLocator ) + public void setDocumentLocator (com.sun.star.xml.sax.XLocator xLocator ) throws com.sun.star.xml.sax.SAXException { } - - + + /* * XSignatureCreationResultListener */ @@ -990,7 +990,7 @@ public class XMLSecurityFrameworkController message += "A Signature is created:"; message += "\nSecurity Id = "+securityId; message += "\nCreation result = "+((creationResult==SecurityOperationStatus.OPERATION_SUCCEEDED)?"Succeed":"Fail"); - + m_testTool.showMessage("Message from : SignatureCreator\n\n"+message+"\n "); } @@ -1003,7 +1003,7 @@ public class XMLSecurityFrameworkController message += "A Signature is verified:"; message += "\nSecurity Id = "+securityId; message += "\nVerify result = "+((verifyResult==SecurityOperationStatus.OPERATION_SUCCEEDED)?"Succeed":"Fail"); - + m_testTool.showMessage("Message from : SignatureVerifier\n\n"+message+"\n "); } @@ -1016,10 +1016,10 @@ public class XMLSecurityFrameworkController message += "An EncryptedData is encrypted:"; message += "\nSecurity Id = "+securityId; message += "\nEncrypt result = "+((encryptionResult==SecurityOperationStatus.OPERATION_SUCCEEDED)?"Succeed":"Fail"); - + m_testTool.showMessage("Message from : Encryptor\n\n"+message+"\n "); } - + /* * XDecryptionResultListener methods */ @@ -1029,10 +1029,10 @@ public class XMLSecurityFrameworkController message += "An EncryptedData is decrypted:"; message += "\nSecurity Id = "+securityId; message += "\nDecrypt result = "+((decryptionResult==SecurityOperationStatus.OPERATION_SUCCEEDED)?"Succeed":"Fail"); - + m_testTool.showMessage("Message from : Decryptor\n\n"+message+"\n "); } - + /* * XSAXEventKeeperStatusChangeListener methods */ @@ -1041,19 +1041,19 @@ public class XMLSecurityFrameworkController m_testTool.showMessage("Message from : SAXEventKeeper\n\n"+ (isBlocking?"The SAX event stream is blocked.":"The SAX event stream is unblocked.")+ "\n "); - + this.m_bIsBlocking = isBlocking; } - + public void collectionStatusChanged(boolean isInsideCollectedElement) { m_testTool.showMessage("Message from : SAXEventKeeper\n\n"+ (isInsideCollectedElement?"Begin to buffer data ...":"End of data bufferring.")+ "\n "); - + /* this.m_bIsInsideCollectedElement = isInsideCollectedElement; - + if ( !m_bIsInsideCollectedElement && !m_bIsBlocking) { m_bSAXEventKeeperIncluded = false; @@ -1065,7 +1065,7 @@ public class XMLSecurityFrameworkController changeOutput(); */ } - + public void bufferStatusChanged(boolean isBufferEmpty) { m_testTool.showMessage("Message from : SAXEventKeeper\n\n"+ diff --git a/xmlsecurity/tools/uno/XMLTreeCellRanderer.java b/xmlsecurity/tools/uno/XMLTreeCellRanderer.java index 77891a239853..567ba2111217 100644 --- a/xmlsecurity/tools/uno/XMLTreeCellRanderer.java +++ b/xmlsecurity/tools/uno/XMLTreeCellRanderer.java @@ -1,7 +1,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 @@ -34,27 +34,27 @@ import java.awt.Component; import javax.swing.JTree; /* - * a TreeCellRender which can show a graph on the current + * a TreeCellRender which can show a graph on the current * tree node. */ -class XMLTreeCellRanderer extends DefaultTreeCellRenderer +class XMLTreeCellRanderer extends DefaultTreeCellRenderer { /* * the icon for the current Node */ private ImageIcon m_currentIcon; - + /* * the current Node */ private Node m_currentNode; - + XMLTreeCellRanderer(Node currentNode) { m_currentNode = currentNode; m_currentIcon = new ImageIcon("current.gif"); } - + public Component getTreeCellRendererComponent( JTree tree, Object value, @@ -62,14 +62,14 @@ class XMLTreeCellRanderer extends DefaultTreeCellRenderer boolean expanded, boolean leaf, int row, - boolean hasFocus) + boolean hasFocus) { super.getTreeCellRendererComponent( tree, value, sel, expanded, leaf, row, hasFocus); - - if (((AdapterNode)value).getNode() == m_currentNode) + + if (((AdapterNode)value).getNode() == m_currentNode) { setIcon(m_currentIcon); setToolTipText("This is the current element."); @@ -77,8 +77,8 @@ class XMLTreeCellRanderer extends DefaultTreeCellRenderer else { setToolTipText(null); /* no tool tip */ - } - + } + return this; } } |