summaryrefslogtreecommitdiff
path: root/xmlsecurity/tools/standalone
diff options
context:
space:
mode:
Diffstat (limited to 'xmlsecurity/tools/standalone')
-rw-r--r--xmlsecurity/tools/standalone/csfit/certmngr.cxx191
-rw-r--r--xmlsecurity/tools/standalone/csfit/decrypter.cxx274
-rw-r--r--xmlsecurity/tools/standalone/csfit/encrypter.cxx311
-rw-r--r--xmlsecurity/tools/standalone/csfit/helper.cxx268
-rw-r--r--xmlsecurity/tools/standalone/csfit/helper.hxx241
-rw-r--r--xmlsecurity/tools/standalone/csfit/makefile.mk155
-rw-r--r--xmlsecurity/tools/standalone/csfit/signer.cxx372
-rw-r--r--xmlsecurity/tools/standalone/csfit/util/makefile.mk174
-rw-r--r--xmlsecurity/tools/standalone/csfit/verifier.cxx342
-rw-r--r--xmlsecurity/tools/standalone/mscsfit/certmngr.cxx154
-rw-r--r--xmlsecurity/tools/standalone/mscsfit/decrypter.cxx248
-rw-r--r--xmlsecurity/tools/standalone/mscsfit/encrypter.cxx310
-rw-r--r--xmlsecurity/tools/standalone/mscsfit/helper.cxx222
-rw-r--r--xmlsecurity/tools/standalone/mscsfit/helper.hxx204
-rw-r--r--xmlsecurity/tools/standalone/mscsfit/makefile.mk131
-rw-r--r--xmlsecurity/tools/standalone/mscsfit/signer.cxx344
-rw-r--r--xmlsecurity/tools/standalone/mscsfit/util/makefile.mk174
-rw-r--r--xmlsecurity/tools/standalone/mscsfit/verifier.cxx329
-rw-r--r--xmlsecurity/tools/standalone/readme.txt19
19 files changed, 0 insertions, 4463 deletions
diff --git a/xmlsecurity/tools/standalone/csfit/certmngr.cxx b/xmlsecurity/tools/standalone/csfit/certmngr.cxx
deleted file mode 100644
index a8ada2d60..000000000
--- a/xmlsecurity/tools/standalone/csfit/certmngr.cxx
+++ /dev/null
@@ -1,191 +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.
- *
- ************************************************************************/
-
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_xmlsecurity.hxx"
-
-#include <stdio.h>
-#include "helper.hxx"
-
-#include "libxml/tree.h"
-#include "libxml/parser.h"
-#ifndef XMLSEC_NO_XSLT
-#include "libxslt/xslt.h"
-#endif
-
-#include "securityenvironment_nssimpl.hxx"
-
-#include <xmlsecurity/biginteger.hxx>
-
-
-#include "nspr.h"
-#include "prtypes.h"
-
-#include "pk11func.h"
-#include "cert.h"
-#include "cryptohi.h"
-#include "certdb.h"
-#include "nss.h"
-
-#include "xmlsec/strings.h"
-#include "xmlsec/xmltree.h"
-
-#include <rtl/ustring.hxx>
-
-using namespace ::rtl ;
-using namespace ::cppu ;
-using namespace ::com::sun::star::uno ;
-using namespace ::com::sun::star::io ;
-using namespace ::com::sun::star::ucb ;
-using namespace ::com::sun::star::beans ;
-using namespace ::com::sun::star::document ;
-using namespace ::com::sun::star::lang ;
-using namespace ::com::sun::star::security ;
-using namespace ::com::sun::star::xml::wrapper ;
-using namespace ::com::sun::star::xml::crypto ;
-
-int SAL_CALL main( int argc, char **argv )
-{
- CERTCertDBHandle* certHandle ;
- PK11SlotInfo* slot ;
-
- if( argc != 3 ) {
- fprintf( stderr, "Usage: %s < CertDir > <rdb file>\n\n" , argv[0] ) ;
- return 1 ;
- }
-
- for( ; getchar() != 'q' ; ) {
- slot = NULL ;
-
- //Initialize NSPR and NSS
- PR_Init( PR_SYSTEM_THREAD, PR_PRIORITY_NORMAL, 1 ) ;
- PK11_SetPasswordFunc( PriPK11PasswordFunc ) ;
- if( NSS_Init( argv[1] ) != SECSuccess ) {
- fprintf( stderr , "### cannot intialize NSS!\n" ) ;
- goto done ;
- }
-
- certHandle = CERT_GetDefaultCertDB() ;
- slot = PK11_GetInternalKeySlot() ;
-
- if( PK11_NeedLogin( slot ) ) {
- SECStatus nRet = PK11_Authenticate( slot, PR_TRUE, NULL );
- if( nRet != SECSuccess ) {
- fprintf( stderr , "### cannot authehticate the crypto token!\n" ) ;
- goto done ;
- }
- }
-
-
- try {
- Reference< XMultiComponentFactory > xManager = NULL ;
- Reference< XComponentContext > xContext = NULL ;
-
- xManager = serviceManager( xContext , OUString(RTL_CONSTASCII_USTRINGPARAM("local")), OUString::createFromAscii( argv[2] ) ) ;
- OSL_ENSURE( xManager.is() ,
- "ServicesManager - "
- "Cannot get service manager" ) ;
-
- //Create security environment
- //Build Security Environment
- Reference< XInterface > xsecenv =
- xManager->createInstanceWithContext( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.xml.security.bridge.xmlsec.SecurityEnvironment_NssImpl")), xContext ) ;
- OSL_ENSURE( xsecenv.is() ,
- "Signer - "
- "Cannot get service instance of \"xsec.SecurityEnvironment\"" ) ;
-
- Reference< XSecurityEnvironment > xSecEnv( xsecenv , UNO_QUERY ) ;
- OSL_ENSURE( xSecEnv.is() ,
- "Signer - "
- "Cannot get interface of \"XSecurityEnvironment\" from service \"xsec.SecurityEnvironment\"" ) ;
-
- //Setup key slot and certDb
- Reference< XUnoTunnel > xEnvTunnel( xsecenv , UNO_QUERY ) ;
- OSL_ENSURE( xEnvTunnel.is() ,
- "Signer - "
- "Cannot get interface of \"XUnoTunnel\" from service \"xsec.SecurityEnvironment\"" ) ;
-
- SecurityEnvironment_NssImpl* pSecEnv = ( SecurityEnvironment_NssImpl* )xEnvTunnel->getSomething( SecurityEnvironment_NssImpl::getUnoTunnelId() ) ;
- OSL_ENSURE( pSecEnv != NULL ,
- "Signer - "
- "Cannot get implementation of \"xsec.SecurityEnvironment\"" ) ;
-
- pSecEnv->setCryptoSlot( slot ) ;
- pSecEnv->setCertDb( certHandle ) ;
-
- //Get personal certificate
- Sequence < Reference< XCertificate > > xPersonalCerts = pSecEnv->getPersonalCertificates() ;
- Sequence < Reference< XCertificate > > xCertPath ;
- for( int i = 0; i < xPersonalCerts.getLength(); i ++ ) {
- //Print the certificate infomation.
- fprintf( stdout, "\nPersonal Certificate Info\n" ) ;
- fprintf( stdout, "\tCertificate Issuer[%s]\n", OUStringToOString( xPersonalCerts[i]->getIssuerName(), RTL_TEXTENCODING_ASCII_US ).getStr() ) ;
- fprintf( stdout, "\tCertificate Serial Number[%s]\n", OUStringToOString( bigIntegerToNumericString( xPersonalCerts[i]->getSerialNumber() ), RTL_TEXTENCODING_ASCII_US ).getStr() ) ;
- fprintf( stdout, "\tCertificate Subject[%s]\n", OUStringToOString( xPersonalCerts[i]->getSubjectName(), RTL_TEXTENCODING_ASCII_US ).getStr() ) ;
-
- //build the certificate path
- xCertPath = pSecEnv->buildCertificatePath( xPersonalCerts[i] ) ;
- //Print the certificate path.
- fprintf( stdout, "\tCertificate Path\n" ) ;
- for( int j = 0; j < xCertPath.getLength(); j ++ ) {
- fprintf( stdout, "\t\tCertificate Authority Subject[%s]\n", OUStringToOString( xCertPath[j]->getSubjectName(), RTL_TEXTENCODING_ASCII_US ).getStr() ) ;
- }
-
- //Get the certificate
- Sequence < sal_Int8 > serial = xPersonalCerts[i]->getSerialNumber() ;
- Reference< XCertificate > xcert = pSecEnv->getCertificate( xPersonalCerts[i]->getIssuerName(), xPersonalCerts[i]->getSerialNumber() ) ;
- if( !xcert.is() ) {
- fprintf( stdout, "The personal certificate is not in the certificate database\n" ) ;
- }
-
- //Get the certificate characters
- sal_Int32 chars = pSecEnv->getCertificateCharacters( xPersonalCerts[i] ) ;
- fprintf( stdout, "The certificate characters are %d\n", chars ) ;
-
- //Get the certificate status
- sal_Int32 validity = pSecEnv->verifyCertificate( xPersonalCerts[i] ) ;
- fprintf( stdout, "The certificate validities are %d\n", validity ) ;
- }
- } catch( Exception& e ) {
- fprintf( stderr , "Error Message: %s\n" , OUStringToOString( e.Message , RTL_TEXTENCODING_ASCII_US ).getStr() ) ;
- goto done ;
- }
-
-done:
- if( slot != NULL )
- PK11_FreeSlot( slot ) ;
-
- PK11_LogoutAll() ;
- NSS_Shutdown() ;
-
- }
-
- return 0;
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmlsecurity/tools/standalone/csfit/decrypter.cxx b/xmlsecurity/tools/standalone/csfit/decrypter.cxx
deleted file mode 100644
index c0c80c50d..000000000
--- a/xmlsecurity/tools/standalone/csfit/decrypter.cxx
+++ /dev/null
@@ -1,274 +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.
- *
- ************************************************************************/
-
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_xmlsecurity.hxx"
-
-#include <stdio.h>
-#include "helper.hxx"
-
-#include "libxml/tree.h"
-#include "libxml/parser.h"
-#ifndef XMLSEC_NO_XSLT
-#include "libxslt/xslt.h"
-#endif
-
-
-#include "securityenvironment_nssimpl.hxx"
-#include "xmlelementwrapper_xmlsecimpl.hxx"
-
-#include "nspr.h"
-#include "prtypes.h"
-
-#include "pk11func.h"
-#include "cert.h"
-#include "cryptohi.h"
-#include "certdb.h"
-#include "nss.h"
-
-#include "xmlsec/strings.h"
-#include "xmlsec/xmltree.h"
-
-#include <rtl/ustring.hxx>
-#include <cppuhelper/bootstrap.hxx>
-#include <cppuhelper/servicefactory.hxx>
-
-#include <com/sun/star/beans/PropertyValue.hpp>
-#include <com/sun/star/xml/wrapper/XXMLElementWrapper.hpp>
-#include <com/sun/star/xml/wrapper/XXMLDocumentWrapper.hpp>
-#include <com/sun/star/xml/crypto/XXMLEncryption.hpp>
-#include <com/sun/star/xml/crypto/XXMLEncryptionTemplate.hpp>
-#include <com/sun/star/xml/crypto/XXMLSecurityContext.hpp>
-#include <com/sun/star/xml/crypto/XSecurityEnvironment.hpp>
-
-
-using namespace ::rtl ;
-using namespace ::cppu ;
-using namespace ::com::sun::star::uno ;
-using namespace ::com::sun::star::io ;
-using namespace ::com::sun::star::ucb ;
-using namespace ::com::sun::star::beans ;
-using namespace ::com::sun::star::document ;
-using namespace ::com::sun::star::lang ;
-using namespace ::com::sun::star::registry ;
-using namespace ::com::sun::star::xml::wrapper ;
-using namespace ::com::sun::star::xml::crypto ;
-
-
-int SAL_CALL main( int argc, char **argv )
-{
- CERTCertDBHandle* certHandle = NULL ;
- PK11SlotInfo* slot = NULL ;
- xmlDocPtr doc = NULL ;
- xmlNodePtr tplNode ;
- xmlNodePtr tarNode ;
- FILE* dstFile = NULL ;
-
-
- if( argc != 5 ) {
- fprintf( stderr, "Usage: %s < CertDir > <input file_url> <output file_url> <rdb file>\n\n" , argv[0] ) ;
- return 1 ;
- }
-
- //Init libxml and libxslt libraries
- xmlInitParser();
- LIBXML_TEST_VERSION
- xmlLoadExtDtdDefaultValue = XML_DETECT_IDS | XML_COMPLETE_ATTRS;
- xmlSubstituteEntitiesDefault(1);
-
- #ifndef XMLSEC_NO_XSLT
- xmlIndentTreeOutput = 1;
- #endif // XMLSEC_NO_XSLT
-
-
- //Initialize NSPR and NSS
- PR_Init( PR_SYSTEM_THREAD, PR_PRIORITY_NORMAL, 1 ) ;
- PK11_SetPasswordFunc( PriPK11PasswordFunc ) ;
- if( NSS_Init( argv[1] ) != SECSuccess ) {
- fprintf( stderr , "### cannot intialize NSS!\n" ) ;
- goto done ;
- }
-
- certHandle = CERT_GetDefaultCertDB() ;
- slot = PK11_GetInternalKeySlot() ;
-
- //Load XML document
- doc = xmlParseFile( argv[2] ) ;
- if( doc == NULL || xmlDocGetRootElement( doc ) == NULL ) {
- fprintf( stderr , "### Cannot load template xml document!\n" ) ;
- goto done ;
- }
-
- //Find the encryption template
- tplNode = xmlSecFindNode( xmlDocGetRootElement( doc ), xmlSecNodeEncryptedData, xmlSecEncNs ) ;
- if( tplNode == NULL ) {
- fprintf( stderr , "### Cannot find the encryption template!\n" ) ;
- goto done ;
- }
-
-
- try {
- Reference< XMultiComponentFactory > xManager = NULL ;
- Reference< XComponentContext > xContext = NULL ;
-
- xManager = serviceManager( xContext , OUString(RTL_CONSTASCII_USTRINGPARAM("local")), OUString::createFromAscii( argv[4] ) ) ;
-
- //Create encryption template
- Reference< XInterface > tplElement =
- xManager->createInstanceWithContext( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.xml.security.bridge.xmlsec.XMLElementWrapper_XmlSecImpl")) , xContext ) ;
- OSL_ENSURE( tplElement.is() ,
- "Decryptor - "
- "Cannot get service instance of \"xsec.XMLElementWrapper\"" ) ;
-
- Reference< XXMLElementWrapper > xTplElement( tplElement , UNO_QUERY ) ;
- OSL_ENSURE( xTplElement.is() ,
- "Decryptor - "
- "Cannot get interface of \"XXMLElementWrapper\" from service \"xsec.XMLElementWrapper\"" ) ;
-
- Reference< XUnoTunnel > xTplEleTunnel( xTplElement , UNO_QUERY ) ;
- OSL_ENSURE( xTplEleTunnel.is() ,
- "Decryptor - "
- "Cannot get interface of \"XUnoTunnel\" from service \"xsec.XMLElementWrapper\"" ) ;
-
- XMLElementWrapper_XmlSecImpl* pTplElement = ( XMLElementWrapper_XmlSecImpl* )xTplEleTunnel->getSomething( XMLElementWrapper_XmlSecImpl::getUnoTunnelImplementationId() ) ;
- OSL_ENSURE( pTplElement != NULL ,
- "Decryptor - "
- "Cannot get implementation of \"xsec.XMLElementWrapper\"" ) ;
-
- pTplElement->setNativeElement( tplNode ) ;
-
- //Build XML Encryption template
- Reference< XInterface > enctpl =
- xManager->createInstanceWithContext( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.xml.crypto.XMLEncryptionTemplate")), xContext ) ;
- OSL_ENSURE( enctpl.is() ,
- "Decryptor - "
- "Cannot get service instance of \"xsec.XMLEncryptionTemplate\"" ) ;
-
- Reference< XXMLEncryptionTemplate > xTemplate( enctpl , UNO_QUERY ) ;
- OSL_ENSURE( xTemplate.is() ,
- "Decryptor - "
- "Cannot get interface of \"XXMLEncryptionTemplate\" from service \"xsec.XMLEncryptionTemplate\"" ) ;
-
- //Import the encryption template
- xTemplate->setTemplate( xTplElement ) ;
-
- //Create security environment
- //Build Security Environment
- Reference< XInterface > xsecenv =
- xManager->createInstanceWithContext( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.xml.security.bridge.xmlsec.SecurityEnvironment_NssImpl")), xContext ) ;
- OSL_ENSURE( xsecenv.is() ,
- "Decryptor - "
- "Cannot get service instance of \"xsec.SecurityEnvironment\"" ) ;
-
- Reference< XSecurityEnvironment > xSecEnv( xsecenv , UNO_QUERY ) ;
- OSL_ENSURE( xSecEnv.is() ,
- "Decryptor - "
- "Cannot get interface of \"XSecurityEnvironment\" from service \"xsec.SecurityEnvironment\"" ) ;
-
- //Setup key slot and certDb
- Reference< XUnoTunnel > xEnvTunnel( xsecenv , UNO_QUERY ) ;
- OSL_ENSURE( xEnvTunnel.is() ,
- "Decryptor - "
- "Cannot get interface of \"XUnoTunnel\" from service \"xsec.SecurityEnvironment\"" ) ;
-
- SecurityEnvironment_NssImpl* pSecEnv = ( SecurityEnvironment_NssImpl* )xEnvTunnel->getSomething( SecurityEnvironment_NssImpl::getUnoTunnelId() ) ;
- OSL_ENSURE( pSecEnv != NULL ,
- "Decryptor - "
- "Cannot get implementation of \"xsec.SecurityEnvironment\"" ) ;
-
- pSecEnv->setCryptoSlot( slot ) ;
- pSecEnv->setCertDb( certHandle ) ;
-
-
- //Build XML Security Context
- Reference< XInterface > xmlsecctx =
- xManager->createInstanceWithContext( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.xml.security.bridge.xmlsec.XMLSecurityContext_NssImpl")), xContext ) ;
- OSL_ENSURE( xmlsecctx.is() ,
- "Decryptor - "
- "Cannot get service instance of \"xsec.XMLSecurityContext\"" ) ;
-
- Reference< XXMLSecurityContext > xSecCtx( xmlsecctx , UNO_QUERY ) ;
- OSL_ENSURE( xSecCtx.is() ,
- "Decryptor - "
- "Cannot get interface of \"XXMLSecurityContext\" from service \"xsec.XMLSecurityContext\"" ) ;
-
- xSecCtx->setSecurityEnvironment( xSecEnv ) ;
-
-
- //Get encrypter
- Reference< XInterface > xmlencrypter =
- xManager->createInstanceWithContext( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.xml.security.bridge.xmlsec.XMLEncryption_NssImpl")), xContext ) ;
- OSL_ENSURE( xmlencrypter.is() ,
- "Decryptor - "
- "Cannot get service instance of \"xsec.XMLEncryption\"" ) ;
-
- Reference< XXMLEncryption > xEncrypter( xmlencrypter , UNO_QUERY ) ;
- OSL_ENSURE( xEncrypter.is() ,
- "Decryptor - "
- "Cannot get interface of \"XXMLEncryption\" from service \"xsec.XMLEncryption\"" ) ;
-
-
- //Perform decryption
- Reference< XXMLElementWrapper> xDecrRes = xEncrypter->decrypt( xTemplate , xSecCtx ) ;
- OSL_ENSURE( xDecrRes.is() ,
- "Decryptor - "
- "Cannot decrypt the xml document" ) ;
- } catch( Exception& e ) {
- fprintf( stderr , "Error Message: %s\n" , OUStringToOString( e.Message , RTL_TEXTENCODING_ASCII_US ).getStr() ) ;
- goto done ;
- }
-
- dstFile = fopen( argv[3], "w" ) ;
- if( dstFile == NULL ) {
- fprintf( stderr , "### Can not open file %s\n", argv[3] ) ;
- goto done ;
- }
-
- //Save result
- xmlDocDump( dstFile, doc ) ;
-
-done:
- if( dstFile != NULL )
- fclose( dstFile ) ;
-
- if( slot != NULL )
- PK11_FreeSlot( slot ) ;
-
- PK11_LogoutAll() ;
- NSS_Shutdown() ;
-
- /* Shutdown libxslt/libxml */
- #ifndef XMLSEC_NO_XSLT
- xsltCleanupGlobals();
- #endif /* XMLSEC_NO_XSLT */
- xmlCleanupParser();
-
- return 0;
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmlsecurity/tools/standalone/csfit/encrypter.cxx b/xmlsecurity/tools/standalone/csfit/encrypter.cxx
deleted file mode 100644
index efdd6164a..000000000
--- a/xmlsecurity/tools/standalone/csfit/encrypter.cxx
+++ /dev/null
@@ -1,311 +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.
- *
- ************************************************************************/
-
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_xmlsecurity.hxx"
-
-#include <stdio.h>
-#include "helper.hxx"
-
-#include "libxml/tree.h"
-#include "libxml/parser.h"
-#ifndef XMLSEC_NO_XSLT
-#include "libxslt/xslt.h"
-#endif
-
-#include "securityenvironment_nssimpl.hxx"
-#include "xmlelementwrapper_xmlsecimpl.hxx"
-
-#include "nspr.h"
-#include "prtypes.h"
-
-#include "pk11func.h"
-#include "cert.h"
-#include "cryptohi.h"
-#include "certdb.h"
-#include "nss.h"
-
-#include "xmlsec/strings.h"
-#include "xmlsec/xmltree.h"
-
-#include <rtl/ustring.hxx>
-#include <cppuhelper/servicefactory.hxx>
-
-#include <com/sun/star/lang/XComponent.hpp>
-#include <com/sun/star/beans/PropertyValue.hpp>
-#include <com/sun/star/xml/wrapper/XXMLElementWrapper.hpp>
-#include <com/sun/star/xml/wrapper/XXMLDocumentWrapper.hpp>
-#include <com/sun/star/xml/crypto/XXMLEncryption.hpp>
-#include <com/sun/star/xml/crypto/XXMLEncryptionTemplate.hpp>
-#include <com/sun/star/xml/crypto/XXMLSecurityContext.hpp>
-#include <com/sun/star/xml/crypto/XSecurityEnvironment.hpp>
-
-using namespace ::rtl ;
-using namespace ::cppu ;
-using namespace ::com::sun::star::uno ;
-using namespace ::com::sun::star::io ;
-using namespace ::com::sun::star::ucb ;
-using namespace ::com::sun::star::beans ;
-using namespace ::com::sun::star::document ;
-using namespace ::com::sun::star::lang ;
-using namespace ::com::sun::star::registry ;
-using namespace ::com::sun::star::xml::wrapper ;
-using namespace ::com::sun::star::xml::crypto ;
-
-int SAL_CALL main( int argc, char **argv )
-{
- CERTCertDBHandle* certHandle ;
- PK11SlotInfo* slot = NULL ;
- PK11SymKey* symKey = NULL ;
- xmlDocPtr doc = NULL ;
- xmlNodePtr tplNode ;
- xmlNodePtr tarNode ;
- FILE* dstFile = NULL ;
-
- if( argc != 7 ) {
- fprintf( stderr, "Usage: %s < CertDir > <file_url of template> <file_url of result> <target element name> <target element namespace> <rdb file>\n\n" , argv[0] ) ;
- return 1 ;
- }
-
- //Init libxml and libxslt libraries
- xmlInitParser();
- LIBXML_TEST_VERSION
- xmlLoadExtDtdDefaultValue = XML_DETECT_IDS | XML_COMPLETE_ATTRS;
- xmlSubstituteEntitiesDefault(1);
-
- #ifndef XMLSEC_NO_XSLT
- xmlIndentTreeOutput = 1;
- #endif // XMLSEC_NO_XSLT
-
- //Initialize NSPR and NSS
- PR_Init( PR_SYSTEM_THREAD, PR_PRIORITY_NORMAL, 1 ) ;
- PK11_SetPasswordFunc( PriPK11PasswordFunc ) ;
- if( NSS_Init( argv[1] ) != SECSuccess ) {
- fprintf( stderr , "### cannot intialize NSS!\n" ) ;
- goto done ;
- }
-
- certHandle = CERT_GetDefaultCertDB() ;
- slot = PK11_GetInternalKeySlot() ;
-
- symKey = PK11_KeyGen( slot , CKM_DES3_CBC, NULL, 128, NULL ) ;
- if( symKey == NULL ) {
- fprintf( stderr , "### cannot create symmetric key!\n" ) ;
- goto done ;
- }
-
- //Load XML document
- doc = xmlParseFile( argv[2] ) ;
- if( doc == NULL || xmlDocGetRootElement( doc ) == NULL ) {
- fprintf( stderr , "### Cannot load template xml document!\n" ) ;
- goto done ;
- }
-
- //Find the encryption template
- tplNode = xmlSecFindNode( xmlDocGetRootElement( doc ), xmlSecNodeEncryptedData, xmlSecEncNs ) ;
- if( tplNode == NULL ) {
- fprintf( stderr , "### Cannot find the encryption template!\n" ) ;
- goto done ;
- }
-
- //Find the encryption template
- tarNode = xmlSecFindNode( xmlDocGetRootElement( doc ), ( const unsigned char*)argv[4], ( const unsigned char*)argv[5] ) ;
- if( tarNode == NULL ) {
- fprintf( stderr , "### Cannot find the encryption target!\n" ) ;
- goto done ;
- }
-
- try {
- Reference< XMultiComponentFactory > xManager = NULL ;
- Reference< XComponentContext > xContext = NULL ;
-
- xManager = serviceManager( xContext , OUString(RTL_CONSTASCII_USTRINGPARAM("local")), OUString::createFromAscii( argv[6] ) ) ;
-
- //Create encryption template
- Reference< XInterface > tplElement =
- xManager->createInstanceWithContext( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.xml.security.bridge.xmlsec.XMLElementWrapper_XmlSecImpl")) , xContext ) ;
- OSL_ENSURE( tplElement.is() ,
- "Encryptor - "
- "Cannot get service instance of \"xsec.XMLElementWrapper\"" ) ;
-
- Reference< XXMLElementWrapper > xTplElement( tplElement , UNO_QUERY ) ;
- OSL_ENSURE( xTplElement.is() ,
- "Encryptor - "
- "Cannot get interface of \"XXMLElementWrapper\" from service \"xsec.XMLElementWrapper\"" ) ;
-
- Reference< XUnoTunnel > xTplEleTunnel( xTplElement , UNO_QUERY ) ;
- OSL_ENSURE( xTplEleTunnel.is() ,
- "Encryptor - "
- "Cannot get interface of \"XUnoTunnel\" from service \"xsec.XMLElementWrapper\"" ) ;
-
- XMLElementWrapper_XmlSecImpl* pTplElement = ( XMLElementWrapper_XmlSecImpl* )xTplEleTunnel->getSomething( XMLElementWrapper_XmlSecImpl::getUnoTunnelImplementationId() ) ;
- OSL_ENSURE( pTplElement != NULL ,
- "Encryptor - "
- "Cannot get implementation of \"xsec.XMLElementWrapper\"" ) ;
-
- pTplElement->setNativeElement( tplNode ) ;
-
- //Create encryption target element
- Reference< XInterface > tarElement =
- xManager->createInstanceWithContext( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.xml.security.bridge.xmlsec.XMLElementWrapper_XmlSecImpl")) , xContext ) ;
- OSL_ENSURE( tarElement.is() ,
- "Encryptor - "
- "Cannot get service instance of \"xsec.XMLElementWrapper\"" ) ;
-
- Reference< XXMLElementWrapper > xTarElement( tarElement , UNO_QUERY ) ;
- OSL_ENSURE( xTarElement.is() ,
- "Encryptor - "
- "Cannot get interface of \"XXMLElementWrapper\" from service \"xsec.XMLElementWrapper\"" ) ;
-
- Reference< XUnoTunnel > xTarEleTunnel( xTarElement , UNO_QUERY ) ;
- OSL_ENSURE( xTarEleTunnel.is() ,
- "Encryptor - "
- "Cannot get interface of \"XUnoTunnel\" from service \"xsec.XMLElementWrapper\"" ) ;
-
- XMLElementWrapper_XmlSecImpl* pTarElement = ( XMLElementWrapper_XmlSecImpl* )xTarEleTunnel->getSomething( XMLElementWrapper_XmlSecImpl::getUnoTunnelImplementationId() ) ;
- OSL_ENSURE( pTarElement != NULL ,
- "Encryptor - "
- "Cannot get implementation of \"xsec.XMLElementWrapper\"" ) ;
-
- pTarElement->setNativeElement( tarNode ) ;
-
-
- //Build XML Encryption template
- Reference< XInterface > enctpl =
- xManager->createInstanceWithContext( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.xml.crypto.XMLEncryptionTemplate")), xContext ) ;
- OSL_ENSURE( enctpl.is() ,
- "Encryptor - "
- "Cannot get service instance of \"xsec.XMLEncryptionTemplate\"" ) ;
-
- Reference< XXMLEncryptionTemplate > xTemplate( enctpl , UNO_QUERY ) ;
- OSL_ENSURE( xTemplate.is() ,
- "Encryptor - "
- "Cannot get interface of \"XXMLEncryptionTemplate\" from service \"xsec.XMLEncryptionTemplate\"" ) ;
-
- //Import the encryption template
- xTemplate->setTemplate( xTplElement ) ;
- xTemplate->setTarget( xTarElement ) ;
-
- //Create security environment
- //Build Security Environment
- Reference< XInterface > xsecenv =
- xManager->createInstanceWithContext( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.xml.security.bridge.xmlsec.SecurityEnvironment_NssImpl")), xContext ) ;
- OSL_ENSURE( xsecenv.is() ,
- "Encryptor - "
- "Cannot get service instance of \"xsec.SecurityEnvironment\"" ) ;
-
- Reference< XSecurityEnvironment > xSecEnv( xsecenv , UNO_QUERY ) ;
- OSL_ENSURE( xSecEnv.is() ,
- "Encryptor - "
- "Cannot get interface of \"XSecurityEnvironment\" from service \"xsec.SecurityEnvironment\"" ) ;
-
- //Setup key slot and certDb
- Reference< XUnoTunnel > xEnvTunnel( xsecenv , UNO_QUERY ) ;
- OSL_ENSURE( xEnvTunnel.is() ,
- "Encryptor - "
- "Cannot get interface of \"XUnoTunnel\" from service \"xsec.SecurityEnvironment\"" ) ;
-
- SecurityEnvironment_NssImpl* pSecEnv = ( SecurityEnvironment_NssImpl* )xEnvTunnel->getSomething( SecurityEnvironment_NssImpl::getUnoTunnelId() ) ;
- OSL_ENSURE( pSecEnv != NULL ,
- "Encryptor - "
- "Cannot get implementation of \"xsec.SecurityEnvironment\"" ) ;
-
- pSecEnv->setCryptoSlot( slot ) ;
- pSecEnv->setCertDb( certHandle ) ;
- pSecEnv->adoptSymKey( symKey ) ;
-
-
- //Build XML Security Context
- Reference< XInterface > xmlsecctx =
- xManager->createInstanceWithContext( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.xml.security.bridge.xmlsec.XMLSecurityContext_NssImpl")), xContext ) ;
- OSL_ENSURE( xmlsecctx.is() ,
- "Encryptor - "
- "Cannot get service instance of \"xsec.XMLSecurityContext\"" ) ;
-
- Reference< XXMLSecurityContext > xSecCtx( xmlsecctx , UNO_QUERY ) ;
- OSL_ENSURE( xSecCtx.is() ,
- "Encryptor - "
- "Cannot get interface of \"XXMLSecurityContext\" from service \"xsec.XMLSecurityContext\"" ) ;
-
- xSecCtx->setSecurityEnvironment( xSecEnv ) ;
-
- //Get encrypter
- Reference< XInterface > xmlencrypter =
- xManager->createInstanceWithContext( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.xml.security.bridge.xmlsec.XMLEncryption_NssImpl")), xContext ) ;
- OSL_ENSURE( xmlencrypter.is() ,
- "Encryptor - "
- "Cannot get service instance of \"xsec.XMLEncryption\"" ) ;
-
- Reference< XXMLEncryption > xEncrypter( xmlencrypter , UNO_QUERY ) ;
- OSL_ENSURE( xEncrypter.is() ,
- "Encryptor - "
- "Cannot get interface of \"XXMLEncryption\" from service \"xsec.XMLEncryption\"" ) ;
-
- //perform encryption
- xTemplate = xEncrypter->encrypt( xTemplate , xSecCtx ) ;
- OSL_ENSURE( xTemplate.is() ,
- "Encryptor - "
- "Cannot encrypt the xml document" ) ;
- } catch( Exception& e ) {
- fprintf( stderr , "Error Message: %s\n" , OUStringToOString( e.Message , RTL_TEXTENCODING_ASCII_US ).getStr() ) ;
- goto done ;
- }
-
- dstFile = fopen( argv[3], "w" ) ;
- if( dstFile == NULL ) {
- fprintf( stderr , "### Can not open file %s\n", argv[3] ) ;
- goto done ;
- }
-
- //Save result
- xmlDocDump( dstFile, doc ) ;
-
-done:
- if( dstFile != NULL )
- fclose( dstFile ) ;
-
- if( symKey != NULL ) {
- PK11_FreeSymKey( symKey ) ;
- }
-
- if( slot != NULL )
- PK11_FreeSlot( slot ) ;
-
- PK11_LogoutAll() ;
- NSS_Shutdown() ;
-
- /* Shutdown libxslt/libxml */
- #ifndef XMLSEC_NO_XSLT
- xsltCleanupGlobals();
- #endif /* XMLSEC_NO_XSLT */
- xmlCleanupParser();
-
- return 0;
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmlsecurity/tools/standalone/csfit/helper.cxx b/xmlsecurity/tools/standalone/csfit/helper.cxx
deleted file mode 100644
index 6487f89cf..000000000
--- a/xmlsecurity/tools/standalone/csfit/helper.cxx
+++ /dev/null
@@ -1,268 +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.
- *
- ************************************************************************/
-
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_xmlsecurity.hxx"
-
-#include "helper.hxx"
-#include "osl/diagnose.h"
-#include "rtl/ustring.h"
-/*#include "libxml/xmlstring.h"
-*/
-
-/*-
- * Helper : create a input stream from a file
- */
-Reference< XInputStream > createStreamFromFile( const OUString sFile )
-{
- const sal_Char* pcFile ;
- OString aString ;
-
- aString = OUStringToOString( sFile , RTL_TEXTENCODING_ASCII_US ) ;
- pcFile = aString.getStr() ;
- if( pcFile != NULL ) {
- FILE *f = fopen( pcFile , "rb" );
- Reference< XInputStream > r;
-
- if( f ) {
- fseek( f , 0 , SEEK_END );
- int nLength = ftell( f );
- fseek( f , 0 , SEEK_SET );
-
- Sequence<sal_Int8> seqIn(nLength);
- fread( seqIn.getArray() , nLength , 1 , f );
-
- r = Reference< XInputStream > ( new OInputStream( seqIn ) );
- fclose( f );
- }
- return r;
- } else {
- return NULL ;
- }
-
- return NULL ;
-}
-
-/*-
- * Helper : set a output stream to a file
- */
-Reference< XOutputStream > createStreamToFile( const OUString sFile )
-{
- const sal_Char* pcFile ;
- OString aString ;
-
- aString = OUStringToOString( sFile , RTL_TEXTENCODING_ASCII_US ) ;
- pcFile = aString.getStr() ;
- if( pcFile != NULL )
- return Reference< XOutputStream >( new OOutputStream( pcFile ) ) ;
- else
- return NULL ;
-}
-
-/*-
- * Helper : get service manager and context
- */
-Reference< XMultiComponentFactory > serviceManager( Reference< XComponentContext >& xContext , OUString sUnoUrl , OUString sRdbUrl ) throw( RuntimeException , Exception )
-{
- Reference< XMultiComponentFactory > xLocalServiceManager = NULL ;
- Reference< XComponentContext > xLocalComponentContext = NULL ;
- Reference< XMultiComponentFactory > xUsedServiceManager = NULL ;
- Reference< XComponentContext > xUsedComponentContext = NULL ;
-
- OSL_ENSURE( sUnoUrl.getLength() ,
- "serviceManager - "
- "No uno URI specified" ) ;
-
- OSL_ENSURE( sRdbUrl.getLength() ,
- "serviceManager - "
- "No rdb URI specified" ) ;
-
- if( sUnoUrl.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "local" ) ) ) {
- Reference< XSimpleRegistry > xSimpleRegistry = createSimpleRegistry();
- OSL_ENSURE( xSimpleRegistry.is() ,
- "serviceManager - "
- "Cannot create simple registry" ) ;
-
- //xSimpleRegistry->open(OUString(RTL_CONSTASCII_USTRINGPARAM("xmlsecurity.rdb")), sal_False, sal_False);
- xSimpleRegistry->open(sRdbUrl, sal_True, sal_False);
- OSL_ENSURE( xSimpleRegistry->isValid() ,
- "serviceManager - "
- "Cannot open xml security registry rdb" ) ;
-
- xLocalComponentContext = 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" ) ;
-
- /*-
- * Because of the exception rasied from
- * ucbhelper/source/provider/provconf.cxx, lin 323
- * I do not use the content broker at present
- ********************************************************************
- //init ucb
- if( ::ucb::ContentBroker::get() == NULL ) {
- Reference< lang::XMultiServiceFactory > xSvmg( xLocalServiceManager , UNO_QUERY ) ;
- OSL_ENSURE( xLocalServiceManager.is() ,
- "serviceManager - "
- "Cannot get multi-service factory" ) ;
-
- Sequence< Any > args( 2 ) ;
- args[ 0 ] <<= OUString(RTL_CONSTASCII_USTRINGPARAM( UCB_CONFIGURATION_KEY1_LOCAL )) ;
- args[ 1 ] <<= OUString(RTL_CONSTASCII_USTRINGPARAM( UCB_CONFIGURATION_KEY2_OFFICE )) ;
- if( ! ::ucb::ContentBroker::initialize( xSvmg , args ) ) {
- throw RuntimeException( OUString(RTL_CONSTASCII_USTRINGPARAM("Cannot inlitialize ContentBroker")) , Reference< XInterface >() , Any() ) ;
- }
- }
- ********************************************************************/
-
- xUsedComponentContext = xLocalComponentContext ;
- xUsedServiceManager = xLocalServiceManager ;
- } else {
- Reference< XComponentContext > xLocalComponentContext = defaultBootstrap_InitialComponentContext() ;
- OSL_ENSURE( xLocalComponentContext.is() ,
- "serviceManager - "
- "Cannot create intial component context" ) ;
-
- Reference< XMultiComponentFactory > xLocalServiceManager = xLocalComponentContext->getServiceManager();
- OSL_ENSURE( xLocalServiceManager.is() ,
- "serviceManager - "
- "Cannot create intial service manager" ) ;
-
- Reference< XInterface > urlResolver =
- xLocalServiceManager->createInstanceWithContext( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.bridge.UnoUrlResolver")) , xLocalComponentContext ) ;
- OSL_ENSURE( urlResolver.is() ,
- "serviceManager - "
- "Cannot get service instance of \"bridge.UnoUrlResolver\"" ) ;
-
- Reference< XUnoUrlResolver > xUnoUrlResolver( urlResolver , UNO_QUERY ) ;
- OSL_ENSURE( xUnoUrlResolver.is() ,
- "serviceManager - "
- "Cannot get interface of \"XUnoUrlResolver\" from service \"bridge.UnoUrlResolver\"" ) ;
-
- Reference< XInterface > initialObject = xUnoUrlResolver->resolve( sUnoUrl ) ;
- OSL_ENSURE( initialObject.is() ,
- "serviceManager - "
- "Cannot resolve uno url" ) ;
-
- /*-
- * Method 1: with Naming Service
- ********************************************************************
- Reference< XNamingService > xNamingService( initialObject , UNO_QUERY ) ;
- OSL_ENSURE( xNamingService.is() ,
- "serviceManager - "
- "Cannot get interface of \"XNamingService\" from URL resolver" ) ;
-
- Reference< XInterface > serviceManager =
- xNamingService->getRegisteredObject( OUString(RTL_CONSTASCII_USTRINGPARAM("StarOffice.ServiceManager")) ) ;
- OSL_ENSURE( serviceManager.is() ,
- "serviceManager - "
- "Cannot get service instance of \"StarOffice.ServiceManager\"" ) ;
-
- xUsedServiceManager = Reference< XMultiComponentFactory >( serviceManager , UNO_QUERY );
- OSL_ENSURE( xUsedServiceManager.is() ,
- "serviceManager - "
- "Cannot get interface of \"XMultiComponentFactory\" from service \"StarOffice.ServiceManager\"" ) ;
-
- Reference< XPropertySet > xPropSet( xUsedServiceManager , UNO_QUERY ) ;
- OSL_ENSURE( xPropSet.is() ,
- "serviceManager - "
- "Cannot get interface of \"XPropertySet\" from service \"StarOffice.ServiceManager\"" ) ;
-
- xPropSet->getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("DefaultContext")) ) >>= xUsedComponentContext ;
- OSL_ENSURE( xUsedComponentContext.is() ,
- "serviceManager - "
- "Cannot create remote component context" ) ;
-
- ********************************************************************/
-
- /*-
- * Method 2: with Componnent context
- ********************************************************************
- Reference< XPropertySet > xPropSet( initialObject , UNO_QUERY ) ;
- OSL_ENSURE( xPropSet.is() ,
- "serviceManager - "
- "Cannot get interface of \"XPropertySet\" from URL resolver" ) ;
-
- xPropSet->getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("DefaultContext")) ) >>= xUsedComponentContext ;
- OSL_ENSURE( xUsedComponentContext.is() ,
- "serviceManager - "
- "Cannot create remote component context" ) ;
-
- xUsedServiceManager = xUsedComponentContext->getServiceManager();
- OSL_ENSURE( xUsedServiceManager.is() ,
- "serviceManager - "
- "Cannot create remote service manager" ) ;
- ********************************************************************/
-
- /*-
- * Method 3: with Service Manager
- ********************************************************************/
- xUsedServiceManager = Reference< XMultiComponentFactory >( initialObject , UNO_QUERY );
- OSL_ENSURE( xUsedServiceManager.is() ,
- "serviceManager - "
- "Cannot create remote service manager" ) ;
-
- Reference< XPropertySet > xPropSet( xUsedServiceManager , UNO_QUERY ) ;
- OSL_ENSURE( xPropSet.is() ,
- "serviceManager - "
- "Cannot get interface of \"XPropertySet\" from service \"StarOffice.ServiceManager\"" ) ;
-
- xPropSet->getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("DefaultContext")) ) >>= xUsedComponentContext ;
- OSL_ENSURE( xUsedComponentContext.is() ,
- "serviceManager - "
- "Cannot create remote component context" ) ;
- /********************************************************************/
- }
-
- xContext = xUsedComponentContext ;
- return xUsedServiceManager ;
-}
-
-char* PriPK11PasswordFunc(
- PK11SlotInfo *slot ,
- PRBool retry ,
- void* arg
-) {
- char* passwd = NULL ;
-
- if( retry != PR_TRUE ) {
- passwd = ( char* )PORT_Alloc( 20 ) ;
- printf( "Input Password:\n" ) ;
- scanf( "%s" , passwd ) ;
- printf( "The passwod is [%s]\n" , passwd ) ;
- }
-
- return passwd ;
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmlsecurity/tools/standalone/csfit/helper.hxx b/xmlsecurity/tools/standalone/csfit/helper.hxx
deleted file mode 100644
index a8d52fbb1..000000000
--- a/xmlsecurity/tools/standalone/csfit/helper.hxx
+++ /dev/null
@@ -1,241 +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 <libxml/xmlstring.h>
-*/
-
-#include <rtl/ustring.hxx>
-#include <pk11func.h>
-
-#include <cppuhelper/bootstrap.hxx>
-#include <cppuhelper/implbase1.hxx>
-#include <cppuhelper/servicefactory.hxx>
-#include <ucbhelper/contentbroker.hxx>
-#include <ucbhelper/configurationkeys.hxx>
-
-#include <com/sun/star/lang/XComponent.hpp>
-#include <com/sun/star/bridge/XUnoUrlResolver.hpp>
-#include <com/sun/star/registry/XImplementationRegistration.hpp>
-#include <com/sun/star/document/XFilter.hpp>
-#include <com/sun/star/document/XExporter.hpp>
-#include <com/sun/star/document/XImporter.hpp>
-#include <com/sun/star/io/XActiveDataSource.hpp>
-#include <com/sun/star/beans/PropertyValue.hpp>
-#include <com/sun/star/beans/XPropertySet.hpp>
-#include <com/sun/star/ucb/XSimpleFileAccess.hpp>
-
-#include <com/sun/star/xml/crypto/XUriBinding.hpp>
-#include <com/sun/star/xml/wrapper/XXMLDocumentWrapper.hpp>
-#include <com/sun/star/xml/wrapper/XXMLElementWrapper.hpp>
-
-#include <com/sun/star/xml/sax/XParser.hpp>
-#include <com/sun/star/xml/sax/XDocumentHandler.hpp>
-#include <com/sun/star/xml/sax/XExtendedDocumentHandler.hpp>
-#include <com/sun/star/xml/sax/InputSource.hpp>
-#include <com/sun/star/io/XInputStream.hpp>
-#include <com/sun/star/io/XOutputStream.hpp>
-#include <com/sun/star/uno/XNamingService.hpp>
-
-using namespace ::rtl ;
-using namespace ::cppu ;
-using namespace ::com::sun::star ;
-using namespace ::com::sun::star::uno ;
-using namespace ::com::sun::star::io ;
-using namespace ::com::sun::star::ucb ;
-using namespace ::com::sun::star::beans ;
-using namespace ::com::sun::star::document ;
-using namespace ::com::sun::star::lang ;
-using namespace ::com::sun::star::bridge ;
-using namespace ::com::sun::star::registry ;
-using namespace ::com::sun::star::task ;
-using namespace ::com::sun::star::xml ;
-using namespace ::com::sun::star::xml::wrapper ;
-using namespace ::com::sun::star::xml::sax ;
-
-
-/**
- * Helper: Implementation of XInputStream
- */
-class OInputStream : public WeakImplHelper1 < XInputStream >
-{
- public:
- OInputStream( const Sequence< sal_Int8 >&seq ) : m_seq( seq ), nPos( 0 ) {}
-
- virtual sal_Int32 SAL_CALL readBytes(
- Sequence< sal_Int8 >& aData ,
- sal_Int32 nBytesToRead
- ) throw( NotConnectedException, BufferSizeExceededException, IOException, RuntimeException )
- {
- nBytesToRead = ( nBytesToRead > m_seq.getLength() - nPos ) ?
- m_seq.getLength() - nPos :
- nBytesToRead ;
- aData = Sequence< sal_Int8 > ( &( m_seq.getConstArray()[nPos] ), nBytesToRead ) ;
- nPos += nBytesToRead ;
- return nBytesToRead ;
- }
-
- virtual sal_Int32 SAL_CALL readSomeBytes(
- ::com::sun::star::uno::Sequence< sal_Int8 >& aData ,
- sal_Int32 nMaxBytesToRead
- ) throw( NotConnectedException, BufferSizeExceededException, IOException, RuntimeException )
- {
- return readBytes( aData, nMaxBytesToRead ) ;
- }
-
- virtual void SAL_CALL skipBytes(
- sal_Int32 nBytesToSkip
- ) throw( NotConnectedException, BufferSizeExceededException, IOException, RuntimeException )
- {
- // not implemented
- }
-
- virtual sal_Int32 SAL_CALL available(
- void
- ) throw( NotConnectedException, IOException, RuntimeException )
- {
- return m_seq.getLength() - nPos ;
- }
-
- virtual void SAL_CALL closeInput(
- void
- ) throw( NotConnectedException, IOException, RuntimeException )
- {
- // not needed
- }
-
- private:
- sal_Int32 nPos;
- Sequence< sal_Int8> m_seq;
-} ;
-
-/**
- * Helper : create a input stream from a file
- */
-Reference< XInputStream > createStreamFromFile( const OUString sFile ) ;
-
-/**
- * Helper: Implementation of XOutputStream
- */
-class OOutputStream : public WeakImplHelper1 < XOutputStream >
-{
- public:
- OOutputStream( const char *pcFile ) {
- strcpy( m_pcFile , pcFile ) ;
- m_f = 0 ;
- }
-
- virtual void SAL_CALL writeBytes(
- const Sequence< sal_Int8 >& aData
- ) throw( NotConnectedException , BufferSizeExceededException , RuntimeException ) {
- if( !m_f ) {
- m_f = fopen( m_pcFile , "w" ) ;
- }
-
- fwrite( aData.getConstArray() , 1 , aData.getLength() , m_f ) ;
- }
-
- virtual void SAL_CALL flush(
- void
- ) throw( NotConnectedException , BufferSizeExceededException , RuntimeException ) {
- fflush( m_f ) ;
- }
-
- virtual void SAL_CALL closeOutput(
- void
- ) throw( NotConnectedException , BufferSizeExceededException , RuntimeException ) {
- fclose( m_f ) ;
- m_f = 0 ;
- }
-
- private:
- char m_pcFile[256];
- FILE *m_f;
-} ;
-
-/**
- * Helper: Implementation of XUriBinding
- */
-class OUriBinding : public WeakImplHelper1 < ::com::sun::star::xml::crypto::XUriBinding >
-{
- public:
- OUriBinding() {
- //Do nothing
- }
-
- OUriBinding(
- ::rtl::OUString& aUri,
- ::com::sun::star::uno::Reference< com::sun::star::io::XInputStream >& aInputStream ) {
- m_vUris.push_back( aUri ) ;
- m_vStreams.push_back( aInputStream ) ;
- }
-
- virtual void SAL_CALL setUriBinding(
- const ::rtl::OUString& aUri ,
- const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& aInputStream
- ) throw( ::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException ) {
- m_vUris.push_back( aUri ) ;
- m_vStreams.push_back( aInputStream ) ;
- }
-
- virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getUriBinding( const ::rtl::OUString& uri ) throw( ::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException ) {
- ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > xInputStream ;
-
- int size = m_vUris.size() ;
- for( int i = 0 ; i<size ; ++i ) {
- if( uri == m_vUris[i] ) {
- xInputStream = m_vStreams[i];
- break;
- }
- }
-
- return xInputStream;
- }
-
- private:
- std::vector< ::rtl::OUString > m_vUris ;
- std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > > m_vStreams ;
-} ;
-
-/**
- * Helper : set a output stream to a file
- */
-Reference< XOutputStream > createStreamToFile( const OUString sFile ) ;
-
-/**
- * Helper : get service manager and context
- */
-Reference< XMultiComponentFactory > serviceManager( Reference< XComponentContext >& xContext , OUString sUnoUrl , OUString sRdbUrl ) throw( RuntimeException , Exception ) ;
-
-/**
- * Helper : Get password function for PKCS11 slot
- */
-char* PriPK11PasswordFunc( PK11SlotInfo *slot , PRBool retry , void* arg ) ;
-
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmlsecurity/tools/standalone/csfit/makefile.mk b/xmlsecurity/tools/standalone/csfit/makefile.mk
deleted file mode 100644
index 36efa47ff..000000000
--- a/xmlsecurity/tools/standalone/csfit/makefile.mk
+++ /dev/null
@@ -1,155 +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=xmlsecurity-cxsfit
-ENABLE_EXCEPTIONS=TRUE
-NO_BSYMBOLIC=TRUE
-TARGETTYPE=CUI
-LIBTARGET=NO
-
-# --- Settings -----------------------------------------------------
-
-.INCLUDE : settings.mk
-.INCLUDE : $(PRJ)$/util$/target.pmk
-
-
-.IF "$(CRYPTO_ENGINE)" == "nss"
-
-MOZ_INC = $(SOLARVERSION)$/$(INPATH)$/inc$(UPDMINOREXT)$/mozilla
-NSS_INC = $(MOZ_INC)$/nss
-NSPR_INC = $(MOZ_INC)$/nspr
-
-CDEFS += -DXMLSEC_CRYPTO_NSS -DXMLSEC_NO_XSLT
-SOLARINC += \
- -I$(MOZ_INC) \
- -I$(NSPR_INC) \
- -I$(NSS_INC) \
- -I$(PRJ)$/source$/xmlsec \
- -I$(PRJ)$/source$/xmlsec$/nss
-
-# --- Files --------------------------------------------------------
-
-SHARE_LIBS = \
- $(CPPULIB) \
- $(CPPUHELPERLIB) \
- $(SALHELPERLIB) \
- $(SALLIB)
-
-.IF "$(GUI)"=="WNT"
-SHARE_LIBS+= "ixml2.lib" "nss3.lib" "nspr4.lib" "libxmlsec.lib" "libxmlsec-nss.lib" "xsec_xmlsec.lib"
-.ELSE
-SHARE_LIBS+= "-lxml2" "-lnss3" "-lnspr4" "-lxmlsec1" "-lxmlsec1-nss" "-lxsec_xmlsec"
-.ENDIF
-
-SHARE_OBJS = \
- $(OBJ)$/helper.obj
-
-#
-# The 1st application
-#
-
-APP2TARGET= signer
-APP2OBJS= \
- $(SHARE_OBJS) \
- $(OBJ)$/signer.obj
-
-.IF "$(OS)" == "LINUX"
-APP2STDLIBS+= -lstdc++
-.ENDIF
-
-APP2STDLIBS+= \
- $(SHARE_LIBS)
-
-#
-# The 2nd application
-#
-APP3TARGET= encrypter
-APP3OBJS= \
- $(SHARE_OBJS) \
- $(OBJ)$/encrypter.obj
-
-.IF "$(OS)" == "LINUX"
-APP3STDLIBS+= -lstdc++
-.ENDIF
-
-APP3STDLIBS+= \
- $(SHARE_LIBS)
-
-#
-# The 3rd application
-#
-APP4TARGET= verifier
-APP4OBJS= \
- $(SHARE_OBJS) \
- $(OBJ)$/verifier.obj
-
-.IF "$(OS)" == "LINUX"
-APP4STDLIBS+= -lstdc++
-.ENDIF
-
-APP4STDLIBS+= \
- $(SHARE_LIBS)
-
-#
-# The 4th application
-#
-APP5TARGET= decrypter
-APP5OBJS= \
- $(SHARE_OBJS) \
- $(OBJ)$/decrypter.obj
-
-.IF "$(OS)" == "LINUX"
-APP5STDLIBS+= -lstdc++
-.ENDIF
-
-APP5STDLIBS+= \
- $(SHARE_LIBS)
-
-#
-# The 5th application
-#
-APP6TARGET= certmngr
-APP6OBJS= \
- $(SHARE_OBJS) \
- $(OBJ)$/certmngr.obj
-
-.IF "$(OS)" == "LINUX"
-APP6STDLIBS+= -lstdc++
-.ENDIF
-
-APP6STDLIBS+= \
- $(SHARE_LIBS)
-
-.ENDIF
-
-# --- Targets ------------------------------------------------------
-
-.INCLUDE : target.mk
-
diff --git a/xmlsecurity/tools/standalone/csfit/signer.cxx b/xmlsecurity/tools/standalone/csfit/signer.cxx
deleted file mode 100644
index 0dfcc48c4..000000000
--- a/xmlsecurity/tools/standalone/csfit/signer.cxx
+++ /dev/null
@@ -1,372 +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.
- *
- ************************************************************************/
-
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_xmlsecurity.hxx"
-
-#include <stdio.h>
-#include "helper.hxx"
-
-#include "libxml/tree.h"
-#include "libxml/parser.h"
-#ifndef XMLSEC_NO_XSLT
-#include "libxslt/xslt.h"
-#endif
-
-#include "securityenvironment_nssimpl.hxx"
-#include "xmlelementwrapper_xmlsecimpl.hxx"
-
-#include "nspr.h"
-#include "prtypes.h"
-
-#include "pk11func.h"
-#include "cert.h"
-#include "cryptohi.h"
-#include "certdb.h"
-#include "nss.h"
-
-#include "xmlsec/strings.h"
-#include "xmlsec/xmltree.h"
-
-#include <rtl/ustring.hxx>
-
-#include <com/sun/star/beans/PropertyValue.hpp>
-#include <com/sun/star/xml/wrapper/XXMLElementWrapper.hpp>
-#include <com/sun/star/xml/wrapper/XXMLDocumentWrapper.hpp>
-#include <com/sun/star/xml/crypto/XXMLSignature.hpp>
-#include <com/sun/star/xml/crypto/XXMLSignatureTemplate.hpp>
-#include <com/sun/star/xml/crypto/XXMLSecurityContext.hpp>
-#include <com/sun/star/xml/crypto/XSecurityEnvironment.hpp>
-
-using namespace ::rtl ;
-using namespace ::cppu ;
-using namespace ::com::sun::star::uno ;
-using namespace ::com::sun::star::io ;
-using namespace ::com::sun::star::ucb ;
-using namespace ::com::sun::star::beans ;
-using namespace ::com::sun::star::document ;
-using namespace ::com::sun::star::lang ;
-using namespace ::com::sun::star::xml::wrapper ;
-using namespace ::com::sun::star::xml::crypto ;
-
-
-int SAL_CALL main( int argc, char **argv )
-{
- CERTCertDBHandle* certHandle ;
- PK11SlotInfo* slot ;
- xmlDocPtr doc ;
- xmlNodePtr tplNode ;
- xmlNodePtr tarNode ;
- xmlAttrPtr idAttr ;
- xmlChar* idValue ;
- xmlAttrPtr uriAttr ;
- xmlChar* uriValue ;
- OUString* uri ;
- Reference< XUriBinding > xUriBinding ;
- FILE* dstFile ;
-
- if( argc != 5 ) {
- fprintf( stderr, "Usage: %s < CertDir > <file_url of template> <file_url of result> <rdb file>\n\n" , argv[0] ) ;
- return 1 ;
- }
-
- for( int hhh = 0 ; hhh < 10 ; hhh ++ ) {
- slot = NULL ;
- doc = NULL ;
- uri = NULL ;
- dstFile = NULL ;
-
-
- //Init libxml and libxslt libraries
- xmlInitParser();
- LIBXML_TEST_VERSION
- xmlLoadExtDtdDefaultValue = XML_DETECT_IDS | XML_COMPLETE_ATTRS;
- xmlSubstituteEntitiesDefault(1);
-
- #ifndef XMLSEC_NO_XSLT
- xmlIndentTreeOutput = 1;
- #endif // XMLSEC_NO_XSLT
-
-
- //Initialize NSPR and NSS
- PR_Init( PR_SYSTEM_THREAD, PR_PRIORITY_NORMAL, 1 ) ;
- PK11_SetPasswordFunc( PriPK11PasswordFunc ) ;
- if( NSS_Init( argv[1] ) != SECSuccess ) {
- fprintf( stderr , "### cannot intialize NSS!\n" ) ;
- goto done ;
- }
-
- certHandle = CERT_GetDefaultCertDB() ;
- slot = PK11_GetInternalKeySlot() ;
-
- if( PK11_NeedLogin( slot ) ) {
- SECStatus nRet = PK11_Authenticate( slot, PR_TRUE, NULL );
- if( nRet != SECSuccess ) {
- fprintf( stderr , "### cannot authehticate the crypto token!\n" ) ;
- goto done ;
- }
- }
-
- //Load XML document
- doc = xmlParseFile( argv[2] ) ;
- if( doc == NULL || xmlDocGetRootElement( doc ) == NULL ) {
- fprintf( stderr , "### Cannot load template xml document!\n" ) ;
- goto done ;
- }
-
- //Find the signature template
- tplNode = xmlSecFindNode( xmlDocGetRootElement( doc ), xmlSecNodeSignature, xmlSecDSigNs ) ;
- if( tplNode == NULL ) {
- fprintf( stderr , "### Cannot find the signature template!\n" ) ;
- goto done ;
- }
-
- //Find the element with ID attribute
- //Here we only try to find the "document" node.
- tarNode = xmlSecFindNode( xmlDocGetRootElement( doc ), ( xmlChar* )"document", ( xmlChar* )"http://openoffice.org/2000/office" ) ;
- if( tarNode == NULL ) {
- tarNode = xmlSecFindNode( xmlDocGetRootElement( doc ), ( xmlChar* )"document", NULL ) ;
- }
-
- //Find the "id" attrbute in the element
- if( tarNode != NULL ) {
- if( ( idAttr = xmlHasProp( tarNode, ( xmlChar* )"id" ) ) != NULL ) {
- //NULL
- } else if( ( idAttr = xmlHasProp( tarNode, ( xmlChar* )"Id" ) ) != NULL ) {
- //NULL
- } else {
- idAttr = NULL ;
- }
- }
-
- //Add ID to DOM
- if( idAttr != NULL ) {
- idValue = xmlNodeListGetString( tarNode->doc, idAttr->children, 1 ) ;
- if( idValue == NULL ) {
- fprintf( stderr , "### the ID value is NULL!\n" ) ;
- goto done ;
- }
-
- if( xmlAddID( NULL, doc, idValue, idAttr ) == NULL ) {
- fprintf( stderr , "### Can not add the ID value!\n" ) ;
- goto done ;
- }
- }
-
- //Reference handler
- //Find the signature reference
- tarNode = xmlSecFindNode( tplNode, xmlSecNodeReference, xmlSecDSigNs ) ;
- if( tarNode == NULL ) {
- fprintf( stderr , "### Cannot find the signature reference!\n" ) ;
- goto done ;
- }
-
- //Find the "URI" attrbute in the reference
- uriAttr = xmlHasProp( tarNode, ( xmlChar* )"URI" ) ;
- if( tarNode == NULL ) {
- fprintf( stderr , "### Cannot find URI of the reference!\n" ) ;
- goto done ;
- }
-
- //Get the "URI" attrbute value
- uriValue = xmlNodeListGetString( tarNode->doc, uriAttr->children, 1 ) ;
- if( uriValue == NULL ) {
- fprintf( stderr , "### the URI value is NULL!\n" ) ;
- goto done ;
- }
-
- if( strchr( ( const char* )uriValue, '/' ) != NULL && strchr( ( const char* )uriValue, '#' ) == NULL ) {
- fprintf( stdout , "### Find a stream URI [%s]\n", uriValue ) ;
- // uri = new ::rtl::OUString( ( const sal_Unicode* )uriValue ) ;
- uri = new ::rtl::OUString( ( const sal_Char* )uriValue, xmlStrlen( uriValue ), RTL_TEXTENCODING_ASCII_US ) ;
- }
-
- if( uri != NULL ) {
- fprintf( stdout , "### Find the URI [%s]\n", OUStringToOString( *uri , RTL_TEXTENCODING_ASCII_US ).getStr() ) ;
- Reference< XInputStream > xStream = createStreamFromFile( *uri ) ;
- if( !xStream.is() ) {
- fprintf( stderr , "### Can not get the URI stream!\n" ) ;
- goto done ;
- }
-
- xUriBinding = new OUriBinding( *uri, xStream ) ;
- }
-
- try {
- Reference< XMultiComponentFactory > xManager = NULL ;
- Reference< XComponentContext > xContext = NULL ;
-
- xManager = serviceManager( xContext , OUString(RTL_CONSTASCII_USTRINGPARAM("local")), OUString::createFromAscii( argv[4] ) ) ;
- OSL_ENSURE( xManager.is() ,
- "ServicesManager - "
- "Cannot get service manager" ) ;
-
- //Create signature template
- Reference< XInterface > element =
- xManager->createInstanceWithContext( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.xml.security.bridge.xmlsec.XMLElementWrapper_XmlSecImpl")) , xContext ) ;
- OSL_ENSURE( element.is() ,
- "Signer - "
- "Cannot get service instance of \"wrapper.XMLElementWrapper\"" ) ;
-
- Reference< XXMLElementWrapper > xElement( element , UNO_QUERY ) ;
- OSL_ENSURE( xElement.is() ,
- "Signer - "
- "Cannot get interface of \"XXMLElement\" from service \"xsec.XMLElement\"" ) ;
-
- Reference< XUnoTunnel > xEleTunnel( xElement , UNO_QUERY ) ;
- OSL_ENSURE( xEleTunnel.is() ,
- "Signer - "
- "Cannot get interface of \"XUnoTunnel\" from service \"xsec.XMLElement\"" ) ;
-
- XMLElementWrapper_XmlSecImpl* pElement = ( XMLElementWrapper_XmlSecImpl* )xEleTunnel->getSomething( XMLElementWrapper_XmlSecImpl::getUnoTunnelImplementationId() ) ;
- OSL_ENSURE( pElement != NULL ,
- "Signer - "
- "Cannot get implementation of \"xsec.XMLElement\"" ) ;
-
- //Set signature template
- pElement->setNativeElement( tplNode ) ;
-
- //Build XML Signature template
- Reference< XInterface > signtpl =
- xManager->createInstanceWithContext( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.xml.crypto.XMLSignatureTemplate")) , xContext ) ;
- OSL_ENSURE( signtpl.is() ,
- "Signer - "
- "Cannot get service instance of \"xsec.XMLSignatureTemplate\"" ) ;
-
- Reference< XXMLSignatureTemplate > xTemplate( signtpl , UNO_QUERY ) ;
- OSL_ENSURE( xTemplate.is() ,
- "Signer - "
- "Cannot get interface of \"XXMLSignatureTemplate\" from service \"xsec.XMLSignatureTemplate\"" ) ;
-
- //Import the signature template
- xTemplate->setTemplate( xElement ) ;
-
- //Import the URI/Stream binding
- if( xUriBinding.is() )
- xTemplate->setBinding( xUriBinding ) ;
-
- //Create security environment
- //Build Security Environment
- Reference< XInterface > xsecenv =
- xManager->createInstanceWithContext( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.xml.security.bridge.xmlsec.SecurityEnvironment_NssImpl")), xContext ) ;
- OSL_ENSURE( xsecenv.is() ,
- "Signer - "
- "Cannot get service instance of \"xsec.SecurityEnvironment\"" ) ;
-
- Reference< XSecurityEnvironment > xSecEnv( xsecenv , UNO_QUERY ) ;
- OSL_ENSURE( xSecEnv.is() ,
- "Signer - "
- "Cannot get interface of \"XSecurityEnvironment\" from service \"xsec.SecurityEnvironment\"" ) ;
-
- //Setup key slot and certDb
- Reference< XUnoTunnel > xEnvTunnel( xsecenv , UNO_QUERY ) ;
- OSL_ENSURE( xElement.is() ,
- "Signer - "
- "Cannot get interface of \"XUnoTunnel\" from service \"xsec.SecurityEnvironment\"" ) ;
-
- SecurityEnvironment_NssImpl* pSecEnv = ( SecurityEnvironment_NssImpl* )xEnvTunnel->getSomething( SecurityEnvironment_NssImpl::getUnoTunnelId() ) ;
- OSL_ENSURE( pSecEnv != NULL ,
- "Signer - "
- "Cannot get implementation of \"xsec.SecurityEnvironment\"" ) ;
-
- pSecEnv->setCryptoSlot( slot ) ;
- pSecEnv->setCertDb( certHandle ) ;
-
- //Build XML Security Context
- Reference< XInterface > xmlsecctx =
- xManager->createInstanceWithContext( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.xml.security.bridge.xmlsec.XMLSecurityContext_NssImpl")), xContext ) ;
- OSL_ENSURE( xsecenv.is() ,
- "Signer - "
- "Cannot get service instance of \"xsec.XMLSecurityContext\"" ) ;
-
- Reference< XXMLSecurityContext > xSecCtx( xmlsecctx , UNO_QUERY ) ;
- OSL_ENSURE( xSecCtx.is() ,
- "Signer - "
- "Cannot get interface of \"XXMLSecurityContext\" from service \"xsec.XMLSecurityContext\"" ) ;
-
- xSecCtx->setSecurityEnvironment( xSecEnv ) ;
-
- //Generate XML signature
- Reference< XInterface > xmlsigner =
- xManager->createInstanceWithContext( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.xml.security.bridge.xmlsec.XMLSignature_NssImpl")), xContext ) ;
- OSL_ENSURE( xmlsigner.is() ,
- "Signer - "
- "Cannot get service instance of \"xsec.XMLSignature\"" ) ;
-
- Reference< XXMLSignature > xSigner( xmlsigner , UNO_QUERY ) ;
- OSL_ENSURE( xSigner.is() ,
- "Signer - "
- "Cannot get interface of \"XXMLSignature\" from service \"xsec.XMLSignature\"" ) ;
-
- //perform signature
- xTemplate = xSigner->generate( xTemplate , xSecCtx ) ;
- OSL_ENSURE( xTemplate.is() ,
- "Signer - "
- "Cannot generate the xml signature" ) ;
- } catch( Exception& e ) {
- fprintf( stderr , "Error Message: %s\n" , OUStringToOString( e.Message , RTL_TEXTENCODING_ASCII_US ).getStr() ) ;
- goto done ;
- }
-
- dstFile = fopen( argv[3], "w" ) ;
- if( dstFile == NULL ) {
- fprintf( stderr , "### Can not open file %s\n", argv[3] ) ;
- goto done ;
- }
-
- //Save result
- xmlDocDump( dstFile, doc ) ;
-
-done:
- if( uri != NULL )
- delete uri ;
-
- if( dstFile != NULL )
- fclose( dstFile ) ;
-
- if( doc != NULL )
- xmlFreeDoc( doc ) ;
-
- if( slot != NULL )
- PK11_FreeSlot( slot ) ;
-
- PK11_LogoutAll() ;
- NSS_Shutdown() ;
-
- /* Shutdown libxslt/libxml */
- #ifndef XMLSEC_NO_XSLT
- xsltCleanupGlobals();
- #endif /* XMLSEC_NO_XSLT */
- xmlCleanupParser();
-
- }
-
- return 0;
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmlsecurity/tools/standalone/csfit/util/makefile.mk b/xmlsecurity/tools/standalone/csfit/util/makefile.mk
deleted file mode 100644
index ee030fd35..000000000
--- a/xmlsecurity/tools/standalone/csfit/util/makefile.mk
+++ /dev/null
@@ -1,174 +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=xmlsecurity-secfit-boot
-TARGETTYPE=GUI
-
-GEN_HID=TRUE
-APP2NOSAL=TRUE
-
-# --- Settings -----------------------------------------------------------
-USE_JAVAVER=TRUE
-
-.INCLUDE : settings.mk
-
-VERINFONAME=verinfo
-
-.INCLUDE : target.mk
-.INCLUDE : $(PRJ)$/util$/target.pmk
-
-# -------------------------------------------------------------------------
-# --- Targets -------------------------------------------------------------
-
-ALLTAR : $(BIN)$/boot_services.rdb
-
-REGISTERLIBS= \
- i18npool.uno$(DLLPOST) \
- $(DLLPRE)tk$(DLLPOSTFIX)$(DLLPOST) \
- $(DLLPRE)mcnttype$(DLLPOST)
-
-# $(DLLPRE)i18n$(DLLPOSTFIX)$(DLLPOST) \
-# $(DLLPRE)i18npool$(DLLPOSTFIX)$(DLLPOST) \
-# $(DLLPRE)tk$(DLLPOSTFIX)$(DLLPOST) \
-# $(DLLPRE)mcnttype$(DLLPOST)
-
-# Additional libraries
-DLLPRE_NO=
-REGISTERLIBS+= \
- $(DLLPRE_NO)dynamicloader.uno$(DLLPOST) \
- $(DLLPRE_NO)namingservice.uno$(DLLPOST) \
- $(DLLPRE_NO)bootstrap.uno$(DLLPOST) \
- $(DLLPRE)xsec_fw$(DLLPOST) \
- $(DLLPRE)xsec_xmlsec$(DLLPOST)
-
-.IF "$(GUI)" == "UNX"
-MY_DLLDIR=$(SOLARLIBDIR)
-REGISTERLIBS+= \
- $(DLLPRE)dtransX11$(DLLPOSTFIX)$(DLLPOST)
-
-.ELSE # "$(GUI)" == "UNX"
-.IF "$(GUI)"=="WNT"
-
-MY_DLLDIR=$(SOLARBINDIR)
-REGISTERLIBS+= \
- $(DLLPRE)sysdtrans$(DLLPOST) \
- $(DLLPRE)ftransl$(DLLPOST) \
- $(DLLPRE)dnd$(DLLPOST)
-
-.ELSE # "$(GUI)"=="WNT"
-
- @echo "**********************************************************"
- @echo "*** unknown platform: don't know which librarys to use ***"
- @echo "**********************************************************"
- force_dmake_to_error
-.ENDIF # "$(GUI)"=="WNT"
-.ENDIF # "$(GUI)" == "UNX"
-
-.IF "$(SOLAR_JAVA)" != ""
-.IF "$(JAVANUMVER)" >= "000100040000"
-# native libraries, which are only necessary, when java shall run within setup
-REGISTERLIBS_JAVA= \
- javavm.uno$(DLLPOST) \
- javaloader.uno$(DLLPOST)
-
-# add here java components, which shall run with setup
-REGISTERJARS=\
- java_uno_accessbridge.jar
-# xsec_jxsec.jar
-
-# jar-files, which regcomp needs so that it can use java
-REGCOMP_JARS=unoil.jar java_uno.jar ridl.jar jurt.jar juh.jar
-
-# CLASSPATH, which regcomp needs to be run
-# $(SOLARLIBDIR) needs to be included in case Java components are registered,
-# because java_uno.jar needs to find the native java_uno shared library:
-MY_CLASSPATH_TMP=$(foreach,i,$(REGCOMP_JARS) $(SOLARBINDIR)$/$i)$(PATH_SEPERATOR)$(SOLARLIBDIR)$(PATH_SEPERATOR)$(XCLASSPATH)
-REGCOMP_CLASSPATH=$(strip $(subst,!,$(PATH_SEPERATOR) $(MY_CLASSPATH_TMP:s/ /!/)))
-
-.IF "$(GUI)"!="WNT"
-DOLLAR_SIGN=\$$
-MY_JAVA_COMPPATH=file://$(SOLARBINDIR)
-.IF "$(OS)"=="MACOSX"
-REGCOMP_ENV=\
- setenv CLASSPATH $(REGCOMP_CLASSPATH) && \
- setenv DYLD_LIBRARY_PATH $(DYLD_LIBRARY_PATH):$(JDKLIB)
-.ELSE
-REGCOMP_ENV=\
- setenv CLASSPATH $(REGCOMP_CLASSPATH) && \
- setenv LD_LIBRARY_PATH $(LD_LIBRARY_PATH):$(JDKLIB)
-.ENDIF
-.ELSE # "$(GUI)" != "WNT"
-.IF "$(USE_SHELL)" != "4nt"
-DOLLAR_SIGN=\$$
-REGCOMP_ENV=\
- setenv CLASSPATH "$(strip $(subst,\,/ $(shell @guw.pl echo $(REGCOMP_CLASSPATH))))" && \
- setenv PATH "$(PATH):$(JREPATH)"
-MY_JAVA_COMPPATH=$(strip $(subst,\,/ file:///$(shell @guw.pl echo $(SOLARBINDIR))))
-.ELSE # "$(USE_SHELL)" != "4nt"
-DOLLAR_SIGN=$$
-REGCOMP_ENV=\
- set CLASSPATH=$(REGCOMP_CLASSPATH) && \
- set PATH=$(PATH);$(JREPATH)
-MY_JAVA_COMPPATH=$(strip $(subst,\,/ file:///$(SOLARBINDIR)))
-.ENDIF # "$(USE_SHELL)" != "4nt"
-.ENDIF # "$(GUI)"!="WNT"
-.ENDIF # "$(JAVANUMVER)" >= "000100040000"
-.ENDIF # "$(SOLAR_JAVA)" != ""
-
-$(BIN)$/boot_services.rdb: \
- makefile.mk \
- $(foreach,i,$(REGISTERLIBS) $(MY_DLLDIR)$/$(i)) \
- $(foreach,i,$(REGISTERLIBS_JAVA) $(MY_DLLDIR)$/$(i))
- -rm -f $@ $(BIN)$/regcomp.rdb $(BIN)$/boot_services.tmp
-# register the native libraries
- $(REGCOMP) -register -r $(BIN)$/boot_services.tmp -c "$(strip $(REGISTERLIBS))"
-.IF "$(SOLAR_JAVA)" != ""
-.IF "$(OS)"!="MACOSX"
-.IF "$(JAVANUMVER)" >= "000100040000"
- $(REGCOMP) -register -r $(BIN)$/boot_services.tmp -c "$(strip $(REGISTERLIBS_JAVA))"
-# prepare a registry which regcomp can work on (types+java services)
- $(REGCOMP) -register -r $(BIN)$/regcomp.rdb -c "$(strip $(REGISTERLIBS_JAVA))"
- $(REGMERGE) $(BIN)$/regcomp.rdb / $(SOLARBINDIR)/udkapi.rdb
-# now do the registration
- $(REGCOMP_ENV) && \
- $(REGCOMP) -br $(BIN)$/regcomp.rdb \
- -register \
- -r $(BIN)$/boot_services.tmp \
- -l com.sun.star.loader.Java2 \
- -env:UNO_JAVA_COMPPATH=$(MY_JAVA_COMPPATH) \
- $(foreach,i,$(REGISTERJARS) -c vnd.sun.star.expand:$(DOLLAR_SIGN)UNO_JAVA_COMPPATH/$(i))
-# $(foreach,i,$(REGISTERJARS) -c vnd.sun.star.expand:$(DOLLAR_SIGN)UNO_JAVA_COMPPATH/$(i)) -c $(MY_JAVA_COMPPATH)$/xsec_jxsec.jar
-
-.ENDIF # "$(JAVANUMVER)" >= "000100040000"
-.ENDIF # "$(OS)" != "MACOSX"
-.ENDIF # "$(SOLAR_JAVA)" != ""
-# to have a transaction, move it now to the final name
- $(REGMERGE) $(BIN)$/boot_services.tmp / $(SOLARBINDIR)/types.rdb
- mv $(BIN)$/boot_services.tmp $@
-
diff --git a/xmlsecurity/tools/standalone/csfit/verifier.cxx b/xmlsecurity/tools/standalone/csfit/verifier.cxx
deleted file mode 100644
index caa74beed..000000000
--- a/xmlsecurity/tools/standalone/csfit/verifier.cxx
+++ /dev/null
@@ -1,342 +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.
- *
- ************************************************************************/
-
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_xmlsecurity.hxx"
-
-#include <stdio.h>
-#include "helper.hxx"
-
-#include "libxml/tree.h"
-#include "libxml/parser.h"
-#ifndef XMLSEC_NO_XSLT
-#include "libxslt/xslt.h"
-#endif
-
-#include "securityenvironment_nssimpl.hxx"
-#include "xmlelementwrapper_xmlsecimpl.hxx"
-
-#include "nspr.h"
-#include "prtypes.h"
-
-#include "pk11func.h"
-#include "cert.h"
-#include "cryptohi.h"
-#include "certdb.h"
-#include "nss.h"
-
-#include "xmlsec/strings.h"
-#include "xmlsec/xmltree.h"
-
-#include <rtl/ustring.hxx>
-#include <cppuhelper/servicefactory.hxx>
-
-#include <com/sun/star/lang/XComponent.hpp>
-#include <com/sun/star/beans/PropertyValue.hpp>
-#include <com/sun/star/xml/wrapper/XXMLElementWrapper.hpp>
-#include <com/sun/star/xml/wrapper/XXMLDocumentWrapper.hpp>
-#include <com/sun/star/xml/crypto/XXMLSignature.hpp>
-#include <com/sun/star/xml/crypto/XXMLSignatureTemplate.hpp>
-#include <com/sun/star/xml/crypto/XXMLSecurityContext.hpp>
-#include <com/sun/star/xml/crypto/XSecurityEnvironment.hpp>
-
-using namespace ::rtl ;
-using namespace ::cppu ;
-using namespace ::com::sun::star::uno ;
-using namespace ::com::sun::star::io ;
-using namespace ::com::sun::star::ucb ;
-using namespace ::com::sun::star::beans ;
-using namespace ::com::sun::star::document ;
-using namespace ::com::sun::star::lang ;
-using namespace ::com::sun::star::registry ;
-using namespace ::com::sun::star::xml::wrapper ;
-using namespace ::com::sun::star::xml::crypto ;
-
-
-int SAL_CALL main( int argc, char **argv )
-{
- CERTCertDBHandle* certHandle = NULL ;
- PK11SlotInfo* slot = NULL ;
- xmlDocPtr doc = NULL ;
- xmlNodePtr tplNode ;
- xmlNodePtr tarNode ;
- xmlAttrPtr idAttr ;
- xmlChar* idValue ;
- xmlAttrPtr uriAttr ;
- xmlChar* uriValue ;
- OUString* uri = NULL ;
- Reference< XUriBinding > xUriBinding ;
-
- if( argc != 4 ) {
- fprintf( stderr, "Usage: %s < CertDir > <file_url> <rdb file>\n" , argv[0] ) ;
- return 1 ;
- }
-
- //Init libxml and libxslt libraries
- xmlInitParser();
- LIBXML_TEST_VERSION
- xmlLoadExtDtdDefaultValue = XML_DETECT_IDS | XML_COMPLETE_ATTRS;
- xmlSubstituteEntitiesDefault(1);
-
- #ifndef XMLSEC_NO_XSLT
- xmlIndentTreeOutput = 1;
- #endif // XMLSEC_NO_XSLT
-
-
- //Initialize NSPR and NSS
- PR_Init( PR_SYSTEM_THREAD, PR_PRIORITY_NORMAL, 1 ) ;
- PK11_SetPasswordFunc( PriPK11PasswordFunc ) ;
- if( NSS_Init( argv[1] ) != SECSuccess ) {
- fprintf( stderr , "### cannot intialize NSS!\n" ) ;
- return 1 ;
- }
-
- certHandle = CERT_GetDefaultCertDB() ;
- slot = PK11_GetInternalKeySlot() ;
-
- //Load XML document
- doc = xmlParseFile( argv[2] ) ;
- if( doc == NULL || xmlDocGetRootElement( doc ) == NULL ) {
- fprintf( stderr , "### Cannot load template xml document!\n" ) ;
- goto done ;
- }
-
- //Find the signature template
- tplNode = xmlSecFindNode( xmlDocGetRootElement( doc ), xmlSecNodeSignature, xmlSecDSigNs ) ;
- if( tplNode == NULL ) {
- fprintf( stderr , "### Cannot find the signature template!\n" ) ;
- goto done ;
- }
-
- //Find the element with ID attribute
- tarNode = xmlSecFindNode( xmlDocGetRootElement( doc ), ( xmlChar* )"document", ( xmlChar* )"http://openoffice.org/2000/office" ) ;
- if( tarNode == NULL ) {
- tarNode = xmlSecFindNode( xmlDocGetRootElement( doc ), ( xmlChar* )"document", NULL ) ;
- }
-
- //Find the "id" attrbute in the element
- if( tarNode != NULL ) {
- if( ( idAttr = xmlHasProp( tarNode, ( xmlChar* )"id" ) ) != NULL ) {
- //NULL
- } else if( ( idAttr = xmlHasProp( tarNode, ( xmlChar* )"Id" ) ) != NULL ) {
- //NULL
- } else {
- idAttr = NULL ;
- }
- }
-
- //Add ID to DOM
- if( idAttr != NULL ) {
- idValue = xmlNodeListGetString( tarNode->doc, idAttr->children, 1 ) ;
- if( idValue == NULL ) {
- fprintf( stderr , "### the ID value is NULL!\n" ) ;
- goto done ;
- }
-
- if( xmlAddID( NULL, doc, idValue, idAttr ) == NULL ) {
- fprintf( stderr , "### Can not add the ID value!\n" ) ;
- goto done ;
- }
- }
-
- //Reference handler
- //Find the signature reference
- tarNode = xmlSecFindNode( tplNode, xmlSecNodeReference, xmlSecDSigNs ) ;
- if( tarNode == NULL ) {
- fprintf( stderr , "### Cannot find the signature reference!\n" ) ;
- goto done ;
- }
-
- //Find the "URI" attrbute in the reference
- uriAttr = xmlHasProp( tarNode, ( xmlChar* )"URI" ) ;
- if( tarNode == NULL ) {
- fprintf( stderr , "### Cannot find URI of the reference!\n" ) ;
- goto done ;
- }
-
- //Get the "URI" attrbute value
- uriValue = xmlNodeListGetString( tarNode->doc, uriAttr->children, 1 ) ;
- if( uriValue == NULL ) {
- fprintf( stderr , "### the URI value is NULL!\n" ) ;
- goto done ;
- }
-
- if( strchr( ( const char* )uriValue, '/' ) != NULL && strchr( ( const char* )uriValue, '#' ) == NULL ) {
- fprintf( stdout , "### Find a stream URI [%s]\n", uriValue ) ;
- // uri = new ::rtl::OUString( ( const sal_Unicode* )uriValue ) ;
- uri = new ::rtl::OUString( ( const sal_Char* )uriValue, xmlStrlen( uriValue ), RTL_TEXTENCODING_ASCII_US ) ;
- }
-
- if( uri != NULL ) {
- fprintf( stdout , "### Find the URI [%s]\n", OUStringToOString( *uri , RTL_TEXTENCODING_ASCII_US ).getStr() ) ;
- Reference< XInputStream > xStream = createStreamFromFile( *uri ) ;
- if( !xStream.is() ) {
- fprintf( stderr , "### Can not get the URI stream!\n" ) ;
- goto done ;
- }
-
- xUriBinding = new OUriBinding( *uri, xStream ) ;
- }
-
-
- try {
- Reference< XMultiComponentFactory > xManager = NULL ;
- Reference< XComponentContext > xContext = NULL ;
-
- xManager = serviceManager( xContext , OUString(RTL_CONSTASCII_USTRINGPARAM("local")), OUString::createFromAscii( argv[3] ) ) ;
-
- //Create signature template
- Reference< XInterface > element =
- xManager->createInstanceWithContext( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.xml.security.bridge.xmlsec.XMLElementWrapper_XmlSecImpl")) , xContext ) ;
- OSL_ENSURE( element.is() ,
- "Verifier - "
- "Cannot get service instance of \"xsec.XMLElementWrapper\"" ) ;
-
- Reference< XXMLElementWrapper > xElement( element , UNO_QUERY ) ;
- OSL_ENSURE( xElement.is() ,
- "Verifier - "
- "Cannot get interface of \"XXMLElementWrapper\" from service \"xsec.XMLElementWrapper\"" ) ;
-
- Reference< XUnoTunnel > xEleTunnel( xElement , UNO_QUERY ) ;
- OSL_ENSURE( xEleTunnel.is() ,
- "Verifier - "
- "Cannot get interface of \"XUnoTunnel\" from service \"xsec.XMLElement\"" ) ;
-
- XMLElementWrapper_XmlSecImpl* pElement = ( XMLElementWrapper_XmlSecImpl* )xEleTunnel->getSomething( XMLElementWrapper_XmlSecImpl::getUnoTunnelImplementationId() ) ;
- OSL_ENSURE( pElement != NULL ,
- "Verifier - "
- "Cannot get implementation of \"xsec.XMLElementWrapper\"" ) ;
-
- //Set signature template
- pElement->setNativeElement( tplNode ) ;
-
- //Build XML Signature template
- Reference< XInterface > signtpl =
- xManager->createInstanceWithContext( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.xml.crypto.XMLSignatureTemplate")), xContext ) ;
- OSL_ENSURE( signtpl.is() ,
- "Verifier - "
- "Cannot get service instance of \"xsec.XMLSignatureTemplate\"" ) ;
-
- Reference< XXMLSignatureTemplate > xTemplate( signtpl , UNO_QUERY ) ;
- OSL_ENSURE( xTemplate.is() ,
- "Verifier - "
- "Cannot get interface of \"XXMLSignatureTemplate\" from service \"xsec.XMLSignatureTemplate\"" ) ;
-
- //Import the signature template
- xTemplate->setTemplate( xElement ) ;
-
- //Import the URI/Stream binding
- if( xUriBinding.is() )
- xTemplate->setBinding( xUriBinding ) ;
-
- //Create security environment
- //Build Security Environment
- Reference< XInterface > xsecenv =
- xManager->createInstanceWithContext( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.xml.security.bridge.xmlsec.SecurityEnvironment_NssImpl")), xContext ) ;
- OSL_ENSURE( xsecenv.is() ,
- "Verifier - "
- "Cannot get service instance of \"xsec.SecurityEnvironment\"" ) ;
-
- Reference< XSecurityEnvironment > xSecEnv( xsecenv , UNO_QUERY ) ;
- OSL_ENSURE( xSecEnv.is() ,
- "Verifier - "
- "Cannot get interface of \"XSecurityEnvironment\" from service \"xsec.SecurityEnvironment\"" ) ;
-
- //Setup key slot and certDb
- Reference< XUnoTunnel > xEnvTunnel( xsecenv , UNO_QUERY ) ;
- OSL_ENSURE( xElement.is() ,
- "Verifier - "
- "Cannot get interface of \"XUnoTunnel\" from service \"xsec.SecurityEnvironment\"" ) ;
-
- SecurityEnvironment_NssImpl* pSecEnv = ( SecurityEnvironment_NssImpl* )xEnvTunnel->getSomething( SecurityEnvironment_NssImpl::getUnoTunnelId() ) ;
- OSL_ENSURE( pSecEnv != NULL ,
- "Verifier - "
- "Cannot get implementation of \"xsec.SecurityEnvironment\"" ) ;
-
- pSecEnv->setCryptoSlot( slot ) ;
- pSecEnv->setCertDb( certHandle ) ;
-
- //Build XML Security Context
- Reference< XInterface > xmlsecctx =
- xManager->createInstanceWithContext( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.xml.security.bridge.xmlsec.XMLSecurityContext_NssImpl")), xContext ) ;
- OSL_ENSURE( xsecenv.is() ,
- "Verifier - "
- "Cannot get service instance of \"xsec.XMLSecurityContext\"" ) ;
-
- Reference< XXMLSecurityContext > xSecCtx( xmlsecctx , UNO_QUERY ) ;
- OSL_ENSURE( xSecCtx.is() ,
- "Verifier - "
- "Cannot get interface of \"XXMLSecurityContext\" from service \"xsec.XMLSecurityContext\"" ) ;
-
- xSecCtx->setSecurityEnvironment( xSecEnv ) ;
-
- //Generate XML signature
- Reference< XInterface > xmlsigner =
- xManager->createInstanceWithContext( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.xml.security.bridge.xmlsec.XMLSignature_NssImpl")), xContext ) ;
- OSL_ENSURE( xmlsigner.is() ,
- "Verifier - "
- "Cannot get service instance of \"xsec.XMLSignature\"" ) ;
-
- Reference< XXMLSignature > xSigner( xmlsigner , UNO_QUERY ) ;
- OSL_ENSURE( xSigner.is() ,
- "Verifier - "
- "Cannot get interface of \"XXMLSignature\" from service \"xsec.XMLSignature\"" ) ;
-
-
- //perform validation
- sal_Bool valid = xSigner->validate( xTemplate , xSecCtx ) ;
- if( !valid ) {
- printf( "Signature is INVALID!\n" ) ;
- } else {
- printf( "Signature is VALID!\n" ) ;
- }
- } catch( Exception& e ) {
- fprintf( stderr , "Error Message: %s\n" , OUStringToOString( e.Message , RTL_TEXTENCODING_ASCII_US ).getStr() ) ;
- goto done ;
- }
-
-done :
- if( doc != NULL )
- xmlFreeDoc( doc ) ;
-
- if( slot != NULL )
- PK11_FreeSlot( slot ) ;
-
- PK11_LogoutAll() ;
- NSS_Shutdown() ;
-
- /* Shutdown libxslt/libxml */
- #ifndef XMLSEC_NO_XSLT
- xsltCleanupGlobals();
- #endif /* XMLSEC_NO_XSLT */
- xmlCleanupParser();
-
- return 0 ;
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmlsecurity/tools/standalone/mscsfit/certmngr.cxx b/xmlsecurity/tools/standalone/mscsfit/certmngr.cxx
deleted file mode 100644
index 501a859ee..000000000
--- a/xmlsecurity/tools/standalone/mscsfit/certmngr.cxx
+++ /dev/null
@@ -1,154 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/** -- C++ Source File -- **/
-
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_xmlsecurity.hxx"
-#include <stdio.h>
-#include "helper.hxx"
-
-#include "libxml/tree.h"
-#include "libxml/parser.h"
-#ifndef XMLSEC_NO_XSLT
-#include "libxslt/xslt.h"
-#endif
-
-#include "securityenvironment_mscryptimpl.hxx"
-
-#include <xmlsecurity/biginteger.hxx>
-
-#include "xmlsec/strings.h"
-#include "xmlsec/xmltree.h"
-#include "xmlsec/mscrypto/app.h"
-
-#include <rtl/ustring.hxx>
-
-using namespace ::rtl ;
-using namespace ::cppu ;
-using namespace ::com::sun::star::uno ;
-using namespace ::com::sun::star::io ;
-using namespace ::com::sun::star::ucb ;
-using namespace ::com::sun::star::beans ;
-using namespace ::com::sun::star::document ;
-using namespace ::com::sun::star::lang ;
-using namespace ::com::sun::star::security ;
-using namespace ::com::sun::star::xml::wrapper ;
-using namespace ::com::sun::star::xml::crypto ;
-
-int SAL_CALL main( int argc, char **argv )
-{
- const char* n_pCertStore ;
- HCERTSTORE n_hStoreHandle ;
-
- if( argc != 3 && argc != 2 ) {
- fprintf( stderr, "Usage: %s <rdb file>\n" , argv[0] ) ;
- fprintf( stderr, "Or: \t%s <rdb file> < Cert Store Name >\n\n" , argv[0] ) ;
- return 1 ;
- }
-
- //Initialize the crypto engine
- if( argc == 3 ) {
- n_pCertStore = argv[2] ;
- n_hStoreHandle = CertOpenSystemStore( NULL, n_pCertStore ) ;
- if( n_hStoreHandle == NULL ) {
- fprintf( stderr, "Can not open the system cert store %s\n", n_pCertStore ) ;
- return 1 ;
- }
- } else {
- n_pCertStore = NULL ;
- n_hStoreHandle = NULL ;
- }
- //xmlSecMSCryptoAppInit( n_pCertStore ) ;
-
- try {
- Reference< XMultiComponentFactory > xManager = NULL ;
- Reference< XComponentContext > xContext = NULL ;
-
- xManager = serviceManager( xContext , OUString(RTL_CONSTASCII_USTRINGPARAM("local")), OUString::createFromAscii( argv[1] ) ) ;
- OSL_ENSURE( xManager.is() ,
- "ServicesManager - "
- "Cannot get service manager" ) ;
-
- //Create security environment
- //Build Security Environment
- Reference< XInterface > xsecenv =
- xManager->createInstanceWithContext( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.xml.security.bridge.xmlsec.SecurityEnvironment_MSCryptImpl")), xContext ) ;
- OSL_ENSURE( xsecenv.is() ,
- "Signer - "
- "Cannot get service instance of \"xsec.SecurityEnvironment\"" ) ;
-
- Reference< XSecurityEnvironment > xSecEnv( xsecenv , UNO_QUERY ) ;
- OSL_ENSURE( xSecEnv.is() ,
- "Signer - "
- "Cannot get interface of \"XSecurityEnvironment\" from service \"xsec.SecurityEnvironment\"" ) ;
-
- Reference< XUnoTunnel > xEnvTunnel( xsecenv , UNO_QUERY ) ;
- OSL_ENSURE( xEnvTunnel.is() ,
- "Signer - "
- "Cannot get interface of \"XUnoTunnel\" from service \"xsec.SecurityEnvironment\"" ) ;
-
- SecurityEnvironment_MSCryptImpl* pSecEnv = ( SecurityEnvironment_MSCryptImpl* )xEnvTunnel->getSomething( SecurityEnvironment_MSCryptImpl::getUnoTunnelId() ) ;
- OSL_ENSURE( pSecEnv != NULL ,
- "Signer - "
- "Cannot get implementation of \"xsec.SecurityEnvironment\"" ) ;
-
- //Setup key slot and certDb
- if( n_hStoreHandle != NULL ) {
- pSecEnv->setCryptoSlot( n_hStoreHandle ) ;
- pSecEnv->setCertDb( n_hStoreHandle ) ;
- } else {
- pSecEnv->enableDefaultCrypt( sal_True ) ;
- }
-
- //Get personal certificate
- Sequence < Reference< XCertificate > > xPersonalCerts = pSecEnv->getPersonalCertificates() ;
- OSL_ENSURE( xPersonalCerts.hasElements() ,
- "getPersonalCertificates - "
- "No personal certificates found\n" ) ;
-
- Sequence < Reference< XCertificate > > xCertPath ;
- for( int i = 0; i < xPersonalCerts.getLength(); i ++ ) {
- //Print the certificate infomation.
- fprintf( stdout, "\nPersonal Certificate Info\n" ) ;
- fprintf( stdout, "\tCertificate Issuer[%s]\n", OUStringToOString( xPersonalCerts[i]->getIssuerName(), RTL_TEXTENCODING_ASCII_US ).getStr() ) ;
- fprintf( stdout, "\tCertificate Serial Number[%s]\n", OUStringToOString( bigIntegerToNumericString( xPersonalCerts[i]->getSerialNumber() ), RTL_TEXTENCODING_ASCII_US ).getStr() ) ;
- fprintf( stdout, "\tCertificate Subject[%s]\n", OUStringToOString( xPersonalCerts[i]->getSubjectName(), RTL_TEXTENCODING_ASCII_US ).getStr() ) ;
-
- //build the certificate path
- xCertPath = pSecEnv->buildCertificatePath( xPersonalCerts[i] ) ;
- //Print the certificate path.
- fprintf( stdout, "\tCertificate Path\n" ) ;
- for( int j = 0; j < xCertPath.getLength(); j ++ ) {
- fprintf( stdout, "\t\tCertificate Authority Subject[%s]\n", OUStringToOString( xCertPath[j]->getSubjectName(), RTL_TEXTENCODING_ASCII_US ).getStr() ) ;
- }
-
- //Get the certificate
- Sequence < sal_Int8 > serial = xPersonalCerts[i]->getSerialNumber() ;
- Reference< XCertificate > xcert = pSecEnv->getCertificate( xPersonalCerts[i]->getIssuerName(), xPersonalCerts[i]->getSerialNumber() ) ;
- if( !xcert.is() ) {
- fprintf( stdout, "The personal certificate is not in the certificate database\n" ) ;
- }
-
- //Get the certificate characters
- sal_Int32 chars = pSecEnv->getCertificateCharacters( xPersonalCerts[i] ) ;
- fprintf( stdout, "The certificate characters are %d\n", chars ) ;
-
- //Get the certificate status
- sal_Int32 validity = pSecEnv->verifyCertificate( xPersonalCerts[i] ) ;
- fprintf( stdout, "The certificate validities are %d\n", validity ) ;
-
- }
- } catch( Exception& e ) {
- fprintf( stderr , "Error Message: %s\n" , OUStringToOString( e.Message , RTL_TEXTENCODING_ASCII_US ).getStr() ) ;
- goto done ;
- }
-
-done:
- if( n_hStoreHandle != NULL )
- CertCloseStore( n_hStoreHandle, CERT_CLOSE_STORE_FORCE_FLAG ) ;
-
- //xmlSecMSCryptoAppShutdown() ;
-
- return 0;
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmlsecurity/tools/standalone/mscsfit/decrypter.cxx b/xmlsecurity/tools/standalone/mscsfit/decrypter.cxx
deleted file mode 100644
index 56ac2ea7c..000000000
--- a/xmlsecurity/tools/standalone/mscsfit/decrypter.cxx
+++ /dev/null
@@ -1,248 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/** -- C++ Source File -- **/
-
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_xmlsecurity.hxx"
-#include <stdio.h>
-#include "helper.hxx"
-
-#include "libxml/tree.h"
-#include "libxml/parser.h"
-#ifndef XMLSEC_NO_XSLT
-#include "libxslt/xslt.h"
-#endif
-
-
-#include "securityenvironment_mscryptimpl.hxx"
-#include "xmlelementwrapper_xmlsecimpl.hxx"
-
-#include "nspr.h"
-#include "prtypes.h"
-
-#include "pk11func.h"
-#include "cert.h"
-#include "cryptohi.h"
-#include "certdb.h"
-#include "nss.h"
-
-#include "xmlsec/strings.h"
-#include "xmlsec/xmltree.h"
-
-#include <rtl/ustring.hxx>
-#include <cppuhelper/bootstrap.hxx>
-#include <cppuhelper/servicefactory.hxx>
-
-#include <com/sun/star/beans/PropertyValue.hpp>
-#include <com/sun/star/xml/wrapper/XXMLElementWrapper.hpp>
-#include <com/sun/star/xml/wrapper/XXMLDocumentWrapper.hpp>
-#include <com/sun/star/xml/crypto/XXMLEncryption.hpp>
-#include <com/sun/star/xml/crypto/XXMLEncryptionTemplate.hpp>
-#include <com/sun/star/xml/crypto/XXMLSecurityContext.hpp>
-#include <com/sun/star/xml/crypto/XSecurityEnvironment.hpp>
-
-
-using namespace ::rtl ;
-using namespace ::cppu ;
-using namespace ::com::sun::star::uno ;
-using namespace ::com::sun::star::io ;
-using namespace ::com::sun::star::ucb ;
-using namespace ::com::sun::star::beans ;
-using namespace ::com::sun::star::document ;
-using namespace ::com::sun::star::lang ;
-using namespace ::com::sun::star::registry ;
-using namespace ::com::sun::star::xml::wrapper ;
-using namespace ::com::sun::star::xml::crypto ;
-
-
-int SAL_CALL main( int argc, char **argv )
-{
- CERTCertDBHandle* certHandle = NULL ;
- PK11SlotInfo* slot = NULL ;
- xmlDocPtr doc = NULL ;
- xmlNodePtr tplNode ;
- xmlNodePtr tarNode ;
- FILE* dstFile = NULL ;
-
-
- if( argc != 5 ) {
- fprintf( stderr, "Usage: %s < CertDir > <input file_url> <output file_url> <rdb file>\n\n" , argv[0] ) ;
- return 1 ;
- }
-
- //Init libxml and libxslt libraries
- xmlInitParser();
- LIBXML_TEST_VERSION
- xmlLoadExtDtdDefaultValue = XML_DETECT_IDS | XML_COMPLETE_ATTRS;
- xmlSubstituteEntitiesDefault(1);
-
- #ifndef XMLSEC_NO_XSLT
- xmlIndentTreeOutput = 1;
- #endif // XMLSEC_NO_XSLT
-
-
- //Initialize NSPR and NSS
- PR_Init( PR_SYSTEM_THREAD, PR_PRIORITY_NORMAL, 1 ) ;
- PK11_SetPasswordFunc( PriPK11PasswordFunc ) ;
- if( NSS_Init( argv[1] ) != SECSuccess ) {
- fprintf( stderr , "### cannot intialize NSS!\n" ) ;
- goto done ;
- }
-
- certHandle = CERT_GetDefaultCertDB() ;
- slot = PK11_GetInternalKeySlot() ;
-
- //Load XML document
- doc = xmlParseFile( argv[2] ) ;
- if( doc == NULL || xmlDocGetRootElement( doc ) == NULL ) {
- fprintf( stderr , "### Cannot load template xml document!\n" ) ;
- goto done ;
- }
-
- //Find the encryption template
- tplNode = xmlSecFindNode( xmlDocGetRootElement( doc ), xmlSecNodeEncryptedData, xmlSecEncNs ) ;
- if( tplNode == NULL ) {
- fprintf( stderr , "### Cannot find the encryption template!\n" ) ;
- goto done ;
- }
-
-
- try {
- Reference< XMultiComponentFactory > xManager = NULL ;
- Reference< XComponentContext > xContext = NULL ;
-
- xManager = serviceManager( xContext , OUString(RTL_CONSTASCII_USTRINGPARAM("local")), OUString::createFromAscii( argv[4] ) ) ;
-
- //Create encryption template
- Reference< XInterface > tplElement =
- xManager->createInstanceWithContext( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.xml.xsec.XMLElementWrapper")) , xContext ) ;
- OSL_ENSURE( tplElement.is() ,
- "Decryptor - "
- "Cannot get service instance of \"xsec.XMLElementWrapper\"" ) ;
-
- Reference< XXMLElementWrapper > xTplElement( tplElement , UNO_QUERY ) ;
- OSL_ENSURE( xTplElement.is() ,
- "Decryptor - "
- "Cannot get interface of \"XXMLElementWrapper\" from service \"xsec.XMLElementWrapper\"" ) ;
-
- Reference< XUnoTunnel > xTplEleTunnel( xTplElement , UNO_QUERY ) ;
- OSL_ENSURE( xTplEleTunnel.is() ,
- "Decryptor - "
- "Cannot get interface of \"XUnoTunnel\" from service \"xsec.XMLElementWrapper\"" ) ;
-
- XMLElementWrapper_XmlSecImpl* pTplElement = ( XMLElementWrapper_XmlSecImpl* )xTplEleTunnel->getSomething( XMLElementWrapper_XmlSecImpl::getUnoTunnelImplementationId() ) ;
- OSL_ENSURE( pTplElement != NULL ,
- "Decryptor - "
- "Cannot get implementation of \"xsec.XMLElementWrapper\"" ) ;
-
- pTplElement->setNativeElement( tplNode ) ;
-
- //Build XML Encryption template
- Reference< XInterface > enctpl =
- xManager->createInstanceWithContext( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.xml.xsec.XMLEncryptionTemplate")), xContext ) ;
- OSL_ENSURE( enctpl.is() ,
- "Decryptor - "
- "Cannot get service instance of \"xsec.XMLEncryptionTemplate\"" ) ;
-
- Reference< XXMLEncryptionTemplate > xTemplate( enctpl , UNO_QUERY ) ;
- OSL_ENSURE( xTemplate.is() ,
- "Decryptor - "
- "Cannot get interface of \"XXMLEncryptionTemplate\" from service \"xsec.XMLEncryptionTemplate\"" ) ;
-
- //Import the encryption template
- xTemplate->setTemplate( xTplElement ) ;
-
- //Create security environment
- //Build Security Environment
- Reference< XInterface > xsecenv =
- xManager->createInstanceWithContext( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.xml.xsec.SecurityEnvironment")), xContext ) ;
- OSL_ENSURE( xsecenv.is() ,
- "Decryptor - "
- "Cannot get service instance of \"xsec.SecurityEnvironment\"" ) ;
-
- Reference< XSecurityEnvironment > xSecEnv( xsecenv , UNO_QUERY ) ;
- OSL_ENSURE( xSecEnv.is() ,
- "Decryptor - "
- "Cannot get interface of \"XSecurityEnvironment\" from service \"xsec.SecurityEnvironment\"" ) ;
-
- //Setup key slot and certDb
- Reference< XUnoTunnel > xEnvTunnel( xsecenv , UNO_QUERY ) ;
- OSL_ENSURE( xEnvTunnel.is() ,
- "Decryptor - "
- "Cannot get interface of \"XUnoTunnel\" from service \"xsec.SecurityEnvironment\"" ) ;
-
- SecurityEnvironment_XmlSecImpl* pSecEnv = ( SecurityEnvironment_XmlSecImpl* )xEnvTunnel->getSomething( SecurityEnvironment_XmlSecImpl::getUnoTunnelId() ) ;
- OSL_ENSURE( pSecEnv != NULL ,
- "Decryptor - "
- "Cannot get implementation of \"xsec.SecurityEnvironment\"" ) ;
-
- pSecEnv->setCryptoSlot( slot ) ;
- pSecEnv->setCertDb( certHandle ) ;
-
-
- //Build XML Security Context
- Reference< XInterface > xmlsecctx =
- xManager->createInstanceWithContext( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.xml.xsec.XMLSecurityContext")), xContext ) ;
- OSL_ENSURE( xmlsecctx.is() ,
- "Decryptor - "
- "Cannot get service instance of \"xsec.XMLSecurityContext\"" ) ;
-
- Reference< XXMLSecurityContext > xSecCtx( xmlsecctx , UNO_QUERY ) ;
- OSL_ENSURE( xSecCtx.is() ,
- "Decryptor - "
- "Cannot get interface of \"XXMLSecurityContext\" from service \"xsec.XMLSecurityContext\"" ) ;
-
- xSecCtx->setSecurityEnvironment( xSecEnv ) ;
-
-
- //Get encrypter
- Reference< XInterface > xmlencrypter =
- xManager->createInstanceWithContext( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.xml.xsec.XMLEncryption")), xContext ) ;
- OSL_ENSURE( xmlencrypter.is() ,
- "Decryptor - "
- "Cannot get service instance of \"xsec.XMLEncryption\"" ) ;
-
- Reference< XXMLEncryption > xEncrypter( xmlencrypter , UNO_QUERY ) ;
- OSL_ENSURE( xEncrypter.is() ,
- "Decryptor - "
- "Cannot get interface of \"XXMLEncryption\" from service \"xsec.XMLEncryption\"" ) ;
-
-
- //Perform decryption
- Reference< XXMLElementWrapper> xDecrRes = xEncrypter->decrypt( xTemplate , xSecCtx ) ;
- OSL_ENSURE( xDecrRes.is() ,
- "Decryptor - "
- "Cannot decrypt the xml document" ) ;
- } catch( Exception& e ) {
- fprintf( stderr , "Error Message: %s\n" , OUStringToOString( e.Message , RTL_TEXTENCODING_ASCII_US ).getStr() ) ;
- goto done ;
- }
-
- dstFile = fopen( argv[3], "w" ) ;
- if( dstFile == NULL ) {
- fprintf( stderr , "### Can not open file %s\n", argv[3] ) ;
- goto done ;
- }
-
- //Save result
- xmlDocDump( dstFile, doc ) ;
-
-done:
- if( dstFile != NULL )
- fclose( dstFile ) ;
-
- if( slot != NULL )
- PK11_FreeSlot( slot ) ;
-
- PK11_LogoutAll() ;
- NSS_Shutdown() ;
-
- /* Shutdown libxslt/libxml */
- #ifndef XMLSEC_NO_XSLT
- xsltCleanupGlobals();
- #endif /* XMLSEC_NO_XSLT */
- xmlCleanupParser();
-
- return 0;
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmlsecurity/tools/standalone/mscsfit/encrypter.cxx b/xmlsecurity/tools/standalone/mscsfit/encrypter.cxx
deleted file mode 100644
index 621836275..000000000
--- a/xmlsecurity/tools/standalone/mscsfit/encrypter.cxx
+++ /dev/null
@@ -1,310 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/** -- C++ Source File -- **/
-
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_xmlsecurity.hxx"
-#include <stdio.h>
-#include "helper.hxx"
-
-#include "libxml/tree.h"
-#include "libxml/parser.h"
-#ifndef XMLSEC_NO_XSLT
-#include "libxslt/xslt.h"
-#endif
-
-#include "securityenvironment_mscryptimpl.hxx"
-#include "xmlelementwrapper_xmlsecimpl.hxx"
-
-#include "xmlsec/strings.h"
-#include "xmlsec/mscrypto/app.h"
-#include "xmlsec/xmltree.h"
-
-#include <rtl/ustring.hxx>
-#include <cppuhelper/servicefactory.hxx>
-
-#include <com/sun/star/lang/XComponent.hpp>
-#include <com/sun/star/beans/PropertyValue.hpp>
-#include <com/sun/star/xml/wrapper/XXMLElementWrapper.hpp>
-#include <com/sun/star/xml/wrapper/XXMLDocumentWrapper.hpp>
-#include <com/sun/star/xml/crypto/XXMLEncryption.hpp>
-#include <com/sun/star/xml/crypto/XXMLEncryptionTemplate.hpp>
-#include <com/sun/star/xml/crypto/XXMLSecurityContext.hpp>
-#include <com/sun/star/xml/crypto/XSecurityEnvironment.hpp>
-
-using namespace ::rtl ;
-using namespace ::cppu ;
-using namespace ::com::sun::star::uno ;
-using namespace ::com::sun::star::io ;
-using namespace ::com::sun::star::ucb ;
-using namespace ::com::sun::star::beans ;
-using namespace ::com::sun::star::document ;
-using namespace ::com::sun::star::lang ;
-using namespace ::com::sun::star::registry ;
-using namespace ::com::sun::star::xml::wrapper ;
-using namespace ::com::sun::star::xml::crypto ;
-
-int SAL_CALL main( int argc, char **argv )
-{
- const char* n_pCertStore ;
- HCERTSTORE n_hStoreHandle ;
-
- xmlDocPtr doc = NULL ;
- xmlNodePtr tplNode ;
- xmlNodePtr tarNode ;
- FILE* dstFile = NULL ;
-
- HCRYPTPROV hCryptProv = NULL ;
- HCRYPTKEY symKey = NULL ;
-
- if( argc != 6 && argc != 7 ) {
- fprintf( stderr, "Usage: %s <file_url of template> <file_url of result> <target element name> <target element namespace> <rdb file>\n\n" , argv[0] ) ;
- fprintf( stderr, "Usage: %s <file_url of template> <file_url of result> <target element name> <target element namespace> <rdb file> < Cert Store Name >\n\n" , argv[0] ) ;
- return 1 ;
- }
-
- //Init libxml and libxslt libraries
- xmlInitParser();
- LIBXML_TEST_VERSION
- xmlLoadExtDtdDefaultValue = XML_DETECT_IDS | XML_COMPLETE_ATTRS;
- xmlSubstituteEntitiesDefault(1);
-
- #ifndef XMLSEC_NO_XSLT
- xmlIndentTreeOutput = 1;
- #endif // XMLSEC_NO_XSLT
-
- //Initialize the crypto engine
- if( argc == 7 ) {
- n_pCertStore = argv[6] ;
- n_hStoreHandle = CertOpenSystemStore( NULL, n_pCertStore ) ;
- if( n_hStoreHandle == NULL ) {
- fprintf( stderr, "Can not open the system cert store %s\n", n_pCertStore ) ;
- return 1 ;
- }
- } else {
- n_pCertStore = NULL ;
- n_hStoreHandle = NULL ;
- }
- xmlSecMSCryptoAppInit( n_pCertStore ) ;
-
- //Create encryption key.
- //CryptAcquireContext( &hCryptProv , NULL , NULL , PROV_RSA_FULL , CRYPT_DELETEKEYSET ) ;
- //CryptAcquireContext( &hCryptProv , "MyTempKeyContainer" , NULL , PROV_RSA_FULL , CRYPT_DELETEKEYSET ) ;
-
- if( !CryptAcquireContext( &hCryptProv , NULL , NULL , PROV_RSA_FULL , CRYPT_VERIFYCONTEXT ) ) {
- fprintf( stderr, "### cannot get crypto provider context!\n" );
- goto done ;
- }
-
- if( !CryptGenKey( hCryptProv, CALG_RC4, 0x00800000 | CRYPT_EXPORTABLE, &symKey ) ) {
- fprintf( stderr , "### cannot create symmetric key!\n" ) ;
- goto done ;
- }
-
- //Load XML document
- doc = xmlParseFile( argv[1] ) ;
- if( doc == NULL || xmlDocGetRootElement( doc ) == NULL ) {
- fprintf( stderr , "### Cannot load template xml document!\n" ) ;
- goto done ;
- }
-
- //Find the encryption template
- tplNode = xmlSecFindNode( xmlDocGetRootElement( doc ), xmlSecNodeEncryptedData, xmlSecEncNs ) ;
- if( tplNode == NULL ) {
- fprintf( stderr , "### Cannot find the encryption template!\n" ) ;
- goto done ;
- }
-
- //Find the encryption template
- tarNode = xmlSecFindNode( xmlDocGetRootElement( doc ), ( const unsigned char*)argv[3], ( const unsigned char*)argv[4] ) ;
- if( tarNode == NULL ) {
- fprintf( stderr , "### Cannot find the encryption target!\n" ) ;
- goto done ;
- }
-
- try {
- Reference< XMultiComponentFactory > xManager = NULL ;
- Reference< XComponentContext > xContext = NULL ;
-
- xManager = serviceManager( xContext , OUString(RTL_CONSTASCII_USTRINGPARAM("local")), OUString::createFromAscii( argv[5] ) ) ;
-
- //Create encryption template
- Reference< XInterface > tplElement =
- xManager->createInstanceWithContext( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.xml.security.bridge.xmlsec.XMLElementWrapper_XmlSecImpl")) , xContext ) ;
- OSL_ENSURE( tplElement.is() ,
- "Encryptor - "
- "Cannot get service instance of \"xsec.XMLElementWrapper\"" ) ;
-
- Reference< XXMLElementWrapper > xTplElement( tplElement , UNO_QUERY ) ;
- OSL_ENSURE( xTplElement.is() ,
- "Encryptor - "
- "Cannot get interface of \"XXMLElementWrapper\" from service \"xsec.XMLElementWrapper\"" ) ;
-
- Reference< XUnoTunnel > xTplEleTunnel( xTplElement , UNO_QUERY ) ;
- OSL_ENSURE( xTplEleTunnel.is() ,
- "Encryptor - "
- "Cannot get interface of \"XUnoTunnel\" from service \"xsec.XMLElementWrapper\"" ) ;
-
- XMLElementWrapper_XmlSecImpl* pTplElement = ( XMLElementWrapper_XmlSecImpl* )xTplEleTunnel->getSomething( XMLElementWrapper_XmlSecImpl::getUnoTunnelImplementationId() ) ;
- OSL_ENSURE( pTplElement != NULL ,
- "Encryptor - "
- "Cannot get implementation of \"xsec.XMLElementWrapper\"" ) ;
-
- pTplElement->setNativeElement( tplNode ) ;
-
- //Create encryption target element
- Reference< XInterface > tarElement =
- xManager->createInstanceWithContext( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.xml.security.bridge.xmlsec.XMLElementWrapper_XmlSecImpl")) , xContext ) ;
- OSL_ENSURE( tarElement.is() ,
- "Encryptor - "
- "Cannot get service instance of \"xsec.XMLElementWrapper\"" ) ;
-
- Reference< XXMLElementWrapper > xTarElement( tarElement , UNO_QUERY ) ;
- OSL_ENSURE( xTarElement.is() ,
- "Encryptor - "
- "Cannot get interface of \"XXMLElementWrapper\" from service \"xsec.XMLElementWrapper\"" ) ;
-
- Reference< XUnoTunnel > xTarEleTunnel( xTarElement , UNO_QUERY ) ;
- OSL_ENSURE( xTarEleTunnel.is() ,
- "Encryptor - "
- "Cannot get interface of \"XUnoTunnel\" from service \"xsec.XMLElementWrapper\"" ) ;
-
- XMLElementWrapper_XmlSecImpl* pTarElement = ( XMLElementWrapper_XmlSecImpl* )xTarEleTunnel->getSomething( XMLElementWrapper_XmlSecImpl::getUnoTunnelImplementationId() ) ;
- OSL_ENSURE( pTarElement != NULL ,
- "Encryptor - "
- "Cannot get implementation of \"xsec.XMLElementWrapper\"" ) ;
-
- pTarElement->setNativeElement( tarNode ) ;
-
-
- //Build XML Encryption template
- Reference< XInterface > enctpl =
- xManager->createInstanceWithContext( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.xml.crypto.XMLEncryptionTemplate")), xContext ) ;
- OSL_ENSURE( enctpl.is() ,
- "Encryptor - "
- "Cannot get service instance of \"xsec.XMLEncryptionTemplate\"" ) ;
-
- Reference< XXMLEncryptionTemplate > xTemplate( enctpl , UNO_QUERY ) ;
- OSL_ENSURE( xTemplate.is() ,
- "Encryptor - "
- "Cannot get interface of \"XXMLEncryptionTemplate\" from service \"xsec.XMLEncryptionTemplate\"" ) ;
-
- //Import the encryption template
- xTemplate->setTemplate( xTplElement ) ;
- xTemplate->setTarget( xTarElement ) ;
-
- //Create security environment
- //Build Security Environment
- Reference< XInterface > xsecenv =
- xManager->createInstanceWithContext( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.xml.security.bridge.xmlsec.SecurityEnvironment_MSCryptImpl")), xContext ) ;
- OSL_ENSURE( xsecenv.is() ,
- "Encryptor - "
- "Cannot get service instance of \"xsec.SecurityEnvironment\"" ) ;
-
- Reference< XSecurityEnvironment > xSecEnv( xsecenv , UNO_QUERY ) ;
- OSL_ENSURE( xSecEnv.is() ,
- "Encryptor - "
- "Cannot get interface of \"XSecurityEnvironment\" from service \"xsec.SecurityEnvironment\"" ) ;
-
- //Setup key slot and certDb
- Reference< XUnoTunnel > xEnvTunnel( xsecenv , UNO_QUERY ) ;
- OSL_ENSURE( xEnvTunnel.is() ,
- "Encryptor - "
- "Cannot get interface of \"XUnoTunnel\" from service \"xsec.SecurityEnvironment\"" ) ;
-
- SecurityEnvironment_MSCryptImpl* pSecEnv = ( SecurityEnvironment_MSCryptImpl* )xEnvTunnel->getSomething( SecurityEnvironment_MSCryptImpl::getUnoTunnelId() ) ;
- OSL_ENSURE( pSecEnv != NULL ,
- "Encryptor - "
- "Cannot get implementation of \"xsec.SecurityEnvironment\"" ) ;
-
- //Setup key slot and certDb
- if( n_hStoreHandle != NULL ) {
- pSecEnv->setCryptoSlot( n_hStoreHandle ) ;
- pSecEnv->setCertDb( n_hStoreHandle ) ;
- } else {
- pSecEnv->enableDefaultCrypt( sal_True ) ;
- }
-
- pSecEnv->adoptSymKey( symKey ) ;
-
-
- //Build XML Security Context
- Reference< XInterface > xmlsecctx =
- xManager->createInstanceWithContext( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.xml.security.bridge.xmlsec.XMLSecurityContext_MSCryptImpl")), xContext ) ;
- OSL_ENSURE( xmlsecctx.is() ,
- "Encryptor - "
- "Cannot get service instance of \"xsec.XMLSecurityContext\"" ) ;
-
- Reference< XXMLSecurityContext > xSecCtx( xmlsecctx , UNO_QUERY ) ;
- OSL_ENSURE( xSecCtx.is() ,
- "Encryptor - "
- "Cannot get interface of \"XXMLSecurityContext\" from service \"xsec.XMLSecurityContext\"" ) ;
-
- xSecCtx->addSecurityEnvironment( xSecEnv ) ;
-
- //Get encrypter
- Reference< XInterface > xmlencrypter =
- xManager->createInstanceWithContext( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.xml.security.bridge.xmlsec.XMLEncryption_MSCryptImpl")), xContext ) ;
- OSL_ENSURE( xmlencrypter.is() ,
- "Encryptor - "
- "Cannot get service instance of \"xsec.XMLEncryption\"" ) ;
-
- Reference< XXMLEncryption > xEncrypter( xmlencrypter , UNO_QUERY ) ;
- OSL_ENSURE( xEncrypter.is() ,
- "Encryptor - "
- "Cannot get interface of \"XXMLEncryption\" from service \"xsec.XMLEncryption\"" ) ;
-
- //perform encryption
- xTemplate = xEncrypter->encrypt( xTemplate , xSecEnv ) ;
- OSL_ENSURE( xTemplate.is() ,
- "Encryptor - "
- "Cannot encrypt the xml document" ) ;
-
-
- com::sun::star::xml::crypto::SecurityOperationStatus m_nStatus = xTemplate->getStatus();
- if (m_nStatus == SecurityOperationStatus_OPERATION_SUCCEEDED)
- {
- fprintf( stdout, "Operation succeeds.\n") ;
- }
- else
- {
- fprintf( stdout, "Operation fails.\n") ;
- }
- } catch( Exception& e ) {
- fprintf( stderr , "Error Message: %s\n" , OUStringToOString( e.Message , RTL_TEXTENCODING_ASCII_US ).getStr() ) ;
- goto done ;
- }
-
- dstFile = fopen( argv[2], "w" ) ;
- if( dstFile == NULL ) {
- fprintf( stderr , "### Can not open file %s\n", argv[2] ) ;
- goto done ;
- }
-
- //Save result
- xmlDocDump( dstFile, doc ) ;
-
-done:
- if( dstFile != NULL )
- fclose( dstFile ) ;
-
- if( symKey != NULL ) {
- CryptDestroyKey( symKey ) ;
- }
-
- if( hCryptProv != NULL ) {
- CryptReleaseContext( hCryptProv, 0 ) ;
- }
-
- if( n_hStoreHandle != NULL )
- CertCloseStore( n_hStoreHandle, CERT_CLOSE_STORE_FORCE_FLAG ) ;
-
- /* Shutdown libxslt/libxml */
- #ifndef XMLSEC_NO_XSLT
- xsltCleanupGlobals();
- #endif /* XMLSEC_NO_XSLT */
- xmlCleanupParser();
-
- return 0;
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmlsecurity/tools/standalone/mscsfit/helper.cxx b/xmlsecurity/tools/standalone/mscsfit/helper.cxx
deleted file mode 100644
index 9a7b4bb75..000000000
--- a/xmlsecurity/tools/standalone/mscsfit/helper.cxx
+++ /dev/null
@@ -1,222 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-#include "helper.hxx"
-#include "osl/diagnose.h"
-#include "rtl/ustring.h"
-
-/*-
- * Helper : create a input stream from a file
- */
-Reference< XInputStream > createStreamFromFile( const OUString sFile )
-{
- const sal_Char* pcFile ;
- OString aString ;
-
- aString = OUStringToOString( sFile , RTL_TEXTENCODING_ASCII_US ) ;
- pcFile = aString.getStr() ;
- if( pcFile != NULL ) {
- FILE *f = fopen( pcFile , "rb" );
- Reference< XInputStream > r;
-
- if( f ) {
- fseek( f , 0 , SEEK_END );
- int nLength = ftell( f );
- fseek( f , 0 , SEEK_SET );
-
- Sequence<sal_Int8> seqIn(nLength);
- fread( seqIn.getArray() , nLength , 1 , f );
-
- r = Reference< XInputStream > ( new OInputStream( seqIn ) );
- fclose( f );
- }
- return r;
- } else {
- return NULL ;
- }
-
- return NULL ;
-}
-
-/*-
- * Helper : set a output stream to a file
- */
-Reference< XOutputStream > createStreamToFile( const OUString sFile )
-{
- const sal_Char* pcFile ;
- OString aString ;
-
- aString = OUStringToOString( sFile , RTL_TEXTENCODING_ASCII_US ) ;
- pcFile = aString.getStr() ;
- if( pcFile != NULL )
- return Reference< XOutputStream >( new OOutputStream( pcFile ) ) ;
- else
- return NULL ;
-}
-
-/*-
- * Helper : get service manager and context
- */
-Reference< XMultiComponentFactory > serviceManager( Reference< XComponentContext >& xContext , OUString sUnoUrl , OUString sRdbUrl ) throw( RuntimeException , Exception )
-{
- Reference< XMultiComponentFactory > xLocalServiceManager = NULL ;
- Reference< XComponentContext > xLocalComponentContext = NULL ;
- Reference< XMultiComponentFactory > xUsedServiceManager = NULL ;
- Reference< XComponentContext > xUsedComponentContext = NULL ;
-
- OSL_ENSURE( sUnoUrl.getLength() ,
- "serviceManager - "
- "No uno URI specified" ) ;
-
- OSL_ENSURE( sRdbUrl.getLength() ,
- "serviceManager - "
- "No rdb URI specified" ) ;
-
- if( sUnoUrl.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "local" ) ) ) {
- Reference< XSimpleRegistry > xSimpleRegistry = createSimpleRegistry();
- OSL_ENSURE( xSimpleRegistry.is() ,
- "serviceManager - "
- "Cannot create simple registry" ) ;
-
- //xSimpleRegistry->open(OUString(RTL_CONSTASCII_USTRINGPARAM("xmlsecurity.rdb")), sal_False, sal_False);
- xSimpleRegistry->open(sRdbUrl, sal_True, sal_False);
- OSL_ENSURE( xSimpleRegistry->isValid() ,
- "serviceManager - "
- "Cannot open xml security registry rdb" ) ;
-
- xLocalComponentContext = 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" ) ;
-
- /*-
- * Because of the exception rasied from
- * ucbhelper/source/provider/provconf.cxx, lin 323
- * I do not use the content broker at present
- ********************************************************************
- //init ucb
- if( ::ucb::ContentBroker::get() == NULL ) {
- Reference< lang::XMultiServiceFactory > xSvmg( xLocalServiceManager , UNO_QUERY ) ;
- OSL_ENSURE( xLocalServiceManager.is() ,
- "serviceManager - "
- "Cannot get multi-service factory" ) ;
-
- Sequence< Any > args( 2 ) ;
- args[ 0 ] <<= OUString(RTL_CONSTASCII_USTRINGPARAM( UCB_CONFIGURATION_KEY1_LOCAL )) ;
- args[ 1 ] <<= OUString(RTL_CONSTASCII_USTRINGPARAM( UCB_CONFIGURATION_KEY2_OFFICE )) ;
- if( ! ::ucb::ContentBroker::initialize( xSvmg , args ) ) {
- throw RuntimeException( OUString(RTL_CONSTASCII_USTRINGPARAM("Cannot inlitialize ContentBroker")) , Reference< XInterface >() , Any() ) ;
- }
- }
- ********************************************************************/
-
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_xmlsecurity.hxx"
-
- xUsedComponentContext = xLocalComponentContext ;
- xUsedServiceManager = xLocalServiceManager ;
- } else {
- Reference< XComponentContext > xLocalComponentContext = defaultBootstrap_InitialComponentContext() ;
- OSL_ENSURE( xLocalComponentContext.is() ,
- "serviceManager - "
- "Cannot create intial component context" ) ;
-
- Reference< XMultiComponentFactory > xLocalServiceManager = xLocalComponentContext->getServiceManager();
- OSL_ENSURE( xLocalServiceManager.is() ,
- "serviceManager - "
- "Cannot create intial service manager" ) ;
-
- Reference< XInterface > urlResolver =
- xLocalServiceManager->createInstanceWithContext( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.bridge.UnoUrlResolver")) , xLocalComponentContext ) ;
- OSL_ENSURE( urlResolver.is() ,
- "serviceManager - "
- "Cannot get service instance of \"bridge.UnoUrlResolver\"" ) ;
-
- Reference< XUnoUrlResolver > xUnoUrlResolver( urlResolver , UNO_QUERY ) ;
- OSL_ENSURE( xUnoUrlResolver.is() ,
- "serviceManager - "
- "Cannot get interface of \"XUnoUrlResolver\" from service \"bridge.UnoUrlResolver\"" ) ;
-
- Reference< XInterface > initialObject = xUnoUrlResolver->resolve( sUnoUrl ) ;
- OSL_ENSURE( initialObject.is() ,
- "serviceManager - "
- "Cannot resolve uno url" ) ;
-
- /*-
- * Method 1: with Naming Service
- ********************************************************************
- Reference< XNamingService > xNamingService( initialObject , UNO_QUERY ) ;
- OSL_ENSURE( xNamingService.is() ,
- "serviceManager - "
- "Cannot get interface of \"XNamingService\" from URL resolver" ) ;
-
- Reference< XInterface > serviceManager =
- xNamingService->getRegisteredObject( OUString(RTL_CONSTASCII_USTRINGPARAM("StarOffice.ServiceManager")) ) ;
- OSL_ENSURE( serviceManager.is() ,
- "serviceManager - "
- "Cannot get service instance of \"StarOffice.ServiceManager\"" ) ;
-
- xUsedServiceManager = Reference< XMultiComponentFactory >( serviceManager , UNO_QUERY );
- OSL_ENSURE( xUsedServiceManager.is() ,
- "serviceManager - "
- "Cannot get interface of \"XMultiComponentFactory\" from service \"StarOffice.ServiceManager\"" ) ;
-
- Reference< XPropertySet > xPropSet( xUsedServiceManager , UNO_QUERY ) ;
- OSL_ENSURE( xPropSet.is() ,
- "serviceManager - "
- "Cannot get interface of \"XPropertySet\" from service \"StarOffice.ServiceManager\"" ) ;
-
- xPropSet->getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("DefaultContext")) ) >>= xUsedComponentContext ;
- OSL_ENSURE( xUsedComponentContext.is() ,
- "serviceManager - "
- "Cannot create remote component context" ) ;
-
- ********************************************************************/
-
- /*-
- * Method 2: with Componnent context
- ********************************************************************
- Reference< XPropertySet > xPropSet( initialObject , UNO_QUERY ) ;
- OSL_ENSURE( xPropSet.is() ,
- "serviceManager - "
- "Cannot get interface of \"XPropertySet\" from URL resolver" ) ;
-
- xPropSet->getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("DefaultContext")) ) >>= xUsedComponentContext ;
- OSL_ENSURE( xUsedComponentContext.is() ,
- "serviceManager - "
- "Cannot create remote component context" ) ;
-
- xUsedServiceManager = xUsedComponentContext->getServiceManager();
- OSL_ENSURE( xUsedServiceManager.is() ,
- "serviceManager - "
- "Cannot create remote service manager" ) ;
- ********************************************************************/
-
- /*-
- * Method 3: with Service Manager
- ********************************************************************/
- xUsedServiceManager = Reference< XMultiComponentFactory >( initialObject , UNO_QUERY );
- OSL_ENSURE( xUsedServiceManager.is() ,
- "serviceManager - "
- "Cannot create remote service manager" ) ;
-
- Reference< XPropertySet > xPropSet( xUsedServiceManager , UNO_QUERY ) ;
- OSL_ENSURE( xPropSet.is() ,
- "serviceManager - "
- "Cannot get interface of \"XPropertySet\" from service \"StarOffice.ServiceManager\"" ) ;
-
- xPropSet->getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("DefaultContext")) ) >>= xUsedComponentContext ;
- OSL_ENSURE( xUsedComponentContext.is() ,
- "serviceManager - "
- "Cannot create remote component context" ) ;
- /********************************************************************/
- }
-
- xContext = xUsedComponentContext ;
- return xUsedServiceManager ;
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmlsecurity/tools/standalone/mscsfit/helper.hxx b/xmlsecurity/tools/standalone/mscsfit/helper.hxx
deleted file mode 100644
index 3fe345ffd..000000000
--- a/xmlsecurity/tools/standalone/mscsfit/helper.hxx
+++ /dev/null
@@ -1,204 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-#include <stdio.h>
-#include <rtl/ustring.hxx>
-
-#include <cppuhelper/bootstrap.hxx>
-#include <cppuhelper/implbase1.hxx>
-#include <cppuhelper/servicefactory.hxx>
-#include <ucbhelper/contentbroker.hxx>
-#include <ucbhelper/configurationkeys.hxx>
-
-#include <com/sun/star/lang/XComponent.hpp>
-#include <com/sun/star/bridge/XUnoUrlResolver.hpp>
-#include <com/sun/star/registry/XImplementationRegistration.hpp>
-#include <com/sun/star/document/XFilter.hpp>
-#include <com/sun/star/document/XExporter.hpp>
-#include <com/sun/star/document/XImporter.hpp>
-#include <com/sun/star/io/XActiveDataSource.hpp>
-#include <com/sun/star/beans/PropertyValue.hpp>
-#include <com/sun/star/beans/XPropertySet.hpp>
-#include <com/sun/star/ucb/XSimpleFileAccess.hpp>
-
-#include <com/sun/star/xml/crypto/XUriBinding.hpp>
-#include <com/sun/star/xml/wrapper/XXMLDocumentWrapper.hpp>
-#include <com/sun/star/xml/wrapper/XXMLElementWrapper.hpp>
-
-#include <com/sun/star/xml/sax/XParser.hpp>
-#include <com/sun/star/xml/sax/XDocumentHandler.hpp>
-#include <com/sun/star/xml/sax/XExtendedDocumentHandler.hpp>
-#include <com/sun/star/xml/sax/InputSource.hpp>
-#include <com/sun/star/io/XInputStream.hpp>
-#include <com/sun/star/io/XOutputStream.hpp>
-#include <com/sun/star/uno/XNamingService.hpp>
-
-using namespace ::rtl ;
-using namespace ::cppu ;
-using namespace ::com::sun::star ;
-using namespace ::com::sun::star::uno ;
-using namespace ::com::sun::star::io ;
-using namespace ::com::sun::star::ucb ;
-using namespace ::com::sun::star::beans ;
-using namespace ::com::sun::star::document ;
-using namespace ::com::sun::star::lang ;
-using namespace ::com::sun::star::bridge ;
-using namespace ::com::sun::star::registry ;
-using namespace ::com::sun::star::task ;
-using namespace ::com::sun::star::xml ;
-using namespace ::com::sun::star::xml::wrapper ;
-using namespace ::com::sun::star::xml::sax ;
-
-
-/**
- * Helper: Implementation of XInputStream
- */
-class OInputStream : public WeakImplHelper1 < XInputStream >
-{
- public:
- OInputStream( const Sequence< sal_Int8 >&seq ) : m_seq( seq ), nPos( 0 ) {}
-
- virtual sal_Int32 SAL_CALL readBytes(
- Sequence< sal_Int8 >& aData ,
- sal_Int32 nBytesToRead
- ) throw( NotConnectedException, BufferSizeExceededException, IOException, RuntimeException )
- {
- nBytesToRead = ( nBytesToRead > m_seq.getLength() - nPos ) ?
- m_seq.getLength() - nPos :
- nBytesToRead ;
- aData = Sequence< sal_Int8 > ( &( m_seq.getConstArray()[nPos] ), nBytesToRead ) ;
- nPos += nBytesToRead ;
- return nBytesToRead ;
- }
-
- virtual sal_Int32 SAL_CALL readSomeBytes(
- ::com::sun::star::uno::Sequence< sal_Int8 >& aData ,
- sal_Int32 nMaxBytesToRead
- ) throw( NotConnectedException, BufferSizeExceededException, IOException, RuntimeException )
- {
- return readBytes( aData, nMaxBytesToRead ) ;
- }
-
- virtual void SAL_CALL skipBytes(
- sal_Int32 nBytesToSkip
- ) throw( NotConnectedException, BufferSizeExceededException, IOException, RuntimeException )
- {
- // not implemented
- }
-
- virtual sal_Int32 SAL_CALL available(
- void
- ) throw( NotConnectedException, IOException, RuntimeException )
- {
- return m_seq.getLength() - nPos ;
- }
-
- virtual void SAL_CALL closeInput(
- void
- ) throw( NotConnectedException, IOException, RuntimeException )
- {
- // not needed
- }
-
- private:
- sal_Int32 nPos;
- Sequence< sal_Int8> m_seq;
-} ;
-
-/**
- * Helper : create a input stream from a file
- */
-Reference< XInputStream > createStreamFromFile( const OUString sFile ) ;
-
-/**
- * Helper: Implementation of XOutputStream
- */
-class OOutputStream : public WeakImplHelper1 < XOutputStream >
-{
- public:
- OOutputStream( const char *pcFile ) {
- strcpy( m_pcFile , pcFile ) ;
- m_f = 0 ;
- }
-
- virtual void SAL_CALL writeBytes(
- const Sequence< sal_Int8 >& aData
- ) throw( NotConnectedException , BufferSizeExceededException , RuntimeException ) {
- if( !m_f ) {
- m_f = fopen( m_pcFile , "w" ) ;
- }
-
- fwrite( aData.getConstArray() , 1 , aData.getLength() , m_f ) ;
- }
-
- virtual void SAL_CALL flush(
- void
- ) throw( NotConnectedException , BufferSizeExceededException , RuntimeException ) {
- fflush( m_f ) ;
- }
-
- virtual void SAL_CALL closeOutput(
- void
- ) throw( NotConnectedException , BufferSizeExceededException , RuntimeException ) {
- fclose( m_f ) ;
- m_f = 0 ;
- }
-
- private:
- char m_pcFile[256];
- FILE *m_f;
-} ;
-
-/**
- * Helper: Implementation of XUriBinding
- */
-class OUriBinding : public WeakImplHelper1 < ::com::sun::star::xml::crypto::XUriBinding >
-{
- public:
- OUriBinding() {
- //Do nothing
- }
-
- OUriBinding(
- ::rtl::OUString& aUri,
- ::com::sun::star::uno::Reference< com::sun::star::io::XInputStream >& aInputStream ) {
- m_vUris.push_back( aUri ) ;
- m_vStreams.push_back( aInputStream ) ;
- }
-
- virtual void SAL_CALL setUriBinding(
- const ::rtl::OUString& aUri ,
- const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& aInputStream
- ) throw( ::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException ) {
- m_vUris.push_back( aUri ) ;
- m_vStreams.push_back( aInputStream ) ;
- }
-
- virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getUriBinding( const ::rtl::OUString& uri ) throw( ::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException ) {
- ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > xInputStream ;
-
- int size = m_vUris.size() ;
- for( int i = 0 ; i<size ; ++i ) {
- if( uri == m_vUris[i] ) {
- xInputStream = m_vStreams[i];
- break;
- }
- }
-
- return xInputStream;
- }
-
- private:
- std::vector< ::rtl::OUString > m_vUris ;
- std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > > m_vStreams ;
-} ;
-
-/**
- * Helper : set a output stream to a file
- */
-Reference< XOutputStream > createStreamToFile( const OUString sFile ) ;
-
-/**
- * Helper : get service manager and context
- */
-Reference< XMultiComponentFactory > serviceManager( Reference< XComponentContext >& xContext , OUString sUnoUrl , OUString sRdbUrl ) throw( RuntimeException , Exception ) ;
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmlsecurity/tools/standalone/mscsfit/makefile.mk b/xmlsecurity/tools/standalone/mscsfit/makefile.mk
deleted file mode 100644
index ce8be6685..000000000
--- a/xmlsecurity/tools/standalone/mscsfit/makefile.mk
+++ /dev/null
@@ -1,131 +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=xmlsecurity-mscxsfit
-ENABLE_EXCEPTIONS=TRUE
-NO_BSYMBOLIC=TRUE
-LIBTARGET=NO
-
-
-# --- Settings -----------------------------------------------------
-
-.INCLUDE : settings.mk
-.INCLUDE : $(PRJ)$/util$/target.pmk
-
-.IF "$(CRYPTO_ENGINE)" == "mscrypto"
-
-CDEFS += -DXMLSEC_CRYPTO_MSCRYPTO -DXMLSEC_NO_XSLT
-SOLARINC += \
- -I$(PRJ)$/source$/xmlsec \
- -I$(PRJ)$/source$/xmlsec$/mscrypt
-
-# --- Files --------------------------------------------------------
-
-SHARE_LIBS = \
- $(CPPULIB) \
- $(CPPUHELPERLIB) \
- $(SALLIB)
-
-.IF "$(GUI)"=="WNT"
-SHARE_LIBS+= "libxml2.lib" "crypt32.lib" "advapi32.lib" "libxmlsec.lib" "libxmlsec-mscrypto.lib" "xsec_xmlsec.lib" "xs_comm.lib" "xs_mscrypt.lib"
-.ELSE
-SHARE_LIBS+= "-lxml2" "-lnss3" "-lnspr4" "-lxmlsec1" "-lxmlsec1-nss" "-lxsec_xmlsec" "-lxs_comm" "-lxs_nss"
-.ENDIF
-
-SHARE_OBJS = \
- $(OBJ)$/helper.obj
-
-#
-# The 1st application
-#
-
-APP2TARGET= signer
-APP2OBJS= \
- $(SHARE_OBJS) \
- $(OBJ)$/signer.obj
-
-.IF "$(OS)" == "LINUX"
-APP2STDLIBS+= -lstdc++
-.ENDIF
-
-APP2STDLIBS+= \
- $(SHARE_LIBS)
-
-#
-# The 2nd application
-#
-APP3TARGET= encrypter
-APP3OBJS= \
- $(SHARE_OBJS) \
- $(OBJ)$/encrypter.obj
-
-.IF "$(OS)" == "LINUX"
-APP3STDLIBS+= -lstdc++
-.ENDIF
-
-APP3STDLIBS+= \
- $(SHARE_LIBS)
-
-#
-# The 3rd application
-#
-APP4TARGET= verifier
-APP4OBJS= \
- $(SHARE_OBJS) \
- $(OBJ)$/verifier.obj
-
-.IF "$(OS)" == "LINUX"
-APP4STDLIBS+= -lstdc++
-.ENDIF
-
-APP4STDLIBS+= \
- $(SHARE_LIBS)
-
-#
-# The 5th application
-#
-APP6TARGET= certmngr
-APP6OBJS= \
- $(SHARE_OBJS) \
- $(OBJ)$/certmngr.obj
-
-.IF "$(OS)" == "LINUX"
-APP6STDLIBS+= -lstdc++
-.ENDIF
-
-APP6STDLIBS+= \
- $(SHARE_LIBS)
-
-.ENDIF
-
-# --- Targets ------------------------------------------------------
-
-.INCLUDE : target.mk
-
diff --git a/xmlsecurity/tools/standalone/mscsfit/signer.cxx b/xmlsecurity/tools/standalone/mscsfit/signer.cxx
deleted file mode 100644
index d515e0a7f..000000000
--- a/xmlsecurity/tools/standalone/mscsfit/signer.cxx
+++ /dev/null
@@ -1,344 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/** -- C++ Source File -- **/
-
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_xmlsecurity.hxx"
-#include <stdio.h>
-#include "helper.hxx"
-
-#include "libxml/tree.h"
-#include "libxml/parser.h"
-#ifndef XMLSEC_NO_XSLT
-#include "libxslt/xslt.h"
-#endif
-
-#include "securityenvironment_mscryptimpl.hxx"
-#include "xmlelementwrapper_xmlsecimpl.hxx"
-
-#include "xmlsec/strings.h"
-#include "xmlsec/mscrypto/app.h"
-#include "xmlsec/xmltree.h"
-
-#include <rtl/ustring.hxx>
-
-#include <com/sun/star/beans/PropertyValue.hpp>
-#include <com/sun/star/xml/wrapper/XXMLElementWrapper.hpp>
-#include <com/sun/star/xml/wrapper/XXMLDocumentWrapper.hpp>
-#include <com/sun/star/xml/crypto/XXMLSignature.hpp>
-#include <com/sun/star/xml/crypto/XXMLSignatureTemplate.hpp>
-#include <com/sun/star/xml/crypto/XXMLSecurityContext.hpp>
-#include <com/sun/star/xml/crypto/XSecurityEnvironment.hpp>
-
-using namespace ::rtl ;
-using namespace ::cppu ;
-using namespace ::com::sun::star::uno ;
-using namespace ::com::sun::star::io ;
-using namespace ::com::sun::star::ucb ;
-using namespace ::com::sun::star::beans ;
-using namespace ::com::sun::star::document ;
-using namespace ::com::sun::star::lang ;
-using namespace ::com::sun::star::xml::wrapper ;
-using namespace ::com::sun::star::xml::crypto ;
-
-
-int SAL_CALL main( int argc, char **argv )
-{
- const char* n_pCertStore ;
- HCERTSTORE n_hStoreHandle ;
-
- xmlDocPtr doc = NULL ;
- xmlNodePtr tplNode ;
- xmlNodePtr tarNode ;
- xmlAttrPtr idAttr ;
- xmlChar* idValue ;
- xmlAttrPtr uriAttr ;
- xmlChar* uriValue ;
- OUString* uri = NULL ;
- Reference< XUriBinding > xUriBinding ;
- FILE* dstFile = NULL ;
-
- if( argc !=4 && argc != 5 ) {
- fprintf( stderr, "Usage: %s <file_url of template> <file_url of result> <rdb file>\n" , argv[0] ) ;
- fprintf( stderr, "Or: \t%s <file_url of template> <file_url of result> <rdb file> < Cert Store Name >\n\n" , argv[0] ) ;
- return 1 ;
- }
-
- for( int hhh = 0 ; hhh < 4 ; hhh ++ ) {
-
- //Init libxml and libxslt libraries
- xmlInitParser();
- LIBXML_TEST_VERSION
- xmlLoadExtDtdDefaultValue = XML_DETECT_IDS | XML_COMPLETE_ATTRS;
- xmlSubstituteEntitiesDefault(1);
-
- #ifndef XMLSEC_NO_XSLT
- xmlIndentTreeOutput = 1;
- #endif // XMLSEC_NO_XSLT
-
- //Initialize the crypto engine
- if( argc == 5 ) {
- n_pCertStore = argv[4] ;
- n_hStoreHandle = CertOpenSystemStore( NULL, n_pCertStore ) ;
- if( n_hStoreHandle == NULL ) {
- fprintf( stderr, "Can not open the system cert store %s\n", n_pCertStore ) ;
- return 1 ;
- }
- } else {
- n_pCertStore = NULL ;
- n_hStoreHandle = NULL ;
- }
- xmlSecMSCryptoAppInit( n_pCertStore ) ;
-
- //Load XML document
- doc = xmlParseFile( argv[1] ) ;
- if( doc == NULL || xmlDocGetRootElement( doc ) == NULL ) {
- fprintf( stderr , "### Cannot load template xml document!\n" ) ;
- goto done ;
- }
-
- //Find the signature template
- tplNode = xmlSecFindNode( xmlDocGetRootElement( doc ), xmlSecNodeSignature, xmlSecDSigNs ) ;
- if( tplNode == NULL ) {
- fprintf( stderr , "### Cannot find the signature template!\n" ) ;
- goto done ;
- }
-
- //Find the element with ID attribute
- //Here we only try to find the "document" node.
- tarNode = xmlSecFindNode( xmlDocGetRootElement( doc ), ( xmlChar* )"document", ( xmlChar* )"http://openoffice.org/2000/office" ) ;
- if( tarNode == NULL ) {
- tarNode = xmlSecFindNode( xmlDocGetRootElement( doc ), ( xmlChar* )"document", NULL ) ;
- }
-
- //Find the "id" attrbute in the element
- if( tarNode != NULL ) {
- if( ( idAttr = xmlHasProp( tarNode, ( xmlChar* )"id" ) ) != NULL ) {
- //NULL
- } else if( ( idAttr = xmlHasProp( tarNode, ( xmlChar* )"Id" ) ) != NULL ) {
- //NULL
- } else {
- idAttr = NULL ;
- }
- }
-
- //Add ID to DOM
- if( idAttr != NULL ) {
- idValue = xmlNodeListGetString( tarNode->doc, idAttr->children, 1 ) ;
- if( idValue == NULL ) {
- fprintf( stderr , "### the ID value is NULL!\n" ) ;
- goto done ;
- }
-
- if( xmlAddID( NULL, doc, idValue, idAttr ) == NULL ) {
- fprintf( stderr , "### Can not add the ID value!\n" ) ;
- goto done ;
- }
- }
-
- //Reference handler
- //Find the signature reference
- tarNode = xmlSecFindNode( tplNode, xmlSecNodeReference, xmlSecDSigNs ) ;
- if( tarNode == NULL ) {
- fprintf( stderr , "### Cannot find the signature reference!\n" ) ;
- goto done ;
- }
-
- //Find the "URI" attrbute in the reference
- uriAttr = xmlHasProp( tarNode, ( xmlChar* )"URI" ) ;
- if( tarNode == NULL ) {
- fprintf( stderr , "### Cannot find URI of the reference!\n" ) ;
- goto done ;
- }
-
- //Get the "URI" attrbute value
- uriValue = xmlNodeListGetString( tarNode->doc, uriAttr->children, 1 ) ;
- if( uriValue == NULL ) {
- fprintf( stderr , "### the URI value is NULL!\n" ) ;
- goto done ;
- }
-
- if( strchr( ( const char* )uriValue, '/' ) != NULL && strchr( ( const char* )uriValue, '#' ) == NULL ) {
- fprintf( stdout , "### Find a stream URI [%s]\n", uriValue ) ;
- // uri = new ::rtl::OUString( ( const sal_Unicode* )uriValue ) ;
- uri = new ::rtl::OUString( ( const sal_Char* )uriValue, xmlStrlen( uriValue ), RTL_TEXTENCODING_ASCII_US ) ;
- }
-
- if( uri != NULL ) {
- fprintf( stdout , "### Find the URI [%s]\n", OUStringToOString( *uri , RTL_TEXTENCODING_ASCII_US ).getStr() ) ;
- Reference< XInputStream > xStream = createStreamFromFile( *uri ) ;
- if( !xStream.is() ) {
- fprintf( stderr , "### Can not get the URI stream!\n" ) ;
- goto done ;
- }
-
- xUriBinding = new OUriBinding( *uri, xStream ) ;
- }
-
- try {
- Reference< XMultiComponentFactory > xManager = NULL ;
- Reference< XComponentContext > xContext = NULL ;
-
- xManager = serviceManager( xContext , OUString(RTL_CONSTASCII_USTRINGPARAM("local")), OUString::createFromAscii( argv[3] ) ) ;
- OSL_ENSURE( xManager.is() ,
- "ServicesManager - "
- "Cannot get service manager" ) ;
-
- //Create signature template
- Reference< XInterface > element =
- xManager->createInstanceWithContext( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.xml.security.bridge.xmlsec.XMLElementWrapper_XmlSecImpl")) , xContext ) ;
- OSL_ENSURE( element.is() ,
- "Signer - "
- "Cannot get service instance of \"wrapper.XMLElementWrapper\"" ) ;
-
- Reference< XXMLElementWrapper > xElement( element , UNO_QUERY ) ;
- OSL_ENSURE( xElement.is() ,
- "Signer - "
- "Cannot get interface of \"XXMLElement\" from service \"xsec.XMLElement\"" ) ;
-
- Reference< XUnoTunnel > xEleTunnel( xElement , UNO_QUERY ) ;
- OSL_ENSURE( xEleTunnel.is() ,
- "Signer - "
- "Cannot get interface of \"XUnoTunnel\" from service \"xsec.XMLElement\"" ) ;
-
- XMLElementWrapper_XmlSecImpl* pElement = ( XMLElementWrapper_XmlSecImpl* )xEleTunnel->getSomething( XMLElementWrapper_XmlSecImpl::getUnoTunnelImplementationId() ) ;
- OSL_ENSURE( pElement != NULL ,
- "Signer - "
- "Cannot get implementation of \"xsec.XMLElement\"" ) ;
-
- //Set signature template
- pElement->setNativeElement( tplNode ) ;
-
- //Build XML Signature template
- Reference< XInterface > signtpl =
- xManager->createInstanceWithContext( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.xml.crypto.XMLSignatureTemplate")) , xContext ) ;
- OSL_ENSURE( signtpl.is() ,
- "Signer - "
- "Cannot get service instance of \"xsec.XMLSignatureTemplate\"" ) ;
-
- Reference< XXMLSignatureTemplate > xTemplate( signtpl , UNO_QUERY ) ;
- OSL_ENSURE( xTemplate.is() ,
- "Signer - "
- "Cannot get interface of \"XXMLSignatureTemplate\" from service \"xsec.XMLSignatureTemplate\"" ) ;
-
- //Import the signature template
- xTemplate->setTemplate( xElement ) ;
-
- //Import the URI/Stream binding
- if( xUriBinding.is() )
- xTemplate->setBinding( xUriBinding ) ;
-
- //Create security environment
- //Build Security Environment
- Reference< XInterface > xsecenv =
- xManager->createInstanceWithContext( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.xml.security.bridge.xmlsec.SecurityEnvironment_MSCryptImpl")), xContext ) ;
- OSL_ENSURE( xsecenv.is() ,
- "Signer - "
- "Cannot get service instance of \"xsec.SecurityEnvironment\"" ) ;
-
- Reference< XSecurityEnvironment > xSecEnv( xsecenv , UNO_QUERY ) ;
- OSL_ENSURE( xSecEnv.is() ,
- "Signer - "
- "Cannot get interface of \"XSecurityEnvironment\" from service \"xsec.SecurityEnvironment\"" ) ;
-
- //Setup key slot and certDb
- Reference< XUnoTunnel > xEnvTunnel( xsecenv , UNO_QUERY ) ;
- OSL_ENSURE( xElement.is() ,
- "Signer - "
- "Cannot get interface of \"XUnoTunnel\" from service \"xsec.SecurityEnvironment\"" ) ;
-
- SecurityEnvironment_MSCryptImpl* pSecEnv = ( SecurityEnvironment_MSCryptImpl* )xEnvTunnel->getSomething( SecurityEnvironment_MSCryptImpl::getUnoTunnelId() ) ;
- OSL_ENSURE( pSecEnv != NULL ,
- "Signer - "
- "Cannot get implementation of \"xsec.SecurityEnvironment\"" ) ;
-
- //Setup key slot and certDb
- if( n_hStoreHandle != NULL ) {
- pSecEnv->setCryptoSlot( n_hStoreHandle ) ;
- pSecEnv->setCertDb( n_hStoreHandle ) ;
- } else {
- pSecEnv->enableDefaultCrypt( sal_True ) ;
- }
-
- //Build XML Security Context
- Reference< XInterface > xmlsecctx =
- xManager->createInstanceWithContext( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.xml.security.bridge.xmlsec.XMLSecurityContext_MSCryptImpl")), xContext ) ;
- OSL_ENSURE( xsecenv.is() ,
- "Signer - "
- "Cannot get service instance of \"xsec.XMLSecurityContext\"" ) ;
-
- Reference< XXMLSecurityContext > xSecCtx( xmlsecctx , UNO_QUERY ) ;
- OSL_ENSURE( xSecCtx.is() ,
- "Signer - "
- "Cannot get interface of \"XXMLSecurityContext\" from service \"xsec.XMLSecurityContext\"" ) ;
-
- xSecCtx->addSecurityEnvironment( xSecEnv ) ;
-
- //Generate XML signature
- Reference< XInterface > xmlsigner =
- xManager->createInstanceWithContext( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.xml.security.bridge.xmlsec.XMLSignature_MSCryptImpl")), xContext ) ;
- OSL_ENSURE( xmlsigner.is() ,
- "Signer - "
- "Cannot get service instance of \"xsec.XMLSignature\"" ) ;
-
- Reference< XXMLSignature > xSigner( xmlsigner , UNO_QUERY ) ;
- OSL_ENSURE( xSigner.is() ,
- "Signer - "
- "Cannot get interface of \"XXMLSignature\" from service \"xsec.XMLSignature\"" ) ;
-
- //perform signature
- xTemplate = xSigner->generate( xTemplate , xSecEnv ) ;
- OSL_ENSURE( xTemplate.is() ,
- "Signer - "
- "Cannot generate the xml signature" ) ;
-
- SecurityOperationStatus m_nStatus = xTemplate->getStatus();
-
- if (m_nStatus == SecurityOperationStatus_OPERATION_SUCCEEDED)
- {
- fprintf( stdout, "Operation succeeds.\n") ;
- }
- else
- {
- fprintf( stdout, "Operation fails.\n") ;
- }
- } catch( Exception& e ) {
- fprintf( stderr , "Error Message: %s\n" , OUStringToOString( e.Message , RTL_TEXTENCODING_ASCII_US ).getStr() ) ;
- goto done ;
- }
-
- dstFile = fopen( argv[2], "w" ) ;
- if( dstFile == NULL ) {
- fprintf( stderr , "### Can not open file %s\n", argv[2] ) ;
- goto done ;
- }
-
- //Save result
- xmlDocDump( dstFile, doc ) ;
-
-done:
- if( uri != NULL )
- delete uri ;
-
- if( dstFile != NULL )
- fclose( dstFile ) ;
-
- if( doc != NULL )
- xmlFreeDoc( doc ) ;
-
- if( n_hStoreHandle != NULL )
- CertCloseStore( n_hStoreHandle, CERT_CLOSE_STORE_FORCE_FLAG ) ;
-
- xmlSecMSCryptoAppShutdown() ;
-
- /* Shutdown libxslt/libxml */
- #ifndef XMLSEC_NO_XSLT
- xsltCleanupGlobals();
- #endif /* XMLSEC_NO_XSLT */
- xmlCleanupParser();
-
- }
-
- return 0;
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmlsecurity/tools/standalone/mscsfit/util/makefile.mk b/xmlsecurity/tools/standalone/mscsfit/util/makefile.mk
deleted file mode 100644
index 16236ab60..000000000
--- a/xmlsecurity/tools/standalone/mscsfit/util/makefile.mk
+++ /dev/null
@@ -1,174 +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=xmlsecurity-mscsfit-boot
-TARGETTYPE=GUI
-
-GEN_HID=TRUE
-APP2NOSAL=TRUE
-
-# --- Settings -----------------------------------------------------------
-USE_JAVAVER=TRUE
-
-.INCLUDE : settings.mk
-.INCLUDE : $(PRJ)$/util$/target.pmk
-
-VERINFONAME=verinfo
-
-.INCLUDE : target.mk
-
-# -------------------------------------------------------------------------
-# --- Targets -------------------------------------------------------------
-
-ALLTAR : $(BIN)$/boot_services.rdb
-
-REGISTERLIBS= \
- i18npool.uno$(DLLPOST) \
- $(DLLPRE)tk$(DLLPOSTFIX)$(DLLPOST) \
- $(DLLPRE)mcnttype$(DLLPOST)
-
-# $(DLLPRE)i18n$(DLLPOSTFIX)$(DLLPOST) \
-# $(DLLPRE)i18npool$(DLLPOSTFIX)$(DLLPOST) \
-# $(DLLPRE)tk$(DLLPOSTFIX)$(DLLPOST) \
-# $(DLLPRE)mcnttype$(DLLPOST)
-
-# Additional libraries
-DLLPRE_NO=
-REGISTERLIBS+= \
- $(DLLPRE_NO)dynamicloader.uno$(DLLPOST) \
- $(DLLPRE_NO)namingservice.uno$(DLLPOST) \
- $(DLLPRE_NO)bootstrap.uno$(DLLPOST) \
- $(DLLPRE)xsec_fw$(DLLPOST) \
- $(DLLPRE)xsec_xmlsec$(DLLPOST)
-
-.IF "$(GUI)" == "UNX"
-MY_DLLDIR=$(SOLARLIBDIR)
-REGISTERLIBS+= \
- $(DLLPRE)dtransX11$(DLLPOSTFIX)$(DLLPOST)
-
-.ELSE # "$(GUI)" == "UNX"
-.IF "$(GUI)"=="WNT"
-
-MY_DLLDIR=$(SOLARBINDIR)
-REGISTERLIBS+= \
- $(DLLPRE)sysdtrans$(DLLPOST) \
- $(DLLPRE)ftransl$(DLLPOST) \
- $(DLLPRE)dnd$(DLLPOST)
-
-.ELSE # "$(GUI)"=="WNT"
-
- @echo "**********************************************************"
- @echo "*** unknown platform: don't know which librarys to use ***"
- @echo "**********************************************************"
- force_dmake_to_error
-.ENDIF # "$(GUI)"=="WNT"
-.ENDIF # "$(GUI)" == "UNX"
-
-.IF "$(SOLAR_JAVA)" != ""
-.IF "$(JAVANUMVER)" >= "000100040000"
-# native libraries, which are only necessary, when java shall run within setup
-REGISTERLIBS_JAVA= \
- javavm.uno$(DLLPOST) \
- javaloader.uno$(DLLPOST)
-
-# add here java components, which shall run with setup
-REGISTERJARS=\
- java_uno_accessbridge.jar
-# xsec_jxsec.jar
-
-# jar-files, which regcomp needs so that it can use java
-REGCOMP_JARS=unoil.jar java_uno.jar ridl.jar jurt.jar juh.jar
-
-# CLASSPATH, which regcomp needs to be run
-# $(SOLARLIBDIR) needs to be included in case Java components are registered,
-# because java_uno.jar needs to find the native java_uno shared library:
-MY_CLASSPATH_TMP=$(foreach,i,$(REGCOMP_JARS) $(SOLARBINDIR)$/$i)$(PATH_SEPERATOR)$(SOLARLIBDIR)$(PATH_SEPERATOR)$(XCLASSPATH)
-REGCOMP_CLASSPATH=$(strip $(subst,!,$(PATH_SEPERATOR) $(MY_CLASSPATH_TMP:s/ /!/)))
-
-.IF "$(GUI)"!="WNT"
-DOLLAR_SIGN=\$$
-MY_JAVA_COMPPATH=file://$(SOLARBINDIR)
-.IF "$(OS)"=="MACOSX"
-REGCOMP_ENV=\
- setenv CLASSPATH $(REGCOMP_CLASSPATH) && \
- setenv DYLD_LIBRARY_PATH $(DYLD_LIBRARY_PATH):$(JDKLIB)
-.ELSE
-REGCOMP_ENV=\
- setenv CLASSPATH $(REGCOMP_CLASSPATH) && \
- setenv LD_LIBRARY_PATH $(LD_LIBRARY_PATH):$(JDKLIB)
-.ENDIF
-.ELSE # "$(GUI)" != "WNT"
-.IF "$(USE_SHELL)" != "4nt"
-DOLLAR_SIGN=\$$
-REGCOMP_ENV=\
- setenv CLASSPATH "$(strip $(subst,\,/ $(shell @guw.pl echo $(REGCOMP_CLASSPATH))))" && \
- setenv PATH "$(PATH):$(JREPATH)"
-MY_JAVA_COMPPATH=$(strip $(subst,\,/ file:///$(shell @guw.pl echo $(SOLARBINDIR))))
-.ELSE # "$(USE_SHELL)" != "4nt"
-DOLLAR_SIGN=$$
-REGCOMP_ENV=\
- set CLASSPATH=$(REGCOMP_CLASSPATH) && \
- set PATH=$(PATH);$(JREPATH)
-MY_JAVA_COMPPATH=$(strip $(subst,\,/ file:///$(SOLARBINDIR)))
-.ENDIF # "$(USE_SHELL)" != "4nt"
-.ENDIF # "$(GUI)"!="WNT"
-.ENDIF # "$(JAVANUMVER)" >= "000100040000"
-.ENDIF # "$(SOLAR_JAVA)" != ""
-
-$(BIN)$/boot_services.rdb: \
- makefile.mk \
- $(foreach,i,$(REGISTERLIBS) $(MY_DLLDIR)$/$(i)) \
- $(foreach,i,$(REGISTERLIBS_JAVA) $(MY_DLLDIR)$/$(i))
- -rm -f $@ $(BIN)$/regcomp.rdb $(BIN)$/boot_services.tmp
-# register the native libraries
- $(REGCOMP) -register -r $(BIN)$/boot_services.tmp -c "$(strip $(REGISTERLIBS))"
-.IF "$(SOLAR_JAVA)" != ""
-.IF "$(OS)"!="MACOSX"
-.IF "$(JAVANUMVER)" >= "000100040000"
- $(REGCOMP) -register -r $(BIN)$/boot_services.tmp -c "$(strip $(REGISTERLIBS_JAVA))"
-# prepare a registry which regcomp can work on (types+java services)
- $(REGCOMP) -register -r $(BIN)$/regcomp.rdb -c "$(strip $(REGISTERLIBS_JAVA))"
- $(REGMERGE) $(BIN)$/regcomp.rdb / $(SOLARBINDIR)/udkapi.rdb
-# now do the registration
- $(REGCOMP_ENV) && \
- $(REGCOMP) -br $(BIN)$/regcomp.rdb \
- -register \
- -r $(BIN)$/boot_services.tmp \
- -l com.sun.star.loader.Java2 \
- -env:UNO_JAVA_COMPPATH=$(MY_JAVA_COMPPATH) \
- $(foreach,i,$(REGISTERJARS) -c vnd.sun.star.expand:$(DOLLAR_SIGN)UNO_JAVA_COMPPATH/$(i))
-# $(foreach,i,$(REGISTERJARS) -c vnd.sun.star.expand:$(DOLLAR_SIGN)UNO_JAVA_COMPPATH/$(i)) -c $(MY_JAVA_COMPPATH)$/xsec_jxsec.jar
-
-.ENDIF # "$(JAVANUMVER)" >= "000100040000"
-.ENDIF # "$(OS)" != "MACOSX"
-.ENDIF # "$(SOLAR_JAVA)" != ""
-# to have a transaction, move it now to the final name
- $(REGMERGE) $(BIN)$/boot_services.tmp / $(SOLARBINDIR)/types.rdb
- mv $(BIN)$/boot_services.tmp $@
-
diff --git a/xmlsecurity/tools/standalone/mscsfit/verifier.cxx b/xmlsecurity/tools/standalone/mscsfit/verifier.cxx
deleted file mode 100644
index 6ba703da5..000000000
--- a/xmlsecurity/tools/standalone/mscsfit/verifier.cxx
+++ /dev/null
@@ -1,329 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/** -- C++ Source File -- **/
-
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_xmlsecurity.hxx"
-#include <stdio.h>
-#include "helper.hxx"
-
-#include "libxml/tree.h"
-#include "libxml/parser.h"
-#ifndef XMLSEC_NO_XSLT
-#include "libxslt/xslt.h"
-#endif
-
-#include "securityenvironment_mscryptimpl.hxx"
-#include "xmlelementwrapper_xmlsecimpl.hxx"
-
-#include "xmlsec/strings.h"
-#include "xmlsec/mscrypto/app.h"
-#include "xmlsec/xmltree.h"
-
-#include <rtl/ustring.hxx>
-#include <cppuhelper/servicefactory.hxx>
-
-#include <com/sun/star/lang/XComponent.hpp>
-#include <com/sun/star/beans/PropertyValue.hpp>
-#include <com/sun/star/xml/wrapper/XXMLElementWrapper.hpp>
-#include <com/sun/star/xml/wrapper/XXMLDocumentWrapper.hpp>
-#include <com/sun/star/xml/crypto/XXMLSignature.hpp>
-#include <com/sun/star/xml/crypto/XXMLSignatureTemplate.hpp>
-#include <com/sun/star/xml/crypto/XXMLSecurityContext.hpp>
-#include <com/sun/star/xml/crypto/XSecurityEnvironment.hpp>
-
-using namespace ::rtl ;
-using namespace ::cppu ;
-using namespace ::com::sun::star::uno ;
-using namespace ::com::sun::star::io ;
-using namespace ::com::sun::star::ucb ;
-using namespace ::com::sun::star::beans ;
-using namespace ::com::sun::star::document ;
-using namespace ::com::sun::star::lang ;
-using namespace ::com::sun::star::registry ;
-using namespace ::com::sun::star::xml::wrapper ;
-using namespace ::com::sun::star::xml::crypto ;
-
-
-int SAL_CALL main( int argc, char **argv )
-{
- const char* n_pCertStore ;
- HCERTSTORE n_hStoreHandle ;
-
- xmlDocPtr doc = NULL ;
- xmlNodePtr tplNode ;
- xmlNodePtr tarNode ;
- xmlAttrPtr idAttr ;
- xmlChar* idValue ;
- xmlAttrPtr uriAttr ;
- xmlChar* uriValue ;
- OUString* uri = NULL ;
- Reference< XUriBinding > xUriBinding ;
-
- if( argc !=3 && argc != 4 ) {
- fprintf( stderr, "Usage: %s <file_url> <rdb file>\n" , argv[0] ) ;
- fprintf( stderr, "Or: \t%s <file_url> <rdb file> < Cert Store Name >\n\n" , argv[0] ) ;
- return 1 ;
- }
-
- for( int hhh = 0 ; hhh < 1 ; hhh ++ ) {
-
- //Init libxml and libxslt libraries
- xmlInitParser();
- LIBXML_TEST_VERSION
- xmlLoadExtDtdDefaultValue = XML_DETECT_IDS | XML_COMPLETE_ATTRS;
- xmlSubstituteEntitiesDefault(1);
-
- #ifndef XMLSEC_NO_XSLT
- xmlIndentTreeOutput = 1;
- #endif // XMLSEC_NO_XSLT
-
- //Initialize the crypto engine
- if( argc == 4 ) {
- n_pCertStore = argv[3] ;
- n_hStoreHandle = CertOpenSystemStore( NULL, n_pCertStore ) ;
- if( n_hStoreHandle == NULL ) {
- fprintf( stderr, "Can not open the system cert store %s\n", n_pCertStore ) ;
- return 1 ;
- }
- } else {
- n_pCertStore = NULL ;
- n_hStoreHandle = NULL ;
- }
- xmlSecMSCryptoAppInit( n_pCertStore ) ;
-
- //Load XML document
- doc = xmlParseFile( argv[1] ) ;
- if( doc == NULL || xmlDocGetRootElement( doc ) == NULL ) {
- fprintf( stderr , "### Cannot load template xml document!\n" ) ;
- goto done ;
- }
-
- //Find the signature template
- tplNode = xmlSecFindNode( xmlDocGetRootElement( doc ), xmlSecNodeSignature, xmlSecDSigNs ) ;
- if( tplNode == NULL ) {
- fprintf( stderr , "### Cannot find the signature template!\n" ) ;
- goto done ;
- }
-
- //Find the element with ID attribute
- tarNode = xmlSecFindNode( xmlDocGetRootElement( doc ), ( xmlChar* )"document", ( xmlChar* )"http://openoffice.org/2000/office" ) ;
- if( tarNode == NULL ) {
- tarNode = xmlSecFindNode( xmlDocGetRootElement( doc ), ( xmlChar* )"document", NULL ) ;
- }
-
- //Find the "id" attrbute in the element
- if( tarNode != NULL ) {
- if( ( idAttr = xmlHasProp( tarNode, ( xmlChar* )"id" ) ) != NULL ) {
- //NULL
- } else if( ( idAttr = xmlHasProp( tarNode, ( xmlChar* )"Id" ) ) != NULL ) {
- //NULL
- } else {
- idAttr = NULL ;
- }
- }
-
- //Add ID to DOM
- if( idAttr != NULL ) {
- idValue = xmlNodeListGetString( tarNode->doc, idAttr->children, 1 ) ;
- if( idValue == NULL ) {
- fprintf( stderr , "### the ID value is NULL!\n" ) ;
- goto done ;
- }
-
- if( xmlAddID( NULL, doc, idValue, idAttr ) == NULL ) {
- fprintf( stderr , "### Can not add the ID value!\n" ) ;
- goto done ;
- }
- }
-
- //Reference handler
- //Find the signature reference
- tarNode = xmlSecFindNode( tplNode, xmlSecNodeReference, xmlSecDSigNs ) ;
- if( tarNode == NULL ) {
- fprintf( stderr , "### Cannot find the signature reference!\n" ) ;
- goto done ;
- }
-
- //Find the "URI" attrbute in the reference
- uriAttr = xmlHasProp( tarNode, ( xmlChar* )"URI" ) ;
- if( tarNode == NULL ) {
- fprintf( stderr , "### Cannot find URI of the reference!\n" ) ;
- goto done ;
- }
-
- //Get the "URI" attrbute value
- uriValue = xmlNodeListGetString( tarNode->doc, uriAttr->children, 1 ) ;
- if( uriValue == NULL ) {
- fprintf( stderr , "### the URI value is NULL!\n" ) ;
- goto done ;
- }
-
- if( strchr( ( const char* )uriValue, '/' ) != NULL && strchr( ( const char* )uriValue, '#' ) == NULL ) {
- fprintf( stdout , "### Find a stream URI [%s]\n", uriValue ) ;
- // uri = new ::rtl::OUString( ( const sal_Unicode* )uriValue ) ;
- uri = new ::rtl::OUString( ( const sal_Char* )uriValue, xmlStrlen( uriValue ), RTL_TEXTENCODING_ASCII_US ) ;
- }
-
- if( uri != NULL ) {
- fprintf( stdout , "### Find the URI [%s]\n", OUStringToOString( *uri , RTL_TEXTENCODING_ASCII_US ).getStr() ) ;
- Reference< XInputStream > xStream = createStreamFromFile( *uri ) ;
- if( !xStream.is() ) {
- fprintf( stderr , "### Can not get the URI stream!\n" ) ;
- goto done ;
- }
-
- xUriBinding = new OUriBinding( *uri, xStream ) ;
- }
-
-
- try {
- Reference< XMultiComponentFactory > xManager = NULL ;
- Reference< XComponentContext > xContext = NULL ;
-
- xManager = serviceManager( xContext , OUString(RTL_CONSTASCII_USTRINGPARAM("local")), OUString::createFromAscii( argv[2] ) ) ;
-
- //Create signature template
- Reference< XInterface > element =
- xManager->createInstanceWithContext( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.xml.security.bridge.xmlsec.XMLElementWrapper_XmlSecImpl")) , xContext ) ;
- OSL_ENSURE( element.is() ,
- "Verifier - "
- "Cannot get service instance of \"xsec.XMLElementWrapper\"" ) ;
-
- Reference< XXMLElementWrapper > xElement( element , UNO_QUERY ) ;
- OSL_ENSURE( xElement.is() ,
- "Verifier - "
- "Cannot get interface of \"XXMLElementWrapper\" from service \"xsec.XMLElementWrapper\"" ) ;
-
- Reference< XUnoTunnel > xEleTunnel( xElement , UNO_QUERY ) ;
- OSL_ENSURE( xEleTunnel.is() ,
- "Verifier - "
- "Cannot get interface of \"XUnoTunnel\" from service \"xsec.XMLElement\"" ) ;
-
- XMLElementWrapper_XmlSecImpl* pElement = ( XMLElementWrapper_XmlSecImpl* )xEleTunnel->getSomething( XMLElementWrapper_XmlSecImpl::getUnoTunnelImplementationId() ) ;
- OSL_ENSURE( pElement != NULL ,
- "Verifier - "
- "Cannot get implementation of \"xsec.XMLElementWrapper\"" ) ;
-
- //Set signature template
- pElement->setNativeElement( tplNode ) ;
-
- //Build XML Signature template
- Reference< XInterface > signtpl =
- xManager->createInstanceWithContext( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.xml.crypto.XMLSignatureTemplate")), xContext ) ;
- OSL_ENSURE( signtpl.is() ,
- "Verifier - "
- "Cannot get service instance of \"xsec.XMLSignatureTemplate\"" ) ;
-
- Reference< XXMLSignatureTemplate > xTemplate( signtpl , UNO_QUERY ) ;
- OSL_ENSURE( xTemplate.is() ,
- "Verifier - "
- "Cannot get interface of \"XXMLSignatureTemplate\" from service \"xsec.XMLSignatureTemplate\"" ) ;
-
- //Import the signature template
- xTemplate->setTemplate( xElement ) ;
-
- //Import the URI/Stream binding
- if( xUriBinding.is() )
- xTemplate->setBinding( xUriBinding ) ;
-
- //Create security environment
- //Build Security Environment
- Reference< XInterface > xsecenv =
- xManager->createInstanceWithContext( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.xml.security.bridge.xmlsec.SecurityEnvironment_MSCryptImpl")), xContext ) ;
- OSL_ENSURE( xsecenv.is() ,
- "Verifier - "
- "Cannot get service instance of \"xsec.SecurityEnvironment\"" ) ;
-
- Reference< XSecurityEnvironment > xSecEnv( xsecenv , UNO_QUERY ) ;
- OSL_ENSURE( xSecEnv.is() ,
- "Verifier - "
- "Cannot get interface of \"XSecurityEnvironment\" from service \"xsec.SecurityEnvironment\"" ) ;
-
- //Setup key slot and certDb
- Reference< XUnoTunnel > xEnvTunnel( xsecenv , UNO_QUERY ) ;
- OSL_ENSURE( xElement.is() ,
- "Verifier - "
- "Cannot get interface of \"XUnoTunnel\" from service \"xsec.SecurityEnvironment\"" ) ;
-
- SecurityEnvironment_MSCryptImpl* pSecEnv = ( SecurityEnvironment_MSCryptImpl* )xEnvTunnel->getSomething( SecurityEnvironment_MSCryptImpl::getUnoTunnelId() ) ;
- OSL_ENSURE( pSecEnv != NULL ,
- "Verifier - "
- "Cannot get implementation of \"xsec.SecurityEnvironment\"" ) ;
-
- //Setup key slot and certDb
- if( n_hStoreHandle != NULL ) {
- pSecEnv->setCryptoSlot( n_hStoreHandle ) ;
- pSecEnv->setCertDb( n_hStoreHandle ) ;
- } else {
- pSecEnv->enableDefaultCrypt( sal_True ) ;
- }
-
- //Build XML Security Context
- Reference< XInterface > xmlsecctx =
- xManager->createInstanceWithContext( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.xml.security.bridge.xmlsec.XMLSecurityContext_MSCryptImpl")), xContext ) ;
- OSL_ENSURE( xsecenv.is() ,
- "Verifier - "
- "Cannot get service instance of \"xsec.XMLSecurityContext\"" ) ;
-
- Reference< XXMLSecurityContext > xSecCtx( xmlsecctx , UNO_QUERY ) ;
- OSL_ENSURE( xSecCtx.is() ,
- "Verifier - "
- "Cannot get interface of \"XXMLSecurityContext\" from service \"xsec.XMLSecurityContext\"" ) ;
-
- xSecCtx->addSecurityEnvironment( xSecEnv ) ;
-
- //Generate XML signature
- Reference< XInterface > xmlsigner =
- xManager->createInstanceWithContext( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.xml.security.bridge.xmlsec.XMLSignature_MSCryptImpl")), xContext ) ;
- OSL_ENSURE( xmlsigner.is() ,
- "Verifier - "
- "Cannot get service instance of \"xsec.XMLSignature\"" ) ;
-
- Reference< XXMLSignature > xSigner( xmlsigner , UNO_QUERY ) ;
- OSL_ENSURE( xSigner.is() ,
- "Verifier - "
- "Cannot get interface of \"XXMLSignature\" from service \"xsec.XMLSignature\"" ) ;
-
-
- //perform validation
- xTemplate = xSigner->validate( xTemplate , xSecCtx ) ;
-
- com::sun::star::xml::crypto::SecurityOperationStatus m_nStatus = xTemplate->getStatus();
-
- if (m_nStatus == SecurityOperationStatus_OPERATION_SUCCEEDED)
- {
- fprintf( stdout, "Operation succeeds.\n") ;
- }
- else
- {
- fprintf( stdout, "Operation fails.\n") ;
- }
- } catch( Exception& e ) {
- fprintf( stderr , "Error Message: %s\n" , OUStringToOString( e.Message , RTL_TEXTENCODING_ASCII_US ).getStr() ) ;
- goto done ;
- }
-
-done :
- if( uri != NULL )
- delete uri ;
-
- if( doc != NULL )
- xmlFreeDoc( doc ) ;
-
- if( n_hStoreHandle != NULL )
- CertCloseStore( n_hStoreHandle, CERT_CLOSE_STORE_FORCE_FLAG ) ;
-
- xmlSecMSCryptoAppShutdown() ;
-
- /* Shutdown libxslt/libxml */
- #ifndef XMLSEC_NO_XSLT
- xsltCleanupGlobals();
- #endif /* XMLSEC_NO_XSLT */
- xmlCleanupParser();
-
- }
-
- return 0 ;
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmlsecurity/tools/standalone/readme.txt b/xmlsecurity/tools/standalone/readme.txt
deleted file mode 100644
index 8ea7fa2ff..000000000
--- a/xmlsecurity/tools/standalone/readme.txt
+++ /dev/null
@@ -1,19 +0,0 @@
-How to use the standalone program
-
-After building, there is two programs named jsfit.dsig.signer and jsfit.dsig.verifier under the class folder, these two program are used to test the jsr based bridge component.
-
-After installation, you need do following step to launch the program.
-
-1) create a temporary folder
-
-2) copy services.rdb, types.rdb and setup_services.rdb from the <OpenOffice>/program folder to the temporary folder,
-
-3) in the temporary folder, merge both the types.rdb and the setup_services.rdb into the services.rdb.
-
-4) register jsr-based component into services.rdb
-
-5) run the signer program
-
-6) run the verifier program
-
-7) remove the temporary folder