summaryrefslogtreecommitdiff
path: root/xmlsecurity
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2012-01-04 12:05:23 +0100
committerStephan Bergmann <sbergman@redhat.com>2012-01-04 12:05:23 +0100
commita11aa274dac55b06fba32e348a8386fa4fa9d146 (patch)
treedd467618cc828bd14b1497ceef7d45fa4ddea240 /xmlsecurity
parent67e31e585f0513f74eb2eab759831e2a9e258483 (diff)
Dead code.
Diffstat (limited to 'xmlsecurity')
-rw-r--r--xmlsecurity/tools/demo/JavaFlatFilter.java225
-rw-r--r--xmlsecurity/tools/demo/makefile.mk156
-rw-r--r--xmlsecurity/tools/demo/manifest1
-rw-r--r--xmlsecurity/tools/demo/mozprofile.cxx108
-rw-r--r--xmlsecurity/tools/demo/multisigdemo.cxx237
-rw-r--r--xmlsecurity/tools/demo/performance.cxx1872
-rw-r--r--xmlsecurity/tools/demo/readme.txt22
-rw-r--r--xmlsecurity/tools/demo/signdemo.cxx157
-rw-r--r--xmlsecurity/tools/demo/util.cxx112
-rw-r--r--xmlsecurity/tools/demo/util.hxx53
-rw-r--r--xmlsecurity/tools/demo/util2.cxx427
-rw-r--r--xmlsecurity/tools/demo/verifydemo.cxx109
12 files changed, 0 insertions, 3479 deletions
diff --git a/xmlsecurity/tools/demo/JavaFlatFilter.java b/xmlsecurity/tools/demo/JavaFlatFilter.java
deleted file mode 100644
index 331ace804072..000000000000
--- a/xmlsecurity/tools/demo/JavaFlatFilter.java
+++ /dev/null
@@ -1,225 +0,0 @@
-/*************************************************************************
- *
- * 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
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-package com.sun.star.xml.security.eval;
-
-import com.sun.star.registry.XRegistryKey;
-import com.sun.star.comp.loader.FactoryHelper;
-import com.sun.star.uno.UnoRuntime;
-import com.sun.star.xml.sax.InputSource;
-import com.sun.star.xml.sax.XDocumentHandler;
-import com.sun.star.xml.sax.XParser;
-import com.sun.star.xml.sax.XDTDHandler;
-import com.sun.star.xml.sax.XEntityResolver;
-import com.sun.star.xml.sax.XErrorHandler;
-import com.sun.star.xml.sax.XAttributeList;
-import com.sun.star.lang.XSingleServiceFactory;
-import com.sun.star.lang.XMultiServiceFactory;
-import com.sun.star.lang.XTypeProvider;
-import com.sun.star.lang.XServiceInfo;
-import com.sun.star.lang.Locale;
-
-/*
- * the JavaFlatFilter class is a pure java filter, which does nothing
- * but forwarding the SAX events to the next document handler.
- * The purpose of this class is to calculate the time consumed by
- * the UNO C++/Java bridge during exporting/importing.
- */
-public class JavaFlatFilter extends Object
- implements XDocumentHandler, XParser, XTypeProvider, XServiceInfo
-{
- XDocumentHandler m_xDocumentHandler;
-
- /* XDocumentHandler */
- public void startDocument()
- throws com.sun.star.xml.sax.SAXException
- {
- m_xDocumentHandler.startDocument();
- }
-
- public void endDocument()
- 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
- {
- m_xDocumentHandler.startElement(aName, xAttribs);
- }
-
- 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
- {
- m_xDocumentHandler.characters(aChars);
- }
-
- 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
- {
- m_xDocumentHandler.processingInstruction(aTarget, aData);
- }
-
- 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()
- {
- 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
- */
- retValue[0]= new com.sun.star.uno.Type( XServiceInfo.class);
- 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()
- {
- if (_implementationId == null) {
- _implementationId= new byte[16];
- int hash = hashCode(); // hashDode of this object
- _implementationId[0] = (byte)(hash & 0xff);
- _implementationId[1] = (byte)((hash >>> 8) & 0xff);
- _implementationId[2] = (byte)((hash >>> 16) & 0xff);
- _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( )
- {
- return getClass().getName();
- }
-
- public boolean supportsService(String serviceName)
- {
- boolean rc = false;
-
- if ( serviceName.equals( __serviceName))
- {
- rc = true;
- }
-
- return rc;
- }
-
- 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.lang.XSingleServiceFactory xSingleServiceFactory = null;
- if (implName.equals( JavaFlatFilter.class.getName()) )
- {
- xSingleServiceFactory = FactoryHelper.getServiceFactory( JavaFlatFilter.class,
- JavaFlatFilter.__serviceName,
- multiFactory,
- regKey);
- }
-
- return xSingleServiceFactory;
- }
-
- /* static __writeRegistryServiceInfo implementation */
- public static boolean __writeRegistryServiceInfo(XRegistryKey regKey)
- {
- return FactoryHelper.writeRegistryServiceInfo( JavaFlatFilter.class.getName(),
- __serviceName,
- regKey);
- }
-}
diff --git a/xmlsecurity/tools/demo/makefile.mk b/xmlsecurity/tools/demo/makefile.mk
deleted file mode 100644
index 4ca49affd1ea..000000000000
--- a/xmlsecurity/tools/demo/makefile.mk
+++ /dev/null
@@ -1,156 +0,0 @@
-#*************************************************************************
-#
-# 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
-#
-# This file is part of OpenOffice.org.
-#
-# OpenOffice.org is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Lesser General Public License version 3
-# only, as published by the Free Software Foundation.
-#
-# OpenOffice.org is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Lesser General Public License version 3 for more details
-# (a copy is included in the LICENSE file that accompanied this code).
-#
-# You should have received a copy of the GNU Lesser General Public License
-# version 3 along with OpenOffice.org. If not, see
-# <http://www.openoffice.org/license.html>
-# for a copy of the LGPLv3 License.
-#
-#*************************************************************************
-
-PRJ=..$/..
-
-PRJNAME=xmlsecurity
-TARGET=demo
-ENABLE_EXCEPTIONS=TRUE
-LIBTARGET=NO
-
-# --- Settings -----------------------------------------------------
-
-.INCLUDE : settings.mk
-.INCLUDE : $(PRJ)$/util$/target.pmk
-
-CDEFS += -DXMLSEC_CRYPTO_NSS -DXMLSEC_NO_XSLT
-
-# --- Files --------------------------------------------------------
-
-SHARE_LIBS = \
- $(CPPULIB) \
- $(CPPUHELPERLIB) \
- $(SALLIB) \
- $(UCBHELPERLIB) \
- $(UNOTOOLSLIB) \
- $(TOOLSLIB) \
- $(XMLOFFLIB) \
- $(LIBXML2LIB) \
- $(NSS3LIB) \
- $(NSPR4LIB) \
- $(XMLSECLIB) \
- $(COMPHELPERLIB)
-
-.IF "$(CRYPTO_ENGINE)" == "mscrypto"
-SHARE_LIBS+= $(XMLSECLIB-MS)
-.ELSE
-SHARE_LIBS+= $(XMLSECLIB-NSS)
-.ENDIF
-
-
-
-# HACK: Use SLO for demo directly...
-SHARE_OBJS = \
- $(OBJ)$/util.obj \
- $(OBJ)$/util2.obj \
- $(SLO)$/biginteger.obj \
- $(SLO)$/baseencoding.obj \
- $(SLO)/xmlsignaturehelper.obj \
- $(SLO)/xmlsignaturehelper2.obj \
- $(SLO)/xsecctl.obj \
- $(SLO)/xsecparser.obj \
- $(SLO)/xsecsign.obj \
- $(SLO)/xsecverify.obj
-
-#
-# ---------- signdemo ----------
-#
-APP1TARGET=signdemo
-APP1DEPN=makefile.mk
-APP1STDLIBS+=$(SHARE_LIBS)
-APP1OBJS= $(SHARE_OBJS) $(OBJ)$/signdemo.obj
-
-#
-# ---------- verifydemo ----------
-#
-APP2TARGET=verifydemo
-APP2DEPN=makefile.mk
-APP2STDLIBS+=$(SHARE_LIBS)
-APP2OBJS= $(SHARE_OBJS) $(OBJ)$/verifydemo.obj
-
-#
-# ---------- multisigdemo ----------
-#
-APP3TARGET=multisigdemo
-APP3DEPN=makefile.mk
-APP3STDLIBS+=$(SHARE_LIBS)
-APP3OBJS= $(SHARE_OBJS) $(OBJ)$/multisigdemo.obj
-
-#
-# ---------- mozprofile ----------
-#
-APP4TARGET=mozprofile
-APP4DEPN=makefile.mk
-APP4STDLIBS+=$(SHARE_LIBS)
-APP4OBJS= $(SHARE_OBJS) $(OBJ)$/mozprofile.obj
-
-#
-# ---------- performance ----------
-#
-APP5TARGET=performance
-APP5DEPN=makefile.mk
-APP5STDLIBS+=$(SHARE_LIBS)
-APP5OBJS= $(OBJ)$/util.obj $(OBJ)$/performance.obj
-
-#
-# ---------- jflatfilter ----------
-#
-PACKAGE= com$/sun$/star$/xml$/security$/eval
-JARFILES= ridl.jar jurt.jar unoil.jar juh.jar
-JAVAFILES:= $(shell @ls *.java)
-JAVACLASSFILES= $(CLASSDIR)$/$(PACKAGE)$/JavaFlatFilter.class
-JARCLASSDIRS= $(PACKAGE)
-JARTARGET= jflatfilter.jar
-JARCOMPRESS= TRUE
-
-
-# --- Targets ------------------------------------------------------
-
-.INCLUDE : target.mk
-
-ALLTAR : $(BIN)$/demo.rdb
-
-$(JAVACLASSFILES) : $(JAVAFILES)
-
-REGISTERLIBS= \
- dynamicloader.uno$(DLLPOST) \
- namingservice.uno$(DLLPOST) \
- bootstrap.uno$(DLLPOST) \
- sax.uno$(DLLPOST) \
- $(DLLPRE)mozab2$(DLLPOST)
-
-$(BIN)$/demo.rdb: \
- makefile.mk \
- $(foreach,i,$(REGISTERLIBS) $(SOLARSHAREDBIN)$/$(i))
- -rm -f $@ $(BIN)$/regcomp.rdb $(BIN)$/demo.tmp
- $(REGCOMP) -register -r $(BIN)$/demo.tmp -c "$(strip $(REGISTERLIBS))"
- $(REGCOMP) -register -r $(BIN)$/demo.tmp -c $(DLLPRE)xsec_fw$(DLLPOST)
- $(REGCOMP) -register -r $(BIN)$/demo.tmp -c $(DLLPRE)xsec_xmlsec$(DLLPOST)
- $(REGMERGE) $(BIN)$/demo.tmp / $(SOLARBINDIR)/types.rdb
- mv $(BIN)$/demo.tmp $@
-
-
diff --git a/xmlsecurity/tools/demo/manifest b/xmlsecurity/tools/demo/manifest
deleted file mode 100644
index 93cb7d908467..000000000000
--- a/xmlsecurity/tools/demo/manifest
+++ /dev/null
@@ -1 +0,0 @@
-RegistrationClassName: com.sun.star.xml.security.eval.JavaFlatFilter
diff --git a/xmlsecurity/tools/demo/mozprofile.cxx b/xmlsecurity/tools/demo/mozprofile.cxx
deleted file mode 100644
index a94bfc34b10b..000000000000
--- a/xmlsecurity/tools/demo/mozprofile.cxx
+++ /dev/null
@@ -1,108 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*************************************************************************
- *
- * 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
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-
-#include "util.hxx"
-
-#include <stdio.h>
-#include <tools/date.hxx>
-#include <tools/time.hxx>
-#include <cppuhelper/servicefactory.hxx>
-
-#include <xmlsecurity/biginteger.hxx>
-#include <xmlsecurity/xmlsignaturehelper.hxx>
-#include <com/sun/star/mozilla/XMozillaBootstrap.hpp>
-
-using namespace ::com::sun::star;
-
-int SAL_CALL main( int argc, char **argv )
-{
- fprintf( stdout, "\nTesting Mozilla Profile Detection...\n\nOpenOffice.org will use the first detected profile.\nResults might be different when started in OOo program folder!\n" ) ;
-
- uno::Reference< lang::XMultiServiceFactory > xMSF = CreateDemoServiceFactory();
- if ( !xMSF.is() )
- {
- 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++)
- {
- if ( i == 0 )
- fprintf( stdout, "\nThunderbird: " );
- else if ( i == 1 )
- fprintf( stdout, "\nMozilla: " );
- else if ( i == 2 )
- fprintf( stdout, "\nFireFox: " );
- else
- fprintf( stdout, "\nDefault: " );
-
- ::rtl::OUString profile = xMozillaBootstrap->getDefaultProfile(productTypes[i]);
- if ( profile.getLength() )
- {
- ::rtl::OUString profilepath = xMozillaBootstrap->getProfilePath(productTypes[i],profile);
- fprintf( stdout, "Name=%s, Path=%s", rtl::OUStringToOString( profile , RTL_TEXTENCODING_ASCII_US ).getStr(), rtl::OUStringToOString( profilepath , RTL_TEXTENCODING_ASCII_US ).getStr() );
- }
- else
- {
- fprintf( stdout, "NOT FOUND" );
- }
- }
-
- /*
- * creates a signature helper
- */
- XMLSignatureHelper aSignatureHelper( xMSF );
-
- /*
- * creates a security context.
- */
- rtl::OUString aCryptoToken;
- bool bInit = aSignatureHelper.Init( aCryptoToken );
- if ( !bInit )
- {
- fprintf( stdout, "\n\nERROR: Unable to initialize security environment.\n\n" );
- }
- else
- {
- fprintf( stdout, "\n\nSecurity environment can be initialized successfully.\n\n" );
- }
-
- return 0;
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmlsecurity/tools/demo/multisigdemo.cxx b/xmlsecurity/tools/demo/multisigdemo.cxx
deleted file mode 100644
index 1d26f03f5a65..000000000000
--- a/xmlsecurity/tools/demo/multisigdemo.cxx
+++ /dev/null
@@ -1,237 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*************************************************************************
- *
- * 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
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-
-#include <stdio.h>
-#include "util.hxx"
-
-#include <rtl/ustring.hxx>
-#include <cppuhelper/servicefactory.hxx>
-
-#include <xmlsecurity/biginteger.hxx>
-#include <xmlsecurity/xmlsignaturehelper.hxx>
-#include "xmlsecurity/baseencoding.hxx"
-#include <tools/date.hxx>
-#include <tools/time.hxx>
-
-using namespace ::com::sun::star;
-
-long denyVerifyHandler( void *, void * )
-{
- return 0;
-}
-
-long startVerifyHandler( void *, void * )
-{
- return QueryVerifySignature();
-}
-
-int SAL_CALL main( int argc, char **argv )
-{
- 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 ;
- }
-
- uno::Reference< lang::XMultiServiceFactory > xMSF = CreateDemoServiceFactory();
-
- rtl::OUString aSIGFileName = rtl::OUString::createFromAscii(argv[1]);
- rtl::OUString aSIGFileName2 = rtl::OUString::createFromAscii(argv[2]);
- rtl::OUString aXMLFileName = rtl::OUString::createFromAscii(argv[3]);
- rtl::OUString aBINFileName = rtl::OUString::createFromAscii(argv[4]);
- rtl::OUString aCryptoToken;
- if ( argc >= 7 )
- aCryptoToken = rtl::OUString::createFromAscii(argv[6]);
-
- sal_Int32 nSecurityId;
- uno::Reference< io::XOutputStream > xOutputStream;
- uno::Reference< io::XInputStream > xInputStream;
- bool bDone;
- SignatureInformations signatureInformations;
- uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler> xDocumentHandler;
-
- // -------- START -------
-
- XMLSignatureHelper aSignatureHelper( xMSF );
-
- bool bInit = aSignatureHelper.Init( aCryptoToken );
- if ( !bInit )
- {
- 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
- */
- uno::Reference< xml::crypto::XSecurityEnvironment > xSecurityEnvironment = aSignatureHelper.GetSecurityEnvironment();
- uno::Sequence< uno::Reference< ::com::sun::star::security::XCertificate > > xPersonalCerts = xSecurityEnvironment->getPersonalCertificates() ;
-
- fprintf( stdout, "\nPlease select two certificates:\n" );
-
- for ( int nSig = 0; nSig < 2; nSig++ )
- {
- // New security ID for signature...
- nSecurityId = aSignatureHelper.GetNewSecurityId();
-
- // Select certificate...
- uno::Reference< ::com::sun::star::security::XCertificate > xPersonalCert = getCertificateFromEnvironment( xSecurityEnvironment, true );
- aSignatureHelper.SetX509Certificate(
- nSecurityId, xPersonalCert->getIssuerName(),
- bigIntegerToNumericString( xPersonalCert->getSerialNumber()),
- baseEncode(xPersonalCert->getEncoded(), BASE64));
- aSignatureHelper.AddForSigning( nSecurityId, aXMLFileName, aXMLFileName, sal_False );
- aSignatureHelper.AddForSigning( nSecurityId, aBINFileName, aBINFileName, sal_True );
- aSignatureHelper.SetDateTime( nSecurityId, Date(), Time() );
- }
- /*
- * creates signature
- */
- xOutputStream = OpenOutputStream( aSIGFileName );
- bDone = aSignatureHelper.CreateAndWriteSignature( xOutputStream );
- if ( !bDone )
- fprintf( stderr, "\nSTATUS MISSION 1: Error creating Signature!\n" );
- else
- 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...
- */
- aSignatureHelper.SetStartVerifySignatureHdl( Link( NULL, denyVerifyHandler ) );
- aSignatureHelper.StartMission();
-
- xInputStream = OpenInputStream( aSIGFileName );
- bDone = aSignatureHelper.ReadAndVerifySignature( xInputStream );
- xInputStream->closeInput();
-
- if ( !bDone )
- 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]);
- aSignatureHelper.CloseDocumentHandler( xDocumentHandler);
- aSignatureHelper.EndMission();
-
- fprintf( stdout, "\n\nTEST MISSION 3: Insert a new signature to the first signature file\n");
-
- aSignatureHelper.StartMission();
-
- nSecurityId = aSignatureHelper.GetNewSecurityId();
-
- // Select certificate...
- uno::Reference< ::com::sun::star::security::XCertificate > xPersonalCert = getCertificateFromEnvironment( xSecurityEnvironment, true );
- aSignatureHelper.SetX509Certificate(
- nSecurityId, xPersonalCert->getIssuerName(),
- bigIntegerToNumericString( xPersonalCert->getSerialNumber()),
- baseEncode(xPersonalCert->getEncoded(), BASE64));
- aSignatureHelper.AddForSigning( nSecurityId, aXMLFileName, aXMLFileName, sal_False );
- 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]);
- aSignatureHelper.CloseDocumentHandler( xDocumentHandler);
-
- if ( !bDone )
- fprintf( stderr, "\nSTATUS MISSION 3: Error creating Signature!\n" );
- else
- fprintf( stdout, "\nSTATUS MISSION 3: Signature successfully created!\n" );
-
- aSignatureHelper.EndMission();
-
- fprintf( stdout, "\n\nTEST MISSION 4 : Verify the first signature file\n");
-
- aSignatureHelper.SetStartVerifySignatureHdl( Link( NULL, startVerifyHandler ) );
-
- aSignatureHelper.StartMission();
-
- xInputStream = OpenInputStream( aSIGFileName );
- bDone = aSignatureHelper.ReadAndVerifySignature( xInputStream );
- xInputStream->closeInput();
-
- if ( !bDone )
- fprintf( stderr, "\nSTATUS MISSION 4: Error verifying Signatures!\n" );
- else
- fprintf( stdout, "\nSTATUS MISSION 4: All choosen Signatures veryfied successfully!\n" );
-
- aSignatureHelper.EndMission();
-
- 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
- fprintf( stdout, "\nSTATUS MISSION 5: All choosen Signatures veryfied successfully!\n" );
-
- aSignatureHelper.EndMission();
-
- QueryPrintSignatureDetails( aSignatureHelper.GetSignatureInformations(), aSignatureHelper.GetSecurityEnvironment() );
-
- return 0;
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmlsecurity/tools/demo/performance.cxx b/xmlsecurity/tools/demo/performance.cxx
deleted file mode 100644
index a806997cf03c..000000000000
--- a/xmlsecurity/tools/demo/performance.cxx
+++ /dev/null
@@ -1,1872 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*************************************************************************
- *
- * 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
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-
-#include <rtl/ustring.hxx>
-#include <cppuhelper/bootstrap.hxx>
-#include <cppuhelper/servicefactory.hxx>
-#include <com/sun/star/bridge/XUnoUrlResolver.hpp>
-#include <com/sun/star/registry/XImplementationRegistration.hpp>
-#include <com/sun/star/beans/XPropertySet.hpp>
-#include <com/sun/star/lang/XMultiComponentFactory.hpp>
-
-#include <comphelper/processfactory.hxx>
-
-#include <iostream>
-#include <fstream>
-
-#include <util.hxx>
-
-#include <com/sun/star/lang/XMultiServiceFactory.hpp>
-#include <com/sun/star/io/XOutputStream.hpp>
-#include <com/sun/star/io/XInputStream.hpp>
-#include <com/sun/star/xml/sax/XParser.hpp>
-#include <com/sun/star/xml/sax/XDocumentHandler.hpp>
-#include <com/sun/star/xml/sax/XAttributeList.hpp>
-#include <cppuhelper/implbase4.hxx>
-
-#include <com/sun/star/xml/crypto/sax/XSignatureCreationResultListener.hpp>
-#include <com/sun/star/xml/crypto/sax/XSignatureVerifyResultListener.hpp>
-#include <com/sun/star/xml/crypto/sax/XSAXEventKeeperStatusChangeListener.hpp>
-#include <com/sun/star/xml/crypto/sax/XSecuritySAXEventKeeper.hpp>
-#include <com/sun/star/xml/crypto/sax/XReferenceResolvedListener.hpp>
-#include <com/sun/star/xml/crypto/XXMLSignature.hpp>
-#include <com/sun/star/xml/csax/XMLAttribute.hpp>
-#include <com/sun/star/xml/crypto/XSEInitializer.hpp>
-#include <com/sun/star/xml/crypto/SecurityOperationStatus.hpp>
-#include <com/sun/star/io/XActiveDataSource.hpp>
-#include <com/sun/star/lang/XInitialization.hpp>
-#include <com/sun/star/xml/crypto/sax/XKeyCollector.hpp>
-#include <com/sun/star/xml/crypto/sax/ElementMarkPriority.hpp>
-#include <com/sun/star/xml/crypto/sax/XReferenceResolvedBroadcaster.hpp>
-#include <com/sun/star/xml/crypto/sax/XMissionTaker.hpp>
-#include <com/sun/star/xml/crypto/sax/XBlockerMonitor.hpp>
-#include <com/sun/star/xml/crypto/sax/XSignatureCreationResultBroadcaster.hpp>
-#include <com/sun/star/xml/crypto/sax/XSignatureVerifyResultBroadcaster.hpp>
-#include <com/sun/star/xml/crypto/sax/XReferenceCollector.hpp>
-#include <com/sun/star/xml/crypto/sax/XSAXEventKeeperStatusChangeBroadcaster.hpp>
-#include <com/sun/star/xml/wrapper/XXMLDocumentWrapper.hpp>
-
-#include <xmloff/attrlist.hxx>
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <osl/time.h>
-
-
-#ifndef INCLUDED_VECTOR
-#include <vector>
-#define INCLUDED_VECTOR
-#endif
-
-#ifndef INCLUDED_STACK
-#include <stack>
-#define INCLUDED_STACK
-#endif
-
-/* xml security framework components */
-#define SIGNATURECREATOR_COMPONENT "com.sun.star.xml.crypto.sax.SignatureCreator"
-#define SIGNATUREVERIFIER_COMPONENT "com.sun.star.xml.crypto.sax.SignatureVerifier"
-#define JAVAFLATFILTER_COMPONENT "com.sun.star.xml.crypto.eval.JavaFlatFilter"
-#define SAXEVENTKEEPER_COMPONENT "com.sun.star.xml.crypto.sax.SAXEventKeeper"
-
-/* java based bridge components */
-#define SEINITIALIZER_JAVA_COMPONENT "com.sun.star.xml.security.bridge.jxsec.SEInitializer_JxsecImpl"
-#define XMLSIGNATURE_JAVA_COMPONENT "com.sun.star.xml.security.bridge.jxsec.XMLSignature_JxsecImpl"
-#define XMLDOCUMENTWRAPPER_JAVA_COMPONENT "com.sun.star.xml.security.bridge.jxsec.XMLDocumentWrapper_JxsecImpl"
-
-/* c based bridge components */
-#define SEINITIALIZER_C_COMPONENT "com.sun.star.xml.crypto.SEInitializer"
-#define XMLSIGNATURE_C_COMPONENT "com.sun.star.xml.crypto.XMLSignature"
-#define XMLDOCUMENT_C_COMPONENT "com.sun.star.xml.wrapper.XMLDocumentWrapper"
-
-/* security related elements and attributes */
-#define SIGNATURE_STR "Signature"
-#define REFERENCE_STR "Reference"
-#define SIGNEDINFO_STR "SignedInfo"
-#define KEYINFO_STR "KeyInfo"
-#define KEYVALUE_STR "KeyValue"
-#define KEYNAME_STR "KeyName"
-#define X509DATA_STR "X509Data"
-#define ENCRYPTEDKEY_STR "EncryptedKey"
-#define RETRIEVALMETHOD_STR "RetrievalMethod"
-#define OTHER_ELEMENT_STR "OTHER_ELEMENT_STR"
-#define REFNUM_ATTR_STR "refNum"
-#define URI_ATTR_STR "URI"
-
-
-#define RTL_ASCII_USTRINGPARAM( asciiStr ) asciiStr, strlen( asciiStr ), RTL_TEXTENCODING_ASCII_US
-
-namespace cssu = com::sun::star::uno;
-namespace cssl = com::sun::star::lang;
-namespace cssb = com::sun::star::beans;
-namespace cssi = com::sun::star::io;
-namespace cssxc = com::sun::star::xml::crypto;
-namespace cssxs = com::sun::star::xml::sax;
-namespace cssxw = com::sun::star::xml::wrapper;
-namespace cssxcsax = com::sun::star::xml::csax;
-
-
-using namespace ::com::sun::star;
-
-
-class XSecTester;
-
-/*
- * The XSecTester class is a C++ version of SecurityFramworkController.java
- *
- */
-
-class SecurityEntity
-{
-private:
- static int m_nNextSecurityId;
- rtl::OUString m_ouKeyURI;
-
-protected:
- com::sun::star::uno::Reference<
- com::sun::star::lang::XMultiServiceFactory > mxMSF;
-
- 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 >
- m_xSAXEventKeeper;
-
- com::sun::star::uno::Reference<
- com::sun::star::xml::crypto::XXMLSecurityContext >
- m_xXMLSecurityContext;
-
- com::sun::star::uno::Reference<
- com::sun::star::xml::crypto::XXMLSignature >
- m_xXMLSignature;
-
- int m_nSecurityId;
-
-private:
- int getNextSecurityId() const;
-
-protected:
- SecurityEntity(
- 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 >&
- xXMLSecurityContext,
- const com::sun::star::uno::Reference<
- com::sun::star::xml::crypto::XXMLSignature >&
- xXMLSignature,
- 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 >
- getReferenceListener() const;
-
- bool setKey( const rtl::OUString& ouUri, bool bIsExporting );
-
- void setKeyURI(const rtl::OUString& ouUri);
-
- bool endMission();
-};
-
-
-class SignatureEntity : public SecurityEntity
-{
-private:
- std::vector< rtl::OUString > m_vReferenceIds;
- int m_nSignatureElementCollectorId;
-
- bool hasReference(const rtl::OUString& ouUri) const;
-
-public:
- SignatureEntity(
- const com::sun::star::uno::Reference<
- com::sun::star::xml::crypto::sax::XSecuritySAXEventKeeper >&
- xSAXEventKeeper,
- bool bIsExporting,
- XSecTester* pListener,
- 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 >&
- xXMLSignature,
- const com::sun::star::uno::Reference<
- 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 );
-};
-
-struct AncestorEvent
-{
- AncestorEvent(sal_Int32 nAttrNum) : aAttributeList(nAttrNum), bIsStartElement(false) {};
-
- bool bIsStartElement;
- rtl::OUString ouName;
-
- 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,
- com::sun::star::xml::sax::XDocumentHandler
->
-{
-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 >
- 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 >
- m_xXMLDocumentWrapper;
-
- com::sun::star::uno::Reference<
- com::sun::star::xml::sax::XDocumentHandler >
- m_xOutputHandler;
-
- 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 >
- m_xXMLSecurityContext;
-
- com::sun::star::uno::Reference<
- 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 >
- createOutputStream( const rtl::OUString& ouFile );
-
- rtl::OUString parseFile(
- 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 sendAncestorStartElementEvent(
- 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 sendAncestorEndElementEvent(
- const rtl::OUString& ouName,
- const com::sun::star::uno::Reference<
- com::sun::star::xml::sax::XDocumentHandler >& xDocumentHandler) const;
-
- std::vector< AncestorEvent* >::const_iterator 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), m_bIsExporting(false), m_bIsBlocking(false),
- m_bIsInsideCollectedElement(false), m_bIsSAXEventKeeperOnTheSAXChain(false)
- {
- };
-
- virtual ~XSecTester(){};
-
- /* XSignatureCreationResultListener */
- 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,
- 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(
- 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,
- 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& outputFileName,
- sal_Bool isJavaBased)
- throw (com::sun::star::uno::RuntimeException);
- virtual rtl::OUString SAL_CALL import_xml(
- 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)
- throw (com::sun::star::uno::RuntimeException);
-
- /* XDocumentHandler */
- virtual void SAL_CALL endDocument()
- throw (com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL startDocument()
- throw (com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL characters(const class rtl::OUString&)
- throw (com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL processingInstruction(const rtl::OUString&, const rtl::OUString&)
- throw (com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL ignorableWhitespace(const rtl::OUString&)
- throw (com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL startElement(
- 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&)
- throw (com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL setDocumentLocator(
- const com::sun::star::uno::Reference< com::sun::star::xml::sax::XLocator >&)
- throw (com::sun::star::uno::RuntimeException);
-};
-
-rtl::OUString XSecTester::parseFile(
- 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 )
- {
- /* initialization */
- rtl::OUString SEInitializer_comp;
- rtl::OUString XMLSignature_comp;
- rtl::OUString tokenPath;
- cssu::Reference < cssxc::XSEInitializer > xSEInitializer;
-
- if (bIsJavaBased)
- {
- SEInitializer_comp = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( SEINITIALIZER_JAVA_COMPONENT ));
- XMLSignature_comp = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( XMLSIGNATURE_JAVA_COMPONENT));
- m_ouXMLDocumentWrapperComponentName = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( XMLDOCUMENTWRAPPER_JAVA_COMPONENT ));
- tokenPath = m_ouJavaCryptokenDir;
- }
- else
- {
- SEInitializer_comp = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( SEINITIALIZER_C_COMPONENT ));
- XMLSignature_comp = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( XMLSIGNATURE_C_COMPONENT));
- m_ouXMLDocumentWrapperComponentName = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( XMLDOCUMENT_C_COMPONENT ));
- tokenPath = m_ouCCryptokenDir;
- }
-
- xSEInitializer = cssu::Reference < cssxc::XSEInitializer > (
- mxMSF->createInstance( SEInitializer_comp ),
- 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 (
- 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 (
- 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 =
- 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.empty());
- OSL_ASSERT(m_vUnsolvedReferenceURIs.empty());
- OSL_ASSERT(m_vUnsolvedReferenceKeeperIds.empty());
- OSL_ASSERT(m_vUnsolvedReferenceRefNums.empty());
- 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)
- {
- m_xSaxParser->setDocumentHandler(this);
- m_xSaxParser->parseStream(aInput);
- }
- 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))) /
- ((double)1000000000.0);
-
- char buf[32];
- sprintf(buf, "%.2f", diff);
- ouMessage += rtl::OUString(RTL_ASCII_USTRINGPARAM(buf));
- }
- else
- {
- ouMessage += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("N/A"));
- }
-
- }
- else
- {
- ouMessage += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("-"));
- }
-
- return ouMessage;
-}
-
-/* XSignatureCreationResultListener */
-void SAL_CALL XSecTester::signatureCreated(
- sal_Int32 securityId,
- cssxc::SecurityOperationStatus creationResult )
- throw (cssu::RuntimeException)
-{
- m_nTotalSignatureNumber++;
- if (creationResult == cssxc::SecurityOperationStatus_OPERATION_SUCCEEDED)
- {
- m_nSuccessfulSignatureNumber++;
- }
-}
-
-/* XSignatureVerifyResultListener */
-void SAL_CALL XSecTester::signatureVerified(
- sal_Int32 securityId,
- cssxc::SecurityOperationStatus verifyResult )
- throw (cssu::RuntimeException)
-{
- m_nTotalSignatureNumber++;
- 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;
- }
- else
- {
- m_bIsSAXEventKeeperOnTheSAXChain = true;
- }
- changeOutput();
-}
-
-void SAL_CALL XSecTester::bufferStatusChanged( sal_Bool isBufferEmpty )
- throw (cssu::RuntimeException)
-{
- if (isBufferEmpty)
- {
- m_xXMLDocumentWrapper = NULL;
-
- m_xSAXEventKeeper = NULL;
- m_bIsSAXEventKeeperOnTheSAXChain = false;
- changeOutput();
- }
-}
-
-/* XXMLSecTester */
-rtl::OUString SAL_CALL XSecTester::export_xml( const rtl::OUString& inputFileName, const rtl::OUString& outputFileName, sal_Bool isJavaBased)
- 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);
- ouMessage += rtl::OUString(RTL_ASCII_USTRINGPARAM("\t")) + ouRemark;
-
- return ouMessage;
-}
-
-rtl::OUString SAL_CALL XSecTester::import_xml( const rtl::OUString& inputFileName, const rtl::OUString& outputFileName, sal_Bool isJavaBased)
- throw (cssu::RuntimeException)
-{
- rtl::OUString ouMessage;
-
- m_nTotalSignatureNumber = 0;
- m_nSuccessfulSignatureNumber = 0;
-
- ouMessage += parseFile(inputFileName, outputFileName, sal_False, isJavaBased);
-
- rtl::OUString ouRemark = rtl::OUString::valueOf(m_nSuccessfulSignatureNumber) +
- rtl::OUString(RTL_ASCII_USTRINGPARAM( "/" ))
- + rtl::OUString::valueOf(m_nTotalSignatureNumber);
- ouMessage += rtl::OUString(RTL_ASCII_USTRINGPARAM("\t")) + ouRemark;
-
- return ouMessage;
-}
-
-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 )
- {
- /* create SAX Parser */
- 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 (
- 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(
- xSaxWriter, cssu::UNO_QUERY);
-
- if (!isBridgeInvolved)
- {
- /* connect the SAX Parser and the SAX Writer */
- m_xSaxParser->setDocumentHandler ( xSaxWriterHandler );
- }
- else
- {
- /* create Java Flat Filter */
- const rtl::OUString sJavaFlatFilter(
- RTL_CONSTASCII_USTRINGPARAM( JAVAFLATFILTER_COMPONENT ) );
- cssu::Reference < cssxs::XParser > xJavaFilterParser
- ( mxMSF->createInstance( sJavaFlatFilter ), cssu::UNO_QUERY );
- cssu::Reference < cssxs::XDocumentHandler > xJavaFilterHandler(
- xJavaFilterParser, cssu::UNO_QUERY );
-
- if ( !xJavaFilterParser.is() )
- return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("NO JAVA"));
-
- /* connect the SAX Parser, the Java Flat Filter and the SAX Writer */
- xJavaFilterParser->setDocumentHandler( xSaxWriterHandler );
- m_xSaxParser->setDocumentHandler ( xJavaFilterHandler );
- }
-
-
- /* set output stream */
- cssu::Reference< cssi::XOutputStream > xOutputStream =
- OpenOutputStream(outputFileName);
- xSaxWriter->setOutputStream( xOutputStream );
-
- /* prepare input stream */
- 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];
- sprintf(buf, "%.2f", diff);
- ouMessage += rtl::OUString(RTL_ASCII_USTRINGPARAM(buf));
- }
-
- return ouMessage;
-}
-
-void SAL_CALL XSecTester::setCryptoDir(const rtl::OUString & javaDirName, const rtl::OUString & cDirName)
- throw (cssu::RuntimeException)
-{
- m_ouJavaCryptokenDir = javaDirName;
- m_ouCCryptokenDir = cDirName;
-}
-
-
-cssu::Reference< cssu::XInterface > SAL_CALL XSecTester_createInstance(
- const cssu::Reference< cssl::XMultiServiceFactory > & rSMgr)
- throw( cssu::Exception )
-{
- return (cppu::OWeakObject*) new XSecTester( rSMgr );
-}
-
-int SecurityEntity::m_nNextSecurityId = 1;
-
-SecurityEntity::SecurityEntity(
- const cssu::Reference<cssxc::sax::XSecuritySAXEventKeeper>& xSAXEventKeeper,
- const cssu::Reference<cssxc::XXMLSecurityContext>& xXMLSecurityContext,
- const cssu::Reference<cssxc::XXMLSignature>& xXMLSignature,
- const cssu::Reference< cssl::XMultiServiceFactory > &rsMSF)
- :m_xSAXEventKeeper(xSAXEventKeeper),
- m_xXMLSecurityContext(xXMLSecurityContext),
- m_xXMLSignature(xXMLSignature),
- mxMSF(rsMSF),
- m_ouKeyURI(RTL_ASCII_USTRINGPARAM(""))
-{
- m_nSecurityId = getNextSecurityId();
-}
-
-int SecurityEntity::getNextSecurityId() const
-{
- int nId = m_nNextSecurityId++;
- return nId;
-}
-
-void SecurityEntity::setKeyId(int nId)
-{
- cssu::Reference<cssxc::sax::XKeyCollector> keyCollector (m_xReferenceListener, cssu::UNO_QUERY);
- keyCollector->setKeyId(nId);
-}
-
-
-void SecurityEntity::setKeyURI(const rtl::OUString& ouUri)
-{
- m_ouKeyURI = ouUri;
-}
-
-cssu::Reference<cssxc::sax::XReferenceResolvedListener> SecurityEntity::getReferenceListener() const
-{
- return m_xReferenceListener;
-}
-
-int SecurityEntity::getSecurityId() const
-{
- return m_nSecurityId;
-}
-
-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),
- true);
-
- setKeyId(nKeeperId);
- m_xSAXEventKeeper->setSecurityId(nKeeperId, m_nSecurityId);
-
- cssu::Reference<cssxc::sax::XReferenceResolvedBroadcaster> xReferenceResolvedBroadcaster
- (m_xSAXEventKeeper, cssu::UNO_QUERY);
- xReferenceResolvedBroadcaster->addReferenceResolvedListener(nKeeperId,
- m_xReferenceListener);
-
- rc = true;
- }
-
- return rc;
-}
-
-bool SecurityEntity::endMission()
-{
- 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,
- XSecTester* pListener,
- const cssu::Reference<cssxc::XXMLSecurityContext>& xXMLSecurityContext,
- const cssu::Reference<cssxc::XXMLSignature>& xXMLSignature,
- const cssu::Reference< cssl::XMultiServiceFactory >& rsMSF)
- :SecurityEntity(xSAXEventKeeper,
- xXMLSecurityContext,
- xXMLSignature,
- rsMSF)
-{
- if (bIsExporting)
- {
- m_nSignatureElementCollectorId =
- m_xSAXEventKeeper->addSecurityElementCollector(
- cssxc::sax::ElementMarkPriority_AFTERMODIFY,
- true);
-
- m_xSAXEventKeeper->setSecurityId(m_nSignatureElementCollectorId, m_nSecurityId);
-
- m_xReferenceListener = cssu::Reference< cssxc::sax::XReferenceResolvedListener >(
- mxMSF->createInstance( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( SIGNATURECREATOR_COMPONENT ))),
- 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
- {
- 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(RTL_CONSTASCII_USTRINGPARAM( SIGNATUREVERIFIER_COMPONENT ))),
- 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);
- }
-
- cssu::Reference<cssxc::sax::XReferenceResolvedBroadcaster> xReferenceResolvedBroadcaster
- (m_xSAXEventKeeper, cssu::UNO_QUERY);
- xReferenceResolvedBroadcaster->addReferenceResolvedListener(
- m_nSignatureElementCollectorId, m_xReferenceListener);
-}
-
-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)
- {
- if (ouUri == *ii)
- {
- rc = true;
- break;
- }
- }
-
- return rc;
-}
-
-bool SignatureEntity::setReference(const rtl::OUString& ouUri, bool bIsExporting) const
-{
- bool rc = false;
-
- 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
- (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;
-}
-
-/* XDocumentHandler */
-void SAL_CALL XSecTester::startDocument()
- throw (cssu::RuntimeException)
-{
-}
-
-void SAL_CALL XSecTester::endDocument()
- throw (cssu::RuntimeException)
-{
-}
-
-void SAL_CALL XSecTester::characters(const class rtl::OUString & chars)
- throw (cssu::RuntimeException)
-{
- m_xExportHandler->characters(chars);
-}
-
-void SAL_CALL XSecTester::processingInstruction(const rtl::OUString & target, const rtl::OUString &data)
- throw (cssu::RuntimeException)
-{
- m_xExportHandler->processingInstruction(target, data);
-}
-
-void SAL_CALL XSecTester::ignorableWhitespace(const rtl::OUString &)
- throw (cssu::RuntimeException)
-{
-
-}
-
-void SAL_CALL XSecTester::startElement(const rtl::OUString & name, const cssu::Reference<cssxs::XAttributeList> &xAttribs)
- throw (cssu::RuntimeException)
-{
- rtl::OUString ouIdAttr = xAttribs->getValueByName(
- rtl::OUString(RTL_ASCII_USTRINGPARAM("id")));
-
- 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 (foundSecurityRelated() && ! m_bIsExporting)
- {
- needResend = true;
- }
- }
-
- if ( !m_bIsSAXEventKeeperOnTheSAXChain )
- {
- addStartAncestorEvent(name, xAttribs);
- }
-
- bool bSuppressingForwarding = checkSecurityElement(name, xAttribs);
-
- checkReference(name, xAttribs, ouIdAttr);
-
- if (needResend)
- {
- m_xSAXEventKeeper->setNextHandler(NULL);
-
- cssu::Reference<cssxs::XDocumentHandler> xSAXEventKeeperHandler
- (m_xSAXEventKeeper, cssu::UNO_QUERY);
-
- xSAXEventKeeperHandler->startElement(name, xAttribs);
- m_xSAXEventKeeper->setNextHandler(this);
- }
-
- if (!bSuppressingForwarding)
- {
- m_xExportHandler->startElement(name, xAttribs);
- }
-}
-
-void SAL_CALL XSecTester::endElement(const rtl::OUString& name)
- throw (cssu::RuntimeException)
-{
- 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())
- {
- void* pSignature = m_stCurrentPath.top();
- bIsStringType = m_stCurrentPathType.top();
-
- if (!bIsStringType && pSignature != NULL)
- {
- ((SignatureEntity *) pSignature)->setReferenceNumber();
- }
- }
- }
- }
-
- if ( !m_bIsSAXEventKeeperOnTheSAXChain )
- {
- addEndAncestorEvent(name);
- }
-
- m_xExportHandler->endElement(name);
-}
-
-void SAL_CALL XSecTester::setDocumentLocator( const cssu::Reference<cssxs::XLocator>& )
- throw (cssu::RuntimeException)
-{
-}
-
-void XSecTester::changeOutput()
-{
- if (m_bIsExporting)
- {
- 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
- {
- m_xExportHandler = m_xOutputHandler;
- }
- }
- else
- {
- 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
- {
- m_xSaxParser->setDocumentHandler(this);
- }
-
- }
-}
-
-bool XSecTester::foundSecurityRelated()
-{
- if (m_xSAXEventKeeper == NULL)
- {
- m_bIsBlocking = false;
- m_bIsInsideCollectedElement = false;
-
- m_xXMLDocumentWrapper = cssu::Reference<cssxw::XXMLDocumentWrapper>
- (mxMSF->createInstance( m_ouXMLDocumentWrapperComponentName ),
- cssu::UNO_QUERY);
-
- m_xSAXEventKeeper = cssu::Reference< cssxc::sax::XSecuritySAXEventKeeper >
- (mxMSF->createInstance( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( SAXEVENTKEEPER_COMPONENT ))),
- cssu::UNO_QUERY);
-
- cssu::Reference<cssl::XInitialization> xInitialization(m_xSAXEventKeeper, cssu::UNO_QUERY);
-
- 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->addSAXEventKeeperStatusChangeListener(this);
- }
-
- bool rc = false;
-
- if (!m_bIsSAXEventKeeperOnTheSAXChain)
- {
- rc = true;
- }
-
- m_bIsSAXEventKeeperOnTheSAXChain=true;
- changeOutput();
-
- return rc;
-}
-
-void XSecTester::findKeyOrReference(SecurityEntity* pSecurityEntity, const rtl::OUString& ouUri, bool bIsFindingKey)
-{
- std::vector<rtl::OUString>::iterator ii_referenceURIs;
- std::vector<int>::iterator ii_referenceKeeperIds;
- std::vector<int>::iterator ii_referenceRefNums;
-
- for (ii_referenceURIs = m_vUnsolvedReferenceURIs.begin(),
- ii_referenceKeeperIds = m_vUnsolvedReferenceKeeperIds.begin(),
- ii_referenceRefNums = m_vUnsolvedReferenceRefNums.begin();
- ii_referenceURIs != m_vUnsolvedReferenceURIs.end(); )
- {
- rtl::OUString ouReferenceUri = *ii_referenceURIs;
-
- if (ouReferenceUri == ouUri)
- {
- int nKeeperId = *ii_referenceKeeperIds;
- int nRefNum = *ii_referenceRefNums;
-
- if ( bIsFindingKey )
- {
- int nClonedKeeperId = m_xSAXEventKeeper->cloneElementCollector(
- nKeeperId,
- 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(
- nClonedKeeperId,
- pSecurityEntity->getReferenceListener());
- }
- else
- {
- int nClonedKeeperId = m_xSAXEventKeeper->cloneElementCollector(
- nKeeperId,
- m_bIsExporting?
- (cssxc::sax::ElementMarkPriority_AFTERMODIFY):
- (cssxc::sax::ElementMarkPriority_BEFOREMODIFY));
-
- m_xSAXEventKeeper->setSecurityId(nClonedKeeperId, pSecurityEntity->getSecurityId());
-
- cssu::Reference<cssxc::sax::XReferenceResolvedBroadcaster>
- xReferenceResolvedBroadcaster
- (m_xSAXEventKeeper, cssu::UNO_QUERY);
- xReferenceResolvedBroadcaster->addReferenceResolvedListener(
- nClonedKeeperId,
- pSecurityEntity->getReferenceListener());
-
- cssu::Reference<cssxc::sax::XReferenceCollector> xReferenceCollector
- (pSecurityEntity->getReferenceListener(), cssu::UNO_QUERY);
- xReferenceCollector->setReferenceId(nClonedKeeperId);
- }
-
- nRefNum--;
- 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
- {
- (*ii_referenceRefNums) = nRefNum;
-
- ++ii_referenceURIs;
- ++ii_referenceKeeperIds;
- ++ii_referenceRefNums;
- }
-
- if (bIsFindingKey)
- {
- break;
- }
- }
- else
- {
- ++ii_referenceURIs;
- ++ii_referenceKeeperIds;
- ++ii_referenceRefNums;
- }
- }
-}
-
-bool XSecTester::checkSecurityElement(
- const rtl::OUString& ouLocalName,
- const cssu::Reference<cssxs::XAttributeList>& xAttribs)
-{
- bool rc = false;
-
- if (ouLocalName.equalsAscii(SIGNATURE_STR))
- {
- SignatureEntity* pSignatureEntity = new SignatureEntity(
- m_xSAXEventKeeper,
- m_bIsExporting,
- this,
- 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())
- {
- void* pSignedInfo = m_stCurrentPath.top();
- bool bIsStringType = m_stCurrentPathType.top();
-
- m_stCurrentPath.pop();
- m_stCurrentPathType.pop();
-
- if (bIsStringType && !m_stCurrentPath.empty())
- {
- void* pSignature = m_stCurrentPath.top();
- bool bIsStringType2 = m_stCurrentPathType.top();
-
- if (!strcmp((const char*)pSignedInfo, SIGNEDINFO_STR) && !bIsStringType2)
- {
- 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)
- {
- pSignatureEntity->addReferenceURI(uri);
- findKeyOrReference(pSignatureEntity, uri, true);
- }
- }
- }
- }
- m_stCurrentPath.push(pSignedInfo);
- m_stCurrentPathType.push(bIsStringType);
- }
- 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))
- {
- 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())
- {
- bool bIsStringType2 = m_stCurrentPathType.top();
-
- if (!bIsStringType2)
- {
- 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))
- {
- 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())
- {
- bool bIsStringType2 = m_stCurrentPathType.top();
-
- if (!bIsStringType2)
- {
- 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)
- {
- 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))
- {
- m_stCurrentPath.push((void *)KEYINFO_STR);
- m_stCurrentPathType.push(true);
- }
- else if(ouLocalName.equalsAscii(SIGNEDINFO_STR))
- {
- m_stCurrentPath.push((void *)SIGNEDINFO_STR);
- m_stCurrentPathType.push(true);
- }
- else
- {
- m_stCurrentPath.push((void *)OTHER_ELEMENT_STR);
- m_stCurrentPathType.push(true);
- }
-
- return rc;
-}
-
-void XSecTester::checkReference(
- const rtl::OUString& ouLocalName,
- const cssu::Reference<cssxs::XAttributeList>& xAttribs,
- const rtl::OUString& ouId)
-{
- rtl::OUString refNumStr =
- xAttribs->getValueByName(rtl::OUString(RTL_ASCII_USTRINGPARAM(REFNUM_ATTR_STR)));
-
- if (ouId != NULL && ouId.getLength()>0 )
- {
- int nRefNum = 999;
- if (refNumStr != NULL && refNumStr.getLength()>0 )
- {
- nRefNum = refNumStr.toInt32();
- }
-
- int nLength = m_vSignatureList.size();
- for (int i = 0; i<nLength; ++i)
- {
- SignatureEntity* pSignatureEntity = m_vSignatureList.at(i);
-
- if (pSignatureEntity->setReference(ouId, m_bIsExporting))
- {
- nRefNum--;
- }
-
- if (pSignatureEntity->setKey(ouId, m_bIsExporting))
- {
- nRefNum--;
- }
- }
-
- if (nRefNum>0)
- {
- int nKeeperId;
-
- if (ouLocalName.equalsAscii(ENCRYPTEDKEY_STR))
- {
- nKeeperId = m_xSAXEventKeeper->addSecurityElementCollector(
- m_bIsExporting ?
- (cssxc::sax::ElementMarkPriority_BEFOREMODIFY):
- (cssxc::sax::ElementMarkPriority_AFTERMODIFY),
- true);
- }
- else
- {
- nKeeperId = m_xSAXEventKeeper->addSecurityElementCollector(
- m_bIsExporting?
- (cssxc::sax::ElementMarkPriority_AFTERMODIFY):
- (cssxc::sax::ElementMarkPriority_BEFOREMODIFY),
- false);
- }
-
- m_vUnsolvedReferenceURIs.push_back(ouId);
- m_vUnsolvedReferenceKeeperIds.push_back(nKeeperId);
- m_vUnsolvedReferenceRefNums.push_back(nRefNum);
- }
- }
-}
-
-void XSecTester::endMission()
-{
- while (!m_vSignatureList.empty())
- {
- if (!m_vSignatureList.empty())
- {
- SignatureEntity * pSignatureEntity = m_vSignatureList.at(0);
- m_vSignatureList.erase(m_vSignatureList.begin());
- pSignatureEntity->endMission();
- delete pSignatureEntity;
- }
- }
-
- while (!m_vUnsolvedReferenceURIs.empty())
- {
- int nKeeperId = m_vUnsolvedReferenceKeeperIds.at(0);
- m_xSAXEventKeeper->removeElementCollector(nKeeperId);
- m_vUnsolvedReferenceURIs.erase(m_vUnsolvedReferenceURIs.begin());
- m_vUnsolvedReferenceKeeperIds.erase(m_vUnsolvedReferenceKeeperIds.begin());
- m_vUnsolvedReferenceRefNums.erase(m_vUnsolvedReferenceRefNums.begin());
- }
-}
-
-void XSecTester::addStartAncestorEvent(
- const rtl::OUString& ouName,
- const cssu::Reference< cssxs::XAttributeList >& xAttribs)
-{
- sal_Int32 nLength = xAttribs->getLength();
- AncestorEvent* ancestorEvent = new AncestorEvent( nLength );
-
- ancestorEvent->bIsStartElement = true;
- ancestorEvent->ouName = ouName;
-
- 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 cssu::Sequence< cssxcsax::XMLAttribute >& attrList,
- const cssu::Reference< cssxs::XDocumentHandler >& xDocumentHandler) const
-{
- SvXMLAttributeList* pAttributeList = new SvXMLAttributeList();
- cssu::Reference < cssxs::XAttributeList > xAttrList
- = cssu::Reference< cssxs::XAttributeList > (pAttributeList);
-
- sal_Int32 nLength = attrList.getLength();
-
- for (int i = 0; i<nLength; ++i)
- {
- pAttributeList->AddAttribute( attrList[i].sName, attrList[i].sValue);
- }
-
- xDocumentHandler->startElement(ouName, xAttrList);
-}
-
-void XSecTester::sendAncestorEndElementEvent(
- const rtl::OUString& ouName,
- const cssu::Reference< cssxs::XDocumentHandler >& xDocumentHandler) const
-{
- xDocumentHandler->endElement(ouName);
-}
-
-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(
- (*ii)->ouName, (*ii)->aAttributeList, xDocumentHandler);
- }
- else
- {
- while ((next != m_vAncestorEvents.end()) && ((*next)->bIsStartElement))
- {
- 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);
- }
- else
- {
- sendAncestorEndElementEvent((*ii)->ouName, xDocumentHandler);
- ++ii;
- }
- }
- }
-
- /* free the ancestor events list */
- std::vector< AncestorEvent* >::iterator jj;
-
- while (!m_vAncestorEvents.empty())
- {
- jj = m_vAncestorEvents.begin();
- delete *jj;
- m_vAncestorEvents.erase(jj);
- }
-}
-
-/*
- * Get the length of a file in a platform independant fashion
- */
-int getLength(const char *pInputFileName)
-{
- int nSize = 0;
- std::ifstream data(pInputFileName);
-
- data.seekg(0, std::ios_base::end);
- nSize = data.tellg();
-
- return nSize;
-}
-
-void outputHeader()
-{
- fprintf(stderr, "%16s%4s%8s%12s%12s%12s%12s\n", "File Name", "E/I", "Size", "-C++", "-Java", "Forw-O", "No S/E");
- fprintf(stderr, "===============================================================================\n");
-}
-
-/*
- * 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,
- const rtl::OUString& ouTime_Java,
- const rtl::OUString& ouTime_NoSecurity,
- const rtl::OUString& ouTime_JavaForwardOnly,
- const rtl::OUString& ouRemark_C,
- const rtl::OUString& ouRemark_Java,
- bool bIsExporting)
-{
- int nSize = getLength(rtl::OString(ouInputFileName, ouInputFileName.getLength(), RTL_TEXTENCODING_ASCII_US).getStr());
- std::ofstream data;
-
- /* print screen */
- int nPosition = ouInputFileName.lastIndexOf('\\');
- rtl::OUString fileName = ouInputFileName.copy(nPosition + 1);
-
- fprintf(stderr, "%16s", rtl::OString(fileName, fileName.getLength(), RTL_TEXTENCODING_ASCII_US).getStr());
-
- fprintf(stderr, "%4s", bIsExporting?"E":"I");
- fprintf(stderr, "%7dK", nSize/1024);
- 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",
- 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];
- sprintf(str, "%d %s", nSize, rtl::OString(ouTime_C, ouTime_C.getLength(), RTL_TEXTENCODING_ASCII_US).getStr());
- data.open("d:\\time_vs_size.txt", std::ios::app);
- data << str << std::endl;
- data.close();
-
- sprintf(str, "%d %s", nSize, rtl::OString(ouTime_Java, ouTime_Java.getLength(), RTL_TEXTENCODING_ASCII_US).getStr());
- data.open("d:\\time_vs_size_without_sec.txt", std::ios::app);
- data << str << std::endl;
- data.close();
- */
-}
-
-int main( int argc, char **argv )
-{
- if (argc < 3)
- {
- fprintf(stderr, "Usage: testtool <exportbatchfile> <importbatchfile> [<cppcryptotoken>] [<javacryptotoken>]\n");
- exit (-1);
- }
-
- rtl::OUString aExportBatchFile = rtl::OUString::createFromAscii(argv[1]);
- rtl::OUString aImportBatchFile = rtl::OUString::createFromAscii(argv[2]);
- rtl::OUString aCPPCryptoToken;
- if ( argc > 3 )
- aCPPCryptoToken = rtl::OUString::createFromAscii(argv[3]);
- rtl::OUString aJavaCryptoToken;
- if ( argc > 4 )
- aJavaCryptoToken = rtl::OUString::createFromAscii(argv[4]);
-
- 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;
- rtl::OUString outputFileName2;
- rtl::OUString ouRemark_C, ouRemark_Java;
-
- outputHeader();
-
- std::ifstream batch_export, batch_import;
-
- batch_export.open(OUStringToOString( aExportBatchFile, RTL_TEXTENCODING_ASCII_US ).getStr());
-
- const int MAX_LINE = 80;
- char line[MAX_LINE + 1];
-
- 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) +
- rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("-ex.xml"));
- ouTime_C = pTester->export_xml(ouInputFileName, outputFileName1, sal_False);
- nPosition1 = ouTime_C.lastIndexOf('\t');
- ouRemark_C = ouTime_C.copy(nPosition1 + 1);
- ouTime_C = ouTime_C.copy(0, nPosition1);
-
- /*
- * export the file with signautre/encryption (Java)
- */
- outputFileName1 = ouInputFileName.copy(0, nPosition) +
- rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("-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) +
- rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("-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) +
- rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("-ex-jf.xml"));
- ouTime_JavaForwardOnly = pTester->transfer_without_sec(ouInputFileName, outputFileName2, sal_True);
-
- /*
- * print output
- */
- output(ouInputFileName, ouTime_C, ouTime_Java, ouTime_NoSecurity, ouTime_JavaForwardOnly, ouRemark_C, ouRemark_Java, true);
- }
-
- batch_export.close();
-
- batch_import.open(OUStringToOString( aImportBatchFile, RTL_TEXTENCODING_ASCII_US ).getStr());
-
- 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) +
- rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("-im.xml"));
- ouTime_C = pTester->import_xml(ouInputFileName, outputFileName1, sal_False);
- nPosition1 = ouTime_C.lastIndexOf('\t');
- ouRemark_C = ouTime_C.copy(nPosition1 + 1);
- ouTime_C = ouTime_C.copy(0, nPosition1);
-
- /*
- * import the file with signautre/encryption (Java)
- */
- outputFileName1 = ouInputFileName.copy(0, nPosition) +
- rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("-im2.xml"));
- ouTime_Java = pTester->import_xml(ouInputFileName, outputFileName1, sal_True);
- nPosition1 = ouTime_Java.lastIndexOf('\t');
- ouRemark_Java = ouTime_Java.copy(nPosition1 + 1);
- ouTime_Java = ouTime_Java.copy(0, nPosition1);
-
- /*
- * import the file without signautre/encryption
- */
- outputFileName2 = ouInputFileName.copy(0, nPosition) +
- rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("-im-no.xml"));
- ouTime_NoSecurity = pTester->transfer_without_sec(ouInputFileName, outputFileName2, sal_False);
-
- /*
- * import the file without signautre/encryption
- */
-
- outputFileName2 = ouInputFileName.copy(0, nPosition) +
- rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("-im-jf.xml"));
- ouTime_JavaForwardOnly = pTester->transfer_without_sec(ouInputFileName, outputFileName2, sal_True);
-
- /*
- * print output
- */
- output(ouInputFileName, ouTime_C, ouTime_Java, ouTime_NoSecurity, ouTime_JavaForwardOnly, ouRemark_C, ouRemark_Java, false);
- }
-
- batch_import.close();
-
- fprintf(stderr, "\n");
- }
- catch( cssu::Exception& e )
- {
- fprintf( stderr , "\nEXCEPTION! Error Message: %s\n" ,
- rtl::OUStringToOString( e.Message, RTL_TEXTENCODING_ASCII_US ).getStr() ) ;
- }
-
- return 0;
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmlsecurity/tools/demo/readme.txt b/xmlsecurity/tools/demo/readme.txt
deleted file mode 100644
index 33b5e56ccecb..000000000000
--- a/xmlsecurity/tools/demo/readme.txt
+++ /dev/null
@@ -1,22 +0,0 @@
-How to use the demo programs
-=================================
-
-
-PERFORMANCE
--------------------------------
-
-This program is for evaluating the performance of the XML Security framework.
-
-You can use the sample files from tools/examples:
-
-run "performance eval_export.txt eval_import.txt"
-
-The export file list includes all files need to be signed, and the import file list include all files need to be verified.
-
-JavaFlatFilter:
-Used to test performance with Java.
-Currently it doesn't work, seems to be because of JavaFramework doesn't work in stand alone program.
-
-In case you want to try it:
-- set CLASSPATH=e:\Solar\r\j2sdk1.4.1_03\jre\lib;d:\x\juh.jar;d:\x\jurt.jar;d:\x\ridl.jar;d:\x\unoil.jar;d:\x\java_uno.jar
-- regcomp -register -r demo.rdb -c file://d/x/jflatfilter.jar -br demo.rdb \ No newline at end of file
diff --git a/xmlsecurity/tools/demo/signdemo.cxx b/xmlsecurity/tools/demo/signdemo.cxx
deleted file mode 100644
index 9ececf1ce321..000000000000
--- a/xmlsecurity/tools/demo/signdemo.cxx
+++ /dev/null
@@ -1,157 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*************************************************************************
- *
- * 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
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-
-#include "util.hxx"
-
-#include <stdio.h>
-#include <tools/date.hxx>
-#include <tools/time.hxx>
-#include <cppuhelper/servicefactory.hxx>
-
-#include <xmlsecurity/biginteger.hxx>
-#include <xmlsecurity/xmlsignaturehelper.hxx>
-#include "xmlsecurity/baseencoding.hxx"
-
-using namespace ::com::sun::star;
-
-int SAL_CALL main( int argc, char **argv )
-{
- if( argc < 4 )
- {
- fprintf( stderr, "Usage: %s <signature file> <xml stream file> <binary stream file> [<cryptoken>]\n" , argv[0] ) ;
- return -1 ;
- }
-
- rtl::OUString aSIGFileName = rtl::OUString::createFromAscii(argv[1]);
- rtl::OUString aXMLFileName = rtl::OUString::createFromAscii(argv[2]);
- rtl::OUString aBINFileName = rtl::OUString::createFromAscii(argv[3]);
- 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.
- */
- bool bInit = aSignatureHelper.Init( aCryptoToken );
- if ( !bInit )
- {
- 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 )
- {
- 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 ++ )
- 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() )
- {
- fprintf( stdout, "No certificate choosen - exit.\n" );
- return (-2);
- }
-
- /*
- * creates a new signature id
- */
- sal_Int32 nSecurityId = aSignatureHelper.GetNewSecurityId();
-
- /*
- * configures the X509 certificate
- */
- aSignatureHelper.SetX509Certificate(
- nSecurityId, nEnvIndex,
- xPersonalCert->getIssuerName(),
- bigIntegerToNumericString( xPersonalCert->getSerialNumber()),
- baseEncode(xPersonalCert->getEncoded(), BASE64));
-
- /*
- * 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" );
- }
- else
- {
- fprintf( stdout, "\nSTATUS: Signature successfully created!\n" );
- }
-
- aSignatureHelper.EndMission();
-
- QueryPrintSignatureDetails( aSignatureHelper.GetSignatureInformations(), aSignatureHelper.GetSecurityEnvironment() );
-
- return 0;
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmlsecurity/tools/demo/util.cxx b/xmlsecurity/tools/demo/util.cxx
deleted file mode 100644
index 96e414ec0612..000000000000
--- a/xmlsecurity/tools/demo/util.cxx
+++ /dev/null
@@ -1,112 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*************************************************************************
- *
- * 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
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-
-#include "util.hxx"
-
-#include <stdio.h>
-
-#include <com/sun/star/registry/XImplementationRegistration.hpp>
-#include <cppuhelper/bootstrap.hxx>
-#include <comphelper/processfactory.hxx>
-#include <unotools/streamhelper.hxx>
-#include <tools/string.hxx>
-
-namespace cssu = com::sun::star::uno;
-namespace cssl = com::sun::star::lang;
-namespace cssxc = com::sun::star::xml::crypto;
-namespace cssi = com::sun::star::io;
-
-using namespace ::com::sun::star;
-
-cssu::Reference< cssl::XMultiServiceFactory > CreateDemoServiceFactory()
-{
- cssu::Reference< cssl::XMultiServiceFactory > xMSF;
-
- try
- {
- cssu::Reference< cssl::XMultiComponentFactory > xLocalServiceManager = NULL ;
- cssu::Reference< cssu::XComponentContext > xLocalComponentContext = NULL ;
-
- cssu::Reference< ::com::sun::star::registry::XSimpleRegistry > xSimpleRegistry
- = ::cppu::createSimpleRegistry();
- OSL_ENSURE( xSimpleRegistry.is(),
- "serviceManager - "
- "Cannot create simple registry" ) ;
-
- xSimpleRegistry->open(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("demo.rdb")), sal_True, sal_False);
- OSL_ENSURE( xSimpleRegistry->isValid() ,
- "serviceManager - "
- "Cannot open xml security registry rdb" ) ;
-
- xLocalComponentContext = ::cppu::bootstrap_InitialComponentContext( xSimpleRegistry ) ;
- OSL_ENSURE( xLocalComponentContext.is() ,
- "serviceManager - "
- "Cannot create intial component context" ) ;
-
- xLocalServiceManager = xLocalComponentContext->getServiceManager() ;
- OSL_ENSURE( xLocalServiceManager.is() ,
- "serviceManager - "
- "Cannot create intial service manager" ) ;
-
- xMSF = cssu::Reference< cssl::XMultiServiceFactory >(xLocalServiceManager, cssu::UNO_QUERY) ;
-
- ::comphelper::setProcessServiceFactory( xMSF );
- }
- catch( cssu::Exception& e )
- {
- fprintf( stderr , "Error creating ServiceManager, Exception is %s\n" , rtl::OUStringToOString( e.Message , RTL_TEXTENCODING_ASCII_US ).getStr() ) ;
- exit (-1);
- }
-
- return xMSF;
-}
-
-::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > OpenInputStream( const ::rtl::OUString& rStreamName )
-{
- SvFileStream* pStream = new SvFileStream( rStreamName, STREAM_READ );
- pStream->Seek( STREAM_SEEK_TO_END );
- sal_uLong nBytes = pStream->Tell();
- pStream->Seek( STREAM_SEEK_TO_BEGIN );
- SvLockBytesRef xLockBytes = new SvLockBytes( pStream, sal_True );
- uno::Reference< io::XInputStream > xInputStream = new utl::OInputStreamHelper( xLockBytes, nBytes );
-
- return xInputStream;
-
-}
-
-::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream > OpenOutputStream( const ::rtl::OUString& rStreamName )
-{
- SvFileStream* pStream = new SvFileStream( rStreamName, STREAM_WRITE );
- SvLockBytesRef xLockBytes = new SvLockBytes( pStream, sal_True );
- uno::Reference< io::XOutputStream > xOutputStream = new utl::OOutputStreamHelper( xLockBytes );
-
- return xOutputStream;
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmlsecurity/tools/demo/util.hxx b/xmlsecurity/tools/demo/util.hxx
deleted file mode 100644
index 6f88fd24935f..000000000000
--- a/xmlsecurity/tools/demo/util.hxx
+++ /dev/null
@@ -1,53 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*************************************************************************
- *
- * 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
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-#include <rtl/ustring.hxx>
-
-#include <cppuhelper/servicefactory.hxx>
-#include <xmlsecurity/xmlsignaturehelper.hxx>
-
-// Get the demo.rdb servcie manager...
-::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > CreateDemoServiceFactory();
-
-// Ask user to show more signature details...
-void QueryPrintSignatureDetails( const SignatureInformations& SignatureInformations, ::com::sun::star::uno::Reference< ::com::sun::star::xml::crypto::XSecurityEnvironment > );
-
-// Query value from user.
-int QuerySelectNumber( int nMin, int nMax );
-
-// Ask to verify the signature
-long QueryVerifySignature();
-
-// Open In/Output Stream
-::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > OpenInputStream( const ::rtl::OUString& rStreamName );
-::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, sal_Bool nType);
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmlsecurity/tools/demo/util2.cxx b/xmlsecurity/tools/demo/util2.cxx
deleted file mode 100644
index 1babdfd4d3ef..000000000000
--- a/xmlsecurity/tools/demo/util2.cxx
+++ /dev/null
@@ -1,427 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*************************************************************************
- *
- * 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
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-
-#include <rtl/locale.h>
-#include <osl/nlsupport.h>
-#include <osl/process.h>
-
-#include <util.hxx>
-
-#include <stdio.h>
-
-#include <com/sun/star/registry/XImplementationRegistration.hpp>
-#include <com/sun/star/security/KeyUsage.hpp>
-#include <cppuhelper/bootstrap.hxx>
-#include <xmlsecurity/biginteger.hxx>
-#include <comphelper/processfactory.hxx>
-#include <unotools/streamhelper.hxx>
-
-#include <rtl/ustrbuf.hxx>
-#include <tools/string.hxx>
-
-namespace cssu = com::sun::star::uno;
-namespace cssl = com::sun::star::lang;
-namespace cssxc = com::sun::star::xml::crypto;
-namespace cssi = com::sun::star::io;
-
-using namespace ::com::sun::star;
-
-/** convert util::DateTime to ISO Date String */
-void convertDateTime( ::rtl::OUStringBuffer& rBuffer,
- const com::sun::star::util::DateTime& rDateTime )
-{
- String aString( String::CreateFromInt32( rDateTime.Year ) );
- aString += '-';
- if( rDateTime.Month < 10 )
- aString += '0';
- aString += String::CreateFromInt32( rDateTime.Month );
- aString += '-';
- if( rDateTime.Day < 10 )
- aString += '0';
- aString += String::CreateFromInt32( rDateTime.Day );
-
- if( rDateTime.Seconds != 0 ||
- rDateTime.Minutes != 0 ||
- rDateTime.Hours != 0 )
- {
- aString += 'T';
- if( rDateTime.Hours < 10 )
- aString += '0';
- aString += String::CreateFromInt32( rDateTime.Hours );
- aString += ':';
- if( rDateTime.Minutes < 10 )
- aString += '0';
- aString += String::CreateFromInt32( rDateTime.Minutes );
- aString += ':';
- if( rDateTime.Seconds < 10 )
- aString += '0';
- aString += String::CreateFromInt32( rDateTime.Seconds );
- if ( rDateTime.HundredthSeconds > 0)
- {
- aString += ',';
- if (rDateTime.HundredthSeconds < 10)
- aString += '0';
- aString += String::CreateFromInt32( rDateTime.HundredthSeconds );
- }
- }
-
- rBuffer.append( aString );
-}
-
-::rtl::OUString printHexString(cssu::Sequence< sal_Int8 > data)
-{
- 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,
- cssu::Reference< ::com::sun::star::xml::crypto::XSecurityEnvironment >& xSecurityEnvironment )
-{
- char* status[50] = {
- "STATUS_UNKNOWN",
- "OPERATION_SUCCEEDED",
- "RUNTIMEERROR_FAILED",
- "ENGINE_FAILED",
- "MALLOC_FAILED",
- "STRDUP_FAILED",
- "CRYPTO_FAILED",
- "XML_FAILED",
- "XSLT_FAILED",
- "IO_FAILED",
- "DISABLED",
- "NOT_IMPLEMENTED",
- "INVALID_SIZE",
- "INVALID_DATA",
- "INVALID_RESULT",
- "INVALID_TYPE",
- "INVALID_OPERATION",
- "INVALID_STATUS",
- "INVALID_FORMAT",
- "DATA_NOT_MATCH",
- "INVALID_NODE",
- "INVALID_NODE_CONTENT",
- "INVALID_NODE_ATTRIBUTE",
- "MISSING_NODE_ATTRIBUTE",
- "NODE_ALREADY_PRESENT",
- "UNEXPECTED_NODE",
- "NODE_NOT_FOUND",
- "INVALID_TRANSFORM",
- "INVALID_TRANSFORM_KEY",
- "INVALID_URI_TYPE",
- "TRANSFORM_SAME_DOCUMENT_REQUIRED",
- "TRANSFORM_DISABLED",
- "INVALID_KEY_DATA",
- "KEY_DATA_NOT_FOUND",
- "KEY_DATA_ALREADY_EXIST",
- "INVALID_KEY_DATA_SIZE",
- "KEY_NOT_FOUND",
- "KEYDATA_DISABLED",
- "MAX_RETRIEVALS_LEVEL",
- "MAX_RETRIEVAL_TYPE_MISMATCH",
- "MAX_ENCKEY_LEVEL",
- "CERT_VERIFY_FAILED",
- "CERT_NOT_FOUND",
- "CERT_REVOKED",
- "CERT_ISSUER_FAILED",
- "CERT_NOT_YET_VALID",
- "CERT_HAS_EXPIRED",
- "DSIG_NO_REFERENCES",
- "DSIG_INVALID_REFERENCE",
- "ASSERTION"};
-
- rtl::OUString result;
-
- result += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Security Id : "))
- +rtl::OUString::valueOf(infor.nSecurityId)
- +rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\n"));
- result += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Status : ["))
- +rtl::OUString::valueOf((sal_Int32)(infor.nStatus))
- +rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("] "))
- +rtl::OUString::createFromAscii(status[infor.nStatus])
- +rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\n"));
-
- const SignatureReferenceInformations& rInfors = infor.vSignatureReferenceInfors;
- int i;
- int size = rInfors.size();
-
- result += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("--References :\n"));
- for (i=0; i<size; i++)
- {
- result += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("---URI : "));
- result += rInfors[i].ouURI;
- result += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\n"));
- result += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("---DigestValue : "));
- result += rInfors[i].ouDigestValue;
- result += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\n"));
- }
-
- if (infor.ouX509IssuerName.getLength()>0)
- {
- result += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("--X509IssuerName :\n"));
- result += infor.ouX509IssuerName;
- result += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\n"));
- }
-
- if (infor.ouX509SerialNumber.getLength()>0)
- {
- result += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("--X509SerialNumber :\n"));
- result += infor.ouX509SerialNumber;
- result += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\n"));
- }
-
- if (infor.ouX509Certificate.getLength()>0)
- {
- result += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("--X509Certificate :\n"));
- result += infor.ouX509Certificate;
- result += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\n"));
- }
-
- if (infor.ouSignatureValue.getLength()>0)
- {
- result += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("--SignatureValue :\n"));
- result += infor.ouSignatureValue;
- result += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\n"));
- }
-
- result += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("--Date :\n"));
-
- ::rtl::OUStringBuffer buffer;
- convertDateTime( buffer, infor.stDateTime );
- result += buffer.makeStringAndClear();
- result += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\n"));
-
- if (infor.ouX509IssuerName.getLength()>0 && infor.ouX509SerialNumber.getLength()>0 && xSecurityEnvironment.is())
- {
- result += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("--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() )
- {
- fprintf(stdout , " xCert is NULL , so can not buildCertificatePath\n");
- return result ;
- }
- else
- {
- xCertPath = xSecurityEnvironment->buildCertificatePath( xCert ) ;
- }
-
- for( int i = 0; i < xCertPath.getLength(); i++ )
- {
- result += xCertPath[i]->getSubjectName();
- result += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\n Subject public key algorithm : "));
- result += xCertPath[i]->getSubjectPublicKeyAlgorithm();
- result += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\n Signature algorithm : "));
- result += xCertPath[i]->getSignatureAlgorithm();
-
- result += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\n Subject public key value : "));
- cssu::Sequence< sal_Int8 > keyValue = xCertPath[i]->getSubjectPublicKeyValue();
- result += printHexString(keyValue);
-
- result += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\n Thumbprint (SHA1) : "));
- cssu::Sequence< sal_Int8 > SHA1Thumbprint = xCertPath[i]->getSHA1Thumbprint();
- result += printHexString(SHA1Thumbprint);
-
- result += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\n Thumbprint (MD5) : "));
- cssu::Sequence< sal_Int8 > MD5Thumbprint = xCertPath[i]->getMD5Thumbprint();
- result += printHexString(MD5Thumbprint);
-
- result += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\n <<\n"));
- }
-
- result += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\n Key Usage : "));
- sal_Int32 usage = xCert->getCertificateUsage();
-
- if (usage & ::com::sun::star::security::KeyUsage::DIGITAL_SIGNATURE)
- {
- result += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DIGITAL_SIGNATURE "));
- }
-
- if (usage & ::com::sun::star::security::KeyUsage::NON_REPUDIATION)
- {
- result += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("NON_REPUDIATION "));
- }
-
- if (usage & ::com::sun::star::security::KeyUsage::KEY_ENCIPHERMENT)
- {
- result += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("KEY_ENCIPHERMENT "));
- }
-
- if (usage & ::com::sun::star::security::KeyUsage::DATA_ENCIPHERMENT)
- {
- result += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DATA_ENCIPHERMENT "));
- }
-
- if (usage & ::com::sun::star::security::KeyUsage::KEY_AGREEMENT)
- {
- result += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("KEY_AGREEMENT "));
- }
-
- if (usage & ::com::sun::star::security::KeyUsage::KEY_CERT_SIGN)
- {
- result += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("KEY_CERT_SIGN "));
- }
-
- if (usage & ::com::sun::star::security::KeyUsage::CRL_SIGN)
- {
- result += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CRL_SIGN "));
- }
-
- result += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\n"));
- }
-
- result += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\n"));
- return result;
-}
-
-::rtl::OUString getSignatureInformations(
- const SignatureInformations& SignatureInformations,
- 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(RTL_CONSTASCII_USTRINGPARAM("\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 , sal_Bool nType)
-{
- cssu::Sequence< cssu::Reference< ::com::sun::star::security::XCertificate > > xPersonalCerts ;
- int length = 0;
- int i;
-
- // add By CP
- sal_uInt16 encoding ;
- rtl_Locale *pLocale = NULL ;
- osl_getProcessLocale( &pLocale ) ;
- encoding = osl_getTextEncodingFromLocale( pLocale ) ;
- // CP end
-
- if( nType != sal_False )
- xPersonalCerts = xSecurityEnvironment->getPersonalCertificates() ;
- else
- return NULL; // not support then;
-
- length = xPersonalCerts.getLength();
- if(length == 0)
- {
- fprintf( stdout, "\nNo certificate found!\n" ) ;
- return NULL;
- }
-
- fprintf( stdout, "\nSelect a certificate:\n" ) ;
- for( i = 0; i < length; i ++ )
- {
- rtl::OUString xxxIssuer;
- rtl::OUString xxxSubject;
- rtl::OString yyyIssuer;
- rtl::OString yyySubject;
-
- xxxIssuer=xPersonalCerts[i]->getIssuerName();
- yyyIssuer=rtl::OUStringToOString( xxxIssuer, encoding );
-
- xxxSubject=xPersonalCerts[i]->getSubjectName();
- yyySubject=rtl::OUStringToOString( xxxSubject, encoding );
-
- fprintf( stdout, "\n%d:\nsubject=[%s]\nissuer=[%s]\n",
- i+1,
- yyySubject.getStr(),
- yyyIssuer.getStr());
- }
-
- int sel = QuerySelectNumber( 1, length ) -1;
- return xPersonalCerts[sel] ;
-}
-
-void QueryPrintSignatureDetails( const SignatureInformations& SignatureInformations, ::com::sun::star::uno::Reference< ::com::sun::star::xml::crypto::XSecurityEnvironment > rSecEnv )
-{
- char cShowDetails;
- fprintf( stdout, "\nDisplay details (y/n) [y]?" );
- fflush( stdout );
- fscanf( stdin, "%c", &cShowDetails);
- if ( cShowDetails == 'y' )
- {
- rtl_Locale *pLocale = NULL ;
- osl_getProcessLocale( &pLocale ) ;
- sal_uInt16 encoding = osl_getTextEncodingFromLocale( pLocale ) ;
-
- fprintf( stdout, "------------- Signature details START -------------\n" );
- fprintf( stdout, "%s",
- rtl::OUStringToOString(
- getSignatureInformations( SignatureInformations, rSecEnv),
- encoding).getStr());
-
- fprintf( stdout, "------------- Signature details END -------------\n" );
- }
-}
-
-int QuerySelectNumber( int nMin, int nMax )
-{
- fprintf( stdout, "\n" ) ;
- int sel = 0;
- do
- {
- fprintf( stdout, "\nSelect <%d-%d>:", nMin, nMax ) ;
- fflush( stdout );
- fscanf( stdin, "%d", &sel ) ;
- } while( ( sel < nMin ) || ( sel > nMax ) );
-
- return sel;
-}
-
-long QueryVerifySignature()
-{
- char answer;
- fprintf( stdout, "\nFound a signature - verify this one (y/n) [y]?" );
- fflush( stdout );
- fscanf( stdin, "%c", &answer);
- return (answer == 'n')?0:1;
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmlsecurity/tools/demo/verifydemo.cxx b/xmlsecurity/tools/demo/verifydemo.cxx
deleted file mode 100644
index 817dbf4388f3..000000000000
--- a/xmlsecurity/tools/demo/verifydemo.cxx
+++ /dev/null
@@ -1,109 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*************************************************************************
- *
- * 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
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-
-#include "util.hxx"
-
-#include <stdio.h>
-#include <cppuhelper/servicefactory.hxx>
-
-#include <xmlsecurity/xmlsignaturehelper.hxx>
-
-using namespace ::com::sun::star;
-
-long startVerifyHandler( void *, void * )
-{
- return QueryVerifySignature();
-}
-
-int SAL_CALL main( int argc, char **argv )
-{
- if( argc < 2 )
- {
- fprintf( stderr, "Usage: %s <signature file> [<cryptoken>]\n" , argv[0] ) ;
- return -1 ;
- }
-
- rtl::OUString aSIGFileName = rtl::OUString::createFromAscii(argv[1]);
- rtl::OUString aCryptoToken;
- if ( argc >= 3 )
- aCryptoToken = rtl::OUString::createFromAscii(argv[2]);
-
- uno::Reference< lang::XMultiServiceFactory > xMSF = CreateDemoServiceFactory();
-
-
- /*
- * creates a signature helper
- */
- XMLSignatureHelper aSignatureHelper( xMSF );
-
- /*
- * creates a security context.
- */
- bool bInit = aSignatureHelper.Init( aCryptoToken );
- if ( !bInit )
- {
- fprintf( stderr, "Error initializing security context!" );
- return -1;
- }
-
- /*
- * configures the start-verify handler
- */
- aSignatureHelper.SetStartVerifySignatureHdl( Link( NULL, startVerifyHandler ) );
-
- aSignatureHelper.StartMission();
-
- /*
- * verifies the signature
- */
- 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" );
- }
- else
- {
- fprintf( stdout, "\nSTATUS: All choosen Signatures veryfied successfully!\n" );
- }
-
- aSignatureHelper.EndMission();
-
- QueryPrintSignatureDetails( aSignatureHelper.GetSignatureInformations(), aSignatureHelper.GetSecurityEnvironment() );
-
- return 0;
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */