From 9f34fde7a8750b856570b5e855d2ecb226bf0c23 Mon Sep 17 00:00:00 2001 From: Malte Timmermann Date: Mon, 12 Jul 2004 12:15:31 +0000 Subject: libxmlsec --- xmlsecurity/inc/xmlsecurity/certificatechooser.hxx | 126 ++ xmlsecurity/inc/xmlsecurity/certificateviewer.hxx | 185 +++ .../inc/xmlsecurity/digitalsignaturesdialog.hxx | 152 ++ xmlsecurity/inc/xmlsecurity/sigstruct.hxx | 120 ++ xmlsecurity/inc/xmlsecurity/stbcontrl.hxx | 91 ++ xmlsecurity/inc/xmlsecurity/xmlsignaturehelper.hxx | 214 +++ xmlsecurity/prj/build.lst | 10 + xmlsecurity/prj/d.lst | 4 + .../source/component/documentdigitalsignatures.cxx | 123 ++ .../source/component/documentdigitalsignatures.hxx | 94 ++ xmlsecurity/source/component/makefile.mk | 86 ++ xmlsecurity/source/component/registerservices.cxx | 135 ++ xmlsecurity/source/dialogs/certificatechooser.cxx | 216 +++ xmlsecurity/source/dialogs/certificatechooser.src | 125 ++ xmlsecurity/source/dialogs/certificateviewer.cxx | 397 ++++++ xmlsecurity/source/dialogs/certificateviewer.src | 334 +++++ xmlsecurity/source/dialogs/dialogs.hrc | 263 ++++ .../source/dialogs/digitalsignaturesdialog.cxx | 545 +++++++ .../source/dialogs/digitalsignaturesdialog.src | 159 +++ xmlsecurity/source/dialogs/makefile.mk | 100 ++ xmlsecurity/source/dialogs/resourcemanager.cxx | 190 +++ xmlsecurity/source/dialogs/resourcemanager.hxx | 96 ++ xmlsecurity/source/dialogs/stbcontrl.cxx | 232 +++ xmlsecurity/source/framework/buffernode.cxx | 1313 +++++++++++++++++ xmlsecurity/source/framework/buffernode.hxx | 175 +++ xmlsecurity/source/framework/decryptorimpl.cxx | 288 ++++ xmlsecurity/source/framework/decryptorimpl.hxx | 176 +++ xmlsecurity/source/framework/elementcollector.cxx | 330 +++++ xmlsecurity/source/framework/elementcollector.hxx | 147 ++ xmlsecurity/source/framework/elementmark.cxx | 136 ++ xmlsecurity/source/framework/elementmark.hxx | 123 ++ xmlsecurity/source/framework/encryptionengine.cxx | 254 ++++ xmlsecurity/source/framework/encryptionengine.hxx | 157 ++ xmlsecurity/source/framework/encryptorimpl.cxx | 328 +++++ xmlsecurity/source/framework/encryptorimpl.hxx | 190 +++ xmlsecurity/source/framework/makefile.mk | 98 ++ .../source/framework/saxeventkeeperimpl.cxx | 1503 ++++++++++++++++++++ .../source/framework/saxeventkeeperimpl.hxx | 423 ++++++ xmlsecurity/source/framework/securityengine.cxx | 122 ++ xmlsecurity/source/framework/securityengine.hxx | 225 +++ .../source/framework/signaturecreatorimpl.cxx | 343 +++++ .../source/framework/signaturecreatorimpl.hxx | 189 +++ xmlsecurity/source/framework/signatureengine.cxx | 306 ++++ xmlsecurity/source/framework/signatureengine.hxx | 199 +++ .../source/framework/signatureverifierimpl.cxx | 288 ++++ .../source/framework/signatureverifierimpl.hxx | 175 +++ .../source/framework/xmlencryptiontemplateimpl.cxx | 164 +++ .../source/framework/xmlencryptiontemplateimpl.hxx | 168 +++ .../source/framework/xmlsignaturetemplateimpl.cxx | 193 +++ .../source/framework/xmlsignaturetemplateimpl.hxx | 177 +++ xmlsecurity/source/framework/xsec_framework.cxx | 284 ++++ xmlsecurity/source/helper/makefile.mk | 90 ++ xmlsecurity/source/helper/xmlsignaturehelper.cxx | 424 ++++++ xmlsecurity/source/helper/xmlsignaturehelper2.cxx | 242 ++++ xmlsecurity/source/helper/xmlsignaturehelper2.hxx | 164 +++ xmlsecurity/source/helper/xsecctl.cxx | 1359 ++++++++++++++++++ xmlsecurity/source/helper/xsecctl.hxx | 580 ++++++++ xmlsecurity/source/helper/xsecparser.cxx | 353 +++++ xmlsecurity/source/helper/xsecparser.hxx | 199 +++ xmlsecurity/source/helper/xsecsign.cxx | 394 +++++ xmlsecurity/source/helper/xsecverify.cxx | 349 +++++ .../xmlsec/certificateextension_xmlsecimpl.cxx | 134 ++ .../xmlsec/certificateextension_xmlsecimpl.hxx | 119 ++ xmlsecurity/source/xmlsec/makefile.mk | 94 ++ xmlsecurity/source/xmlsec/mscrypt/makefile.mk | 102 ++ .../mscrypt/securityenvironment_mscryptimpl.cxx | 1028 +++++++++++++ .../mscrypt/securityenvironment_mscryptimpl.hxx | 235 +++ .../xmlsec/mscrypt/seinitializer_mscryptimpl.cxx | 269 ++++ .../xmlsec/mscrypt/seinitializer_mscryptimpl.hxx | 152 ++ .../xmlsec/mscrypt/x509certificate_mscryptimpl.cxx | 392 +++++ .../xmlsec/mscrypt/x509certificate_mscryptimpl.hxx | 147 ++ .../xmlsec/mscrypt/xmlencryption_mscryptimpl.cxx | 403 ++++++ .../xmlsec/mscrypt/xmlencryption_mscryptimpl.hxx | 165 +++ .../mscrypt/xmlsecuritycontext_mscryptimpl.cxx | 331 +++++ .../mscrypt/xmlsecuritycontext_mscryptimpl.hxx | 174 +++ .../xmlsec/mscrypt/xmlsignature_mscryptimpl.cxx | 336 +++++ .../xmlsec/mscrypt/xmlsignature_mscryptimpl.hxx | 165 +++ xmlsecurity/source/xmlsec/mscrypt/xsec_mscrypt.cxx | 198 +++ xmlsecurity/source/xmlsec/nss/makefile.mk | 158 ++ .../xmlsec/nss/securityenvironment_nssimpl.cxx | 832 +++++++++++ .../xmlsec/nss/securityenvironment_nssimpl.hxx | 210 +++ .../source/xmlsec/nss/seinitializer_nssimpl.cxx | 390 +++++ .../source/xmlsec/nss/seinitializer_nssimpl.hxx | 152 ++ .../source/xmlsec/nss/x509certificate_nssimpl.cxx | 360 +++++ .../source/xmlsec/nss/x509certificate_nssimpl.hxx | 146 ++ .../source/xmlsec/nss/xmlencryption_nssimpl.cxx | 429 ++++++ .../source/xmlsec/nss/xmlencryption_nssimpl.hxx | 165 +++ .../xmlsec/nss/xmlsecuritycontext_nssimpl.cxx | 290 ++++ .../xmlsec/nss/xmlsecuritycontext_nssimpl.hxx | 174 +++ .../source/xmlsec/nss/xmlsignature_nssimpl.cxx | 336 +++++ .../source/xmlsec/nss/xmlsignature_nssimpl.hxx | 165 +++ xmlsecurity/source/xmlsec/nss/xsec_nss.cxx | 199 +++ xmlsecurity/source/xmlsec/saxhelper.cxx | 465 ++++++ xmlsecurity/source/xmlsec/saxhelper.hxx | 123 ++ .../xmlsec/xmldocumentwrapper_xmlsecimpl.cxx | 1187 ++++++++++++++++ .../xmlsec/xmldocumentwrapper_xmlsecimpl.hxx | 328 +++++ .../source/xmlsec/xmlelementwrapper_xmlsecimpl.cxx | 221 +++ .../source/xmlsec/xmlelementwrapper_xmlsecimpl.hxx | 152 ++ xmlsecurity/source/xmlsec/xmlstreamio.cxx | 244 ++++ xmlsecurity/source/xmlsec/xmlstreamio.hxx | 83 ++ xmlsecurity/source/xmlsec/xsec_xmlsec.cxx | 201 +++ xmlsecurity/tools/demo/makefile.mk | 151 ++ xmlsecurity/tools/demo/multisigdemo.cxx | 353 +++++ xmlsecurity/tools/demo/signdemo.cxx | 223 +++ xmlsecurity/tools/demo/util.cxx | 215 +++ xmlsecurity/tools/demo/util.hxx | 87 ++ xmlsecurity/tools/demo/verifydemo.cxx | 180 +++ xmlsecurity/tools/examples/demo-sample.gif | Bin 0 -> 94 bytes xmlsecurity/tools/examples/demo-sample.sxw | Bin 0 -> 19891 bytes xmlsecurity/tools/examples/demo-sample.xml | 3 + xmlsecurity/tools/examples/enc-1.xml | 31 + xmlsecurity/tools/examples/enc-2.xml | 58 + xmlsecurity/tools/examples/eval_export.txt | 7 + xmlsecurity/tools/examples/eval_import.txt | 14 + xmlsecurity/tools/examples/evaluate_win.bat | 142 ++ xmlsecurity/tools/examples/s-in-e-1.xml | 53 + xmlsecurity/tools/examples/s-in-e-2.xml | 53 + xmlsecurity/tools/examples/sign-0.xml | 27 + xmlsecurity/tools/examples/sign-1.xml | 29 + xmlsecurity/tools/examples/sign-2.xml | 33 + xmlsecurity/tools/examples/sign-3.xml | 41 + xmlsecurity/tools/examples/sign-4.xml | 57 + xmlsecurity/tools/examples/sign-5.xml | 89 ++ xmlsecurity/tools/examples/uno_win.bat | 24 + xmlsecurity/tools/examples/warmup.xml | 27 + xmlsecurity/tools/standalone/csfit/certmngr.cxx | 201 +++ xmlsecurity/tools/standalone/csfit/decrypter.cxx | 303 ++++ xmlsecurity/tools/standalone/csfit/encrypter.cxx | 340 +++++ xmlsecurity/tools/standalone/csfit/helper.cxx | 297 ++++ xmlsecurity/tools/standalone/csfit/helper.hxx | 275 ++++ xmlsecurity/tools/standalone/csfit/makefile.mk | 187 +++ xmlsecurity/tools/standalone/csfit/signer.cxx | 388 +++++ .../tools/standalone/csfit/util/makefile.mk | 216 +++ xmlsecurity/tools/standalone/csfit/verifier.cxx | 371 +++++ xmlsecurity/tools/standalone/mscsfit/certmngr.cxx | 140 ++ xmlsecurity/tools/standalone/mscsfit/decrypter.cxx | 243 ++++ xmlsecurity/tools/standalone/mscsfit/encrypter.cxx | 294 ++++ xmlsecurity/tools/standalone/mscsfit/helper.cxx | 217 +++ xmlsecurity/tools/standalone/mscsfit/helper.hxx | 204 +++ xmlsecurity/tools/standalone/mscsfit/makefile.mk | 184 +++ xmlsecurity/tools/standalone/mscsfit/signer.cxx | 328 +++++ .../tools/standalone/mscsfit/util/makefile.mk | 216 +++ xmlsecurity/tools/standalone/mscsfit/verifier.cxx | 319 +++++ xmlsecurity/tools/uno/AdapterNode.java | 199 +++ xmlsecurity/tools/uno/AttributeListHelper.java | 182 +++ xmlsecurity/tools/uno/DomToTreeModelAdapter.java | 200 +++ xmlsecurity/tools/uno/EncryptionEntity.java | 252 ++++ xmlsecurity/tools/uno/ParsingThread.java | 282 ++++ xmlsecurity/tools/uno/SAXEventCollector.java | 229 +++ xmlsecurity/tools/uno/SAXEventPrinter.java | 354 +++++ xmlsecurity/tools/uno/SecurityEntity.java | 236 +++ xmlsecurity/tools/uno/SignatureEntity.java | 322 +++++ xmlsecurity/tools/uno/TestTool.java | 1426 +++++++++++++++++++ .../tools/uno/UnsolvedReferenceTableModel.java | 123 ++ xmlsecurity/tools/uno/XMLFileFilter.java | 113 ++ .../tools/uno/XMLSecurityFrameworkController.java | 1119 +++++++++++++++ xmlsecurity/tools/uno/XMLTreeCellRanderer.java | 119 ++ xmlsecurity/tools/uno/current.gif | Bin 0 -> 94 bytes xmlsecurity/tools/uno/makefile.mk | 83 ++ xmlsecurity/util/exports_xsmscrypt.dxp | 8 + xmlsecurity/util/exports_xsnss.dxp | 8 + xmlsecurity/util/makefile.mk | 194 +++ xmlsecurity/util/target.pmk | 68 + xmlsecurity/util/xmlsecurity.map | 8 + xmlsecurity/util/xsec_fw.dxp | 3 + xmlsecurity/util/xsecctl.flt | 19 + xmlsecurity/workben/makefile.mk | 116 ++ xmlsecurity/workben/signaturetest.cxx | 543 +++++++ 168 files changed, 40905 insertions(+) create mode 100644 xmlsecurity/inc/xmlsecurity/certificatechooser.hxx create mode 100644 xmlsecurity/inc/xmlsecurity/certificateviewer.hxx create mode 100644 xmlsecurity/inc/xmlsecurity/digitalsignaturesdialog.hxx create mode 100644 xmlsecurity/inc/xmlsecurity/sigstruct.hxx create mode 100644 xmlsecurity/inc/xmlsecurity/stbcontrl.hxx create mode 100644 xmlsecurity/inc/xmlsecurity/xmlsignaturehelper.hxx create mode 100644 xmlsecurity/prj/build.lst create mode 100644 xmlsecurity/prj/d.lst create mode 100644 xmlsecurity/source/component/documentdigitalsignatures.cxx create mode 100644 xmlsecurity/source/component/documentdigitalsignatures.hxx create mode 100644 xmlsecurity/source/component/makefile.mk create mode 100644 xmlsecurity/source/component/registerservices.cxx create mode 100644 xmlsecurity/source/dialogs/certificatechooser.cxx create mode 100644 xmlsecurity/source/dialogs/certificatechooser.src create mode 100644 xmlsecurity/source/dialogs/certificateviewer.cxx create mode 100644 xmlsecurity/source/dialogs/certificateviewer.src create mode 100644 xmlsecurity/source/dialogs/dialogs.hrc create mode 100644 xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx create mode 100644 xmlsecurity/source/dialogs/digitalsignaturesdialog.src create mode 100644 xmlsecurity/source/dialogs/makefile.mk create mode 100644 xmlsecurity/source/dialogs/resourcemanager.cxx create mode 100644 xmlsecurity/source/dialogs/resourcemanager.hxx create mode 100644 xmlsecurity/source/dialogs/stbcontrl.cxx create mode 100644 xmlsecurity/source/framework/buffernode.cxx create mode 100644 xmlsecurity/source/framework/buffernode.hxx create mode 100644 xmlsecurity/source/framework/decryptorimpl.cxx create mode 100644 xmlsecurity/source/framework/decryptorimpl.hxx create mode 100644 xmlsecurity/source/framework/elementcollector.cxx create mode 100644 xmlsecurity/source/framework/elementcollector.hxx create mode 100644 xmlsecurity/source/framework/elementmark.cxx create mode 100644 xmlsecurity/source/framework/elementmark.hxx create mode 100644 xmlsecurity/source/framework/encryptionengine.cxx create mode 100644 xmlsecurity/source/framework/encryptionengine.hxx create mode 100644 xmlsecurity/source/framework/encryptorimpl.cxx create mode 100644 xmlsecurity/source/framework/encryptorimpl.hxx create mode 100644 xmlsecurity/source/framework/makefile.mk create mode 100644 xmlsecurity/source/framework/saxeventkeeperimpl.cxx create mode 100644 xmlsecurity/source/framework/saxeventkeeperimpl.hxx create mode 100644 xmlsecurity/source/framework/securityengine.cxx create mode 100644 xmlsecurity/source/framework/securityengine.hxx create mode 100644 xmlsecurity/source/framework/signaturecreatorimpl.cxx create mode 100644 xmlsecurity/source/framework/signaturecreatorimpl.hxx create mode 100644 xmlsecurity/source/framework/signatureengine.cxx create mode 100644 xmlsecurity/source/framework/signatureengine.hxx create mode 100644 xmlsecurity/source/framework/signatureverifierimpl.cxx create mode 100644 xmlsecurity/source/framework/signatureverifierimpl.hxx create mode 100644 xmlsecurity/source/framework/xmlencryptiontemplateimpl.cxx create mode 100644 xmlsecurity/source/framework/xmlencryptiontemplateimpl.hxx create mode 100644 xmlsecurity/source/framework/xmlsignaturetemplateimpl.cxx create mode 100644 xmlsecurity/source/framework/xmlsignaturetemplateimpl.hxx create mode 100644 xmlsecurity/source/framework/xsec_framework.cxx create mode 100644 xmlsecurity/source/helper/makefile.mk create mode 100644 xmlsecurity/source/helper/xmlsignaturehelper.cxx create mode 100644 xmlsecurity/source/helper/xmlsignaturehelper2.cxx create mode 100644 xmlsecurity/source/helper/xmlsignaturehelper2.hxx create mode 100644 xmlsecurity/source/helper/xsecctl.cxx create mode 100644 xmlsecurity/source/helper/xsecctl.hxx create mode 100644 xmlsecurity/source/helper/xsecparser.cxx create mode 100644 xmlsecurity/source/helper/xsecparser.hxx create mode 100644 xmlsecurity/source/helper/xsecsign.cxx create mode 100644 xmlsecurity/source/helper/xsecverify.cxx create mode 100644 xmlsecurity/source/xmlsec/certificateextension_xmlsecimpl.cxx create mode 100644 xmlsecurity/source/xmlsec/certificateextension_xmlsecimpl.hxx create mode 100644 xmlsecurity/source/xmlsec/makefile.mk create mode 100644 xmlsecurity/source/xmlsec/mscrypt/makefile.mk create mode 100644 xmlsecurity/source/xmlsec/mscrypt/securityenvironment_mscryptimpl.cxx create mode 100644 xmlsecurity/source/xmlsec/mscrypt/securityenvironment_mscryptimpl.hxx create mode 100644 xmlsecurity/source/xmlsec/mscrypt/seinitializer_mscryptimpl.cxx create mode 100644 xmlsecurity/source/xmlsec/mscrypt/seinitializer_mscryptimpl.hxx create mode 100644 xmlsecurity/source/xmlsec/mscrypt/x509certificate_mscryptimpl.cxx create mode 100644 xmlsecurity/source/xmlsec/mscrypt/x509certificate_mscryptimpl.hxx create mode 100644 xmlsecurity/source/xmlsec/mscrypt/xmlencryption_mscryptimpl.cxx create mode 100644 xmlsecurity/source/xmlsec/mscrypt/xmlencryption_mscryptimpl.hxx create mode 100644 xmlsecurity/source/xmlsec/mscrypt/xmlsecuritycontext_mscryptimpl.cxx create mode 100644 xmlsecurity/source/xmlsec/mscrypt/xmlsecuritycontext_mscryptimpl.hxx create mode 100644 xmlsecurity/source/xmlsec/mscrypt/xmlsignature_mscryptimpl.cxx create mode 100644 xmlsecurity/source/xmlsec/mscrypt/xmlsignature_mscryptimpl.hxx create mode 100644 xmlsecurity/source/xmlsec/mscrypt/xsec_mscrypt.cxx create mode 100644 xmlsecurity/source/xmlsec/nss/makefile.mk create mode 100644 xmlsecurity/source/xmlsec/nss/securityenvironment_nssimpl.cxx create mode 100644 xmlsecurity/source/xmlsec/nss/securityenvironment_nssimpl.hxx create mode 100644 xmlsecurity/source/xmlsec/nss/seinitializer_nssimpl.cxx create mode 100644 xmlsecurity/source/xmlsec/nss/seinitializer_nssimpl.hxx create mode 100644 xmlsecurity/source/xmlsec/nss/x509certificate_nssimpl.cxx create mode 100644 xmlsecurity/source/xmlsec/nss/x509certificate_nssimpl.hxx create mode 100644 xmlsecurity/source/xmlsec/nss/xmlencryption_nssimpl.cxx create mode 100644 xmlsecurity/source/xmlsec/nss/xmlencryption_nssimpl.hxx create mode 100644 xmlsecurity/source/xmlsec/nss/xmlsecuritycontext_nssimpl.cxx create mode 100644 xmlsecurity/source/xmlsec/nss/xmlsecuritycontext_nssimpl.hxx create mode 100644 xmlsecurity/source/xmlsec/nss/xmlsignature_nssimpl.cxx create mode 100644 xmlsecurity/source/xmlsec/nss/xmlsignature_nssimpl.hxx create mode 100644 xmlsecurity/source/xmlsec/nss/xsec_nss.cxx create mode 100644 xmlsecurity/source/xmlsec/saxhelper.cxx create mode 100644 xmlsecurity/source/xmlsec/saxhelper.hxx create mode 100644 xmlsecurity/source/xmlsec/xmldocumentwrapper_xmlsecimpl.cxx create mode 100644 xmlsecurity/source/xmlsec/xmldocumentwrapper_xmlsecimpl.hxx create mode 100644 xmlsecurity/source/xmlsec/xmlelementwrapper_xmlsecimpl.cxx create mode 100644 xmlsecurity/source/xmlsec/xmlelementwrapper_xmlsecimpl.hxx create mode 100644 xmlsecurity/source/xmlsec/xmlstreamio.cxx create mode 100644 xmlsecurity/source/xmlsec/xmlstreamio.hxx create mode 100644 xmlsecurity/source/xmlsec/xsec_xmlsec.cxx create mode 100644 xmlsecurity/tools/demo/makefile.mk create mode 100644 xmlsecurity/tools/demo/multisigdemo.cxx create mode 100644 xmlsecurity/tools/demo/signdemo.cxx create mode 100644 xmlsecurity/tools/demo/util.cxx create mode 100644 xmlsecurity/tools/demo/util.hxx create mode 100644 xmlsecurity/tools/demo/verifydemo.cxx create mode 100644 xmlsecurity/tools/examples/demo-sample.gif create mode 100644 xmlsecurity/tools/examples/demo-sample.sxw create mode 100644 xmlsecurity/tools/examples/demo-sample.xml create mode 100644 xmlsecurity/tools/examples/enc-1.xml create mode 100644 xmlsecurity/tools/examples/enc-2.xml create mode 100644 xmlsecurity/tools/examples/eval_export.txt create mode 100644 xmlsecurity/tools/examples/eval_import.txt create mode 100644 xmlsecurity/tools/examples/evaluate_win.bat create mode 100644 xmlsecurity/tools/examples/s-in-e-1.xml create mode 100644 xmlsecurity/tools/examples/s-in-e-2.xml create mode 100644 xmlsecurity/tools/examples/sign-0.xml create mode 100644 xmlsecurity/tools/examples/sign-1.xml create mode 100644 xmlsecurity/tools/examples/sign-2.xml create mode 100644 xmlsecurity/tools/examples/sign-3.xml create mode 100644 xmlsecurity/tools/examples/sign-4.xml create mode 100644 xmlsecurity/tools/examples/sign-5.xml create mode 100644 xmlsecurity/tools/examples/uno_win.bat create mode 100644 xmlsecurity/tools/examples/warmup.xml create mode 100644 xmlsecurity/tools/standalone/csfit/certmngr.cxx create mode 100644 xmlsecurity/tools/standalone/csfit/decrypter.cxx create mode 100644 xmlsecurity/tools/standalone/csfit/encrypter.cxx create mode 100644 xmlsecurity/tools/standalone/csfit/helper.cxx create mode 100644 xmlsecurity/tools/standalone/csfit/helper.hxx create mode 100644 xmlsecurity/tools/standalone/csfit/makefile.mk create mode 100644 xmlsecurity/tools/standalone/csfit/signer.cxx create mode 100644 xmlsecurity/tools/standalone/csfit/util/makefile.mk create mode 100644 xmlsecurity/tools/standalone/csfit/verifier.cxx create mode 100644 xmlsecurity/tools/standalone/mscsfit/certmngr.cxx create mode 100644 xmlsecurity/tools/standalone/mscsfit/decrypter.cxx create mode 100644 xmlsecurity/tools/standalone/mscsfit/encrypter.cxx create mode 100644 xmlsecurity/tools/standalone/mscsfit/helper.cxx create mode 100644 xmlsecurity/tools/standalone/mscsfit/helper.hxx create mode 100644 xmlsecurity/tools/standalone/mscsfit/makefile.mk create mode 100644 xmlsecurity/tools/standalone/mscsfit/signer.cxx create mode 100644 xmlsecurity/tools/standalone/mscsfit/util/makefile.mk create mode 100644 xmlsecurity/tools/standalone/mscsfit/verifier.cxx create mode 100644 xmlsecurity/tools/uno/AdapterNode.java create mode 100644 xmlsecurity/tools/uno/AttributeListHelper.java create mode 100644 xmlsecurity/tools/uno/DomToTreeModelAdapter.java create mode 100644 xmlsecurity/tools/uno/EncryptionEntity.java create mode 100644 xmlsecurity/tools/uno/ParsingThread.java create mode 100644 xmlsecurity/tools/uno/SAXEventCollector.java create mode 100644 xmlsecurity/tools/uno/SAXEventPrinter.java create mode 100644 xmlsecurity/tools/uno/SecurityEntity.java create mode 100644 xmlsecurity/tools/uno/SignatureEntity.java create mode 100644 xmlsecurity/tools/uno/TestTool.java create mode 100644 xmlsecurity/tools/uno/UnsolvedReferenceTableModel.java create mode 100644 xmlsecurity/tools/uno/XMLFileFilter.java create mode 100644 xmlsecurity/tools/uno/XMLSecurityFrameworkController.java create mode 100644 xmlsecurity/tools/uno/XMLTreeCellRanderer.java create mode 100644 xmlsecurity/tools/uno/current.gif create mode 100644 xmlsecurity/tools/uno/makefile.mk create mode 100644 xmlsecurity/util/exports_xsmscrypt.dxp create mode 100644 xmlsecurity/util/exports_xsnss.dxp create mode 100644 xmlsecurity/util/makefile.mk create mode 100644 xmlsecurity/util/target.pmk create mode 100644 xmlsecurity/util/xmlsecurity.map create mode 100644 xmlsecurity/util/xsec_fw.dxp create mode 100644 xmlsecurity/util/xsecctl.flt create mode 100644 xmlsecurity/workben/makefile.mk create mode 100644 xmlsecurity/workben/signaturetest.cxx (limited to 'xmlsecurity') diff --git a/xmlsecurity/inc/xmlsecurity/certificatechooser.hxx b/xmlsecurity/inc/xmlsecurity/certificatechooser.hxx new file mode 100644 index 000000000000..9df1445849e8 --- /dev/null +++ b/xmlsecurity/inc/xmlsecurity/certificatechooser.hxx @@ -0,0 +1,126 @@ +/************************************************************************* + * + * $RCSfile: certificatechooser.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:20 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _XMLSECURITY_CERTIFICATECHOOSER_HXX +#define _XMLSECURITY_CERTIFICATECHOOSER_HXX + +#include +#include +#include +#include + +namespace com { +namespace sun { +namespace star { +namespace security { + class XCertificate; } +namespace xml { namespace crypto { + class XSecurityEnvironment; }} +}}} + +#include + +#ifndef _SIGSTRUCT_HXX +#include +#endif + +namespace css = com::sun::star; +namespace cssu = com::sun::star::uno; +namespace dcss = ::com::sun::star; + +class HeaderBar; + +class CertificateChooser : public ModalDialog +{ +private: + // XSecurityEnvironment is needed for building the certification path + cssu::Reference< dcss::xml::crypto::XSecurityEnvironment > mxSecurityEnvironment; + + // Show info for this certificate + cssu::Sequence< cssu::Reference< dcss::security::XCertificate > > maCerts; + + FixedText maHintFT; + SvxSimpleTable maCertLB; + + PushButton maViewBtn; + + FixedLine maBottomSepFL; + OKButton maOKBtn; + CancelButton maCancelBtn; + HelpButton maHelpBtn; + + USHORT GetSelectedEntryPos( void ) const; + DECL_LINK( ViewButtonHdl, Button* ); + DECL_LINK( CertificateHighlightHdl, void* ); + DECL_LINK( CertificateSelectHdl, void* ); + + void ImplShowCertificateDetails(); + +public: + CertificateChooser( Window* pParent, cssu::Reference< dcss::xml::crypto::XSecurityEnvironment >& rxSecurityEnvironment, const SignatureInformations& rCertsToIgnore ); + ~CertificateChooser(); + + cssu::Reference< dcss::security::XCertificate > GetSelectedCertificate(); + +}; + +#endif // _XMLSECURITY_CERTIFICATECHOOSER_HXX + diff --git a/xmlsecurity/inc/xmlsecurity/certificateviewer.hxx b/xmlsecurity/inc/xmlsecurity/certificateviewer.hxx new file mode 100644 index 000000000000..200e9373e423 --- /dev/null +++ b/xmlsecurity/inc/xmlsecurity/certificateviewer.hxx @@ -0,0 +1,185 @@ +/************************************************************************* + * + * $RCSfile: certificateviewer.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:20 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _XMLSECURITY_CERTIFICATEVIEWER_HXX +#define _XMLSECURITY_CERTIFICATEVIEWER_HXX + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace com { +namespace sun { +namespace star { +namespace security { + class XCertificate; } +namespace xml { namespace crypto { + class XSecurityEnvironment; }} +}}} + +namespace css = com::sun::star; +namespace cssu = com::sun::star::uno; +namespace dcss = ::com::sun::star; + +class CertificateViewer : public TabDialog +{ +private: + friend class CertificateViewerGeneralTP; + friend class CertificateViewerDetailsTP; + friend class CertificateViewerCertPathTP; + + TabControl maTabCtrl; + OKButton maOkBtn; + HelpButton maHelpBtn; + + cssu::Reference< dcss::xml::crypto::XSecurityEnvironment > mxSecurityEnvironment; + cssu::Reference< dcss::security::XCertificate > mxCert; +public: + CertificateViewer( Window* pParent, cssu::Reference< dcss::xml::crypto::XSecurityEnvironment >& rxSecurityEnvironment, cssu::Reference< dcss::security::XCertificate >& rXCert ); + virtual ~CertificateViewer(); +}; + + +class CertificateViewerTP : public TabPage +{ +protected: + CertificateViewer* mpDlg; +public: + CertificateViewerTP( Window* _pParent, const ResId& _rResId, CertificateViewer* _pDlg ); + inline void SetTabDlg( CertificateViewer* pTabDlg ); +}; + +inline void CertificateViewerTP::SetTabDlg( CertificateViewer* _pTabDlg ) +{ + mpDlg = _pTabDlg; +} + + +class CertificateViewerGeneralTP : public CertificateViewerTP +{ +private: + Window maFrameWin; + FixedImage maCertImg; + FixedInfo maCertInfoFI; + FixedLine maSep1FL; + FixedInfo maHintNotTrustedFI; + FixedLine maSep2FL; + FixedInfo maIssuedToLabelFI; + FixedInfo maIssuedToFI; + FixedInfo maIssuedByLabelFI; + FixedInfo maIssuedByFI; + FixedInfo maValidFromLabelFI; + FixedInfo maValidFromFI; + FixedInfo maValidToLabelFI; + FixedInfo maValidToFI; + FixedImage maKeyImg; + FixedInfo maHintCorrespPrivKeyFI; +public: + CertificateViewerGeneralTP( Window* pParent, CertificateViewer* _pDlg ); + + virtual void ActivatePage(); +}; + + +class CertificateViewerDetailsTP : public CertificateViewerTP +{ +private: + SvxSimpleTable maElementsLB; + MultiLineEdit maElementML; + + DECL_LINK( ElementSelectHdl, void* ); + void Clear( void ); + void InsertElement( const String& _rField, const String& _rValue, const String& _rDetails ); +public: + CertificateViewerDetailsTP( Window* pParent, CertificateViewer* _pDlg ); + virtual ~CertificateViewerDetailsTP(); + + virtual void ActivatePage(); +}; + + +class CertificateViewerCertPathTP : public CertificateViewerTP +{ +private: + FixedText maCertPathFT; + SvTreeListBox maCertPathLB; + FixedText maCertStatusFT; + MultiLineEdit maCertStatusML; + + DECL_LINK( CertSelectHdl, void* ); + void Clear( void ); + void InsertCert( int _nLevel, const String& _rName, const String& _rStatus ); +public: + CertificateViewerCertPathTP( Window* pParent, CertificateViewer* _pDlg ); + virtual ~CertificateViewerCertPathTP(); + + virtual void ActivatePage(); +}; + + +#endif // _XMLSECURITY_CERTIFICATEVIEWER_HXX + diff --git a/xmlsecurity/inc/xmlsecurity/digitalsignaturesdialog.hxx b/xmlsecurity/inc/xmlsecurity/digitalsignaturesdialog.hxx new file mode 100644 index 000000000000..45c72023546a --- /dev/null +++ b/xmlsecurity/inc/xmlsecurity/digitalsignaturesdialog.hxx @@ -0,0 +1,152 @@ +/************************************************************************* + * + * $RCSfile: digitalsignaturesdialog.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:20 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _XMLSECURITY_DIGITALSIGNATURESDIALOG_HXX +#define _XMLSECURITY_DIGITALSIGNATURESDIALOG_HXX + +#include +#include +#include +#include + +#include + +#ifndef _STLP_VECTOR +#include +#endif + +namespace com { +namespace sun { +namespace star { +namespace lang { + class XMultiServiceFactory; } +namespace embed { + class XStorage; } +}}} + +namespace css = com::sun::star; +namespace cssu = com::sun::star::uno; +namespace dcss = ::com::sun::star; + +class HeaderBar; + +enum DocumentSignatureMode { SignatureModeDocumentContent, SignatureModeMacros, SignatureModePackage }; + +class DigitalSignaturesDialog : public ModalDialog +{ +private: + + XMLSignatureHelper maSignatureHelper; + + css::uno::Reference < css::embed::XStorage > mxStore; + SignatureInformations aCurrentSignatureInformations; + bool mbVerifySignatures; + DocumentSignatureMode meSignatureMode; + + // HACK, until sig in storage works + rtl::OUString maSigFileName; + + FixedText maHintDocFT; + FixedText maHintBasicFT; + FixedText maHintPackageFT; + SvxSimpleTable maSignaturesLB; + + PushButton maViewBtn; + PushButton maAddBtn; + PushButton maRemoveBtn; + + FixedLine maBottomSepFL; + OKButton maOKBtn; + CancelButton maCancelBtn; + HelpButton maHelpBtn; + + DECL_LINK( ViewButtonHdl, Button* ); + DECL_LINK( AddButtonHdl, Button* ); + DECL_LINK( RemoveButtonHdl, Button* ); + DECL_LINK( SignatureHighlightHdl, void* ); + DECL_LINK( SignatureSelectHdl, void* ); + DECL_LINK( StartVerifySignatureHdl, void* ); + + void ImplGetSignatureInformations(); + void ImplFillSignaturesBox(); + void ImplShowSignaturesDetails(); + +public: + DigitalSignaturesDialog( Window* pParent, cssu::Reference< css::lang::XMultiServiceFactory >& rxMSF, DocumentSignatureMode eMode ); + ~DigitalSignaturesDialog(); + + // Initialize the dialog and the security environment, returns TRUE on success + BOOL Init( const rtl::OUString& rTokenName ); + + // Set the storage which should be signed or verified + void SetStorage( const cssu::Reference < css::embed::XStorage >& rxStore ); + + // HACK: Set a signature file name, use this until sig in storage works! + void SetSignatureFileName( const rtl::OUString& rName ) { maSigFileName = rName; } + + // Execute the dialog... + short Execute(); + + static std::vector< rtl::OUString > CreateElementList( css::uno::Reference < css::embed::XStorage >& rxStore, const ::rtl::OUString rRootStorageName, DocumentSignatureMode eMode ); +}; + +#endif // _XMLSECURITY_DIGITALSIGNATURESDIALOG_HXX + diff --git a/xmlsecurity/inc/xmlsecurity/sigstruct.hxx b/xmlsecurity/inc/xmlsecurity/sigstruct.hxx new file mode 100644 index 000000000000..72b5d2231fae --- /dev/null +++ b/xmlsecurity/inc/xmlsecurity/sigstruct.hxx @@ -0,0 +1,120 @@ +/************************************************************************* + * + * $RCSfile: sigstruct.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:20 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _SIGSTRUCT_HXX +#define _SIGSTRUCT_HXX + +#include + +#ifndef INCLUDED_VECTOR +#include +#define INCLUDED_VECTOR +#endif + +/* + * signature status + */ +#define STATUS_INIT 0 +#define STATUS_CREATION_SUCCEED 1 +#define STATUS_CREATION_FAIL 2 +#define STATUS_VERIFY_SUCCEED 3 +#define STATUS_VERIFY_FAIL 4 + +struct SignatureReferenceInformation +{ + sal_Int32 nType; + rtl::OUString ouURI; + rtl::OUString ouDigestValue; + + SignatureReferenceInformation( sal_Int32 type, rtl::OUString uri ) + { + nType = type; + ouURI = uri; + } +}; + +typedef ::std::vector< SignatureReferenceInformation > SignatureReferenceInformations; + +struct SignatureInformation +{ + sal_Int32 nSecurityId; + sal_Int32 nStatus; + SignatureReferenceInformations vSignatureReferenceInfors; + rtl::OUString ouX509IssuerName; + rtl::OUString ouX509SerialNumber; + rtl::OUString ouX509Certificate; + rtl::OUString ouSignatureValue; + rtl::OUString ouDate; + rtl::OUString ouTime; + rtl::OUString ouSignatureId; + rtl::OUString ouPropertyId; + + SignatureInformation( sal_Int32 nId ) + { + nSecurityId = nId; + nStatus = STATUS_INIT; + } +}; + +typedef ::std::vector< SignatureInformation > SignatureInformations; + +#endif + diff --git a/xmlsecurity/inc/xmlsecurity/stbcontrl.hxx b/xmlsecurity/inc/xmlsecurity/stbcontrl.hxx new file mode 100644 index 000000000000..14200eaf1f11 --- /dev/null +++ b/xmlsecurity/inc/xmlsecurity/stbcontrl.hxx @@ -0,0 +1,91 @@ +/************************************************************************* + * + * $RCSfile: stbcontrl.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:20 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _XMLSECURITY_STBCONTRL_HXX +#define _XMLSECURITY_STBCONTRL_HXX + +#include + + +class SvxSizeItem; + +// class SvxPosSizeToolBoxControl ---------------------------------------- + +class XmlSecStatusBarControl : public SfxStatusBarControl +{ +private: + struct XmlSecStatusBarControl_Impl; + + XmlSecStatusBarControl_Impl* mpImpl; + +public: + SFX_DECL_STATUSBAR_CONTROL(); + + XmlSecStatusBarControl( USHORT _nId, StatusBar& _rStb, SfxBindings& _rBind ); + ~XmlSecStatusBarControl(); + + virtual void StateChanged( USHORT nSID, SfxItemState eState, const SfxPoolItem* pState ); + virtual void Paint( const UserDrawEvent& rEvt ); + virtual void Command( const CommandEvent& rCEvt ); +}; + +#endif + diff --git a/xmlsecurity/inc/xmlsecurity/xmlsignaturehelper.hxx b/xmlsecurity/inc/xmlsecurity/xmlsignaturehelper.hxx new file mode 100644 index 000000000000..63130f9a5baa --- /dev/null +++ b/xmlsecurity/inc/xmlsecurity/xmlsignaturehelper.hxx @@ -0,0 +1,214 @@ +/************************************************************************* + * + * $RCSfile: xmlsignaturehelper.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:20 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _XMLSECURITY_XMLSIGNATUREHELPER_HXX +#define _XMLSECURITY_XMLSIGNATUREHELPER_HXX + +#ifndef _STLP_VECTOR +#include +#endif + +#include + +#include + +#include + +#include +#include +#include +#include +#include +#include + +extern rtl::OUString bigIntegerToNumericString( ::com::sun::star::uno::Sequence< sal_Int8 > serial ); +extern ::com::sun::star::uno::Sequence< sal_Int8 > numericStringToBigInteger ( rtl::OUString serialNumber ); + +class XSecController; + +namespace com { +namespace sun { +namespace star { +namespace lang { + class XMultiServiceFactory; } +namespace io { + class XOutputStream; + class XInputStream; } +namespace embed { + class XStorage; } +}}} + +struct XMLSignatureCreationResult +{ + sal_Int32 nSecurityId; + com::sun::star::xml::crypto::sax::SignatureCreationResult nSignatureCreationResult; + + XMLSignatureCreationResult( sal_Int32 nId, com::sun::star::xml::crypto::sax::SignatureCreationResult nResult ) + { + nSecurityId = nId; + nSignatureCreationResult = nResult; + } +}; + +struct XMLSignatureVerifyResult +{ + sal_Int32 nSecurityId; + com::sun::star::xml::crypto::sax::SignatureVerifyResult nSignatureVerifyResult; + + XMLSignatureVerifyResult( sal_Int32 nId, com::sun::star::xml::crypto::sax::SignatureVerifyResult nResult ) + { + nSecurityId = nId; + nSignatureVerifyResult = nResult; + } +}; + +typedef ::std::vector XMLSignatureCreationResults; +typedef ::std::vector XMLSignatureVerifyResults; + + + +/********************************************************** + XMLSignatureHelper + + Helper class for the XML Security framework + + Functions: + 1. help to create a security context; + 2. help to listen signature creation result; + 3. help to listen signature verify result; + 4. help to indicate which signature to verify. + + **********************************************************/ + +class XMLSignatureHelper +{ +private: + ::com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory> mxMSF; + ::com::sun::star::uno::Reference< com::sun::star::xml::crypto::sax::XSecurityController > mxSecurityController; + ::com::sun::star::uno::Reference< com::sun::star::xml::crypto::XUriBinding > mxUriBinding; + + ::com::sun::star::uno::Reference< com::sun::star::xml::crypto::XSEInitializer > mxSEInitializer; + ::com::sun::star::uno::Reference< com::sun::star::xml::crypto::XXMLSecurityContext > mxSecurityContext; + + XMLSignatureCreationResults maCreationResults; + XMLSignatureVerifyResults maVerifyResults; + XSecController* mpXSecController; + bool mbError; + Link maStartVerifySignatureHdl; + +private: + void ImplCreateSEInitializer(); + DECL_LINK( SignatureCreationResultListener, XMLSignatureCreationResult*); + DECL_LINK( SignatureVerifyResultListener, XMLSignatureVerifyResult* ); + DECL_LINK( StartVerifySignatureElement, const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList >* ); + + // Not allowed: + XMLSignatureHelper(const XMLSignatureHelper&); + +public: + XMLSignatureHelper(const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory>& rxMSF ); + ~XMLSignatureHelper(); + + // Initialize the security context with given crypto token. + // Empty string means default crypto token. + // Returns true for success. + bool Init( const rtl::OUString& rTokenPath ); + + // Set UriBinding to create input streams to open files. + // Default implementation is capable to open files from disk. + void SetUriBinding( com::sun::star::uno::Reference< com::sun::star::xml::crypto::XUriBinding >& rxUriBinding ); + + // Set the storage which should be used by the default UriBinding + // Must be set before StatrtMission(). + void SetStorage( const com::sun::star::uno::Reference < com::sun::star::embed::XStorage >& rxStorage ); + + // Argument for the Link is a uno::Reference< xml::sax::XAttributeList >* + // Return 1 to verify, 0 to skip. + // Default will verify all. + void SetStartVerifySignatureHdl( const Link& rLink ); + + // Get the security environment + ::com::sun::star::uno::Reference< ::com::sun::star::xml::crypto::XSecurityEnvironment > GetSecurityEnvironment(); + + // After signing/veryfieng, get information about signatures + SignatureInformations GetSignatureInformations() const; + + // See XSecController for documentation + void StartMission(); + void EndMission(); + sal_Int32 GetNewSecurityId(); + void SetX509Certificate( sal_Int32 nSecurityId, const rtl::OUString& ouX509IssuerName, const rtl::OUString& ouX509SerialNumber); + void SetDateTime( sal_Int32 nSecurityId, const rtl::OUString& ouDate, const rtl::OUString& ouTime); + + void AddForSigning( sal_Int32 securityId, const rtl::OUString& uri, const rtl::OUString& objectURL, sal_Bool bBinary ); + bool CreateAndWriteSignatue( const com::sun::star::uno::Reference< com::sun::star::xml::sax::XDocumentHandler >& xDocumentHandler ); + bool CreateAndWriteSignatue( const com::sun::star::uno::Reference< com::sun::star::io::XOutputStream >& xOutputStream ); + bool ReadAndVerifySignatue( const com::sun::star::uno::Reference< com::sun::star::io::XInputStream >& xInputStream ); + + // MT: ??? I think only for adding/removing, not for new signatures... + // MM: Yes, but if you want to insert a new signature into an existing signature file, those function + // will be very usefull, see Mission 3 in the new "multisigdemo" program :-) + ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler> CreateDocumentHandlerWithHeader( const com::sun::star::uno::Reference< com::sun::star::io::XOutputStream >& xOutputStream ); + void CloseDocumentHandler( const ::com::sun::star::uno::Reference< com::sun::star::xml::sax::XDocumentHandler>& xDocumentHandler ); + void ExportSignature( const com::sun::star::uno::Reference< com::sun::star::xml::sax::XDocumentHandler >& xDocumentHandler, const SignatureInformation& signatureInfo ); +}; + +#endif // _XMLSECURITY_XMLSIGNATUREHELPER_HXX diff --git a/xmlsecurity/prj/build.lst b/xmlsecurity/prj/build.lst new file mode 100644 index 000000000000..5659e9664996 --- /dev/null +++ b/xmlsecurity/prj/build.lst @@ -0,0 +1,10 @@ +xs xmlsecurity : xmloff offapi unoil svx moz NULL +xs xmlsecurity usr1 - all xs_mkout NULL +xs xmlsecurity\source\framework nmake - all xs_fw NULL +xs xmlsecurity\source\xmlsec\nss nmake - all xs_nss NULL +xs xmlsecurity\source\xmlsec\mscrypt nmake - all xs_mscrypt NULL +xs xmlsecurity\source\xmlsec nmake - all xs_xmlsec xs_nss xs_mscrypt NULL +xs xmlsecurity\source\helper nmake - all xs_helper NULL +xs xmlsecurity\source\dialogs nmake - all xs_dialogs NULL +xs xmlsecurity\source\component nmake - all xs_component NULL +xs xmlsecurity\util nmake - all xs_util xs_fw xs_xmlsec xs_nss xs_mscrypt xs_helper xs_dialogs xs_component NULL diff --git a/xmlsecurity/prj/d.lst b/xmlsecurity/prj/d.lst new file mode 100644 index 000000000000..a0b6506e7956 --- /dev/null +++ b/xmlsecurity/prj/d.lst @@ -0,0 +1,4 @@ +..\%__SRC%\bin\xsec_fw.dll %_DEST%\bin%_EXT%\xsec_fw.dll +..\%__SRC%\bin\xsec_xmlsec.dll %_DEST%\bin%_EXT%\xsec_xmlsec.dll +..\%__SRC%\bin\xmlsecurity.dll %_DEST%\bin%_EXT%\xmlsecurity.dll + diff --git a/xmlsecurity/source/component/documentdigitalsignatures.cxx b/xmlsecurity/source/component/documentdigitalsignatures.cxx new file mode 100644 index 000000000000..d000b23a33bd --- /dev/null +++ b/xmlsecurity/source/component/documentdigitalsignatures.cxx @@ -0,0 +1,123 @@ +/************************************************************************* + * + * $RCSfile: documentdigitalsignatures.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:24 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + + +#include +#include + +#ifndef _COM_SUN_STAR_EMBED_XSTORAGE_HPP_ +#include +#endif + + +using namespace ::com::sun::star; +using namespace ::com::sun::star; + + +DocumentDigitalSignatures::DocumentDigitalSignatures( const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory> rxMSF ) +{ + mxMSF = rxMSF; +} + + +sal_Bool DocumentDigitalSignatures::SignDocumentContent( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& rxStorage, const ::rtl::OUString& rStorageName, const ::rtl::OUString& rTokenName ) throw (::com::sun::star::uno::RuntimeException) +{ + DigitalSignaturesDialog aSignaturesDialog( NULL, mxMSF, SignatureModeDocumentContent ); + + bool bInit = aSignaturesDialog.Init( rTokenName ); + + DBG_ASSERT( bInit, "Error initializing security context!" ); + if ( bInit ) + { + aSignaturesDialog.SetStorage( rxStorage ); + aSignaturesDialog.SetSignatureFileName( rStorageName ); + aSignaturesDialog.Execute(); + } + + return 0; +} + +::com::sun::star::uno::Sequence< ::com::sun::star::security::DocumentSignaturesInformation > DocumentDigitalSignatures::VerifyDocumentContentSignatures( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& Storage, const ::rtl::OUString& StorageName, const ::rtl::OUString& rTokenName ) throw (::com::sun::star::uno::RuntimeException) +{ + ::com::sun::star::uno::Sequence< ::com::sun::star::security::DocumentSignaturesInformation > aInfos; + return aInfos; +} + +rtl::OUString DocumentDigitalSignatures::GetImplementationName() throw (uno::RuntimeException) +{ + return rtl::OUString ( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.security.DocumentDigitalSignatures" ) ); +} + +uno::Sequence< rtl::OUString > SAL_CALL DocumentDigitalSignatures::GetSupportedServiceNames() throw (cssu::RuntimeException) +{ + uno::Sequence < rtl::OUString > aRet(1); + rtl::OUString* pArray = aRet.getArray(); + pArray[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.security.DocumentDigitalSignatures" ) ); + return aRet; +} + + +com::sun::star::uno::Reference< com::sun::star::uno::XInterface > SAL_CALL DocumentDigitalSignatures_CreateInstance( + const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& rSMgr) throw ( com::sun::star::uno::Exception ) +{ + return (cppu::OWeakObject*) new DocumentDigitalSignatures( rSMgr ); +} + diff --git a/xmlsecurity/source/component/documentdigitalsignatures.hxx b/xmlsecurity/source/component/documentdigitalsignatures.hxx new file mode 100644 index 000000000000..50d10ad85084 --- /dev/null +++ b/xmlsecurity/source/component/documentdigitalsignatures.hxx @@ -0,0 +1,94 @@ +/************************************************************************* + * + * $RCSfile: documentdigitalsignatures.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:24 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _XMLSECURITY_DOCUMENTDIGITALSIGNATURES_HXX +#define _XMLSECURITY_DOCUMENTDIGITALSIGNATURES_HXX + +#include + +#include + + +class DocumentDigitalSignatures : public cppu::WeakImplHelper1 +< + com::sun::star::security::XDocumentDigitalSignatures +> +{ +private: + com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > mxMSF; + +public: + DocumentDigitalSignatures( const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory> rxMSF ); + + // for service registration... + static ::rtl::OUString GetImplementationName() throw (com::sun::star::uno::RuntimeException); + static ::com::sun::star::uno::Sequence < ::rtl::OUString > GetSupportedServiceNames() throw (com::sun::star::uno::RuntimeException); + + // XDocumentDigitalSignatures + virtual sal_Bool SAL_CALL SignDocumentContent( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& Storage, const ::rtl::OUString& StorageName, const ::rtl::OUString& rTokenName ) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::security::DocumentSignaturesInformation > SAL_CALL VerifyDocumentContentSignatures( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& Storage, const ::rtl::OUString& StorageName, const ::rtl::OUString& rTokenName ) throw (::com::sun::star::uno::RuntimeException); + +}; + +com::sun::star::uno::Reference< com::sun::star::uno::XInterface > SAL_CALL DocumentDigitalSignatures_CreateInstance( + const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& rSMgr) throw ( com::sun::star::uno::Exception ); + +#endif // _XMLSECURITY_DOCUMENTDIGITALSIGNATURES_HXX diff --git a/xmlsecurity/source/component/makefile.mk b/xmlsecurity/source/component/makefile.mk new file mode 100644 index 000000000000..b25ed052d35e --- /dev/null +++ b/xmlsecurity/source/component/makefile.mk @@ -0,0 +1,86 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1.1.1 $ +# +# last change: $Author: mt $ $Date: 2004-07-12 13:15:24 $ +# +# The Contents of this file are made available subject to the terms of +# either of the following licenses +# +# - GNU Lesser General Public License Version 2.1 +# - Sun Industry Standards Source License Version 1.1 +# +# Sun Microsystems Inc., October, 2000 +# +# GNU Lesser General Public License Version 2.1 +# ============================================= +# Copyright 2000 by Sun Microsystems, Inc. +# 901 San Antonio Road, Palo Alto, CA 94303, USA +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License version 2.1, as published by the Free Software Foundation. +# +# This library 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 for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, +# MA 02111-1307 USA +# +# +# Sun Industry Standards Source License Version 1.1 +# ================================================= +# The contents of this file are subject to the Sun Industry Standards +# Source License Version 1.1 (the "License"); You may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at http://www.openoffice.org/license.html. +# +# Software provided under this License is provided on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, +# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, +# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. +# See the License for the specific provisions governing your rights and +# obligations concerning the Software. +# +# The Initial Developer of the Original Code is: Sun Microsystems, Inc. +# +# Copyright: 2000 by Sun Microsystems, Inc. +# +# All Rights Reserved. +# +# Contributor(s): _______________________________________ +# +# +# +#************************************************************************* + +PRJ=..$/.. + +PRJNAME=xmlsecurity +TARGET=component + +ENABLE_EXCEPTIONS=TRUE + +# --- Settings ----------------------------------------------------- + +.INCLUDE : svpre.mk +.INCLUDE : settings.mk +.INCLUDE : sv.mk +.INCLUDE : $(PRJ)$/util$/target.pmk + +# --- Files -------------------------------------------------------- + +SLOFILES= \ + $(SLO)$/documentdigitalsignatures.obj \ + $(SLO)$/registerservices.obj \ + + +# --- Targets ------------------------------------------------------ + +.INCLUDE : target.mk diff --git a/xmlsecurity/source/component/registerservices.cxx b/xmlsecurity/source/component/registerservices.cxx new file mode 100644 index 000000000000..43c4260b187a --- /dev/null +++ b/xmlsecurity/source/component/registerservices.cxx @@ -0,0 +1,135 @@ +/************************************************************************* + * + * $RCSfile: registerservices.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:24 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#include + +#ifndef _COM_SUN_STAR_LANG_XSINGLESERVICEFACTORY_HPP_ +#include +#endif + +#include + + +#include + +using namespace ::com::sun::star; + +extern "C" +{ +void SAL_CALL component_getImplementationEnvironment( const sal_Char ** ppEnvTypeName, uno_Environment ** ppEnv ) +{ + *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; +} + +sal_Bool SAL_CALL component_writeInfo( void* pServiceManager, void* pRegistryKey ) +{ + if (pRegistryKey) + { + try + { + sal_Int32 nPos = 0; + uno::Reference< registry::XRegistryKey > xNewKey( + reinterpret_cast< registry::XRegistryKey* >( pRegistryKey )->createKey( DocumentDigitalSignatures::GetImplementationName() ) ); + xNewKey = xNewKey->createKey( rtl::OUString::createFromAscii( "/UNO/SERVICES" ) ); + + const uno::Sequence< rtl::OUString >& rSNL = DocumentDigitalSignatures::GetSupportedServiceNames(); + const rtl::OUString* pArray = rSNL.getConstArray(); + for ( nPos = rSNL.getLength(); nPos--; ) + xNewKey->createKey( pArray[nPos] ); + + return sal_True; + } + catch (registry::InvalidRegistryException &) + { + DBG_ERROR( "InvalidRegistryException!" ); + } + } + return sal_False; +} + +void* SAL_CALL component_getFactory( const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey ) +{ + void* pRet = NULL; + + //Decryptor + rtl::OUString implName = rtl::OUString::createFromAscii( pImplName ); + if ( pServiceManager && implName.equals( DocumentDigitalSignatures::GetImplementationName() ) ) + { + uno::Reference< lang::XSingleServiceFactory > xFactory( cppu::createSingleFactory( + reinterpret_cast< lang::XMultiServiceFactory * >( pServiceManager ), + rtl::OUString::createFromAscii( pImplName ), + DocumentDigitalSignatures_CreateInstance, DocumentDigitalSignatures::GetSupportedServiceNames() ) ); + + if (xFactory.is()) + { + xFactory->acquire(); + pRet = xFactory.get(); + } + } + return pRet; +} + +} // extern "C" + + + + + diff --git a/xmlsecurity/source/dialogs/certificatechooser.cxx b/xmlsecurity/source/dialogs/certificatechooser.cxx new file mode 100644 index 000000000000..efab9b3143e1 --- /dev/null +++ b/xmlsecurity/source/dialogs/certificatechooser.cxx @@ -0,0 +1,216 @@ +/************************************************************************* + * + * $RCSfile: certificatechooser.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:23 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#include +#include + +#ifndef _COM_SUN_STAR_XML_CRYPTO_XSECURITYENVIRONMENT_HPP_ +#include +#endif + +#ifndef _COMPHELPER_SEQUENCE_HXX_ +#include +#endif + +// MM : added for password exception +#include +#include +using namespace ::com::sun::star::security; + +// Only for bigIntegerToNumericString +#include + +#include "dialogs.hrc" +#include "resourcemanager.hxx" + +/* HACK: disable some warnings for MS-C */ +#ifdef _MSC_VER +#pragma warning (disable : 4355) // 4355: this used in initializer-list +#endif + +using namespace ::com::sun::star; +using namespace ::com::sun::star; + +#define INVAL_SEL 0xFFFF + + +USHORT CertificateChooser::GetSelectedEntryPos( void ) const +{ + USHORT nSel = INVAL_SEL; + + SvLBoxEntry* pSel = maCertLB.FirstSelected(); + if( pSel ) + nSel = ( USHORT ) pSel->GetUserData(); + + return nSel; +} + +CertificateChooser::CertificateChooser( Window* _pParent, uno::Reference< dcss::xml::crypto::XSecurityEnvironment >& _rxSecurityEnvironment, const SignatureInformations& _rCertsToIgnore ) + :ModalDialog ( _pParent, XMLSEC_RES( RID_XMLSECDLG_CERTCHOOSER ) ) + ,maHintFT ( this, ResId( FT_HINT_SELECT ) ) + ,maCertLB ( this, ResId( LB_SIGNATURES ) ) + ,maViewBtn ( this, ResId( BTN_VIEWCERT ) ) + ,maBottomSepFL ( this, ResId( FL_BOTTOM_SEP ) ) + ,maOKBtn ( this, ResId( BTN_OK ) ) + ,maCancelBtn ( this, ResId( BTN_CANCEL ) ) + ,maHelpBtn ( this, ResId( BTN_HELP ) ) +{ + static long nTabs[] = { 3, 0, 30*CS_LB_WIDTH/100, 60*CS_LB_WIDTH/100 }; + maCertLB.SetTabs( &nTabs[0] ); + maCertLB.InsertHeaderEntry( String( ResId( STR_HEADERBAR ) ) ); + + FreeResource(); + + mxSecurityEnvironment = _rxSecurityEnvironment; + + + maCertLB.SetSelectHdl( LINK( this, CertificateChooser, CertificateHighlightHdl ) ); + maCertLB.SetDoubleClickHdl( LINK( this, CertificateChooser, CertificateSelectHdl ) ); + + // MM : added for password exception + try + { + maCerts = mxSecurityEnvironment->getPersonalCertificates(); + } + catch (NoPasswordException&) + { + InfoBox( this, rtl::OUString( String( RTL_CONSTASCII_USTRINGPARAM( "No password is provided!\n\n" ) ) ) ).Execute(); + } + + sal_Int32 nCertificates = maCerts.getLength(); + sal_Int32 nCertificatesToIgnore = _rCertsToIgnore.size(); + if( nCertificatesToIgnore ) + { + for( sal_Int32 nCert = nCertificates; nCert; ) + { + uno::Reference< security::XCertificate > xCert = maCerts[ --nCert ]; + int nCertsToIgnore = _rCertsToIgnore.size(); + for( sal_Int32 nSig = 0; nSig < nCertificatesToIgnore; ++nSig ) + { + const SignatureInformation& rInf = _rCertsToIgnore[ nSig ]; + if( ( xCert->getIssuerName() == rInf.ouX509IssuerName ) && ( bigIntegerToNumericString( xCert->getSerialNumber() ) == rInf.ouX509SerialNumber ) ) + { + ::comphelper::removeElementAt( maCerts, nCert ); + } + } + } + nCertificates = maCerts.getLength(); + } + + String aCN_Id( String::CreateFromAscii( "CN" ) ); + + for( sal_Int32 nC = 0; nC < nCertificates; ++nC ) + { + String aSubject ( XmlSec::GetContentPart( maCerts[ nC ]->getSubjectName(), aCN_Id ) ); + String aDateTimeStr( XmlSec::GetDateString( maCerts[ nC ]->getNotAfter() ) ); + String aIssuer ( XmlSec::GetContentPart( maCerts[ nC ]->getIssuerName(), aCN_Id ) ); + + SvLBoxEntry* pEntry = maCertLB.InsertEntry( aSubject ); + maCertLB.SetEntryText( aIssuer, pEntry, 1 ); + maCertLB.SetEntryText( aDateTimeStr, pEntry, 2 ); + pEntry->SetUserData( ( void* ) nC ); // missuse user data as index + } + + maViewBtn.SetClickHdl( LINK( this, CertificateChooser, ViewButtonHdl ) ); + maViewBtn.Disable(); +} + +CertificateChooser::~CertificateChooser() +{ +} + +uno::Reference< dcss::security::XCertificate > CertificateChooser::GetSelectedCertificate() +{ + uno::Reference< dcss::security::XCertificate > xCert; + USHORT nSelected = GetSelectedEntryPos(); + if( nSelected < maCerts.getLength() ) + xCert = maCerts[ nSelected ]; + + return xCert; +} + +IMPL_LINK( CertificateChooser, CertificateHighlightHdl, void*, EMPTYARG ) +{ + maViewBtn.Enable(); + return 0; +} + +IMPL_LINK( CertificateChooser, CertificateSelectHdl, void*, EMPTYARG ) +{ + EndDialog( 1 ); + return 0; +} + +IMPL_LINK( CertificateChooser, ViewButtonHdl, Button*, EMPTYARG ) +{ + ImplShowCertificateDetails(); + return 0; +} + +void CertificateChooser::ImplShowCertificateDetails() +{ + uno::Reference< dcss::security::XCertificate > xCert = GetSelectedCertificate(); + if( xCert.is() ) + { + CertificateViewer aViewer( this, mxSecurityEnvironment, xCert ); + aViewer.Execute(); + } +} \ No newline at end of file diff --git a/xmlsecurity/source/dialogs/certificatechooser.src b/xmlsecurity/source/dialogs/certificatechooser.src new file mode 100644 index 000000000000..9431a3405608 --- /dev/null +++ b/xmlsecurity/source/dialogs/certificatechooser.src @@ -0,0 +1,125 @@ +/************************************************************************* + * + * $RCSfile: certificatechooser.src,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:23 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#include "dialogs.hrc" + +ModalDialog RID_XMLSECDLG_CERTCHOOSER +{ +// HelpId = HID_XMLSECDLG_CERTCHOOSER; + Size = MAP_APPFONT( CS_WIDTH, CS_HEIGHT ); + OutputSize = TRUE; + Closeable = TRUE; + Moveable = TRUE; + SVLook = TRUE; + +// Text = "Zertifikat auswählen"; + Text = "Select Certificate"; + Text [ en-US ] = "Select Certificate"; + + FixedText FT_HINT_SELECT + { + Pos = MAP_APPFONT( CS_COL_0, CS_ROW_0 ); + Size = MAP_APPFONT( CS_COL_2-CS_COL_0, RSC_CD_FIXEDTEXT_HEIGHT ); + Text = "Select the certificate you want to use for signing"; + Text [ en-US ] = "Select the certificate you want to use for signing"; + }; + Control LB_SIGNATURES + { + Pos = MAP_APPFONT( CS_COL_0, CS_ROW_1 ); + Size = MAP_APPFONT( CS_LB_WIDTH, CS_ROW_2-CS_ROW_1 ); + SVLook = TRUE; + Border = TRUE; + }; + String STR_HEADERBAR + { + Text = "Issued to\tIssued by\tExpiration Date"; + Text [ en-US ] = "Issued to\tIssued by\tExpiration Date"; + }; + PushButton BTN_VIEWCERT + { + Pos = MAP_APPFONT( CS_COL_1, CS_ROW_3 ); + Size = MAP_APPFONT( CS_COL_2-CS_COL_1, RSC_CD_PUSHBUTTON_HEIGHT ); +// Text = "Zertifikat anzeigen..."; + Text = "View Certificate..."; + Text [ en-US ] = "View Certificate..."; + }; + FixedLine FL_BOTTOM_SEP + { + Pos = MAP_APPFONT( 0, DLGS_BOTTOM_FL_Y( CS_HEIGHT ) ); + Size = MAP_APPFONT( CS_WIDTH, RSC_CD_FIXEDLINE_HEIGHT ); + }; + OKButton BTN_OK + { + DefButton = TRUE; + Pos = MAP_APPFONT( DLGS_BOTTOM_OK_X( CS_WIDTH ), DLGS_BOTTOM_BTN_Y( CS_HEIGHT ) ); + Size = MAP_APPFONT( RSC_CD_PUSHBUTTON_WIDTH, RSC_CD_PUSHBUTTON_HEIGHT ); + }; + CancelButton BTN_CANCEL + { + Pos = MAP_APPFONT( DLGS_BOTTOM_CANCEL_X( CS_WIDTH ), DLGS_BOTTOM_BTN_Y( CS_HEIGHT ) ); + Size = MAP_APPFONT( RSC_CD_PUSHBUTTON_WIDTH, RSC_CD_PUSHBUTTON_HEIGHT ); + }; + HelpButton BTN_HELP + { + Pos = MAP_APPFONT( DLGS_BOTTOM_HELP_X( CS_WIDTH ), DLGS_BOTTOM_BTN_Y( CS_HEIGHT ) ); + Size = MAP_APPFONT( RSC_CD_PUSHBUTTON_WIDTH, RSC_CD_PUSHBUTTON_HEIGHT ); + }; +}; diff --git a/xmlsecurity/source/dialogs/certificateviewer.cxx b/xmlsecurity/source/dialogs/certificateviewer.cxx new file mode 100644 index 000000000000..1d106bc4f51b --- /dev/null +++ b/xmlsecurity/source/dialogs/certificateviewer.cxx @@ -0,0 +1,397 @@ +/************************************************************************* + * + * $RCSfile: certificateviewer.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:23 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#include + +// Only for bigIntegerToNumericString +#include + + +#ifndef _COM_SUN_STAR_SECURITY_XCERTIFICATE_HPP_ +#include +#endif + +#include "dialogs.hrc" +#include "resourcemanager.hxx" + +/* HACK: disable some warnings for MS-C */ +#ifdef _MSC_VER +#pragma warning (disable : 4355) // 4355: this used in initializer-list +#endif + +using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star; + + +namespace +{ + void AdjustPosAndSize( Control& _rCtrl, Point& _rStartIn_EndOut, long _nXOffset = 0 ); + + void AdjustPosAndSize( Control& _rCtrl, Point& _rStartIn_EndOut, long _nOffs ) + { + long nWidth = _rCtrl.GetTextWidth( _rCtrl.GetText() ); + Size aSize( _rCtrl.GetSizePixel() ); + nWidth += _nOffs; + aSize.Width() = nWidth; + _rCtrl.SetPosPixel( _rStartIn_EndOut ); + _rCtrl.SetSizePixel( aSize ); + _rStartIn_EndOut.X() += nWidth; + } +}; + +CertificateViewer::CertificateViewer( + Window* _pParent, + cssu::Reference< dcss::xml::crypto::XSecurityEnvironment >& _rxSecurityEnvironment, + cssu::Reference< dcss::security::XCertificate >& _rXCert ) + :TabDialog ( _pParent, XMLSEC_RES( RID_XMLSECDLG_CERTVIEWER ) ) + ,maTabCtrl ( this, ResId( 1 ) ) + ,maOkBtn ( this, ResId( BTN_OK ) ) + ,maHelpBtn ( this, ResId( BTN_HELP ) ) +{ + FreeResource(); + + mxSecurityEnvironment = _rxSecurityEnvironment; + mxCert = _rXCert; + + maTabCtrl.SetTabPage( RID_XMLSECTP_GENERAL, new CertificateViewerGeneralTP( &maTabCtrl, this ) ); + maTabCtrl.SetTabPage( RID_XMLSECTP_DETAILS, new CertificateViewerDetailsTP( &maTabCtrl, this ) ); + maTabCtrl.SetTabPage( RID_XMLSECTP_CERTPATH, new CertificateViewerCertPathTP( &maTabCtrl, this ) ); + maTabCtrl.SetCurPageId( RID_XMLSECTP_GENERAL ); +} + +CertificateViewer::~CertificateViewer() +{ + delete maTabCtrl.GetTabPage( RID_XMLSECTP_CERTPATH ); + delete maTabCtrl.GetTabPage( RID_XMLSECTP_DETAILS ); + delete maTabCtrl.GetTabPage( RID_XMLSECTP_GENERAL ); +} + +CertificateViewerTP::CertificateViewerTP( Window* _pParent, const ResId& _rResId, CertificateViewer* _pDlg ) + :TabPage ( _pParent, _rResId ) + ,mpDlg ( _pDlg ) +{ +} + + +CertificateViewerGeneralTP::CertificateViewerGeneralTP( Window* _pParent, CertificateViewer* _pDlg ) + :CertificateViewerTP ( _pParent, XMLSEC_RES( RID_XMLSECTP_GENERAL ), _pDlg ) + ,maFrameWin ( this, ResId( WIN_FRAME ) ) + ,maCertImg ( this, ResId( IMG_CERT ) ) + ,maCertInfoFI ( this, ResId( FI_CERTINFO ) ) + ,maSep1FL ( this, ResId( FL_SEP1 ) ) + ,maHintNotTrustedFI ( this, ResId( FI_HINTNOTTRUST ) ) + ,maSep2FL ( this, ResId( FL_SEP2 ) ) + ,maIssuedToLabelFI ( this, ResId( FI_ISSTOLABEL ) ) + ,maIssuedToFI ( this, ResId( FI_ISSTO ) ) + ,maIssuedByLabelFI ( this, ResId( FI_ISSBYLABEL ) ) + ,maIssuedByFI ( this, ResId( FI_ISSBY ) ) + ,maValidFromLabelFI ( this, ResId( FI_VALFROMLABEL ) ) + ,maValidFromFI ( this, ResId( FI_VALFROM ) ) + ,maValidToLabelFI ( this, ResId( FI_VALTOLABEL ) ) + ,maValidToFI ( this, ResId( FI_VALTO ) ) + ,maKeyImg ( this, ResId( IMG_KEY ) ) + ,maHintCorrespPrivKeyFI ( this, ResId( FI_CORRPRIVKEY ) ) +{ + FreeResource(); + + Wallpaper aBack( GetSettings().GetStyleSettings().GetWindowColor() ); + + maFrameWin.SetBackground( aBack ); + maCertInfoFI.SetBackground( aBack ); + maSep1FL.SetBackground( aBack ); + maHintNotTrustedFI.SetBackground( aBack ); + maSep2FL.SetBackground( aBack ); + maIssuedToLabelFI.SetBackground( aBack ); + maIssuedToFI.SetBackground( aBack ); + maIssuedByLabelFI.SetBackground( aBack ); + maIssuedByFI.SetBackground( aBack ); + maValidFromLabelFI.SetBackground( aBack ); + maValidFromFI.SetBackground( aBack ); + maValidToLabelFI.SetBackground( aBack ); + maValidToFI.SetBackground( aBack ); + maKeyImg.SetBackground( aBack ); + maHintCorrespPrivKeyFI.SetBackground( aBack ); + + // make some bold + Font aFnt( maCertInfoFI.GetFont() ); + aFnt.SetWeight( WEIGHT_BOLD ); + maCertInfoFI.SetFont( aFnt ); + maHintNotTrustedFI.SetFont( aFnt ); + maIssuedToLabelFI.SetFont( aFnt ); + maIssuedByLabelFI.SetFont( aFnt ); + maValidFromLabelFI.SetFont( aFnt ); + maValidToLabelFI.SetFont( aFnt ); + + // insert data + cssu::Reference< dcss::security::XCertificate > xCert = mpDlg->mxCert; + + String aCN_Id( String::CreateFromAscii( "CN" ) ); + + maIssuedToFI.SetText( XmlSec::GetContentPart( xCert->getSubjectName(), aCN_Id ) ); + maIssuedByFI.SetText( XmlSec::GetContentPart( xCert->getIssuerName(), aCN_Id ) ); + maValidFromFI.SetText( XmlSec::GetDateString( xCert->getNotBefore() ) ); + maValidToFI.SetText( XmlSec::GetDateString( xCert->getNotAfter() ) ); + + // recalc positions for date fields according to real size + Point aPos( maValidFromLabelFI.GetPosPixel() ); +// long nWidth; + +// nWidth = GetTextWidth( maValidFromLabelFI.GetText() ); +// maValidFromLabelFI.SetSizePixel +// aPos.X() += nWidth; + AdjustPosAndSize( maValidFromLabelFI, aPos ); + +// maValidFromFI.SetPosPixel( aPos ); +// nWidth = GetTextWidth( maValidFromFI.GetText() ); +// aPos.X() += nWidth; + AdjustPosAndSize( maValidFromFI, aPos ); + +// maValidToLabelFI.SetPosPixel( aPos ); +// nWidth = GetTextWidth( maValidToLabelFI.GetText() ); +// aPos.X() += nWidth; + +// maValidToFI.SetPosPixel( aPos ); + AdjustPosAndSize( maValidToLabelFI, aPos ); + AdjustPosAndSize( maValidToFI, aPos ); + + // adjust position of fixed text depending on image sizes + long nWidth = maCertImg.GetSizePixel().Width(); + aPos = maCertInfoFI.GetPosPixel(); + aPos.X() = maCertImg.GetPosPixel().X(); + aPos.X() += nWidth; + maCertInfoFI.SetPosPixel( aPos ); + + nWidth = maKeyImg.GetSizePixel().Width(); + aPos = maHintCorrespPrivKeyFI.GetPosPixel(); + aPos.X() = maKeyImg.GetPosPixel().X(); + aPos.X() += nWidth; +// maHintCorrespPrivKeyFI.SetPosPixel( aPos ); + AdjustPosAndSize( maHintCorrespPrivKeyFI, aPos ); +} + +void CertificateViewerGeneralTP::ActivatePage() +{ +} + + +void CertificateViewerDetailsTP::Clear( void ) +{ + maElementML.SetText( String() ); + ULONG i = 0; + SvLBoxEntry* pEntry = maElementsLB.GetEntry( i ); + while( pEntry ) + { + delete ( String* ) pEntry->GetUserData(); + ++i; + pEntry = maElementsLB.GetEntry( i ); + } + + maElementsLB.Clear(); +} + +void CertificateViewerDetailsTP::InsertElement( const String& _rField, const String& _rValue, const String& _rDetails ) +{ + SvLBoxEntry* pEntry = maElementsLB.InsertEntry( _rField ); + maElementsLB.SetEntryText( _rValue, pEntry, 1 ); + pEntry->SetUserData( ( void* ) new String( _rDetails ) ); // extended view of value +// pEntry->SetUserData( ( void* ) new String( XmlSec::GetPureContent( _rValue, "\n", true ) ) ); +} + +CertificateViewerDetailsTP::CertificateViewerDetailsTP( Window* _pParent, CertificateViewer* _pDlg ) + :CertificateViewerTP ( _pParent, XMLSEC_RES( RID_XMLSECTP_DETAILS ), _pDlg ) + ,maElementsLB ( this, ResId( LB_ELEMENTS ) ) + ,maElementML ( this, ResId( ML_ELEMENT ) ) +{ + static long nTabs[] = { 2, 0, 40*CS_LB_WIDTH/100 }; + maElementsLB.SetTabs( &nTabs[ 0 ] ); + maElementsLB.InsertHeaderEntry( String( ResId( STR_HEADERBAR ) ) ); + + // fill list box + Reference< security::XCertificate > xCert = mpDlg->mxCert; + String aLBEntry; + String aDetails; + aLBEntry = aDetails = String::CreateFromInt32( xCert->getVersion() ); + InsertElement( String( ResId( STR_VERSION ) ), aLBEntry, aDetails ); + Sequence< sal_Int8 > aSerNumSeq = xCert->getSerialNumber(); + const sal_Int8* pSerNumSeq = aSerNumSeq.getConstArray(); + int nCnt = aSerNumSeq.getLength(); + String aSerNumStr; + const char pHexDigs[ 17 ] = "0123456789ABCEDF"; + char pBuffer[ 4 ] = " "; + UINT8 nNum; + for( int i = 0 ; i < nCnt ; ++i ) + { + nNum = UINT8( pSerNumSeq[ i ] ); + pBuffer[ 0 ] = pHexDigs[ nNum & 0x0F ]; + nNum >>= 4; + pBuffer[ 1 ] = pHexDigs[ nNum ]; +// aSerNumStr += String::CreateFromInt32( UINT8( pSerNumSeq[ i ] ), 16 ); +// aSerNumStr.AppendAscii( " " ); + aSerNumStr.AppendAscii( pBuffer ); + } + InsertElement( String( ResId( STR_SERIALNUM ) ), aSerNumStr, aSerNumStr ); + InsertElement( String( ResId( STR_SIGALGORITHM ) ), String::CreateFromAscii( "n/a" ), String() ); + aLBEntry = XmlSec::GetPureContent( xCert->getIssuerName(), ", " ); + aDetails = XmlSec::GetPureContent( xCert->getIssuerName(), "\n", true ); + InsertElement( String( ResId( STR_ISSUER ) ), aLBEntry, aDetails ); + aLBEntry = aDetails = XmlSec::GetDateTimeString( xCert->getNotBefore() ); + InsertElement( String( ResId( STR_VALIDFROM ) ), aLBEntry, aDetails ); + aLBEntry = aDetails = XmlSec::GetDateTimeString( xCert->getNotAfter() ); + InsertElement( String( ResId( STR_VALIDTO ) ), aLBEntry, aDetails ); + aLBEntry = XmlSec::GetPureContent( xCert->getSubjectName(), ", " ); + aDetails = XmlSec::GetPureContent( xCert->getSubjectName(), "\n", true ); + InsertElement( String( ResId( STR_SUBJECT ) ), aLBEntry, aDetails ); + + FreeResource(); + + maElementsLB.SetSelectHdl( LINK( this, CertificateViewerDetailsTP, ElementSelectHdl ) ); +} + +CertificateViewerDetailsTP::~CertificateViewerDetailsTP() +{ + Clear(); +} + +void CertificateViewerDetailsTP::ActivatePage() +{ +} + +IMPL_LINK( CertificateViewerDetailsTP, ElementSelectHdl, void*, EMPTYARG ) +{ + SvLBoxEntry* pEntry = maElementsLB.FirstSelected(); + String aElementText; + if( pEntry ) + { + aElementText = *( ( String* ) pEntry->GetUserData() ); + } + + maElementML.SetText( aElementText ); + + return 0; +} + + + +CertificateViewerCertPathTP::CertificateViewerCertPathTP( Window* _pParent, CertificateViewer* _pDlg ) + :CertificateViewerTP ( _pParent, XMLSEC_RES( RID_XMLSECTP_CERTPATH ), _pDlg ) + ,maCertPathFT ( this, ResId( FT_CERTPATH ) ) + ,maCertPathLB ( this, ResId( LB_SIGNATURES ) ) + ,maCertStatusFT ( this, ResId( FT_CERTSTATUS ) ) + ,maCertStatusML ( this, ResId( ML_CERTSTATUS ) ) +{ + // fill list box + Sequence< Reference< security::XCertificate > > + aCertPath = _pDlg->mxSecurityEnvironment->buildCertificatePath( _pDlg->mxCert ); + const Reference< security::XCertificate >* + pCertPath = aCertPath.getConstArray(); + + String aCN_Id( String::CreateFromAscii( "CN" ) ); + int nCnt = aCertPath.getLength(); + for( int i = 0 ; i < nCnt ; ++i ) + InsertCert( i, XmlSec::GetContentPart( pCertPath[ i ]->getIssuerName(), aCN_Id ), String::CreateFromInt32( i ) ); + + FreeResource(); + + maCertPathLB.SetSelectHdl( LINK( this, CertificateViewerCertPathTP, CertSelectHdl ) ); +} + +CertificateViewerCertPathTP::~CertificateViewerCertPathTP() +{ + Clear(); +} + +void CertificateViewerCertPathTP::ActivatePage() +{ +} + +IMPL_LINK( CertificateViewerCertPathTP, CertSelectHdl, void*, EMPTYARG ) +{ + SvLBoxEntry* pEntry = maCertPathLB.FirstSelected(); + String aStatus; + if( pEntry ) + aStatus = *( ( String* ) pEntry->GetUserData() ); + + maCertStatusML.SetText( aStatus ); + + return 0; +} + +void CertificateViewerCertPathTP::Clear( void ) +{ + maCertStatusML.SetText( String() ); + ULONG i = 0; + SvLBoxEntry* pEntry = maCertPathLB.GetEntry( i ); + while( pEntry ) + { + delete ( String* ) pEntry->GetUserData(); + ++i; + pEntry = maCertPathLB.GetEntry( i ); + } + + maCertPathLB.Clear(); +} + +void CertificateViewerCertPathTP::InsertCert( int _nLevel, const String& _rName, const String& _rStatus ) +{ + SvLBoxEntry* pEntry = maCertPathLB.InsertEntry( _rName ); + pEntry->SetUserData( ( void* ) new String( _rStatus ) ); +} diff --git a/xmlsecurity/source/dialogs/certificateviewer.src b/xmlsecurity/source/dialogs/certificateviewer.src new file mode 100644 index 000000000000..3749294bdfc1 --- /dev/null +++ b/xmlsecurity/source/dialogs/certificateviewer.src @@ -0,0 +1,334 @@ +/************************************************************************* + * + * $RCSfile: certificateviewer.src,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:23 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#include "dialogs.hrc" + +TabDialog RID_XMLSECDLG_CERTVIEWER +{ + // HelpID = HID_XMLSECDLG_CERTVIEWER; + Size = MAP_APPFONT( TD_WIDTH, TD_HEIGHT ); + OutputSize = TRUE; + Closeable = TRUE; + Moveable = TRUE; + SVLook = TRUE; + + Text = "View Certificate"; + Text [ en-US ] = "View Certificate"; + TabControl 1 + { + Pos = MAP_APPFONT( TD_SP_INNERBORDER_LEFT, TD_SP_INNERBORDER_TOP ); + Size = MAP_APPFONT( TP_WIDTH, TP_HEIGHT+RIDDER_HEIGHT ); + SVLook = TRUE ; + PageList = + { + PageItem + { + Identifier = RID_XMLSECTP_GENERAL; + Text = "General"; + Text [ en-US ] = "General"; + }; + PageItem + { + Identifier = RID_XMLSECTP_DETAILS; + Text = "Details"; + Text [ en-US ] = "Details"; + }; + PageItem + { + Identifier = RID_XMLSECTP_CERTPATH; + Text = "Certification Path"; + Text [ en-US ] = "Certification Path"; + }; + }; + }; + OKButton BTN_OK + { + Pos = MAP_APPFONT( CV_COL_A, CV_ROW_A ); + Size = MAP_APPFONT( RSC_CD_PUSHBUTTON_WIDTH, RSC_CD_PUSHBUTTON_HEIGHT ); + DefButton = TRUE; + }; + HelpButton BTN_HELP + { + Pos = MAP_APPFONT( CV_COL_C, CV_ROW_A ); + Size = MAP_APPFONT( RSC_CD_PUSHBUTTON_WIDTH, RSC_CD_PUSHBUTTON_HEIGHT ); + }; +}; + +TabPage RID_XMLSECTP_GENERAL +{ +// HelpId = HID_XMLSECTP_GENERAL; + Size = MAP_APPFONT( TP_WIDTH, TP_HEIGHT ); + OutputSize = TRUE; + Hide = TRUE; + SVLook = TRUE; + Window WIN_FRAME + { + SVLook = TRUE; + Border = TRUE; + Pos = MAP_APPFONT( CV_COL_0, CV_ROW_0 ); + Size = MAP_APPFONT( CV_CONT_WIDTH, CV_CONT_HEIGHT ); + }; + FixedImage IMG_CERT + { + Pos = MAP_APPFONT( CW_COL_0, CW_ROW_0 ); + Size = MAP_APPFONT( CW_COL_2-CW_COL_0, CW_ROW_2-CW_ROW_0 ); +// Fixed = Image +// { +// ImageBitmap = Bitmap { File = "xmlsec_cert_l.bmp"; }; +// MaskColor = STD_MASKCOLOR; +// }; + }; + FixedText FI_CERTINFO + { + Pos = MAP_APPFONT( CW_COL_3, CW_ROW_1 ); + Size = MAP_APPFONT( CW_COL_5-CW_COL_3, RSC_CD_FIXEDTEXT_HEIGHT ); + Text = " Certificate Information"; + Text [ en-US ] = " Certificate Information"; + }; + FixedLine FL_SEP1 + { + Pos = MAP_APPFONT( CW_COL_0, CW_ROW_3 ); + Size = MAP_APPFONT( CW_COL_5-CW_COL_0, RSC_CD_FIXEDLINE_HEIGHT ); + }; + FixedText FI_HINTNOTTRUST + { + Pos = MAP_APPFONT( CW_COL_1, CW_ROW_4 ); + Size = MAP_APPFONT( CW_COL_5a-CW_COL_1, CW_ROW_4a-CW_ROW_4 ); + WordBreak = TRUE; + Text = "This CA Root certificate is not trusted. To enable trust, install this certificate in the Trusted Root Certification Authorities store"; + Text [ en-US ] = "This CA Root certificate is not trusted. To enable trust, install this certificate in the Trusted Root Certification Authorities store"; + }; + FixedLine FL_SEP2 + { + Pos = MAP_APPFONT( CW_COL_0, CW_ROW_5 ); + Size = MAP_APPFONT( CW_COL_5-CW_COL_0, RSC_CD_FIXEDLINE_HEIGHT ); + }; + FixedText FI_ISSTOLABEL + { + Pos = MAP_APPFONT( CW_COL_1, CW_ROW_6 ); + Size = MAP_APPFONT( CW_COL_4-CW_COL_1-1, RSC_CD_FIXEDTEXT_HEIGHT ); + Text = "Issued to:"; + Text [ en-US ] = "Issued to:"; + }; + FixedText FI_ISSTO + { + Pos = MAP_APPFONT( CW_COL_4, CW_ROW_6 ); + Size = MAP_APPFONT( CW_COL_5-CW_COL_4, RSC_CD_FIXEDTEXT_HEIGHT ); + }; + FixedText FI_ISSBYLABEL + { + Pos = MAP_APPFONT( CW_COL_1, CW_ROW_7 ); + Size = MAP_APPFONT( CW_COL_4-CW_COL_1-1, RSC_CD_FIXEDTEXT_HEIGHT ); + Text = "Issued by:"; + Text [ en-US ] = "Issued by:"; + }; + FixedText FI_ISSBY + { + Pos = MAP_APPFONT( CW_COL_4, CW_ROW_7 ); + Size = MAP_APPFONT( CW_COL_5-CW_COL_4, RSC_CD_FIXEDTEXT_HEIGHT ); + }; + FixedText FI_VALFROMLABEL + { + Pos = MAP_APPFONT( CW_COL_1, CW_ROW_8 ); + Size = MAP_APPFONT( CW_COL_4a-CW_COL_1-1, RSC_CD_FIXEDTEXT_HEIGHT ); + Text = "Valid from "; + Text [ en-US ] = "Valid from "; + }; + FixedText FI_VALFROM + { + Pos = MAP_APPFONT( CW_COL_4a, CW_ROW_8 ); + Size = MAP_APPFONT( CW_COL_4b-CW_COL_4a, RSC_CD_FIXEDTEXT_HEIGHT ); + }; + FixedText FI_VALTOLABEL + { + Pos = MAP_APPFONT( CW_COL_4c, CW_ROW_8 ); + Size = MAP_APPFONT( CW_COL_4d-CW_COL_4c, RSC_CD_FIXEDTEXT_HEIGHT ); + Text = " to "; + Text [ en-US ] = " to "; + }; + FixedText FI_VALTO + { + Pos = MAP_APPFONT( CW_COL_4e, CW_ROW_8 ); + Size = MAP_APPFONT( CW_COL_5-CW_COL_4e, RSC_CD_FIXEDTEXT_HEIGHT ); + }; + FixedImage IMG_KEY + { + Pos = MAP_APPFONT( CW_COL_0, CW_ROW_9 ); + Size = MAP_APPFONT( CW_COL_2-CW_COL_0, CW_ROW_11-CW_ROW_9 ); +// Fixed = Image +// { +// ImageBitmap = Bitmap { File = "xmlsec_key.bmp"; }; +// MaskColor = STD_MASKCOLOR; +// }; + }; + FixedText FI_CORRPRIVKEY + { + Pos = MAP_APPFONT( CW_COL_1a, CW_ROW_10 ); + Size = MAP_APPFONT( CW_COL_5-CW_COL_1a, RSC_CD_FIXEDTEXT_HEIGHT ); + Text = "You have a private key that corresponds to this certificate."; + Text [ en-US ] = "You have a private key that corresponds to this certificate."; + }; +}; + +TabPage RID_XMLSECTP_DETAILS +{ +// HelpId = HID_XMLSECTP_DETAILS; + Size = MAP_APPFONT( TP_WIDTH, TP_HEIGHT ); + OutputSize = TRUE; + Hide = TRUE; + SVLook = TRUE; + Control LB_ELEMENTS + { + Pos = MAP_APPFONT( CV_COL_0, CV_ROW_0 ); + Size = MAP_APPFONT( CV_CONT_WIDTH, CV_ROW_1-CV_ROW_0 ); + SVLook = TRUE; + Border = TRUE; + }; + String STR_HEADERBAR + { + Text = "Field\tValue"; + Text [ en-US ] = "Field\tValue"; + }; + MultiLineEdit ML_ELEMENT + { + Pos = MAP_APPFONT( CV_COL_0, CV_ROW_2 ); + Size = MAP_APPFONT( CV_CONT_WIDTH, CV_ROW_3-CV_ROW_2 ); + ReadOnly = TRUE; + Border = TRUE; + }; + String STR_VERSION + { + Text = "Version"; + Text [ en-US ] = "Version"; + }; + String STR_SERIALNUM + { + Text = "Serial Number"; + Text [ en-US ] = "Serial Number"; + }; + String STR_SIGALGORITHM + { + Text = "Signature Algorithm"; + Text [ en-US ] = "Signature Algorithm"; + }; + String STR_ISSUER + { + Text = "Issuer"; + Text [ en-US ] = "Issuer"; + }; + String STR_VALIDFROM + { + Text = "Valid From"; + Text [ en-US ] = "Valid From"; + }; + String STR_VALIDTO + { + Text = "Valid to"; + Text [ en-US ] = "Valid to"; + }; + String STR_SUBJECT + { + Text = "Subject"; + Text [ en-US ] = "Subject"; + }; + String STR_PUBKEY + { + Text = "Public Key"; + Text [ en-US ] = "Public Key"; + }; +}; + +TabPage RID_XMLSECTP_CERTPATH +{ +// HelpId = HID_XMLSECTP_CERTPATH; + Size = MAP_APPFONT( TP_WIDTH, TP_HEIGHT ); + OutputSize = TRUE; + Hide = TRUE; + SVLook = TRUE; + FixedText FT_CERTPATH + { + Pos = MAP_APPFONT( CV_COL_0, CV_ROW_0 ); + Size = MAP_APPFONT( CV_CONT_WIDTH, RSC_CD_FIXEDTEXT_HEIGHT ); + Text = "Certification path"; + Text [ en-US ] = "Certification path"; + }; + Control LB_SIGNATURES + { + Pos = MAP_APPFONT( CV_COL_0, CV_ROW_0A ); + Size = MAP_APPFONT( CV_CONT_WIDTH, CV_ROW_1-CV_ROW_0A ); + SVLook = TRUE; + Border = TRUE; + }; + FixedText FT_CERTSTATUS + { + Pos = MAP_APPFONT( CV_COL_0, CV_ROW_2 ); + Size = MAP_APPFONT( CV_CONT_WIDTH, RSC_CD_FIXEDTEXT_HEIGHT ); + Text = "Certification status"; + Text [ en-US ] = "Certification status"; + }; + MultiLineEdit ML_CERTSTATUS + { + Pos = MAP_APPFONT( CV_COL_0, CV_ROW_2A ); + Size = MAP_APPFONT( CV_CONT_WIDTH, CV_ROW_3-CV_ROW_2A ); + ReadOnly = TRUE; + Border = TRUE; + }; +}; diff --git a/xmlsecurity/source/dialogs/dialogs.hrc b/xmlsecurity/source/dialogs/dialogs.hrc new file mode 100644 index 000000000000..eda9da08473a --- /dev/null +++ b/xmlsecurity/source/dialogs/dialogs.hrc @@ -0,0 +1,263 @@ +/************************************************************************* + * + * $RCSfile: dialogs.hrc,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:23 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. +* + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _DIALOGS_HRC +#define _DIALOGS_HRC + +#include + + +#define STD_MASKCOLOR Color{Red=0xffff;Green=0x0000;Blue=0xffff;} + +// --------- general dialog ids --------- + +#define RID_XMLSECDLG_DIGSIG 1000 +#define RID_XMLSECDLG_CERTCHOOSER 1001 +#define RID_XMLSECDLG_CERTVIEWER 1002 +#define RID_XMLSECTP_GENERAL 1003 +#define RID_XMLSECTP_DETAILS 1004 +#define RID_XMLSECTP_CERTPATH 1005 + +#define FL_BOTTOM_SEP 50 +#define BTN_OK 51 +#define BTN_CANCEL 52 +#define BTN_HELP 53 +#define LB_SIGNATURES 54 +#define BTN_VIEWCERT 55 +#define STR_HEADERBAR 56 + +// --------- general metrics --------- +#define DLGS_WIDTH 287 +#define DLGS_HEIGHT 195 +// --------- ... for tab dialogs ----- +#define TP_WIDTH 260 +#define TP_HEIGHT 185 +#define RIDDER_HEIGHT (RSC_CD_PUSHBUTTON_HEIGHT) +#define TD_SP_INNERBORDER_LEFT 3 +#define TD_SP_INNERBORDER_RIGHT 3 +#define TD_SP_INNERBORDER_TOP 3 +#define TD_SP_INNERBORDER_BOTTOM 3 +#define TD_WIDTH (TP_WIDTH+TD_SP_INNERBORDER_LEFT+TD_SP_INNERBORDER_RIGHT) +#define TD_HEIGHT (TP_HEIGHT+TD_SP_INNERBORDER_TOP+2*TD_SP_INNERBORDER_BOTTOM+RSC_CD_PUSHBUTTON_HEIGHT+RIDDER_HEIGHT) + +#define SEP_FL_SPACE_Y 6 +#define SEP_FL_ADJ_Y(val) (val-3) +#define DLGS_BOTTOM_BTN_L(dlgh) (dlgh-RSC_SP_DLG_INNERBORDER_BOTTOM) +#define DLGS_BOTTOM_BTN_Y(dlgh) (DLGS_BOTTOM_BTN_L(dlgh)-RSC_CD_PUSHBUTTON_HEIGHT) +#define DLGS_BOTTOM_FL_Y(dlgh) (DLGS_BOTTOM_BTN_Y(dlgh)-SEP_FL_SPACE_Y-5) +#define DLGS_BOTTOM_LAST_CTRL_L(dlgh) (DLGS_BOTTOM_BTN_Y(dlgh)-2*SEP_FL_SPACE_Y-3) +#define DLGS_BOTTOM_HELP_X(dlgw) (dlgw-RSC_SP_DLG_INNERBORDER_RIGHT-RSC_CD_PUSHBUTTON_WIDTH) +#define DLGS_BOTTOM_CANCEL_X(dlgw) (DLGS_BOTTOM_HELP_X(dlgw)-RSC_SP_CTRL_X-RSC_CD_PUSHBUTTON_WIDTH) +#define DLGS_BOTTOM_OK_X(dlgw) (DLGS_BOTTOM_CANCEL_X(dlgw)-RSC_SP_CTRL_X-RSC_CD_PUSHBUTTON_WIDTH) + + +// --------- dialog Digital Signatures --------- +#define BTN_ADDCERT 2 +#define BTN_REMOVECERT 3 +#define FT_HINT_DOC 4 +#define FT_HINT_BASIC 5 +#define FT_HINT_PACK 6 + +//#define DS_WIDTH DLGS_WIDTH +//#define DS_HEIGHT DLGS_HEIGHT +#define DS_BTNWIDTH_1 70 +#define DS_BTNSPACE_X RSC_SP_CTRL_X +#define DS_WIDTH (RSC_SP_DLG_INNERBORDER_LEFT+RSC_SP_DLG_INNERBORDER_RIGHT+2*DS_BTNSPACE_X+3*DS_BTNWIDTH_1) +#define DS_HEIGHT (DLGS_WIDTH*2/3) + +#define DS_COL_0 RSC_SP_DLG_INNERBORDER_LEFT +//#define DS_COL_MID (DS_WIDTH/2) +//#define DS_COL_3 (DS_COL_MID-(DS_BTNWIDTH_1/2)) +//#define DS_COL_4 (DS_COL_2+DS_BTNWIDTH_1) +//#define DS_COL_2 (DS_COL_3-DS_BTNSPACE_X) +//#define DS_COL_1 (DS_COL_2-DS_BTNWIDTH_1) +#define DS_COL_1 DS_COL_0 +#define DS_COL_2 (DS_COL_1+DS_BTNWIDTH_1) +#define DS_COL_3 (DS_COL_2+DS_BTNSPACE_X) +#define DS_COL_4 (DS_COL_3+DS_BTNWIDTH_1) +#define DS_COL_5 (DS_COL_4+DS_BTNSPACE_X) +//#define DS_COL_6 (DS_COL_5+DS_BTNWIDTH_1) +#define DS_COL_7 (DS_WIDTH-RSC_SP_DLG_INNERBORDER_RIGHT) +#define DS_COL_6 DS_COL_7 + +#define DS_ROW_0 RSC_SP_DLG_INNERBORDER_TOP +#define DS_ROW_1 (DS_ROW_0+RSC_CD_FIXEDTEXT_HEIGHT+RSC_SP_CTRL_DESC_X) +#define DS_ROW_7 DLGS_BOTTOM_BTN_L(DS_HEIGHT) +#define DS_ROW_6 DLGS_BOTTOM_BTN_Y(DS_HEIGHT) +#define DS_ROW_5 DLGS_BOTTOM_FL_Y(DS_HEIGHT) +#define DS_ROW_4 DLGS_BOTTOM_LAST_CTRL_L(DS_HEIGHT) +#define DS_ROW_3 (DS_ROW_4-RSC_CD_PUSHBUTTON_HEIGHT) +#define DS_ROW_2 (DS_ROW_3-RSC_SP_CTRL_Y) + +#define DS_LB_WIDTH (DS_COL_7-DS_COL_0) + +// --------- dialog Ceritficate chooser --------- +#define FT_HINT_SELECT 1 + +#define CS_WIDTH DLGS_WIDTH +#define CS_HEIGHT DLGS_HEIGHT +#define CS_BTNWIDTH_1 DS_BTNWIDTH_1 + +#define CS_COL_0 RSC_SP_DLG_INNERBORDER_LEFT +#define CS_COL_2 (CS_WIDTH-RSC_SP_DLG_INNERBORDER_RIGHT) +#define CS_COL_1 (CS_COL_2-CS_BTNWIDTH_1) + +#define CS_ROW_0 RSC_SP_DLG_INNERBORDER_TOP +#define CS_ROW_1 (CS_ROW_0+RSC_CD_FIXEDTEXT_HEIGHT+RSC_SP_CTRL_DESC_X) +#define CS_ROW_4 DLGS_BOTTOM_LAST_CTRL_L(CS_HEIGHT) +#define CS_ROW_3 (CS_ROW_4-RSC_CD_PUSHBUTTON_HEIGHT) +#define CS_ROW_2 (CS_ROW_3-RSC_SP_CTRL_Y) + +#define CS_LB_WIDTH (CS_COL_2-CS_COL_0) + +// --------- tab dialog Certificate viewer --------- + +#define CV_COL_0 TD_SP_INNERBORDER_LEFT +#define CV_COL_1 (TP_WIDTH-RSC_SP_TBPG_INNERBORDER_RIGHT) +#define CV_ROW_0 RSC_SP_TBPG_INNERBORDER_TOP +#define CV_ROW_3 (TP_HEIGHT-RSC_SP_TBPG_INNERBORDER_BOTTOM) +#define CV_CONT_WIDTH (CV_COL_1-CV_COL_0) +#define CV_CONT_HEIGHT (CV_ROW_3-CV_ROW_0) +#define CV_ROW_1 (CV_ROW_0+2*CV_CONT_HEIGHT/3) +#define CV_ROW_2 (CV_ROW_1+RSC_SP_CTRL_GROUP_Y) + +#define CV_COL_D (TD_WIDTH-TD_SP_INNERBORDER_RIGHT) +#define CV_COL_C (CV_COL_D-RSC_CD_PUSHBUTTON_WIDTH) +#define CV_COL_B (CV_COL_C-RSC_SP_CTRL_X) +#define CV_COL_A (CV_COL_B-RSC_CD_PUSHBUTTON_WIDTH) + +#define CV_ROW_B (TD_HEIGHT-TD_SP_INNERBORDER_BOTTOM) +#define CV_ROW_A (CV_ROW_B-RSC_CD_PUSHBUTTON_HEIGHT) + +// --------- tab page Certificate viewer - General --------- +#define WIN_FRAME 2 +#define IMG_CERT 3 +#define FI_CERTINFO 4 +#define FL_SEP1 5 +#define FI_HINTNOTTRUST 6 +#define FL_SEP2 7 +#define FI_ISSTOLABEL 8 +#define FI_ISSTO 9 +#define FI_ISSBYLABEL 10 +#define FI_ISSBY 11 +#define FI_VALFROMLABEL 12 +#define FI_VALFROM 13 +#define FI_VALTOLABEL 14 +#define FI_VALTO 15 +#define IMG_KEY 16 +#define FI_CORRPRIVKEY 17 + +#define IMG1_WIDTH 33 +#define IMG1_HEIGHT 22 +#define IMG2_WIDTH 20 +#define IMG2_HEIGHT 20 +#define DATE_WIDTH 30 +#define CW_COL_0 (CV_COL_0+RSC_SP_GRP_INNERBORDER_LEFT) +#define CW_COL_1 (CW_COL_0+RSC_SP_FLGR_SPACE_X) +#define CW_COL_1a (CW_COL_0+IMG2_WIDTH+1) +#define CW_COL_2 (CW_COL_0+IMG1_WIDTH) +#define CW_COL_3 (CW_COL_2+RSC_SP_CTRL_GROUP_X) +#define CW_COL_4 (CW_COL_1+40) +#define CW_COL_5 (CV_CONT_WIDTH-RSC_SP_GRP_INNERBORDER_RIGHT) +#define CW_COL_5a (CW_COL_5-RSC_SP_GRP_INNERBORDER_RIGHT) +#define CW_COL_4a (CW_COL_1+38) +#define CW_COL_4b (CW_COL_4a+DATE_WIDTH) +#define CW_COL_4c (CW_COL_4b+3) +#define CW_COL_4d (CW_COL_4c+8) +#define CW_COL_4e (CW_COL_4d+3) +#define CW_ROW_0 (CV_ROW_0+RSC_SP_GRP_INNERBORDER_TOP) +#define CW_ROW_1 (CW_ROW_0+RSC_SP_GRP_INNERBORDER_TOP) +#define CW_ROW_2 (CW_ROW_0+IMG1_HEIGHT) +#define CW_ROW_3 (CW_ROW_2+3) +#define CW_ROW_4 (CW_ROW_3+RSC_SP_CTRL_Y+RSC_CD_FIXEDLINE_HEIGHT) +#define CW_ROW_4a (CW_ROW_4+35) +#define CW_ROW_5 (CW_ROW_4a+3) +#define CW_ROW_6 (CW_ROW_5+RSC_SP_CTRL_Y+RSC_CD_FIXEDLINE_HEIGHT) +#define CW_ROW_7 (CW_ROW_6+RSC_SP_CTRL_Y+RSC_CD_FIXEDTEXT_HEIGHT) +#define CW_ROW_8 (CW_ROW_7+RSC_SP_CTRL_Y+RSC_CD_FIXEDTEXT_HEIGHT) +#define CW_ROW_9 (CW_ROW_8+RSC_SP_CTRL_Y+RSC_CD_FIXEDTEXT_HEIGHT) +#define CW_ROW_10 (CW_ROW_9+2) +#define CW_ROW_11 (CW_ROW_9+IMG2_HEIGHT) + +// --------- tab page Certificate viewer - Details --------- + +#define LB_ELEMENTS 1 +#define ML_ELEMENT 2 + +#define STR_VERSION 1 +#define STR_SERIALNUM 2 +#define STR_SIGALGORITHM 3 +#define STR_ISSUER 4 +#define STR_VALIDFROM 5 +#define STR_VALIDTO 6 +#define STR_SUBJECT 7 +#define STR_PUBKEY 8 + +// --------- tab page Certificate viewer - Certification Path --------- + +#define FT_CERTPATH 1 +#define FT_CERTSTATUS 2 +#define ML_CERTSTATUS 3 + +#define CV_ROW_0A (CV_ROW_0+RSC_SP_CTRL_DESC_Y+RSC_CD_FIXEDTEXT_HEIGHT) +#define CV_ROW_2A (CV_ROW_2+RSC_SP_CTRL_DESC_Y+RSC_CD_FIXEDTEXT_HEIGHT) + +#endif diff --git a/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx b/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx new file mode 100644 index 000000000000..65650a5645ea --- /dev/null +++ b/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx @@ -0,0 +1,545 @@ +/************************************************************************* + * + * $RCSfile: digitalsignaturesdialog.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:24 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#include +#include +#include + +#ifndef _COM_SUN_STAR_EMBED_XSTORAGE_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_EMBED_ELEMENTMODES_HPP_ +#include +#endif +#include +#include +#include + +// Only needed until sig is in storage: +#include + +/*- + * deleted by AF. base64.h is a mozilla nss file, this file should not depend + * on nss/nspr. + */ +//#include + +#if OSL_DEBUG_LEVEL > 1 +#include +#endif + +#include + +#include "dialogs.hrc" +#include "resourcemanager.hxx" + +// MM : added for password exception +#include +using namespace ::com::sun::star::security; + +/* HACK: disable some warnings for MS-C */ +#ifdef _MSC_VER +#pragma warning (disable : 4355) // 4355: this used in initializer-list +#endif + +using namespace ::com::sun::star; +using namespace ::com::sun::star; + +DigitalSignaturesDialog::DigitalSignaturesDialog( Window* pParent, uno::Reference< lang::XMultiServiceFactory >& rxMSF, DocumentSignatureMode eMode ) + :ModalDialog ( pParent, XMLSEC_RES( RID_XMLSECDLG_DIGSIG ) ) + ,maSignatureHelper ( rxMSF ) + ,meSignatureMode ( eMode ) + ,maHintDocFT ( this, ResId( FT_HINT_DOC ) ) + ,maHintBasicFT ( this, ResId( FT_HINT_BASIC ) ) + ,maHintPackageFT ( this, ResId( FT_HINT_PACK ) ) + ,maSignaturesLB ( this, ResId( LB_SIGNATURES ) ) + ,maViewBtn ( this, ResId( BTN_VIEWCERT ) ) + ,maAddBtn ( this, ResId( BTN_ADDCERT ) ) + ,maRemoveBtn ( this, ResId( BTN_REMOVECERT ) ) + ,maBottomSepFL ( this, ResId( FL_BOTTOM_SEP ) ) + ,maOKBtn ( this, ResId( BTN_OK ) ) + ,maCancelBtn ( this, ResId( BTN_CANCEL ) ) + ,maHelpBtn ( this, ResId( BTN_HELP ) ) +{ + static long nTabs[] = { 3, 0, 32*DS_LB_WIDTH/100, 64*DS_LB_WIDTH/100 }; + maSignaturesLB.SetTabs( &nTabs[ 0 ] ); + maSignaturesLB.InsertHeaderEntry( String( ResId( STR_HEADERBAR ) ) ); + + FreeResource(); + mbVerifySignatures = true; + + maSignaturesLB.SetSelectHdl( LINK( this, DigitalSignaturesDialog, SignatureHighlightHdl ) ); + maSignaturesLB.SetDoubleClickHdl( LINK( this, DigitalSignaturesDialog, SignatureSelectHdl ) ); + + maViewBtn.SetClickHdl( LINK( this, DigitalSignaturesDialog, ViewButtonHdl ) ); + maViewBtn.Disable(); + + maAddBtn.SetClickHdl( LINK( this, DigitalSignaturesDialog, AddButtonHdl ) ); + + maRemoveBtn.SetClickHdl( LINK( this, DigitalSignaturesDialog, RemoveButtonHdl ) ); + maRemoveBtn.Disable(); + + switch( meSignatureMode ) + { + case SignatureModeDocumentContent: maHintDocFT.Show(); break; + case SignatureModeMacros: maHintBasicFT.Show(); break; + case SignatureModePackage: maHintPackageFT.Show(); break; + } +} + +DigitalSignaturesDialog::~DigitalSignaturesDialog() +{ +} + +BOOL DigitalSignaturesDialog::Init( const rtl::OUString& rTokenName ) +{ + bool bInit = maSignatureHelper.Init( rTokenName ); + + DBG_ASSERT( bInit, "Error initializing security context!" ); + + if ( bInit ) + { + maSignatureHelper.SetStartVerifySignatureHdl( LINK( this, DigitalSignaturesDialog, StartVerifySignatureHdl ) ); + } + + return bInit; +} + +void DigitalSignaturesDialog::SetStorage( const com::sun::star::uno::Reference < com::sun::star::embed::XStorage >& rxStore ) +{ + mxStore = rxStore; + maSignatureHelper.SetStorage( mxStore ); +} + + + +short DigitalSignaturesDialog::Execute() +{ + // Verify Signatures and add certificates to ListBox... + mbVerifySignatures = true; + ImplGetSignatureInformations(); + ImplFillSignaturesBox(); + + // Only verify once, content will not change. + // But for refreshing signature information, StartVerifySignatureHdl will be called after each add/remove + mbVerifySignatures = false; + + short nRet = Dialog::Execute(); + + return nRet; +} + +IMPL_LINK( DigitalSignaturesDialog, SignatureHighlightHdl, void*, EMPTYARG ) +{ + bool bSel = maSignaturesLB.FirstSelected() != 0; + maViewBtn.Enable( bSel ); + maRemoveBtn.Enable( bSel ); + return 0; +} + +IMPL_LINK( DigitalSignaturesDialog, SignatureSelectHdl, void*, EMPTYARG ) +{ + ImplShowSignaturesDetails(); + return 0; +} + +IMPL_LINK( DigitalSignaturesDialog, ViewButtonHdl, Button*, EMPTYARG ) +{ + ImplShowSignaturesDetails(); + return 0; +} + +IMPL_LINK( DigitalSignaturesDialog, AddButtonHdl, Button*, EMPTYARG ) +{ + try + { + // Check if we have the password for the key store. + // If no, we don't want to raise an empty dialog. + maSignatureHelper.GetSecurityEnvironment()->getPersonalCertificates(); + + uno::Reference xSecEnv = maSignatureHelper.GetSecurityEnvironment(); + CertificateChooser aChooser( (Window*)this, xSecEnv, aCurrentSignatureInformations ); + if( aChooser.Execute() ) + { + maSignatureHelper.StartMission(); + + sal_Int32 nSecurityId = maSignatureHelper.GetNewSecurityId(); + uno::Reference< ::com::sun::star::security::XCertificate > xCert = aChooser.GetSelectedCertificate(); + maSignatureHelper.SetX509Certificate( nSecurityId, xCert->getIssuerName(), bigIntegerToNumericString( xCert->getSerialNumber() ) ); + + std::vector< rtl::OUString > aElements = CreateElementList( mxStore, rtl::OUString(), meSignatureMode ); + + ::rtl::OUString aXMLExt( RTL_CONSTASCII_USTRINGPARAM( "XML" ) ); + sal_Int32 nElements = aElements.size(); + for ( sal_Int32 n = 0; n < nElements; n++ ) + { + bool bBinaryMode = true; + sal_Int32 nSep = aElements[n].lastIndexOf( '.' ); + if ( nSep != (-1) ) + { + ::rtl::OUString aExt = aElements[n].copy( nSep+1 ); + if ( aExt.equalsIgnoreAsciiCase( aXMLExt ) ) + bBinaryMode = false; + } + maSignatureHelper.AddForSigning( nSecurityId, aElements[n], aElements[n], bBinaryMode ); + } + + bool bDone = false; + bool bRefreshInformations = false; + + if ( !maSigFileName.getLength() ) + { + ::rtl::OUString aSIGStreamName( RTL_CONSTASCII_USTRINGPARAM( "SIGNATURES" ) ); + uno::Reference < io::XStream > xStream = mxStore->openStreamElement( aSIGStreamName, embed::ElementModes::WRITE ); + uno::Reference< io::XOutputStream > xOutputStream( xStream, uno::UNO_QUERY ); + // CHANGE TO KEEP OLD SIGS WHEN SIG IN STREAM WORKS! + //bDone = maSignatureHelper.CreateAndWriteSignatue( xOutputStream ); + + uno::Reference< com::sun::star::xml::sax::XDocumentHandler> xDocumentHandler = maSignatureHelper.CreateDocumentHandlerWithHeader( xOutputStream); + // Export old signatures... + int nInfos = aCurrentSignatureInformations.size(); + for ( int n = 0; n < nInfos; n++ ) + maSignatureHelper.ExportSignature( xDocumentHandler, aCurrentSignatureInformations[n]); + + // Create a new one... + bDone = maSignatureHelper.CreateAndWriteSignatue( xDocumentHandler ); + + // That's it... + maSignatureHelper.CloseDocumentHandler( xDocumentHandler); + + uno::Reference< embed::XTransactedObject > xTrans( mxStore, uno::UNO_QUERY ); + xTrans->commit(); + uno::Reference< lang::XComponent > xComp( mxStore, uno::UNO_QUERY ); + xComp->dispose(); + } + else + { + SvFileStream* pStream = new SvFileStream( maSigFileName, STREAM_WRITE|STREAM_TRUNC ); + SvLockBytesRef xLockBytes = new SvLockBytes( pStream, TRUE ); + uno::Reference< io::XOutputStream > xOutputStream = new utl::OOutputStreamHelper( xLockBytes ); + + uno::Reference< com::sun::star::xml::sax::XDocumentHandler> xDocumentHandler = maSignatureHelper.CreateDocumentHandlerWithHeader( xOutputStream); + // Export old signatures... + int nInfos = aCurrentSignatureInformations.size(); + for ( int n = 0; n < nInfos; n++ ) + maSignatureHelper.ExportSignature( xDocumentHandler, aCurrentSignatureInformations[n]); + + // Create a new one... + bDone = maSignatureHelper.CreateAndWriteSignatue( xDocumentHandler ); + + // That's it... + maSignatureHelper.CloseDocumentHandler( xDocumentHandler); + } + + maSignatureHelper.EndMission(); + + if ( bDone ) + { + // Can't simply remember current information, need parsing for getting full information :( + ImplGetSignatureInformations(); + ImplFillSignaturesBox(); + } + + } + } + catch (NoPasswordException&) + { + } + + return 0; +} + +IMPL_LINK( DigitalSignaturesDialog, RemoveButtonHdl, Button*, EMPTYARG ) +{ + if( maSignaturesLB.FirstSelected() ) + { + USHORT nSelected = (USHORT) maSignaturesLB.FirstSelected()->GetUserData(); + aCurrentSignatureInformations.erase( aCurrentSignatureInformations.begin()+nSelected ); + + // Export all other signatures... + if ( !maSigFileName.getLength() ) + { + // See AddButtonHdl, later.... + } + else + { + SvFileStream* pStream = new SvFileStream( maSigFileName, STREAM_WRITE|STREAM_TRUNC ); + SvLockBytesRef xLockBytes = new SvLockBytes( pStream, TRUE ); + uno::Reference< io::XOutputStream > xOutputStream = new utl::OOutputStreamHelper( xLockBytes ); + + uno::Reference< css::xml::sax::XDocumentHandler> xDocumentHandler = maSignatureHelper.CreateDocumentHandlerWithHeader( xOutputStream); + + int nInfos = aCurrentSignatureInformations.size(); + for( int n = 0 ; n < nInfos ; ++n ) + maSignatureHelper.ExportSignature( xDocumentHandler, aCurrentSignatureInformations[ n ] ); + + // That's it... + maSignatureHelper.CloseDocumentHandler( xDocumentHandler ); + } + + ImplFillSignaturesBox(); + } + + return 0; +} + +IMPL_LINK( DigitalSignaturesDialog, StartVerifySignatureHdl, void*, EMPTYARG ) +{ + return mbVerifySignatures ? 1 : 0; +} + +void DigitalSignaturesDialog::ImplFillSignaturesBox() +{ + maSignaturesLB.Clear(); + + uno::Reference< ::com::sun::star::xml::crypto::XSecurityEnvironment > xSecEnv = maSignatureHelper.GetSecurityEnvironment(); + uno::Reference< ::com::sun::star::security::XCertificate > xCert; + + String aCN_Id( String::CreateFromAscii( "CN" ) ); + int nInfos = aCurrentSignatureInformations.size(); + for( int n = 0; n < nInfos; ++n ) + { + const SignatureInformation& rInfo = aCurrentSignatureInformations[n]; + xCert = xSecEnv->getCertificate( rInfo.ouX509IssuerName, numericStringToBigInteger( rInfo.ouX509SerialNumber ) ); + + // If we don't get it, create it from signature data: + if ( !xCert.is() ) + xCert = xSecEnv->createCertificateFromAscii( rInfo.ouX509Certificate ) ; + + DBG_ASSERT( xCert.is(), "Certificate not found and can't be created!" ); + + String aSubject; + String aIssuer; + String aDateTimeStr; + if( xCert.is() ) + { + aSubject = XmlSec::GetContentPart( xCert->getSubjectName(), aCN_Id ); + aIssuer = XmlSec::GetContentPart( rInfo.ouX509IssuerName, aCN_Id ); + aDateTimeStr = XmlSec::GetDateString( xCert->getNotAfter() ); + } + else + { +#if OSL_DEBUG_LEVEL > 1 + aSubject = String::CreateFromAscii( "ERROR getting certificate!" ); +#endif + } + SvLBoxEntry* pEntry = maSignaturesLB.InsertEntry( aSubject ); + maSignaturesLB.SetEntryText( aIssuer, pEntry, 1 ); + maSignaturesLB.SetEntryText( aDateTimeStr, pEntry, 2 ); + pEntry->SetUserData( ( void* ) n ); // missuse user data as index + } + +// maViewBtn.Disable(); + SignatureHighlightHdl( NULL ); +} + +void DigitalSignaturesDialog::ImplGetSignatureInformations() +{ + aCurrentSignatureInformations.clear(); + + maSignatureHelper.StartMission(); + + bool bVerifyOK = false; + + if ( maSigFileName.getLength() ) + { + SvFileStream* pStream = new SvFileStream( maSigFileName, STREAM_READ ); + pStream->Seek( STREAM_SEEK_TO_END ); + ULONG nBytes = pStream->Tell(); + pStream->Seek( STREAM_SEEK_TO_BEGIN ); + SvLockBytesRef xLockBytes = new SvLockBytes( pStream, TRUE ); + if ( nBytes ) + { + uno::Reference< io::XInputStream > xInputStream = new utl::OInputStreamHelper( xLockBytes, nBytes ); + bVerifyOK = maSignatureHelper.ReadAndVerifySignatue( xInputStream ); + xInputStream->closeInput(); + } + } + else + { + ::rtl::OUString aSIGStreamName( RTL_CONSTASCII_USTRINGPARAM( "SIGNATURE" ) ); + if ( mxStore->isStreamElement( aSIGStreamName ) ) + { + uno::Reference < io::XStream > xStream = mxStore->openStreamElement( aSIGStreamName, embed::ElementModes::READ ); + uno::Reference< io::XInputStream > xInputStream( xStream, uno::UNO_QUERY ); + bVerifyOK = maSignatureHelper.ReadAndVerifySignatue( xInputStream ); + } + } + + if ( bVerifyOK ) + aCurrentSignatureInformations = maSignatureHelper.GetSignatureInformations(); + + maSignatureHelper.EndMission(); + + mbVerifySignatures = false; +} + +void DigitalSignaturesDialog::ImplShowSignaturesDetails() +{ + if( maSignaturesLB.FirstSelected() ) + { + USHORT nSelected = (USHORT) maSignaturesLB.FirstSelected()->GetUserData(); + const SignatureInformation& rInfo = aCurrentSignatureInformations[ nSelected ]; + uno::Reference< dcss::security::XCertificate > xCert = maSignatureHelper.GetSecurityEnvironment()->getCertificate( rInfo.ouX509IssuerName, numericStringToBigInteger( rInfo.ouX509SerialNumber ) ); + + // If we don't get it, create it from signature data: + if ( !xCert.is() ) + xCert = maSignatureHelper.GetSecurityEnvironment()->createCertificateFromAscii( rInfo.ouX509Certificate ) ; + + DBG_ASSERT( xCert.is(), "Certificate not found and can't be created!" ); + + uno::Reference xSecEnv = maSignatureHelper.GetSecurityEnvironment(); + CertificateViewer aViewer( this, xSecEnv, xCert ); + aViewer.Execute(); + } +} + +void ImplFillElementList( std::vector< rtl::OUString >& rList, uno::Reference < embed::XStorage >& rxStore, const ::rtl::OUString rRootStorageName, bool bRecursive ) +{ + ::rtl::OUString aMetaInfName( RTL_CONSTASCII_USTRINGPARAM( "META-INF" ) ); + ::rtl::OUString aSep( RTL_CONSTASCII_USTRINGPARAM( "/" ) ); + + uno::Reference < container::XNameAccess > xElements( rxStore, uno::UNO_QUERY ); + uno::Sequence< ::rtl::OUString > aElements = xElements->getElementNames(); + sal_Int32 nElements = aElements.getLength(); + const ::rtl::OUString* pNames = aElements.getConstArray(); + for ( sal_Int32 n = 0; n < nElements; n++ ) + { + if ( pNames[n] != aMetaInfName ) + { + if ( rxStore->isStreamElement( pNames[n] ) ) + { + ::rtl::OUString aFullName( rRootStorageName + pNames[n] ); + rList.push_back( aFullName ); + } + else if ( bRecursive && rxStore->isStorageElement( pNames[n] ) ) + { + uno::Reference < embed::XStorage > xSubStore = rxStore->openStorageElement( pNames[n], embed::ElementModes::READ ); + rtl::OUString aFullRootName( rRootStorageName + pNames[n] + aSep ); + ImplFillElementList( rList, rxStore, aFullRootName, bRecursive ); + } + } + } +} + +std::vector< rtl::OUString > DigitalSignaturesDialog::CreateElementList( uno::Reference < embed::XStorage >& rxStore, const ::rtl::OUString rRootStorageName, DocumentSignatureMode eMode ) +{ + std::vector< rtl::OUString > aElements; + ::rtl::OUString aSep( RTL_CONSTASCII_USTRINGPARAM( "/" ) ); + + + switch ( eMode ) + { + case SignatureModeDocumentContent: + { + // 1) Main content + ImplFillElementList( aElements, rxStore, ::rtl::OUString(), false ); + + // 2) Pictures... + rtl::OUString aSubStorageName( rtl::OUString::createFromAscii( "Pictures" ) ); + try + { + uno::Reference < embed::XStorage > xSubStore = rxStore->openStorageElement( aSubStorageName, embed::ElementModes::READ ); + ImplFillElementList( aElements, xSubStore, aSubStorageName+aSep, true ); + } + catch( com::sun::star::io::IOException& ) + { + ; // Doesn't have to exist... + } + } + break; + case SignatureModeMacros: + { + // 1) Macros + rtl::OUString aSubStorageName( rtl::OUString::createFromAscii( "Basic" ) ); + try + { + uno::Reference < embed::XStorage > xSubStore = rxStore->openStorageElement( aSubStorageName, embed::ElementModes::READ ); + ImplFillElementList( aElements, xSubStore, aSubStorageName+aSep, true ); + } + catch( com::sun::star::io::IOException& ) + { + ; // Doesn't have to exist... + } + + // 2) Dialogs + aSubStorageName = rtl::OUString::createFromAscii( "Dialogs") ; + try + { + uno::Reference < embed::XStorage > xSubStore = rxStore->openStorageElement( aSubStorageName, embed::ElementModes::READ ); + ImplFillElementList( aElements, xSubStore, aSubStorageName+aSep, true ); + } + catch( com::sun::star::io::IOException& ) + { + ; // Doesn't have to exist... + } + } + break; + case SignatureModePackage: + { + // Everything except META-INF + ImplFillElementList( aElements, rxStore, ::rtl::OUString(), true ); + } + break; + } + + return aElements; +} diff --git a/xmlsecurity/source/dialogs/digitalsignaturesdialog.src b/xmlsecurity/source/dialogs/digitalsignaturesdialog.src new file mode 100644 index 000000000000..8ea04dc9e2fd --- /dev/null +++ b/xmlsecurity/source/dialogs/digitalsignaturesdialog.src @@ -0,0 +1,159 @@ +/************************************************************************* + * + * $RCSfile: digitalsignaturesdialog.src,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:24 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#include "dialogs.hrc" + +ModalDialog RID_XMLSECDLG_DIGSIG +{ +// HelpId = HID_XMLSECDLG_DIGSIG; + Size = MAP_APPFONT( DS_WIDTH, DS_HEIGHT ); + OutputSize = TRUE; + Closeable = TRUE; + Moveable = TRUE; + SVLook = TRUE; + +// Text = "Digital Signatures"; + Text = "Digital Signatures"; + Text [ en-US ] = "Digital Signatures"; + + FixedText FT_HINT_DOC + { + Pos = MAP_APPFONT( DS_COL_0, DS_ROW_0 ); + Size = MAP_APPFONT( DS_COL_7-DS_COL_0, RSC_CD_FIXEDTEXT_HEIGHT ); + Hide = TRUE; + Text = "The following have signed the document content"; + Text [ en-US ] = "The following have signed the document content"; + }; + FixedText FT_HINT_BASIC + { + Pos = MAP_APPFONT( DS_COL_0, DS_ROW_0 ); + Size = MAP_APPFONT( DS_COL_7-DS_COL_0, RSC_CD_FIXEDTEXT_HEIGHT ); + Hide = TRUE; + Text = "The following have signed the document macro"; + Text [ en-US ] = "The following have signed the document macro"; + }; + FixedText FT_HINT_PACK + { + Pos = MAP_APPFONT( DS_COL_0, DS_ROW_0 ); + Size = MAP_APPFONT( DS_COL_7-DS_COL_0, RSC_CD_FIXEDTEXT_HEIGHT ); + Hide = TRUE; + Text = "The following have signed this package"; + Text [ en-US ] = "The following have signed this package"; + }; +// ListBox LB_SIGNATURES + Control LB_SIGNATURES + { + Pos = MAP_APPFONT( DS_COL_0, DS_ROW_1 ); + Size = MAP_APPFONT( DS_LB_WIDTH, DS_ROW_2-DS_ROW_1 ); + SVLook = TRUE; + Border = TRUE; + }; + String STR_HEADERBAR + { + Text = "Signer\tDigital ID Issued by\tDate"; + Text [ en-US ] = "Signer\tDigital ID Issued by\tDate"; + }; + PushButton BTN_VIEWCERT + { + Pos = MAP_APPFONT( DS_COL_1, DS_ROW_3 ); + Size = MAP_APPFONT( DS_COL_2-DS_COL_1, RSC_CD_PUSHBUTTON_HEIGHT ); +// Text = "Zertifikat anzeigen..."; + Text = "View Certificate..."; + Text [ en-US ] = "View Certificate..."; + }; + PushButton BTN_ADDCERT + { + Pos = MAP_APPFONT( DS_COL_3, DS_ROW_3 ); + Size = MAP_APPFONT( DS_COL_4-DS_COL_3, RSC_CD_PUSHBUTTON_HEIGHT ); +// Text = "Hinzufügen..."; + Text = "Add..."; + Text [ en-US ] = "Add..."; + }; + PushButton BTN_REMOVECERT + { + Pos = MAP_APPFONT( DS_COL_5, DS_ROW_3 ); + Size = MAP_APPFONT( DS_COL_6-DS_COL_5, RSC_CD_PUSHBUTTON_HEIGHT ); +// Text = "Entfernen"; + Text = "Remove"; + Text [ en-US ] = "Remove"; + }; + FixedLine FL_BOTTOM_SEP + { + Pos = MAP_APPFONT( 0, DLGS_BOTTOM_FL_Y( DS_HEIGHT ) ); + Size = MAP_APPFONT( DS_WIDTH, RSC_CD_FIXEDLINE_HEIGHT ); + }; + OKButton BTN_OK + { + DefButton = TRUE; + Pos = MAP_APPFONT( DLGS_BOTTOM_OK_X( DS_WIDTH ), DLGS_BOTTOM_BTN_Y( DS_HEIGHT ) ); + Size = MAP_APPFONT( RSC_CD_PUSHBUTTON_WIDTH, RSC_CD_PUSHBUTTON_HEIGHT ); + }; + CancelButton BTN_CANCEL + { + Pos = MAP_APPFONT( DLGS_BOTTOM_CANCEL_X( DS_WIDTH ), DLGS_BOTTOM_BTN_Y( DS_HEIGHT ) ); + Size = MAP_APPFONT( RSC_CD_PUSHBUTTON_WIDTH, RSC_CD_PUSHBUTTON_HEIGHT ); + }; + HelpButton BTN_HELP + { + Pos = MAP_APPFONT( DLGS_BOTTOM_HELP_X( DS_WIDTH ), DLGS_BOTTOM_BTN_Y( DS_HEIGHT ) ); + Size = MAP_APPFONT( RSC_CD_PUSHBUTTON_WIDTH, RSC_CD_PUSHBUTTON_HEIGHT ); + }; +}; diff --git a/xmlsecurity/source/dialogs/makefile.mk b/xmlsecurity/source/dialogs/makefile.mk new file mode 100644 index 000000000000..bf12824c8e0a --- /dev/null +++ b/xmlsecurity/source/dialogs/makefile.mk @@ -0,0 +1,100 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1.1.1 $ +# +# last change: $Author: mt $ $Date: 2004-07-12 13:15:24 $ +# +# The Contents of this file are made available subject to the terms of +# either of the following licenses +# +# - GNU Lesser General Public License Version 2.1 +# - Sun Industry Standards Source License Version 1.1 +# +# Sun Microsystems Inc., October, 2000 +# +# GNU Lesser General Public License Version 2.1 +# ============================================= +# Copyright 2000 by Sun Microsystems, Inc. +# 901 San Antonio Road, Palo Alto, CA 94303, USA +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License version 2.1, as published by the Free Software Foundation. +# +# This library 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 for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, +# MA 02111-1307 USA +# +# +# Sun Industry Standards Source License Version 1.1 +# ================================================= +# The contents of this file are subject to the Sun Industry Standards +# Source License Version 1.1 (the "License"); You may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at http://www.openoffice.org/license.html. +# +# Software provided under this License is provided on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, +# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, +# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. +# See the License for the specific provisions governing your rights and +# obligations concerning the Software. +# +# The Initial Developer of the Original Code is: Sun Microsystems, Inc. +# +# Copyright: 2000 by Sun Microsystems, Inc. +# +# All Rights Reserved. +# +# Contributor(s): _______________________________________ +# +# +# +#************************************************************************* + +PRJ=..$/.. + +PRJNAME=xmlsecurity +TARGET=dialogs +TARGETTYPE=GUI + + +ENABLE_EXCEPTIONS=TRUE + +# --- Settings ----------------------------------------------------- + +.INCLUDE : svpre.mk +.INCLUDE : settings.mk +.INCLUDE : sv.mk +.INCLUDE : $(PRJ)$/util$/target.pmk + + +# --- Files -------------------------------------------------------- + +BMP_IN=$(PRJ)$/res + +SRS1NAME=dialogs +SRC1FILES = \ + digitalsignaturesdialog.src \ + certificatechooser.src \ + certificateviewer.src + +SLOFILES= \ + $(SLO)$/stbcontrl.obj \ + $(SLO)$/digitalsignaturesdialog.obj \ + $(SLO)$/certificatechooser.obj \ + $(SLO)$/certificateviewer.obj \ + $(SLO)$/resourcemanager.obj + + +# --- Targets ------------------------------------------------------ + +.INCLUDE : target.mk diff --git a/xmlsecurity/source/dialogs/resourcemanager.cxx b/xmlsecurity/source/dialogs/resourcemanager.cxx new file mode 100644 index 000000000000..aa19d487bc3b --- /dev/null +++ b/xmlsecurity/source/dialogs/resourcemanager.cxx @@ -0,0 +1,190 @@ +/************************************************************************* + * + * $RCSfile: resourcemanager.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:24 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#include "resourcemanager.hxx" + +#include +#include + + +namespace XmlSec +{ + static ResMgr* pResMgr = 0; + static International* pInternational = 0; + + ResMgr* GetResMgr( void ) + { + if( !pResMgr ) + { + ByteString aName( "xmlsec" ); + aName += ByteString::CreateFromInt32( SOLARUPD ); +// pResMgr = ResMgr::CreateResMgr( aName.GetBuffer(), Application::GetSettings().GetUILanguage() ); + LanguageType aLang( LANGUAGE_ENGLISH_US ); +// pResMgr = ResMgr::CreateResMgr( aName.GetBuffer(), aLang ); +// MT: Change to Locale + pResMgr = ResMgr::CreateResMgr( aName.GetBuffer()); + } + + return pResMgr; + } + + International* GetInternational( void ) + { + if( !pInternational ) + { + LanguageType aLang( LANGUAGE_ENGLISH_US ); + pInternational = new International( aLang ); + } + return pInternational; + } + + DateTime GetDateTime( const ::com::sun::star::util::DateTime& _rDT ) + { + return DateTime( + Date( _rDT.Day, _rDT.Month, _rDT.Year ), + Time( _rDT.Hours, _rDT.Minutes, _rDT.Seconds, _rDT.HundredthSeconds ) ); + } + + String GetDateTimeString( const ::com::sun::star::util::DateTime& _rDT ) + { + return GetInternational()->GetLongDate( GetDateTime( _rDT ) ); + } + + String GetDateString( const ::com::sun::star::util::DateTime& _rDT ) + { + return GetInternational()->GetLongDate( GetDateTime( _rDT ) ); + } + + String GetPureContent( const String& _rRawString, const char* _pCommaReplacement, bool _bPreserveId ) + { + enum STATE { ID, EQUALSIGN, CONT }; + String s; + STATE e = ID; + + const sal_Unicode* p = _rRawString.GetBuffer(); + sal_Unicode c; + const sal_Unicode cComma = ','; + const sal_Unicode cEqualSign = '='; + String aCommaReplacement; + if( _pCommaReplacement ) + aCommaReplacement = String::CreateFromAscii( _pCommaReplacement ); + + while( *p ) + { + c = *p; + switch( e ) + { + case ID: + if( _bPreserveId ) + s += c; + + if( c == cEqualSign ) + e = CONT; + break; +// case EQUALSIGN: +// break; + case CONT: + if( c == cComma ) + { + s += aCommaReplacement; + e = ID; + } + else + s += c; + break; + } + + ++p; + } + +// xub_StrLen nEquPos = _rRawString.SearchAscii( "=" ); +// if( nEquPos == STRING_NOTFOUND ) +// s = _rRawString; +// else +// { +// ++nEquPos; +// s = String( _rRawString, nEquPos, STRING_MAXLEN ); +// s.EraseLeadingAndTrailingChars(); +// } + + return s; + } + + String GetContentPart( const String& _rRawString, const String& _rPartId ) + { + String s; + + xub_StrLen nContStart = _rRawString.Search( _rPartId ); + if( nContStart != STRING_NOTFOUND ) + { + nContStart += _rPartId.Len(); + ++nContStart; // now it's start of content, directly after Id + + xub_StrLen nContEnd = _rRawString.Search( sal_Unicode( ',' ), nContStart ); + + s = String( _rRawString, nContStart, nContEnd - nContStart ); + } + + return s; + } +} + + diff --git a/xmlsecurity/source/dialogs/resourcemanager.hxx b/xmlsecurity/source/dialogs/resourcemanager.hxx new file mode 100644 index 000000000000..3b215dfbe7bb --- /dev/null +++ b/xmlsecurity/source/dialogs/resourcemanager.hxx @@ -0,0 +1,96 @@ +/************************************************************************* + * + * $RCSfile: resourcemanager.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:24 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _RESOURCEMANAGER_HXX +#define _RESOURCEMANAGER_HXX + +#ifndef _TOOLS_RESMGR_HXX +#include +#endif +#ifndef _TOOLS_INTN_HXX +#include +#endif +#ifndef _DATETIME_HXX +#include +#endif +#ifndef _COM_SUN_STAR_UTIL_DATETIME_HPP_ +#include +#endif + + +namespace XmlSec +{ + ResMgr* GetResMgr( void ); + + International* GetInternational( void ); + DateTime GetDateTime( const ::com::sun::star::util::DateTime& _rDT ); + String GetDateTimeString( const ::com::sun::star::util::DateTime& _rDT ); + String GetDateString( const ::com::sun::star::util::DateTime& _rDT ); + + String GetPureContent( const String& _rRawString, + const char* _pCommaReplacement = ", ", + bool _bPreserveId = false ); // strips "CN=" and so from string + String GetContentPart( const String& _rRawString, const String& _rPartId ); +} + +#define XMLSEC_RES(id) ResId(id,XmlSec::GetResMgr()) + +#endif diff --git a/xmlsecurity/source/dialogs/stbcontrl.cxx b/xmlsecurity/source/dialogs/stbcontrl.cxx new file mode 100644 index 000000000000..a4d92885b424 --- /dev/null +++ b/xmlsecurity/source/dialogs/stbcontrl.cxx @@ -0,0 +1,232 @@ +/************************************************************************* + * + * $RCSfile: stbcontrl.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:24 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRUNTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRUNTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc.. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +// include --------------------------------------------------------------- + +#ifndef _SHL_HXX //autogen +#include +#endif +#ifndef _STATUS_HXX //autogen +#include +#endif +#ifndef _MENU_HXX //autogen +#include +#endif +#ifndef _SV_IMAGE_HXX +#include +#endif +//#ifndef _SFXITEMPOOL_HXX +//#include +//#endif +#ifndef _SFXAPP_HXX +#include +#endif +#ifndef _SFXMODULE_HXX +#include +#endif +#ifndef _SFXDISPATCH_HXX //autogen +#include +#endif +#ifndef _SFX_OBJSH_HXX //autogen +#include +#endif + +#include + + +#include + +#define PAINT_OFFSET 5 + +//#include "sizeitem.hxx" +//#include "dialmgr.hxx" +//#include "dlgutil.hxx" +//#include "stbctrls.h" + +//#include "dialogs.hrc" + +/*#ifndef _UNOTOOLS_LOCALEDATAWRAPPER_HXX +#include +#endif +#ifndef _UNOTOOLS_PROCESSFACTORY_HXX +#include +#endif*/ + + + +SFX_IMPL_STATUSBAR_CONTROL( XmlSecStatusBarControl, SfxBoolItem ); + +/* +class FunctionPopup_Impl : public PopupMenu +{ +public: + FunctionPopup_Impl( USHORT nCheck ); + + USHORT GetSelected() const { return nSelected; } + +private: + USHORT nSelected; + + virtual void Select(); +}; + +// ----------------------------------------------------------------------- + +FunctionPopup_Impl::FunctionPopup_Impl( USHORT nCheck ) : + PopupMenu( ResId( RID_SVXMNU_PSZ_FUNC, DIALOG_MGR() ) ), + nSelected( 0 ) +{ + if (nCheck) + CheckItem( nCheck ); +} + +// ----------------------------------------------------------------------- + +void FunctionPopup_Impl::Select() +{ + nSelected = GetCurItemId(); +} +*/ + + + +struct XmlSecStatusBarControl::XmlSecStatusBarControl_Impl +{ + Point maPos; + Size maSize; + bool mbSigned; + Image maImage; +}; + + +XmlSecStatusBarControl::XmlSecStatusBarControl( USHORT _nId, StatusBar& _rStb, SfxBindings& _rBind ) + :SfxStatusBarControl( _nId, _rStb, _rBind ) + + ,mpImpl( new XmlSecStatusBarControl_Impl ) +{ + mpImpl->mbSigned = false; +// pImp->maImage = Image( ResId( RID_SVXBMP_POSITION, DIALOG_MGR() ) ); +} + +XmlSecStatusBarControl::~XmlSecStatusBarControl() +{ + delete mpImpl; +} + +void XmlSecStatusBarControl::StateChanged( USHORT nSID, SfxItemState eState, const SfxPoolItem* pState ) +{ + GetStatusBar().SetHelpText( GetId(), String() ); // necessary ? + GetStatusBar().SetHelpId( GetId(), nSID ); // necessary ? + + if( SFX_ITEM_AVAILABLE != eState ) + { + mpImpl->mbSigned = false; + } + else if( pState->ISA( SfxBoolItem ) ) + { + mpImpl->mbSigned = ( ( SfxBoolItem* ) pState )->GetValue(); + } + else + { + DBG_ERRORFILE( "+XmlSecStatusBarControl::StateChanged(): invalid item type" ); + mpImpl->mbSigned = false; + } + + if( GetStatusBar().AreItemsVisible() ) // necessary ? + GetStatusBar().SetItemData( GetId(), 0 ); + + GetStatusBar().SetItemText( GetId(), String() ); // necessary ? +} + +void XmlSecStatusBarControl::Command( const CommandEvent& rCEvt ) +{ + // can / has to be done when integrated in Office! +// if( rCEvt.GetCommand() == .... ) + if( false ) + { +// GetBindings().GetDispatcher()->Execute( SID_PSZ_FUNCTION, SFX_CALLMODE_RECORD, &aItem, 0L ); + } + else + SfxStatusBarControl::Command( rCEvt ); +} + +void XmlSecStatusBarControl::Paint( const UserDrawEvent& rUsrEvt ) +{ + OutputDevice* pDev = rUsrEvt.GetDevice(); + DBG_ASSERT( pDev, "-XmlSecStatusBarControl::Paint(): no Output Device... this will lead to nirvana..." ); + const Rectangle& rRect = rUsrEvt.GetRect(); + StatusBar& rBar = GetStatusBar(); + Point aItemPos = rBar.GetItemTextPos( GetId() ); + Color aOldLineColor = pDev->GetLineColor(); + Color aOldFillColor = pDev->GetFillColor(); + + // just 4 testing until we've got a bitmap + pDev->SetLineColor(); + pDev->SetFillColor( pDev->GetBackground().GetColor() ); + + String s( String::CreateFromAscii( mpImpl->mbSigned? "X" : "-" ) ); + pDev->DrawRect( rRect ); + pDev->DrawText( Point( rRect.Left() + rRect.GetWidth() / 2 - pDev->GetTextWidth( s ) / 2, aItemPos.Y() ), s ); + + pDev->SetLineColor( aOldLineColor ); + pDev->SetFillColor( aOldFillColor ); +} + diff --git a/xmlsecurity/source/framework/buffernode.cxx b/xmlsecurity/source/framework/buffernode.cxx new file mode 100644 index 000000000000..148fb3709e0a --- /dev/null +++ b/xmlsecurity/source/framework/buffernode.cxx @@ -0,0 +1,1313 @@ +/************************************************************************* + * + * $RCSfile: buffernode.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:23 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#include "elementmark.hxx" +#include "elementcollector.hxx" +#include "buffernode.hxx" + +#ifndef _COM_SUN_STAR_XML_CRYPTO_SAX_CONSTOFSECURITYID_HPP_ +#include +#endif + +namespace cssu = com::sun::star::uno; +namespace cssxw = com::sun::star::xml::wrapper; +namespace cssxc = com::sun::star::xml::crypto; + +BufferNode::BufferNode( const cssu::Reference< cssxw::XXMLElementWrapper >& xXMLElement ) + :m_xXMLElement(xXMLElement), + m_pParent(NULL), + m_pBlocker(NULL), + m_bAllReceived(false) +{ +} + +bool BufferNode::isECOfBeforeModifyIncluded(sal_Int32 nIgnoredSecurityId) const +/****** BufferNode/isECOfBeforeModifyIncluded ******************************** + * + * NAME + * isECOfBeforeModifyIncluded -- checks whether there is some + * ElementCollector on this BufferNode, that has BEFORE-MODIFY priority. + * + * SYNOPSIS + * bExist = isECOfBeforeModifyIncluded(nIgnoredSecurityId); + * + * FUNCTION + * checks each ElementCollector on this BufferNode, if all following + * conditions are satisfied, then returns true: + * 1. the ElementCollector's priority is PRI_BEFOREMODIFY; + * 2. the ElementCollector's securityId can't be ignored. + * otherwise, returns false. + * + * INPUTS + * nIgnoredSecurityId - the security Id to be ignored. If it equals + * to UNDEFINEDSECURITYID, then no security Id + * will be ignored. + * + * RESULT + * bExist - true if a match found, false otherwise + * + * HISTORY + * 05.01.2004 - implemented + * + * AUTHOR + * Michael Mi + * Email: michael.mi@sun.com + ******************************************************************************/ +{ + bool rc = false; + std::vector< const ElementCollector* >::const_iterator ii = m_vElementCollectors.begin(); + + for( ; ii != m_vElementCollectors.end() ; ++ii ) + { + ElementCollector* pElementCollector = (ElementCollector*)*ii; + + if ((nIgnoredSecurityId == cssxc::sax::ConstOfSecurityId::UNDEFINEDSECURITYID || + pElementCollector->getSecurityId() != nIgnoredSecurityId) && + (pElementCollector->getPriority() == cssxc::sax::ElementMarkPriority_PRI_BEFOREMODIFY)) + { + rc = true; + break; + } + } + + return rc; +} + +void BufferNode::setReceivedAll() +/****** BufferNode/setReceiveAll ********************************************* + * + * NAME + * setReceivedAll -- indicates that the element in this BufferNode has + * been compeletely bufferred. + * + * SYNOPSIS + * setReceivedAll(); + * + * FUNCTION + * sets the all-received flag and launches ElementCollector's notify + * process. + * + * INPUTS + * empty + * + * RESULT + * empty + * + * HISTORY + * 05.01.2004 - implemented + * + * AUTHOR + * Michael Mi + * Email: michael.mi@sun.com + ******************************************************************************/ +{ + m_bAllReceived = true; + elementCollectorNotify(); +} + +bool BufferNode::isAllReceived() const +{ + return m_bAllReceived; +} + +void BufferNode::addElementCollector(const ElementCollector* pElementCollector) +/****** BufferNode/addElementCollector *************************************** + * + * NAME + * addElementCollector -- adds a new ElementCollector to this BufferNode. + * + * SYNOPSIS + * addElementCollector(pElementCollector); + * + * FUNCTION + * see NAME + * + * INPUTS + * pElementCollector - the ElementCollector to be added + * + * RESULT + * empty + * + * HISTORY + * 05.01.2004 - implemented + * + * AUTHOR + * Michael Mi + * Email: michael.mi@sun.com + ******************************************************************************/ +{ + m_vElementCollectors.push_back( pElementCollector ); + ((ElementCollector*)pElementCollector)->setBufferNode(this); +} + +void BufferNode::removeElementCollector(const ElementCollector* pElementCollector) +/****** BufferNode/removeElementCollector ************************************ + * + * NAME + * removeElementCollector -- removes an ElementCollector from this + * BufferNode. + * + * SYNOPSIS + * removeElementCollector(pElementCollector); + * + * FUNCTION + * see NAME + * + * INPUTS + * pElementCollector - the ElementCollector to be removed + * + * RESULT + * empty + * + * HISTORY + * 05.01.2004 - implemented + * + * AUTHOR + * Michael Mi + * Email: michael.mi@sun.com + ******************************************************************************/ +{ + std::vector< const ElementCollector* >::iterator ii = m_vElementCollectors.begin(); + + for( ; ii != m_vElementCollectors.end() ; ++ii ) + { + if( *ii == pElementCollector ) + { + m_vElementCollectors.erase( ii ); + ((ElementCollector*)pElementCollector)->setBufferNode(NULL); + break; + } + } +} + +ElementMark* BufferNode::getBlocker() const +{ + return m_pBlocker; +} + +void BufferNode::setBlocker(const ElementMark* pBlocker) +/****** BufferNode/setBlocker ************************************************ + * + * NAME + * setBlocker -- adds a blocker to this BufferNode. + * + * SYNOPSIS + * setBlocker(pBlocker); + * + * FUNCTION + * see NAME + * + * INPUTS + * pBlocker - the new blocker to be attached + * + * RESULT + * empty + * + * NOTES + * Because there is only one blocker permited for a BufferNode, so the + * old blocker on this BufferNode, if there is one, will be overcasted. + * + * HISTORY + * 05.01.2004 - implemented + * + * AUTHOR + * Michael Mi + * Email: michael.mi@sun.com + ******************************************************************************/ +{ + OSL_ASSERT(!(m_pBlocker != NULL && pBlocker != NULL)); + + m_pBlocker = (ElementMark*)pBlocker; + if (m_pBlocker != NULL) + { + m_pBlocker->setBufferNode(this); + } +} + +rtl::OUString BufferNode::printChildren() const +/****** BufferNode/printChildren ********************************************* + * + * NAME + * printChildren -- prints children information into a string. + * + * SYNOPSIS + * result = printChildren(); + * + * FUNCTION + * see NAME + * + * INPUTS + * empty + * + * RESULT + * result - the information string + * + * HISTORY + * 05.01.2004 - implemented + * + * AUTHOR + * Michael Mi + * Email: michael.mi@sun.com + ******************************************************************************/ +{ + rtl::OUString rc; + std::vector< const ElementCollector* >::const_iterator ii = m_vElementCollectors.begin(); + + for( ; ii != m_vElementCollectors.end() ; ++ii ) + { + rc += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "BufID=" )); + rc += rtl::OUString::valueOf((*ii)->getBufferId()); + + if (((ElementCollector*)(*ii))->getModify()) + { + rc += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "[M]" )); + } + + rc += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ",Pri=" )); + + switch (((ElementCollector*)(*ii))->getPriority()) + { + case cssxc::sax::ElementMarkPriority_PRI_BEFOREMODIFY: + rc += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "BEFOREMODIFY" )); + break; + case cssxc::sax::ElementMarkPriority_PRI_AFTERMODIFY: + rc += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "AFTERMODIFY" )); + break; + default: + rc += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "UNKNOWN" )); + break; + } + + rc += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "(" )); + /* + if (((ElementCollector*)(*ii))->isInternalNotificationSuppressed()) + { + rc += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "*IN-Suppressed* " )); + } + */ + rc += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "SecID=" )); + rc += rtl::OUString::valueOf(((ElementCollector*)(*ii))->getSecurityId()); + rc += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ")" )); + rc += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( " " )); + } + + return rc; +} + +bool BufferNode::hasAnything() const +/****** BufferNode/hasAnything *********************************************** + * + * NAME + * hasAnything -- checks whether there is any ElementCollector or blocker + * on this BufferNode. + * + * SYNOPSIS + * bExist = hasAnything(); + * + * FUNCTION + * see NAME + * + * INPUTS + * empty + * + * RESULT + * bExist - true if there is, false otherwise. + * + * HISTORY + * 05.01.2004 - implemented + * + * AUTHOR + * Michael Mi + * Email: michael.mi@sun.com + ******************************************************************************/ +{ + return (m_pBlocker != NULL || m_vElementCollectors.size() > 0); +} + +bool BufferNode::hasChildren() const +/****** BufferNode/hasChildren *********************************************** + * + * NAME + * hasChildren -- checks whether this BufferNode has any child + * BufferNode. + * + * SYNOPSIS + * bExist = hasChildren(); + * + * FUNCTION + * see NAME + * + * INPUTS + * empty + * + * RESULT + * bExist - true if there is, false otherwise. + * + * HISTORY + * 05.01.2004 - implemented + * + * AUTHOR + * Michael Mi + * Email: michael.mi@sun.com + ******************************************************************************/ +{ + return (m_vChildren.size() > 0); +} + +std::vector< const BufferNode* >* BufferNode::getChildren() const +{ + return new std::vector< const BufferNode* >( m_vChildren ); +} + +const BufferNode* BufferNode::getFirstChild() const +/****** BufferNode/getFirstChild ********************************************* + * + * NAME + * getFirstChild -- retrieves the first child BufferNode. + * + * SYNOPSIS + * child = getFirstChild(); + * + * FUNCTION + * see NAME + * + * INPUTS + * empty + * + * RESULT + * child - the first child BufferNode, or NULL if there is no child + * BufferNode. + * + * HISTORY + * 05.01.2004 - implemented + * + * AUTHOR + * Michael Mi + * Email: michael.mi@sun.com + ******************************************************************************/ +{ + BufferNode* rc = NULL; + + if (m_vChildren.size() > 0) + { + rc = (BufferNode*)m_vChildren.front(); + } + + return (const BufferNode*)rc; +} + +void BufferNode::addChild(const BufferNode* pChild, sal_Int32 nPosition) +/****** BufferNode/addChild(pChild,nPosition) ******************************** + * + * NAME + * addChild -- inserts a child BufferNode at specific position. + * + * SYNOPSIS + * addChild(pChild, nPosition); + * + * FUNCTION + * see NAME + * + * INPUTS + * pChild - the child BufferNode to be added. + * nPosition - the position where the new child locates. + * + * RESULT + * empty + * + * NOTES + * If the nPosition is -1, then the new child BufferNode is appended + * at the end. + * + * HISTORY + * 05.01.2004 - implemented + * + * AUTHOR + * Michael Mi + * Email: michael.mi@sun.com + ******************************************************************************/ +{ + if (nPosition == -1) + { + m_vChildren.push_back( pChild ); + } + else + { + std::vector< const BufferNode* >::iterator ii = m_vChildren.begin(); + ii += nPosition; + m_vChildren.insert(ii, pChild); + } +} + +void BufferNode::addChild(const BufferNode* pChild) +/****** BufferNode/addChild() ************************************************ + * + * NAME + * addChild -- add a new child BufferNode. + * + * SYNOPSIS + * addChild(pChild); + * + * FUNCTION + * see NAME + * + * INPUTS + * pChild - the child BufferNode to be added. + * + * RESULT + * empty + * + * NOTES + * The new child BufferNode is appended at the end. + * + * HISTORY + * 05.01.2004 - implemented + * + * AUTHOR + * Michael Mi + * Email: michael.mi@sun.com + ******************************************************************************/ +{ + addChild(pChild, -1); +} + +void BufferNode::removeChild(const BufferNode* pChild) +/****** BufferNode/removeChild *********************************************** + * + * NAME + * removeChild -- removes a child BufferNode from the children list. + * + * SYNOPSIS + * removeChild(pChild); + * + * FUNCTION + * see NAME + * + * INPUTS + * pChild - the child BufferNode to be removed + * + * RESULT + * empty + * + * HISTORY + * 05.01.2004 - implemented + * + * AUTHOR + * Michael Mi + * Email: michael.mi@sun.com + ******************************************************************************/ +{ + std::vector< const BufferNode* >::iterator ii = m_vChildren.begin(); + + for( ; ii != m_vChildren.end() ; ++ii ) + { + if( *ii == pChild ) + { + m_vChildren.erase( ii ); + break; + } + } +} + +sal_Int32 BufferNode::indexOfChild(const BufferNode* pChild) const +/****** BufferNode/indexOfChild ********************************************** + * + * NAME + * indexOfChild -- gets the index of a child BufferNode. + * + * SYNOPSIS + * index = indexOfChild(pChild); + * + * FUNCTION + * see NAME + * + * INPUTS + * pChild - the child BufferNode whose index to be gotten + * + * RESULT + * index - the index of that child BufferNode. If that child BufferNode + * is not found, -1 is returned. + * + * HISTORY + * 05.01.2004 - implemented + * + * AUTHOR + * Michael Mi + * Email: michael.mi@sun.com + ******************************************************************************/ +{ + sal_Int32 nIndex = 0; + bool bFound = false; + + std::vector< const BufferNode * >::const_iterator ii = m_vChildren.begin(); + + for( ; ii != m_vChildren.end() ; ++ii ) + { + if( *ii == pChild ) + { + bFound = true; + break; + } + nIndex++; + } + + if (!bFound ) + { + nIndex = -1; + } + + return nIndex; +} + +const BufferNode* BufferNode::childAt(sal_Int32 nIndex) const +/****** BufferNode/childAt *************************************************** + * + * NAME + * childAt -- retrieves the child BufferNode at specific possition. + * + * SYNOPSIS + * child = childAt(nIndex); + * + * FUNCTION + * see NAME + * + * INPUTS + * nIndex - the index of the child BufferNode to be retrieved + * + * RESULT + * child - the child BufferNode at index position, or NULL if the index + * is out of the range of children. + * + * HISTORY + * 05.01.2004 - implemented + * + * AUTHOR + * Michael Mi + * Email: michael.mi@sun.com + ******************************************************************************/ +{ + BufferNode* rc = NULL; + + if (nIndex < ((sal_Int32)m_vChildren.size()) && nIndex >= 0) + { + rc = (BufferNode*)m_vChildren[nIndex]; + } + + return (const BufferNode*)rc; +} + +const BufferNode* BufferNode::getParent() const +{ + return m_pParent; +} + +void BufferNode::setParent(const BufferNode* pParent) +{ + m_pParent = (BufferNode*)pParent; +} + +const BufferNode* BufferNode::getNextSibling() const +/****** BufferNode/getNextSibling ******************************************** + * + * NAME + * getNextSibling -- retrieves the next sibling BufferNode. + * + * SYNOPSIS + * sibling = getNextSibling(); + * + * FUNCTION + * see NAME + * + * INPUTS + * empty + * + * RESULT + * sibling - the next sibling BufferNode, or NULL if there is none. + * + * HISTORY + * 05.01.2004 - implemented + * + * AUTHOR + * Michael Mi + * Email: michael.mi@sun.com + ******************************************************************************/ +{ + BufferNode* rc = NULL; + + if (m_pParent != NULL) + { + rc = (BufferNode*)m_pParent->getNextChild(this); + } + + return (const BufferNode*)rc; +} + +const BufferNode* BufferNode::isAncestor(const BufferNode* pDescendant) const +/****** BufferNode/isAncestor ************************************************ + * + * NAME + * isAncestor -- checks whether this BufferNode is an ancestor of another + * BufferNode. + * + * SYNOPSIS + * bIs = isAncestor(pDescendant); + * + * FUNCTION + * see NAME + * + * INPUTS + * pDescendant - the BufferNode to be checked as a descendant + * + * RESULT + * bIs - true if this BufferNode is an ancestor of the pDescendant, + * false otherwise. + * + * HISTORY + * 05.01.2004 - implemented + * + * AUTHOR + * Michael Mi + * Email: michael.mi@sun.com + ******************************************************************************/ +{ + BufferNode* rc = NULL; + + if (pDescendant != NULL) + { + std::vector< const BufferNode* >::const_iterator ii = m_vChildren.begin(); + + for( ; ii != m_vChildren.end() ; ++ii ) + { + BufferNode* pChild = (BufferNode*)*ii; + + if (pChild == pDescendant) + { + rc = pChild; + break; + } + + if (pChild->isAncestor(pDescendant) != NULL) + { + rc = pChild; + break; + } + } + } + + return (const BufferNode*)rc; +} + +bool BufferNode::isPrevious(const BufferNode* pFollowing) const +/****** BufferNode/isPrevious ************************************************ + * + * NAME + * isPrevious -- checks whether this BufferNode is ahead of another + * BufferNode in the tree order. + * + * SYNOPSIS + * bIs = isPrevious(pFollowing); + * + * FUNCTION + * see NAME + * + * INPUTS + * pFollowing - the BufferNode to be checked as a following + * + * RESULT + * bIs - true if this BufferNode is ahead in the tree order, false + * otherwise. + * + * HISTORY + * 05.01.2004 - implemented + * + * AUTHOR + * Michael Mi + * Email: michael.mi@sun.com + ******************************************************************************/ +{ + bool rc = false; + + BufferNode* pNextBufferNode = (BufferNode*)getNextNodeByTreeOrder(); + while (pNextBufferNode != NULL) + { + if (pNextBufferNode == pFollowing) + { + rc = true; + break; + } + + pNextBufferNode = (BufferNode*)(pNextBufferNode->getNextNodeByTreeOrder()); + } + + return rc; +} + +const BufferNode* BufferNode::getNextNodeByTreeOrder() const +/****** BufferNode/getNextNodeByTreeOrder ************************************ + * + * NAME + * getNextNodeByTreeOrder -- retrieves the next BufferNode in the tree + * order. + * + * SYNOPSIS + * next = getNextNodeByTreeOrder(); + * + * FUNCTION + * see NAME + * + * INPUTS + * empty + * + * RESULT + * next - the BufferNode following this BufferNode in the tree order, + * or NULL if there is none. + * + * NOTES + * The "next" node in tree order is defined as: + * 1. If a node has children, then the first child is; + * 2. otherwise, if it has a following sibling, then this sibling node is; + * 3. otherwise, if it has a parent node, the the parent's next sibling + * node is; + * 4. otherwise, no "next" node exists. + * + * HISTORY + * 05.01.2004 - implemented + * + * AUTHOR + * Michael Mi + * Email: michael.mi@sun.com + ******************************************************************************/ +{ + /* + * If this buffer node has m_vChildren, then return the first + * child. + */ + if (hasChildren()) + { + return getFirstChild(); + } + + /* + * Otherwise, it this buffer node has a following sibling, + * then return that sibling. + */ + BufferNode* pNextSibling = (BufferNode*)getNextSibling(); + if (pNextSibling != NULL) + { + return pNextSibling; + } + + /* + * Otherwise, it this buffer node has parent, then return + * its parent's following sibling. + */ + BufferNode* pNode = (BufferNode*)this; + BufferNode* pParent; + BufferNode* pNextSiblingParent = NULL; + + do + { + if (pNode == NULL) + { + break; + } + + pParent = (BufferNode*)pNode->getParent(); + if (pParent != NULL) + { + pNextSiblingParent = (BufferNode*)pParent->getNextSibling(); + } + pNode = pParent; + + }while (pNextSiblingParent == NULL); + + return pNextSiblingParent; +} + +cssu::Reference< cssxw::XXMLElementWrapper > BufferNode::getXMLElement() const +{ + return m_xXMLElement; +} + +void BufferNode::setXMLElement( const cssu::Reference< cssxw::XXMLElementWrapper >& xXMLElement ) +{ + m_xXMLElement = xXMLElement; +} + +void BufferNode::notifyBranch() +/****** BufferNode/notifyBranch ********************************************** + * + * NAME + * notifyBranch -- notifies each BufferNode in the branch of this + * BufferNode in the tree order. + * + * SYNOPSIS + * notifyBranch(); + * + * FUNCTION + * see NAME + * + * INPUTS + * empty + * + * RESULT + * empty + * + * HISTORY + * 05.01.2004 - implemented + * + * AUTHOR + * Michael Mi + * Email: michael.mi@sun.com + ******************************************************************************/ +{ + std::vector< const BufferNode* >::const_iterator ii = m_vChildren.begin(); + + for( ; ii != m_vChildren.end() ; ++ii ) + { + BufferNode* pBufferNode = (BufferNode*)*ii; + pBufferNode->elementCollectorNotify(); + pBufferNode->notifyBranch(); + } +} + +void BufferNode::notifyAncestor() +/****** BufferNode/notifyAncestor ******************************************** + * + * NAME + * notifyAncestor -- notifies each ancestor BufferNode through the parent + * link. + * + * SYNOPSIS + * notifyAncestor(); + * + * FUNCTION + * see NAME + * + * INPUTS + * empty + * + * RESULT + * empty + * + * HISTORY + * 05.01.2004 - implemented + * + * AUTHOR + * Michael Mi + * Email: michael.mi@sun.com + ******************************************************************************/ +{ + BufferNode* pParent = m_pParent; + while (pParent != NULL) + { + pParent->notifyAncestor(); + pParent = (BufferNode*)pParent->getParent(); + } +} + +void BufferNode::elementCollectorNotify() +/****** BufferNode/elementCollectorNotify ************************************ + * + * NAME + * elementCollectorNotify -- notifies this BufferNode. + * + * SYNOPSIS + * elementCollectorNotify(); + * + * FUNCTION + * Notifies this BufferNode if the notification is not suppressed. + * + * INPUTS + * empty + * + * RESULT + * child - the first child BufferNode, or NULL if there is no child + * BufferNode. + * + * HISTORY + * 05.01.2004 - implemented + * + * AUTHOR + * Michael Mi + * Email: michael.mi@sun.com + ******************************************************************************/ +{ + if (m_vElementCollectors.size()>0) + { + cssxc::sax::ElementMarkPriority nMaxPriority = cssxc::sax::ElementMarkPriority_PRI_MINIMUM; + cssxc::sax::ElementMarkPriority nPriority; + + /* + * get the max priority among ElementCollectors on this BufferNode + */ + std::vector< const ElementCollector* >::const_iterator ii = m_vElementCollectors.begin(); + for( ; ii != m_vElementCollectors.end() ; ++ii ) + { + ElementCollector* pElementCollector = (ElementCollector*)*ii; + nPriority = pElementCollector->getPriority(); + if (nPriority > nMaxPriority) + { + nMaxPriority = nPriority; + } + } + + std::vector< const ElementCollector* > vElementCollectors( m_vElementCollectors ); + ii = vElementCollectors.begin(); + + for( ; ii != vElementCollectors.end() ; ++ii ) + { + ElementCollector* pElementCollector = (ElementCollector*)*ii; + nPriority = pElementCollector->getPriority(); + bool bToModify = pElementCollector->getModify(); + + /* + * Only ElementCollector with the max priority can + * perform notify operation. + * Moreover, if any blocker exists in the subtree of + * this BufferNode, this ElementCollector can't do notify + * unless its priority is PRI_BEFOREMODIFY. + */ + if (nPriority == nMaxPriority && + (nPriority == cssxc::sax::ElementMarkPriority_PRI_BEFOREMODIFY || + !isBlockerInSubTreeIncluded(pElementCollector->getSecurityId()))) + { + /* + * If this ElementCollector will modify the bufferred element, then + * special attention must be paid. + * + * If there is any ElementCollector in the subtree or any ancestor + * ElementCollector with PRI_BEFPREMODIFY priority, this + * ElementCollector can't perform notify operation, otherwise, it + * will destroy the bufferred element, in turn, ElementCollectors + * mentioned above can't perform their mission. + */ + //if (!(nMaxPriority == cssxc::sax::ElementMarkPriority_PRI_MODIFY && + if (!(bToModify && + (isECInSubTreeIncluded(pElementCollector->getSecurityId()) || + isECOfBeforeModifyInAncestorIncluded(pElementCollector->getSecurityId())) + )) + { + pElementCollector->notifyListener(); + } + } + } + } +} + +bool BufferNode::isECInSubTreeIncluded(sal_Int32 nIgnoredSecurityId) const +/****** BufferNode/isECInSubTreeIncluded ************************************* + * + * NAME + * isECInSubTreeIncluded -- checks whether there is any ElementCollector + * in the branch of this BufferNode. + * + * SYNOPSIS + * bExist = isECInSubTreeIncluded(nIgnoredSecurityId); + * + * FUNCTION + * checks each BufferNode in the branch of this BufferNode, if there is + * an ElementCollector whose signatureId is not ignored, then return + * true, otherwise, false returned. + * + * INPUTS + * nIgnoredSecurityId - the security Id to be ignored. If it equals + * to UNDEFINEDSECURITYID, then no security Id + * will be ignored. + * + * RESULT + * bExist - true if a match found, false otherwise. + * + * HISTORY + * 05.01.2004 - implemented + * + * AUTHOR + * Michael Mi + * Email: michael.mi@sun.com + ******************************************************************************/ +{ + bool rc = false; + + std::vector< const ElementCollector* >::const_iterator jj = m_vElementCollectors.begin(); + + for( ; jj != m_vElementCollectors.end() ; ++jj ) + { + ElementCollector* pElementCollector = (ElementCollector*)*jj; + if (nIgnoredSecurityId == cssxc::sax::ConstOfSecurityId::UNDEFINEDSECURITYID || + pElementCollector->getSecurityId() != nIgnoredSecurityId) + { + rc = true; + break; + } + } + + if ( !rc ) + { + std::vector< const BufferNode* >::const_iterator ii = m_vChildren.begin(); + + for( ; ii != m_vChildren.end() ; ++ii ) + { + BufferNode* pBufferNode = (BufferNode*)*ii; + + if ( pBufferNode->isECInSubTreeIncluded(nIgnoredSecurityId)) + { + rc = true; + break; + } + } + } + + return rc; +} + +bool BufferNode::isECOfBeforeModifyInAncestorIncluded(sal_Int32 nIgnoredSecurityId) const +/****** BufferNode/isECOfBeforeModifyInAncestorIncluded ********************** + * + * NAME + * isECOfBeforeModifyInAncestorIncluded -- checks whether there is some + * ancestor BufferNode which has ElementCollector with PRI_BEFPREMODIFY + * priority. + * + * SYNOPSIS + * bExist = isECOfBeforeModifyInAncestorIncluded(nIgnoredSecurityId); + * + * FUNCTION + * checks each ancestor BufferNode through the parent link, if there is + * an ElementCollector with PRI_BEFPREMODIFY priority and its + * signatureId is not ignored, then return true, otherwise, false + * returned. + * + * INPUTS + * nIgnoredSecurityId - the security Id to be ignored. If it equals + * to UNDEFINEDSECURITYID, then no security Id + * will be ignored. + * + * RESULT + * bExist - true if a match found, false otherwise. + * + * HISTORY + * 05.01.2004 - implemented + * + * AUTHOR + * Michael Mi + * Email: michael.mi@sun.com + ******************************************************************************/ +{ + bool rc = false; + + BufferNode* pParentNode = m_pParent; + while (pParentNode != NULL) + { + if (pParentNode->isECOfBeforeModifyIncluded(nIgnoredSecurityId)) + { + rc = true; + break; + } + + pParentNode = (BufferNode*)pParentNode->getParent(); + } + + return rc; +} + +bool BufferNode::isBlockerInSubTreeIncluded(sal_Int32 nIgnoredSecurityId) const +/****** BufferNode/isBlockerInSubTreeIncluded ******************************** + * + * NAME + * isBlockerInSubTreeIncluded -- checks whether there is some BufferNode + * which has blocker on it + * + * SYNOPSIS + * bExist = isBlockerInSubTreeIncluded(nIgnoredSecurityId); + * + * FUNCTION + * checks each BufferNode in the branch of this BufferNode, if one has + * a blocker on it, and the blocker's securityId is not ignored, then + * returns true; otherwise, false returns. + * + * INPUTS + * nIgnoredSecurityId - the security Id to be ignored. If it equals + * to UNDEFINEDSECURITYID, then no security Id + * will be ignored. + * + * RESULT + * bExist - true if a match found, false otherwise. + * + * HISTORY + * 05.01.2004 - implemented + * + * AUTHOR + * Michael Mi + * Email: michael.mi@sun.com + ******************************************************************************/ +{ + bool rc = false; + + std::vector< const BufferNode* >::const_iterator ii = m_vChildren.begin(); + + for( ; ii != m_vChildren.end() ; ++ii ) + { + BufferNode* pBufferNode = (BufferNode*)*ii; + ElementMark* pBlocker = pBufferNode->getBlocker(); + + if (pBlocker != NULL && + (nIgnoredSecurityId == cssxc::sax::ConstOfSecurityId::UNDEFINEDSECURITYID || + pBlocker->getSecurityId() != nIgnoredSecurityId )) + { + rc = true; + break; + } + + if (rc || pBufferNode->isBlockerInSubTreeIncluded(nIgnoredSecurityId)) + { + rc = true; + break; + } + } + + return rc; +} + +const BufferNode* BufferNode::getNextChild(const BufferNode* pChild) const +/****** BufferNode/getNextChild ********************************************** + * + * NAME + * getNextChild -- get the next child BufferNode. + * + * SYNOPSIS + * nextChild = getNextChild(); + * + * FUNCTION + * see NAME + * + * INPUTS + * pChild - the child BufferNode whose next node is retrieved. + * + * RESULT + * nextChild - the next child BufferNode after the pChild, or NULL if + * there is none. + * + * HISTORY + * 05.01.2004 - implemented + * + * AUTHOR + * Michael Mi + * Email: michael.mi@sun.com + ******************************************************************************/ +{ + BufferNode* rc = NULL; + bool bChildFound = false; + + std::vector< const BufferNode* >::const_iterator ii = m_vChildren.begin(); + for( ; ii != m_vChildren.end() ; ++ii ) + { + if (bChildFound) + { + rc = (BufferNode*)*ii; + break; + } + + if( *ii == pChild ) + { + bChildFound = true; + } + } + + return (const BufferNode*)rc; +} + + +void BufferNode::freeAllChildren() +/****** BufferNode/freeAllChildren ******************************************* + * + * NAME + * freeAllChildren -- free all his child BufferNode. + * + * SYNOPSIS + * freeAllChildren(); + * + * FUNCTION + * see NAME + * + * INPUTS + * empty + * + * RESULT + * empty + * + * HISTORY + * 30.03.2004 - the correct the memory leak bug + * + * AUTHOR + * Michael Mi + * Email: michael.mi@sun.com + ******************************************************************************/ +{ + std::vector< const BufferNode* >::const_iterator ii = m_vChildren.begin(); + for( ; ii != m_vChildren.end() ; ++ii ) + { + BufferNode *pChild = (BufferNode *)(*ii); + pChild->freeAllChildren(); + delete pChild; + } + + m_vChildren.clear(); +} diff --git a/xmlsecurity/source/framework/buffernode.hxx b/xmlsecurity/source/framework/buffernode.hxx new file mode 100644 index 000000000000..c184ea8ba14f --- /dev/null +++ b/xmlsecurity/source/framework/buffernode.hxx @@ -0,0 +1,175 @@ +/************************************************************************* + * + * $RCSfile: buffernode.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:23 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _BUFFERNODE_HXX +#define _BUFFERNODE_HXX + +#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_XML_WRAPPER_XXMLELEMENTWRAPPER_HPP_ +#include +#endif + +#ifndef INCLUDED_VECTOR +#include +#define INCLUDED_VECTOR +#endif + +class ElementMark; +class ElementCollector; + +class BufferNode +/****** buffernode.hxx/CLASS BufferNode *************************************** + * + * NAME + * BufferNode -- Class to maintain the tree of bufferred elements + * + * FUNCTION + * One BufferNode object represents a bufferred element in the document + * wrapper component. + * All BufferNode objects construct a tree which has the same structure + * of all bufferred elements. That is to say, if one bufferred element is + * an ancestor of another bufferred element, then the corresponding + * BufferNode objects are also in ancestor/descendant relationship. + * This class is used to manipulate the tree of bufferred elements. + * + * HISTORY + * 05.01.2004 - implemented + * + * AUTHOR + * Michael Mi + * Email: michael.mi@sun.com + ******************************************************************************/ +{ +private: + /* the parent BufferNode */ + BufferNode* m_pParent; + + /* all child BufferNodes */ + std::vector< const BufferNode* > m_vChildren; + + /* all ElementCollector holding this BufferNode */ + std::vector< const ElementCollector* > m_vElementCollectors; + + /* + * the blocker holding this BufferNode, one BufferNode can have one + * blocker at most + */ + ElementMark* m_pBlocker; + + /* + * whether the element has completely bufferred by the document wrapper + * component + */ + bool m_bAllReceived; + + /* the XMLElementWrapper of the bufferred element */ + com::sun::star::uno::Reference< + com::sun::star::xml::wrapper::XXMLElementWrapper > m_xXMLElement; + +private: + bool isECInSubTreeIncluded(sal_Int32 nIgnoredSecurityId) const; + bool isECOfBeforeModifyInAncestorIncluded(sal_Int32 nIgnoredSecurityId) const; + bool isBlockerInSubTreeIncluded(sal_Int32 nIgnoredSecurityId) const; + const BufferNode* getNextChild(const BufferNode* pChild) const; + +public: + explicit BufferNode( + const com::sun::star::uno::Reference< + com::sun::star::xml::wrapper::XXMLElementWrapper >& xXMLElement); + virtual ~BufferNode() {}; + + bool isECOfBeforeModifyIncluded(sal_Int32 nIgnoredSecurityId) const; + void setReceivedAll(); + bool isAllReceived() const; + void addElementCollector(const ElementCollector* pElementCollector); + void removeElementCollector(const ElementCollector* pElementCollector); + ElementMark* getBlocker() const; + void setBlocker(const ElementMark* pBlocker); + rtl::OUString printChildren() const; + bool hasAnything() const; + bool hasChildren() const; + std::vector< const BufferNode* >* getChildren() const; + const BufferNode* getFirstChild() const; + void addChild(const BufferNode* pChild, sal_Int32 nPosition); + void addChild(const BufferNode* pChild); + void removeChild(const BufferNode* pChild); + sal_Int32 indexOfChild(const BufferNode* pChild) const; + const BufferNode* childAt(sal_Int32 nIndex) const; + const BufferNode* getParent() const; + void setParent(const BufferNode* pParent); + const BufferNode* getNextSibling() const; + const BufferNode* isAncestor(const BufferNode* pDescendant) const; + bool isPrevious(const BufferNode* pFollowing) const; + const BufferNode* getNextNodeByTreeOrder() const; + com::sun::star::uno::Reference< + com::sun::star::xml::wrapper::XXMLElementWrapper > getXMLElement() const; + void setXMLElement(const com::sun::star::uno::Reference< + com::sun::star::xml::wrapper::XXMLElementWrapper >& xXMLElement); + void notifyBranch(); + void notifyAncestor(); + void elementCollectorNotify(); + void freeAllChildren(); +}; + +#endif + diff --git a/xmlsecurity/source/framework/decryptorimpl.cxx b/xmlsecurity/source/framework/decryptorimpl.cxx new file mode 100644 index 000000000000..b56354a32e8e --- /dev/null +++ b/xmlsecurity/source/framework/decryptorimpl.cxx @@ -0,0 +1,288 @@ +/************************************************************************* + * + * $RCSfile: decryptorimpl.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:22 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#include "decryptorimpl.hxx" + +#ifndef _COM_SUN_STAR_XML_CRYPTO_XXMLENCRYPTIONTEMPLATE_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_XML_WRAPPER_XXMLELEMENTWRAPPER_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_XML_CRYPTO_SAX_DECRYPTIONRESULT_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_ +#include +#endif + +namespace cssu = com::sun::star::uno; +namespace cssl = com::sun::star::lang; +namespace cssxc = com::sun::star::xml::crypto; +namespace cssxw = com::sun::star::xml::wrapper; + +#define SERVICE_NAME "com.sun.star.xml.crypto.sax.Decryptor" +#define IMPLEMENTATION_NAME "com.sun.star.xml.security.framework.DecryptorImpl" + +#define DECLARE_ASCII( SASCIIVALUE ) \ + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SASCIIVALUE ) ) + +DecryptorImpl::DecryptorImpl( const cssu::Reference< cssl::XMultiServiceFactory >& rxMSF) +{ + mxMSF = rxMSF; +} + +DecryptorImpl::~DecryptorImpl() +{ +} + +bool DecryptorImpl::checkReady() const +/****** DecryptorImpl/checkReady ********************************************* + * + * NAME + * checkReady -- checks the conditions for the decryption. + * + * SYNOPSIS + * bReady = checkReady( ); + * + * FUNCTION + * checks whether all following conditions are satisfied: + * 1. the result listener is ready; + * 2. the EncryptionEngine is ready. + * + * INPUTS + * empty + * + * RESULT + * bReady - true if all conditions are satisfied, false otherwise + * + * HISTORY + * 05.01.2004 - implemented + * + * AUTHOR + * Michael Mi + * Email: michael.mi@sun.com + ******************************************************************************/ +{ + return (m_xResultListener.is() && EncryptionEngine::checkReady()); +} + +void DecryptorImpl::notifyResultListener() const + throw (cssu::Exception, cssu::RuntimeException) +/****** DecryptorImpl/notifyResultListener *********************************** + * + * NAME + * notifyResultListener -- notifies the listener about the decryption + * result. + * + * SYNOPSIS + * notifyResultListener( ); + * + * FUNCTION + * see NAME. + * + * INPUTS + * empty + * + * RESULT + * empty + * + * HISTORY + * 05.01.2004 - implemented + * + * AUTHOR + * Michael Mi + * Email: michael.mi@sun.com + ******************************************************************************/ +{ + cssu::Reference< cssxc::sax::XDecryptionResultListener > + xDecryptionResultListener ( m_xResultListener , cssu::UNO_QUERY ) ; + + xDecryptionResultListener->decrypted( + m_nSecurityId, + m_bOperationSucceed?(cssxc::sax::DecryptionResult_DECRYPTIONSUCCEED): + (cssxc::sax::DecryptionResult_DECRYPTIONFAIL)); +} + +void DecryptorImpl::startEngine( const cssu::Reference< + cssxc::XXMLEncryptionTemplate >& + xEncryptionTemplate) + throw (cssu::Exception, cssu::RuntimeException) +/****** DecryptorImpl/startEngine ******************************************** + * + * NAME + * startEngine -- decrypts the encryption. + * + * SYNOPSIS + * startEngine( xEncryptionTemplate ); + * + * FUNCTION + * decrypts the encryption element, then if succeeds, updates the link + * of old template element to the new encryption element in + * SAXEventKeeper. + * + * INPUTS + * xEncryptionTemplate - the encryption template to be decrypted. + * + * RESULT + * empty + * + * HISTORY + * 05.01.2004 - implemented + * + * AUTHOR + * Michael Mi + * Email: michael.mi@sun.com + ******************************************************************************/ +{ + cssu::Reference< cssxw::XXMLElementWrapper > xDecryptedElement; + try + { + xDecryptedElement = m_xXMLEncryption->decrypt(xEncryptionTemplate, m_xXMLSecurityContext); + } + catch( cssu::Exception& ) + { + xDecryptedElement = NULL; + } + + if (xDecryptedElement.is()) + { + m_xSAXEventKeeper->setElement(m_nIdOfTemplateEC, xDecryptedElement); + m_bOperationSucceed = true; + } +} + +/* XDecryptionResultBroadcaster */ +void SAL_CALL DecryptorImpl::addDecryptionResultListener( const cssu::Reference< cssxc::sax::XDecryptionResultListener >& listener ) + throw (cssu::Exception, cssu::RuntimeException) +{ + m_xResultListener = listener; + tryToPerform(); +} + +void SAL_CALL DecryptorImpl::removeDecryptionResultListener( const cssu::Reference< cssxc::sax::XDecryptionResultListener >& listener ) + throw (cssu::RuntimeException) +{ +} + +/* XInitialization */ +void SAL_CALL DecryptorImpl::initialize( const cssu::Sequence< cssu::Any >& aArguments ) + throw (cssu::Exception, cssu::RuntimeException) +{ + sal_Int32 nLength = aArguments.getLength(); + OSL_ASSERT(nLength == 5); + + rtl::OUString ouTempString; + + aArguments[0] >>= ouTempString; + m_nSecurityId = ouTempString.toInt32(); + aArguments[1] >>= m_xSAXEventKeeper; + aArguments[2] >>= ouTempString; + m_nIdOfTemplateEC = ouTempString.toInt32(); + aArguments[3] >>= m_xXMLSecurityContext; + aArguments[4] >>= m_xXMLEncryption; +} + +rtl::OUString DecryptorImpl_getImplementationName () + throw (cssu::RuntimeException) +{ + return rtl::OUString ( RTL_CONSTASCII_USTRINGPARAM ( IMPLEMENTATION_NAME ) ); +} + +sal_Bool SAL_CALL DecryptorImpl_supportsService( const rtl::OUString& ServiceName ) + throw (cssu::RuntimeException) +{ + return ServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( SERVICE_NAME )); +} + +cssu::Sequence< rtl::OUString > SAL_CALL DecryptorImpl_getSupportedServiceNames( ) + throw (cssu::RuntimeException) +{ + cssu::Sequence < rtl::OUString > aRet(1); + rtl::OUString* pArray = aRet.getArray(); + pArray[0] = rtl::OUString ( RTL_CONSTASCII_USTRINGPARAM ( SERVICE_NAME ) ); + return aRet; +} +#undef SERVICE_NAME + +cssu::Reference< cssu::XInterface > SAL_CALL DecryptorImpl_createInstance( const cssu::Reference< cssl::XMultiServiceFactory >& rSMgr) + throw( cssu::Exception ) +{ + return (cppu::OWeakObject*) new DecryptorImpl(rSMgr); +} + +/* XServiceInfo */ +rtl::OUString SAL_CALL DecryptorImpl::getImplementationName( ) + throw (cssu::RuntimeException) +{ + return DecryptorImpl_getImplementationName(); +} +sal_Bool SAL_CALL DecryptorImpl::supportsService( const rtl::OUString& rServiceName ) + throw (cssu::RuntimeException) +{ + return DecryptorImpl_supportsService( rServiceName ); +} +cssu::Sequence< rtl::OUString > SAL_CALL DecryptorImpl::getSupportedServiceNames( ) + throw (cssu::RuntimeException) +{ + return DecryptorImpl_getSupportedServiceNames(); +} + diff --git a/xmlsecurity/source/framework/decryptorimpl.hxx b/xmlsecurity/source/framework/decryptorimpl.hxx new file mode 100644 index 000000000000..52e40f02b391 --- /dev/null +++ b/xmlsecurity/source/framework/decryptorimpl.hxx @@ -0,0 +1,176 @@ +/************************************************************************* + * + * $RCSfile: decryptorimpl.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:22 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _DECRYPTORIMPL_HXX +#define _DECRYPTORIMPL_HXX + +#ifndef _COM_SUN_STAR_XML_CRYPTO_SAX_XDECRYPTIONRESULTBROADCASTER_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_XML_CRYPTO_SAX_XDECRYPTIONRESULTLISTENER_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_LANG_XINITIALIZATION_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_ +#include +#endif +#ifndef _CPPUHELPER_IMPLBASE3_HXX_ +#include +#endif + +#include "encryptionengine.hxx" + +class DecryptorImpl : public cppu::ImplInheritanceHelper3 +< + EncryptionEngine, + com::sun::star::xml::crypto::sax::XDecryptionResultBroadcaster, + com::sun::star::lang::XInitialization, + com::sun::star::lang::XServiceInfo +> +/****** DecryptorImpl.hxx/CLASS DecryptorImpl ********************************* + * + * NAME + * DecryptorImpl -- decrypts an encryption + * + * FUNCTION + * Collects all resources for decrypting an encryption, then decrypts the + * encryption by invoking a xmlsec-based encryption bridge component. + * + * HISTORY + * 05.01.2004 - Interface supported: XDecryptionResultBroadcaster, + * XInitialization, XServiceInfo + * + * AUTHOR + * Michael Mi + * Email: michael.mi@sun.com + ******************************************************************************/ +{ +private: + /* + * the Id of the encryption, which is used for the result listener to + * identify the encryption. + */ + sal_Int32 m_nEncryptionId; + + /* + * the decryption result, + * remembers whether the decryption succeeds. + */ + bool m_bDecryptionSucceed; + + virtual void notifyResultListener() const + throw (com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException); + virtual bool checkReady() const; + virtual void startEngine( const com::sun::star::uno::Reference< + com::sun::star::xml::crypto::XXMLEncryptionTemplate >& + xEncryptionTemplate) + throw (com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException); + +public: + explicit DecryptorImpl( const com::sun::star::uno::Reference< + com::sun::star::lang::XMultiServiceFactory >& rxMSF); + virtual ~DecryptorImpl(); + + /* XDecryptionResultBroadcaster */ + virtual void SAL_CALL addDecryptionResultListener( + const com::sun::star::uno::Reference< + com::sun::star::xml::crypto::sax::XDecryptionResultListener >& + listener ) + throw (com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeDecryptionResultListener( + const com::sun::star::uno::Reference< + com::sun::star::xml::crypto::sax::XDecryptionResultListener >& + listener ) + throw (com::sun::star::uno::RuntimeException); + + /* XInitialization */ + virtual void SAL_CALL initialize( + const com::sun::star::uno::Sequence< com::sun::star::uno::Any >& aArguments ) + throw (com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException); + + /* XServiceInfo */ + virtual rtl::OUString SAL_CALL getImplementationName( ) + throw (com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsService( const rtl::OUString& ServiceName ) + throw (com::sun::star::uno::RuntimeException); + virtual com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames( ) + throw (com::sun::star::uno::RuntimeException); +}; + +rtl::OUString DecryptorImpl_getImplementationName() + throw ( com::sun::star::uno::RuntimeException ); + +sal_Bool SAL_CALL DecryptorImpl_supportsService( const rtl::OUString& ServiceName ) + throw ( com::sun::star::uno::RuntimeException ); + +com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL DecryptorImpl_getSupportedServiceNames( ) + throw ( com::sun::star::uno::RuntimeException ); + +com::sun::star::uno::Reference< com::sun::star::uno::XInterface > +SAL_CALL DecryptorImpl_createInstance( + const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& + rSMgr) + throw ( com::sun::star::uno::Exception ); + +#endif + diff --git a/xmlsecurity/source/framework/elementcollector.cxx b/xmlsecurity/source/framework/elementcollector.cxx new file mode 100644 index 000000000000..c9633e8720dc --- /dev/null +++ b/xmlsecurity/source/framework/elementcollector.cxx @@ -0,0 +1,330 @@ +/************************************************************************* + * + * $RCSfile: elementcollector.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:23 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#include "elementmark.hxx" +#include "elementcollector.hxx" +#include "buffernode.hxx" + +#ifndef _COM_SUN_STAR_XML_CRYPTO_SAX_CONSTOFSECURITYID_HPP_ +#include +#endif + +namespace cssu = com::sun::star::uno; +namespace cssxc = com::sun::star::xml::crypto; + +ElementCollector::ElementCollector( + sal_Int32 nSecurityId, + sal_Int32 nBufferId, + cssxc::sax::ElementMarkPriority nPriority, + bool bToModify, + const com::sun::star::uno::Reference< + com::sun::star::xml::crypto::sax::XReferenceResolvedListener >& + xReferenceResolvedListener) + :ElementMark(nSecurityId, nBufferId), + m_nPriority(nPriority), + m_bToModify(bToModify), + m_xReferenceResolvedListener(xReferenceResolvedListener), + m_bAbleToNotify(false), + m_bNotified(false) +/****** ElementCollector/ElementCollector ************************************* + * + * NAME + * ElementCollector -- constructor method + * + * SYNOPSIS + * ElementCollector(nSecurityId, nBufferId, nPriority, bToModify + * xReferenceResolvedListener); + * + * FUNCTION + * construct an ElementCollector object. + * + * INPUTS + * nSecurityId - represents which security entity the buffer node is + * related with. Either a signature or an encryption is + * a security entity. + * nBufferId - the id of the element bufferred in the document + * wrapper component. The document wrapper component + * uses this id to search the particular bufferred + * element. + * nPriority - the priority value. ElementCollector with lower + * priority value can't notify until all ElementCollectors + * with higher priority value have notified. + * bToModify - A flag representing whether this ElementCollector + * notification will cause the modification of its working + * element. + * xReferenceResolvedListener + * - the listener that this ElementCollector notifies to. + * + * RESULT + * empty + * + * HISTORY + * 05.01.2004 - implemented + * + * AUTHOR + * Michael Mi + * Email: michael.mi@sun.com + ******************************************************************************/ +{ + m_type = cssxc::sax::ElementMarkType_TYPEOFELEMENTCOLLECTOR; +} + +/* +bool ElementCollector::isInternalNotificationSuppressed() const +{ + return m_bInternalNotificationSuppressed; +} +*/ + +cssxc::sax::ElementMarkPriority ElementCollector::getPriority() const +{ + return m_nPriority; +} + +bool ElementCollector::getModify() const +{ + return m_bToModify; +} + +void ElementCollector::notifyListener() +/****** ElementCollector/notifyListener *************************************** + * + * NAME + * notifyListener -- enable the ability to notify the listener + * + * SYNOPSIS + * notifyListener(); + * + * FUNCTION + * enable the ability to notify the listener and try to notify then. + * + * INPUTS + * empty + * + * RESULT + * empty + * + * HISTORY + * 05.01.2004 - implemented + * + * AUTHOR + * Michael Mi + * Email: michael.mi@sun.com + ******************************************************************************/ +{ + m_bAbleToNotify = true; + doNotify(); +} + +bool ElementCollector::isAbleToNotify() const +{ + return m_bAbleToNotify; +} + +void ElementCollector::setReferenceResolvedListener( + const cssu::Reference< cssxc::sax::XReferenceResolvedListener >& xReferenceResolvedListener) +/****** ElementCollector/setReferenceResolvedListener ************************* + * + * NAME + * setReferenceResolvedListener -- configures a listener for the buffer + * node in this object + * + * SYNOPSIS + * setReferenceResolvedListener(xReferenceResolvedListener); + * + * FUNCTION + * configures a new listener and try to notify then. + * + * INPUTS + * xReferenceResolvedListener - the new listener + * + * RESULT + * empty + * + * HISTORY + * 05.01.2004 - implemented + * + * AUTHOR + * Michael Mi + * Email: michael.mi@sun.com + ******************************************************************************/ +{ + m_xReferenceResolvedListener = xReferenceResolvedListener; + doNotify(); +} + +void ElementCollector::setSecurityId(sal_Int32 nSecurityId) +/****** ElementCollector/setSecurityId **************************************** + * + * NAME + * setSecurityId -- configures the security Id of the buffer node + * + * SYNOPSIS + * setSecurityId(nSecurityId); + * + * FUNCTION + * configures the security Id and try to notify then + * + * INPUTS + * nSecurityId - the security Id + * + * RESULT + * empty + * + * HISTORY + * 05.01.2004 - implemented + * + * AUTHOR + * Michael Mi + * Email: michael.mi@sun.com + ******************************************************************************/ +{ + m_nSecurityId = nSecurityId; + doNotify(); +} + +void ElementCollector::doNotify() +/****** ElementCollector/doNotify ********************************************* + * + * NAME + * doNotify -- tries to notify the listener + * + * SYNOPSIS + * doNotify(); + * + * FUNCTION + * notifies the listener when all below conditions are satisfied: + * the listener has not been notified; + * the notify right is granted; + * the listener has already been configured; + * the security id has already been configure + * + * INPUTS + * empty + * + * RESULT + * empty + * + * HISTORY + * 05.01.2004 - implemented + * + * AUTHOR + * Michael Mi + * Email: michael.mi@sun.com + ******************************************************************************/ +{ + if (!m_bNotified && + m_bAbleToNotify && + m_xReferenceResolvedListener.is() && + m_nSecurityId != cssxc::sax::ConstOfSecurityId::UNDEFINEDSECURITYID) + { + m_bNotified = true; + m_xReferenceResolvedListener->referenceResolved(m_nBufferId); + } +} + +ElementCollector* ElementCollector::clone( + sal_Int32 nBufferId, + cssxc::sax::ElementMarkPriority nPriority ) const +/****** ElementCollector/clone ************************************************ + * + * NAME + * clone -- duplicates this ElementCollector object + * + * SYNOPSIS + * cloned = clone(nBufferId, nPriority); + * + * FUNCTION + * duplicates this ElementCollector object with new buffer Id, priority. + * + * INPUTS + * nBufferId - the buffer node's Id + * nPriority - the priority + * + * RESULT + * clone - a new ElementCollector + * + * HISTORY + * 05.01.2004 - implemented + * + * AUTHOR + * Michael Mi + * Email: michael.mi@sun.com + ******************************************************************************/ +{ + ElementCollector* pClonedOne + = new ElementCollector(m_nSecurityId, + nBufferId, nPriority, m_bToModify, + m_xReferenceResolvedListener); + + if (m_bAbleToNotify) + { + pClonedOne->notifyListener(); + } + + if (m_pBufferNode != NULL) + { + m_pBufferNode->addElementCollector(pClonedOne); + } + + return pClonedOne; +} + diff --git a/xmlsecurity/source/framework/elementcollector.hxx b/xmlsecurity/source/framework/elementcollector.hxx new file mode 100644 index 000000000000..703e51a2b039 --- /dev/null +++ b/xmlsecurity/source/framework/elementcollector.hxx @@ -0,0 +1,147 @@ +/************************************************************************* + * + * $RCSfile: elementcollector.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:23 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _ELEMENTCOLLECTOR_HXX +#define _ELEMENTCOLLECTOR_HXX + +#include "elementmark.hxx" + +#ifndef _COM_SUN_STAR_XML_CRYPTO_SAX_XREFERENCERESOLVEDLISTENER_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_XML_CRYPTO_SAX_ELEMENTMARKPRIORITY_HPP_ +#include +#endif + +class ElementCollector : public ElementMark +/****** elementcollector.hxx/CLASS ElementCollector *************************** + * + * NAME + * ElementCollector -- Class to manipulate an element collector + * + * FUNCTION + * This class is derived from the ElementMark class. Beyond the function + * of the ElementMark class, this class also maintains the priority, and + * manages the notify process + * + * HISTORY + * 05.01.2004 - implemented + * + * AUTHOR + * Michael Mi + * Email: michael.mi@sun.com + ******************************************************************************/ +{ +private: + /* + * the notify priority, is one of following values: + * PRI_AFTERMODIFY - this ElementCollector will notify after all + * internal modifications have finished. + * PRI_BEFOREMODIFY - this ElementCollector must notify before any + * internal modification happens. + */ + com::sun::star::xml::crypto::sax::ElementMarkPriority m_nPriority; + + /* + * the modify flag, representing whether which elementcollector will + * modify its data. + */ + bool m_bToModify; + + /* the notify enable flag, see notifyListener method */ + bool m_bAbleToNotify; + + /* whether the listener has been notified */ + bool m_bNotified; + + /* the listener to be notified */ + com::sun::star::uno::Reference< + com::sun::star::xml::crypto::sax::XReferenceResolvedListener > m_xReferenceResolvedListener; + +public: + ElementCollector( + sal_Int32 nSecurityId, + sal_Int32 nBufferId, + com::sun::star::xml::crypto::sax::ElementMarkPriority nPriority, + bool bToModify, + const com::sun::star::uno::Reference< + com::sun::star::xml::crypto::sax::XReferenceResolvedListener >& + xReferenceResolvedListener); + virtual ~ElementCollector() {}; + + //bool isInternalNotificationSuppressed() const; + com::sun::star::xml::crypto::sax::ElementMarkPriority getPriority() const; + bool getModify() const; + void notifyListener(); + bool isAbleToNotify() const; + void setReferenceResolvedListener( + const com::sun::star::uno::Reference< + com::sun::star::xml::crypto::sax::XReferenceResolvedListener >& + referenceResolvedListener); + void setSecurityId(sal_Int32 nSecurityId); + void doNotify(); + ElementCollector* clone( + sal_Int32 nId, + com::sun::star::xml::crypto::sax::ElementMarkPriority nPriority ) const; +}; + +#endif + diff --git a/xmlsecurity/source/framework/elementmark.cxx b/xmlsecurity/source/framework/elementmark.cxx new file mode 100644 index 000000000000..7d6c0596ecf6 --- /dev/null +++ b/xmlsecurity/source/framework/elementmark.cxx @@ -0,0 +1,136 @@ +/************************************************************************* + * + * $RCSfile: elementmark.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:23 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#include "elementmark.hxx" +#include "buffernode.hxx" + +namespace cssxc = com::sun::star::xml::crypto; + +ElementMark::ElementMark(sal_Int32 nSecurityId, sal_Int32 nBufferId) + :m_nSecurityId(nSecurityId), + m_nBufferId(nBufferId), + m_pBufferNode(NULL), + m_type(cssxc::sax::ElementMarkType_TYPEOFELEMENTMARK) +/****** ElementMark/ElementMark *********************************************** + * + * NAME + * ElementMark -- constructor method + * + * SYNOPSIS + * ElementMark(nSecurityId, nBufferId); + * + * FUNCTION + * construct an ElementMark object. + * + * INPUTS + * nSecurityId - represents which security entity the buffer node is + * related with. Either a signature or an encryption is + * a security entity. + * nBufferId - the id of the element bufferred in the document + * wrapper component. The document wrapper component + * uses this id to search the particular bufferred + * element. + * + * RESULT + * empty + * + * HISTORY + * 05.01.2004 - implemented + * + * AUTHOR + * Michael Mi + * Email: michael.mi@sun.com + ******************************************************************************/ +{ +} + +BufferNode* ElementMark::getBufferNode() const +{ + return m_pBufferNode; +} + +void ElementMark::setBufferNode(const BufferNode* pBufferNode) +{ + m_pBufferNode = (BufferNode*)pBufferNode; +} + +sal_Int32 ElementMark::getSecurityId() const +{ + return m_nSecurityId; +} + +void ElementMark::setSecurityId(sal_Int32 nSecurityId) +{ + m_nSecurityId = nSecurityId; +} + +com::sun::star::xml::crypto::sax::ElementMarkType ElementMark::getType() const +{ + return m_type; +} + +sal_Int32 ElementMark::getBufferId() const +{ + return m_nBufferId; +} + + + diff --git a/xmlsecurity/source/framework/elementmark.hxx b/xmlsecurity/source/framework/elementmark.hxx new file mode 100644 index 000000000000..e122f2645e0b --- /dev/null +++ b/xmlsecurity/source/framework/elementmark.hxx @@ -0,0 +1,123 @@ +/************************************************************************* + * + * $RCSfile: elementmark.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:23 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _ELEMENTMARK_HXX +#define _ELEMENTMARK_HXX + +#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_XML_CRYPTO_SAX_ELEMENTMARKTYPE_HPP_ +#include +#endif + +class BufferNode; + +class ElementMark +/****** elementmark.hxx/CLASS ElementMark ************************************* + * + * NAME + * ElementMark -- Class to manipulate an element mark + * + * FUNCTION + * This class maintains the security id, buffer id and its type for a + * buffer node. + * + * HISTORY + * 05.01.2004 - implemented + * + * AUTHOR + * Michael Mi + * Email: michael.mi@sun.com + ******************************************************************************/ +{ +protected: + /* the BufferNode maintained by this object */ + BufferNode* m_pBufferNode; + + /* the security Id */ + sal_Int32 m_nSecurityId; + + /* the buffer Id */ + sal_Int32 m_nBufferId; + + /* + * the type value, is one of following values: + * TYPEOFELEMENTMARK - the default value, represents an blocker if + * not changed + * TYPEOFELEMENTCOLLECTOR - represents an ElementCollector + */ + com::sun::star::xml::crypto::sax::ElementMarkType m_type; + +public: + ElementMark(sal_Int32 nSecurityId, sal_Int32 nBufferId); + virtual ~ElementMark() {}; + + BufferNode* getBufferNode() const; + void setBufferNode(const BufferNode* pBufferNode); + sal_Int32 getSecurityId() const; + void setSecurityId(sal_Int32 nSecurityId); + com::sun::star::xml::crypto::sax::ElementMarkType getType() const; + sal_Int32 getBufferId() const; +}; + +#endif + diff --git a/xmlsecurity/source/framework/encryptionengine.cxx b/xmlsecurity/source/framework/encryptionengine.cxx new file mode 100644 index 000000000000..a2a7daeb0370 --- /dev/null +++ b/xmlsecurity/source/framework/encryptionengine.cxx @@ -0,0 +1,254 @@ +/************************************************************************* + * + * $RCSfile: encryptionengine.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:23 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#include "encryptionengine.hxx" + +#ifndef _COM_SUN_STAR_XML_CRYPTO_XXMLENCRYPTIONTEMPLATE_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_XML_WRAPPER_XXMLELEMENTWRAPPER_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_ +#include +#endif + +namespace cssu = com::sun::star::uno; +namespace cssl = com::sun::star::lang; +namespace cssxc = com::sun::star::xml::crypto; +namespace cssxw = com::sun::star::xml::wrapper; + +#define ENCRYPTION_TEMPLATE "com.sun.star.xml.crypto.XMLEncryptionTemplate" + +#define DECLARE_ASCII( SASCIIVALUE ) \ + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SASCIIVALUE ) ) + +EncryptionEngine::EncryptionEngine( ) + :m_nIdOfBlocker(-1) +{ +} + +bool EncryptionEngine::checkReady() const +/****** EncryptionEngine/checkReady ****************************************** + * + * NAME + * checkReady -- checks the conditions for the main operation. + * + * SYNOPSIS + * bReady = checkReady( ); + * + * FUNCTION + * checks whether all following conditions are satisfied: + * 1. the main operation has't begun yet; + * 2. the key material is known; + * 3. the id of the template blocker is known; + * 4. both the key element and the encryption template + * are bufferred. + * + * INPUTS + * empty + * + * RESULT + * bReady - true if all conditions are satisfied, false otherwise + * + * HISTORY + * 05.01.2004 - implemented + * + * AUTHOR + * Michael Mi + * Email: michael.mi@sun.com + ******************************************************************************/ +{ + bool rc = true; + + sal_Int32 nKeyInc = 0; + if (m_nIdOfKeyEC != 0) + { + nKeyInc = 1; + } + + if (m_bMissionDone || + m_nIdOfKeyEC == -1 || + m_nIdOfBlocker == -1 || + 1+nKeyInc > m_nNumOfResolvedReferences ) + { + rc = false; + } + + return rc; +} + +void EncryptionEngine::tryToPerform( ) + throw (cssu::Exception, cssu::RuntimeException) +/****** EncryptionEngine/tryToPerform **************************************** + * + * NAME + * tryToPerform -- tries to perform the encryption/decryption operation. + * + * SYNOPSIS + * tryToPerform( ); + * + * FUNCTION + * if the situation is ready, perform following operations. + * 1. prepares a encryption template; + * 2. calls the encryption bridge component; + * 3. clears up all used resources; + * 4. notifies the result listener; + * 5. sets the "accomplishment" flag. + * + * INPUTS + * empty + * + * RESULT + * empty + * + * HISTORY + * 05.01.2004 - implemented + * + * AUTHOR + * Michael Mi + * Email: michael.mi@sun.com + ******************************************************************************/ +{ + if (checkReady()) + { + const rtl::OUString sEncryptionTemplate ( + RTL_CONSTASCII_USTRINGPARAM( ENCRYPTION_TEMPLATE ) ); + cssu::Reference < cssxc::XXMLEncryptionTemplate > xEncryptionTemplate( + mxMSF->createInstance( sEncryptionTemplate ), cssu::UNO_QUERY ); + + OSL_ASSERT( xEncryptionTemplate.is() ); + + cssu::Reference< cssxw::XXMLElementWrapper > xXMLElement + = m_xSAXEventKeeper->getElement( m_nIdOfTemplateEC ); + + xEncryptionTemplate->setTemplate(xXMLElement); + + startEngine( xEncryptionTemplate ); + + /* + * done + */ + clearUp( ); + + notifyResultListener(); + + m_bMissionDone = true; + } +} + +void EncryptionEngine::clearUp( ) const +/****** EncryptionEngine/clearup ********************************************* + * + * NAME + * clearUp -- clear up all resources used by this operation. + * + * SYNOPSIS + * clearUp( ); + * + * FUNCTION + * cleaning resources up includes: + * 1. releases the ElementCollector for the encryption template element; + * 2. releases the Blocker for the encryption template element; + * 3. releases the ElementCollector for the key element, if there is one. + * + * INPUTS + * empty + * + * RESULT + * empty + * + * HISTORY + * 05.01.2004 - implemented + * + * AUTHOR + * Michael Mi + * Email: michael.mi@sun.com + ******************************************************************************/ +{ + cssu::Reference < cssxc::sax::XReferenceResolvedBroadcaster > + xReferenceResolvedBroadcaster( m_xSAXEventKeeper, cssu::UNO_QUERY ); + + xReferenceResolvedBroadcaster->removeReferenceResolvedListener( + m_nIdOfTemplateEC, + (const cssu::Reference < cssxc::sax::XReferenceResolvedListener >)((SecurityEngine *)this)); + + m_xSAXEventKeeper->removeElementCollector(m_nIdOfTemplateEC); + + if (m_nIdOfBlocker != -1) + { + m_xSAXEventKeeper->removeBlocker(m_nIdOfBlocker); + } + + if (m_nIdOfKeyEC != 0 && m_nIdOfKeyEC != -1) + { + m_xSAXEventKeeper->removeElementCollector(m_nIdOfKeyEC); + } +} + +/* XBlockerMonitor */ +void SAL_CALL EncryptionEngine::setBlockerId( sal_Int32 id ) + throw (com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException) +{ + m_nIdOfBlocker = id; + tryToPerform(); +} + diff --git a/xmlsecurity/source/framework/encryptionengine.hxx b/xmlsecurity/source/framework/encryptionengine.hxx new file mode 100644 index 000000000000..ca39d7939dd0 --- /dev/null +++ b/xmlsecurity/source/framework/encryptionengine.hxx @@ -0,0 +1,157 @@ +/************************************************************************* + * + * $RCSfile: encryptionengine.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:23 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _ENCRYPTIONENGINE_HXX +#define _ENCRYPTIONENGINE_HXX + +#ifndef _COM_SUN_STAR_XML_CRYPTO_SAX_XREFERENCERESOLVEDLISTENER_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_XML_CRYPTO_SAX_XREFERENCERESOLVEDBROADCASTER_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_XML_CRYPTO_SAX_XBLOCKERMONITOR_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_XML_CRYPTO_SAX_XKEYCOLLECTOR_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_XML_CRYPTO_SAX_XMISSIONTAKER_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_XML_CRYPTO_SAX_XSAXEVENTKEEPER_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_XML_CRYPTO_XXMLSECURITYCONTEXT_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_XML_CRYPTO_XXMLENCRYPTION_HPP_ +#include +#endif + +#ifndef _CPPUHELPER_IMPLBASE1_HXX_ +#include +#endif + +#include "securityengine.hxx" + +class EncryptionEngine : public cppu::ImplInheritanceHelper1 +< + SecurityEngine, + com::sun::star::xml::crypto::sax::XBlockerMonitor +> +/****** encryptionEngine.hxx/CLASS encryptionEngine *************************** + * + * NAME + * EncryptionEngine -- Base class of Encryptor and Decryptor + * + * FUNCTION + * Maintains common members and methods related with encryption. + * + * HISTORY + * 05.01.2004 - Interface supported: XBlockerMonitor + * + * AUTHOR + * Michael Mi + * Email: michael.mi@sun.com + ******************************************************************************/ +{ +protected: + /* + * the Encryption bridge component, which performs encrypt and decrypt + * operation based on xmlsec library. + */ + com::sun::star::uno::Reference< + com::sun::star::xml::crypto::XXMLEncryption > m_xXMLEncryption; + + /* + * the Id of template blocker. + */ + sal_Int32 m_nIdOfBlocker; + +protected: + EncryptionEngine( ); + virtual ~EncryptionEngine(){}; + + virtual void tryToPerform( ) + throw (com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException); + virtual void clearUp( ) const; + virtual bool checkReady() const; + + /* + * starts the main function. This method will be implemented by any sub-class. + * For a Encryptor, it performs encryption operation; + * for a Decryptor, decryption operation is performed. + */ + virtual void startEngine( const com::sun::star::uno::Reference< + com::sun::star::xml::crypto::XXMLEncryptionTemplate >& + xEncryptionTemplate) + throw (com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException) + {}; + +public: + /* XBlockerMonitor */ + virtual void SAL_CALL setBlockerId( sal_Int32 id ) + throw (com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException); +}; + +#endif + diff --git a/xmlsecurity/source/framework/encryptorimpl.cxx b/xmlsecurity/source/framework/encryptorimpl.cxx new file mode 100644 index 000000000000..2006348335e4 --- /dev/null +++ b/xmlsecurity/source/framework/encryptorimpl.cxx @@ -0,0 +1,328 @@ +/************************************************************************* + * + * $RCSfile: encryptorimpl.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:22 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#include "encryptorimpl.hxx" + +#ifndef _COM_SUN_STAR_XML_CRYPTO_XXMLENCRYPTIONTEMPLATE_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_XML_WRAPPER_XXMLELEMENTWRAPPER_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_XML_CRYPTO_SAX_ENCRYPTIONRESULT_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_ +#include +#endif + +namespace cssu = com::sun::star::uno; +namespace cssl = com::sun::star::lang; +namespace cssxc = com::sun::star::xml::crypto; +namespace cssxw = com::sun::star::xml::wrapper; + +#define SERVICE_NAME "com.sun.star.xml.crypto.sax.Encryptor" +#define IMPLEMENTATION_NAME "com.sun.star.xml.security.framework.EncryptorImpl" + +#define DECLARE_ASCII( SASCIIVALUE ) \ + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SASCIIVALUE ) ) + +EncryptorImpl::EncryptorImpl( const cssu::Reference< cssl::XMultiServiceFactory >& rxMSF) +{ + m_nReferenceId = -1; + mxMSF = rxMSF; +} + +EncryptorImpl::~EncryptorImpl() +{ +} + +bool EncryptorImpl::checkReady() const +/****** EncryptorImpl/checkReady ********************************************* + * + * NAME + * checkReady -- checks the conditions for the encryption. + * + * SYNOPSIS + * bReady = checkReady( ); + * + * FUNCTION + * checks whether all following conditions are satisfied: + * 1. the result listener is ready; + * 2. the EncryptionEngine is ready. + * + * INPUTS + * empty + * + * RESULT + * bReady - true if all conditions are satisfied, false otherwise + * + * HISTORY + * 05.01.2004 - implemented + * + * AUTHOR + * Michael Mi + * Email: michael.mi@sun.com + ******************************************************************************/ +{ + sal_Int32 nKeyInc = 0; + if (m_nIdOfKeyEC != 0) + { + nKeyInc = 1; + } + + return (m_xResultListener.is() && + (m_nReferenceId != -1) && + (2+nKeyInc == m_nNumOfResolvedReferences) && + EncryptionEngine::checkReady()); +} + +void EncryptorImpl::notifyResultListener() const + throw (cssu::Exception, cssu::RuntimeException) +/****** DecryptorImpl/notifyResultListener *********************************** + * + * NAME + * notifyResultListener -- notifies the listener about the encryption + * result. + * + * SYNOPSIS + * notifyResultListener( ); + * + * FUNCTION + * see NAME. + * + * INPUTS + * empty + * + * RESULT + * empty + * + * HISTORY + * 05.01.2004 - implemented + * + * AUTHOR + * Michael Mi + * Email: michael.mi@sun.com + ******************************************************************************/ +{ + cssu::Reference< cssxc::sax::XEncryptionResultListener > + xEncryptionResultListener ( m_xResultListener , cssu::UNO_QUERY ) ; + + xEncryptionResultListener->encrypted( + m_nSecurityId, + m_bOperationSucceed?(cssxc::sax::EncryptionResult_ENCRYPTIONSUCCEED): + (cssxc::sax::EncryptionResult_ENCRYPTIONFAIL)); +} + +void EncryptorImpl::startEngine( const cssu::Reference< + cssxc::XXMLEncryptionTemplate >& + xEncryptionTemplate) + throw (cssu::Exception, cssu::RuntimeException) +/****** EncryptorImpl/startEngine ******************************************** + * + * NAME + * startEngine -- generates the encryption. + * + * SYNOPSIS + * startEngine( xEncryptionTemplate ); + * + * FUNCTION + * generates the encryption element, then if succeeds, updates the link + * of old template element to the new encryption element in + * SAXEventKeeper. + * + * INPUTS + * xEncryptionTemplate - the encryption template to be encrypted. + * + * RESULT + * empty + * + * HISTORY + * 05.01.2004 - implemented + * + * AUTHOR + * Michael Mi + * Email: michael.mi@sun.com + ******************************************************************************/ +{ + cssu::Reference < cssxc::XXMLEncryptionTemplate > xResultTemplate; + + cssu::Reference< cssxw::XXMLElementWrapper > + xXMLElement = m_xSAXEventKeeper->getElement( m_nReferenceId ); + xEncryptionTemplate->setTarget(xXMLElement); + + try + { + xResultTemplate = m_xXMLEncryption->encrypt( + xEncryptionTemplate, m_xXMLSecurityContext); + } + catch( cssu::Exception& ) + { + xResultTemplate = NULL; + } + + if (xResultTemplate.is()) + { + cssu::Reference < cssxw::XXMLElementWrapper > xResultEncryption + = xResultTemplate->getTemplate(); + m_xSAXEventKeeper->setElement(m_nIdOfTemplateEC, xResultEncryption); + + m_xSAXEventKeeper->setElement(m_nReferenceId, NULL); + + m_bOperationSucceed = true; + } +} + +/* XReferenceCollector */ +void SAL_CALL EncryptorImpl::setReferenceCount( sal_Int32 count ) + throw (cssu::Exception, cssu::RuntimeException) +{ + /* + * dummp method, because there is only one reference in + * encryption, different from signature. + * so the referenceNumber is always 1 + */ +} + +void SAL_CALL EncryptorImpl::setReferenceId( sal_Int32 id ) + throw (cssu::Exception, cssu::RuntimeException) +{ + m_nReferenceId = id; +} + +/* XEncryptionResultBroadcaster */ +void SAL_CALL EncryptorImpl::addEncryptionResultListener( const cssu::Reference< cssxc::sax::XEncryptionResultListener >& listener ) + throw (cssu::Exception, cssu::RuntimeException) +{ + m_xResultListener = listener; + tryToPerform(); +} + +void SAL_CALL EncryptorImpl::removeEncryptionResultListener( const cssu::Reference< cssxc::sax::XEncryptionResultListener >& listener ) + throw (cssu::RuntimeException) +{ +} + +/* XInitialization */ +void SAL_CALL EncryptorImpl::initialize( const cssu::Sequence< cssu::Any >& aArguments ) + throw (cssu::Exception, cssu::RuntimeException) +{ + sal_Int32 nLength = aArguments.getLength(); + OSL_ASSERT(nLength == 5); + + rtl::OUString ouTempString; + + aArguments[0] >>= ouTempString; + m_nSecurityId = ouTempString.toInt32(); + aArguments[1] >>= m_xSAXEventKeeper; + aArguments[2] >>= ouTempString; + m_nIdOfTemplateEC = ouTempString.toInt32(); + aArguments[3] >>= m_xXMLSecurityContext; + aArguments[4] >>= m_xXMLEncryption; +} + + +rtl::OUString EncryptorImpl_getImplementationName () + throw (cssu::RuntimeException) +{ + return rtl::OUString ( RTL_CONSTASCII_USTRINGPARAM ( IMPLEMENTATION_NAME ) ); +} + +sal_Bool SAL_CALL EncryptorImpl_supportsService( const rtl::OUString& ServiceName ) + throw (cssu::RuntimeException) +{ + return ServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( SERVICE_NAME )); +} + +cssu::Sequence< rtl::OUString > SAL_CALL EncryptorImpl_getSupportedServiceNames( ) + throw (cssu::RuntimeException) +{ + cssu::Sequence < rtl::OUString > aRet(1); + rtl::OUString* pArray = aRet.getArray(); + pArray[0] = rtl::OUString ( RTL_CONSTASCII_USTRINGPARAM ( SERVICE_NAME ) ); + return aRet; +} +#undef SERVICE_NAME + +cssu::Reference< cssu::XInterface > SAL_CALL EncryptorImpl_createInstance( + const cssu::Reference< cssl::XMultiServiceFactory >& rSMgr) + throw( cssu::Exception ) +{ + return (cppu::OWeakObject*) new EncryptorImpl(rSMgr); +} + +/* XServiceInfo */ +rtl::OUString SAL_CALL EncryptorImpl::getImplementationName( ) + throw (cssu::RuntimeException) +{ + return EncryptorImpl_getImplementationName(); +} +sal_Bool SAL_CALL EncryptorImpl::supportsService( const rtl::OUString& rServiceName ) + throw (cssu::RuntimeException) +{ + return EncryptorImpl_supportsService( rServiceName ); +} +cssu::Sequence< rtl::OUString > SAL_CALL EncryptorImpl::getSupportedServiceNames( ) + throw (cssu::RuntimeException) +{ + return EncryptorImpl_getSupportedServiceNames(); +} + diff --git a/xmlsecurity/source/framework/encryptorimpl.hxx b/xmlsecurity/source/framework/encryptorimpl.hxx new file mode 100644 index 000000000000..4977cdb714a3 --- /dev/null +++ b/xmlsecurity/source/framework/encryptorimpl.hxx @@ -0,0 +1,190 @@ +/************************************************************************* + * + * $RCSfile: encryptorimpl.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:22 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _ENCRYPTORIMPL_HXX +#define _ENCRYPTORIMPL_HXX + +#ifndef _COM_SUN_STAR_XML_CRYPTO_SAX_XENCRYPTIONRESULTBROADCASTER_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_XML_CRYPTO_SAX_XENCRYPTIONRESULTLISTENER_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_XML_CRYPTO_SAX_XSIGNATURECOLLECTOR_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_LANG_XINITIALIZATION_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_ +#include +#endif +#ifndef _CPPUHELPER_IMPLBASE4_HXX_ +#include +#endif + +#include "encryptionengine.hxx" + +class EncryptorImpl : public cppu::ImplInheritanceHelper4 +< + EncryptionEngine, + com::sun::star::xml::crypto::sax::XEncryptionResultBroadcaster, + com::sun::star::xml::crypto::sax::XReferenceCollector, + com::sun::star::lang::XInitialization, + com::sun::star::lang::XServiceInfo +> +/****** EncryptorImpl.hxx/CLASS EncryptorImpl ********************************* + * + * NAME + * EncryptorImpl -- generates an encryption + * + * FUNCTION + * Collects all resources for an encryption generation, then generates the + * encryption by invoking a xmlsec-based encryption bridge component. + * + * HISTORY + * 05.01.2004 - Interface supported: XInitialization, XServiceInfo + * + * AUTHOR + * Michael Mi + * Email: michael.mi@sun.com + ******************************************************************************/ +{ +private: + /* + * the Id of the encryption, which is used for the result listener to + * identify the encryption. + */ + sal_Int32 m_nEncryptionId; + + /* + * the Id of the element to be encrypted. + */ + sal_Int32 m_nReferenceId; + + /* + * the decryption result, + * remembers whether the encryption succeeds. + */ + bool m_bEncryptionSucceed; + + virtual void notifyResultListener() const + throw (com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException); + virtual bool checkReady() const; + virtual void startEngine( const com::sun::star::uno::Reference< + com::sun::star::xml::crypto::XXMLEncryptionTemplate >& + xEncryptionTemplate) + throw (com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException); + +public: + explicit EncryptorImpl( const com::sun::star::uno::Reference< + com::sun::star::lang::XMultiServiceFactory >& rxMSF); + virtual ~EncryptorImpl(); + + /* XEncryptionResultBroadcaster */ + virtual void SAL_CALL addEncryptionResultListener( + const com::sun::star::uno::Reference< + com::sun::star::xml::crypto::sax::XEncryptionResultListener >& + listener ) + throw (com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeEncryptionResultListener( + const com::sun::star::uno::Reference< + com::sun::star::xml::crypto::sax::XEncryptionResultListener >& + listener ) + throw (com::sun::star::uno::RuntimeException); + + /* XReferenceCollector */ + virtual void SAL_CALL setReferenceCount( sal_Int32 count ) + throw (com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException); + + virtual void SAL_CALL setReferenceId( sal_Int32 id ) + throw (com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException); + + /* XInitialization */ + virtual void SAL_CALL initialize( + const com::sun::star::uno::Sequence< com::sun::star::uno::Any >& aArguments ) + throw (com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException); + + /* XServiceInfo */ + virtual rtl::OUString SAL_CALL getImplementationName( ) + throw (com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsService( const rtl::OUString& ServiceName ) + throw (com::sun::star::uno::RuntimeException); + virtual com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames( ) + throw (com::sun::star::uno::RuntimeException); +}; + +rtl::OUString EncryptorImpl_getImplementationName() + throw ( com::sun::star::uno::RuntimeException ); + +sal_Bool SAL_CALL EncryptorImpl_supportsService( const rtl::OUString& ServiceName ) + throw ( com::sun::star::uno::RuntimeException ); + +com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL EncryptorImpl_getSupportedServiceNames( ) + throw ( com::sun::star::uno::RuntimeException ); + +com::sun::star::uno::Reference< com::sun::star::uno::XInterface > +SAL_CALL EncryptorImpl_createInstance( + const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& rSMgr) + throw ( com::sun::star::uno::Exception ); + +#endif + diff --git a/xmlsecurity/source/framework/makefile.mk b/xmlsecurity/source/framework/makefile.mk new file mode 100644 index 000000000000..1ceaa7eb7b16 --- /dev/null +++ b/xmlsecurity/source/framework/makefile.mk @@ -0,0 +1,98 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1.1.1 $ +# +# last change: $Author: mt $ $Date: 2004-07-12 13:15:23 $ +# +# The Contents of this file are made available subject to the terms of +# either of the following licenses +# +# - GNU Lesser General Public License Version 2.1 +# - Sun Industry Standards Source License Version 1.1 +# +# Sun Microsystems Inc., October, 2000 +# +# GNU Lesser General Public License Version 2.1 +# ============================================= +# Copyright 2000 by Sun Microsystems, Inc. +# 901 San Antonio Road, Palo Alto, CA 94303, USA +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License version 2.1, as published by the Free Software Foundation. +# +# This library 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 for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, +# MA 02111-1307 USA +# +# +# Sun Industry Standards Source License Version 1.1 +# ================================================= +# The contents of this file are subject to the Sun Industry Standards +# Source License Version 1.1 (the "License"); You may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at http://www.openoffice.org/license.html. +# +# Software provided under this License is provided on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, +# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, +# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. +# See the License for the specific provisions governing your rights and +# obligations concerning the Software. +# +# The Initial Developer of the Original Code is: Sun Microsystems, Inc. +# +# Copyright: 2000 by Sun Microsystems, Inc. +# +# All Rights Reserved. +# +# Contributor(s): _______________________________________ +# +# +# +#************************************************************************* + +PRJ=..$/.. + +PRJNAME = xmlsecurity +TARGET = fw + +ENABLE_EXCEPTIONS = TRUE + +# --- Settings ----------------------------------------------------- + +.INCLUDE : svpre.mk +.INCLUDE : settings.mk +.INCLUDE : sv.mk +.INCLUDE : $(PRJ)$/util$/target.pmk + + +# --- Files -------------------------------------------------------- +SLOFILES= \ + $(SLO)$/buffernode.obj \ + $(SLO)$/elementcollector.obj \ + $(SLO)$/elementmark.obj \ + $(SLO)$/securityengine.obj \ + $(SLO)$/signatureengine.obj \ + $(SLO)$/encryptionengine.obj \ + $(SLO)$/signaturecreatorimpl.obj \ + $(SLO)$/signatureverifierimpl.obj \ + $(SLO)$/encryptorimpl.obj \ + $(SLO)$/decryptorimpl.obj \ + $(SLO)$/saxeventkeeperimpl.obj \ + $(SLO)$/xmlencryptiontemplateimpl.obj \ + $(SLO)$/xmlsignaturetemplateimpl.obj \ + $(SLO)$/xsec_framework.obj + +# --- Targets ------------------------------------------------------ + +.INCLUDE : target.mk + diff --git a/xmlsecurity/source/framework/saxeventkeeperimpl.cxx b/xmlsecurity/source/framework/saxeventkeeperimpl.cxx new file mode 100644 index 000000000000..d926d049db90 --- /dev/null +++ b/xmlsecurity/source/framework/saxeventkeeperimpl.cxx @@ -0,0 +1,1503 @@ +/************************************************************************* + * + * $RCSfile: saxeventkeeperimpl.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:22 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#include "saxeventkeeperimpl.hxx" + +#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_XML_SAX_XDOCUMENTHANDLER_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_XML_CRYPTO_SAX_CONSTOFSECURITYID_HPP_ +#include +#endif + +namespace cssu = com::sun::star::uno; +namespace cssl = com::sun::star::lang; +namespace cssxc = com::sun::star::xml::crypto; +namespace cssxcsax = com::sun::star::xml::csax; +namespace cssxw = com::sun::star::xml::wrapper; +namespace cssxs = com::sun::star::xml::sax; + +#define SERVICE_NAME "com.sun.star.xml.crypto.sax.SAXEventKeeper" +#define IMPLEMENTATION_NAME "com.sun.star.xml.security.framework.SAXEventKeeperImpl" + +#define _USECOMPRESSEDDOCUMENTHANDLER + +SAXEventKeeperImpl::SAXEventKeeperImpl( ) + :m_nNextElementMarkId(1), + m_pNewBlocker(NULL), + m_pCurrentBlockingBufferNode(NULL), + m_pRootBufferNode(NULL), + m_pCurrentBufferNode(NULL), + m_bIsForwarding(false), + m_bIsReleasing(false) +{ + m_vElementMarkBuffers.reserve(2); + m_vNewElementCollectors.reserve(2); + m_vReleasedElementMarkBuffers.reserve(2); +} + +SAXEventKeeperImpl::~SAXEventKeeperImpl() +{ + /* + * delete the BufferNode tree + */ + if (m_pRootBufferNode != NULL) + { + m_pRootBufferNode->freeAllChildren(); + delete m_pRootBufferNode; + } + + m_pRootBufferNode = m_pCurrentBufferNode = m_pCurrentBlockingBufferNode = NULL; + + /* + * delete all unfreed ElementMarks + */ + m_vNewElementCollectors.clear(); + m_pNewBlocker = NULL; + + std::vector< const ElementMark* >::const_iterator ii = m_vElementMarkBuffers.begin(); + for( ; ii != m_vElementMarkBuffers.end(); ++ii ) + { + delete (*ii); + } + m_vElementMarkBuffers.clear(); +} + +void SAXEventKeeperImpl::setCurrentBufferNode(BufferNode* pBufferNode) +/****** SAXEventKeeperImpl/setCurrentBufferNode ****************************** + * + * NAME + * setCurrentBufferNode -- set a new active BufferNode. + * + * SYNOPSIS + * setCurrentBufferNode( pBufferNode ); + * + * FUNCTION + * connects this BufferNode into the BufferNode tree as a child of the + * current active BufferNode. Then makes this BufferNode as the current + * active BufferNode. + * If the previous active BufferNode points to the root + * BufferNode, which means that no buffering operation was proceeding, + * then notifies the status change listener that buffering operation + * will begin at once. + * + * INPUTS + * pBufferNode - a BufferNode which will be the new active BufferNode + * + * RESULT + * empty + * + * HISTORY + * 05.01.2004 - implemented + * + * AUTHOR + * Michael Mi + * Email: michael.mi@sun.com + ******************************************************************************/ +{ + if (pBufferNode != m_pCurrentBufferNode) + { + if ( m_pCurrentBufferNode == m_pRootBufferNode && + m_xSAXEventKeeperStatusChangeListener.is()) + { + m_xSAXEventKeeperStatusChangeListener->collectionStatusChanged(sal_True); + } + + if (pBufferNode->getParent() == NULL) + { + m_pCurrentBufferNode->addChild(pBufferNode); + pBufferNode->setParent(m_pCurrentBufferNode); + } + + m_pCurrentBufferNode = pBufferNode; + } +} + +BufferNode* SAXEventKeeperImpl::addNewElementMarkBuffers() +/****** SAXEventKeeperImpl/addNewElementMarkBuffers ************************** + * + * NAME + * addNewElementMarkBuffers -- add new ElementCollectors and new Blocker. + * + * SYNOPSIS + * pBufferNode = addNewElementMarkBuffers( ); + * + * FUNCTION + * if there are new ElementCollector or new Blocker to be added, then + * connect all of them with the current BufferNode. In case of the + * current BufferNode doesn't exist, creates one. + * Clears up the new ElementCollector list and the new Blocker pointer. + * + * INPUTS + * empty + * + * RESULT + * pBufferNode - the BufferNode that has been connected with both new + * ElementCollectors and new Blocker. + * + * HISTORY + * 05.01.2004 - implemented + * + * AUTHOR + * Michael Mi + * Email: michael.mi@sun.com + ******************************************************************************/ +{ + BufferNode* pBufferNode = NULL; + + if ( (m_vNewElementCollectors.size()>0) || + (m_pNewBlocker != NULL)) + { + /* + * When the current BufferNode is right pointing to the current + * working element in the XMLDocumentWrapper component, then + * no new BufferNode is needed to create. + * This situation can only happen in the "Forwarding" mode. + */ + if ( (m_pCurrentBufferNode != NULL) && + (m_xXMLDocument->isCurrent(m_pCurrentBufferNode->getXMLElement()))) + { + pBufferNode = m_pCurrentBufferNode; + } + else + { + pBufferNode = new BufferNode(m_xXMLDocument->getCurrentElement()); + } + + if (m_pNewBlocker != NULL) + { + pBufferNode->setBlocker(m_pNewBlocker); + + /* + * If no blocking before, then notify the status change listener that + * the SAXEventKeeper has entered "blocking" status, during which, no + * SAX events will be forwarded to the next document handler. + */ + if (m_pCurrentBlockingBufferNode == NULL) + { + m_pCurrentBlockingBufferNode = pBufferNode; + + if (m_xSAXEventKeeperStatusChangeListener.is()) + { + m_xSAXEventKeeperStatusChangeListener->blockingStatusChanged(sal_True); + } + } + + m_pNewBlocker = NULL; + } + + if (m_vNewElementCollectors.size()>0) + { + std::vector< const ElementCollector* >::const_iterator ii = m_vNewElementCollectors.begin(); + + for( ; ii != m_vNewElementCollectors.end(); ++ii ) + { + pBufferNode->addElementCollector(*ii); + } + + m_vNewElementCollectors.clear(); + } + } + + return pBufferNode; +} + +ElementMark* SAXEventKeeperImpl::findElementMarkBuffer(sal_Int32 nId) const +/****** SAXEventKeeperImpl/findElementMarkBuffer ***************************** + * + * NAME + * findElementMarkBuffer -- finds an ElementMark. + * + * SYNOPSIS + * pElementMark = findElementMarkBuffer( nId ); + * + * FUNCTION + * searches an ElementMark with the particular Id in the ElementMark + * list. + * + * INPUTS + * nId - the Id of the ElementMark to be searched. + * + * RESULT + * pElementMark - the ElementMark with the particular Id, or NULL when + * no such Id exists. + * + * HISTORY + * 05.01.2004 - implemented + * + * AUTHOR + * Michael Mi + * Email: michael.mi@sun.com + ******************************************************************************/ +{ + ElementMark* pElementMark = NULL; + + std::vector< const ElementMark* >::const_iterator ii = m_vElementMarkBuffers.begin(); + + for( ; ii != m_vElementMarkBuffers.end(); ++ii ) + { + if ( nId == (*ii)->getBufferId()) + { + pElementMark = (ElementMark*)*ii; + break; + } + } + + return pElementMark; +} + +void SAXEventKeeperImpl::removeElementMarkBuffer(sal_Int32 nId) +/****** SAXEventKeeperImpl/removeElementMarkBuffer *************************** + * + * NAME + * removeElementMarkBuffer -- removes an ElementMark + * + * SYNOPSIS + * removeElementMarkBuffer( nId ); + * + * FUNCTION + * removes an ElementMark with the particular Id in the ElementMark list. + * + * INPUTS + * nId - the Id of the ElementMark to be removed. + * + * RESULT + * empty + * + * HISTORY + * 05.01.2004 - implemented + * + * AUTHOR + * Michael Mi + * Email: michael.mi@sun.com + ******************************************************************************/ +{ + std::vector< const ElementMark* >::iterator ii = m_vElementMarkBuffers.begin(); + + for( ; ii != m_vElementMarkBuffers.end(); ++ii ) + { + if ( nId == (*ii)->getBufferId()) + { + /* + * checks whether this ElementMark still in the new ElementCollect array + */ + std::vector< const ElementCollector* >::iterator jj = m_vNewElementCollectors.begin(); + for( ; jj != m_vNewElementCollectors.end(); ++jj ) + { + if ((*ii) == (*jj)) + { + m_vNewElementCollectors.erase(jj); + break; + } + } + + /* + * checks whether this ElementMark is the new Blocker + */ + if ((*ii) == m_pNewBlocker) + { + m_pNewBlocker = NULL; + } + + /* + * destory the ElementMark + */ + delete (*ii); + + m_vElementMarkBuffers.erase( ii ); + break; + } + } +} + +rtl::OUString SAXEventKeeperImpl::printBufferNode( + BufferNode* pBufferNode, sal_Int32 nIndent) const +/****** SAXEventKeeperImpl/printBufferNode *********************************** + * + * NAME + * printBufferNode -- retrieves the information of a BufferNode and its + * branch. + * + * SYNOPSIS + * info = printBufferNode( pBufferNode, nIndent ); + * + * FUNCTION + * all retrieved information includes: + * 1. whether it is the current BufferNode; + * 2. whether it is the current blocking BufferNode; + * 3. the name of the parent element; + * 4. the name of this element; + * 5. all ElementCollectors working on this BufferNode; + * 6. the Blocker working on this BufferNode; + * 7. all child BufferNodes' information. + * + * INPUTS + * pBufferNode - the BufferNode from where information will be retrieved. + * nIndent - how many space characters prefixed before the output + * message. + * + * RESULT + * info - the information string + * + * HISTORY + * 05.01.2004 - implemented + * + * AUTHOR + * Michael Mi + * Email: michael.mi@sun.com + ******************************************************************************/ +{ + rtl::OUString rc; + + for ( int i=0; igetNodeName(pBufferNode->getXMLElement()); + + BufferNode* pParent = (BufferNode*)pBufferNode->getParent(); + if (pParent != NULL) + { + rc += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "[" )); + rc += m_xXMLDocument->getNodeName(pParent->getXMLElement()); + rc += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "]" )); + } + + rc += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ":EC=" )); + rc += pBufferNode->printChildren(); + rc += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( " BR=" )); + + ElementMark * pBlocker = pBufferNode->getBlocker(); + if (pBlocker != NULL) + { + rc += rtl::OUString::valueOf( pBlocker->getBufferId() ); + rc += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "(SecId=" )); + rc += rtl::OUString::valueOf( pBlocker->getSecurityId() ); + rc += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ")" )); + rc += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( " " )); + } + rc += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "\n" )); + + std::vector< const BufferNode* >* vChildren = pBufferNode->getChildren(); + std::vector< const BufferNode* >::const_iterator jj = vChildren->begin(); + for( ; jj != vChildren->end(); ++jj ) + { + rc += printBufferNode((BufferNode *)*jj, nIndent+4); + } + + delete vChildren; + + return rc; +} + +cssu::Sequence< cssu::Reference< cssxw::XXMLElementWrapper > > + SAXEventKeeperImpl::collectChildWorkingElement(BufferNode* pBufferNode) const +/****** SAXEventKeeperImpl/collectChildWorkingElement ************************ + * + * NAME + * collectChildWorkingElement -- collects a BufferNode's all child + * Elements. + * + * SYNOPSIS + * list = collectChildWorkingElement( pBufferNode ); + * + * FUNCTION + * see NAME. + * + * INPUTS + * pBufferNode - the BufferNode whose child Elements will be collected. + * + * RESULT + * list - the child Elements list. + * + * HISTORY + * 05.01.2004 - implemented + * + * AUTHOR + * Michael Mi + * Email: michael.mi@sun.com + ******************************************************************************/ +{ + std::vector< const BufferNode* >* vChildren = pBufferNode->getChildren(); + + cssu::Sequence < cssu::Reference< + cssxw::XXMLElementWrapper > > aChildrenCollection ( vChildren->size()); + + std::vector< const BufferNode* >::const_iterator ii = vChildren->begin(); + + sal_Int32 nIndex = 0; + for( ; ii != vChildren->end(); ++ii ) + { + aChildrenCollection[nIndex] = (*ii)->getXMLElement(); + nIndex++; + } + + delete vChildren; + + return aChildrenCollection; +} + +void SAXEventKeeperImpl::smashBufferNode( + BufferNode* pBufferNode, bool bClearRoot) const +/****** SAXEventKeeperImpl/smashBufferNode *********************************** + * + * NAME + * smashBufferNode -- removes a BufferNode along with its working + * element. + * + * SYNOPSIS + * smashBufferNode( pBufferNode, bClearRoot ); + * + * FUNCTION + * removes the BufferNode's working element from the DOM document, while + * reserves all ancestor paths for its child BufferNodes. + * when any of the BufferNode's ancestor element is useless, removes it + * too. + * removes the BufferNode from the BufferNode tree. + * + * INPUTS + * pBufferNode - the BufferNode to be removed + * bClearRoot - whether the root element also needs to be cleared up. + * + * RESULT + * empty + * + * NOTES + * when removeing a Blocker's BufferNode, the bClearRoot flag should be + * true. Because a Blocker can buffer many SAX events which are not used + * by any other ElementCollector or Blocker. + * When the bClearRoot is set to true, the root BufferNode will be first + * cleared, with a stop flag seting at the next Blocking BufferNode. This + * operation can delete all useless bufferred SAX events which are only + * needed by the Blocker to be deleted. + * + * HISTORY + * 05.01.2004 - implemented + * + * AUTHOR + * Michael Mi + * Email: michael.mi@sun.com + ******************************************************************************/ +{ + if (!pBufferNode->hasAnything()) + { + BufferNode* pParent = (BufferNode*)pBufferNode->getParent(); + + /* + * delete the XML data + */ + if (pParent == m_pRootBufferNode) + { + bool bIsNotBlocking = (m_pCurrentBlockingBufferNode == NULL); + bool bIsBlockInside = false; + bool bIsBlockingAfterward = false; + + /* + * If this is a blocker, then remove any out-element data + * which caused by blocking. The removal process will stop + * at the next blokcer to avoid removing any useful data. + */ + if (bClearRoot) + { + cssu::Sequence< cssu::Reference< cssxw::XXMLElementWrapper > > + aChildElements = collectChildWorkingElement(m_pRootBufferNode); + + /* + * the clearUselessData only clearup the content in the + * node, not the node itself. + */ + m_xXMLDocument->clearUselessData(m_pRootBufferNode->getXMLElement(), + aChildElements, + bIsNotBlocking?(NULL): + (m_pCurrentBlockingBufferNode->getXMLElement())); + + /* + * remove the node if it is empty, then if its parent is also + * empty, remove it, then if the next parent is also empty, + * remove it,..., until parent become null. + */ + m_xXMLDocument->collapse( m_pRootBufferNode->getXMLElement() ); + } + + /* + * if blocking, check the relationship between this BufferNode and + * the current blocking BufferNode. + */ + if ( !bIsNotBlocking ) + { + /* + * the current blocking BufferNode is a descendant of this BufferNode. + */ + bIsBlockInside = (NULL != pBufferNode->isAncestor(m_pCurrentBlockingBufferNode)); + + /* + * the current blocking BufferNode locates behind this BufferNode in tree + * order. + */ + bIsBlockingAfterward = pBufferNode->isPrevious(m_pCurrentBlockingBufferNode); + } + + /* + * this BufferNode's working element needs to be deleted only when + * 1. there is no blocking, or + * 2. the current blocking BufferNode is a descendant of this BufferNode, + * (then in the BufferNode's working element, the useless data before the blocking + * element should be deleted.) or + * 3. the current blocking BufferNode is locates behind this BufferNode in tree, + * (then the useless data between the blocking element and the working element + * should be deleted.). + * Otherwise, this working element should not be deleted. + */ + if ( bIsNotBlocking || bIsBlockInside || bIsBlockingAfterward ) + { + cssu::Sequence< cssu::Reference< cssxw::XXMLElementWrapper > > + aChildElements = collectChildWorkingElement(pBufferNode); + + /* + * the clearUselessData only clearup the content in the + * node, not the node itself. + */ + m_xXMLDocument->clearUselessData(pBufferNode->getXMLElement(), + aChildElements, + bIsBlockInside?(m_pCurrentBlockingBufferNode->getXMLElement()): + (NULL)); + + /* + * remove the node if it is empty, then if its parent is also + * empty, remove it, then if the next parent is also empty, + * remove it,..., until parent become null. + */ + m_xXMLDocument->collapse( pBufferNode->getXMLElement() ); + } + } + + sal_Int32 nIndex = pParent->indexOfChild(pBufferNode); + + std::vector< const BufferNode* >* vChildren = pBufferNode->getChildren(); + pParent->removeChild(pBufferNode); + pBufferNode->setParent(NULL); + + std::vector< const BufferNode * >::const_iterator ii = vChildren->begin(); + for( ; ii != vChildren->end(); ++ii ) + { + ((BufferNode *)(*ii))->setParent(pParent); + pParent->addChild(*ii, nIndex); + nIndex++; + } + + delete vChildren; + + /* + * delete the BufferNode + */ + delete pBufferNode; + } +} + +BufferNode* SAXEventKeeperImpl::findNextBlockingBufferNode( + BufferNode* pStartBufferNode) const +/****** SAXEventKeeperImpl/findNextBlockingBufferNode ************************ + * + * NAME + * findNextBlockingBufferNode -- finds the next blocking BufferNode + * behind the particular BufferNode. + * + * SYNOPSIS + * pBufferNode = findNextBlockingBufferNode( pStartBufferNode ); + * + * FUNCTION + * see NAME. + * + * INPUTS + * pStartBufferNode - the BufferNode from where to search the next + * blocking BufferNode. + * + * RESULT + * pBufferNode - the next blocking BufferNode, or NULL if no such + * BufferNode exists. + * + * HISTORY + * 05.01.2004 - implemented + * + * AUTHOR + * Michael Mi + * Email: michael.mi@sun.com + ******************************************************************************/ +{ + BufferNode* pNext = NULL; + + if (pStartBufferNode != NULL) + { + pNext = pStartBufferNode; + + while (NULL != (pNext = (BufferNode*)pNext->getNextNodeByTreeOrder())) + { + if (pNext->getBlocker() != NULL) + { + break; + } + } + } + + return pNext; +} + +void SAXEventKeeperImpl::diffuse(BufferNode* pBufferNode) const +/****** SAXEventKeeperImpl/diffuse ******************************************* + * + * NAME + * diffuse -- diffuse the notification. + * + * SYNOPSIS + * diffuse( pBufferNode ); + * + * FUNCTION + * diffuse the collecting completion notification from the specific + * BufferNode along its parent link, until an ancestor which is not + * completely received is met. + * + * INPUTS + * pBufferNode - the BufferNode from which the notification will be + * diffused. + * + * RESULT + * empty + * + * HISTORY + * 05.01.2004 - implemented + * + * AUTHOR + * Michael Mi + * Email: michael.mi@sun.com + ******************************************************************************/ +{ + BufferNode* pParent = pBufferNode; + + while(pParent->isAllReceived()) + { + pParent->elementCollectorNotify(); + pParent = (BufferNode*)pParent->getParent(); + } +} + +void SAXEventKeeperImpl::releaseElementMarkBuffer() +/****** SAXEventKeeperImpl/releaseElementMarkBuffer ************************** + * + * NAME + * releaseElementMarkBuffer -- releases useless ElementMarks + * + * SYNOPSIS + * releaseElementMarkBuffer( ); + * + * FUNCTION + * releases each ElementMark in the releasing list + * m_vReleasedElementMarkBuffers. + * The operation differs between an ElementCollector and a Blocker. + * + * INPUTS + * empty + * + * RESULT + * empty + * + * HISTORY + * 05.01.2004 - implemented + * + * AUTHOR + * Michael Mi + * Email: michael.mi@sun.com + ******************************************************************************/ +{ + m_bIsReleasing = true; + while (m_vReleasedElementMarkBuffers.size()>0) + { + std::vector< sal_Int32 >::iterator pId = m_vReleasedElementMarkBuffers.begin(); + sal_Int32 nId = *pId; + m_vReleasedElementMarkBuffers.erase( pId ); + + ElementMark* pElementMark = findElementMarkBuffer(nId); + + if (pElementMark != NULL) + { + if (cssxc::sax::ElementMarkType_TYPEOFELEMENTCOLLECTOR + == pElementMark->getType()) + /* + * it is a EC + */ + { + ElementCollector* pElementCollector = (ElementCollector*)pElementMark; + + cssxc::sax::ElementMarkPriority nPriority = pElementCollector->getPriority(); + bool bToModify = pElementCollector->getModify(); + + /* + * Delete the EC from the buffer node. + */ + BufferNode* pBufferNode = pElementCollector->getBufferNode(); + pBufferNode->removeElementCollector(pElementCollector); + + if ( nPriority == cssxc::sax::ElementMarkPriority_PRI_BEFOREMODIFY) + { + pBufferNode->notifyBranch(); + } + + if (bToModify) + { + pBufferNode->notifyAncestor(); + } + + /* + * delete the ElementMark + */ + pElementCollector = NULL; + pElementMark = NULL; + removeElementMarkBuffer(nId); + + /* + * delete the BufferNode + */ + diffuse(pBufferNode); + smashBufferNode(pBufferNode, false); + } + else + /* + * it is a Blocker + */ + { + /* + * Delete the TH from the buffer node. + */ + BufferNode *pBufferNode = pElementMark->getBufferNode(); + pBufferNode->setBlocker(NULL); + + /* + * If there is a following handler and no blocking now, then + * forward this event + */ + if (m_pCurrentBlockingBufferNode == pBufferNode) + { + /* + * Before forwarding, the next blocking point needs to be + * found. + */ + m_pCurrentBlockingBufferNode = findNextBlockingBufferNode(pBufferNode); + + /* + * Forward the blocked events between these two STHs. + */ + if (m_xNextHandler.is()) + { + BufferNode* pTempCurrentBufferNode = m_pCurrentBufferNode; + BufferNode* pTempCurrentBlockingBufferNode = m_pCurrentBlockingBufferNode; + + m_pCurrentBufferNode = pBufferNode; + m_pCurrentBlockingBufferNode = NULL; + + m_bIsForwarding = true; + + m_xXMLDocument->generateSAXEvents( + m_xNextHandler, + this, + pBufferNode->getXMLElement(), + (pTempCurrentBlockingBufferNode == NULL)?NULL:(pTempCurrentBlockingBufferNode->getXMLElement())); + + m_bIsForwarding = false; + + m_pCurrentBufferNode = pTempCurrentBufferNode; + if (m_pCurrentBlockingBufferNode == NULL) + { + m_pCurrentBlockingBufferNode = pTempCurrentBlockingBufferNode; + } + } + + if (m_pCurrentBlockingBufferNode == NULL && + m_xSAXEventKeeperStatusChangeListener.is()) + { + m_xSAXEventKeeperStatusChangeListener->blockingStatusChanged(sal_False); + } + } + + /* + * delete the ElementMark + */ + pElementMark = NULL; + removeElementMarkBuffer(nId); + + /* + * delete the BufferNode + */ + diffuse(pBufferNode); + smashBufferNode(pBufferNode, true); + } + } + } + + m_bIsReleasing = false; + + if (!m_pRootBufferNode->hasAnything() && + !m_pRootBufferNode->hasChildren() && + m_xSAXEventKeeperStatusChangeListener.is()) + { + m_xSAXEventKeeperStatusChangeListener->bufferStatusChanged(sal_True); + } +} + +void SAXEventKeeperImpl::markElementMarkBuffer(sal_Int32 nId) +/****** SAXEventKeeperImpl/markElementMarkBuffer ***************************** + * + * NAME + * markElementMarkBuffer -- marks an ElementMark to be released + * + * SYNOPSIS + * markElementMarkBuffer( nId ); + * + * FUNCTION + * puts the ElementMark with the particular Id into the releasing list, + * checks whether the releasing process is runing, if not then launch + * this process. + * + * INPUTS + * nId - the Id of the ElementMark which will be released + * + * RESULT + * empty + * + * HISTORY + * 05.01.2004 - implemented + * + * AUTHOR + * Michael Mi + * Email: michael.mi@sun.com + ******************************************************************************/ +{ + m_vReleasedElementMarkBuffers.push_back( nId ); + if ( !m_bIsReleasing ) + { + releaseElementMarkBuffer(); + } +} + +sal_Int32 SAXEventKeeperImpl::createElementCollector( + sal_Int32 nSecurityId, + cssxc::sax::ElementMarkPriority nPriority, + bool bModifyElement, + const cssu::Reference< cssxc::sax::XReferenceResolvedListener >& xReferenceResolvedListener) +/****** SAXEventKeeperImpl/createElementCollector **************************** + * + * NAME + * createElementCollector -- creates a new ElementCollector on the + * incoming element. + * + * SYNOPSIS + * nId = createElementCollector( nSecurityId, nPriority, + * bModifyElement, + * xReferenceResolvedListener ); + * + * FUNCTION + * allocs a new Id, then create an ElementCollector with this Id value. + * Add the new created ElementCollector to the new ElementCollecotor list. + * + * INPUTS + * nSecurityId - the security Id of the new ElementCollector + * nPriority - the prirority of the new ElementCollector + * bModifyElement -whether this BufferNode will modify the content of + * the corresponding element it works on + * xReferenceResolvedListener - the listener for the new ElementCollector. + * + * RESULT + * nId - the Id of the new ElementCollector + * + * HISTORY + * 05.01.2004 - implemented + * + * AUTHOR + * Michael Mi + * Email: michael.mi@sun.com + ******************************************************************************/ +{ + sal_Int32 nId = m_nNextElementMarkId; + m_nNextElementMarkId ++; + + ElementCollector* pElementCollector + = new ElementCollector( + nSecurityId, + nId, + nPriority, + bModifyElement, + xReferenceResolvedListener); + + m_vElementMarkBuffers.push_back( pElementCollector ); + + /* + * All the new EC to initial EC array. + */ + m_vNewElementCollectors.push_back( pElementCollector ); + + return nId; +} + + +sal_Int32 SAXEventKeeperImpl::createBlocker(sal_Int32 nSecurityId) +/****** SAXEventKeeperImpl/createBlocker ************************************* + * + * NAME + * createBlocker -- creates a new Blocker on the incoming element. + * + * SYNOPSIS + * nId = createBlocker( nSecurityId ); + * + * FUNCTION + * see NAME. + * + * INPUTS + * nSecurityId - the security Id of the new Blocker + * + * RESULT + * nId - the Id of the new Blocker + * + * HISTORY + * 05.01.2004 - implemented + * + * AUTHOR + * Michael Mi + * Email: michael.mi@sun.com + ******************************************************************************/ +{ + sal_Int32 nId = m_nNextElementMarkId; + m_nNextElementMarkId ++; + + OSL_ASSERT(m_pNewBlocker == NULL); + + m_pNewBlocker = new ElementMark(nSecurityId, nId); + m_vElementMarkBuffers.push_back( m_pNewBlocker ); + + return nId; +} + +/* XSAXEventKeeper */ +sal_Int32 SAL_CALL SAXEventKeeperImpl::addElementCollector( ) + throw (cssu::RuntimeException) +{ + return createElementCollector( + cssxc::sax::ConstOfSecurityId::UNDEFINEDSECURITYID, + cssxc::sax::ElementMarkPriority_PRI_AFTERMODIFY, + false, + NULL); +} + +void SAL_CALL SAXEventKeeperImpl::removeElementCollector( sal_Int32 id ) + throw (cssu::RuntimeException) +{ + markElementMarkBuffer(id); +} + +sal_Int32 SAL_CALL SAXEventKeeperImpl::addBlocker( ) + throw (cssu::RuntimeException) +{ + return createBlocker(cssxc::sax::ConstOfSecurityId::UNDEFINEDSECURITYID); +} + +void SAL_CALL SAXEventKeeperImpl::removeBlocker( sal_Int32 id ) + throw (cssu::RuntimeException) +{ + markElementMarkBuffer(id); +} + +sal_Bool SAL_CALL SAXEventKeeperImpl::isBlocking( ) + throw (cssu::RuntimeException) +{ + return (m_pCurrentBlockingBufferNode != NULL); +} + +cssu::Reference< cssxw::XXMLElementWrapper > SAL_CALL + SAXEventKeeperImpl::getElement( sal_Int32 id ) + throw (cssu::RuntimeException) +{ + cssu::Reference< cssxw::XXMLElementWrapper > rc; + + ElementMark* pElementMark = findElementMarkBuffer(id); + if (pElementMark != NULL) + { + rc = pElementMark->getBufferNode()->getXMLElement(); + } + + return rc; +} + +void SAL_CALL SAXEventKeeperImpl::setElement( + sal_Int32 id, + const cssu::Reference< cssxw::XXMLElementWrapper >& aElement ) + throw (cssu::RuntimeException) +{ + if (aElement.is()) + { + m_xXMLDocument->rebuildIDLink(aElement); + + ElementMark* pElementMark = findElementMarkBuffer(id); + + if (pElementMark != NULL) + { + BufferNode* pBufferNode = pElementMark->getBufferNode(); + if (pBufferNode != NULL) + { + bool bIsCurrent = m_xXMLDocument->isCurrent(pBufferNode->getXMLElement()); + pBufferNode->setXMLElement(aElement); + + if (bIsCurrent) + { + m_xXMLDocument->setCurrentElement(aElement); + } + } + } + } + else + { + removeElementCollector( id ); + } +} + +cssu::Reference< cssxs::XDocumentHandler > SAL_CALL SAXEventKeeperImpl::setNextHandler( + const cssu::Reference< cssxs::XDocumentHandler >& xNewHandler ) + throw (cssu::RuntimeException) +{ + cssu::Reference< cssxs::XDocumentHandler > xOldHandler = m_xNextHandler; + + m_xNextHandler = xNewHandler; + return xOldHandler; +} + +rtl::OUString SAL_CALL SAXEventKeeperImpl::printBufferNodeTree() + throw (cssu::RuntimeException) +{ + rtl::OUString rc; + + rc += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ElementMarkBuffers: size = " )); + rc += rtl::OUString::valueOf((sal_Int32)m_vElementMarkBuffers.size()); + rc += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "\nCurrentBufferNode: " )); + rc += m_xXMLDocument->getNodeName(m_pCurrentBufferNode->getXMLElement()); + rc += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "\n" )); + rc += printBufferNode(m_pRootBufferNode, 0); + + return rc; +} + +cssu::Reference< cssxw::XXMLElementWrapper > SAL_CALL SAXEventKeeperImpl::getCurrentBlockingNode() + throw (cssu::RuntimeException) +{ + cssu::Reference< cssxw::XXMLElementWrapper > rc; + + if (m_pCurrentBlockingBufferNode != NULL) + { + rc = m_pCurrentBlockingBufferNode->getXMLElement(); + } + + return rc; +} + +/* XSecuritySAXEventKeeper */ +sal_Int32 SAL_CALL SAXEventKeeperImpl::addSecurityElementCollector( + cssxc::sax::ElementMarkPriority priority, + sal_Bool modifyElement ) + throw (cssu::RuntimeException) +{ + return createElementCollector( + cssxc::sax::ConstOfSecurityId::UNDEFINEDSECURITYID, + priority, + modifyElement, + NULL); +} + +sal_Int32 SAL_CALL SAXEventKeeperImpl::cloneElementCollector( + sal_Int32 referenceId, + cssxc::sax::ElementMarkPriority priority ) + throw (cssu::RuntimeException) +{ + sal_Int32 nId = -1; + + ElementCollector* pElementCollector = (ElementCollector*)findElementMarkBuffer(referenceId); + if (pElementCollector != NULL) + { + nId = m_nNextElementMarkId; + m_nNextElementMarkId ++; + + ElementCollector* pClonedOne + = pElementCollector->clone(nId, priority); + + /* + * add this EC into the security data buffer array. + */ + m_vElementMarkBuffers.push_back(pClonedOne); + + /* + * If the reference EC is still in initial EC array, add + * this cloned one into the initial EC array too. + */ + if (pElementCollector->getBufferNode() == NULL) + { + m_vNewElementCollectors.push_back(pClonedOne); + } + } + + return nId; +} + +void SAL_CALL SAXEventKeeperImpl::setSecurityId( sal_Int32 id, sal_Int32 securityId ) + throw (cssu::RuntimeException) +{ + ElementMark* pElementMark = findElementMarkBuffer(id); + if (pElementMark != NULL) + { + pElementMark->setSecurityId(securityId); + } +} + + +/* XReferenceResolvedBroadcaster */ +void SAL_CALL SAXEventKeeperImpl::addReferenceResolvedListener( + sal_Int32 referenceId, + const cssu::Reference< cssxc::sax::XReferenceResolvedListener >& listener ) + throw (cssu::RuntimeException) +{ + ElementCollector* pElementCollector = (ElementCollector*)findElementMarkBuffer(referenceId); + if (pElementCollector != NULL) + { + pElementCollector->setReferenceResolvedListener(listener); + } +} + +void SAL_CALL SAXEventKeeperImpl::removeReferenceResolvedListener( + sal_Int32 referenceId, + const cssu::Reference< cssxc::sax::XReferenceResolvedListener >& listener ) + throw (cssu::RuntimeException) +{ +} + +/* XSAXEventKeeperStatusChangeBroadcaster */ +void SAL_CALL SAXEventKeeperImpl::addXSAXEventKeeperStatusChangeListener( + const cssu::Reference< cssxc::sax::XSAXEventKeeperStatusChangeListener >& listener ) + throw (cssu::RuntimeException) +{ + m_xSAXEventKeeperStatusChangeListener = listener; +} + +void SAL_CALL SAXEventKeeperImpl::removeXSAXEventKeeperStatusChangeListener( + const cssu::Reference< cssxc::sax::XSAXEventKeeperStatusChangeListener >& listener ) + throw (cssu::RuntimeException) +{ +} + +/* XDocumentHandler */ +void SAL_CALL SAXEventKeeperImpl::startDocument( ) + throw (cssxs::SAXException, cssu::RuntimeException) +{ + if ( m_xNextHandler.is()) + { + m_xNextHandler->startDocument(); + } +} + +void SAL_CALL SAXEventKeeperImpl::endDocument( ) + throw (cssxs::SAXException, cssu::RuntimeException) +{ + if ( m_xNextHandler.is()) + { + m_xNextHandler->endDocument(); + } +} + +void SAL_CALL SAXEventKeeperImpl::startElement( + const rtl::OUString& aName, + const cssu::Reference< cssxs::XAttributeList >& xAttribs ) + throw (cssxs::SAXException, cssu::RuntimeException) +{ + /* + * If there is a following handler and no blocking now, then + * forward this event + */ + if ((m_pCurrentBlockingBufferNode == NULL) && + (m_xNextHandler.is()) && + (!m_bIsForwarding) && + (m_pNewBlocker == NULL)) + { + m_xNextHandler->startElement(aName, xAttribs); + } + + /* + * If not forwarding, buffer this startElement. + */ + if (!m_bIsForwarding) + { + #ifndef _USECOMPRESSEDDOCUMENTHANDLER + m_xDocumentHandler->startElement(aName, xAttribs); + #else + sal_Int32 nLength = xAttribs->getLength(); + cssu::Sequence< cssxcsax::XMLAttribute > aAttributes (nLength); + + for ( int i = 0; igetNameByIndex((short)i); + aAttributes[i].sValue =xAttribs->getValueByIndex((short)i); + } + + m_xCompressedDocumentHandler->_startElement(aName, aAttributes); + #endif + + } + + BufferNode* pBufferNode = addNewElementMarkBuffers(); + if (pBufferNode != NULL) + { + setCurrentBufferNode(pBufferNode); + } +} + +void SAL_CALL SAXEventKeeperImpl::endElement( const rtl::OUString& aName ) + throw (cssxs::SAXException, cssu::RuntimeException) +{ + sal_Bool bIsCurrent = m_xXMLDocument->isCurrent(m_pCurrentBufferNode->getXMLElement()); + + /* + * If there is a following handler and no blocking now, then + * forward this event + */ + if ((m_pCurrentBlockingBufferNode == NULL) && + (m_xNextHandler.is()) && + (!m_bIsForwarding)) + { + m_xNextHandler->endElement(aName); + } + + if ((m_pCurrentBlockingBufferNode != NULL) || + (m_pCurrentBufferNode != m_pRootBufferNode) || + (!m_xXMLDocument->isCurrentElementEmpty())) + { + if (!m_bIsForwarding) + { + #ifndef _USECOMPRESSEDDOCUMENTHANDLER + m_xDocumentHandler->endElement(aName); + #else + m_xCompressedDocumentHandler->_endElement(aName); + #endif + } + + /* + * If the current buffer node has not notified yet, and + * the current buffer node is waiting for the current element, + * then let it notify. + */ + if (bIsCurrent && (m_pCurrentBufferNode != m_pRootBufferNode)) + { + BufferNode* pOldCurrentBufferNode = m_pCurrentBufferNode; + m_pCurrentBufferNode = (BufferNode*)m_pCurrentBufferNode->getParent(); + + pOldCurrentBufferNode->setReceivedAll(); + + if ((m_pCurrentBufferNode == m_pRootBufferNode) && + m_xSAXEventKeeperStatusChangeListener.is()) + { + m_xSAXEventKeeperStatusChangeListener->collectionStatusChanged(sal_False); + } + } + } + else + { + if (!m_bIsForwarding) + { + m_xXMLDocument->removeCurrentElement(); + } + } +} + +void SAL_CALL SAXEventKeeperImpl::characters( const rtl::OUString& aChars ) + throw (cssxs::SAXException, cssu::RuntimeException) +{ + if (!m_bIsForwarding) + { + if ((m_pCurrentBlockingBufferNode == NULL) && m_xNextHandler.is()) + { + m_xNextHandler->characters(aChars); + } + + if ((m_pCurrentBlockingBufferNode != NULL) || + (m_pCurrentBufferNode != m_pRootBufferNode)) + { + #ifndef _USECOMPRESSEDDOCUMENTHANDLER + m_xDocumentHandler->characters(aChars); + #else + m_xCompressedDocumentHandler->_characters(aChars); + #endif + } + } +} + +void SAL_CALL SAXEventKeeperImpl::ignorableWhitespace( const rtl::OUString& aWhitespaces ) + throw (cssxs::SAXException, cssu::RuntimeException) +{ + characters( aWhitespaces ); +} + +void SAL_CALL SAXEventKeeperImpl::processingInstruction( + const rtl::OUString& aTarget, const rtl::OUString& aData ) + throw (cssxs::SAXException, cssu::RuntimeException) +{ + if (!m_bIsForwarding) + { + if ((m_pCurrentBlockingBufferNode == NULL) && m_xNextHandler.is()) + { + m_xNextHandler->processingInstruction(aTarget, aData); + } + + if ((m_pCurrentBlockingBufferNode != NULL) || + (m_pCurrentBufferNode != m_pRootBufferNode)) + { + #ifndef _USECOMPRESSEDDOCUMENTHANDLER + m_xDocumentHandler->processingInstruction(aTarget, aData); + #else + m_xCompressedDocumentHandler->_processingInstruction(aTarget, aData); + #endif + } + } +} + +void SAL_CALL SAXEventKeeperImpl::setDocumentLocator( const cssu::Reference< cssxs::XLocator >& xLocator ) + throw (cssxs::SAXException, cssu::RuntimeException) +{ +} + +/* XInitialization */ +void SAL_CALL SAXEventKeeperImpl::initialize( const cssu::Sequence< cssu::Any >& aArguments ) + throw (cssu::Exception, cssu::RuntimeException) +{ + sal_Int32 nLength = aArguments.getLength(); + + OSL_ASSERT(nLength == 1); + + aArguments[0] >>= m_xXMLDocument; + m_xDocumentHandler = cssu::Reference< cssxs::XDocumentHandler >( + m_xXMLDocument, cssu::UNO_QUERY ); + m_xCompressedDocumentHandler = cssu::Reference< cssxcsax::XCompressedDocumentHandler >( + m_xXMLDocument, cssu::UNO_QUERY ); + + m_pRootBufferNode = new BufferNode(m_xXMLDocument->getCurrentElement()); + m_pCurrentBufferNode = m_pRootBufferNode; +} + +rtl::OUString SAXEventKeeperImpl_getImplementationName () + throw (cssu::RuntimeException) +{ + return rtl::OUString ( RTL_CONSTASCII_USTRINGPARAM ( IMPLEMENTATION_NAME ) ); +} + +sal_Bool SAL_CALL SAXEventKeeperImpl_supportsService( const rtl::OUString& ServiceName ) + throw (cssu::RuntimeException) +{ + return ServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( SERVICE_NAME )); +} + +cssu::Sequence< rtl::OUString > SAL_CALL SAXEventKeeperImpl_getSupportedServiceNames( ) + throw (cssu::RuntimeException) +{ + cssu::Sequence < rtl::OUString > aRet(1); + rtl::OUString* pArray = aRet.getArray(); + pArray[0] = rtl::OUString ( RTL_CONSTASCII_USTRINGPARAM ( SERVICE_NAME ) ); + return aRet; +} +#undef SERVICE_NAME + +cssu::Reference< cssu::XInterface > SAL_CALL SAXEventKeeperImpl_createInstance( + const cssu::Reference< cssl::XMultiServiceFactory > & rSMgr) + throw( cssu::Exception ) +{ + return (cppu::OWeakObject*) new SAXEventKeeperImpl(); +} + +/* XServiceInfo */ +rtl::OUString SAL_CALL SAXEventKeeperImpl::getImplementationName( ) + throw (cssu::RuntimeException) +{ + return SAXEventKeeperImpl_getImplementationName(); +} +sal_Bool SAL_CALL SAXEventKeeperImpl::supportsService( const rtl::OUString& rServiceName ) + throw (cssu::RuntimeException) +{ + return SAXEventKeeperImpl_supportsService( rServiceName ); +} +cssu::Sequence< rtl::OUString > SAL_CALL SAXEventKeeperImpl::getSupportedServiceNames( ) + throw (cssu::RuntimeException) +{ + return SAXEventKeeperImpl_getSupportedServiceNames(); +} + diff --git a/xmlsecurity/source/framework/saxeventkeeperimpl.hxx b/xmlsecurity/source/framework/saxeventkeeperimpl.hxx new file mode 100644 index 000000000000..04ee57e37c50 --- /dev/null +++ b/xmlsecurity/source/framework/saxeventkeeperimpl.hxx @@ -0,0 +1,423 @@ +/************************************************************************* + * + * $RCSfile: saxeventkeeperimpl.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:22 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _SAXEVENTKEEPERIMPL_HXX +#define _SAXEVENTKEEPERIMPL_HXX + +#ifndef _COM_SUN_STAR_XML_CRYPTO_SAX_XSECURITYSAXEVENTKEEPER_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_XML_CRYPTO_SAX_XREFERENCERESOLVEDBROADCASTER_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_XML_CRYPTO_SAX_XSAXEVENTKEEPERSTATUSCHANGEBROADCASTER_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_XML_CRYPTO_SAX_XSAXEVENTKEEPERSTATUSCHANGELISTENER_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_XML_CSAX_XCOMPRESSEDDOCUMENTHANDLER_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_XML_WRAPPER_XXMLDOCUMENTWRAPPER_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_XML_SAX_XDOCUMENTHANDLER_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_LANG_XINITIALIZATION_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_ +#include +#endif +#ifndef _CPPUHELPER_IMPLBASE6_HXX_ +#include +#endif + +#include "buffernode.hxx" +#include "elementmark.hxx" +#include "elementcollector.hxx" + +#ifndef INCLUDED_VECTOR +#include +#define INCLUDED_VECTOR +#endif + +class SAXEventKeeperImpl : public cppu::WeakImplHelper6 +< + com::sun::star::xml::crypto::sax::XSecuritySAXEventKeeper, + com::sun::star::xml::crypto::sax::XReferenceResolvedBroadcaster, + com::sun::star::xml::crypto::sax::XSAXEventKeeperStatusChangeBroadcaster, + com::sun::star::xml::sax::XDocumentHandler, + com::sun::star::lang::XInitialization, + com::sun::star::lang::XServiceInfo +> +/****** SAXEventKeeperImpl.hxx/CLASS SAXEventKeeperImpl *********************** + * + * NAME + * SAXEventKeeperImpl -- SAX events buffer controller + * + * FUNCTION + * Controls SAX events to be bufferred, and controls bufferred SAX events + * to be released. + * + * HISTORY + * 05.01.2004 - Interface supported: XSecuritySAXEventKeeper, + * XReferenceResolvedBroadcaster, + * XSAXEventKeeperStatusChangeBroadcaster, + * XDocumentHandler, XInitialization, XServiceInfo + * + * AUTHOR + * Michael Mi + * Email: michael.mi@sun.com + ******************************************************************************/ +{ +private: + /* + * the XMLDocumentWrapper component which maintains all bufferred SAX + * in DOM format. + */ + com::sun::star::uno::Reference< + com::sun::star::xml::wrapper::XXMLDocumentWrapper > + m_xXMLDocument; + + /* + * the document handler provided by the XMLDocumentWrapper component. + */ + com::sun::star::uno::Reference< + com::sun::star::xml::sax::XDocumentHandler > m_xDocumentHandler; + + /* + * the compressed document handler provided by the XMLDocumentWrapper + * component, the handler has more effient method definition that the + * normal document handler. + */ + com::sun::star::uno::Reference< + com::sun::star::xml::csax::XCompressedDocumentHandler > + m_xCompressedDocumentHandler; + + /* + * a listener which receives this SAXEventKeeper's status change + * notification. + * Based on the status changes, the listener can decide whether the + * SAXEventKeeper should chain on/chain off the SAX chain, or whether + * the SAXEventKeeper is useless any long. + */ + com::sun::star::uno::Reference< + com::sun::star::xml::crypto::sax::XSAXEventKeeperStatusChangeListener > + m_xSAXEventKeeperStatusChangeListener; + + /* + * the root node of the BufferNode tree. + * the BufferNode tree is used to keep track of all bufferred elements, + * it has the same structure with the document which maintains those + * elements physically. + */ + BufferNode* m_pRootBufferNode; + + /* + * the current active BufferNode. + * this is used to keep track the current location in the BufferNode tree, + * the next generated BufferNode will become a child BufferNode of it. + */ + BufferNode* m_pCurrentBufferNode; + + /* + * the next Id for a coming ElementMark. + * the variable is increased by 1 when an new ElementMark is generated, + * in this way, we can promise the Id of any ElementMark is unique. + */ + sal_Int32 m_nNextElementMarkId; + + /* + * maintains a collection of all ElementMarks. + */ + std::vector< const ElementMark* > m_vElementMarkBuffers; + + /* + * maintains a list of new ElementCollectors that will be created + * on the element represented by the next incoming startElement SAX + * event. + * The reason that such the m_vNewElementCollectors is necessary + * is: when an ElementCollector is asked to create, it can't be + * created completely at once, because the BufferNode it will be + * working on has not been created until the next startElement + * SAX event comes. + */ + std::vector< const ElementCollector* > m_vNewElementCollectors; + + /* + * maintains the new Blocker that will be created + * on the element represented by the next incoming startElement SAX + * event. + */ + ElementMark* m_pNewBlocker; + + /* + * the document handler to which all received SAX events will be + * forwarded. + */ + com::sun::star::uno::Reference< + com::sun::star::xml::sax::XDocumentHandler > m_xNextHandler; + + /* + * the current BufferNode which prevents the SAX events to be + * forwarded to the m_xNextHandler. + */ + BufferNode* m_pCurrentBlockingBufferNode; + + /* + * maintains a list of ElementMark that has been asked to release. + * Because during processing a request of releasing an ElementMark, + * another releasing ElementMark request can be invoked. To avoid + * reentering the same method, a such request only add that ElementMark + * into this ElementMark list, then all ElementMarks will be processed in + * order. + */ + std::vector< sal_Int32 > m_vReleasedElementMarkBuffers; + + /* + * a flag to indicate whether the ElementMark releasing process is runing. + * When a releasing request comes, the assigned ElementMark is added to + * the m_vReleasedElementMarkBuffers first, then this flag is checked. + * If the ElementMark releasing process is not running, then call that + * method. + */ + bool m_bIsReleasing; + + /* + * a flag to indicate whether it is the "Forwarding" mode now. + * A "Forwarding" mode means that all received SAX events are from the + * XMLDocumentWrapper component, instead of up-stream component in the + * SAX chain. + * The difference between "Forwarding" mode and normal mode is that: + * no SAX events need to be transferred to the XMLDocumentWrapper component + * again even if a buffer request happens. + */ + bool m_bIsForwarding; + + void setCurrentBufferNode(BufferNode* pBufferNode); + + BufferNode* addNewElementMarkBuffers(); + + ElementMark* findElementMarkBuffer(sal_Int32 nId) const; + + void removeElementMarkBuffer(sal_Int32 nId); + + rtl::OUString printBufferNode( + BufferNode* pBufferNode, sal_Int32 nIndent) const; + + com::sun::star::uno::Sequence< com::sun::star::uno::Reference< + com::sun::star::xml::wrapper::XXMLElementWrapper > > + collectChildWorkingElement(BufferNode* pBufferNode) const; + + void smashBufferNode( + BufferNode* pBufferNode, bool bClearRoot) const; + + BufferNode* findNextBlockingBufferNode( + BufferNode* pStartBufferNode) const; + + void diffuse(BufferNode* pBufferNode) const; + + void releaseElementMarkBuffer(); + + void markElementMarkBuffer(sal_Int32 nId); + + sal_Int32 createElementCollector( + sal_Int32 nSecurityId, + com::sun::star::xml::crypto::sax::ElementMarkPriority nPriority, + bool bModifyElement, + const com::sun::star::uno::Reference< + com::sun::star::xml::crypto::sax::XReferenceResolvedListener>& + xReferenceResolvedListener); + + sal_Int32 createBlocker(sal_Int32 nSecurityId); + +public: + SAXEventKeeperImpl(); + virtual ~SAXEventKeeperImpl(); + + /* XSAXEventKeeper */ + virtual sal_Int32 SAL_CALL addElementCollector( ) + throw (com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeElementCollector( sal_Int32 id ) + throw (com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL addBlocker( ) + throw (com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeBlocker( sal_Int32 id ) + throw (com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isBlocking( ) + throw (com::sun::star::uno::RuntimeException); + virtual com::sun::star::uno::Reference< + com::sun::star::xml::wrapper::XXMLElementWrapper > SAL_CALL + getElement( sal_Int32 id ) + throw (com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setElement( + sal_Int32 id, + const com::sun::star::uno::Reference< + com::sun::star::xml::wrapper::XXMLElementWrapper >& + aElement ) + throw (com::sun::star::uno::RuntimeException); + virtual com::sun::star::uno::Reference< + com::sun::star::xml::sax::XDocumentHandler > SAL_CALL + setNextHandler( const com::sun::star::uno::Reference< + com::sun::star::xml::sax::XDocumentHandler >& xNewHandler ) + throw (com::sun::star::uno::RuntimeException); + virtual rtl::OUString SAL_CALL printBufferNodeTree() + throw (com::sun::star::uno::RuntimeException); + virtual com::sun::star::uno::Reference< + com::sun::star::xml::wrapper::XXMLElementWrapper > SAL_CALL + getCurrentBlockingNode() + throw (com::sun::star::uno::RuntimeException); + + /* XSecuritySAXEventKeeper */ + virtual sal_Int32 SAL_CALL addSecurityElementCollector( + com::sun::star::xml::crypto::sax::ElementMarkPriority priority, + sal_Bool modifyElement ) + throw (com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL cloneElementCollector( + sal_Int32 referenceId, + com::sun::star::xml::crypto::sax::ElementMarkPriority priority ) + throw (com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setSecurityId( sal_Int32 id, sal_Int32 securityId ) + throw (com::sun::star::uno::RuntimeException); + + /* XReferenceResolvedBroadcaster */ + virtual void SAL_CALL addReferenceResolvedListener( + sal_Int32 referenceId, + const com::sun::star::uno::Reference< + com::sun::star::xml::crypto::sax::XReferenceResolvedListener >& + listener ) + throw (com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeReferenceResolvedListener( + sal_Int32 referenceId, + const com::sun::star::uno::Reference< + com::sun::star::xml::crypto::sax::XReferenceResolvedListener >& + listener ) + throw (com::sun::star::uno::RuntimeException); + + /* XSAXEventKeeperStatusChangeBroadcaster */ + virtual void SAL_CALL addXSAXEventKeeperStatusChangeListener( + const com::sun::star::uno::Reference< + com::sun::star::xml::crypto::sax::XSAXEventKeeperStatusChangeListener >& + listener ) + throw (com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeXSAXEventKeeperStatusChangeListener( + const com::sun::star::uno::Reference< + com::sun::star::xml::crypto::sax::XSAXEventKeeperStatusChangeListener >& + listener ) + throw (com::sun::star::uno::RuntimeException); + + /* XDocumentHandler */ + virtual void SAL_CALL startDocument( ) + throw (com::sun::star::xml::sax::SAXException, com::sun::star::uno::RuntimeException); + virtual void SAL_CALL endDocument( ) + throw (com::sun::star::xml::sax::SAXException, com::sun::star::uno::RuntimeException); + virtual void SAL_CALL startElement( + const rtl::OUString& aName, + const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList >& + xAttribs ) + throw (com::sun::star::xml::sax::SAXException, com::sun::star::uno::RuntimeException); + virtual void SAL_CALL endElement( const rtl::OUString& aName ) + throw (com::sun::star::xml::sax::SAXException, com::sun::star::uno::RuntimeException); + virtual void SAL_CALL characters( const rtl::OUString& aChars ) + throw (com::sun::star::xml::sax::SAXException, com::sun::star::uno::RuntimeException); + virtual void SAL_CALL ignorableWhitespace( const rtl::OUString& aWhitespaces ) + throw (com::sun::star::xml::sax::SAXException, com::sun::star::uno::RuntimeException); + virtual void SAL_CALL processingInstruction( + const rtl::OUString& aTarget, const rtl::OUString& aData ) + throw (com::sun::star::xml::sax::SAXException, com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setDocumentLocator( + const com::sun::star::uno::Reference< com::sun::star::xml::sax::XLocator >& xLocator ) + throw (com::sun::star::xml::sax::SAXException, com::sun::star::uno::RuntimeException); + + /* XInitialization */ + virtual void SAL_CALL initialize( + const com::sun::star::uno::Sequence< com::sun::star::uno::Any >& aArguments ) + throw (com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException); + + /* XServiceInfo */ + virtual rtl::OUString SAL_CALL getImplementationName( ) + throw (com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsService( const rtl::OUString& ServiceName ) + throw (com::sun::star::uno::RuntimeException); + virtual com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames( ) + throw (com::sun::star::uno::RuntimeException); +}; + +rtl::OUString SAXEventKeeperImpl_getImplementationName() + throw ( com::sun::star::uno::RuntimeException ); + +sal_Bool SAL_CALL SAXEventKeeperImpl_supportsService( const rtl::OUString& ServiceName ) + throw ( com::sun::star::uno::RuntimeException ); + +com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL SAXEventKeeperImpl_getSupportedServiceNames( ) + throw ( com::sun::star::uno::RuntimeException ); + +com::sun::star::uno::Reference< com::sun::star::uno::XInterface > +SAL_CALL SAXEventKeeperImpl_createInstance( const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > & rSMgr) + throw ( com::sun::star::uno::Exception ); + +#endif + + + diff --git a/xmlsecurity/source/framework/securityengine.cxx b/xmlsecurity/source/framework/securityengine.cxx new file mode 100644 index 000000000000..d4528b3c25b1 --- /dev/null +++ b/xmlsecurity/source/framework/securityengine.cxx @@ -0,0 +1,122 @@ +/************************************************************************* + * + * $RCSfile: securityengine.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:23 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#include "securityengine.hxx" + +#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_ +#include +#endif + +namespace cssu = com::sun::star::uno; +namespace cssl = com::sun::star::lang; +namespace cssxc = com::sun::star::xml::crypto; +namespace cssxw = com::sun::star::xml::wrapper; + +#define DECLARE_ASCII( SASCIIVALUE ) \ + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SASCIIVALUE ) ) + +SecurityEngine::SecurityEngine( const cssu::Reference< cssl::XMultiServiceFactory >& rxMSF ) + :mxMSF( rxMSF ), + m_nIdOfTemplateEC(-1), + m_nIdOfKeyEC(-1), + m_nNumOfResolvedReferences(0), + m_bMissionDone(false), + m_nSecurityId(-1), + m_bOperationSucceed(false) +{ +} + +/* XReferenceResolvedListener */ +void SAL_CALL SecurityEngine::referenceResolved( sal_Int32 referenceId ) + throw (com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException) +{ + m_nNumOfResolvedReferences++; + tryToPerform(); +} + +/* XKeyCollector */ +void SAL_CALL SecurityEngine::setKeyId( sal_Int32 id ) + throw (com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException) +{ + m_nIdOfKeyEC = id; + tryToPerform(); +} + +/* XMissionTaker */ +sal_Bool SAL_CALL SecurityEngine::endMission( ) + throw (com::sun::star::uno::RuntimeException) +{ + sal_Bool rc = m_bMissionDone; + + if (!rc) + { + clearUp( ); + + notifyResultListener(); + m_bMissionDone = true; + } + + m_xResultListener = NULL; + m_xSAXEventKeeper = NULL; + + return rc; +} + diff --git a/xmlsecurity/source/framework/securityengine.hxx b/xmlsecurity/source/framework/securityengine.hxx new file mode 100644 index 000000000000..e944f6b42554 --- /dev/null +++ b/xmlsecurity/source/framework/securityengine.hxx @@ -0,0 +1,225 @@ +/************************************************************************* + * + * $RCSfile: securityengine.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:23 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _SECURITYENGINE_HXX +#define _SECURITYENGINE_HXX + +#ifndef _COM_SUN_STAR_XML_CRYPTO_SAX_XREFERENCERESOLVEDLISTENER_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_XML_CRYPTO_SAX_XREFERENCERESOLVEDBROADCASTER_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_XML_CRYPTO_SAX_XKEYCOLLECTOR_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_XML_CRYPTO_SAX_XMISSIONTAKER_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_XML_CRYPTO_SAX_XSAXEVENTKEEPER_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_XML_CRYPTO_XXMLSECURITYCONTEXT_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_XML_CRYPTO_XXMLSIGNATURE_HPP_ +#include +#endif + +#ifndef _CPPUHELPER_IMPLBASE3_HXX_ +#include +#endif + +class SecurityEngine : public cppu::WeakImplHelper3 +< + com::sun::star::xml::crypto::sax::XReferenceResolvedListener, + com::sun::star::xml::crypto::sax::XKeyCollector, + com::sun::star::xml::crypto::sax::XMissionTaker +> +/****** securityengine.hxx/CLASS SecurityEngine ******************************* + * + * NAME + * SecurityEngine -- Base class of SignatureEngine and EncryptionEngine + * + * FUNCTION + * Maintains common members and methods related with security engine + * operation. + * + * HISTORY + * 05.01.2004 - Interface supported: XReferenceResolvedListener, + * XKeyCollector, and XMissionTaker + * + * AUTHOR + * Michael Mi + * Email: michael.mi@sun.com + ******************************************************************************/ +{ +protected: + com::sun::star::uno::Reference< + com::sun::star::lang::XMultiServiceFactory > mxMSF; + + com::sun::star::uno::Reference< + com::sun::star::xml::crypto::XXMLSecurityContext > m_xXMLSecurityContext; + + /* + * A SAXEventKeeper internally maintians all resources that a security + * operation needs. The m_xSAXEventKeeper member is used to release + * those resources when the security operation finishes. + */ + com::sun::star::uno::Reference< + com::sun::star::xml::crypto::sax::XSAXEventKeeper > m_xSAXEventKeeper; + + /* + * the id of ElementCollector of the template element. + * For a signature, the template element is the Signature element, + * for a encryption, the EncryptedData/EncryptedKey element is. + */ + sal_Int32 m_nIdOfTemplateEC; + + /* + * remembers how many referenced elements have been bufferred completely, + * including the key element, template element, and referenced element of + * signature. + */ + sal_Int32 m_nNumOfResolvedReferences; + + /* + * the id of ElementCollector of the key element. + * If a Signature element or EncryptedData/EncryptedKey element has + * an internal key sub-element, then this member should be -1 + */ + sal_Int32 m_nIdOfKeyEC; + + /* + * remembers whether the current opertion has finished. + */ + bool m_bMissionDone; + + /* + * the Id of the security entity, a signature or encryption, which is used for + * the result listener to identify the entity. + */ + sal_Int32 m_nSecurityId; + + /* + * the result of the operation + */ + bool m_bOperationSucceed; + + /* + * the result listener, which will receives the security operation result. + */ + com::sun::star::uno::Reference< + com::sun::star::uno::XInterface > + m_xResultListener; + +protected: + explicit SecurityEngine( const com::sun::star::uno::Reference< + com::sun::star::lang::XMultiServiceFactory >& rxMSF = NULL ); + virtual ~SecurityEngine() {}; + + /* + * perform the security operation. + * Any derived class will implement this method respectively. + */ + virtual void tryToPerform( ) + throw (com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException){}; + + /* + * clear up all resources used by this operation. + * This method is called after the operation finishes, or a End-Your-Mission + * message is received. + * Any derived class will implement this method respectively. + */ + virtual void clearUp( ) const {}; + + /* + * notifies any possible result listener. + * When verify a signature or conduct a decryption, the operation result will + * be transferred to a listener by this method. + * Any derived class will implement this method respectively. + */ + virtual void notifyResultListener() const + throw (com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException) + {}; + + /* + * checks whether everything is ready. + * Any derived class will implement this method respectively. + */ + virtual bool checkReady() const { return true; }; + +public: + /* XReferenceResolvedListener */ + virtual void SAL_CALL referenceResolved( sal_Int32 referenceId ) + throw (com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException); + + /* XKeyCollector */ + virtual void SAL_CALL setKeyId( sal_Int32 id ) + throw (com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException); + + /* XMissionTaker */ + virtual sal_Bool SAL_CALL endMission( ) + throw (com::sun::star::uno::RuntimeException); +}; + +#endif + diff --git a/xmlsecurity/source/framework/signaturecreatorimpl.cxx b/xmlsecurity/source/framework/signaturecreatorimpl.cxx new file mode 100644 index 000000000000..3de42e6c4e11 --- /dev/null +++ b/xmlsecurity/source/framework/signaturecreatorimpl.cxx @@ -0,0 +1,343 @@ +/************************************************************************* + * + * $RCSfile: signaturecreatorimpl.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:23 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#include "signaturecreatorimpl.hxx" + +#ifndef _COM_SUN_STAR_XML_CRYPTO_XXMLSIGNATURETEMPLATE_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_XML_WRAPPER_XXMLELEMENTWRAPPER_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_XML_CRYPTO_SAX_SIGNATURECREATIONRESULT_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_ +#include +#endif + +namespace cssu = com::sun::star::uno; +namespace cssl = com::sun::star::lang; +namespace cssxc = com::sun::star::xml::crypto; +namespace cssxw = com::sun::star::xml::wrapper; + +#define SERVICE_NAME "com.sun.star.xml.crypto.sax.SignatureCreator" +#define IMPLEMENTATION_NAME "com.sun.star.xml.security.framework.SignatureCreatorImpl" + +#define DECLARE_ASCII( SASCIIVALUE ) \ + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SASCIIVALUE ) ) + +SignatureCreatorImpl::SignatureCreatorImpl( const cssu::Reference< cssl::XMultiServiceFactory >& rxMSF ) + :m_nIdOfBlocker(-1) +{ + mxMSF = rxMSF; +} + +SignatureCreatorImpl::~SignatureCreatorImpl( ) +{ +} + +bool SignatureCreatorImpl::checkReady() const +/****** SignatureCreatorImpl/checkReady ************************************** + * + * NAME + * checkReady -- checks the conditions for the signature generation. + * + * SYNOPSIS + * bReady = checkReady( ); + * + * FUNCTION + * checks whether all following conditions are satisfied: + * 1. the result listener is ready; + * 2. the id of the template blocker is known; + * 3. the SignatureEngine is ready. + * + * INPUTS + * empty + * + * RESULT + * bReady - true if all conditions are satisfied, false otherwise + * + * HISTORY + * 05.01.2004 - implemented + * + * AUTHOR + * Michael Mi + * Email: michael.mi@sun.com + ******************************************************************************/ +{ + return (m_xResultListener.is() && + (m_nIdOfBlocker != -1) && + SignatureEngine::checkReady()); +} + +void SignatureCreatorImpl::notifyResultListener() const + throw (cssu::Exception, cssu::RuntimeException) +/****** SignatureCreatorImpl/notifyResultListener ***************************** + * + * NAME + * notifyResultListener -- notifies the listener about the signature + * creation result. + * + * SYNOPSIS + * notifyResultListener( ); + * + * FUNCTION + * see NAME. + * + * INPUTS + * empty + * + * RESULT + * empty + * + * HISTORY + * 05.01.2004 - implemented + * + * AUTHOR + * Michael Mi + * Email: michael.mi@sun.com + ******************************************************************************/ +{ + cssu::Reference< cssxc::sax::XSignatureCreationResultListener > + xSignatureCreationResultListener ( m_xResultListener , cssu::UNO_QUERY ) ; + + xSignatureCreationResultListener->signatureCreated( + m_nSecurityId, + m_bOperationSucceed?(cssxc::sax::SignatureCreationResult_CREATIONSUCCEED): + (cssxc::sax::SignatureCreationResult_CREATIONFAIL)); +} + +void SignatureCreatorImpl::startEngine( const cssu::Reference< + cssxc::XXMLSignatureTemplate >& + xSignatureTemplate) + throw (cssu::Exception, cssu::RuntimeException) +/****** SignatureCreatorImpl/startEngine ************************************* + * + * NAME + * startEngine -- generates the signature. + * + * SYNOPSIS + * startEngine( xSignatureTemplate ); + * + * FUNCTION + * generates the signature element, then if succeeds, updates the link + * of old template element to the new signature element in + * SAXEventKeeper. + * + * INPUTS + * xSignatureTemplate - the signature template (along with all referenced + * elements) to be signed. + * + * RESULT + * empty + * + * HISTORY + * 05.01.2004 - implemented + * + * AUTHOR + * Michael Mi + * Email: michael.mi@sun.com + ******************************************************************************/ +{ + cssu::Reference< cssxc::XXMLSignatureTemplate > xResultTemplate; + try + { + xResultTemplate = m_xXMLSignature->generate(xSignatureTemplate, m_xXMLSecurityContext); + } + catch( cssu::Exception& ) + { + xResultTemplate = NULL; + } + + if (xResultTemplate.is()) + { + cssu::Reference < cssxw::XXMLElementWrapper > xResultSignature = xResultTemplate->getTemplate(); + m_xSAXEventKeeper->setElement(m_nIdOfTemplateEC, xResultSignature); + + m_bOperationSucceed = true; + } +} + +void SignatureCreatorImpl::clearUp() const +/****** SignatureCreatorImpl/clearUp ***************************************** + * + * NAME + * clearUp -- clear up all resources used by the signature generation. + * + * SYNOPSIS + * clearUp( ); + * + * FUNCTION + * cleaning resources up includes: + * 1. SignatureEngine's clearing up; + * 2. releases the Blocker for the signature template element. + * + * INPUTS + * empty + * + * RESULT + * empty + * + * HISTORY + * 05.01.2004 - implemented + * + * AUTHOR + * Michael Mi + * Email: michael.mi@sun.com + ******************************************************************************/ +{ + SignatureEngine::clearUp(); + + if (m_nIdOfBlocker != -1) + { + m_xSAXEventKeeper->removeBlocker(m_nIdOfBlocker); + } +} + +/* XBlockerMonitor */ +void SAL_CALL SignatureCreatorImpl::setBlockerId( sal_Int32 id ) + throw (cssu::Exception, cssu::RuntimeException) +{ + m_nIdOfBlocker = id; + tryToPerform(); +} + +/* XSignatureCreationResultBroadcaster */ +void SAL_CALL SignatureCreatorImpl::addSignatureCreationResultListener( + const cssu::Reference< cssxc::sax::XSignatureCreationResultListener >& listener ) + throw (cssu::Exception, cssu::RuntimeException) +{ + m_xResultListener = listener; + tryToPerform(); +} + +void SAL_CALL SignatureCreatorImpl::removeSignatureCreationResultListener( + const cssu::Reference< cssxc::sax::XSignatureCreationResultListener >& listener ) + throw (cssu::RuntimeException) +{ +} + +/* XInitialization */ +void SAL_CALL SignatureCreatorImpl::initialize( const cssu::Sequence< cssu::Any >& aArguments ) + throw (cssu::Exception, cssu::RuntimeException) +{ + sal_Int32 nLength = aArguments.getLength(); + OSL_ASSERT(nLength == 5); + + rtl::OUString ouTempString; + + aArguments[0] >>= ouTempString; + m_nSecurityId = ouTempString.toInt32(); + aArguments[1] >>= m_xSAXEventKeeper; + aArguments[2] >>= ouTempString; + m_nIdOfTemplateEC = ouTempString.toInt32(); + aArguments[3] >>= m_xXMLSecurityContext; + aArguments[4] >>= m_xXMLSignature; +} + + +rtl::OUString SignatureCreatorImpl_getImplementationName () + throw (cssu::RuntimeException) +{ + return rtl::OUString ( RTL_CONSTASCII_USTRINGPARAM ( IMPLEMENTATION_NAME ) ); +} + +sal_Bool SAL_CALL SignatureCreatorImpl_supportsService( const rtl::OUString& ServiceName ) + throw (cssu::RuntimeException) +{ + return ServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( SERVICE_NAME )); +} + +cssu::Sequence< rtl::OUString > SAL_CALL SignatureCreatorImpl_getSupportedServiceNames( ) + throw (cssu::RuntimeException) +{ + cssu::Sequence < rtl::OUString > aRet(1); + rtl::OUString* pArray = aRet.getArray(); + pArray[0] = rtl::OUString ( RTL_CONSTASCII_USTRINGPARAM ( SERVICE_NAME ) ); + return aRet; +} +#undef SERVICE_NAME + +cssu::Reference< cssu::XInterface > SAL_CALL SignatureCreatorImpl_createInstance( + const cssu::Reference< cssl::XMultiServiceFactory >& rSMgr) + throw( cssu::Exception ) +{ + return (cppu::OWeakObject*) new SignatureCreatorImpl( rSMgr ); +} + +/* XServiceInfo */ +rtl::OUString SAL_CALL SignatureCreatorImpl::getImplementationName( ) + throw (cssu::RuntimeException) +{ + return SignatureCreatorImpl_getImplementationName(); +} +sal_Bool SAL_CALL SignatureCreatorImpl::supportsService( const rtl::OUString& rServiceName ) + throw (cssu::RuntimeException) +{ + return SignatureCreatorImpl_supportsService( rServiceName ); +} +cssu::Sequence< rtl::OUString > SAL_CALL SignatureCreatorImpl::getSupportedServiceNames( ) + throw (cssu::RuntimeException) +{ + return SignatureCreatorImpl_getSupportedServiceNames(); +} + diff --git a/xmlsecurity/source/framework/signaturecreatorimpl.hxx b/xmlsecurity/source/framework/signaturecreatorimpl.hxx new file mode 100644 index 000000000000..e2ef6f7f1e2e --- /dev/null +++ b/xmlsecurity/source/framework/signaturecreatorimpl.hxx @@ -0,0 +1,189 @@ +/************************************************************************* + * + * $RCSfile: signaturecreatorimpl.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:23 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _SIGNATURECREATORIMPL_HXX +#define _SIGNATURECREATORIMPL_HXX + +#ifndef _COM_SUN_STAR_XML_CRYPTO_SAX_XBLOCKERMONITOR_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_XML_CRYPTO_SAX_XSIGNATURECREATIONRESULTLISTENER_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_XML_CRYPTO_SAX_XSIGNATURECREATIONRESULTBROADCASTER_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_LANG_XINITIALIZATION_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_ +#include +#endif +#ifndef _CPPUHELPER_IMPLBASE4_HXX_ +#include +#endif + +#include "signatureengine.hxx" + +class SignatureCreatorImpl : public cppu::ImplInheritanceHelper4 +< + SignatureEngine, + com::sun::star::xml::crypto::sax::XBlockerMonitor, + com::sun::star::xml::crypto::sax::XSignatureCreationResultBroadcaster, + com::sun::star::lang::XInitialization, + com::sun::star::lang::XServiceInfo +> +/****** SignatureCreatorImpl.hxx/CLASS SignatureCreatorImpl ******************* + * + * NAME + * SignatureCreatorImpl -- generates a signature + * + * FUNCTION + * Collects all resources for a signature generation, then generates the + * signature by invoking a xmlsec-based signature bridge component. + * + * HISTORY + * 05.01.2004 - Interface supported: XBlockerMonitor, + * XInitialization, XServiceInfo + * + * AUTHOR + * Michael Mi + * Email: michael.mi@sun.com + ******************************************************************************/ +{ +private: + /* + * the Id of the signature, which is used for the result listener to + * identify the signature. + */ + sal_Int32 m_nSignatureId; + + /* + * the Id of template blocker. + */ + sal_Int32 m_nIdOfBlocker; + + /* + * the signature creation result + */ + bool m_bCreationSucceed; + + virtual void notifyResultListener() const + throw (com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException); + virtual void clearUp( ) const; + virtual bool checkReady() const; + virtual void startEngine( const com::sun::star::uno::Reference< + com::sun::star::xml::crypto::XXMLSignatureTemplate >& + xSignatureTemplate) + throw (com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException); + +public: + explicit SignatureCreatorImpl( const com::sun::star::uno::Reference< + com::sun::star::lang::XMultiServiceFactory >& rxMSF); + virtual ~SignatureCreatorImpl(); + + /* XBlockerMonitor */ + virtual void SAL_CALL setBlockerId( sal_Int32 id ) + throw (com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException); + + /* XSignatureCreationResultBroadcaster */ + void SAL_CALL addSignatureCreationResultListener( + const com::sun::star::uno::Reference< + com::sun::star::xml::crypto::sax::XSignatureCreationResultListener >& listener ) + throw (com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException); + + void SAL_CALL removeSignatureCreationResultListener( + const com::sun::star::uno::Reference< + com::sun::star::xml::crypto::sax::XSignatureCreationResultListener >& listener ) + throw (com::sun::star::uno::RuntimeException); + + /* XInitialization */ + virtual void SAL_CALL initialize( + const com::sun::star::uno::Sequence< com::sun::star::uno::Any >& aArguments ) + throw (com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException); + + /* XServiceInfo */ + virtual rtl::OUString SAL_CALL getImplementationName( ) + throw (com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsService( const rtl::OUString& ServiceName ) + throw (com::sun::star::uno::RuntimeException); + virtual com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames( ) + throw (com::sun::star::uno::RuntimeException); +}; + +rtl::OUString SignatureCreatorImpl_getImplementationName() + throw ( com::sun::star::uno::RuntimeException ); + +sal_Bool SAL_CALL SignatureCreatorImpl_supportsService( const rtl::OUString& ServiceName ) + throw ( com::sun::star::uno::RuntimeException ); + +com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL SignatureCreatorImpl_getSupportedServiceNames( ) + throw ( com::sun::star::uno::RuntimeException ); + +com::sun::star::uno::Reference< com::sun::star::uno::XInterface > +SAL_CALL SignatureCreatorImpl_createInstance( + const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > & rSMgr) + throw ( com::sun::star::uno::Exception ); + +#endif + + + diff --git a/xmlsecurity/source/framework/signatureengine.cxx b/xmlsecurity/source/framework/signatureengine.cxx new file mode 100644 index 000000000000..bbb3765cf4e6 --- /dev/null +++ b/xmlsecurity/source/framework/signatureengine.cxx @@ -0,0 +1,306 @@ +/************************************************************************* + * + * $RCSfile: signatureengine.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:23 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#include "signatureengine.hxx" + +#ifndef _COM_SUN_STAR_XML_CRYPTO_XXMLSIGNATURETEMPLATE_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_XML_WRAPPER_XXMLELEMENTWRAPPER_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_ +#include +#endif + +namespace cssu = com::sun::star::uno; +namespace cssl = com::sun::star::lang; +namespace cssxc = com::sun::star::xml::crypto; +namespace cssxw = com::sun::star::xml::wrapper; + +#define SIGNATURE_TEMPLATE "com.sun.star.xml.crypto.XMLSignatureTemplate" + +#define DECLARE_ASCII( SASCIIVALUE ) \ + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SASCIIVALUE ) ) + +SignatureEngine::SignatureEngine( ) + :m_nTotalReferenceNumber(-1) +{ +} + +bool SignatureEngine::checkReady() const +/****** SignatureEngine/checkReady ******************************************* + * + * NAME + * checkReady -- checks the conditions for the main operation. + * + * SYNOPSIS + * bReady = checkReady( ); + * + * FUNCTION + * checks whether all following conditions are satisfied: + * 1. the main operation has't begun yet; + * 2. the key material is known; + * 3. the amount of reference is known; + * 4. all of referenced elements, the key element and the signature + * template are bufferred. + * + * INPUTS + * empty + * + * RESULT + * bReady - true if all conditions are satisfied, false otherwise + * + * HISTORY + * 05.01.2004 - implemented + * + * AUTHOR + * Michael Mi + * Email: michael.mi@sun.com + ******************************************************************************/ +{ + bool rc = true; + + sal_Int32 nKeyInc = 0; + if (m_nIdOfKeyEC != 0) + { + nKeyInc = 1; + } + + if (m_bMissionDone || + m_nIdOfKeyEC == -1 || + m_nTotalReferenceNumber == -1 || + m_nTotalReferenceNumber+1+nKeyInc > m_nNumOfResolvedReferences) + { + rc = false; + } + + return rc; +} + +void SignatureEngine::tryToPerform( ) + throw (cssu::Exception, cssu::RuntimeException) +/****** SignatureEngine/tryToPerform ***************************************** + * + * NAME + * tryToPerform -- tries to perform the signature operation. + * + * SYNOPSIS + * tryToPerform( ); + * + * FUNCTION + * if the situation is ready, perform following operations. + * 1. prepares a signature template; + * 2. calls the signature bridge component; + * 3. clears up all used resources; + * 4. notifies the result listener; + * 5. sets the "accomplishment" flag. + * + * INPUTS + * empty + * + * RESULT + * empty + * + * HISTORY + * 05.01.2004 - implemented + * + * AUTHOR + * Michael Mi + * Email: michael.mi@sun.com + ******************************************************************************/ +{ + if (checkReady()) + { + const rtl::OUString ouSignatureTemplate ( + RTL_CONSTASCII_USTRINGPARAM( SIGNATURE_TEMPLATE ) ); + cssu::Reference < cssxc::XXMLSignatureTemplate > + xSignatureTemplate( mxMSF->createInstance( ouSignatureTemplate ), cssu::UNO_QUERY ); + + OSL_ASSERT( xSignatureTemplate.is() ); + + cssu::Reference< cssxw::XXMLElementWrapper > + xXMLElement = m_xSAXEventKeeper->getElement( m_nIdOfTemplateEC ); + + xSignatureTemplate->setTemplate(xXMLElement); + + std::vector< sal_Int32 >::const_iterator ii = m_vReferenceIds.begin(); + + for( ; ii != m_vReferenceIds.end() ; ++ii ) + { + xXMLElement = m_xSAXEventKeeper->getElement( *ii ); + xSignatureTemplate->setTarget(xXMLElement); + } + + /* + * set the Uri binding + */ + xSignatureTemplate->setBinding( this ); + + startEngine( xSignatureTemplate ); + + /* + * done + */ + clearUp( ); + + notifyResultListener(); + + m_bMissionDone = true; + } +} + +void SignatureEngine::clearUp( ) const +/****** SignatureEngine/clearUp ********************************************** + * + * NAME + * clearUp -- clear up all resources used by this operation. + * + * SYNOPSIS + * clearUp( ); + * + * FUNCTION + * cleaning resources up includes: + * 1. releases the ElementCollector for the signature template element; + * 2. releases ElementCollectors for referenced elements; + * 3. releases the ElementCollector for the key element, if there is one. + * + * INPUTS + * empty + * + * RESULT + * empty + * + * HISTORY + * 05.01.2004 - implemented + * + * AUTHOR + * Michael Mi + * Email: michael.mi@sun.com + ******************************************************************************/ +{ + cssu::Reference < cssxc::sax::XReferenceResolvedBroadcaster > + xReferenceResolvedBroadcaster( m_xSAXEventKeeper, cssu::UNO_QUERY ); + xReferenceResolvedBroadcaster->removeReferenceResolvedListener( + m_nIdOfTemplateEC, + (const cssu::Reference < cssxc::sax::XReferenceResolvedListener >)((SecurityEngine *)this)); + + m_xSAXEventKeeper->removeElementCollector(m_nIdOfTemplateEC); + + std::vector< sal_Int32 >::const_iterator ii = m_vReferenceIds.begin(); + + for( ; ii != m_vReferenceIds.end() ; ++ii ) + { + xReferenceResolvedBroadcaster->removeReferenceResolvedListener( + *ii, + (const cssu::Reference < cssxc::sax::XReferenceResolvedListener >)((SecurityEngine *)this)); + m_xSAXEventKeeper->removeElementCollector(*ii); + } + + if (m_nIdOfKeyEC != 0 && m_nIdOfKeyEC != -1) + { + m_xSAXEventKeeper->removeElementCollector(m_nIdOfKeyEC); + } +} + +/* XReferenceCollector */ +void SAL_CALL SignatureEngine::setReferenceCount( sal_Int32 count ) + throw (cssu::Exception, cssu::RuntimeException) +{ + m_nTotalReferenceNumber = count; + tryToPerform(); +} + +void SAL_CALL SignatureEngine::setReferenceId( sal_Int32 id ) + throw (cssu::Exception, cssu::RuntimeException) +{ + m_vReferenceIds.push_back( id ); +} + +/* XUriBinding */ +void SAL_CALL SignatureEngine::setUriBinding( + const rtl::OUString& uri, + const cssu::Reference< com::sun::star::io::XInputStream >& aInputStream ) + throw (cssu::Exception, cssu::RuntimeException) +{ + m_vUris.push_back(uri); + m_vXInputStreams.push_back(aInputStream); +} + +cssu::Reference< com::sun::star::io::XInputStream > SAL_CALL SignatureEngine::getUriBinding( const rtl::OUString& uri ) + throw (cssu::Exception, cssu::RuntimeException) +{ + cssu::Reference< com::sun::star::io::XInputStream > xInputStream; + + int size = m_vUris.size(); + + for( int i=0; i +#endif +#ifndef _COM_SUN_STAR_XML_CRYPTO_SAX_XREFERENCERESOLVEDBROADCASTER_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_XML_CRYPTO_SAX_XSIGNATURECOLLECTOR_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_XML_CRYPTO_SAX_XKEYCOLLECTOR_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_XML_CRYPTO_SAX_XMISSIONTAKER_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_XML_CRYPTO_SAX_XSAXEVENTKEEPER_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_XML_CRYPTO_XXMLSECURITYCONTEXT_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_XML_CRYPTO_XXMLSIGNATURE_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_XML_CRYPTO_XURIBINDING_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_IO_XINPUTSTREAM_HPP_ +#include +#endif + +#ifndef _CPPUHELPER_IMPLBASE2_HXX_ +#include +#endif + +#include "securityengine.hxx" + +#ifndef INCLUDED_VECTOR +#include +#define INCLUDED_VECTOR +#endif + +class SignatureEngine : public cppu::ImplInheritanceHelper2 +< + SecurityEngine, + com::sun::star::xml::crypto::sax::XReferenceCollector, + com::sun::star::xml::crypto::XUriBinding +> +/****** signatureengine.hxx/CLASS SignatureEngine ***************************** + * + * NAME + * SignatureEngine -- Base class of SignatureCreator and SignatureVerifier + * + * FUNCTION + * Maintains common members and methods related with signature operation. + * + * HISTORY + * 05.01.2004 - Interface supported: XReferenceCollector + * + * AUTHOR + * Michael Mi + * Email: michael.mi@sun.com + ******************************************************************************/ +{ +protected: + + /* + * the Signature bridge component, which performs signature generation + * and verification based on xmlsec library. + */ + com::sun::star::uno::Reference< + com::sun::star::xml::crypto::XXMLSignature > m_xXMLSignature; + + /* + * a collection of ElementCollector's ids. Each ElementCollector + * represents one element signed by this signature. + */ + std::vector< sal_Int32 > m_vReferenceIds; + + /* + * remembers how many references this signature has. + */ + sal_Int32 m_nTotalReferenceNumber; + + /* + * a collection of Uri binding. + * + * the m_vUris is used to hold the Uri strings, and the m_vXInputStreams is used + * to hold corresponding binded XInputStream interface. + */ + std::vector< rtl::OUString > m_vUris; + std::vector< com::sun::star::uno::Reference< + com::sun::star::io::XInputStream > > m_vXInputStreams; + +protected: + SignatureEngine( ); + virtual ~SignatureEngine() {}; + + virtual void tryToPerform( ) + throw (com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException); + virtual void clearUp( ) const; + virtual bool checkReady() const; + + /* + * starts the main function. This method will be implemented by any sub-class. + * For a SignatureCreator, it performs signing operation; + * for a SignatureVerifier, verification operation is performed. + */ + virtual void startEngine( const com::sun::star::uno::Reference< + com::sun::star::xml::crypto::XXMLSignatureTemplate >& + xSignatureTemplate) + throw (com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException) + {}; + +public: + /* XReferenceCollector */ + virtual void SAL_CALL setReferenceCount( sal_Int32 count ) + throw (com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException); + + virtual void SAL_CALL setReferenceId( sal_Int32 id ) + throw (com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException); + + /* XUriBinding */ + virtual void SAL_CALL setUriBinding( + const rtl::OUString& uri, + const com::sun::star::uno::Reference< + com::sun::star::io::XInputStream >& aInputStream ) + throw (com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException); + 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); +}; + +#endif + diff --git a/xmlsecurity/source/framework/signatureverifierimpl.cxx b/xmlsecurity/source/framework/signatureverifierimpl.cxx new file mode 100644 index 000000000000..e6e8a084ab4b --- /dev/null +++ b/xmlsecurity/source/framework/signatureverifierimpl.cxx @@ -0,0 +1,288 @@ +/************************************************************************* + * + * $RCSfile: signatureverifierimpl.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:23 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#include "signatureverifierimpl.hxx" + +#ifndef _COM_SUN_STAR_XML_CRYPTO_XXMLSIGNATURETEMPLATE_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_XML_WRAPPER_XXMLELEMENTWRAPPER_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_XML_CRYPTO_SAX_SIGNATUREVERIFYRESULT_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_ +#include +#endif + +namespace cssu = com::sun::star::uno; +namespace cssl = com::sun::star::lang; +namespace cssxc = com::sun::star::xml::crypto; +namespace cssxw = com::sun::star::xml::wrapper; + +#define SERVICE_NAME "com.sun.star.xml.crypto.sax.SignatureVerifier" +#define IMPLEMENTATION_NAME "com.sun.star.xml.security.framework.SignatureVerifierImpl" + +#define DECLARE_ASCII( SASCIIVALUE ) \ + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SASCIIVALUE ) ) + +SignatureVerifierImpl::SignatureVerifierImpl( const cssu::Reference< cssl::XMultiServiceFactory >& rxMSF) +{ + mxMSF = rxMSF; +} + +SignatureVerifierImpl::~SignatureVerifierImpl() +{ +} + +bool SignatureVerifierImpl::checkReady() const +/****** SignatureVerifierImpl/checkReady ************************************* + * + * NAME + * checkReady -- checks the conditions for the signature verification. + * + * SYNOPSIS + * bReady = checkReady( ); + * + * FUNCTION + * checks whether all following conditions are satisfied: + * 1. the result listener is ready; + * 2. the SignatureEngine is ready. + * + * INPUTS + * empty + * + * RESULT + * bReady - true if all conditions are satisfied, false otherwise + * + * HISTORY + * 05.01.2004 - implemented + * + * AUTHOR + * Michael Mi + * Email: michael.mi@sun.com + ******************************************************************************/ +{ + return (m_xResultListener.is() && SignatureEngine::checkReady()); +} + +void SignatureVerifierImpl::notifyResultListener() const + throw (cssu::Exception, cssu::RuntimeException) +/****** SignatureVerifierImpl/notifyResultListener *************************** + * + * NAME + * notifyResultListener -- notifies the listener about the verify result. + * + * SYNOPSIS + * notifyResultListener( ); + * + * FUNCTION + * see NAME. + * + * INPUTS + * empty + * + * RESULT + * empty + * + * HISTORY + * 05.01.2004 - implemented + * + * AUTHOR + * Michael Mi + * Email: michael.mi@sun.com + ******************************************************************************/ +{ + cssu::Reference< cssxc::sax::XSignatureVerifyResultListener > + xSignatureVerifyResultListener ( m_xResultListener , cssu::UNO_QUERY ) ; + + xSignatureVerifyResultListener->signatureVerified( + m_nSecurityId, + m_bOperationSucceed?(cssxc::sax::SignatureVerifyResult_VERIFYSUCCEED): + (cssxc::sax::SignatureVerifyResult_VERIFYFAIL)); +} + +void SignatureVerifierImpl::startEngine( const cssu::Reference< + cssxc::XXMLSignatureTemplate >& + xSignatureTemplate) + throw (cssu::Exception, cssu::RuntimeException) +/****** SignatureVerifierImpl/startEngine ************************************ + * + * NAME + * startEngine -- verifies the signature. + * + * SYNOPSIS + * startEngine( xSignatureTemplate ); + * + * FUNCTION + * see NAME. + * + * INPUTS + * xSignatureTemplate - the signature template (along with all referenced + * elements) to be verified. + * + * RESULT + * empty + * + * HISTORY + * 05.01.2004 - implemented + * + * AUTHOR + * Michael Mi + * Email: michael.mi@sun.com + ******************************************************************************/ +{ + try + { + if ( m_xXMLSignature->validate(xSignatureTemplate, m_xXMLSecurityContext)) + { + m_bOperationSucceed = true; + } + } + catch( cssu::Exception& ) + { + m_bOperationSucceed = false; + } +} + +/* XSignatureVerifyResultBroadcaster */ +void SAL_CALL SignatureVerifierImpl::addSignatureVerifyResultListener( + const cssu::Reference< cssxc::sax::XSignatureVerifyResultListener >& listener ) + throw (cssu::Exception, cssu::RuntimeException) +{ + m_xResultListener = listener; + tryToPerform(); +} + +void SAL_CALL SignatureVerifierImpl::removeSignatureVerifyResultListener( + const cssu::Reference< cssxc::sax::XSignatureVerifyResultListener >& listener ) + throw (cssu::RuntimeException) +{ +} + +/* XInitialization */ +void SAL_CALL SignatureVerifierImpl::initialize( + const cssu::Sequence< cssu::Any >& aArguments ) + throw (cssu::Exception, cssu::RuntimeException) +{ + sal_Int32 nLength = aArguments.getLength(); + OSL_ASSERT(nLength == 5); + + rtl::OUString ouTempString; + + aArguments[0] >>= ouTempString; + m_nSecurityId = ouTempString.toInt32(); + aArguments[1] >>= m_xSAXEventKeeper; + aArguments[2] >>= ouTempString; + m_nIdOfTemplateEC = ouTempString.toInt32(); + aArguments[3] >>= m_xXMLSecurityContext; + aArguments[4] >>= m_xXMLSignature; +} + + +rtl::OUString SignatureVerifierImpl_getImplementationName () + throw (cssu::RuntimeException) +{ + return rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM ( IMPLEMENTATION_NAME ) ); +} + +sal_Bool SAL_CALL SignatureVerifierImpl_supportsService( const rtl::OUString& ServiceName ) + throw (cssu::RuntimeException) +{ + return ServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( SERVICE_NAME )); +} + +cssu::Sequence< rtl::OUString > SAL_CALL SignatureVerifierImpl_getSupportedServiceNames( ) + throw (cssu::RuntimeException) +{ + cssu::Sequence < rtl::OUString > aRet(1); + rtl::OUString* pArray = aRet.getArray(); + pArray[0] = rtl::OUString ( RTL_CONSTASCII_USTRINGPARAM ( SERVICE_NAME ) ); + return aRet; +} +#undef SERVICE_NAME + +cssu::Reference< cssu::XInterface > SAL_CALL SignatureVerifierImpl_createInstance( + const cssu::Reference< cssl::XMultiServiceFactory >& rSMgr) + throw( cssu::Exception ) +{ + return (cppu::OWeakObject*) new SignatureVerifierImpl(rSMgr); +} + +/* XServiceInfo */ +rtl::OUString SAL_CALL SignatureVerifierImpl::getImplementationName( ) + throw (cssu::RuntimeException) +{ + return SignatureVerifierImpl_getImplementationName(); +} +sal_Bool SAL_CALL SignatureVerifierImpl::supportsService( const rtl::OUString& rServiceName ) + throw (cssu::RuntimeException) +{ + return SignatureVerifierImpl_supportsService( rServiceName ); +} +cssu::Sequence< rtl::OUString > SAL_CALL SignatureVerifierImpl::getSupportedServiceNames( ) + throw (cssu::RuntimeException) +{ + return SignatureVerifierImpl_getSupportedServiceNames(); +} + diff --git a/xmlsecurity/source/framework/signatureverifierimpl.hxx b/xmlsecurity/source/framework/signatureverifierimpl.hxx new file mode 100644 index 000000000000..74ad65ccab05 --- /dev/null +++ b/xmlsecurity/source/framework/signatureverifierimpl.hxx @@ -0,0 +1,175 @@ +/************************************************************************* + * + * $RCSfile: signatureverifierimpl.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:23 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _SIGNATUREVERIFIERIMPL_HXX +#define _SIGNATUREVERIFIERIMPL_HXX + +#ifndef _COM_SUN_STAR_XML_CRYPTO_SAX_XSIGNATUREVERIFYRESULTLISTENER_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_XML_CRYPTO_SAX_XSIGNATUREVERIFYRESULTBROADCASTER_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_LANG_XINITIALIZATION_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_ +#include +#endif +#ifndef _CPPUHELPER_IMPLBASE3_HXX_ +#include +#endif + +#include "signatureengine.hxx" + +class SignatureVerifierImpl : public cppu::ImplInheritanceHelper3 +< + SignatureEngine, + com::sun::star::xml::crypto::sax::XSignatureVerifyResultBroadcaster, + com::sun::star::lang::XInitialization, + com::sun::star::lang::XServiceInfo +> +/****** SignatureVerifier.hxx/CLASS SignatureVerifierImpl ********************* + * + * NAME + * SignatureVerifierImpl -- verifies a signature + * + * FUNCTION + * Collects all resources for a signature verification, then verifies the + * signature by invoking a xmlsec-based signature bridge component. + * + * HISTORY + * 05.01.2004 - Interface supported: XSignatureVerifyResultBroadcaster, + * XInitialization, XServiceInfo + * + * AUTHOR + * Michael Mi + * Email: michael.mi@sun.com + ******************************************************************************/ +{ +private: + /* + * the Id of the signature, which is used for the result listener to + * identify the signature. + */ + sal_Int32 m_nSignatureId; + + /* + * the verify result + */ + bool m_bVerifySucceed; + + virtual void notifyResultListener() const + throw (com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException); + virtual bool checkReady() const; + virtual void startEngine( const com::sun::star::uno::Reference< + com::sun::star::xml::crypto::XXMLSignatureTemplate >& + xSignatureTemplate) + throw (com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException); + +public: + explicit SignatureVerifierImpl( const com::sun::star::uno::Reference< + com::sun::star::lang::XMultiServiceFactory >& rxMSF); + virtual ~SignatureVerifierImpl(); + + /* XSignatureVerifyResultBroadcaster */ + virtual void SAL_CALL addSignatureVerifyResultListener( + const com::sun::star::uno::Reference< + com::sun::star::xml::crypto::sax::XSignatureVerifyResultListener >& + listener ) + throw (com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeSignatureVerifyResultListener( + const com::sun::star::uno::Reference< + com::sun::star::xml::crypto::sax::XSignatureVerifyResultListener >& + listener ) + throw (com::sun::star::uno::RuntimeException); + + /* XInitialization */ + virtual void SAL_CALL initialize( + const com::sun::star::uno::Sequence< com::sun::star::uno::Any >& aArguments ) + throw (com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException); + + /* XServiceInfo */ + virtual rtl::OUString SAL_CALL getImplementationName( ) + throw (com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsService( const rtl::OUString& ServiceName ) + throw (com::sun::star::uno::RuntimeException); + virtual com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames( ) + throw (com::sun::star::uno::RuntimeException); +}; + +rtl::OUString SignatureVerifierImpl_getImplementationName() + throw ( com::sun::star::uno::RuntimeException ); + +sal_Bool SAL_CALL SignatureVerifierImpl_supportsService( const rtl::OUString& ServiceName ) + throw ( com::sun::star::uno::RuntimeException ); + +com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL SignatureVerifierImpl_getSupportedServiceNames( ) + throw ( com::sun::star::uno::RuntimeException ); + +com::sun::star::uno::Reference< com::sun::star::uno::XInterface > +SAL_CALL SignatureVerifierImpl_createInstance( + const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > & rSMgr) + throw ( com::sun::star::uno::Exception ); + +#endif + + diff --git a/xmlsecurity/source/framework/xmlencryptiontemplateimpl.cxx b/xmlsecurity/source/framework/xmlencryptiontemplateimpl.cxx new file mode 100644 index 000000000000..b32f11caeeb8 --- /dev/null +++ b/xmlsecurity/source/framework/xmlencryptiontemplateimpl.cxx @@ -0,0 +1,164 @@ +/************************************************************************* + * + * $RCSfile: xmlencryptiontemplateimpl.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:23 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _SAL_CONFIG_H_ +#include +#endif + +#ifndef _RTL_UUID_H_ +#include +#endif + +#ifndef _XMLENCRYPTIONTEMPLATEIMPL_HXX_ +#include "xmlencryptiontemplateimpl.hxx" +#endif + +using namespace ::com::sun::star::uno ; +using ::com::sun::star::lang::XMultiServiceFactory ; +using ::com::sun::star::lang::XSingleServiceFactory ; +using ::rtl::OUString ; + +using ::com::sun::star::xml::wrapper::XXMLElementWrapper ; +using ::com::sun::star::xml::crypto::XXMLEncryptionTemplate ; + +XMLEncryptionTemplateImpl :: XMLEncryptionTemplateImpl( const Reference< XMultiServiceFactory >& aFactory ) : m_xServiceManager( aFactory ) , m_xTemplate( NULL ) , m_xTarget( NULL ) { +} + +XMLEncryptionTemplateImpl :: ~XMLEncryptionTemplateImpl() { +} + +/* XXMLEncryptionTemplate */ +void SAL_CALL XMLEncryptionTemplateImpl :: setTemplate( const Reference< XXMLElementWrapper >& aTemplate ) + throw (com::sun::star::uno::RuntimeException, com::sun::star::lang::IllegalArgumentException) +{ + m_xTemplate = aTemplate ; +} + +/* XXMLEncryptionTemplate */ +Reference< XXMLElementWrapper > SAL_CALL XMLEncryptionTemplateImpl :: getTemplate() +throw (com::sun::star::uno::RuntimeException) +{ + return m_xTemplate ; +} + +/* XXMLEncryptionTemplate */ +void SAL_CALL XMLEncryptionTemplateImpl :: setTarget( const Reference< XXMLElementWrapper >& aTarget ) + throw( com::sun::star::lang::IllegalArgumentException ) { + m_xTarget = aTarget ; +} + +/* XXMLEncryptionTemplate */ +Reference< XXMLElementWrapper > SAL_CALL XMLEncryptionTemplateImpl :: getTarget() +throw (com::sun::star::uno::RuntimeException) +{ + return m_xTarget ; +} + +/* XInitialization */ +void SAL_CALL XMLEncryptionTemplateImpl :: initialize( const Sequence< Any >& aArguments ) throw( Exception, RuntimeException ) { + // TBD +} ; + +/* XServiceInfo */ +OUString SAL_CALL XMLEncryptionTemplateImpl :: getImplementationName() throw( RuntimeException ) { + return impl_getImplementationName() ; +} + +/* XServiceInfo */ +sal_Bool SAL_CALL XMLEncryptionTemplateImpl :: supportsService( const OUString& serviceName) throw( RuntimeException ) { + Sequence< OUString > seqServiceNames = getSupportedServiceNames() ; + const OUString* pArray = seqServiceNames.getConstArray() ; + for( sal_Int32 i = 0 ; i < seqServiceNames.getLength() ; i ++ ) { + if( *( pArray + i ) == serviceName ) + return sal_True ; + } + return sal_False ; +} + +/* XServiceInfo */ +Sequence< OUString > SAL_CALL XMLEncryptionTemplateImpl :: getSupportedServiceNames() throw( RuntimeException ) { + return impl_getSupportedServiceNames() ; +} + +//Helper for XServiceInfo +Sequence< OUString > XMLEncryptionTemplateImpl :: impl_getSupportedServiceNames() { + ::osl::Guard< ::osl::Mutex > aGuard( ::osl::Mutex::getGlobalMutex() ) ; + Sequence< OUString > seqServiceNames( 1 ) ; + seqServiceNames.getArray()[0] = OUString::createFromAscii( "com.sun.star.xml.crypto.XMLEncryptionTemplate" ) ; + return seqServiceNames ; +} + +OUString XMLEncryptionTemplateImpl :: impl_getImplementationName() throw( RuntimeException ) { + return OUString::createFromAscii( "com.sun.star.xml.security.framework.XMLEncryptionTemplateImpl" ) ; +} + +//Helper for registry +Reference< XInterface > SAL_CALL XMLEncryptionTemplateImpl :: impl_createInstance( const Reference< XMultiServiceFactory >& aServiceManager ) throw( RuntimeException ) { + return Reference< XInterface >( *new XMLEncryptionTemplateImpl( aServiceManager ) ) ; +} + +Reference< XSingleServiceFactory > XMLEncryptionTemplateImpl :: impl_createFactory( const Reference< XMultiServiceFactory >& aServiceManager ) { + //Reference< XSingleServiceFactory > xFactory ; + //xFactory = ::cppu::createSingleFactory( aServiceManager , impl_getImplementationName , impl_createInstance , impl_getSupportedServiceNames ) ; + //return xFactory ; + return ::cppu::createSingleFactory( aServiceManager , impl_getImplementationName() , impl_createInstance , impl_getSupportedServiceNames() ) ; +} + diff --git a/xmlsecurity/source/framework/xmlencryptiontemplateimpl.hxx b/xmlsecurity/source/framework/xmlencryptiontemplateimpl.hxx new file mode 100644 index 000000000000..e020aacd8ae5 --- /dev/null +++ b/xmlsecurity/source/framework/xmlencryptiontemplateimpl.hxx @@ -0,0 +1,168 @@ +/************************************************************************* + * + * $RCSfile: xmlencryptiontemplateimpl.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:23 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _XMLENCRYPTIONTEMPLATEIMPL_HXX_ +#define _XMLENCRYPTIONTEMPLATEIMPL_HXX_ + +#ifndef _SAL_CONFIG_H_ +#include +#endif + +#ifndef _RTL_USTRING_HXX_ +#include +#endif + +#ifndef _CPPUHELPER_FACTORY_HXX_ +#include +#endif + +#ifndef _CPPUHELPER_IMPLBASE3_HXX_ +#include +#endif + +#ifndef _COM_SUN_STAR_UNO_EXCEPTION_HPP_ +#include +#endif + +#ifndef _COM_SUN_STAR_UNO_REFERENCE_HPP_ +#include +#endif + +#ifndef _COM_SUN_STAR_LANG_XSINGLESERVICEFACTORY_HPP_ +#include +#endif + +#ifndef _COM_SUN_STAR_LANG_XSECVICEINFO_HPP_ +#include +#endif + +#ifndef _COM_SUN_STAR_LANG_XINITIALIZATION_HPP_ +#include +#endif + +#ifndef _COM_SUN_STAR_LANG_XUNOTUNNEL_HPP_ +#include +#endif + +#ifndef _COM_SUN_STAR_XML_CRYPTO_XXMLENCRYPTIONTEMPLATE_HPP_ +#include +#endif + +#ifndef _COM_SUN_STAR_XML_WRAPPER_XXMLELEMENTWRAPPER_HPP_ +#include +#endif + +class XMLEncryptionTemplateImpl : public ::cppu::WeakImplHelper3< + ::com::sun::star::xml::crypto::XXMLEncryptionTemplate , + ::com::sun::star::lang::XInitialization , + ::com::sun::star::lang::XServiceInfo > +{ + private : + ::com::sun::star::uno::Reference< ::com::sun::star::xml::wrapper::XXMLElementWrapper > m_xTemplate ; + ::com::sun::star::uno::Reference< ::com::sun::star::xml::wrapper::XXMLElementWrapper > m_xTarget ; + ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xServiceManager ; + + public : + XMLEncryptionTemplateImpl( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& aFactory ) ; + virtual ~XMLEncryptionTemplateImpl() ; + + //Methods from XXMLEncryptionTemplate + virtual void SAL_CALL setTemplate( + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::wrapper::XXMLElementWrapper >& aXmlElement + ) + throw (com::sun::star::uno::RuntimeException, com::sun::star::lang::IllegalArgumentException); + + virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::wrapper::XXMLElementWrapper > SAL_CALL getTemplate( + ) throw (com::sun::star::uno::RuntimeException); + + virtual void SAL_CALL setTarget( + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::wrapper::XXMLElementWrapper >& aXmlElement + ) throw( com::sun::star::lang::IllegalArgumentException); + + virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::wrapper::XXMLElementWrapper > SAL_CALL getTarget( + ) throw (com::sun::star::uno::RuntimeException) ; + + //Methods from XInitialization + virtual void SAL_CALL initialize( + const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments + ) throw( ::com::sun::star::uno::Exception , ::com::sun::star::uno::RuntimeException ) ; + + //Methods from XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName() throw( ::com::sun::star::uno::RuntimeException ) ; + + virtual sal_Bool SAL_CALL supportsService( + const ::rtl::OUString& ServiceName + ) throw( ::com::sun::star::uno::RuntimeException ) ; + + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw( ::com::sun::star::uno::RuntimeException ) ; + + //Helper for XServiceInfo + static ::com::sun::star::uno::Sequence< ::rtl::OUString > impl_getSupportedServiceNames() ; + + static ::rtl::OUString impl_getImplementationName() throw( ::com::sun::star::uno::RuntimeException ) ; + + //Helper for registry + static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL impl_createInstance( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& aServiceManager ) throw( ::com::sun::star::uno::RuntimeException ) ; + + static ::com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleServiceFactory > impl_createFactory( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& aServiceManager ) ; +} ; + +#endif // _XMLENCRYPTIONTEMPLATE_XMLSECIMPL_HXX_ diff --git a/xmlsecurity/source/framework/xmlsignaturetemplateimpl.cxx b/xmlsecurity/source/framework/xmlsignaturetemplateimpl.cxx new file mode 100644 index 000000000000..48a27f5db9c2 --- /dev/null +++ b/xmlsecurity/source/framework/xmlsignaturetemplateimpl.cxx @@ -0,0 +1,193 @@ +/************************************************************************* + * + * $RCSfile: xmlsignaturetemplateimpl.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:23 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _SAL_CONFIG_H_ +#include +#endif + +#ifndef _RTL_USTRING_HXX_ +#include +#endif + +#ifndef _RTL_UUID_H_ +#include +#endif + +#ifndef _XMLSIGNATURETEMPLATEIMPL_HXX_ +#include "xmlsignaturetemplateimpl.hxx" +#endif + +using namespace ::com::sun::star::uno ; +using ::com::sun::star::lang::XMultiServiceFactory ; +using ::com::sun::star::lang::XSingleServiceFactory ; +using ::rtl::OUString ; + +using ::com::sun::star::xml::wrapper::XXMLElementWrapper ; +using ::com::sun::star::xml::crypto::XXMLSignatureTemplate ; + +XMLSignatureTemplateImpl :: XMLSignatureTemplateImpl( const Reference< XMultiServiceFactory >& aFactory ) : m_xServiceManager( aFactory ) , m_xTemplate( NULL ) { +} + +XMLSignatureTemplateImpl :: ~XMLSignatureTemplateImpl() { +} + +/* XXMLSignatureTemplate */ +void SAL_CALL XMLSignatureTemplateImpl :: setTemplate( const Reference< XXMLElementWrapper >& aTemplate ) + throw( com::sun::star::uno::RuntimeException, com::sun::star::lang::IllegalArgumentException) +{ + m_xTemplate = aTemplate ; +} + +/* XXMLSignatureTemplate */ +Reference< XXMLElementWrapper > SAL_CALL XMLSignatureTemplateImpl :: getTemplate() + throw (com::sun::star::uno::RuntimeException) +{ + return m_xTemplate ; +} + +void SAL_CALL XMLSignatureTemplateImpl :: setTarget( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::wrapper::XXMLElementWrapper >& aXmlElement ) + throw( com::sun::star::uno::RuntimeException, com::sun::star::lang::IllegalArgumentException) +{ + targets.push_back( aXmlElement ); +} + +::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::xml::wrapper::XXMLElementWrapper > > SAL_CALL XMLSignatureTemplateImpl :: getTargets() + throw (com::sun::star::uno::RuntimeException) +{ + sal_Int32 length = targets.size(); + ::com::sun::star::uno::Sequence< + ::com::sun::star::uno::Reference< ::com::sun::star::xml::wrapper::XXMLElementWrapper > + > aTargets (length); + + sal_Int32 i; + + for (i=0; i& aUriBinding ) + throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException) +{ + m_xUriBinding = aUriBinding; +} + +::com::sun::star::uno::Reference< ::com::sun::star::xml::crypto::XUriBinding > SAL_CALL XMLSignatureTemplateImpl::getBinding() + throw (::com::sun::star::uno::RuntimeException) +{ + return m_xUriBinding; +} + +/* XInitialization */ +void SAL_CALL XMLSignatureTemplateImpl :: initialize( const Sequence< Any >& aArguments ) throw( Exception, RuntimeException ) { + // TBD +} ; + +/* XServiceInfo */ +OUString SAL_CALL XMLSignatureTemplateImpl :: getImplementationName() throw( RuntimeException ) { + return impl_getImplementationName() ; +} + +/* XServiceInfo */ +sal_Bool SAL_CALL XMLSignatureTemplateImpl :: supportsService( const OUString& serviceName) throw( RuntimeException ) { + Sequence< OUString > seqServiceNames = getSupportedServiceNames() ; + const OUString* pArray = seqServiceNames.getConstArray() ; + for( sal_Int32 i = 0 ; i < seqServiceNames.getLength() ; i ++ ) { + if( *( pArray + i ) == serviceName ) + return sal_True ; + } + return sal_False ; +} + +/* XServiceInfo */ +Sequence< OUString > SAL_CALL XMLSignatureTemplateImpl :: getSupportedServiceNames() throw( RuntimeException ) { + return impl_getSupportedServiceNames() ; +} + +//Helper for XServiceInfo +Sequence< OUString > XMLSignatureTemplateImpl :: impl_getSupportedServiceNames() { + ::osl::Guard< ::osl::Mutex > aGuard( ::osl::Mutex::getGlobalMutex() ) ; + Sequence< OUString > seqServiceNames( 1 ) ; + seqServiceNames.getArray()[0] = OUString::createFromAscii( "com.sun.star.xml.crypto.XMLSignatureTemplate" ) ; + return seqServiceNames ; +} + +OUString XMLSignatureTemplateImpl :: impl_getImplementationName() throw( RuntimeException ) { + return OUString::createFromAscii( "com.sun.star.xml.security.framework.XMLSignatureTemplateImpl" ) ; +} + +//Helper for registry +Reference< XInterface > SAL_CALL XMLSignatureTemplateImpl :: impl_createInstance( const Reference< XMultiServiceFactory >& aServiceManager ) throw( RuntimeException ) { + return Reference< XInterface >( *new XMLSignatureTemplateImpl( aServiceManager ) ) ; +} + +Reference< XSingleServiceFactory > XMLSignatureTemplateImpl :: impl_createFactory( const Reference< XMultiServiceFactory >& aServiceManager ) { + //Reference< XSingleServiceFactory > xFactory ; + //xFactory = ::cppu::createSingleFactory( aServiceManager , impl_getImplementationName , impl_createInstance , impl_getSupportedServiceNames ) ; + //return xFactory ; + return ::cppu::createSingleFactory( aServiceManager , impl_getImplementationName() , impl_createInstance , impl_getSupportedServiceNames() ) ; +} + diff --git a/xmlsecurity/source/framework/xmlsignaturetemplateimpl.hxx b/xmlsecurity/source/framework/xmlsignaturetemplateimpl.hxx new file mode 100644 index 000000000000..e4368b5656ca --- /dev/null +++ b/xmlsecurity/source/framework/xmlsignaturetemplateimpl.hxx @@ -0,0 +1,177 @@ +/************************************************************************* + * + * $RCSfile: xmlsignaturetemplateimpl.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:23 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _XMLSIGNATURETEMPLATEIMPL_HXX_ +#define _XMLSIGNATURETEMPLATEIMPL_HXX_ + +#ifndef _SAL_CONFIG_H_ +#include +#endif + +#ifndef _RTL_USTRING_HXX_ +#include +#endif + +#ifndef _CPPUHELPER_FACTORY_HXX_ +#include +#endif + +#ifndef _CPPUHELPER_IMPLBASE3_HXX_ +#include +#endif + +#ifndef _COM_SUN_STAR_UNO_EXCEPTION_HPP_ +#include +#endif + +#ifndef _COM_SUN_STAR_UNO_REFERENCE_HPP_ +#include +#endif + +#ifndef _COM_SUN_STAR_LANG_XSINGLESERVICEFACTORY_HPP_ +#include +#endif + +#ifndef _COM_SUN_STAR_LANG_XSECVICEINFO_HPP_ +#include +#endif + +#ifndef _COM_SUN_STAR_LANG_XINITIALIZATION_HPP_ +#include +#endif + +#ifndef _COM_SUN_STAR_XML_CRYPTO_XXMLSIGNATURETEMPLATE_HPP_ +#include +#endif + +#ifndef _COM_SUN_STAR_XML_WRAPPER_XXMLELEMENTWRAPPER_HPP_ +#include +#endif + +#ifndef __SGI_STL_VECTOR +#include +#endif + +class XMLSignatureTemplateImpl : public ::cppu::WeakImplHelper3< + ::com::sun::star::xml::crypto::XXMLSignatureTemplate , + ::com::sun::star::lang::XInitialization , + ::com::sun::star::lang::XServiceInfo > +{ + private : + ::com::sun::star::uno::Reference< ::com::sun::star::xml::wrapper::XXMLElementWrapper > m_xTemplate ; + ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xServiceManager ; + std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::xml::wrapper::XXMLElementWrapper > > targets; + ::com::sun::star::uno::Reference< ::com::sun::star::xml::crypto::XUriBinding > m_xUriBinding; + + public : + XMLSignatureTemplateImpl( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& aFactory ) ; + virtual ~XMLSignatureTemplateImpl() ; + + //Methods from XXMLSignatureTemplate + virtual void SAL_CALL setTemplate( + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::wrapper::XXMLElementWrapper >& aXmlElement + ) throw( com::sun::star::uno::RuntimeException, com::sun::star::lang::IllegalArgumentException); + + virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::wrapper::XXMLElementWrapper > SAL_CALL getTemplate( + ) throw (com::sun::star::uno::RuntimeException); + + virtual void SAL_CALL setTarget( + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::wrapper::XXMLElementWrapper >& aXmlElement + ) throw( com::sun::star::uno::RuntimeException, com::sun::star::lang::IllegalArgumentException); + + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::xml::wrapper::XXMLElementWrapper > > SAL_CALL getTargets( + ) throw (com::sun::star::uno::RuntimeException); + + virtual void SAL_CALL setBinding( + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::crypto::XUriBinding >& aUriBinding ) + throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::xml::crypto::XUriBinding > + SAL_CALL getBinding( ) + throw (::com::sun::star::uno::RuntimeException); + + //Methods from XInitialization + virtual void SAL_CALL initialize( + const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments + ) throw( ::com::sun::star::uno::Exception , ::com::sun::star::uno::RuntimeException ) ; + + //Methods from XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName() throw( ::com::sun::star::uno::RuntimeException ) ; + + virtual sal_Bool SAL_CALL supportsService( + const ::rtl::OUString& ServiceName + ) throw( ::com::sun::star::uno::RuntimeException ) ; + + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw( ::com::sun::star::uno::RuntimeException ) ; + + //Helper for XServiceInfo + static ::com::sun::star::uno::Sequence< ::rtl::OUString > impl_getSupportedServiceNames() ; + + static ::rtl::OUString impl_getImplementationName() throw( ::com::sun::star::uno::RuntimeException ) ; + + //Helper for registry + static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL impl_createInstance( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& aServiceManager ) throw( ::com::sun::star::uno::RuntimeException ) ; + + static ::com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleServiceFactory > impl_createFactory( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& aServiceManager ) ; +} ; + +#endif // _XMLSIGNATURETEMPLATE_XMLSECIMPL_HXX_ diff --git a/xmlsecurity/source/framework/xsec_framework.cxx b/xmlsecurity/source/framework/xsec_framework.cxx new file mode 100644 index 000000000000..d38ef486f49b --- /dev/null +++ b/xmlsecurity/source/framework/xsec_framework.cxx @@ -0,0 +1,284 @@ +/************************************************************************* + * + * $RCSfile: xsec_framework.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:23 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#include + +#include +#include +#include + +#ifndef _COM_SUN_STAR_LANG_XSINGLESERVICEFACTORY_HPP_ +#include +#endif + +#include +#include +#include +#include +#include +#include +#include + +using namespace ::rtl; +using namespace ::cppu; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::registry; + +extern "C" +{ +//================================================================================================== +void SAL_CALL component_getImplementationEnvironment( + const sal_Char ** ppEnvTypeName, uno_Environment ** ppEnv ) +{ + *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; +} + +//================================================================================================== +sal_Bool SAL_CALL component_writeInfo( + void * pServiceManager, void * pRegistryKey ) +{ + if (pRegistryKey) + { + try + { + //Decryptor + sal_Int32 nPos = 0; + Reference< XRegistryKey > xNewKey( + reinterpret_cast< XRegistryKey * >( pRegistryKey )->createKey( DecryptorImpl_getImplementationName() ) ); + xNewKey = xNewKey->createKey( OUString::createFromAscii( "/UNO/SERVICES" ) ); + + const Sequence< OUString > & rSNL = DecryptorImpl_getSupportedServiceNames(); + const OUString * pArray = rSNL.getConstArray(); + for ( nPos = rSNL.getLength(); nPos--; ) + xNewKey->createKey( pArray[nPos] ); + + //Encryptor + xNewKey = reinterpret_cast< XRegistryKey * >( pRegistryKey )->createKey( EncryptorImpl_getImplementationName() ); + xNewKey = xNewKey->createKey( OUString::createFromAscii( "/UNO/SERVICES" ) ); + const Sequence< OUString > & rSNL2 = EncryptorImpl_getSupportedServiceNames(); + pArray = rSNL2.getConstArray(); + for ( nPos = rSNL2.getLength(); nPos--; ) + xNewKey->createKey( pArray[nPos] ); + + //SignatureCreator + xNewKey = reinterpret_cast< XRegistryKey * >( pRegistryKey )->createKey( SignatureCreatorImpl_getImplementationName() ); + xNewKey = xNewKey->createKey( OUString::createFromAscii( "/UNO/SERVICES" ) ); + const Sequence< OUString > & rSNL3 = SignatureCreatorImpl_getSupportedServiceNames(); + pArray = rSNL3.getConstArray(); + for ( nPos = rSNL3.getLength(); nPos--; ) + xNewKey->createKey( pArray[nPos] ); + + //SignatureVerifier + xNewKey = reinterpret_cast< XRegistryKey * >( pRegistryKey )->createKey( SignatureVerifierImpl_getImplementationName() ); + xNewKey = xNewKey->createKey( OUString::createFromAscii( "/UNO/SERVICES" ) ); + const Sequence< OUString > & rSNL4 = SignatureVerifierImpl_getSupportedServiceNames(); + pArray = rSNL4.getConstArray(); + for ( nPos = rSNL4.getLength(); nPos--; ) + xNewKey->createKey( pArray[nPos] ); + + //SAXEventKeeper + xNewKey = reinterpret_cast< XRegistryKey * >( pRegistryKey )->createKey( SAXEventKeeperImpl_getImplementationName() ); + xNewKey = xNewKey->createKey( OUString::createFromAscii( "/UNO/SERVICES" ) ); + const Sequence< OUString > & rSNL5 = SAXEventKeeperImpl_getSupportedServiceNames(); + pArray = rSNL5.getConstArray(); + for ( nPos = rSNL5.getLength(); nPos--; ) + xNewKey->createKey( pArray[nPos] ); + + //XMLSignatureTemplateImpl + xNewKey = reinterpret_cast< XRegistryKey * >( pRegistryKey )->createKey( XMLSignatureTemplateImpl::impl_getImplementationName() ); + xNewKey = xNewKey->createKey( OUString::createFromAscii( "/UNO/SERVICES" ) ); + const Sequence< OUString > & rSNL6 = XMLSignatureTemplateImpl::impl_getSupportedServiceNames(); + pArray = rSNL6.getConstArray(); + for ( nPos = rSNL6.getLength(); nPos--; ) + xNewKey->createKey( pArray[nPos] ); + + // XMLEncryptionTemplateImpl + xNewKey = reinterpret_cast< XRegistryKey * >( pRegistryKey )->createKey( XMLEncryptionTemplateImpl::impl_getImplementationName() ); + xNewKey = xNewKey->createKey( OUString::createFromAscii( "/UNO/SERVICES" ) ); + const Sequence< OUString > & rSNL7 = XMLEncryptionTemplateImpl::impl_getSupportedServiceNames(); + pArray = rSNL7.getConstArray(); + for ( nPos = rSNL7.getLength(); nPos--; ) + xNewKey->createKey( pArray[nPos] ); + + return sal_True; + } + catch (InvalidRegistryException &) + { + OSL_ENSURE( sal_False, "### InvalidRegistryException!" ); + } + } + return sal_False; +} + +//================================================================================================== +void * SAL_CALL component_getFactory( + const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey ) +{ + void * pRet = 0; + + //Decryptor + OUString implName = OUString::createFromAscii( pImplName ); + if ( pServiceManager && implName.equals(DecryptorImpl_getImplementationName()) ) + { + Reference< XSingleServiceFactory > xFactory( createSingleFactory( + reinterpret_cast< XMultiServiceFactory * >( pServiceManager ), + OUString::createFromAscii( pImplName ), + DecryptorImpl_createInstance, DecryptorImpl_getSupportedServiceNames() ) ); + + if (xFactory.is()) + { + xFactory->acquire(); + pRet = xFactory.get(); + } + } + + //Encryptor + if ( pServiceManager && implName.equals(EncryptorImpl_getImplementationName()) ) + { + Reference< XSingleServiceFactory > xFactory( createSingleFactory( + reinterpret_cast< XMultiServiceFactory * >( pServiceManager ), + OUString::createFromAscii( pImplName ), + EncryptorImpl_createInstance, EncryptorImpl_getSupportedServiceNames() ) ); + + if (xFactory.is()) + { + xFactory->acquire(); + pRet = xFactory.get(); + } + } + + //SignatureCreator + if ( pServiceManager && implName.equals(SignatureCreatorImpl_getImplementationName()) ) + { + Reference< XSingleServiceFactory > xFactory( createSingleFactory( + reinterpret_cast< XMultiServiceFactory * >( pServiceManager ), + OUString::createFromAscii( pImplName ), + SignatureCreatorImpl_createInstance, SignatureCreatorImpl_getSupportedServiceNames() ) ); + + if (xFactory.is()) + { + xFactory->acquire(); + pRet = xFactory.get(); + } + } + + //SignatureVerifier + if ( pServiceManager && implName.equals(SignatureVerifierImpl_getImplementationName()) ) + { + Reference< XSingleServiceFactory > xFactory( createSingleFactory( + reinterpret_cast< XMultiServiceFactory * >( pServiceManager ), + OUString::createFromAscii( pImplName ), + SignatureVerifierImpl_createInstance, SignatureVerifierImpl_getSupportedServiceNames() ) ); + + if (xFactory.is()) + { + xFactory->acquire(); + pRet = xFactory.get(); + } + } + + //SAXEventKeeper + if ( pServiceManager && implName.equals(SAXEventKeeperImpl_getImplementationName()) ) + { + Reference< XSingleServiceFactory > xFactory( createSingleFactory( + reinterpret_cast< XMultiServiceFactory * >( pServiceManager ), + OUString::createFromAscii( pImplName ), + SAXEventKeeperImpl_createInstance, SAXEventKeeperImpl_getSupportedServiceNames() ) ); + + if (xFactory.is()) + { + xFactory->acquire(); + pRet = xFactory.get(); + } + } + + //XMLSignatureTemplate + if ( pServiceManager && implName.equals( XMLSignatureTemplateImpl::impl_getImplementationName()) ) + { + Reference< XSingleServiceFactory > xFactory = XMLSignatureTemplateImpl::impl_createFactory( + reinterpret_cast< XMultiServiceFactory* >( pServiceManager ) ) ; + + if (xFactory.is()) + { + xFactory->acquire(); + pRet = xFactory.get(); + } + } + + //XMLEncryptionTemplate + if ( pServiceManager && implName.equals( XMLEncryptionTemplateImpl::impl_getImplementationName()) ) + { + Reference< XSingleServiceFactory > xFactory = XMLEncryptionTemplateImpl::impl_createFactory( + reinterpret_cast< XMultiServiceFactory* >( pServiceManager ) ) ; + + if (xFactory.is()) + { + xFactory->acquire(); + pRet = xFactory.get(); + } + } + + return pRet; +} +} + + diff --git a/xmlsecurity/source/helper/makefile.mk b/xmlsecurity/source/helper/makefile.mk new file mode 100644 index 000000000000..0d5fec4a5bdb --- /dev/null +++ b/xmlsecurity/source/helper/makefile.mk @@ -0,0 +1,90 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1.1.1 $ +# +# last change: $Author: mt $ $Date: 2004-07-12 13:15:22 $ +# +# The Contents of this file are made available subject to the terms of +# either of the following licenses +# +# - GNU Lesser General Public License Version 2.1 +# - Sun Industry Standards Source License Version 1.1 +# +# Sun Microsystems Inc., October, 2000 +# +# GNU Lesser General Public License Version 2.1 +# ============================================= +# Copyright 2000 by Sun Microsystems, Inc. +# 901 San Antonio Road, Palo Alto, CA 94303, USA +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License version 2.1, as published by the Free Software Foundation. +# +# This library 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 for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, +# MA 02111-1307 USA +# +# +# Sun Industry Standards Source License Version 1.1 +# ================================================= +# The contents of this file are subject to the Sun Industry Standards +# Source License Version 1.1 (the "License"); You may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at http://www.openoffice.org/license.html. +# +# Software provided under this License is provided on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, +# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, +# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. +# See the License for the specific provisions governing your rights and +# obligations concerning the Software. +# +# The Initial Developer of the Original Code is: Sun Microsystems, Inc. +# +# Copyright: 2000 by Sun Microsystems, Inc. +# +# All Rights Reserved. +# +# Contributor(s): _______________________________________ +# +# +# +#************************************************************************* + +PRJ=..$/.. + +PRJNAME=xmlsecurity +TARGET=helper + +ENABLE_EXCEPTIONS=TRUE + +# --- Settings ----------------------------------------------------- + +.INCLUDE : svpre.mk +.INCLUDE : settings.mk +.INCLUDE : sv.mk +.INCLUDE : $(PRJ)$/util$/target.pmk + +# --- Files -------------------------------------------------------- + +SLOFILES= \ + $(SLO)$/xmlsignaturehelper.obj \ + $(SLO)$/xmlsignaturehelper2.obj \ + $(SLO)$/xsecctl.obj \ + $(SLO)$/xsecparser.obj \ + $(SLO)$/xsecsign.obj \ + $(SLO)$/xsecverify.obj + + +# --- Targets ------------------------------------------------------ + +.INCLUDE : target.mk diff --git a/xmlsecurity/source/helper/xmlsignaturehelper.cxx b/xmlsecurity/source/helper/xmlsignaturehelper.cxx new file mode 100644 index 000000000000..ffca2ddb6c78 --- /dev/null +++ b/xmlsecurity/source/helper/xmlsignaturehelper.cxx @@ -0,0 +1,424 @@ +/************************************************************************* + * + * $RCSfile: xmlsignaturehelper.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:22 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#include +#include + +#include + +#include +#include + +#include + +#include +#include +#include + +/* SEInitializer component */ +#define SEINITIALIZER_COMPONENT "com.sun.star.xml.crypto.SEInitializer" + +#define SIGFILEROOTELEMENT "all-signatures" + +using namespace ::com::sun::star; + +XMLSignatureHelper::XMLSignatureHelper( const uno::Reference< lang::XMultiServiceFactory>& rxMSF ) + : mxMSF(rxMSF) +{ + mpXSecController = new XSecController; + mxSecurityController = mpXSecController; + mpXSecController->setFactory( rxMSF ); + mbError = false; +} + +XMLSignatureHelper::~XMLSignatureHelper() +{ + if (mxSEInitializer.is()) + { + mxSEInitializer->freeSecurityContext( mxSecurityContext ); + } +} + +bool XMLSignatureHelper::Init( const rtl::OUString& rTokenPath ) +{ + DBG_ASSERT( !mxSEInitializer.is(), "XMLSignatureHelper::Init - mxSEInitializer already set!" ); + DBG_ASSERT( !mxSecurityContext.is(), "XMLSignatureHelper::Init - mxSecurityContext already set!" ); + + ImplCreateSEInitializer(); + mxSecurityContext = mxSEInitializer->createSecurityContext( rTokenPath ); + return mxSecurityContext.is(); +} + +void XMLSignatureHelper::ImplCreateSEInitializer() +{ + rtl::OUString sSEInitializer; + + sSEInitializer = rtl::OUString::createFromAscii( SEINITIALIZER_COMPONENT ); + mxSEInitializer = uno::Reference< com::sun::star::xml::crypto::XSEInitializer > ( + mxMSF->createInstance( sSEInitializer ), uno::UNO_QUERY ); +} + +void XMLSignatureHelper::SetUriBinding( com::sun::star::uno::Reference< com::sun::star::xml::crypto::XUriBinding >& rxUriBinding ) +{ + mxUriBinding = rxUriBinding; +} + +void XMLSignatureHelper::SetStorage( const com::sun::star::uno::Reference < com::sun::star::embed::XStorage >& rxStorage ) +{ + DBG_ASSERT( !mxUriBinding.is(), "SetStorage - UriBinding already set!" ); + mxUriBinding = new UriBindingHelper( rxStorage ); +} + + +void XMLSignatureHelper::SetStartVerifySignatureHdl( const Link& rLink ) +{ + maStartVerifySignatureHdl = rLink; +} + + +void XMLSignatureHelper::StartMission() +{ + if ( !mxUriBinding.is() ) + mxUriBinding = new UriBindingHelper(); + + mpXSecController->startMission( mxUriBinding, mxSecurityContext ); +} + +void XMLSignatureHelper::EndMission() +{ + mpXSecController->endMission(); +} + +sal_Int32 XMLSignatureHelper::GetNewSecurityId() +{ + return mpXSecController->getNewSecurityId(); +} + +void XMLSignatureHelper::SetX509Certificate( + sal_Int32 nSecurityId, + const rtl::OUString& ouX509IssuerName, + const rtl::OUString& ouX509SerialNumber) +{ + mpXSecController->setX509Certificate( + nSecurityId, + ouX509IssuerName, + ouX509SerialNumber); +} + +void XMLSignatureHelper::SetDateTime( + sal_Int32 nSecurityId, + const rtl::OUString& ouDate, + const rtl::OUString& ouTime) +{ + mpXSecController->setDateTime( + nSecurityId, + ouDate, + ouTime); +} + +void XMLSignatureHelper::AddForSigning( sal_Int32 nSecurityId, const rtl::OUString& uri, const rtl::OUString& objectURL, sal_Bool bBinary ) +{ + mpXSecController->signAStream( nSecurityId, uri, objectURL, bBinary ); +} + +uno::Reference XMLSignatureHelper::CreateDocumentHandlerWithHeader( + const com::sun::star::uno::Reference< com::sun::star::io::XOutputStream >& xOutputStream ) +{ + /* + * get SAX writer component + */ + uno::Reference< io::XActiveDataSource > xSaxWriter( + mxMSF->createInstance(rtl::OUString::createFromAscii( + "com.sun.star.xml.sax.Writer")), + uno::UNO_QUERY ); + + DBG_ASSERT( xSaxWriter.is(), "can't instantiate XML writer" ); + + /* + * connect XML writer to output stream + */ + xSaxWriter->setOutputStream( xOutputStream ); + + /* + * prepare document handler + */ + uno::Reference + xDocHandler( xSaxWriter,uno::UNO_QUERY); + + /* + * write the xml context for signatures + */ + rtl::OUString tag_AllSignatures(RTL_CONSTASCII_USTRINGPARAM(SIGFILEROOTELEMENT)); + + xDocHandler->startDocument(); + xDocHandler->startElement( + tag_AllSignatures, + uno::Reference< xml::sax::XAttributeList > (new SvXMLAttributeList())); + + return xDocHandler; +} + +void XMLSignatureHelper::CloseDocumentHandler( const uno::Reference& xDocumentHandler ) +{ + rtl::OUString tag_AllSignatures(RTL_CONSTASCII_USTRINGPARAM(SIGFILEROOTELEMENT)); + xDocumentHandler->endElement( tag_AllSignatures ); + xDocumentHandler->endDocument(); +} + +void XMLSignatureHelper::ExportSignature( + const uno::Reference< xml::sax::XDocumentHandler >& xDocumentHandler, + const SignatureInformation& signatureInfo ) +{ + mpXSecController->exportSignature(xDocumentHandler, signatureInfo); +} + +bool XMLSignatureHelper::CreateAndWriteSignatue( const uno::Reference< xml::sax::XDocumentHandler >& xDocumentHandler ) +{ + mbError = false; + + /* + * create a signature listener + */ + ImplXMLSignatureListener* pSignatureListener = new ImplXMLSignatureListener( + LINK( this, XMLSignatureHelper, SignatureCreationResultListener ), + LINK( this, XMLSignatureHelper, SignatureVerifyResultListener ), + LINK( this, XMLSignatureHelper, StartVerifySignatureElement ) ); + + /* + * configure the signature creation listener + */ + //mpXSecController->setSignatureCreationResultListener( pSignatureListener ); + + /* + * write signatures + */ + if ( !mpXSecController->WriteSignatue( xDocumentHandler ) ) + { + mbError = true; + } + + /* + * clear up the signature creation listener + */ + //mpXSecController->setSignatureCreationResultListener( NULL ); + + return !mbError; +} + +bool XMLSignatureHelper::CreateAndWriteSignatue( const com::sun::star::uno::Reference< com::sun::star::io::XOutputStream >& xOutputStream ) +{ + uno::Reference xDocHandler + = CreateDocumentHandlerWithHeader(xOutputStream); + + bool rc = CreateAndWriteSignatue( xDocHandler ); + + CloseDocumentHandler(xDocHandler); + + return rc; +} + +bool XMLSignatureHelper::ReadAndVerifySignatue( const com::sun::star::uno::Reference< com::sun::star::io::XInputStream >& xInputStream ) +{ + mbError = false; + + DBG_ASSERT(xInputStream.is(), "input stream missing"); + + /* + * prepare ParserInputSrouce + */ + xml::sax::InputSource aParserInput; + // aParserInput.sSystemId = ouName; + aParserInput.aInputStream = xInputStream; + + /* + * get SAX parser component + */ + uno::Reference< xml::sax::XParser > xParser( + mxMSF->createInstance( + rtl::OUString::createFromAscii("com.sun.star.xml.sax.Parser") ), + uno::UNO_QUERY ); + DBG_ASSERT( xParser.is(), "Can't create parser" ); + + /* + * create a signature reader + */ + uno::Reference< xml::sax::XDocumentHandler > xHandler + = mpXSecController->createSignatureReader( ); + + /* + * create a signature listener + */ + ImplXMLSignatureListener* pSignatureListener = new ImplXMLSignatureListener( + LINK( this, XMLSignatureHelper, SignatureCreationResultListener ), + LINK( this, XMLSignatureHelper, SignatureVerifyResultListener ), + LINK( this, XMLSignatureHelper, StartVerifySignatureElement ) ); + + /* + * configure the signature verify listener + */ + //mpXSecController->setSignatureVerifyResultListener( pSignatureListener ); + + /* + * setup the connection: + * Parser -> SignatureListener -> SignatureReader + */ + pSignatureListener->setNextHandler(xHandler); + xParser->setDocumentHandler( pSignatureListener ); + + /* + * parser the stream + */ + try + { + xParser->parseStream( aParserInput ); + } + catch( xml::sax::SAXParseException& ) + { + mbError = true; + } + catch( xml::sax::SAXException& ) + { + mbError = true; + } + catch( com::sun::star::io::IOException& ) + { + mbError = true; + } + catch( uno::Exception& ) + { + mbError = true; + } + + /* + * clear up the connection + */ + pSignatureListener->setNextHandler( NULL ); + + /* + * clear up the signature verify listener + */ + //mpXSecController->setSignatureVerifyResultListener( NULL ); + + /* + * release the signature reader + */ + mpXSecController->releaseSignatureReader( ); + + return !mbError; +} + +SignatureInformations XMLSignatureHelper::GetSignatureInformations() const +{ + return mpXSecController->getSignatureInformations(); +} + +uno::Reference< ::com::sun::star::xml::crypto::XSecurityEnvironment > XMLSignatureHelper::GetSecurityEnvironment() +{ + return (mxSecurityContext.is()?(mxSecurityContext->getSecurityEnvironment()):NULL); +} + +/* +void XMLSignatureHelper::createSecurityContext( rtl::OUString tokenPath ) +{ + if ( !mxSEInitializer.is() ) + ImplCreateSEInitializer(); + + mxSecurityContext = mxSEInitializer->createSecurityContext(tokenPath); +} + +void XMLSignatureHelper::freeSecurityContext() +{ + if ( !mxSEInitializer.is() ) + ImplCreateSEInitializer(); + + mxSEInitializer->freeSecurityContext( mxSecurityContext ); +} +*/ + +IMPL_LINK( XMLSignatureHelper, SignatureCreationResultListener, XMLSignatureCreationResult*, pResult ) +{ + maCreationResults.insert( maCreationResults.begin() + maCreationResults.size(), *pResult ); + if ( pResult->nSignatureCreationResult != com::sun::star::xml::crypto::sax::SignatureCreationResult_CREATIONSUCCEED ) + mbError = true; + return 0; +} + +IMPL_LINK( XMLSignatureHelper, SignatureVerifyResultListener, XMLSignatureVerifyResult*, pResult ) +{ + maVerifyResults.insert( maVerifyResults.begin() + maVerifyResults.size(), *pResult ); + if ( pResult->nSignatureVerifyResult != com::sun::star::xml::crypto::sax::SignatureVerifyResult_VERIFYSUCCEED ) + mbError = true; + return 0; +} + +IMPL_LINK( XMLSignatureHelper, StartVerifySignatureElement, const uno::Reference< com::sun::star::xml::sax::XAttributeList >*, pAttrs ) +{ + if ( !maStartVerifySignatureHdl.IsSet() || maStartVerifySignatureHdl.Call( (void*)pAttrs ) ) + { + sal_Int32 nSignatureId = mpXSecController->getNewSecurityId(); + mpXSecController->addSignature( nSignatureId ); + } + + return 0; +} + + + diff --git a/xmlsecurity/source/helper/xmlsignaturehelper2.cxx b/xmlsecurity/source/helper/xmlsignaturehelper2.cxx new file mode 100644 index 000000000000..750b6dbf6524 --- /dev/null +++ b/xmlsecurity/source/helper/xmlsignaturehelper2.cxx @@ -0,0 +1,242 @@ +/************************************************************************* + * + * $RCSfile: xmlsignaturehelper2.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:22 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#include +#include + +#include + +#include +#include + +using namespace com::sun::star; + +ImplXMLSignatureListener::ImplXMLSignatureListener( const Link& rCreationResultListenerListener, const Link rVerifyResultListenerListener, const Link rStartSignatureElement ) +{ + maCreationResultListenerListener = rCreationResultListenerListener; + maVerifyResultListenerListener = rVerifyResultListenerListener; + maStartVerifySignatureElementListener = rStartSignatureElement; + +} +ImplXMLSignatureListener::~ImplXMLSignatureListener() +{ +} + +void ImplXMLSignatureListener::setNextHandler( + uno::Reference< xml::sax::XDocumentHandler > xNextHandler) +{ + m_xNextHandler = xNextHandler; +} + +void SAL_CALL ImplXMLSignatureListener::signatureCreated( sal_Int32 securityId, com::sun::star::xml::crypto::sax::SignatureCreationResult nResult ) + throw (com::sun::star::uno::RuntimeException) +{ + XMLSignatureCreationResult aResult( securityId, nResult ); + maCreationResultListenerListener.Call( &aResult ); +} + +void SAL_CALL ImplXMLSignatureListener::signatureVerified( sal_Int32 securityId, com::sun::star::xml::crypto::sax::SignatureVerifyResult nResult ) + throw (com::sun::star::uno::RuntimeException) +{ + XMLSignatureVerifyResult aResult( securityId, nResult ); + maVerifyResultListenerListener.Call( &aResult ); +} + +// --------------------------------------------------------------------------------- +// XDocumentHandler +// --------------------------------------------------------------------------------- +void SAL_CALL ImplXMLSignatureListener::startDocument( ) + throw (com::sun::star::xml::sax::SAXException, com::sun::star::uno::RuntimeException) +{ + if (m_xNextHandler.is()) + { + m_xNextHandler->startDocument(); + } +} + +void SAL_CALL ImplXMLSignatureListener::endDocument( ) + throw (com::sun::star::xml::sax::SAXException, com::sun::star::uno::RuntimeException) +{ + if (m_xNextHandler.is()) + { + m_xNextHandler->endDocument(); + } +} + +void SAL_CALL ImplXMLSignatureListener::startElement( const rtl::OUString& aName, const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList >& xAttribs ) + throw (com::sun::star::xml::sax::SAXException, com::sun::star::uno::RuntimeException) +{ + if ( aName == rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Signature")) ) + { + maStartVerifySignatureElementListener.Call( (void*)&xAttribs ); + } + + if (m_xNextHandler.is()) + { + m_xNextHandler->startElement( aName, xAttribs ); + } +} + +void SAL_CALL ImplXMLSignatureListener::endElement( const rtl::OUString& aName ) + throw (com::sun::star::xml::sax::SAXException, com::sun::star::uno::RuntimeException) +{ + if (m_xNextHandler.is()) + { + m_xNextHandler->endElement( aName ); + } +} + +void SAL_CALL ImplXMLSignatureListener::characters( const rtl::OUString& aChars ) + throw (com::sun::star::xml::sax::SAXException, com::sun::star::uno::RuntimeException) +{ + if (m_xNextHandler.is()) + { + m_xNextHandler->characters( aChars ); + } +} + +void SAL_CALL ImplXMLSignatureListener::ignorableWhitespace( const rtl::OUString& aWhitespaces ) + throw (com::sun::star::xml::sax::SAXException, com::sun::star::uno::RuntimeException) +{ + if (m_xNextHandler.is()) + { + m_xNextHandler->ignorableWhitespace( aWhitespaces ); + } +} + +void SAL_CALL ImplXMLSignatureListener::processingInstruction( const rtl::OUString& aTarget, const rtl::OUString& aData ) + throw (com::sun::star::xml::sax::SAXException, com::sun::star::uno::RuntimeException) +{ + if (m_xNextHandler.is()) + { + m_xNextHandler->processingInstruction( aTarget, aData ); + } +} + +void SAL_CALL ImplXMLSignatureListener::setDocumentLocator( const com::sun::star::uno::Reference< com::sun::star::xml::sax::XLocator >& xLocator ) + throw (com::sun::star::xml::sax::SAXException, com::sun::star::uno::RuntimeException) +{ + if (m_xNextHandler.is()) + { + m_xNextHandler->setDocumentLocator( xLocator ); + } +} + +// --------------------------------------------------------------------------------- +// XUriBinding +// --------------------------------------------------------------------------------- + +UriBindingHelper::UriBindingHelper() +{ +} + +UriBindingHelper::UriBindingHelper( const com::sun::star::uno::Reference < com::sun::star::embed::XStorage >& rxStorage ) +{ + mxStorage = rxStorage; +} + + +void SAL_CALL UriBindingHelper::setUriBinding( const rtl::OUString& uri, const uno::Reference< io::XInputStream >& aInputStream ) + throw (uno::Exception, uno::RuntimeException) +{ +} + +uno::Reference< io::XInputStream > SAL_CALL UriBindingHelper::getUriBinding( const rtl::OUString& uri ) + throw (uno::Exception, uno::RuntimeException) +{ + uno::Reference< io::XInputStream > xInputStream; + if ( mxStorage.is() ) + { + uno::Reference< io::XStream > xStream = OpenInputStream( mxStorage, uri ); + xInputStream = uno::Reference< io::XInputStream >( xStream, uno::UNO_QUERY ); + } + else + { + SvFileStream* pStream = new SvFileStream( uri, STREAM_READ ); + pStream->Seek( STREAM_SEEK_TO_END ); + ULONG nBytes = pStream->Tell(); + pStream->Seek( STREAM_SEEK_TO_BEGIN ); + SvLockBytesRef xLockBytes = new SvLockBytes( pStream, TRUE ); + xInputStream = new utl::OInputStreamHelper( xLockBytes, nBytes ); + } + return xInputStream; +} + +uno::Reference < io::XStream > UriBindingHelper::OpenInputStream( uno::Reference < embed::XStorage >& rxStore, const rtl::OUString& rURI ) +{ + uno::Reference < io::XStream > xStream; + + sal_Int32 nSepPos = rURI.indexOf( '/' ); + if ( nSepPos == -1 ) + { + xStream = rxStore->openStreamElement( rURI, embed::ElementModes::READ ); + } + else + { + rtl::OUString aStoreName = rURI.copy( 0, nSepPos ); + rtl::OUString aElement = rURI.copy( nSepPos+1 ); + uno::Reference < embed::XStorage > xSubStore = rxStore->openStorageElement( aStoreName, embed::ElementModes::READ ); + xStream = OpenInputStream( xSubStore, aElement ); + } + return xStream; +} + + diff --git a/xmlsecurity/source/helper/xmlsignaturehelper2.hxx b/xmlsecurity/source/helper/xmlsignaturehelper2.hxx new file mode 100644 index 000000000000..f41bb3da6c9d --- /dev/null +++ b/xmlsecurity/source/helper/xmlsignaturehelper2.hxx @@ -0,0 +1,164 @@ +/************************************************************************* + * + * $RCSfile: xmlsignaturehelper2.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:22 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#include +#include + +#include +#include + +#include +#include +#include + +namespace com { +namespace sun { +namespace star { +namespace io { + class XStream; + class XOutputStream; + class XInputStream; } +namespace embed { + class XStorage; } +}}} + +class ImplXMLSignatureListener : public cppu::WeakImplHelper3 +< + com::sun::star::xml::crypto::sax::XSignatureCreationResultListener, + com::sun::star::xml::crypto::sax::XSignatureVerifyResultListener, + com::sun::star::xml::sax::XDocumentHandler +> +{ +private: + Link maCreationResultListenerListener; + Link maVerifyResultListenerListener; + Link maStartVerifySignatureElementListener; + + com::sun::star::uno::Reference< + com::sun::star::xml::sax::XDocumentHandler > m_xNextHandler; + +public: + ImplXMLSignatureListener( const Link& rCreationResultListenerListener, const Link rVerifyResultListenerListener, const Link rStartVerifySignatureElement ); + ~ImplXMLSignatureListener(); + + void setNextHandler(com::sun::star::uno::Reference< + com::sun::star::xml::sax::XDocumentHandler > xNextHandler); + + // com::sun::star::xml::crypto::sax::XSignatureCreationResultListener + virtual void SAL_CALL signatureCreated( sal_Int32 securityId, com::sun::star::xml::crypto::sax::SignatureCreationResult creationResult ) + throw (com::sun::star::uno::RuntimeException); + + // com::sun::star::xml::crypto::sax::XSignatureVerifyResultListener + virtual void SAL_CALL signatureVerified( sal_Int32 securityId, com::sun::star::xml::crypto::sax::SignatureVerifyResult verifyResult ) + throw (com::sun::star::uno::RuntimeException); + + // com::sun::star::xml::sax::XDocumentHandler + virtual void SAL_CALL startElement( const rtl::OUString& aName, const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList >& xAttribs ) + throw (com::sun::star::xml::sax::SAXException, com::sun::star::uno::RuntimeException); + + virtual void SAL_CALL startDocument( ) + throw (com::sun::star::xml::sax::SAXException, com::sun::star::uno::RuntimeException); + + virtual void SAL_CALL endDocument( ) + throw (com::sun::star::xml::sax::SAXException, com::sun::star::uno::RuntimeException); + + virtual void SAL_CALL endElement( const rtl::OUString& aName ) + throw (com::sun::star::xml::sax::SAXException, com::sun::star::uno::RuntimeException); + + virtual void SAL_CALL characters( const rtl::OUString& aChars ) + throw (com::sun::star::xml::sax::SAXException, com::sun::star::uno::RuntimeException); + + virtual void SAL_CALL ignorableWhitespace( const rtl::OUString& aWhitespaces ) + throw (com::sun::star::xml::sax::SAXException, com::sun::star::uno::RuntimeException); + + virtual void SAL_CALL processingInstruction( const rtl::OUString& aTarget, const rtl::OUString& aData ) + throw (com::sun::star::xml::sax::SAXException, com::sun::star::uno::RuntimeException); + + virtual void SAL_CALL setDocumentLocator( const com::sun::star::uno::Reference< com::sun::star::xml::sax::XLocator >& xLocator ) + throw (com::sun::star::xml::sax::SAXException, com::sun::star::uno::RuntimeException); +}; + + +// --------------------------------------------------------------------------------- +// XUriBinding +// --------------------------------------------------------------------------------- + +class UriBindingHelper : public cppu::WeakImplHelper1 +< + com::sun::star::xml::crypto::XUriBinding +> +{ +private: + com::sun::star::uno::Reference < com::sun::star::embed::XStorage > mxStorage; + +public: + UriBindingHelper(); + UriBindingHelper( const com::sun::star::uno::Reference < com::sun::star::embed::XStorage >& rxStorage ); + + void SAL_CALL setUriBinding( const rtl::OUString& uri, const com::sun::star::uno::Reference< com::sun::star::io::XInputStream >& aInputStream ) + throw (com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException); + + 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); + + static com::sun::star::uno::Reference < com::sun::star::io::XStream > OpenInputStream( com::sun::star::uno::Reference < com::sun::star::embed::XStorage >& rxStore, const rtl::OUString& rURI ); +}; + diff --git a/xmlsecurity/source/helper/xsecctl.cxx b/xmlsecurity/source/helper/xsecctl.cxx new file mode 100644 index 000000000000..9408b7378a74 --- /dev/null +++ b/xmlsecurity/source/helper/xsecctl.cxx @@ -0,0 +1,1359 @@ +/************************************************************************* + * + * $RCSfile: xsecctl.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:22 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#include + +#ifndef _TOOLS_DEBUG_HXX //autogen wg. DBG_ASSERT +#include +#endif + +#include +#include +#include +#include +#include +#include +#include + +#include + +namespace cssu = com::sun::star::uno; +namespace cssl = com::sun::star::lang; +namespace cssxc = com::sun::star::xml::crypto; +namespace cssxs = com::sun::star::xml::sax; +namespace cssxw = com::sun::star::xml::wrapper; +namespace cssb = com::sun::star::beans; + +/* bridge component names */ +#define XMLSIGNATURE_COMPONENT "com.sun.star.xml.crypto.XMLSignature" +#define XMLDOCUMENTWRAPPER_COMPONENT "com.sun.star.xml.wrapper.XMLDocumentWrapper" + +/* xml security framework components */ +#define SAXEVENTKEEPER_COMPONENT "com.sun.star.xml.crypto.sax.SAXEventKeeper" + +/* string for package protocol */ +#define PACKAGEPROTOCOL "vnd.sun.star.Package:" + +XSecController::XSecController( ) + :m_nNextSecurityId(1), + m_bIsSAXEventKeeperSticky(false), + m_bIsSAXEventKeeperConnected(false), + m_nStatusOfSecurityComponents(UNINITIALIZED), + m_pErrorMessage(NULL), + m_pXSecParser(NULL) +{ +} + +XSecController::~XSecController() +{ +} + + +/* + * private methods + */ +int XSecController::findSignatureInfor( sal_Int32 nSecurityId) +/****** XSecController/findSignatureInfor ************************************* + * + * NAME + * findSignatureInfor -- find SignatureInformation struct for a particular + * signature + * + * SYNOPSIS + * index = findSignatureInfor( nSecurityId ); + * + * FUNCTION + * see NAME. + * + * INPUTS + * nSecurityId - the signature's id + * + * RESULT + * index - the index of the signature, or -1 when no such signature + * existing + * + * HISTORY + * 08.05.2004 - implemented + * + * AUTHOR + * Michael Mi + * Email: michael.mi@sun.com + ******************************************************************************/ +{ + int i; + int size = m_vInternalSignatureInformations.size(); + + for (i=0; i( + mxMSF->createInstance( sXMLSignature ), + cssu::UNO_QUERY ); + + bool bSuccess = (0!=m_xXMLSignature.is()); + if ( bSuccess ) + /* + * XMLSignature created successfully. + */ + { + m_xXMLDocumentWrapper = cssu::Reference< cssxw::XXMLDocumentWrapper >( + mxMSF->createInstance( sXMLDocument ), + cssu::UNO_QUERY ); + } + + bSuccess &= (0!=m_xXMLDocumentWrapper.is()); + if ( bSuccess ) + /* + * XMLDocumentWrapper created successfully. + */ + { + m_xSAXEventKeeper = cssu::Reference< cssxc::sax::XSecuritySAXEventKeeper >( + mxMSF->createInstance( sSAXEventKeeper ), + cssu::UNO_QUERY ); + } + + bSuccess &= (0!=m_xSAXEventKeeper.is()); + + if (bSuccess) + /* + * SAXEventKeeper created successfully. + */ + { + cssu::Reference< cssl::XInitialization > xInitialization(m_xSAXEventKeeper, cssu::UNO_QUERY); + + cssu::Sequence arg(1); + arg[0] = cssu::makeAny(m_xXMLDocumentWrapper); + xInitialization->initialize(arg); + + cssu::Reference + xSAXEventKeeperStatusChangeBroadcaster(m_xSAXEventKeeper, cssu::UNO_QUERY); + cssu::Reference< cssxc::sax::XSAXEventKeeperStatusChangeListener > + xStatusChangeListener = this; + + xSAXEventKeeperStatusChangeBroadcaster + ->addXSAXEventKeeperStatusChangeListener( xStatusChangeListener ); + + m_nStatusOfSecurityComponents = INITIALIZED; + } +} + +bool XSecController::chainOn( bool bRetrievingLastEvent ) +/****** XSecController/chainOn ************************************************ + * + * NAME + * chainOn -- tyies to connect the SAXEventKeeper with the SAX chain. + * + * SYNOPSIS + * bJustChainingOn = chainOn( bRetrievingLastEvent ); + * + * FUNCTION + * First, checks whether the SAXEventKeeper is on the SAX chain. If not, + * creates xml security components, and chains the SAXEventKeeper into + * the SAX chain. + * Before being chained in, the SAXEventKeeper needs to receive all + * missed key SAX events, which can promise the DOM tree bufferred by the + * SAXEventKeeper has the same structure with the original document. + * + * INPUTS + * bRetrievingLastEvent - whether to retrieve the last key SAX event from + * the ElementStackKeeper. + * + * RESULT + * bJustChainingOn - whether the SAXEventKeeper is just chained into the + * SAX chain. + * + * NOTES + * Sometimes, the last key SAX event can't be transferred to the + * SAXEventKeeper together. + * For instance, at the time an referenced element is detected, the + * startElement event has already been reserved by the ElementStackKeeper. + * Meanwhile, an ElementCollector needs to be created before the + * SAXEventKeeper receives that startElement event. + * So for the SAXEventKeeper, it needs to receive all missed key SAX + * events except that startElement event, then adds a new + * ElementCollector, then receives that startElement event. + * + * HISTORY + * 05.01.2004 - implemented + * + * AUTHOR + * Michael Mi + * Email: michael.mi@sun.com + ******************************************************************************/ +{ + bool rc = false; + + if (!m_bIsSAXEventKeeperSticky && !m_bIsSAXEventKeeperConnected) + { + if ( m_nStatusOfSecurityComponents == UNINITIALIZED ) + { + createXSecComponent(); + } + + if ( m_nStatusOfSecurityComponents == INITIALIZED ) + /* + * if all security components are ready, chains on the SAXEventKeeper + */ + { + /* + * disconnect the SAXEventKeeper with its current output handler, + * to make sure no SAX event is forwarded during the connecting + * phase. + */ + m_xSAXEventKeeper->setNextHandler( NULL ); + + cssu::Reference< cssxs::XDocumentHandler > xSEKHandler(m_xSAXEventKeeper, cssu::UNO_QUERY); + + /* + * connects the previous document handler on the SAX chain + */ + if ( m_xPreviousNodeOnSAXChain.is() ) + { + if ( m_bIsPreviousNodeInitializable ) + { + cssu::Reference< cssl::XInitialization > xInitialization + (m_xPreviousNodeOnSAXChain, cssu::UNO_QUERY); + + cssu::Sequence aArgs( 1 ); + aArgs[0] <<= xSEKHandler; + xInitialization->initialize(aArgs); + } + else + { + cssu::Reference< cssxs::XParser > xParser + (m_xPreviousNodeOnSAXChain, cssu::UNO_QUERY); + xParser->setDocumentHandler( xSEKHandler ); + } + } + + /* + * get missed key SAX events + */ + if (m_xElementStackKeeper.is()) + { + m_xElementStackKeeper->retrieve(xSEKHandler, bRetrievingLastEvent); + + /* + * now the ElementStackKeeper can stop its work, because the + * SAXEventKeeper is on the SAX chain, no SAX events will be + * missed. + */ + m_xElementStackKeeper->stop(); + } + + /* + * connects the next document handler on the SAX chain + */ + m_xSAXEventKeeper->setNextHandler( m_xNextNodeOnSAXChain ); + + m_bIsSAXEventKeeperConnected = true; + + rc = true; + } + } + + return rc; +} + +void XSecController::chainOff() +/****** XSecController/chainOff *********************************************** + * + * NAME + * chainOff -- disconnects the SAXEventKeeper from the SAX chain. + * + * SYNOPSIS + * chainOff( ); + * + * FUNCTION + * See NAME. + * + * INPUTS + * empty + * + * RESULT + * empty + * + * HISTORY + * 05.01.2004 - implemented + * + * AUTHOR + * Michael Mi + * Email: michael.mi@sun.com + ******************************************************************************/ +{ + if (!m_bIsSAXEventKeeperSticky ) + { + if (m_bIsSAXEventKeeperConnected) + { + m_xSAXEventKeeper->setNextHandler( NULL ); + + if ( m_xPreviousNodeOnSAXChain.is() ) + { + if ( m_bIsPreviousNodeInitializable ) + { + cssu::Reference< cssl::XInitialization > xInitialization + (m_xPreviousNodeOnSAXChain, cssu::UNO_QUERY); + + cssu::Sequence aArgs( 1 ); + aArgs[0] <<= m_xNextNodeOnSAXChain; + xInitialization->initialize(aArgs); + } + else + { + cssu::Reference< cssxs::XParser > xParser(m_xPreviousNodeOnSAXChain, cssu::UNO_QUERY); + xParser->setDocumentHandler( m_xNextNodeOnSAXChain ); + } + } + + if (m_xElementStackKeeper.is()) + { + /* + * start the ElementStackKeeper to reserve any possible + * missed key SAX events + */ + m_xElementStackKeeper->start(); + } + + m_bIsSAXEventKeeperConnected = false; + } + } +} + +void XSecController::checkChainingStatus() +/****** XSecController/checkChainingStatus ************************************ + * + * NAME + * checkChainingStatus -- connects or disconnects the SAXEventKeeper + * according to the current situation. + * + * SYNOPSIS + * checkChainingStatus( ); + * + * FUNCTION + * The SAXEventKeeper is chained into the SAX chain, when: + * 1. some element is being collected, or + * 2. the SAX event stream is blocking. + * Otherwise, chain off the SAXEventKeeper. + * + * INPUTS + * empty + * + * RESULT + * empty + * + * HISTORY + * 05.01.2004 - implemented + * + * AUTHOR + * Michael Mi + * Email: michael.mi@sun.com + ******************************************************************************/ +{ + if ( m_bIsCollectingElement || m_bIsBlocking ) + { + chainOn(true); + } + else + { + chainOff(); + } +} + +void XSecController::initializeSAXChain() +/****** XSecController/initializeSAXChain ************************************* + * + * NAME + * initializeSAXChain -- initializes the SAX chain according to the + * current setting. + * + * SYNOPSIS + * initializeSAXChain( ); + * + * FUNCTION + * Initializes the SAX chain, if the SAXEventKeeper is asked to be always + * on the SAX chain, chains it on. Otherwise, starts the + * ElementStackKeeper to reserve key SAX events. + * + * INPUTS + * empty + * + * RESULT + * empty + * + * HISTORY + * 05.01.2004 - implemented + * + * AUTHOR + * Michael Mi + * Email: michael.mi@sun.com + ******************************************************************************/ +{ + m_bIsSAXEventKeeperConnected = false; + m_bIsCollectingElement = false; + m_bIsBlocking = false; + + if (m_xElementStackKeeper.is()) + { + /* + * starts the ElementStackKeeper + */ + m_xElementStackKeeper->start(); + } + + chainOff(); +} + +cssu::Reference< com::sun::star::io::XInputStream > + XSecController::getObjectInputStream( const rtl::OUString& objectURL ) +/****** XSecController/getObjectInputStream ************************************ + * + * NAME + * getObjectInputStream -- get a XInputStream interface from a SvStorage + * + * SYNOPSIS + * xInputStream = getObjectInputStream( objectURL ); + * + * FUNCTION + * See NAME. + * + * INPUTS + * objectURL - the object uri + * + * RESULT + * xInputStream - the XInputStream interface + * + * HISTORY + * 15.04.2004 - implemented + * + * AUTHOR + * Michael Mi + * Email: michael.mi@sun.com + ******************************************************************************/ +{ + cssu::Reference< com::sun::star::io::XInputStream > xObjectInputStream; + + DBG_ASSERT( m_xUriBinding.is(), "Need XUriBinding!" ); + + xObjectInputStream = m_xUriBinding->getUriBinding(objectURL); + + return xObjectInputStream; +} + +#if 0 +sal_Int32 XSecController::getFastPropertyIndex(sal_Int32 nHandle) const +/****** XSecController/getFastPropertyIndex *********************************** + * + * NAME + * getFastPropertyIndex -- gets the index of a particular fast property + * + * SYNOPSIS + * nIndex = getFastPropertyIndex( nHandle ); + * + * FUNCTION + * See NAME. + * + * INPUTS + * nHandle - the key for the fast property + * + * RESULT + * nIndex - the index of the fast property, or -1 + * if the key is not found. + * + * HISTORY + * 05.01.2004 - implemented + * + * AUTHOR + * Michael Mi + * Email: michael.mi@sun.com + ******************************************************************************/ +{ + std::vector< sal_Int32 >::const_iterator ii = m_vFastPropertyIndexs.begin(); + sal_Int32 nIndex = 0; + + bool bFound = false; + + for( ; ii != m_vFastPropertyIndexs.end(); ++ii,++nIndex ) + { + if ( nHandle == (*ii)) + { + bFound = true; + break; + } + } + + if (!bFound) + { + nIndex = -1; + } + + return nIndex; +} +#endif + +/* + * public methods + */ + +void XSecController::setFactory( const cssu::Reference& rxMSF) +/****** XSecController/setFactory ********************************************* + * + * NAME + * setFactory -- configures the service factory component. + * + * SYNOPSIS + * setFactory( rxMSF ); + * + * FUNCTION + * See NAME. + * + * INPUTS + * rxMSF - the service factory component + * + * RESULT + * empty + * + * HISTORY + * 05.01.2004 - implemented + * + * AUTHOR + * Michael Mi + * Email: michael.mi@sun.com + ******************************************************************************/ +{ + mxMSF = rxMSF; +} + +#if 0 +void XSecController::setSignatureCreationResultListener( + const cssu::Reference< cssxc::sax::XSignatureCreationResultListener >& xSignatureCreationResultListener) +{ + m_xSignatureCreationResultListener = xSignatureCreationResultListener; +} + +void XSecController::setSignatureVerifyResultListener( + const cssu::Reference< cssxc::sax::XSignatureVerifyResultListener >& xSignatureVerifyResultListener) +{ + m_xSignatureVerifyResultListener = xSignatureVerifyResultListener; +} +#endif + +sal_Int32 XSecController::getNewSecurityId( ) +{ + sal_Int32 nId = m_nNextSecurityId; + m_nNextSecurityId++; + return nId; +} + +void XSecController::startMission( + const cssu::Reference< cssxc::XUriBinding >& xUriBinding, + const cssu::Reference< cssxc::XXMLSecurityContext >& xSecurityContext ) +/****** XSecController/startMission ******************************************* + * + * NAME + * startMission -- starts a new security mission. + * + * SYNOPSIS + * startMission( xUriBinding, xSecurityContect ); + * + * FUNCTION + * get ready for a new mission. + * + * INPUTS + * xUriBinding - the Uri binding that provide maps between uris and + * XInputStreams + * xSecurityContext - the security context component which can provide + * cryptoken + * + * RESULT + * empty + * + * HISTORY + * 05.01.2004 - implemented + * + * AUTHOR + * Michael Mi + * Email: michael.mi@sun.com + ******************************************************************************/ +{ + m_xUriBinding = xUriBinding; + + m_nStatusOfSecurityComponents = UNINITIALIZED; + m_xSecurityContext = xSecurityContext; + m_pErrorMessage = NULL; + + m_vInternalSignatureInformations.clear(); + + m_bVerifyCurrentSignature = false; +} + +void XSecController::setSAXChainConnector( + const cssu::Reference< cssl::XInitialization >& xInitialization, + const cssu::Reference< cssxs::XDocumentHandler >& xDocumentHandler, + const cssu::Reference< cssxc::sax::XElementStackKeeper >& xElementStackKeeper) +/****** XSecController/setSAXChainConnector *********************************** + * + * NAME + * setSAXChainConnector -- configures the components which will + * collaborate with the SAXEventKeeper on the SAX chain. + * + * SYNOPSIS + * setSAXChainConnector( xInitialization, + * xDocumentHandler, + * xElementStackKeeper ); + * + * FUNCTION + * See NAME. + * + * INPUTS + * xInitialization - the previous node on the SAX chain + * xDocumentHandler - the next node on the SAX chain + * xElementStackKeeper - the ElementStackKeeper component which reserves + * missed key SAX events for the SAXEventKeeper + * + * RESULT + * empty + * + * HISTORY + * 05.01.2004 - implemented + * + * AUTHOR + * Michael Mi + * Email: michael.mi@sun.com + ******************************************************************************/ +{ + m_bIsPreviousNodeInitializable = true; + m_xPreviousNodeOnSAXChain = xInitialization; + m_xNextNodeOnSAXChain = xDocumentHandler; + m_xElementStackKeeper = xElementStackKeeper; + + initializeSAXChain( ); +} + +void XSecController::setSAXChainConnector( + const cssu::Reference< cssxs::XParser >& xParser, + const cssu::Reference< cssxs::XDocumentHandler >& xDocumentHandler, + const cssu::Reference< cssxc::sax::XElementStackKeeper >& xElementStackKeeper) +/****** XSecController/setSAXChainConnector *********************************** + * + * NAME + * setSAXChainConnector -- configures the components which will + * collaborate with the SAXEventKeeper on the SAX chain. + * + * SYNOPSIS + * setSAXChainConnector( xParser, xDocumentHandler, xElementStackKeeper ); + * + * FUNCTION + * See NAME. + * + * INPUTS + * xParser - the previous node on the SAX chain + * xDocumentHandler - the next node on the SAX chain + * xElementStackKeeper -the ElementStackKeeper component which reserves + * missed key SAX events for the SAXEventKeeper + * + * RESULT + * empty + * + * HISTORY + * 05.01.2004 - implemented + * + * AUTHOR + * Michael Mi + * Email: michael.mi@sun.com + ******************************************************************************/ +{ + m_bIsPreviousNodeInitializable = false; + m_xPreviousNodeOnSAXChain = xParser; + m_xNextNodeOnSAXChain = xDocumentHandler; + m_xElementStackKeeper = xElementStackKeeper; + + initializeSAXChain( ); +} + +void XSecController::clearSAXChainConnector() +/****** XSecController/clearSAXChainConnector ********************************* + * + * NAME + * clearSAXChainConnector -- resets the collaborating components. + * + * SYNOPSIS + * clearSAXChainConnector( ); + * + * FUNCTION + * See NAME. + * + * INPUTS + * empty + * + * RESULT + * empty + * + * HISTORY + * 05.01.2004 - implemented + * + * AUTHOR + * Michael Mi + * Email: michael.mi@sun.com + ******************************************************************************/ +{ + /* + * before reseting, if the ElementStackKeeper has kept something, then + * those kept key SAX events must be transferred to the SAXEventKeeper + * first. This is to promise the next node to the SAXEventKeeper on the + * SAX chain always receives a complete document. + */ + if (m_xElementStackKeeper.is() && m_xSAXEventKeeper.is()) + { + cssu::Reference< cssxs::XDocumentHandler > xSEKHandler(m_xSAXEventKeeper, cssu::UNO_QUERY); + m_xElementStackKeeper->retrieve(xSEKHandler, sal_True); + } + + chainOff(); + + m_xPreviousNodeOnSAXChain = NULL; + m_xNextNodeOnSAXChain = NULL; + m_xElementStackKeeper = NULL; +} + +void XSecController::endMission() +/****** XSecController/endMission ********************************************* + * + * NAME + * endMission -- forces to end all missions + * + * SYNOPSIS + * endMission( ); + * + * FUNCTION + * Deletes all signature information and forces all missions to an end. + * + * INPUTS + * empty + * + * RESULT + * empty + * + * HISTORY + * 05.01.2004 - implemented + * + * AUTHOR + * Michael Mi + * Email: michael.mi@sun.com + ******************************************************************************/ +{ + sal_Int32 size = m_vInternalSignatureInformations.size(); + + for (int i=0; i xMissionTaker + ( m_vInternalSignatureInformations[i].xReferenceResolvedListener, cssu::UNO_QUERY ); + + /* + * askes the SignatureCreator/SignatureVerifier to release + * all resouces it uses. + */ + xMissionTaker->endMission(); + } + } + + m_xUriBinding = NULL; + m_xSecurityContext = NULL; + + /* + * free the status change listener reference to this object + */ + if (m_xSAXEventKeeper.is()) + { + cssu::Reference + xSAXEventKeeperStatusChangeBroadcaster(m_xSAXEventKeeper, cssu::UNO_QUERY); + xSAXEventKeeperStatusChangeBroadcaster + ->addXSAXEventKeeperStatusChangeListener( NULL ); + } +} + +const char* XSecController::getErrorMessage() +/****** XSecController/getErrorMessage **************************************** + * + * NAME + * getErrorMessage -- get the last error message + * + * SYNOPSIS + * pErrorMessage = getErrorMessage( ); + * + * FUNCTION + * see NAME. + * + * INPUTS + * empty + * + * RESULT + * empty + * + * HISTORY + * 22.04.2004 - implemented + * + * AUTHOR + * Michael Mi + * Email: michael.mi@sun.com + ******************************************************************************/ +{ + return m_pErrorMessage; +} + +void XSecController::exportSignature( + const cssu::Reference& xDocumentHandler, + const SignatureInformation& signatureInfo ) +/****** XSecController/exportSignature **************************************** + * + * NAME + * exportSignature -- export a signature structure to an XDocumentHandler + * + * SYNOPSIS + * exportSignature( xDocumentHandler, signatureInfo); + * + * FUNCTION + * see NAME. + * + * INPUTS + * xDocumentHandler - the document handler to receive the signature + * signatureInfo - signature to be exported + * + * RESULT + * empty + * + * HISTORY + * 26.05.2004 - implemented + * + * AUTHOR + * Michael Mi + * Email: michael.mi@sun.com + ******************************************************************************/ +{ + /* + * defines all element tags in Signature element. + */ + rtl::OUString tag_Signature(RTL_CONSTASCII_USTRINGPARAM(TAG_SIGNATURE)); + rtl::OUString tag_SignedInfo(RTL_CONSTASCII_USTRINGPARAM(TAG_SIGNEDINFO)); + rtl::OUString tag_CanonicalizationMethod(RTL_CONSTASCII_USTRINGPARAM(TAG_CANONICALIZATIONMETHOD)); + rtl::OUString tag_SignatureMethod(RTL_CONSTASCII_USTRINGPARAM(TAG_SIGNATUREMETHOD)); + rtl::OUString tag_Reference(RTL_CONSTASCII_USTRINGPARAM(TAG_REFERENCE)); + rtl::OUString tag_Transforms(RTL_CONSTASCII_USTRINGPARAM(TAG_TRANSFORMS)); + rtl::OUString tag_Transform(RTL_CONSTASCII_USTRINGPARAM(TAG_TRANSFORM)); + rtl::OUString tag_DigestMethod(RTL_CONSTASCII_USTRINGPARAM(TAG_DIGESTMETHOD)); + rtl::OUString tag_DigestValue(RTL_CONSTASCII_USTRINGPARAM(TAG_DIGESTVALUE)); + rtl::OUString tag_SignatureValue(RTL_CONSTASCII_USTRINGPARAM(TAG_SIGNATUREVALUE)); + rtl::OUString tag_KeyInfo(RTL_CONSTASCII_USTRINGPARAM(TAG_KEYINFO)); + rtl::OUString tag_X509Data(RTL_CONSTASCII_USTRINGPARAM(TAG_X509DATA)); + rtl::OUString tag_X509IssuerSerial(RTL_CONSTASCII_USTRINGPARAM(TAG_X509ISSUERSERIAL)); + rtl::OUString tag_X509IssuerName(RTL_CONSTASCII_USTRINGPARAM(TAG_X509ISSUERNAME)); + rtl::OUString tag_X509SerialNumber(RTL_CONSTASCII_USTRINGPARAM(TAG_X509SERIALNUMBER)); + rtl::OUString tag_X509Certificate(RTL_CONSTASCII_USTRINGPARAM(TAG_X509CERTIFICATE)); + + rtl::OUString tag_Object(RTL_CONSTASCII_USTRINGPARAM(TAG_OBJECT)); + rtl::OUString tag_SignatureProperties(RTL_CONSTASCII_USTRINGPARAM(TAG_SIGNATUREPROPERTIES)); + rtl::OUString tag_SignatureProperty(RTL_CONSTASCII_USTRINGPARAM(TAG_SIGNATUREPROPERTY)); + rtl::OUString tag_Timestamp(RTL_CONSTASCII_USTRINGPARAM(TAG_TIMESTAMP)); + rtl::OUString tag_Date(RTL_CONSTASCII_USTRINGPARAM(TAG_DATE)); + rtl::OUString tag_Time(RTL_CONSTASCII_USTRINGPARAM(TAG_TIME)); + + const SignatureReferenceInformations& vReferenceInfors = signatureInfo.vSignatureReferenceInfors; + SvXMLAttributeList *pAttributeList; + + /* + * Write Signature element + */ + pAttributeList = new SvXMLAttributeList(); + pAttributeList->AddAttribute( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(ATTR_XMLNS)), + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(NS_XMLDSIG))); + + if (signatureInfo.ouSignatureId.getLength()>0) + { + pAttributeList->AddAttribute( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(ATTR_ID)), + rtl::OUString(signatureInfo.ouSignatureId)); + } + + xDocumentHandler->startElement( tag_Signature, cssu::Reference< cssxs::XAttributeList > (pAttributeList)); + { + /* Write SignedInfo element */ + xDocumentHandler->startElement( + tag_SignedInfo, + cssu::Reference< cssxs::XAttributeList > (new SvXMLAttributeList())); + { + /* Write CanonicalizationMethod element */ + pAttributeList = new SvXMLAttributeList(); + pAttributeList->AddAttribute( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(ATTR_ALGORITHM)), + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(ALGO_C14N))); + xDocumentHandler->startElement( tag_CanonicalizationMethod, cssu::Reference< cssxs::XAttributeList > (pAttributeList) ); + xDocumentHandler->endElement( tag_CanonicalizationMethod ); + + /* Write SignatureMethod element */ + pAttributeList = new SvXMLAttributeList(); + pAttributeList->AddAttribute( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(ATTR_ALGORITHM)), + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(ALGO_RSASHA1))); + xDocumentHandler->startElement( tag_SignatureMethod, cssu::Reference< cssxs::XAttributeList > (pAttributeList) ); + xDocumentHandler->endElement( tag_SignatureMethod ); + + /* Write Reference element */ + int j; + int refNum = vReferenceInfors.size(); + + for(j=0; jAddAttribute( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(ATTR_URI)), + refInfor.ouURI); + } + else + /* + * same-document reference + */ + { + pAttributeList->AddAttribute( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(ATTR_URI)), + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(CHAR_FRAGMENT))+refInfor.ouURI); + } + + xDocumentHandler->startElement( tag_Reference, cssu::Reference< cssxs::XAttributeList > (pAttributeList) ); + { + /* Write Transforms element */ + if (refInfor.nType == 3) + /* + * xml stream, so c14n transform is needed + */ + { + xDocumentHandler->startElement( + tag_Transforms, + cssu::Reference< cssxs::XAttributeList > (new SvXMLAttributeList())); + { + pAttributeList = new SvXMLAttributeList(); + pAttributeList->AddAttribute( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(ATTR_ALGORITHM)), + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(ALGO_C14N))); + xDocumentHandler->startElement( + tag_Transform, + cssu::Reference< cssxs::XAttributeList > (pAttributeList) ); + xDocumentHandler->endElement( tag_Transform ); + } + xDocumentHandler->endElement( tag_Transforms ); + } + + /* Write DigestMethod element */ + pAttributeList = new SvXMLAttributeList(); + pAttributeList->AddAttribute( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(ATTR_ALGORITHM)), + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(ALGO_XMLDSIGSHA1))); + xDocumentHandler->startElement( + tag_DigestMethod, + cssu::Reference< cssxs::XAttributeList > (pAttributeList) ); + xDocumentHandler->endElement( tag_DigestMethod ); + + /* Write DigestValue element */ + xDocumentHandler->startElement( + tag_DigestValue, + cssu::Reference< cssxs::XAttributeList > (new SvXMLAttributeList())); + xDocumentHandler->characters( refInfor.ouDigestValue ); + xDocumentHandler->endElement( tag_DigestValue ); + } + xDocumentHandler->endElement( tag_Reference ); + } + } + xDocumentHandler->endElement( tag_SignedInfo ); + + /* Write SignatureValue element */ + xDocumentHandler->startElement( + tag_SignatureValue, + cssu::Reference< cssxs::XAttributeList > (new SvXMLAttributeList())); + xDocumentHandler->characters( signatureInfo.ouSignatureValue ); + xDocumentHandler->endElement( tag_SignatureValue ); + + /* Write KeyInfo element */ + xDocumentHandler->startElement( + tag_KeyInfo, + cssu::Reference< cssxs::XAttributeList > (new SvXMLAttributeList())); + { + /* Write X509Data element */ + xDocumentHandler->startElement( + tag_X509Data, + cssu::Reference< cssxs::XAttributeList > (new SvXMLAttributeList())); + { + /* Write X509IssuerSerial element */ + xDocumentHandler->startElement( + tag_X509IssuerSerial, + cssu::Reference< cssxs::XAttributeList > (new SvXMLAttributeList())); + { + /* Write X509IssuerName element */ + xDocumentHandler->startElement( + tag_X509IssuerName, + cssu::Reference< cssxs::XAttributeList > (new SvXMLAttributeList())); + xDocumentHandler->characters( signatureInfo.ouX509IssuerName ); + xDocumentHandler->endElement( tag_X509IssuerName ); + + /* Write X509SerialNumber element */ + xDocumentHandler->startElement( + tag_X509SerialNumber, + cssu::Reference< cssxs::XAttributeList > (new SvXMLAttributeList())); + xDocumentHandler->characters( signatureInfo.ouX509SerialNumber ); + xDocumentHandler->endElement( tag_X509SerialNumber ); + } + xDocumentHandler->endElement( tag_X509IssuerSerial ); + + /* Write X509Certificate element */ + if (signatureInfo.ouX509Certificate.getLength()>0) + { + xDocumentHandler->startElement( + tag_X509Certificate, + cssu::Reference< cssxs::XAttributeList > (new SvXMLAttributeList())); + xDocumentHandler->characters( signatureInfo.ouX509Certificate ); + xDocumentHandler->endElement( tag_X509Certificate ); + } + } + xDocumentHandler->endElement( tag_X509Data ); + } + xDocumentHandler->endElement( tag_KeyInfo ); + + if (signatureInfo.ouDate.getLength()>0 ||signatureInfo.ouTime.getLength()>0) + { + /* Write Object element */ + xDocumentHandler->startElement( + tag_Object, + cssu::Reference< cssxs::XAttributeList > (new SvXMLAttributeList())); + { + /* Write SignatureProperties element */ + xDocumentHandler->startElement( + tag_SignatureProperties, + cssu::Reference< cssxs::XAttributeList > (new SvXMLAttributeList())); + { + /* Write SignatureProperty element */ + pAttributeList = new SvXMLAttributeList(); + pAttributeList->AddAttribute( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(ATTR_ID)), + signatureInfo.ouPropertyId); + pAttributeList->AddAttribute( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(ATTR_TARGET)), + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(CHAR_FRAGMENT))+signatureInfo.ouSignatureId); + xDocumentHandler->startElement( + tag_SignatureProperty, + cssu::Reference< cssxs::XAttributeList > (pAttributeList)); + { + /* Write timestamp element */ + pAttributeList = new SvXMLAttributeList(); + pAttributeList->AddAttribute( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(ATTR_XMLNS)), + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(NS_DATETIME))); + xDocumentHandler->startElement( + tag_Timestamp, + cssu::Reference< cssxs::XAttributeList > (pAttributeList)); + { + /* Write date element */ + xDocumentHandler->startElement( + tag_Date, + cssu::Reference< cssxs::XAttributeList > (new SvXMLAttributeList())); + xDocumentHandler->characters( signatureInfo.ouDate ); + xDocumentHandler->endElement( tag_Date ); + + /* Write time element */ + xDocumentHandler->startElement( + tag_Time, + cssu::Reference< cssxs::XAttributeList > (new SvXMLAttributeList())); + xDocumentHandler->characters( signatureInfo.ouTime ); + xDocumentHandler->endElement( tag_Time ); + } + xDocumentHandler->endElement( tag_Timestamp ); + } + xDocumentHandler->endElement( tag_SignatureProperty ); + } + xDocumentHandler->endElement( tag_SignatureProperties ); + } + xDocumentHandler->endElement( tag_Object ); + } + } + xDocumentHandler->endElement( tag_Signature ); +} + +bool XSecController::getSignatureInfor( sal_Int32 nSecurityId, SignatureInformation& signatureInfor ) +{ + int index = findSignatureInfor(nSecurityId); + if (index == -1) + { + return false; + } + else + { + signatureInfor = m_vInternalSignatureInformations[index].signatureInfor; + return true; + } +} + +SignatureInformations XSecController::getSignatureInformations() +{ + SignatureInformations vInfors; + int sigNum = m_vInternalSignatureInformations.size(); + + for (int i=0; i TRUE": + "Blocking Status => FALSE")), + rtl::OUString::createFromAscii("SAXEventKeeper Status")); + */ + + this->m_bIsBlocking = isBlocking; + checkChainingStatus(); +} + +void SAL_CALL XSecController::collectionStatusChanged( + sal_Bool isInsideCollectedElement ) + throw (cssu::RuntimeException) +{ + /* + showMessageBox( rtl::OUString::createFromAscii((isInsideCollectedElement? + "Collection Status => TRUE": + "Collection Status => FALSE")), + rtl::OUString::createFromAscii("SAXEventKeeper Status")); + */ + + this->m_bIsCollectingElement = isInsideCollectedElement; + checkChainingStatus(); +} + +void SAL_CALL XSecController::bufferStatusChanged( sal_Bool isBufferEmpty ) + throw (cssu::RuntimeException) +{ + /* + showMessageBox( rtl::OUString::createFromAscii((isBufferEmpty? + "Buffer Empty => TRUE": + "Buffer Empty => FALSE")), + rtl::OUString::createFromAscii("SAXEventKeeper Status")); + */ +} + +/* + * XSignatureCreationResultListener + */ +void SAL_CALL XSecController::signatureCreated( sal_Int32 securityId, com::sun::star::xml::crypto::sax::SignatureCreationResult nResult ) + throw (com::sun::star::uno::RuntimeException) +{ + int index = findSignatureInfor(securityId); + DBG_ASSERT( index != -1, "Signature Not Found!" ); + + SignatureInformation& signatureInfor = m_vInternalSignatureInformations[index].signatureInfor; + + if (nResult == cssxc::sax::SignatureCreationResult_CREATIONSUCCEED) + { + signatureInfor.nStatus = STATUS_CREATION_SUCCEED; + } + else + { + signatureInfor.nStatus = STATUS_CREATION_FAIL; + } +} + +/* + * XSignatureVerifyResultListener + */ +void SAL_CALL XSecController::signatureVerified( sal_Int32 securityId, com::sun::star::xml::crypto::sax::SignatureVerifyResult nResult ) + throw (com::sun::star::uno::RuntimeException) +{ + int index = findSignatureInfor(securityId); + DBG_ASSERT( index != -1, "Signature Not Found!" ); + + SignatureInformation& signatureInfor = m_vInternalSignatureInformations[index].signatureInfor; + + if (nResult == cssxc::sax::SignatureVerifyResult_VERIFYSUCCEED) + { + signatureInfor.nStatus = STATUS_VERIFY_SUCCEED; + } + else + { + signatureInfor.nStatus = STATUS_VERIFY_FAIL; + } +} diff --git a/xmlsecurity/source/helper/xsecctl.hxx b/xmlsecurity/source/helper/xsecctl.hxx new file mode 100644 index 000000000000..7d3a939f93af --- /dev/null +++ b/xmlsecurity/source/helper/xsecctl.hxx @@ -0,0 +1,580 @@ +/************************************************************************* + * + * $RCSfile: xsecctl.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:22 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _XSEC_CTL_HXX +#define _XSEC_CTL_HXX + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#ifndef INCLUDED_VECTOR +#include +#define INCLUDED_VECTOR +#endif + +/* + * all error information + */ +#define ERROR_CANNOTCREATEXMLSECURITYCOMPONENT "Can't create XML security components." +#define ERROR_SAXEXCEPTIONDURINGCREATION "A SAX exception is throwed during signature creation." +#define ERROR_IOEXCEPTIONDURINGCREATION "An IO exception is throwed during signature creation." +#define ERROR_EXCEPTIONDURINGCREATION "An exception is throwed during signature creation." + +/* + * all stringS in signature element + */ +#define TAG_SIGNATURE "Signature" +#define TAG_SIGNEDINFO "SignedInfo" +#define TAG_CANONICALIZATIONMETHOD "CanonicalizationMethod" +#define TAG_SIGNATUREMETHOD "SignatureMethod" +#define TAG_REFERENCE "Reference" +#define TAG_TRANSFORMS "Transforms" +#define TAG_TRANSFORM "Transform" +#define TAG_DIGESTMETHOD "DigestMethod" +#define TAG_DIGESTVALUE "DigestValue" +#define TAG_SIGNATUREVALUE "SignatureValue" +#define TAG_KEYINFO "KeyInfo" +#define TAG_X509DATA "X509Data" +#define TAG_X509ISSUERSERIAL "X509IssuerSerial" +#define TAG_X509ISSUERNAME "X509IssuerName" +#define TAG_X509SERIALNUMBER "X509SerialNumber" +#define TAG_X509CERTIFICATE "X509Certificate" +#define TAG_OBJECT "Object" +#define TAG_SIGNATUREPROPERTIES "SignatureProperties" +#define TAG_SIGNATUREPROPERTY "SignatureProperty" +#define TAG_TIMESTAMP "timestamp" +#define TAG_DATE "date" +#define TAG_TIME "time" + +#define ATTR_XMLNS "xmlns" +#define ATTR_ALGORITHM "Algorithm" +#define ATTR_URI "URI" +#define ATTR_ID "Id" +#define ATTR_TARGET "Target" + +#define NS_XMLDSIG "http://www.w3.org/2000/09/xmldsig#" +#define NS_DATETIME "http://www.ietf.org/rfcXXXX.txt" + +#define ALGO_C14N "http://www.w3.org/TR/2001/REC-xml-c14n-20010315" +#define ALGO_RSASHA1 "http://www.w3.org/2000/09/xmldsig#rsa-sha1" +#define ALGO_XMLDSIGSHA1 "http://www.w3.org/2000/09/xmldsig#sha1" + +#define CHAR_FRAGMENT "#" +#define CHAR_BLANK " " + + +/* + * status of security related components + */ +#define UNINITIALIZED 0 +#define INITIALIZED 1 +#define FAILTOINITIALIZED 2 + +#define RTL_ASCII_USTRINGPARAM( asciiStr ) asciiStr, strlen( asciiStr ), RTL_TEXTENCODING_ASCII_US + +class InternalSignatureInformation +{ +public: + SignatureInformation signatureInfor; + + com::sun::star::uno::Reference< + com::sun::star::xml::crypto::sax::XReferenceResolvedListener > + xReferenceResolvedListener; + + ::std::vector< sal_Int32 > vKeeperIds; + + InternalSignatureInformation( + sal_Int32 nId, + com::sun::star::uno::Reference< com::sun::star::xml::crypto::sax::XReferenceResolvedListener > + xListener) + :signatureInfor(nId) + { + xReferenceResolvedListener = xListener; + } + + void addReference( sal_Int32 type, rtl::OUString uri, sal_Int32 keeperId ) + { + signatureInfor.vSignatureReferenceInfors.push_back( + SignatureReferenceInformation(type, uri)); + vKeeperIds.push_back( keeperId ); + } +}; + +typedef ::std::vector< InternalSignatureInformation > InternalSignatureInformations; + +class XSecController : public cppu::WeakImplHelper4 +< + com::sun::star::xml::crypto::sax::XSecurityController, + //com::sun::star::beans::XFastPropertySet, + com::sun::star::xml::crypto::sax::XSAXEventKeeperStatusChangeListener, + com::sun::star::xml::crypto::sax::XSignatureCreationResultListener, + com::sun::star::xml::crypto::sax::XSignatureVerifyResultListener +> +/****** XSecController.hxx/CLASS XSecController ******************************* + * + * NAME + * XSecController -- the xml security framework controller + * + * FUNCTION + * Controlls the whole xml security framework to create signatures or to + * verify signatures. + * + * HISTORY + * 05.01.2004 - Interface supported: XSecurityController, + * XFastPropertySet, XSAXEventKeeperStatusChangeListener, + * XSignatureCreationResultListener, + * XSignatureVerifyResultListener + * + * NOTES + * The XFastPropertySet interface is used to transfer common values to + * classes in other module, for instance, the signature id for all + * sessions is transferred to xmloff module through this interface. + * + * AUTHOR + * Michael Mi + * Email: michael.mi@sun.com + ******************************************************************************/ +{ + friend class XSecParser; + +private: + com::sun::star::uno::Reference< + com::sun::star::lang::XMultiServiceFactory> mxMSF; + + /* + * used to buffer SAX events + */ + com::sun::star::uno::Reference< + com::sun::star::xml::wrapper::XXMLDocumentWrapper > m_xXMLDocumentWrapper; + + /* + * the SAX events keeper + */ + com::sun::star::uno::Reference< + com::sun::star::xml::crypto::sax::XSecuritySAXEventKeeper > m_xSAXEventKeeper; + + /* + * the bridge component which creates/verifies signature + */ + com::sun::star::uno::Reference< + com::sun::star::xml::crypto::XXMLSignature > m_xXMLSignature; + + /* + * the Security Context + */ + com::sun::star::uno::Reference< + com::sun::star::xml::crypto::XXMLSecurityContext > m_xSecurityContext; + +#if 0 + /* + * the signature creation result listener + */ + com::sun::star::uno::Reference< + com::sun::star::xml::crypto::sax::XSignatureCreationResultListener > m_xSignatureCreationResultListener; + /* + * the signature verify result listener + */ + com::sun::star::uno::Reference< + com::sun::star::xml::crypto::sax::XSignatureVerifyResultListener > m_xSignatureVerifyResultListener; +#endif + + /* + * the security id incrementer, in order to make any security id unique + * to the SAXEventKeeper. + * Because each XSecController has its own SAXEventKeeper, so this variable + * is not necessary to be static. + */ + sal_Int32 m_nNextSecurityId; + + /* + * Signature information + */ + InternalSignatureInformations m_vInternalSignatureInformations; + + /* + * the previous node on the SAX chain. + * The reason that use a Reference type variable + * is that the previous components are different when exporting + * and importing, and there is no other common interface they + * can provided. + */ + com::sun::star::uno::Reference< + com::sun::star::uno::XInterface > m_xPreviousNodeOnSAXChain; + /* + * whether the preivous node can provide an XInitiazlize interface, + * use this variable in order to typecast the XInterface to the + * correct interface type. + */ + bool m_bIsPreviousNodeInitializable; + + /* + * the next node on the SAX chain. + * it can always provide an XDocumentHandler interface. + */ + com::sun::star::uno::Reference< + com::sun::star::xml::sax::XDocumentHandler > m_xNextNodeOnSAXChain; + + /* + * the ElementStackKeeper is used to reserve the key SAX events. + * when the SAXEventKeeper is chained on the SAX chain, it need + * first get all missed key SAX events in order to make sure the + * DOM tree it buffering has the same structure with the original + * document. + * + * For a given section of a SAX event stream, the key SAX events + * are the minimal SAX event subset of that section, which, + * combining with SAX events outside of this section, has the same + * structure with the original document. + * + * For example, sees the following dom fragment: + * + * + * + * + * + * + * + * + * + * If we consider the SAX event section from startElement() to + * startElement(), then the key SAX events are: + * + * startElement(), startElement(), startElement() + * + * The startElement() and endElement() is ignored, because + * they are unimportant for the tree structure in this section. + * + * If we consider the SAX event section from startElement() to + * endElement(), the key SAX events are: + * + * startElement(), endElement(), endElement(), + * endElement(). + */ + com::sun::star::uno::Reference< + com::sun::star::xml::crypto::sax::XElementStackKeeper > m_xElementStackKeeper; + + /* + * a flag representing whether the SAXEventKeeper is now on the + * SAX chain. + */ + bool m_bIsSAXEventKeeperConnected; + + /* + * a flag representing whether it is collecting some element, + * which means that the SAXEventKeeper can't be chained off the + * SAX chain. + */ + bool m_bIsCollectingElement; + + /* + * a flag representing whether the SAX event stream is blocking, + * which also means that the SAXEventKeeper can't be chained off + * the SAX chain. + */ + bool m_bIsBlocking; + + /* + * a flag representing the current status of security related + * components. + */ + sal_Int32 m_nStatusOfSecurityComponents; + + /* + * a flag representing whether the SAXEventKeeper need to be + * on the SAX chain all the time. + * This flag is used to the situation when creating signature. + */ + bool m_bIsSAXEventKeeperSticky; + + /* + * fast property vector + */ + std::vector< sal_Int32 > m_vFastPropertyIndexs; + std::vector< com::sun::star::uno::Any > m_vFastPropertyValues; + + /* + * error message pointer + */ + const char *m_pErrorMessage; + + /* + * the XSecParser which is used to parse the signature stream + */ + XSecParser *m_pXSecParser; + + /* + * the caller assigned signature id for the next signature in the + * signature stream + */ + sal_Int32 m_nReservedSignatureId; + + /* + * representing whether to verify the current signature + */ + bool m_bVerifyCurrentSignature; +public: + /* + * An xUriBinding is provided to map Uris to XInputStream interfaces. + */ + com::sun::star::uno::Reference< + com::sun::star::xml::crypto::XUriBinding > m_xUriBinding; + +private: + + /* + * Common methods + */ + void createXSecComponent( ); + int findSignatureInfor( sal_Int32 nSecurityId ); + bool chainOn( bool bRetrievingLastEvent ); + void chainOff(); + void checkChainingStatus(); + void initializeSAXChain(); + + com::sun::star::uno::Reference< + com::sun::star::io::XInputStream > getObjectInputStream( const rtl::OUString& objectURL ); + + //sal_Int32 getFastPropertyIndex(sal_Int32 nHandle) const; + + /* + * For signature generation + */ + rtl::OUString createId(); + com::sun::star::uno::Reference< + com::sun::star::xml::crypto::sax::XReferenceResolvedListener > prepareSignatureToWrite( + InternalSignatureInformation& signatureInfo ); + + /* + * For signature verification + */ + void addSignature(); + void addReference( const rtl::OUString& ouUri); + void addStreamReference( + const rtl::OUString& ouUri, + bool isBinary ); + void setReferenceCount() const; + + void setX509IssuerName( rtl::OUString& ouX509IssuerName ); + void setX509SerialNumber( rtl::OUString& ouX509SerialNumber ); + void setX509Certificate( rtl::OUString& ouX509Certificate ); + void setSignatureValue( rtl::OUString& ouSignatureValue ); + void setDigestValue( rtl::OUString& ouDigestValue ); + void setDate( rtl::OUString& ouDate ); + void setTime( rtl::OUString& ouTime ); + + com::sun::star::uno::Reference< + com::sun::star::xml::crypto::sax::XReferenceResolvedListener > prepareSignatureToRead( + sal_Int32 nSecurityId ); + +public: + XSecController(); + ~XSecController(); + + /* + * Common methods + */ + void setFactory( const com::sun::star::uno::Reference< + com::sun::star::lang::XMultiServiceFactory>& rxMSF); +#if 0 + void setSignatureCreationResultListener( const com::sun::star::uno::Reference< + com::sun::star::xml::crypto::sax::XSignatureCreationResultListener >& xSignatureCreationResultListener); + void setSignatureVerifyResultListener( const com::sun::star::uno::Reference< + com::sun::star::xml::crypto::sax::XSignatureVerifyResultListener >& xSignatureVerifyResultListener); +#endif + + sal_Int32 getNewSecurityId( ); + + void startMission( const com::sun::star::uno::Reference< + com::sun::star::xml::crypto::XUriBinding >& xUriBinding, + const com::sun::star::uno::Reference< + com::sun::star::xml::crypto::XXMLSecurityContext >& xSecurityContext ); + + void setSAXChainConnector( + const com::sun::star::uno::Reference< + com::sun::star::lang::XInitialization >& xInitialization, + const com::sun::star::uno::Reference< + com::sun::star::xml::sax::XDocumentHandler >& xDocumentHandler, + const com::sun::star::uno::Reference< + com::sun::star::xml::crypto::sax::XElementStackKeeper >& xElementStackKeeper); + + void setSAXChainConnector( + const com::sun::star::uno::Reference< + com::sun::star::xml::sax::XParser >& xParser, + const com::sun::star::uno::Reference< + com::sun::star::xml::sax::XDocumentHandler >& xDocumentHandler, + const com::sun::star::uno::Reference< + com::sun::star::xml::crypto::sax::XElementStackKeeper >& xElementStackKeeper); + + void clearSAXChainConnector(); + void endMission(); + const char* getErrorMessage(); + bool getSignatureInfor( sal_Int32 nSecurityId, SignatureInformation& signatureInfor ); + SignatureInformations getSignatureInformations(); + + void exportSignature( + const com::sun::star::uno::Reference< + com::sun::star::xml::sax::XDocumentHandler >& xDocumentHandler, + const SignatureInformation& signatureInfo ); + + + /* + * For signature generation + */ + void collectToSign( sal_Int32 securityId, const rtl::OUString& referenceId ); + void signAStream( sal_Int32 securityId, const rtl::OUString& uri, const rtl::OUString& objectURL, sal_Bool isBinary); + + void setX509Certificate( + sal_Int32 nSecurityId, + const rtl::OUString& ouX509IssuerName, + const rtl::OUString& ouX509SerialNumber); + + void setDateTime( + sal_Int32 nSecurityId, + const rtl::OUString& ouDate, + const rtl::OUString& ouTime); + + bool WriteSignatue( + const com::sun::star::uno::Reference< + com::sun::star::xml::sax::XDocumentHandler >& xDocumentHandler ); + + /* + * For signature verification + */ + void collectToVerify( const rtl::OUString& referenceId ); + void addSignature( sal_Int32 nSignatureId ); + com::sun::star::uno::Reference< com::sun::star::xml::sax::XDocumentHandler > createSignatureReader(); + void releaseSignatureReader(); + +public: + /* Interface methods */ + + /* + * XSecurityController + * + * no method in XSecurityController interface + */ + + /* + * XFastPropertySet + */ + /* + virtual void SAL_CALL setFastPropertyValue( + sal_Int32 nHandle, + const com::sun::star::uno::Any& aValue ) + throw ( + com::sun::star::beans::UnknownPropertyException, + com::sun::star::beans::PropertyVetoException, + com::sun::star::lang::IllegalArgumentException, + com::sun::star::lang::WrappedTargetException, + com::sun::star::uno::RuntimeException); + virtual com::sun::star::uno::Any SAL_CALL getFastPropertyValue( + sal_Int32 nHandle ) + throw ( + com::sun::star::beans::UnknownPropertyException, + com::sun::star::lang::WrappedTargetException, + com::sun::star::uno::RuntimeException); + */ + + /* + * XSAXEventKeeperStatusChangeListener + */ + virtual void SAL_CALL blockingStatusChanged( sal_Bool isBlocking ) + throw (com::sun::star::uno::RuntimeException); + virtual void SAL_CALL collectionStatusChanged( + sal_Bool isInsideCollectedElement ) + throw (com::sun::star::uno::RuntimeException); + virtual void SAL_CALL bufferStatusChanged( sal_Bool isBufferEmpty ) + throw (com::sun::star::uno::RuntimeException); + + /* + * XSignatureCreationResultListener + */ + virtual void SAL_CALL signatureCreated( sal_Int32 securityId, com::sun::star::xml::crypto::sax::SignatureCreationResult nResult ) + throw (com::sun::star::uno::RuntimeException); + + /* + * XSignatureVerifyResultListener + */ + virtual void SAL_CALL signatureVerified( sal_Int32 securityId, com::sun::star::xml::crypto::sax::SignatureVerifyResult nResult ) + throw (com::sun::star::uno::RuntimeException); +}; + +#endif + diff --git a/xmlsecurity/source/helper/xsecparser.cxx b/xmlsecurity/source/helper/xsecparser.cxx new file mode 100644 index 000000000000..8ad5a7f747cd --- /dev/null +++ b/xmlsecurity/source/helper/xsecparser.cxx @@ -0,0 +1,353 @@ +/************************************************************************* + * + * $RCSfile: xsecparser.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:22 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#include "xsecparser.hxx" + +#ifndef _TOOLS_DEBUG_HXX //autogen wg. DBG_ASSERT +#include +#endif + +namespace cssu = com::sun::star::uno; +namespace cssxs = com::sun::star::xml::sax; + +#define RTL_ASCII_USTRINGPARAM( asciiStr ) asciiStr, strlen( asciiStr ), RTL_TEXTENCODING_ASCII_US + +XSecParser::XSecParser( + XSecController* pXSecController, + const cssu::Reference< cssxs::XDocumentHandler >& xNextHandler ) + : m_pXSecController(pXSecController), + m_xNextHandler(xNextHandler), + m_bReferenceUnresolved(false) +{ +} + +rtl::OUString XSecParser::getIdAttr(const cssu::Reference< cssxs::XAttributeList >& xAttribs ) +{ + rtl::OUString ouIdAttr = xAttribs->getValueByName( + rtl::OUString(RTL_ASCII_USTRINGPARAM("id"))); + + if (ouIdAttr == NULL) + { + ouIdAttr = xAttribs->getValueByName( + rtl::OUString(RTL_ASCII_USTRINGPARAM("Id"))); + } + + return ouIdAttr; +} + +/* + * XDocumentHandler + */ +void SAL_CALL XSecParser::startDocument( ) + throw (cssxs::SAXException, cssu::RuntimeException) +{ + m_bInX509IssuerName = false; + m_bInX509SerialNumber = false; + m_bInX509Certificate = false; + m_bInSignatureValue = false; + m_bInDigestValue = false; + m_bInDate = false; + m_bInTime = false; + + if (m_xNextHandler.is()) + { + m_xNextHandler->startDocument(); + } +} + +void SAL_CALL XSecParser::endDocument( ) + throw (cssxs::SAXException, cssu::RuntimeException) +{ + if (m_xNextHandler.is()) + { + m_xNextHandler->endDocument(); + } +} + +void SAL_CALL XSecParser::startElement( + const rtl::OUString& aName, + const cssu::Reference< cssxs::XAttributeList >& xAttribs ) + throw (cssxs::SAXException, cssu::RuntimeException) +{ + rtl::OUString ouIdAttr = getIdAttr(xAttribs); + if (ouIdAttr != NULL) + { + m_pXSecController->collectToVerify( ouIdAttr ); + } + + if ( aName == rtl::OUString(RTL_ASCII_USTRINGPARAM(TAG_SIGNATURE)) ) + { + m_pXSecController->addSignature(); + } + else if ( aName == rtl::OUString(RTL_ASCII_USTRINGPARAM(TAG_REFERENCE)) ) + { + rtl::OUString ouUri = xAttribs->getValueByName(rtl::OUString(RTL_ASCII_USTRINGPARAM(ATTR_URI))); + DBG_ASSERT( ouUri != NULL, "URI == NULL" ); + + if (0 == ouUri.compareTo(rtl::OUString(RTL_ASCII_USTRINGPARAM(CHAR_FRAGMENT)),1)) + { + /* + * remove the first character '#' from the attribute value + */ + m_pXSecController->addReference( ouUri.copy(1) ); + } + else + { + /* + * remember the uri + */ + m_currentReferenceURI = ouUri; + m_bReferenceUnresolved = true; + } + } + else if (aName == rtl::OUString(RTL_ASCII_USTRINGPARAM(TAG_TRANSFORM))) + { + if ( m_bReferenceUnresolved ) + { + rtl::OUString ouAlgorithm = xAttribs->getValueByName(rtl::OUString(RTL_ASCII_USTRINGPARAM(ATTR_ALGORITHM))); + + if (ouAlgorithm != NULL && ouAlgorithm == rtl::OUString(RTL_ASCII_USTRINGPARAM(ALGO_C14N))) + /* + * a xml stream + */ + { + m_pXSecController->addStreamReference( m_currentReferenceURI, sal_False); + m_bReferenceUnresolved = false; + } + } + } + else if (aName == rtl::OUString(RTL_ASCII_USTRINGPARAM(TAG_X509ISSUERNAME))) + { + m_ouX509IssuerName = rtl::OUString::createFromAscii(""); + m_bInX509IssuerName = true; + } + else if (aName == rtl::OUString(RTL_ASCII_USTRINGPARAM(TAG_X509SERIALNUMBER))) + { + m_ouX509SerialNumber = rtl::OUString::createFromAscii(""); + m_bInX509SerialNumber = true; + } + else if (aName == rtl::OUString(RTL_ASCII_USTRINGPARAM(TAG_X509CERTIFICATE))) + { + m_ouX509Certificate = rtl::OUString::createFromAscii(""); + m_bInX509Certificate = true; + } + else if (aName == rtl::OUString(RTL_ASCII_USTRINGPARAM(TAG_SIGNATUREVALUE))) + { + m_ouSignatureValue = rtl::OUString::createFromAscii(""); + m_bInSignatureValue = true; + } + else if (aName == rtl::OUString(RTL_ASCII_USTRINGPARAM(TAG_DIGESTVALUE))) + { + m_ouDigestValue = rtl::OUString::createFromAscii(""); + m_bInDigestValue = true; + } + else if (aName == rtl::OUString(RTL_ASCII_USTRINGPARAM(TAG_DATE))) + { + m_ouDate = rtl::OUString::createFromAscii(""); + m_bInDate = true; + } + else if (aName == rtl::OUString(RTL_ASCII_USTRINGPARAM(TAG_TIME))) + { + m_ouTime = rtl::OUString::createFromAscii(""); + m_bInTime = true; + } + + if (m_xNextHandler.is()) + { + m_xNextHandler->startElement(aName, xAttribs); + } +} + +void SAL_CALL XSecParser::endElement( const rtl::OUString& aName ) + throw (cssxs::SAXException, cssu::RuntimeException) +{ + if (aName == rtl::OUString(RTL_ASCII_USTRINGPARAM(TAG_DIGESTVALUE))) + { + m_bInDigestValue = false; + } + else if ( aName == rtl::OUString(RTL_ASCII_USTRINGPARAM(TAG_REFERENCE)) ) + { + if ( m_bReferenceUnresolved ) + /* + * it must be a octet stream + */ + { + m_pXSecController->addStreamReference( m_currentReferenceURI, sal_True); + m_bReferenceUnresolved = false; + } + + m_pXSecController->setDigestValue( m_ouDigestValue ); + } + else if ( aName == rtl::OUString(RTL_ASCII_USTRINGPARAM(TAG_SIGNEDINFO)) ) + { + m_pXSecController->setReferenceCount(); + } + else if ( aName == rtl::OUString(RTL_ASCII_USTRINGPARAM(TAG_SIGNATUREVALUE)) ) + { + m_pXSecController->setSignatureValue( m_ouSignatureValue ); + m_bInSignatureValue = false; + } + else if (aName == rtl::OUString(RTL_ASCII_USTRINGPARAM(TAG_X509ISSUERNAME))) + { + m_pXSecController->setX509IssuerName( m_ouX509IssuerName ); + m_bInX509IssuerName = false; + } + else if (aName == rtl::OUString(RTL_ASCII_USTRINGPARAM(TAG_X509SERIALNUMBER))) + { + m_pXSecController->setX509SerialNumber( m_ouX509SerialNumber ); + m_bInX509SerialNumber = false; + } + else if (aName == rtl::OUString(RTL_ASCII_USTRINGPARAM(TAG_X509CERTIFICATE))) + { + m_pXSecController->setX509Certificate( m_ouX509Certificate ); + m_bInX509Certificate = false; + } + else if ( aName == rtl::OUString(RTL_ASCII_USTRINGPARAM(TAG_DATE)) ) + { + m_pXSecController->setDate( m_ouDate ); + m_bInDate = false; + } + else if ( aName == rtl::OUString(RTL_ASCII_USTRINGPARAM(TAG_TIME)) ) + { + m_pXSecController->setTime( m_ouTime ); + m_bInTime = false; + } + + if (m_xNextHandler.is()) + { + m_xNextHandler->endElement(aName); + } +} + +void SAL_CALL XSecParser::characters( const rtl::OUString& aChars ) + throw (cssxs::SAXException, cssu::RuntimeException) +{ + if (m_bInX509IssuerName) + { + m_ouX509IssuerName += aChars; + } + else if (m_bInX509SerialNumber) + { + m_ouX509SerialNumber += aChars; + } + else if (m_bInX509Certificate) + { + m_ouX509Certificate += aChars; + } + else if (m_bInSignatureValue) + { + m_ouSignatureValue += aChars; + } + else if (m_bInDigestValue) + { + m_ouDigestValue += aChars; + } + else if (m_bInDate) + { + m_ouDate += aChars; + } + else if (m_bInTime) + { + m_ouTime += aChars; + } + + if (m_xNextHandler.is()) + { + m_xNextHandler->characters(aChars); + } +} + +void SAL_CALL XSecParser::ignorableWhitespace( const rtl::OUString& aWhitespaces ) + throw (cssxs::SAXException, cssu::RuntimeException) +{ + if (m_xNextHandler.is()) + { + m_xNextHandler->ignorableWhitespace( aWhitespaces ); + } +} + +void SAL_CALL XSecParser::processingInstruction( const rtl::OUString& aTarget, const rtl::OUString& aData ) + throw (cssxs::SAXException, cssu::RuntimeException) +{ + if (m_xNextHandler.is()) + { + m_xNextHandler->processingInstruction(aTarget, aData); + } +} + +void SAL_CALL XSecParser::setDocumentLocator( const cssu::Reference< cssxs::XLocator >& xLocator ) + throw (cssxs::SAXException, cssu::RuntimeException) +{ + if (m_xNextHandler.is()) + { + m_xNextHandler->setDocumentLocator( xLocator ); + } +} + +/* + * XInitialization + */ +void SAL_CALL XSecParser::initialize( + const cssu::Sequence< cssu::Any >& aArguments ) + throw(cssu::Exception, cssu::RuntimeException) +{ + aArguments[0] >>= m_xNextHandler; +} diff --git a/xmlsecurity/source/helper/xsecparser.hxx b/xmlsecurity/source/helper/xsecparser.hxx new file mode 100644 index 000000000000..da2b765a7ad6 --- /dev/null +++ b/xmlsecurity/source/helper/xsecparser.hxx @@ -0,0 +1,199 @@ +/************************************************************************* + * + * $RCSfile: xsecparser.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:22 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _XSEC_CTL_PARSER_HXX +#define _XSEC_CTL_PARSER_HXX + +#include + +#include +#include +#include +#include + +#include + +class XSecParser: public cppu::WeakImplHelper2 +< + com::sun::star::xml::sax::XDocumentHandler, + com::sun::star::lang::XInitialization +> +/****** XSecController.hxx/CLASS XSecParser *********************************** + * + * NAME + * XSecParser -- a SAX parser that can detect security elements + * + * FUNCTION + * The XSecParser object is connected on the SAX chain and detects + * security elements in the SAX event stream, then notifies + * the XSecController. + * + * HISTORY + * 05.01.2004 - Interface supported: XDocumentHandler, XInitialization + * + * NOTES + * This class is used when importing a document. + * + * AUTHOR + * Michael Mi + * Email: michael.mi@sun.com + ******************************************************************************/ +{ + friend class XSecController; +private: + /* + * the following members are used to reserve the signature information, + * including X509IssuerName, X509SerialNumber, and X509Certificate,etc. + */ + rtl::OUString m_ouX509IssuerName; + rtl::OUString m_ouX509SerialNumber; + rtl::OUString m_ouX509Certificate; + rtl::OUString m_ouDigestValue; + rtl::OUString m_ouSignatureValue; + rtl::OUString m_ouDate; + rtl::OUString m_ouTime; + + /* + * whether inside a particular element + */ + bool m_bInX509IssuerName; + bool m_bInX509SerialNumber; + bool m_bInX509Certificate; + bool m_bInDigestValue; + bool m_bInSignatureValue; + bool m_bInDate; + bool m_bInTime; + + /* + * the XSecController collaborating with XSecParser + */ + XSecController* m_pXSecController; + + /* + * the next XDocumentHandler on the SAX chain + */ + com::sun::star::uno::Reference< + com::sun::star::xml::sax::XDocumentHandler > m_xNextHandler; + + /* + * this string is used to remember the current handled reference's URI, + * + * because it can be decided whether a stream reference is xml based or binary based + * only after the Transforms element is read in, so we have to reserve the reference's + * URI when the startElement event is met. + */ + rtl::OUString m_currentReferenceURI; + bool m_bReferenceUnresolved; + +private: + rtl::OUString getIdAttr(const com::sun::star::uno::Reference< + com::sun::star::xml::sax::XAttributeList >& xAttribs ); + +public: + XSecParser( XSecController* pXSecController, + const com::sun::star::uno::Reference< + com::sun::star::xml::sax::XDocumentHandler >& xNextHandler ); + ~XSecParser(){}; + + /* + * XDocumentHandler + */ + virtual void SAL_CALL startDocument( ) + throw (com::sun::star::xml::sax::SAXException, com::sun::star::uno::RuntimeException); + + virtual void SAL_CALL endDocument( ) + throw (com::sun::star::xml::sax::SAXException, com::sun::star::uno::RuntimeException); + + virtual void SAL_CALL startElement( + const rtl::OUString& aName, + const com::sun::star::uno::Reference< + com::sun::star::xml::sax::XAttributeList >& xAttribs ) + throw (com::sun::star::xml::sax::SAXException, com::sun::star::uno::RuntimeException); + + virtual void SAL_CALL endElement( const rtl::OUString& aName ) + throw (com::sun::star::xml::sax::SAXException, com::sun::star::uno::RuntimeException); + + virtual void SAL_CALL characters( const rtl::OUString& aChars ) + throw (com::sun::star::xml::sax::SAXException, com::sun::star::uno::RuntimeException); + + virtual void SAL_CALL ignorableWhitespace( const rtl::OUString& aWhitespaces ) + throw (com::sun::star::xml::sax::SAXException, com::sun::star::uno::RuntimeException); + + virtual void SAL_CALL processingInstruction( + const rtl::OUString& aTarget, + const rtl::OUString& aData ) + throw (com::sun::star::xml::sax::SAXException, com::sun::star::uno::RuntimeException); + + virtual void SAL_CALL setDocumentLocator( + const com::sun::star::uno::Reference< + com::sun::star::xml::sax::XLocator >& xLocator ) + throw (com::sun::star::xml::sax::SAXException, com::sun::star::uno::RuntimeException); + + /* + * XInitialization + */ + virtual void SAL_CALL initialize( + const com::sun::star::uno::Sequence< com::sun::star::uno::Any >& aArguments ) + throw(com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException); +}; + +#endif + diff --git a/xmlsecurity/source/helper/xsecsign.cxx b/xmlsecurity/source/helper/xsecsign.cxx new file mode 100644 index 000000000000..8b5bfaa1653e --- /dev/null +++ b/xmlsecurity/source/helper/xsecsign.cxx @@ -0,0 +1,394 @@ +/************************************************************************* + * + * $RCSfile: xsecsign.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:22 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#include + +#ifndef _TOOLS_DEBUG_HXX //autogen wg. DBG_ASSERT +#include +#endif + +#include +#include +#include +#include +#include +#include +#include + +#ifndef _RTL_UUID_H_ +#include +#endif + +#include + +namespace cssu = com::sun::star::uno; +namespace cssl = com::sun::star::lang; +namespace cssxc = com::sun::star::xml::crypto; +namespace cssxs = com::sun::star::xml::sax; + +/* xml security framework components */ +#define SIGNATURECREATOR_COMPONENT "com.sun.star.xml.crypto.sax.SignatureCreator" + +/* protected: for signature generation */ +rtl::OUString XSecController::createId() +{ + cssu::Sequence< sal_Int8 > aSeq( 16 ); + rtl_createUuid ((sal_uInt8 *)aSeq.getArray(), 0, sal_True); + + char str[68]="ID_"; + int length = 3; + for (int i=0; i<16; ++i) + { + length += sprintf(str+length, "%04x", (unsigned char)aSeq[i]); + } + + return rtl::OUString::createFromAscii(str); +} + +cssu::Reference< cssxc::sax::XReferenceResolvedListener > XSecController::prepareSignatureToWrite( + InternalSignatureInformation& internalSignatureInfor ) +{ + sal_Int32 nSecurityId = internalSignatureInfor.signatureInfor.nSecurityId; + SignatureReferenceInformations& vReferenceInfors = internalSignatureInfor.signatureInfor.vSignatureReferenceInfors; + + sal_Int32 nIdOfSignatureElementCollector; + cssu::Reference< cssxc::sax::XReferenceResolvedListener > xReferenceResolvedListener; + + nIdOfSignatureElementCollector = + m_xSAXEventKeeper->addSecurityElementCollector( cssxc::sax::ElementMarkPriority_PRI_AFTERMODIFY, sal_True ); + + m_xSAXEventKeeper->setSecurityId(nIdOfSignatureElementCollector, nSecurityId); + + /* + * create a SignatureCreator + */ + xReferenceResolvedListener = cssu::Reference< cssxc::sax::XReferenceResolvedListener >( + mxMSF->createInstance( + rtl::OUString::createFromAscii(SIGNATURECREATOR_COMPONENT)), + cssu::UNO_QUERY); + + cssu::Reference xInitialization(xReferenceResolvedListener, cssu::UNO_QUERY); + + cssu::Sequence args(5); + args[0] = cssu::makeAny(rtl::OUString::valueOf(nSecurityId)); + args[1] = cssu::makeAny(m_xSAXEventKeeper); + args[2] = cssu::makeAny(rtl::OUString::valueOf(nIdOfSignatureElementCollector)); + args[3] = cssu::makeAny(m_xSecurityContext); + args[4] = cssu::makeAny(m_xXMLSignature); + xInitialization->initialize(args); + + sal_Int32 nBlockerId = m_xSAXEventKeeper->addBlocker(); + m_xSAXEventKeeper->setSecurityId(nBlockerId, nSecurityId); + + cssu::Reference xBlockerMonitor(xReferenceResolvedListener, cssu::UNO_QUERY); + xBlockerMonitor->setBlockerId(nBlockerId); + + cssu::Reference< cssxc::sax::XSignatureCreationResultBroadcaster > + xSignatureCreationResultBroadcaster(xReferenceResolvedListener, cssu::UNO_QUERY); + + xSignatureCreationResultBroadcaster->addSignatureCreationResultListener( this ); + + cssu::Reference + xReferenceResolvedBroadcaster + (m_xSAXEventKeeper, + cssu::UNO_QUERY); + + xReferenceResolvedBroadcaster->addReferenceResolvedListener( + nIdOfSignatureElementCollector, + xReferenceResolvedListener); + + cssu::Reference xReferenceCollector + (xReferenceResolvedListener, cssu::UNO_QUERY); + + int i; + int size = vReferenceInfors.size(); + sal_Int32 nReferenceCount = 0; + + for(i=0; isetSecurityId(keeperId, nSecurityId); + xReferenceResolvedBroadcaster->addReferenceResolvedListener( keeperId, xReferenceResolvedListener); + xReferenceCollector->setReferenceId( keeperId ); + nReferenceCount++; + } + } + + xReferenceCollector->setReferenceCount( nReferenceCount ); + + /* + * adds all URI binding + */ + cssu::Reference xUriBinding + (xReferenceResolvedListener, cssu::UNO_QUERY); + + for(i=0; i xInputStream + = getObjectInputStream( refInfor.ouURI ); + + if (xInputStream.is()) + { + xUriBinding->setUriBinding(refInfor.ouURI,xInputStream); + } + } + + cssu::Reference keyCollector (xReferenceResolvedListener, cssu::UNO_QUERY); + keyCollector->setKeyId(0); + + if (internalSignatureInfor.signatureInfor.ouDate.getLength()>0 ||internalSignatureInfor.signatureInfor.ouTime.getLength()>0) + /* + * add a reference to datatime property, this reference is transparent to the xmlsecurity + * framework + */ + { + internalSignatureInfor.signatureInfor.ouSignatureId = createId(); + internalSignatureInfor.signatureInfor.ouPropertyId = createId(); + internalSignatureInfor.addReference(1, internalSignatureInfor.signatureInfor.ouPropertyId, -1 ); + size++; + } + + /* + * replace both digestValues and signatueValue to " " + */ + for(i=0; iaddSecurityElementCollector( + cssxc::sax::ElementMarkPriority_PRI_AFTERMODIFY, sal_False); + + int index = findSignatureInfor( securityId ); + + if ( index == -1 ) + { + InternalSignatureInformation isi(securityId, NULL); + isi.addReference(1, referenceId, nKeeperId ); + m_vInternalSignatureInformations.push_back( isi ); + } + else + { + m_vInternalSignatureInformations[index].addReference(1, referenceId, nKeeperId ); + } + } +} + +void XSecController::signAStream( sal_Int32 securityId, const rtl::OUString& uri, const rtl::OUString& objectURL, sal_Bool isBinary) +{ + sal_Int32 type = ((isBinary==sal_True)?2:3); + + int index = findSignatureInfor( securityId ); + + if (index == -1) + { + InternalSignatureInformation isi(securityId, NULL); + isi.addReference(type, uri, -1); + m_vInternalSignatureInformations.push_back( isi ); + } + else + { + m_vInternalSignatureInformations[index].addReference(type, uri, -1); + } +} + +void XSecController::setX509Certificate( + sal_Int32 nSecurityId, + const rtl::OUString& ouX509IssuerName, + const rtl::OUString& ouX509SerialNumber) +{ + int index = findSignatureInfor( nSecurityId ); + + if ( index == -1 ) + { + InternalSignatureInformation isi(nSecurityId, NULL); + isi.signatureInfor.ouX509IssuerName = ouX509IssuerName; + isi.signatureInfor.ouX509SerialNumber = ouX509SerialNumber; + m_vInternalSignatureInformations.push_back( isi ); + } + else + { + SignatureInformation &si + = m_vInternalSignatureInformations[index].signatureInfor; + si.ouX509IssuerName = ouX509IssuerName; + si.ouX509SerialNumber = ouX509SerialNumber; + } +} + +void XSecController::setDateTime( + sal_Int32 nSecurityId, + const rtl::OUString& ouDate, + const rtl::OUString& ouTime) +{ + int index = findSignatureInfor( nSecurityId ); + + if ( index == -1 ) + { + InternalSignatureInformation isi(nSecurityId, NULL); + isi.signatureInfor.ouDate = ouDate; + isi.signatureInfor.ouTime = ouTime; + m_vInternalSignatureInformations.push_back( isi ); + } + else + { + SignatureInformation &si + = m_vInternalSignatureInformations[index].signatureInfor; + si.ouDate = ouDate; + si.ouTime = ouTime; + } +} + +bool XSecController::WriteSignatue( + const cssu::Reference& xDocumentHandler ) +{ + bool rc = false; + + DBG_ASSERT( xDocumentHandler.is(), "I really need a document handler!" ); + + /* + * chain the SAXEventKeeper to the SAX chain + */ + chainOn(true); + + if ( m_nStatusOfSecurityComponents == INITIALIZED ) + /* + * if all security components are ready, add the signature + * stream. + */ + { + m_bIsSAXEventKeeperSticky = true; + m_xSAXEventKeeper->setNextHandler(xDocumentHandler); + + try + { + /* + * export the signature template + */ + cssu::Reference xSEKHandler( m_xSAXEventKeeper,cssu::UNO_QUERY); + + int i; + int sigNum = m_vInternalSignatureInformations.size(); + + for (i=0; isetNextHandler( NULL ); + m_bIsSAXEventKeeperSticky = false; + } + else + { + m_pErrorMessage = ERROR_CANNOTCREATEXMLSECURITYCOMPONENT; + } + + return rc; +} + diff --git a/xmlsecurity/source/helper/xsecverify.cxx b/xmlsecurity/source/helper/xsecverify.cxx new file mode 100644 index 000000000000..9faf78c864c0 --- /dev/null +++ b/xmlsecurity/source/helper/xsecverify.cxx @@ -0,0 +1,349 @@ +/************************************************************************* + * + * $RCSfile: xsecverify.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:22 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#include +#include "xsecparser.hxx" + +#ifndef _TOOLS_DEBUG_HXX //autogen wg. DBG_ASSERT +#include +#endif + +#include +#include +#include +#include +#include +#include + +namespace cssu = com::sun::star::uno; +namespace cssl = com::sun::star::lang; +namespace cssxc = com::sun::star::xml::crypto; +namespace cssxs = com::sun::star::xml::sax; + +/* xml security framework components */ +#define SIGNATUREVERIFIER_COMPONENT "com.sun.star.xml.crypto.sax.SignatureVerifier" + +/* protected: for signature verify */ +cssu::Reference< cssxc::sax::XReferenceResolvedListener > XSecController::prepareSignatureToRead( + sal_Int32 nSecurityId) +{ + if ( m_nStatusOfSecurityComponents != INITIALIZED ) + { + return NULL; + } + + sal_Int32 nIdOfSignatureElementCollector; + cssu::Reference< cssxc::sax::XReferenceResolvedListener > xReferenceResolvedListener; + + nIdOfSignatureElementCollector = + m_xSAXEventKeeper->addSecurityElementCollector( cssxc::sax::ElementMarkPriority_PRI_BEFOREMODIFY, sal_False); + + m_xSAXEventKeeper->setSecurityId(nIdOfSignatureElementCollector, nSecurityId); + + /* + * create a SignatureVerifier + */ + xReferenceResolvedListener = cssu::Reference< cssxc::sax::XReferenceResolvedListener >( + mxMSF->createInstance( + rtl::OUString::createFromAscii( SIGNATUREVERIFIER_COMPONENT )), + cssu::UNO_QUERY); + + cssu::Reference xInitialization(xReferenceResolvedListener, cssu::UNO_QUERY); + + cssu::Sequence args(5); + args[0] = cssu::makeAny(rtl::OUString::valueOf(nSecurityId)); + args[1] = cssu::makeAny(m_xSAXEventKeeper); + args[2] = cssu::makeAny(rtl::OUString::valueOf(nIdOfSignatureElementCollector)); + args[3] = cssu::makeAny(m_xSecurityContext); + args[4] = cssu::makeAny(m_xXMLSignature); + xInitialization->initialize(args); + + cssu::Reference< cssxc::sax::XSignatureVerifyResultBroadcaster > + signatureVerifyResultBroadcaster(xReferenceResolvedListener, cssu::UNO_QUERY); + + signatureVerifyResultBroadcaster->addSignatureVerifyResultListener( this ); + + cssu::Reference xReferenceResolvedBroadcaster + (m_xSAXEventKeeper, + cssu::UNO_QUERY); + + xReferenceResolvedBroadcaster->addReferenceResolvedListener( + nIdOfSignatureElementCollector, + xReferenceResolvedListener); + + cssu::Reference keyCollector (xReferenceResolvedListener, cssu::UNO_QUERY); + keyCollector->setKeyId(0); + + return xReferenceResolvedListener; +} + +void XSecController::addSignature() +{ + cssu::Reference< cssxc::sax::XReferenceResolvedListener > xReferenceResolvedListener = NULL; + sal_Int32 nSignatureId = 0; + + + if (m_bVerifyCurrentSignature) + { + chainOn(true); + xReferenceResolvedListener = prepareSignatureToRead( m_nReservedSignatureId ); + m_bVerifyCurrentSignature = false; + nSignatureId = m_nReservedSignatureId; + } + + InternalSignatureInformation isi( nSignatureId, xReferenceResolvedListener ); + m_vInternalSignatureInformations.push_back( isi ); +} + +void XSecController::addReference( const rtl::OUString& ouUri) +{ + InternalSignatureInformation &isi = m_vInternalSignatureInformations[m_vInternalSignatureInformations.size()-1]; + isi.addReference(1,ouUri, -1 ); +} + +void XSecController::addStreamReference( + const rtl::OUString& ouUri, + bool isBinary ) +{ + sal_Int32 type = (isBinary?2:3); + + InternalSignatureInformation &isi = m_vInternalSignatureInformations[m_vInternalSignatureInformations.size()-1]; + + if ( isi.xReferenceResolvedListener.is() ) + { + /* + * get the input stream + */ + cssu::Reference< com::sun::star::io::XInputStream > xObjectInputStream + = getObjectInputStream( ouUri ); + + if ( xObjectInputStream.is() ) + { + cssu::Reference xUriBinding + (isi.xReferenceResolvedListener, cssu::UNO_QUERY); + xUriBinding->setUriBinding(ouUri, xObjectInputStream); + } + } + + isi.addReference(type, ouUri, -1); +} + +void XSecController::setReferenceCount() const +{ + const InternalSignatureInformation &isi = m_vInternalSignatureInformations[m_vInternalSignatureInformations.size()-1]; + + if ( isi.xReferenceResolvedListener.is() ) + { + const SignatureReferenceInformations &refInfors = isi.signatureInfor.vSignatureReferenceInfors; + + int refNum = refInfors.size(); + sal_Int32 referenceCount = 0; + + for(int i=0 ; i xReferenceCollector + (isi.xReferenceResolvedListener, cssu::UNO_QUERY); + xReferenceCollector->setReferenceCount( referenceCount ); + } +} + +void XSecController::setX509IssuerName( rtl::OUString& ouX509IssuerName ) +{ + InternalSignatureInformation &isi = m_vInternalSignatureInformations[m_vInternalSignatureInformations.size()-1]; + isi.signatureInfor.ouX509IssuerName = ouX509IssuerName; +} + +void XSecController::setX509SerialNumber( rtl::OUString& ouX509SerialNumber ) +{ + InternalSignatureInformation &isi = m_vInternalSignatureInformations[m_vInternalSignatureInformations.size()-1]; + isi.signatureInfor.ouX509SerialNumber = ouX509SerialNumber; +} + +void XSecController::setX509Certificate( rtl::OUString& ouX509Certificate ) +{ + InternalSignatureInformation &isi = m_vInternalSignatureInformations[m_vInternalSignatureInformations.size()-1]; + isi.signatureInfor.ouX509Certificate = ouX509Certificate; +} + +void XSecController::setSignatureValue( rtl::OUString& ouSignatureValue ) +{ + InternalSignatureInformation &isi = m_vInternalSignatureInformations[m_vInternalSignatureInformations.size()-1]; + isi.signatureInfor.ouSignatureValue = ouSignatureValue; +} + +void XSecController::setDigestValue( rtl::OUString& ouDigestValue ) +{ + SignatureInformation &si = m_vInternalSignatureInformations[m_vInternalSignatureInformations.size()-1].signatureInfor; + SignatureReferenceInformation &reference = si.vSignatureReferenceInfors[si.vSignatureReferenceInfors.size()-1]; + reference.ouDigestValue = ouDigestValue; +} + +void XSecController::setDate( rtl::OUString& ouDate ) +{ + InternalSignatureInformation &isi = m_vInternalSignatureInformations[m_vInternalSignatureInformations.size()-1]; + isi.signatureInfor.ouDate = ouDate; +} + +void XSecController::setTime( rtl::OUString& ouTime ) +{ + InternalSignatureInformation &isi = m_vInternalSignatureInformations[m_vInternalSignatureInformations.size()-1]; + isi.signatureInfor.ouTime = ouTime; +} + +/* public: for signature verify */ +void XSecController::collectToVerify( const rtl::OUString& referenceId ) +{ + /* DBG_ASSERT( m_xSAXEventKeeper.is(), "the SAXEventKeeper is NULL" ); */ + + if ( m_nStatusOfSecurityComponents == INITIALIZED ) + /* + * if all security components are ready, verify the signature. + */ + { + bool bJustChainingOn = false; + cssu::Reference< cssxs::XDocumentHandler > xHandler = NULL; + + int i,j; + int sigNum = m_vInternalSignatureInformations.size(); + + for (i=0; isetNextHandler(NULL); + } + + sal_Int32 nKeeperId = m_xSAXEventKeeper->addSecurityElementCollector( + cssxc::sax::ElementMarkPriority_PRI_BEFOREMODIFY, sal_False ); + + cssu::Reference xReferenceResolvedBroadcaster + (m_xSAXEventKeeper, + cssu::UNO_QUERY ); + + cssu::Reference xReferenceCollector + ( isi.xReferenceResolvedListener, cssu::UNO_QUERY ); + + m_xSAXEventKeeper->setSecurityId(nKeeperId, isi.signatureInfor.nSecurityId); + xReferenceResolvedBroadcaster->addReferenceResolvedListener( nKeeperId, isi.xReferenceResolvedListener); + xReferenceCollector->setReferenceId( nKeeperId ); + + isi.vKeeperIds[j] = nKeeperId; + break; + } + } + } + + if ( bJustChainingOn ) + { + cssu::Reference< cssxs::XDocumentHandler > xSEKHandler(m_xSAXEventKeeper, cssu::UNO_QUERY); + if (m_xElementStackKeeper.is()) + { + m_xElementStackKeeper->retrieve(xSEKHandler, sal_True); + } + m_xSAXEventKeeper->setNextHandler(xHandler); + } + } +} + +void XSecController::addSignature( sal_Int32 nSignatureId ) +{ + DBG_ASSERT( m_pXSecParser != NULL, "No XSecParser initialized" ); + + m_nReservedSignatureId = nSignatureId; + m_bVerifyCurrentSignature = true; +} + +cssu::Reference< cssxs::XDocumentHandler > XSecController::createSignatureReader() +{ + m_pXSecParser = new XSecParser( this, NULL ); + cssu::Reference< cssl::XInitialization > xInitialization = m_pXSecParser; + + setSAXChainConnector(xInitialization, NULL, NULL); + + return m_pXSecParser; +} + +void XSecController::releaseSignatureReader() +{ + clearSAXChainConnector( ); + m_pXSecParser = NULL; +} + diff --git a/xmlsecurity/source/xmlsec/certificateextension_xmlsecimpl.cxx b/xmlsecurity/source/xmlsec/certificateextension_xmlsecimpl.cxx new file mode 100644 index 000000000000..f9c7f9f78fb6 --- /dev/null +++ b/xmlsecurity/source/xmlsec/certificateextension_xmlsecimpl.cxx @@ -0,0 +1,134 @@ +/************************************************************************* + * + * $RCSfile: certificateextension_xmlsecimpl.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:20 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _SAL_CONFIG_H_ +#include +#endif + +#ifndef _RTL_UUID_H_ +#include +#endif + +#ifndef _certificateextension_nssimpl_hxx_ +#include "certificateextension_xmlsecimpl.hxx" +#endif + +using namespace ::com::sun::star::uno ; +using ::rtl::OUString ; + +using ::com::sun::star::security::XCertificateExtension ; + +CertificateExtension_XmlSecImpl :: CertificateExtension_XmlSecImpl() : + m_critical( sal_False ) , + m_xExtnId() , + m_xExtnValue() +{ +} + +CertificateExtension_XmlSecImpl :: ~CertificateExtension_XmlSecImpl() { +} + + +//Methods from XCertificateExtension +sal_Bool SAL_CALL CertificateExtension_XmlSecImpl :: isCritical() throw( ::com::sun::star::uno::RuntimeException ) { + return m_critical ; +} + +::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL CertificateExtension_XmlSecImpl :: getExtnId() throw( ::com::sun::star::uno::RuntimeException ) { + return m_xExtnId ; +} + +::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL CertificateExtension_XmlSecImpl :: getExtnValue() throw( ::com::sun::star::uno::RuntimeException ) { + return m_xExtnValue ; +} + +//Helper method +void CertificateExtension_XmlSecImpl :: setCertExtn( ::com::sun::star::uno::Sequence< sal_Int8 > extnId, ::com::sun::star::uno::Sequence< sal_Int8 > extnValue, sal_Bool critical ) { + m_critical = critical ; + m_xExtnId = extnId ; + m_xExtnValue = extnValue ; +} + +void CertificateExtension_XmlSecImpl :: setCertExtn( unsigned char* value, unsigned int vlen, unsigned char* id, unsigned int idlen, sal_Bool critical ) { + unsigned int i ; + if( value != NULL && vlen != 0 ) { + Sequence< sal_Int8 > extnv( vlen ) ; + for( i = 0; i < vlen ; i ++ ) + extnv[i] = *( value + i ) ; + + m_xExtnValue = extnv ; + } else { + m_xExtnValue = NULL ; + } + + if( id != NULL && idlen != 0 ) { + Sequence< sal_Int8 > extnId( idlen ) ; + for( i = 0; i < idlen ; i ++ ) + extnId[i] = *( id + i ) ; + + m_xExtnId = extnId ; + } else { + m_xExtnId = NULL ; + } + + m_critical = critical ; +} + diff --git a/xmlsecurity/source/xmlsec/certificateextension_xmlsecimpl.hxx b/xmlsecurity/source/xmlsec/certificateextension_xmlsecimpl.hxx new file mode 100644 index 000000000000..f71d9831e6c1 --- /dev/null +++ b/xmlsecurity/source/xmlsec/certificateextension_xmlsecimpl.hxx @@ -0,0 +1,119 @@ +/************************************************************************* + * + * $RCSfile: certificateextension_xmlsecimpl.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:20 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _CERTIFICATEEXTENSION_XMLSECIMPL_HXX_ +#define _CERTIFICATEEXTENSION_XMLSECIMPL_HXX_ + +#ifndef _SAL_CONFIG_H_ +#include +#endif + +#ifndef _RTL_USTRING_HXX_ +#include +#endif + +#ifndef _CPPUHELPER_FACTORY_HXX_ +#include +#endif + +#ifndef _CPPUHELPER_IMPLBASE1_HXX_ +#include +#endif + +#ifndef _COM_SUN_STAR_UNO_EXCEPTION_HPP_ +#include +#endif + +#ifndef _COM_SUN_STAR_UNO_SECURITYEXCEPTION_HPP_ +#include "com/sun/star/uno/SecurityException.hpp" +#endif + +#ifndef _COM_SUN_STAR_SECURITY_XCERTIFICATEEXTENSION_HPP_ +#include +#endif + +class CertificateExtension_XmlSecImpl : public ::cppu::WeakImplHelper1< + ::com::sun::star::security::XCertificateExtension > +{ + private : + sal_Bool m_critical ; + ::com::sun::star::uno::Sequence< sal_Int8 > m_xExtnId ; + ::com::sun::star::uno::Sequence< sal_Int8 > m_xExtnValue ; + + public : + CertificateExtension_XmlSecImpl() ; + virtual ~CertificateExtension_XmlSecImpl() ; + + //Methods from XCertificateExtension + virtual sal_Bool SAL_CALL isCritical() throw( ::com::sun::star::uno::RuntimeException ) ; + + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getExtnId() throw( ::com::sun::star::uno::RuntimeException ) ; + + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getExtnValue() throw( ::com::sun::star::uno::RuntimeException ) ; + + //Helper method + void setCertExtn( ::com::sun::star::uno::Sequence< sal_Int8 > extnId, ::com::sun::star::uno::Sequence< sal_Int8 > extnValue, sal_Bool critical ) ; + + void setCertExtn( unsigned char* value, unsigned int vlen, unsigned char* id, unsigned int idlen, sal_Bool critical ) ; +} ; + +#endif // _CERTIFICATEEXTENSION_XMLSECIMPL_HXX_ + diff --git a/xmlsecurity/source/xmlsec/makefile.mk b/xmlsecurity/source/xmlsec/makefile.mk new file mode 100644 index 000000000000..0f563a39b288 --- /dev/null +++ b/xmlsecurity/source/xmlsec/makefile.mk @@ -0,0 +1,94 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1.1.1 $ +# +# last change: $Author: mt $ $Date: 2004-07-12 13:15:21 $ +# +# The Contents of this file are made available subject to the terms of +# either of the following licenses +# +# - GNU Lesser General Public License Version 2.1 +# - Sun Industry Standards Source License Version 1.1 +# +# Sun Microsystems Inc., October, 2000 +# +# GNU Lesser General Public License Version 2.1 +# ============================================= +# Copyright 2000 by Sun Microsystems, Inc. +# 901 San Antonio Road, Palo Alto, CA 94303, USA +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License version 2.1, as published by the Free Software Foundation. +# +# This library 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 for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, +# MA 02111-1307 USA +# +# +# Sun Industry Standards Source License Version 1.1 +# ================================================= +# The contents of this file are subject to the Sun Industry Standards +# Source License Version 1.1 (the "License"); You may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at http://www.openoffice.org/license.html. +# +# Software provided under this License is provided on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, +# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, +# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. +# See the License for the specific provisions governing your rights and +# obligations concerning the Software. +# +# The Initial Developer of the Original Code is: Sun Microsystems, Inc. +# +# Copyright: 2000 by Sun Microsystems, Inc. +# +# All Rights Reserved. +# +# Contributor(s): _______________________________________ +# +# +# +#************************************************************************* + +PRJ=..$/.. + +PRJNAME = xmlsecurity +TARGET = xs_comm + +ENABLE_EXCEPTIONS = TRUE + +# --- Settings ----------------------------------------------------- + +.INCLUDE : svpre.mk +.INCLUDE : settings.mk +.INCLUDE : sv.mk +.INCLUDE : $(PRJ)$/util$/target.pmk + +.IF "$(CRYPTO_ENGINE)" == "mscrypto" +CDEFS += -DXMLSEC_CRYPTO_MSCRYPTO -DXMLSEC_NO_XSLT +.ELSE +CDEFS += -DXMLSEC_CRYPTO_NSS -DXMLSEC_NO_XSLT +.ENDIF + +# --- Files -------------------------------------------------------- +SLOFILES = \ + $(SLO)$/saxhelper.obj \ + $(SLO)$/xmldocumentwrapper_xmlsecimpl.obj \ + $(SLO)$/xmlelementwrapper_xmlsecimpl.obj \ + $(SLO)$/certificateextension_xmlsecimpl.obj \ + $(SLO)$/xmlstreamio.obj \ + $(SLO)$/xsec_xmlsec.obj + +# --- Targets ------------------------------------------------------ + +.INCLUDE : target.mk diff --git a/xmlsecurity/source/xmlsec/mscrypt/makefile.mk b/xmlsecurity/source/xmlsec/mscrypt/makefile.mk new file mode 100644 index 000000000000..22a9437bbceb --- /dev/null +++ b/xmlsecurity/source/xmlsec/mscrypt/makefile.mk @@ -0,0 +1,102 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1.1.1 $ +# +# last change: $Author: mt $ $Date: 2004-07-12 13:15:22 $ +# +# The Contents of this file are made available subject to the terms of +# either of the following licenses +# +# - GNU Lesser General Public License Version 2.1 +# - Sun Industry Standards Source License Version 1.1 +# +# Sun Microsystems Inc., October, 2000 +# +# GNU Lesser General Public License Version 2.1 +# ============================================= +# Copyright 2000 by Sun Microsystems, Inc. +# 901 San Antonio Road, Palo Alto, CA 94303, USA +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License version 2.1, as published by the Free Software Foundation. +# +# This library 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 for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, +# MA 02111-1307 USA +# +# +# Sun Industry Standards Source License Version 1.1 +# ================================================= +# The contents of this file are subject to the Sun Industry Standards +# Source License Version 1.1 (the "License"); You may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at http://www.openoffice.org/license.html. +# +# Software provided under this License is provided on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, +# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, +# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. +# See the License for the specific provisions governing your rights and +# obligations concerning the Software. +# +# The Initial Developer of the Original Code is: Sun Microsystems, Inc. +# +# Copyright: 2000 by Sun Microsystems, Inc. +# +# All Rights Reserved. +# +# Contributor(s): _______________________________________ +# +# +# +#************************************************************************* + +PRJ=..$/..$/.. + +PRJNAME = xmlsecurity +TARGET = xs_mscrypt + +ENABLE_EXCEPTIONS = TRUE + +# --- Settings ----------------------------------------------------- + +.INCLUDE : svpre.mk +.INCLUDE : settings.mk +.INCLUDE : sv.mk +.INCLUDE : $(PRJ)$/util$/target.pmk + +.IF "$(CRYPTO_ENGINE)" != "mscrypto" +LIBTARGET=NO +.ENDIF + +.IF "$(CRYPTO_ENGINE)" == "mscrypto" + +CDEFS += -DXMLSEC_CRYPTO_MSCRYPTO -DXMLSEC_NO_XSLT + +# --- Files -------------------------------------------------------- +INCLOCAL = \ + .. + +SLOFILES = \ + $(SLO)$/securityenvironment_mscryptimpl.obj \ + $(SLO)$/xmlencryption_mscryptimpl.obj \ + $(SLO)$/xmlsecuritycontext_mscryptimpl.obj \ + $(SLO)$/xmlsignature_mscryptimpl.obj \ + $(SLO)$/x509certificate_mscryptimpl.obj \ + $(SLO)$/seinitializer_mscryptimpl.obj \ + $(SLO)$/xsec_mscrypt.obj + +.ENDIF + +# --- Targets ------------------------------------------------------ + +.INCLUDE : target.mk diff --git a/xmlsecurity/source/xmlsec/mscrypt/securityenvironment_mscryptimpl.cxx b/xmlsecurity/source/xmlsec/mscrypt/securityenvironment_mscryptimpl.cxx new file mode 100644 index 000000000000..61647496a20d --- /dev/null +++ b/xmlsecurity/source/xmlsec/mscrypt/securityenvironment_mscryptimpl.cxx @@ -0,0 +1,1028 @@ +/************************************************************************* + * + * $RCSfile: securityenvironment_mscryptimpl.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:21 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _SAL_CONFIG_H_ +#include +#endif + +#ifndef _XSECURITYENVIRONMENT_MSCRYPTIMPL_HXX_ +#include "securityenvironment_mscryptimpl.hxx" +#endif + +#ifndef _X509CERTIFICATE_NSSIMPL_HXX_ +#include "x509certificate_mscryptimpl.hxx" +#endif + +#ifndef _RTL_UUID_H_ +#include +#endif + +#include "Windows.h" +#include "WinCrypt.h" + +#include "xmlsec/xmlsec.h" +#include "xmlsec/keysmngr.h" +#include "xmlsec/crypto.h" +#include + +using namespace ::com::sun::star::uno ; +using namespace ::com::sun::star::lang ; +using ::com::sun::star::lang::XMultiServiceFactory ; +using ::com::sun::star::lang::XSingleServiceFactory ; +using ::rtl::OUString ; + +using ::com::sun::star::xml::crypto::XSecurityEnvironment ; +using ::com::sun::star::security::XCertificate ; + +extern Sequence< sal_Int8 > numericStringToBigInteger( OUString ) ; +extern OUString bigIntegerToNumericString( Sequence< sal_Int8 > serial ) ; + +extern X509Certificate_MSCryptImpl* MswcryCertContextToXCert( PCCERT_CONTEXT cert ) ; + +SecurityEnvironment_MSCryptImpl :: SecurityEnvironment_MSCryptImpl( const Reference< XMultiServiceFactory >& aFactory ) : m_hProv( NULL ) , m_pszContainer( NULL ) , m_hKeyStore( NULL ), m_hCertStore( NULL ), m_tSymKeyList() , m_tPubKeyList() , m_tPriKeyList(), m_xServiceManager( aFactory ), m_bEnableDefault( sal_False ) { +} + +SecurityEnvironment_MSCryptImpl :: ~SecurityEnvironment_MSCryptImpl() { + if( m_hProv != NULL ) { + CryptReleaseContext( m_hProv, 0 ) ; + m_hProv = NULL ; + } + + if( m_pszContainer != NULL ) { + //TODO: Don't know whether or not it should be released now. + m_pszContainer = NULL ; + } + + if( m_hCertStore != NULL ) { + CertCloseStore( m_hCertStore, CERT_CLOSE_STORE_FORCE_FLAG ) ; + m_hCertStore = NULL ; + } + + if( m_hKeyStore != NULL ) { + CertCloseStore( m_hKeyStore, CERT_CLOSE_STORE_FORCE_FLAG ) ; + m_hKeyStore = NULL ; + } + + if( !m_tSymKeyList.empty() ) { + std::list< HCRYPTKEY >::iterator symKeyIt ; + + for( symKeyIt = m_tSymKeyList.begin() ; symKeyIt != m_tSymKeyList.end() ; symKeyIt ++ ) + CryptDestroyKey( *symKeyIt ) ; + } + + if( !m_tPubKeyList.empty() ) { + std::list< HCRYPTKEY >::iterator pubKeyIt ; + + for( pubKeyIt = m_tPubKeyList.begin() ; pubKeyIt != m_tPubKeyList.end() ; pubKeyIt ++ ) + CryptDestroyKey( *pubKeyIt ) ; + } + + if( !m_tPriKeyList.empty() ) { + std::list< HCRYPTKEY >::iterator priKeyIt ; + + for( priKeyIt = m_tPriKeyList.begin() ; priKeyIt != m_tPriKeyList.end() ; priKeyIt ++ ) + CryptDestroyKey( *priKeyIt ) ; + } +} + +/* XInitialization */ +void SAL_CALL SecurityEnvironment_MSCryptImpl :: initialize( const Sequence< Any >& aArguments ) throw( Exception, RuntimeException ) { + //TODO +} ; + +/* XServiceInfo */ +OUString SAL_CALL SecurityEnvironment_MSCryptImpl :: getImplementationName() throw( RuntimeException ) { + return impl_getImplementationName() ; +} + +/* XServiceInfo */ +sal_Bool SAL_CALL SecurityEnvironment_MSCryptImpl :: supportsService( const OUString& serviceName) throw( RuntimeException ) { + Sequence< OUString > seqServiceNames = getSupportedServiceNames() ; + const OUString* pArray = seqServiceNames.getConstArray() ; + for( sal_Int32 i = 0 ; i < seqServiceNames.getLength() ; i ++ ) { + if( *( pArray + i ) == serviceName ) + return sal_True ; + } + return sal_False ; +} + +/* XServiceInfo */ +Sequence< OUString > SAL_CALL SecurityEnvironment_MSCryptImpl :: getSupportedServiceNames() throw( RuntimeException ) { + return impl_getSupportedServiceNames() ; +} + +//Helper for XServiceInfo +Sequence< OUString > SecurityEnvironment_MSCryptImpl :: impl_getSupportedServiceNames() { + ::osl::Guard< ::osl::Mutex > aGuard( ::osl::Mutex::getGlobalMutex() ) ; + Sequence< OUString > seqServiceNames( 1 ) ; + seqServiceNames.getArray()[0] = OUString::createFromAscii( "com.sun.star.xml.crypto.SecurityEnvironment" ) ; + return seqServiceNames ; +} + +OUString SecurityEnvironment_MSCryptImpl :: impl_getImplementationName() throw( RuntimeException ) { + return OUString::createFromAscii( "com.sun.star.xml.security.bridge.xmlsec.SecurityEnvironment_MSCryptImpl" ) ; +} + +//Helper for registry +Reference< XInterface > SAL_CALL SecurityEnvironment_MSCryptImpl :: impl_createInstance( const Reference< XMultiServiceFactory >& aServiceManager ) throw( RuntimeException ) { + return Reference< XInterface >( *new SecurityEnvironment_MSCryptImpl( aServiceManager ) ) ; +} + +Reference< XSingleServiceFactory > SecurityEnvironment_MSCryptImpl :: impl_createFactory( const Reference< XMultiServiceFactory >& aServiceManager ) { + return ::cppu::createSingleFactory( aServiceManager , impl_getImplementationName() , impl_createInstance , impl_getSupportedServiceNames() ) ; +} + +/* XUnoTunnel */ +sal_Int64 SAL_CALL SecurityEnvironment_MSCryptImpl :: getSomething( const Sequence< sal_Int8 >& aIdentifier ) + throw( RuntimeException ) +{ + if( aIdentifier.getLength() == 16 && 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(), aIdentifier.getConstArray(), 16 ) ) { + return ( sal_Int64 )this ; + } + return 0 ; +} + +/* XUnoTunnel extension */ +const Sequence< sal_Int8>& SecurityEnvironment_MSCryptImpl :: getUnoTunnelId() { + static Sequence< sal_Int8 >* pSeq = 0 ; + if( !pSeq ) { + ::osl::Guard< ::osl::Mutex > aGuard( ::osl::Mutex::getGlobalMutex() ) ; + if( !pSeq ) { + static Sequence< sal_Int8> aSeq( 16 ) ; + rtl_createUuid( ( sal_uInt8* )aSeq.getArray() , 0 , sal_True ) ; + pSeq = &aSeq ; + } + } + return *pSeq ; +} + +/* XUnoTunnel extension */ +SecurityEnvironment_MSCryptImpl* SecurityEnvironment_MSCryptImpl :: getImplementation( const Reference< XInterface > xObj ) { + Reference< XUnoTunnel > xUT( xObj , UNO_QUERY ) ; + if( xUT.is() ) { + return ( SecurityEnvironment_MSCryptImpl* )xUT->getSomething( getUnoTunnelId() ) ; + } else + return NULL ; +} + +/* Native methods */ +HCRYPTPROV SecurityEnvironment_MSCryptImpl :: getCryptoProvider() throw( ::com::sun::star::uno::Exception , ::com::sun::star::uno::RuntimeException ) { + return m_hProv ; +} + +void SecurityEnvironment_MSCryptImpl :: setCryptoProvider( HCRYPTPROV aProv ) throw( ::com::sun::star::uno::Exception , ::com::sun::star::uno::RuntimeException ) { + if( m_hProv != NULL ) { + CryptReleaseContext( m_hProv, 0 ) ; + m_hProv = NULL ; + } + + if( aProv != NULL ) { + if( !CryptContextAddRef( aProv, NULL, NULL ) ) + throw Exception() ; + else + m_hProv = aProv ; + } +} + +LPCTSTR SecurityEnvironment_MSCryptImpl :: getKeyContainer() throw( ::com::sun::star::uno::Exception , ::com::sun::star::uno::RuntimeException ) { + return m_pszContainer ; +} + +void SecurityEnvironment_MSCryptImpl :: setKeyContainer( LPCTSTR aKeyContainer ) throw( ::com::sun::star::uno::Exception , ::com::sun::star::uno::RuntimeException ) { + //TODO: Don't know whether or not it should be copied. + m_pszContainer = aKeyContainer ; +} + + +HCERTSTORE SecurityEnvironment_MSCryptImpl :: getCryptoSlot() throw( Exception , RuntimeException ) { + return m_hKeyStore ; +} + +void SecurityEnvironment_MSCryptImpl :: setCryptoSlot( HCERTSTORE aSlot) throw( Exception , RuntimeException ) { + if( m_hKeyStore != NULL ) { + CertCloseStore( m_hKeyStore, CERT_CLOSE_STORE_FORCE_FLAG ) ; + m_hKeyStore = NULL ; + } + + if( aSlot != NULL ) { + m_hKeyStore = CertDuplicateStore( aSlot ) ; + } +} + +HCERTSTORE SecurityEnvironment_MSCryptImpl :: getCertDb() throw( Exception , RuntimeException ) { + return m_hCertStore ; +} + +void SecurityEnvironment_MSCryptImpl :: setCertDb( HCERTSTORE aCertDb ) throw( Exception , RuntimeException ) { + if( m_hCertStore != NULL ) { + CertCloseStore( m_hCertStore, CERT_CLOSE_STORE_FORCE_FLAG ) ; + m_hCertStore = NULL ; + } + + if( aCertDb != NULL ) { + m_hCertStore = CertDuplicateStore( aCertDb ) ; + } +} + +void SecurityEnvironment_MSCryptImpl :: adoptSymKey( HCRYPTKEY aSymKey ) throw( Exception , RuntimeException ) { + HCRYPTKEY symkey ; + std::list< HCRYPTKEY >::iterator keyIt ; + + if( aSymKey != NULL ) { + //First try to find the key in the list + for( keyIt = m_tSymKeyList.begin() ; keyIt != m_tSymKeyList.end() ; keyIt ++ ) { + if( *keyIt == aSymKey ) + return ; + } + + //If we do not find the key in the list, add a new node + if( !CryptDuplicateKey( aSymKey, NULL, 0, &symkey ) ) + throw RuntimeException() ; + + try { + m_tSymKeyList.push_back( symkey ) ; + } catch ( Exception& ) { + CryptDestroyKey( symkey ) ; + } + } +} + +void SecurityEnvironment_MSCryptImpl :: rejectSymKey( HCRYPTKEY aSymKey ) throw( Exception , RuntimeException ) { + HCRYPTKEY symkey ; + std::list< HCRYPTKEY >::iterator keyIt ; + + if( aSymKey != NULL ) { + for( keyIt = m_tSymKeyList.begin() ; keyIt != m_tSymKeyList.end() ; keyIt ++ ) { + if( *keyIt == aSymKey ) { + symkey = *keyIt ; + CryptDestroyKey( symkey ) ; + m_tSymKeyList.erase( keyIt ) ; + break ; + } + } + } +} + +HCRYPTKEY SecurityEnvironment_MSCryptImpl :: getSymKey( unsigned int position ) throw( Exception , RuntimeException ) { + HCRYPTKEY symkey ; + std::list< HCRYPTKEY >::iterator keyIt ; + unsigned int pos ; + + symkey = NULL ; + for( pos = 0, keyIt = m_tSymKeyList.begin() ; pos < position && keyIt != m_tSymKeyList.end() ; pos ++ , keyIt ++ ) ; + + if( pos == position && keyIt != m_tSymKeyList.end() ) + symkey = *keyIt ; + + return symkey ; +} + +void SecurityEnvironment_MSCryptImpl :: adoptPubKey( HCRYPTKEY aPubKey ) throw( Exception , RuntimeException ) { + HCRYPTKEY pubkey ; + std::list< HCRYPTKEY >::iterator keyIt ; + + if( aPubKey != NULL ) { + //First try to find the key in the list + for( keyIt = m_tPubKeyList.begin() ; keyIt != m_tPubKeyList.end() ; keyIt ++ ) { + if( *keyIt == aPubKey ) + return ; + } + + //If we do not find the key in the list, add a new node + if( !CryptDuplicateKey( aPubKey, NULL, 0, &pubkey ) ) + throw RuntimeException() ; + + try { + m_tPubKeyList.push_back( pubkey ) ; + } catch ( Exception& ) { + CryptDestroyKey( pubkey ) ; + } + } +} + +void SecurityEnvironment_MSCryptImpl :: rejectPubKey( HCRYPTKEY aPubKey ) throw( Exception , RuntimeException ) { + HCRYPTKEY pubkey ; + std::list< HCRYPTKEY >::iterator keyIt ; + + if( aPubKey != NULL ) { + for( keyIt = m_tPubKeyList.begin() ; keyIt != m_tPubKeyList.end() ; keyIt ++ ) { + if( *keyIt == aPubKey ) { + pubkey = *keyIt ; + CryptDestroyKey( pubkey ) ; + m_tPubKeyList.erase( keyIt ) ; + break ; + } + } + } +} + +HCRYPTKEY SecurityEnvironment_MSCryptImpl :: getPubKey( unsigned int position ) throw( Exception , RuntimeException ) { + HCRYPTKEY pubkey ; + std::list< HCRYPTKEY >::iterator keyIt ; + unsigned int pos ; + + pubkey = NULL ; + for( pos = 0, keyIt = m_tPubKeyList.begin() ; pos < position && keyIt != m_tPubKeyList.end() ; pos ++ , keyIt ++ ) ; + + if( pos == position && keyIt != m_tPubKeyList.end() ) + pubkey = *keyIt ; + + return pubkey ; +} + +void SecurityEnvironment_MSCryptImpl :: adoptPriKey( HCRYPTKEY aPriKey ) throw( Exception , RuntimeException ) { + HCRYPTKEY prikey ; + std::list< HCRYPTKEY >::iterator keyIt ; + + if( aPriKey != NULL ) { + //First try to find the key in the list + for( keyIt = m_tPriKeyList.begin() ; keyIt != m_tPriKeyList.end() ; keyIt ++ ) { + if( *keyIt == aPriKey ) + return ; + } + + //If we do not find the key in the list, add a new node + if( !CryptDuplicateKey( aPriKey, NULL, 0, &prikey ) ) + throw RuntimeException() ; + + try { + m_tPriKeyList.push_back( prikey ) ; + } catch ( Exception& ) { + CryptDestroyKey( prikey ) ; + } + } +} + +void SecurityEnvironment_MSCryptImpl :: rejectPriKey( HCRYPTKEY aPriKey ) throw( Exception , RuntimeException ) { + HCRYPTKEY prikey ; + std::list< HCRYPTKEY >::iterator keyIt ; + + if( aPriKey != NULL ) { + for( keyIt = m_tPriKeyList.begin() ; keyIt != m_tPriKeyList.end() ; keyIt ++ ) { + if( *keyIt == aPriKey ) { + prikey = *keyIt ; + CryptDestroyKey( prikey ) ; + m_tPriKeyList.erase( keyIt ) ; + break ; + } + } + } +} + +HCRYPTKEY SecurityEnvironment_MSCryptImpl :: getPriKey( unsigned int position ) throw( SecurityException , RuntimeException ) { + HCRYPTKEY prikey ; + std::list< HCRYPTKEY >::iterator keyIt ; + unsigned int pos ; + + prikey = NULL ; + for( pos = 0, keyIt = m_tPriKeyList.begin() ; pos < position && keyIt != m_tPriKeyList.end() ; pos ++ , keyIt ++ ) ; + + if( pos == position && keyIt != m_tPriKeyList.end() ) + prikey = *keyIt ; + + return prikey ; +} + +//Methods from XSecurityEnvironment +Sequence< Reference < XCertificate > > SecurityEnvironment_MSCryptImpl :: getPersonalCertificates() throw( SecurityException , RuntimeException ) { + sal_Int32 length ; + X509Certificate_MSCryptImpl* xcert ; + std::list< X509Certificate_MSCryptImpl* > certsList ; + PCCERT_CONTEXT pCertContext ; + + //firstly, we try to find private keys in given key store. + if( m_hKeyStore != NULL ) { + pCertContext = NULL ; + while( pCertContext = CertEnumCertificatesInStore( m_hKeyStore, pCertContext ) ) { + xcert = MswcryCertContextToXCert( pCertContext ) ; + if( xcert != NULL ) + certsList.push_back( xcert ) ; + } + } + + //secondly, we try to find certificate from registered private keys. + if( !m_tPriKeyList.empty() ) { + //TODO: Don't know whether or not it is necessary ans possible. + } + + //Thirdly, we try to find certificate from system default key store. + if( m_bEnableDefault ) { + HCERTSTORE hSystemKeyStore ; + + /* + hSystemKeyStore = CertOpenStore( + CERT_STORE_PROV_SYSTEM , + 0 , + NULL , + CERT_SYSTEM_STORE_CURRENT_USER | CERT_STORE_READONLY_FLAG | CERT_STORE_OPEN_EXISTING_FLAG , + L"MY" + ) ; + */ + hSystemKeyStore = CertOpenSystemStore( 0, "MY" ) ; + if( hSystemKeyStore != NULL ) { + pCertContext = NULL ; + while( pCertContext = CertEnumCertificatesInStore( hSystemKeyStore, pCertContext ) ) { + xcert = MswcryCertContextToXCert( pCertContext ) ; + if( xcert != NULL ) + certsList.push_back( xcert ) ; + } + } + + CertCloseStore( hSystemKeyStore, CERT_CLOSE_STORE_CHECK_FLAG ) ; + } + + length = certsList.size() ; + if( length != 0 ) { + int i ; + std::list< X509Certificate_MSCryptImpl* >::iterator xcertIt ; + Sequence< Reference< XCertificate > > certSeq( length ) ; + + for( i = 0, xcertIt = certsList.begin(); xcertIt != certsList.end(); xcertIt ++, i++ ) { + certSeq[i] = *xcertIt ; + } + + return certSeq ; + } + + return Sequence< Reference< XCertificate > >() ; +} + +Reference< XCertificate > SecurityEnvironment_MSCryptImpl :: getCertificate( const OUString& issuerName, const Sequence< sal_Int8 >& serialNumber ) throw( SecurityException , RuntimeException ) { + X509Certificate_MSCryptImpl* xcert ; + PCCERT_CONTEXT pCertContext ; + LPSTR pszName ; + CERT_INFO certInfo ; + + //Create cert info from issue and serial + rtl::OString oissuer = rtl::OUStringToOString( issuerName , RTL_TEXTENCODING_ASCII_US ) ; + pszName = ( char* )oissuer.getStr() ; + + if( ! ( CertStrToName( + X509_ASN_ENCODING | PKCS_7_ASN_ENCODING , + pszName , + CERT_X500_NAME_STR | CERT_NAME_STR_REVERSE_FLAG , + NULL , + NULL , + &certInfo.Issuer.cbData, NULL ) ) + ) { + throw SecurityException() ; + } + + if( !( certInfo.Issuer.pbData = ( BYTE* )malloc( certInfo.Issuer.cbData ) ) ) { + throw RuntimeException() ; + } + + if( ! ( CertStrToName( + X509_ASN_ENCODING | PKCS_7_ASN_ENCODING , + pszName , + CERT_X500_NAME_STR | CERT_NAME_STR_REVERSE_FLAG , + NULL , + ( BYTE* )certInfo.Issuer.pbData , + &certInfo.Issuer.cbData, NULL ) ) + ) { + free( certInfo.Issuer.pbData ) ; + throw SecurityException() ; + } + + certInfo.SerialNumber.cbData = serialNumber.getLength() ; + if( !( certInfo.SerialNumber.pbData = ( BYTE* )malloc( certInfo.SerialNumber.cbData ) ) ) { + free( certInfo.Issuer.pbData ) ; + throw SecurityException() ; + } + + for( unsigned int i = 0; i < certInfo.SerialNumber.cbData; i ++ ) + certInfo.SerialNumber.pbData[i] = serialNumber[ certInfo.SerialNumber.cbData - i - 1 ] ; + + pCertContext = NULL ; + + //Above all, we try to find the certificate in the given key store. + if( m_hKeyStore != NULL ) { + //Find the certificate from the store. + pCertContext = CertFindCertificateInStore( + m_hKeyStore, + X509_ASN_ENCODING | PKCS_7_ASN_ENCODING, + 0, + CERT_FIND_SUBJECT_CERT, + &certInfo, + NULL + ) ; + } + + //firstly, we try to find the certificate in the given cert store. + if( m_hCertStore != NULL ) { + //Find the certificate from the store. + pCertContext = CertFindCertificateInStore( + m_hCertStore, + X509_ASN_ENCODING | PKCS_7_ASN_ENCODING, + 0, + CERT_FIND_SUBJECT_CERT, + &certInfo, + NULL + ) ; + } + + //Secondly, we try to find certificate from system default key store. + if( pCertContext == NULL && m_bEnableDefault ) { + HCERTSTORE hSystemKeyStore ; + + hSystemKeyStore = CertOpenSystemStore( 0, "MY" ) ; + if( hSystemKeyStore != NULL ) { + pCertContext = CertFindCertificateInStore( + hSystemKeyStore, + X509_ASN_ENCODING | PKCS_7_ASN_ENCODING, + 0, + CERT_FIND_SUBJECT_CERT, + &certInfo, + NULL + ) ; + } + + CertCloseStore( hSystemKeyStore, CERT_CLOSE_STORE_CHECK_FLAG ) ; + } + + //Thirdly, we try to find certificate from system default root cert store. + if( pCertContext == NULL && m_bEnableDefault ) { + HCERTSTORE hSystemRootStore ; + + hSystemRootStore = CertOpenSystemStore( 0, "Root" ) ; + if( hSystemRootStore != NULL ) { + pCertContext = CertFindCertificateInStore( + hSystemRootStore, + X509_ASN_ENCODING | PKCS_7_ASN_ENCODING, + 0, + CERT_FIND_SUBJECT_CERT, + &certInfo, + NULL + ) ; + } + + CertCloseStore( hSystemRootStore, CERT_CLOSE_STORE_CHECK_FLAG ) ; + } + + //Fourthly, we try to find certificate from system default trust cert store. + if( pCertContext == NULL && m_bEnableDefault ) { + HCERTSTORE hSystemTrustStore ; + + hSystemTrustStore = CertOpenSystemStore( 0, "Trust" ) ; + if( hSystemTrustStore != NULL ) { + pCertContext = CertFindCertificateInStore( + hSystemTrustStore, + X509_ASN_ENCODING | PKCS_7_ASN_ENCODING, + 0, + CERT_FIND_SUBJECT_CERT, + &certInfo, + NULL + ) ; + } + + CertCloseStore( hSystemTrustStore, CERT_CLOSE_STORE_CHECK_FLAG ) ; + } + + //Fifthly, we try to find certificate from system default CA cert store. + if( pCertContext == NULL && m_bEnableDefault ) { + HCERTSTORE hSystemCAStore ; + + hSystemCAStore = CertOpenSystemStore( 0, "CA" ) ; + if( hSystemCAStore != NULL ) { + pCertContext = CertFindCertificateInStore( + hSystemCAStore, + X509_ASN_ENCODING | PKCS_7_ASN_ENCODING, + 0, + CERT_FIND_SUBJECT_CERT, + &certInfo, + NULL + ) ; + } + + CertCloseStore( hSystemCAStore, CERT_CLOSE_STORE_CHECK_FLAG ) ; + } + + + free( certInfo.Issuer.pbData ) ; + free( certInfo.SerialNumber.pbData ) ; + + if( pCertContext != NULL ) { + xcert = MswcryCertContextToXCert( pCertContext ) ; + } else { + xcert = NULL ; + } + + return xcert ; +} + +Reference< XCertificate > SecurityEnvironment_MSCryptImpl :: getCertificate( const OUString& issuerName, const OUString& serialNumber ) throw( SecurityException , RuntimeException ) { + Sequence< sal_Int8 > serial = numericStringToBigInteger( serialNumber ) ; + return getCertificate( issuerName, serial ) ; +} + +Sequence< Reference < XCertificate > > SecurityEnvironment_MSCryptImpl :: buildCertificatePath( const Reference< XCertificate >& begin ) throw( SecurityException , RuntimeException ) { + PCCERT_CHAIN_CONTEXT pChainContext ; + PCCERT_CONTEXT pCertContext ; + const X509Certificate_MSCryptImpl* xcert ; + + CERT_ENHKEY_USAGE enhKeyUsage ; + CERT_USAGE_MATCH certUsage ; + CERT_CHAIN_PARA chainPara ; + + enhKeyUsage.cUsageIdentifier = 0 ; + enhKeyUsage.rgpszUsageIdentifier = NULL ; + certUsage.dwType = USAGE_MATCH_TYPE_AND ; + certUsage.Usage = enhKeyUsage ; + chainPara.cbSize = sizeof( CERT_CHAIN_PARA ) ; + chainPara.RequestedUsage = certUsage ; + + Reference< XUnoTunnel > xCertTunnel( begin, UNO_QUERY ) ; + if( !xCertTunnel.is() ) { + throw RuntimeException() ; + } + + xcert = ( X509Certificate_MSCryptImpl* )xCertTunnel->getSomething( X509Certificate_MSCryptImpl::getUnoTunnelId() ) ; + if( xcert == NULL ) { + throw RuntimeException() ; + } + + pCertContext = xcert->getMswcryCert() ; + + pChainContext = NULL ; + + //Above all, we try to find the certificate in the given key store. + if( pCertContext != NULL ) { + if( !CertGetCertificateChain( + NULL , + pCertContext , + NULL , + m_hKeyStore , + &chainPara , + 0 , + NULL , + &pChainContext + ) + ) { + pChainContext = NULL ; + } + } + + //firstly, we try to find the certificate in the given cert store. + if( pCertContext != NULL && pChainContext != NULL ) { + if( !CertGetCertificateChain( + NULL , + pCertContext , + NULL , + m_hCertStore , + &chainPara , + 0 , + NULL , + &pChainContext + ) + ) { + pChainContext = NULL ; + } + } + + //Secondly, we try to find certificate from system default system store. + if( pCertContext != NULL && pChainContext != NULL ) { + HCERTSTORE hCollectionStore ; + + hCollectionStore = CertOpenStore( + CERT_STORE_PROV_COLLECTION , + 0 , + NULL , + 0 , + NULL + ) ; + + if( hCollectionStore != NULL ) { + HCERTSTORE hSystemStore ; + + //Add system key store to the collection. + hSystemStore = CertOpenSystemStore( 0, "MY" ) ; + if( hSystemStore != NULL ) { + CertAddStoreToCollection ( + hCollectionStore , + hSystemStore , + CERT_PHYSICAL_STORE_ADD_ENABLE_FLAG , + 1 + ) ; + CertCloseStore( hSystemStore, CERT_CLOSE_STORE_CHECK_FLAG ) ; + } + + //Add system root store to the collection. + hSystemStore = CertOpenSystemStore( 0, "Root" ) ; + if( hSystemStore != NULL ) { + CertAddStoreToCollection ( + hCollectionStore , + hSystemStore , + CERT_PHYSICAL_STORE_ADD_ENABLE_FLAG , + 2 + ) ; + CertCloseStore( hSystemStore, CERT_CLOSE_STORE_CHECK_FLAG ) ; + } + + //Add system trust store to the collection. + hSystemStore = CertOpenSystemStore( 0, "Trust" ) ; + if( hSystemStore != NULL ) { + CertAddStoreToCollection ( + hCollectionStore , + hSystemStore , + CERT_PHYSICAL_STORE_ADD_ENABLE_FLAG , + 3 + ) ; + CertCloseStore( hSystemStore, CERT_CLOSE_STORE_CHECK_FLAG ) ; + } + + //Add system CA store to the collection. + hSystemStore = CertOpenSystemStore( 0, "CA" ) ; + if( hSystemStore != NULL ) { + CertAddStoreToCollection ( + hCollectionStore , + hSystemStore , + CERT_PHYSICAL_STORE_ADD_ENABLE_FLAG , + 4 + ) ; + CertCloseStore( hSystemStore, CERT_CLOSE_STORE_CHECK_FLAG ) ; + } + + //Get the chain from the collection store. + if( !CertGetCertificateChain( + NULL , + pCertContext , + NULL , + hCollectionStore , + &chainPara , + 0 , + NULL , + &pChainContext + ) + ) { + pChainContext = NULL ; + } + + CertCloseStore( hCollectionStore, CERT_CLOSE_STORE_CHECK_FLAG ) ; + } + } + + if( pChainContext != NULL && pChainContext->cChain > 0 ) { + PCCERT_CONTEXT pCertInChain ; + PCERT_SIMPLE_CHAIN pCertChain ; + X509Certificate_MSCryptImpl* pCert ; + + pCertChain = pChainContext->rgpChain[0] ; + if( pCertChain->cElement ) { + Sequence< Reference< XCertificate > > xCertChain( pCertChain->cElement ) ; + + for( unsigned int i = 0 ; i < pCertChain->cElement ; i ++ ) { + if( pCertChain->rgpElement[i] ) + pCertInChain = pCertChain->rgpElement[i]->pCertContext ; + else + pCertInChain = NULL ; + + if( pCertInChain != NULL ) { + pCert = MswcryCertContextToXCert( pCertInChain ) ; + if( pCert != NULL ) + xCertChain[i] = pCert ; + } + } + + CertFreeCertificateChain( pChainContext ) ; + pChainContext = NULL ; + + return xCertChain ; + } + } + + return NULL ; +} + +Reference< XCertificate > SecurityEnvironment_MSCryptImpl :: createCertificateFromRaw( const Sequence< sal_Int8 >& rawCertificate ) throw( SecurityException , RuntimeException ) { + X509Certificate_MSCryptImpl* xcert ; + + if( rawCertificate.getLength() > 0 ) { + xcert = new X509Certificate_MSCryptImpl() ; + if( xcert == NULL ) + throw RuntimeException() ; + + xcert->setRawCert( rawCertificate ) ; + } else { + xcert = NULL ; + } + + return xcert ; +} + +Reference< XCertificate > SecurityEnvironment_MSCryptImpl :: createCertificateFromAscii( const OUString& asciiCertificate ) throw( SecurityException , RuntimeException ) { + xmlChar* chCert ; + xmlSecSize certSize ; + + rtl::OString oscert = rtl::OUStringToOString( asciiCertificate , RTL_TEXTENCODING_ASCII_US ) ; + + chCert = xmlStrndup( ( const xmlChar* )oscert.getStr(), ( int )oscert.getLength() ) ; + + certSize = xmlSecBase64Decode( chCert, ( xmlSecByte* )chCert, xmlStrlen( chCert ) ) ; + + Sequence< sal_Int8 > rawCert( certSize ) ; + for( unsigned int i = 0 ; i < certSize ; i ++ ) + rawCert[i] = *( chCert + i ) ; + + xmlFree( chCert ) ; + + return createCertificateFromRaw( rawCert ) ; +} + +void SecurityEnvironment_MSCryptImpl :: enableDefaultCrypt( sal_Bool enable ) throw( Exception, RuntimeException ) { + m_bEnableDefault = enable ; +} + +sal_Bool SecurityEnvironment_MSCryptImpl :: defaultEnabled() throw( Exception, RuntimeException ) { + return m_bEnableDefault ; +} + +X509Certificate_MSCryptImpl* MswcryCertContextToXCert( PCCERT_CONTEXT cert ) +{ + X509Certificate_MSCryptImpl* xcert ; + + if( cert != NULL ) { + xcert = new X509Certificate_MSCryptImpl() ; + if( xcert != NULL ) { + xcert->setMswcryCert( cert ) ; + } + } else { + xcert = NULL ; + } + + return xcert ; +} + +/*- + * This is just one temporary conversion + */ +Sequence< sal_Int8 > numericStringToBigInteger ( + OUString serialNumber +) { + xmlChar* chSerial ; + unsigned long ui ; + unsigned char bb[5] ; + int len ; + + rtl::OString oseri = rtl::OUStringToOString( serialNumber , RTL_TEXTENCODING_ASCII_US ) ; + + chSerial = xmlStrndup( ( const xmlChar* )oseri.getStr(), ( int )oseri.getLength() ) ; + ui = atoi( ( const char* )chSerial ) ; + xmlFree( chSerial ) ; + + bb[0] = 0; + bb[1] = (unsigned char) (ui >> 24); + bb[2] = (unsigned char) (ui >> 16); + bb[3] = (unsigned char) (ui >> 8); + bb[4] = (unsigned char) (ui); + + /* + ** Small integers are encoded in a single byte. Larger integers + ** require progressively more space. + */ + if( ui > 0x7f ) { + if( ui > 0x7fff ) { + if( ui > 0x7fffffL ) { + if( ui >= 0x80000000L ) { + len = 5 ; + } else { + len = 4 ; + } + } else { + len = 3 ; + } + } else { + len = 2 ; + } + } else { + len = 1 ; + } + + Sequence< sal_Int8 > serial( len ) ; + for( int i = 0 ; i < len ; i ++ ) + serial[i] = *( bb + sizeof( bb ) - len + i ) ; + + return serial ; +} + +/*- + * This is just one temporary conversion + */ +OUString bigIntegerToNumericString( Sequence< sal_Int8 > serial ) +{ + OUString aRet; + + if( serial.getLength() ) + { + long ival = 0; + + { + unsigned len = serial.getLength() ; + unsigned char *cp = ( unsigned char* )&serial[0] ; + unsigned long overflow = 0x1ffUL << (((sizeof(ival) - 1) * 8) - 1); + unsigned long ofloinit; + + if (*cp & 0x80) + ival = -1L; + ofloinit = ival & overflow; + + while (len) { + if ((ival & overflow) != ofloinit) { + return aRet; + } + ival = ival << 8; + ival |= *cp++; + --len; + } + } + + /*---------------------- + { + unsigned len = serial.getLength() ; + unsigned char *cp = ( unsigned char* )&serial[len-1] ; + unsigned long overflow = 0x1ffUL << (((sizeof(ival) - 1) * 8) - 1); + unsigned long ofloinit; + + if (*cp & 0x80) + ival = -1L; + ofloinit = ival & overflow; + + while (len) { + if ((ival & overflow) != ofloinit) { + return aRet; + } + ival = ival << 8; + ival |= *cp--; + --len; + } + } + ----------------------*/ + + { + char str[10] ; + int len ; + len = sprintf( str, "%d", ival ) ; + aRet = OUString::createFromAscii( str ) ; + } + } + + return aRet; +} + diff --git a/xmlsecurity/source/xmlsec/mscrypt/securityenvironment_mscryptimpl.hxx b/xmlsecurity/source/xmlsec/mscrypt/securityenvironment_mscryptimpl.hxx new file mode 100644 index 000000000000..bd80f566a248 --- /dev/null +++ b/xmlsecurity/source/xmlsec/mscrypt/securityenvironment_mscryptimpl.hxx @@ -0,0 +1,235 @@ +/************************************************************************* + * + * $RCSfile: securityenvironment_mscryptimpl.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:22 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _XSECURITYENVIRONMENT_MSCRYPTIMPL_HXX_ +#define _XSECURITYENVIRONMENT_MSCRYPTIMPL_HXX_ + +#ifndef _SAL_CONFIG_H_ +#include +#endif + +#ifndef _RTL_USTRING_HXX_ +#include +#endif + +#ifndef _CPPUHELPER_FACTORY_HXX_ +#include +#endif + +#ifndef _CPPUHELPER_IMPLBASE4_HXX_ +#include +#endif + +#ifndef _COM_SUN_STAR_UNO_EXCEPTION_HPP_ +#include +#endif + +#ifndef _COM_SUN_STAR_UNO_REFERENCE_HPP_ +#include +#endif + +#ifndef _COM_SUN_STAR_LANG_XSINGLESERVICEFACTORY_HPP_ +#include +#endif + +#ifndef _COM_SUN_STAR_LANG_XSECVICEINFO_HPP_ +#include +#endif + +#ifndef _COM_SUN_STAR_LANG_XINITIALIZATION_HPP_ +#include +#endif + +#ifndef _COM_SUN_STAR_XML_CRYPTO_XSECURITYENVIRONMENT_HPP_ +#include +#endif + +#ifndef _COM_SUN_STAR_SECURITY_XCERTIFICATE_HPP_ +#include +#endif + +#ifndef _COM_SUN_STAR_LANG_XUNOTUNNEL_HPP_ +#include +#endif + +#include + +#include +#include + +class SecurityEnvironment_MSCryptImpl : public ::cppu::WeakImplHelper4< + ::com::sun::star::xml::crypto::XSecurityEnvironment , + ::com::sun::star::lang::XInitialization , + ::com::sun::star::lang::XServiceInfo , + ::com::sun::star::lang::XUnoTunnel > +{ + private : + //cyrpto provider and key container + HCRYPTPROV m_hProv ; + LPCTSTR m_pszContainer ; + + //Key store + HCERTSTORE m_hKeyStore ; + + //Certiticate store + HCERTSTORE m_hCertStore ; + + //Enable default system cryptography setting + sal_Bool m_bEnableDefault ; + + //External keys + std::list< HCRYPTKEY > m_tSymKeyList ; + std::list< HCRYPTKEY > m_tPubKeyList ; + std::list< HCRYPTKEY > m_tPriKeyList ; + + //Service manager + ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xServiceManager ; + + public : + SecurityEnvironment_MSCryptImpl( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& aFactory ) ; + virtual ~SecurityEnvironment_MSCryptImpl() ; + + //Methods from XSecurityEnvironment + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::security::XCertificate > > SAL_CALL getPersonalCertificates() throw( ::com::sun::star::uno::SecurityException , ::com::sun::star::uno::RuntimeException ) ; + + virtual ::com::sun::star::uno::Reference< ::com::sun::star::security::XCertificate > SAL_CALL getCertificate( const ::rtl::OUString& issuerName, const ::com::sun::star::uno::Sequence< sal_Int8 >& serialNumber ) throw( ::com::sun::star::uno::SecurityException , ::com::sun::star::uno::RuntimeException ) ; + + virtual ::com::sun::star::uno::Reference< ::com::sun::star::security::XCertificate > SAL_CALL getCertificate( const ::rtl::OUString& issuerName, const ::rtl::OUString& serialNumber ) throw( ::com::sun::star::uno::SecurityException , ::com::sun::star::uno::RuntimeException ) ; + + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::security::XCertificate > > SAL_CALL buildCertificatePath( const ::com::sun::star::uno::Reference< ::com::sun::star::security::XCertificate >& beginCert ) throw( ::com::sun::star::uno::SecurityException , ::com::sun::star::uno::RuntimeException ) ; + + virtual ::com::sun::star::uno::Reference< ::com::sun::star::security::XCertificate > SAL_CALL createCertificateFromRaw( const ::com::sun::star::uno::Sequence< sal_Int8 >& rawCertificate ) throw( ::com::sun::star::uno::SecurityException , ::com::sun::star::uno::RuntimeException ) ; + + virtual ::com::sun::star::uno::Reference< ::com::sun::star::security::XCertificate > SAL_CALL createCertificateFromAscii( const ::rtl::OUString& asciiCertificate ) throw( ::com::sun::star::uno::SecurityException , ::com::sun::star::uno::RuntimeException ) ; + + //Methods from XInitialization + virtual void SAL_CALL initialize( + const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments + ) throw( ::com::sun::star::uno::Exception , ::com::sun::star::uno::RuntimeException ) ; + + //Methods from XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName() throw( ::com::sun::star::uno::RuntimeException ) ; + + virtual sal_Bool SAL_CALL supportsService( + const ::rtl::OUString& ServiceName + ) throw( ::com::sun::star::uno::RuntimeException ) ; + + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw( ::com::sun::star::uno::RuntimeException ) ; + + //Helper for XServiceInfo + static ::com::sun::star::uno::Sequence< ::rtl::OUString > impl_getSupportedServiceNames() ; + + static ::rtl::OUString impl_getImplementationName() throw( ::com::sun::star::uno::RuntimeException ) ; + + //Helper for registry + static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL impl_createInstance( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& aServiceManager ) throw( ::com::sun::star::uno::RuntimeException ) ; + + static ::com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleServiceFactory > impl_createFactory( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& aServiceManager ) ; + + //Methods from XUnoTunnel + virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) + throw (::com::sun::star::uno::RuntimeException); + + static const ::com::sun::star::uno::Sequence< sal_Int8 >& getUnoTunnelId() ; + static SecurityEnvironment_MSCryptImpl* getImplementation( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > xObj ) ; + + //Native mehtods + virtual HCRYPTPROV getCryptoProvider() throw( ::com::sun::star::uno::Exception , ::com::sun::star::uno::RuntimeException ) ; + + virtual void setCryptoProvider( HCRYPTPROV aProv ) throw( ::com::sun::star::uno::Exception , ::com::sun::star::uno::RuntimeException ) ; + + virtual LPCTSTR getKeyContainer() throw( ::com::sun::star::uno::Exception , ::com::sun::star::uno::RuntimeException ) ; + + virtual void setKeyContainer( LPCTSTR aKeyContainer ) throw( ::com::sun::star::uno::Exception , ::com::sun::star::uno::RuntimeException ) ; + + virtual HCERTSTORE getCryptoSlot() throw( ::com::sun::star::uno::Exception , ::com::sun::star::uno::RuntimeException ) ; + + virtual void setCryptoSlot( HCERTSTORE aKeyStore ) throw( ::com::sun::star::uno::Exception , ::com::sun::star::uno::RuntimeException ) ; + + virtual HCERTSTORE getCertDb() throw( ::com::sun::star::uno::Exception , ::com::sun::star::uno::RuntimeException ) ; + + virtual void setCertDb( HCERTSTORE aCertDb ) throw( ::com::sun::star::uno::Exception , ::com::sun::star::uno::RuntimeException ) ; + + virtual void adoptSymKey( HCRYPTKEY aSymKey ) throw( ::com::sun::star::uno::Exception , ::com::sun::star::uno::RuntimeException ) ; + + virtual void rejectSymKey( HCRYPTKEY aSymKey ) throw( ::com::sun::star::uno::Exception , ::com::sun::star::uno::RuntimeException ) ; + + virtual HCRYPTKEY getSymKey( unsigned int position ) throw( ::com::sun::star::uno::Exception , ::com::sun::star::uno::RuntimeException ) ; + + virtual void adoptPubKey( HCRYPTKEY aPubKey ) throw( ::com::sun::star::uno::Exception , ::com::sun::star::uno::RuntimeException ) ; + + virtual void rejectPubKey( HCRYPTKEY aPubKey ) throw( ::com::sun::star::uno::Exception , ::com::sun::star::uno::RuntimeException ) ; + + virtual HCRYPTKEY getPubKey( unsigned int position ) throw( ::com::sun::star::uno::Exception , ::com::sun::star::uno::RuntimeException ) ; + + virtual void adoptPriKey( HCRYPTKEY aPriKey ) throw( ::com::sun::star::uno::Exception , ::com::sun::star::uno::RuntimeException ) ; + + virtual void rejectPriKey( HCRYPTKEY aPriKey ) throw( ::com::sun::star::uno::Exception , ::com::sun::star::uno::RuntimeException ) ; + + virtual HCRYPTKEY getPriKey( unsigned int position ) throw( ::com::sun::star::uno::Exception , ::com::sun::star::uno::RuntimeException ) ; + + virtual void enableDefaultCrypt( sal_Bool enable ) throw( ::com::sun::star::uno::Exception , ::com::sun::star::uno::RuntimeException ) ; + + virtual sal_Bool defaultEnabled() throw( ::com::sun::star::uno::Exception , ::com::sun::star::uno::RuntimeException ) ; +} ; + +#endif // _XSECURITYENVIRONMENT_MSCRYPTIMPL_HXX_ + diff --git a/xmlsecurity/source/xmlsec/mscrypt/seinitializer_mscryptimpl.cxx b/xmlsecurity/source/xmlsec/mscrypt/seinitializer_mscryptimpl.cxx new file mode 100644 index 000000000000..a526634c6e0a --- /dev/null +++ b/xmlsecurity/source/xmlsec/mscrypt/seinitializer_mscryptimpl.cxx @@ -0,0 +1,269 @@ +/************************************************************************* + * + * $RCSfile: seinitializer_mscryptimpl.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:21 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#include "seinitializer_mscryptimpl.hxx" + +#include "securityenvironment_mscryptimpl.hxx" + +#include "xmlsec/strings.h" +#include "xmlsec/mscrypto/app.h" + +namespace cssu = com::sun::star::uno; +namespace cssl = com::sun::star::lang; +namespace cssxc = com::sun::star::xml::crypto; + +#define SERVICE_NAME "com.sun.star.xml.crypto.SEInitializer" +#define IMPLEMENTATION_NAME "com.sun.star.xml.security.bridge.xmlsec.SEInitializer_MSCryptImpl" +#define SECURITY_ENVIRONMENT "com.sun.star.xml.crypto.SecurityEnvironment" +#define SECURITY_CONTEXT "com.sun.star.xml.crypto.XMLSecurityContext" + +SEInitializer_MSCryptImpl::SEInitializer_MSCryptImpl( + const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > &rxMSF) + :mxMSF( rxMSF ) +{ +} + +SEInitializer_MSCryptImpl::~SEInitializer_MSCryptImpl() +{ +} + +/* XSEInitializer */ +cssu::Reference< cssxc::XXMLSecurityContext > SAL_CALL + SEInitializer_MSCryptImpl::createSecurityContext( + const rtl::OUString& sCertDB ) + throw (cssu::RuntimeException) +{ + const char* n_pCertStore ; + HCERTSTORE n_hStoreHandle ; + + //Initialize the crypto engine + if( sCertDB.getLength() > 0 ) + { + rtl::OString sCertDir(sCertDB, sCertDB.getLength(), RTL_TEXTENCODING_ASCII_US); + n_pCertStore = sCertDir.getStr(); + n_hStoreHandle = CertOpenSystemStore( NULL, n_pCertStore ) ; + if( n_hStoreHandle == NULL ) + { + return NULL; + } + } + else + { + n_pCertStore = NULL ; + n_hStoreHandle = NULL ; + } + + xmlSecMSCryptoAppInit( n_pCertStore ) ; + + try { + /* Build Security Environment */ + const rtl::OUString sSecyrutyEnvironment ( RTL_CONSTASCII_USTRINGPARAM( SECURITY_ENVIRONMENT ) ); + cssu::Reference< cssxc::XSecurityEnvironment > xSecEnv( mxMSF->createInstance ( sSecyrutyEnvironment ), cssu::UNO_QUERY ); + if( !xSecEnv.is() ) + { + if( n_hStoreHandle != NULL ) + { + CertCloseStore( n_hStoreHandle, CERT_CLOSE_STORE_FORCE_FLAG ) ; + } + + xmlSecMSCryptoAppShutdown() ; + return NULL; + } + + /* Setup key slot and certDb */ + cssu::Reference< cssl::XUnoTunnel > xEnvTunnel( xSecEnv , cssu::UNO_QUERY ) ; + if( !xEnvTunnel.is() ) + { + if( n_hStoreHandle != NULL ) + { + CertCloseStore( n_hStoreHandle, CERT_CLOSE_STORE_FORCE_FLAG ) ; + } + + xmlSecMSCryptoAppShutdown() ; + return NULL; + } + + SecurityEnvironment_MSCryptImpl* pSecEnv = ( SecurityEnvironment_MSCryptImpl* )xEnvTunnel->getSomething( SecurityEnvironment_MSCryptImpl::getUnoTunnelId() ) ; + if( pSecEnv == NULL ) + { + if( n_hStoreHandle != NULL ) + { + CertCloseStore( n_hStoreHandle, CERT_CLOSE_STORE_FORCE_FLAG ) ; + } + + xmlSecMSCryptoAppShutdown() ; + return NULL; + } + + if( n_hStoreHandle != NULL ) + { + pSecEnv->setCryptoSlot( n_hStoreHandle ) ; + pSecEnv->setCertDb( n_hStoreHandle ) ; + } + else + { + pSecEnv->enableDefaultCrypt( sal_True ) ; + } + + /* Build XML Security Context */ + const rtl::OUString sSecyrutyContext ( RTL_CONSTASCII_USTRINGPARAM( SECURITY_CONTEXT ) ); + cssu::Reference< cssxc::XXMLSecurityContext > xSecCtx( mxMSF->createInstance ( sSecyrutyContext ), cssu::UNO_QUERY ); + if( !xSecCtx.is() ) + { + if( n_hStoreHandle != NULL ) + { + CertCloseStore( n_hStoreHandle, CERT_CLOSE_STORE_FORCE_FLAG ) ; + } + + xmlSecMSCryptoAppShutdown() ; + return NULL; + } + + xSecCtx->setSecurityEnvironment( xSecEnv ) ; + return xSecCtx; + } + catch( cssu::Exception& ) + { + if( n_hStoreHandle != NULL ) + { + CertCloseStore( n_hStoreHandle, CERT_CLOSE_STORE_FORCE_FLAG ) ; + } + + xmlSecMSCryptoAppShutdown() ; + return NULL; + } +} + +void SAL_CALL SEInitializer_MSCryptImpl::freeSecurityContext( const cssu::Reference< cssxc::XXMLSecurityContext >& securityContext ) + throw (cssu::RuntimeException) +{ + /* + cssu::Reference< cssxc::XSecurityEnvironment > xSecEnv + = securityContext->getSecurityEnvironment(); + + if( xSecEnv.is() ) + { + cssu::Reference< cssl::XUnoTunnel > xEnvTunnel( xSecEnv , cssu::UNO_QUERY ) ; + if( xEnvTunnel.is() ) + { + SecurityEnvironment_MSCryptImpl* pSecEnv = ( SecurityEnvironment_MSCryptImpl* )xEnvTunnel->getSomething( SecurityEnvironment_MSCryptImpl::getUnoTunnelId() ) ; + HCERTSTORE n_hStoreHandle = pSecEnv->getCryptoSlot(); + + if( n_hStoreHandle != NULL ) + { + CertCloseStore( n_hStoreHandle, CERT_CLOSE_STORE_FORCE_FLAG ) ; + pSecEnv->setCryptoSlot( NULL ) ; + pSecEnv->setCertDb( NULL ) ; + } + + xmlSecMSCryptoAppShutdown() ; + } + } + */ + + xmlSecMSCryptoAppShutdown() ; +} + +rtl::OUString SEInitializer_MSCryptImpl_getImplementationName () + throw (cssu::RuntimeException) +{ + return rtl::OUString ( RTL_CONSTASCII_USTRINGPARAM ( IMPLEMENTATION_NAME ) ); +} + +sal_Bool SAL_CALL SEInitializer_MSCryptImpl_supportsService( const rtl::OUString& ServiceName ) + throw (cssu::RuntimeException) +{ + return ServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( SERVICE_NAME )); +} + +cssu::Sequence< rtl::OUString > SAL_CALL SEInitializer_MSCryptImpl_getSupportedServiceNames( ) + throw (cssu::RuntimeException) +{ + cssu::Sequence < rtl::OUString > aRet(1); + rtl::OUString* pArray = aRet.getArray(); + pArray[0] = rtl::OUString ( RTL_CONSTASCII_USTRINGPARAM ( SERVICE_NAME ) ); + return aRet; +} +#undef SERVICE_NAME + +cssu::Reference< cssu::XInterface > SAL_CALL SEInitializer_MSCryptImpl_createInstance( const cssu::Reference< cssl::XMultiServiceFactory > & rSMgr) + throw( cssu::Exception ) +{ + return (cppu::OWeakObject*) new SEInitializer_MSCryptImpl(rSMgr); +} + +/* XServiceInfo */ +rtl::OUString SAL_CALL SEInitializer_MSCryptImpl::getImplementationName( ) + throw (cssu::RuntimeException) +{ + return SEInitializer_MSCryptImpl_getImplementationName(); +} +sal_Bool SAL_CALL SEInitializer_MSCryptImpl::supportsService( const rtl::OUString& rServiceName ) + throw (cssu::RuntimeException) +{ + return SEInitializer_MSCryptImpl_supportsService( rServiceName ); +} +cssu::Sequence< rtl::OUString > SAL_CALL SEInitializer_MSCryptImpl::getSupportedServiceNames( ) + throw (cssu::RuntimeException) +{ + return SEInitializer_MSCryptImpl_getSupportedServiceNames(); +} + diff --git a/xmlsecurity/source/xmlsec/mscrypt/seinitializer_mscryptimpl.hxx b/xmlsecurity/source/xmlsec/mscrypt/seinitializer_mscryptimpl.hxx new file mode 100644 index 000000000000..1726e79533ad --- /dev/null +++ b/xmlsecurity/source/xmlsec/mscrypt/seinitializer_mscryptimpl.hxx @@ -0,0 +1,152 @@ +/************************************************************************* + * + * $RCSfile: seinitializer_mscryptimpl.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:21 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _SEINITIALIZERIMPL_HXX +#define _SEINITIALIZERIMPL_HXX + +#ifndef _COM_SUN_STAR_XML_CRYPTO_XXMLSECURITYCONTEXT_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_XML_CRYPTO_SEINITIALIZER_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_LANG_XUNOTUNNEL_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_ +#include +#endif +#ifndef _CPPUHELPER_IMPLBASE2_HXX_ +#include +#endif + +#include + +class SEInitializer_MSCryptImpl : public cppu::WeakImplHelper2 +< + com::sun::star::xml::crypto::XSEInitializer, + com::sun::star::lang::XServiceInfo +> +/****** SEInitializer_MSCryptImpl.hxx/CLASS SEInitializer_MSCryptImpl *********** + * + * NAME + * SEInitializer_MSCryptImpl -- Class to initialize a Security Context + * instance + * + * FUNCTION + * Use this class to initialize a XmlSec based Security Context + * instance. After this instance is used up, use this class to free this + * instance. + * + * HISTORY + * 05.01.2004 - Interface supported: XSEInitializer, XSEInitializer + * + * AUTHOR + * Michael Mi + * Email: michael.mi@sun.com + ******************************************************************************/ +{ +private: + com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > mxMSF; + +public: + SEInitializer_MSCryptImpl(const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > &rxMSF); + virtual ~SEInitializer_MSCryptImpl(); + + /* XSEInitializer */ + virtual com::sun::star::uno::Reference< + com::sun::star::xml::crypto::XXMLSecurityContext > + SAL_CALL createSecurityContext( const rtl::OUString& certDB ) + throw (com::sun::star::uno::RuntimeException); + + virtual void SAL_CALL freeSecurityContext( const com::sun::star::uno::Reference< + com::sun::star::xml::crypto::XXMLSecurityContext >& securityContext ) + throw (com::sun::star::uno::RuntimeException); + + /* XServiceInfo */ + virtual rtl::OUString SAL_CALL getImplementationName( ) + throw (com::sun::star::uno::RuntimeException); + + virtual sal_Bool SAL_CALL supportsService( const rtl::OUString& ServiceName ) + throw (com::sun::star::uno::RuntimeException); + + virtual com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames( ) + throw (com::sun::star::uno::RuntimeException); +}; + +rtl::OUString SEInitializer_MSCryptImpl_getImplementationName() + throw ( com::sun::star::uno::RuntimeException ); + +sal_Bool SAL_CALL SEInitializer_MSCryptImpl_supportsService( const rtl::OUString& ServiceName ) + throw ( com::sun::star::uno::RuntimeException ); + +com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL SEInitializer_MSCryptImpl_getSupportedServiceNames( ) + throw ( com::sun::star::uno::RuntimeException ); + +com::sun::star::uno::Reference< com::sun::star::uno::XInterface > +SAL_CALL SEInitializer_MSCryptImpl_createInstance( const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > & rSMgr) + throw ( com::sun::star::uno::Exception ); + +#endif + diff --git a/xmlsecurity/source/xmlsec/mscrypt/x509certificate_mscryptimpl.cxx b/xmlsecurity/source/xmlsec/mscrypt/x509certificate_mscryptimpl.cxx new file mode 100644 index 000000000000..b24779740a95 --- /dev/null +++ b/xmlsecurity/source/xmlsec/mscrypt/x509certificate_mscryptimpl.cxx @@ -0,0 +1,392 @@ +/************************************************************************* + * + * $RCSfile: x509certificate_mscryptimpl.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:22 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _SAL_CONFIG_H_ +#include +#endif + +#ifndef _RTL_UUID_H_ +#include +#endif + +#ifndef _X509CERTIFICATE_MSCRYPTIMPL_HXX_ +#include "x509certificate_mscryptimpl.hxx" +#endif + +#ifndef _CERTIFICATEEXTENSION_XMLSECIMPL_HXX_ +#include "certificateextension_xmlsecimpl.hxx" +#endif + +using namespace ::com::sun::star::uno ; +using namespace ::com::sun::star::security ; +using ::rtl::OUString ; + +using ::com::sun::star::security::XCertificate ; +using ::com::sun::star::util::DateTime ; + +X509Certificate_MSCryptImpl :: X509Certificate_MSCryptImpl() : + m_pCertContext( NULL ) +{ +} + +X509Certificate_MSCryptImpl :: ~X509Certificate_MSCryptImpl() { + if( m_pCertContext != NULL ) { + CertFreeCertificateContext( m_pCertContext ) ; + } +} + +//Methods from XCertificate +sal_Int16 SAL_CALL X509Certificate_MSCryptImpl :: getVersion() throw ( ::com::sun::star::uno::RuntimeException) { + if( m_pCertContext != NULL && m_pCertContext->pCertInfo != NULL ) { + return ( char )m_pCertContext->pCertInfo->dwVersion ; + } else { + return -1 ; + } +} + +::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL X509Certificate_MSCryptImpl :: getSerialNumber() throw ( ::com::sun::star::uno::RuntimeException) { + if( m_pCertContext != NULL && m_pCertContext->pCertInfo != NULL ) { + Sequence< sal_Int8 > serial( m_pCertContext->pCertInfo->SerialNumber.cbData ) ; + for( unsigned int i = 0 ; i < m_pCertContext->pCertInfo->SerialNumber.cbData ; i ++ ) + serial[i] = *( m_pCertContext->pCertInfo->SerialNumber.pbData + m_pCertContext->pCertInfo->SerialNumber.cbData - i - 1 ) ; + + return serial ; + } else { + return NULL ; + } +} + +::rtl::OUString SAL_CALL X509Certificate_MSCryptImpl :: getIssuerName() throw ( ::com::sun::star::uno::RuntimeException) { + if( m_pCertContext != NULL && m_pCertContext->pCertInfo != NULL ) { + char* issuer ; + DWORD cbIssuer ; + + cbIssuer = CertNameToStr( + X509_ASN_ENCODING | PKCS_7_ASN_ENCODING , + &( m_pCertContext->pCertInfo->Issuer ), + CERT_X500_NAME_STR | CERT_NAME_STR_REVERSE_FLAG , + NULL, 0 + ) ; + + if( cbIssuer != 0 ) { + issuer = new char[ cbIssuer ] ; + if( issuer == NULL ) + throw RuntimeException() ; + + cbIssuer = CertNameToStr( + X509_ASN_ENCODING | PKCS_7_ASN_ENCODING , + &( m_pCertContext->pCertInfo->Issuer ), + CERT_X500_NAME_STR | CERT_NAME_STR_REVERSE_FLAG , + issuer, cbIssuer + ) ; + + if( cbIssuer <= 0 ) { + delete issuer ; + throw RuntimeException() ; + } + + OUString xIssuer = OUString::createFromAscii( issuer ) ; + delete issuer ; + + return xIssuer ; + } else { + return OUString() ; + } + } else { + return OUString() ; + } +} + +::rtl::OUString SAL_CALL X509Certificate_MSCryptImpl :: getSubjectName() throw ( ::com::sun::star::uno::RuntimeException) { + if( m_pCertContext != NULL && m_pCertContext->pCertInfo != NULL ) { + char* subject ; + DWORD cbSubject ; + + cbSubject = CertNameToStr( + X509_ASN_ENCODING | PKCS_7_ASN_ENCODING , + &( m_pCertContext->pCertInfo->Subject ), + CERT_X500_NAME_STR | CERT_NAME_STR_REVERSE_FLAG , + NULL, 0 + ) ; + + if( cbSubject != 0 ) { + subject = new char[ cbSubject ] ; + if( subject == NULL ) + throw RuntimeException() ; + + cbSubject = CertNameToStr( + X509_ASN_ENCODING | PKCS_7_ASN_ENCODING , + &( m_pCertContext->pCertInfo->Subject ), + CERT_X500_NAME_STR | CERT_NAME_STR_REVERSE_FLAG , + subject, cbSubject + ) ; + + if( cbSubject <= 0 ) { + delete subject ; + throw RuntimeException() ; + } + + OUString xSubject = OUString::createFromAscii( subject ) ; + delete subject ; + + return xSubject ; + } else { + return OUString() ; + } + } else { + return OUString() ; + } +} + +::com::sun::star::util::DateTime SAL_CALL X509Certificate_MSCryptImpl :: getNotBefore() throw ( ::com::sun::star::uno::RuntimeException ) { + if( m_pCertContext != NULL && m_pCertContext->pCertInfo != NULL ) { + SYSTEMTIME explTime ; + DateTime dateTime ; + + if( FileTimeToSystemTime( &( m_pCertContext->pCertInfo->NotBefore ), &explTime ) ) { + //Convert the time to readable local time + dateTime.HundredthSeconds = explTime.wMilliseconds / 100 ; + dateTime.Seconds = explTime.wSecond ; + dateTime.Minutes = explTime.wMinute ; + dateTime.Hours = explTime.wHour ; + dateTime.Day = explTime.wDay ; + dateTime.Month = explTime.wMonth ; + dateTime.Year = explTime.wYear ; + } + + return dateTime ; + } else { + return DateTime() ; + } +} + +::com::sun::star::util::DateTime SAL_CALL X509Certificate_MSCryptImpl :: getNotAfter() throw ( ::com::sun::star::uno::RuntimeException) { + if( m_pCertContext != NULL && m_pCertContext->pCertInfo != NULL ) { + SYSTEMTIME explTime ; + DateTime dateTime ; + + if( FileTimeToSystemTime( &( m_pCertContext->pCertInfo->NotAfter ), &explTime ) ) { + //Convert the time to readable local time + dateTime.HundredthSeconds = explTime.wMilliseconds / 100 ; + dateTime.Seconds = explTime.wSecond ; + dateTime.Minutes = explTime.wMinute ; + dateTime.Hours = explTime.wHour ; + dateTime.Day = explTime.wDay ; + dateTime.Month = explTime.wMonth ; + dateTime.Year = explTime.wYear ; + } + + return dateTime ; + } else { + return DateTime() ; + } +} + +::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL X509Certificate_MSCryptImpl :: getIssuerUniqueID() throw ( ::com::sun::star::uno::RuntimeException) { + if( m_pCertContext != NULL && m_pCertContext->pCertInfo != NULL ) { + Sequence< sal_Int8 > issuerUid( m_pCertContext->pCertInfo->IssuerUniqueId.cbData ) ; + for( unsigned int i = 0 ; i < m_pCertContext->pCertInfo->IssuerUniqueId.cbData; i ++ ) + issuerUid[i] = *( m_pCertContext->pCertInfo->IssuerUniqueId.pbData + i ) ; + + return issuerUid ; + } else { + return NULL ; + } +} + +::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL X509Certificate_MSCryptImpl :: getSubjectUniqueID() throw ( ::com::sun::star::uno::RuntimeException ) { + if( m_pCertContext != NULL && m_pCertContext->pCertInfo != NULL ) { + Sequence< sal_Int8 > subjectUid( m_pCertContext->pCertInfo->SubjectUniqueId.cbData ) ; + for( unsigned int i = 0 ; i < m_pCertContext->pCertInfo->SubjectUniqueId.cbData; i ++ ) + subjectUid[i] = *( m_pCertContext->pCertInfo->SubjectUniqueId.pbData + i ) ; + + return subjectUid ; + } else { + return NULL ; + } +} + +::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::security::XCertificateExtension > > SAL_CALL X509Certificate_MSCryptImpl :: getExtensions() throw ( ::com::sun::star::uno::RuntimeException ) { + if( m_pCertContext != NULL && m_pCertContext->pCertInfo != NULL && m_pCertContext->pCertInfo->cExtension != 0 ) { + CertificateExtension_XmlSecImpl* xExtn ; + CERT_EXTENSION* pExtn ; + Sequence< Reference< XCertificateExtension > > xExtns( m_pCertContext->pCertInfo->cExtension ) ; + + for( unsigned int i = 0; i < m_pCertContext->pCertInfo->cExtension; i++ ) { + pExtn = &(m_pCertContext->pCertInfo->rgExtension[i]) ; + + xExtn = new CertificateExtension_XmlSecImpl() ; + if( xExtn == NULL ) + throw RuntimeException() ; + + xExtn->setCertExtn( pExtn->Value.pbData, pExtn->Value.cbData, ( unsigned char* )pExtn->pszObjId, strlen( pExtn->pszObjId ), pExtn->fCritical ) ; + + xExtns[i] = xExtn ; + } + + return xExtns ; + } else { + return NULL ; + } +} + +::com::sun::star::uno::Reference< ::com::sun::star::security::XCertificateExtension > SAL_CALL X509Certificate_MSCryptImpl :: findCertExtension( const ::com::sun::star::uno::Sequence< sal_Int8 >& oid ) throw (::com::sun::star::uno::RuntimeException) { + if( m_pCertContext != NULL && m_pCertContext->pCertInfo != NULL && m_pCertContext->pCertInfo->cExtension != 0 ) { + CertificateExtension_XmlSecImpl* xExtn ; + CERT_EXTENSION* pExtn ; + Sequence< Reference< XCertificateExtension > > xExtns( m_pCertContext->pCertInfo->cExtension ) ; + + xExtn = NULL ; + for( unsigned int i = 0; i < m_pCertContext->pCertInfo->cExtension; i++ ) { + pExtn = &( m_pCertContext->pCertInfo->rgExtension[i] ) ; + + //TODO: Compare the oid + if( 0 ) { + xExtn = new CertificateExtension_XmlSecImpl() ; + if( xExtn == NULL ) + throw RuntimeException() ; + + xExtn->setCertExtn( pExtn->Value.pbData, pExtn->Value.cbData, ( unsigned char* )pExtn->pszObjId, strlen( pExtn->pszObjId ), pExtn->fCritical ) ; + } + } + + return xExtn ; + } else { + return NULL ; + } +} + + +::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL X509Certificate_MSCryptImpl :: getEncoded() throw ( ::com::sun::star::uno::RuntimeException) { + if( m_pCertContext != NULL && m_pCertContext->cbCertEncoded > 0 ) { + Sequence< sal_Int8 > rawCert( m_pCertContext->cbCertEncoded ) ; + + for( unsigned int i = 0 ; i < m_pCertContext->cbCertEncoded ; i ++ ) + rawCert[i] = *( m_pCertContext->pbCertEncoded + i ) ; + + return rawCert ; + } else { + return NULL ; + } +} + +//Helper methods +void X509Certificate_MSCryptImpl :: setMswcryCert( const CERT_CONTEXT* cert ) { + if( m_pCertContext != NULL ) { + CertFreeCertificateContext( m_pCertContext ) ; + m_pCertContext = NULL ; + } + + if( cert != NULL ) { + m_pCertContext = CertDuplicateCertificateContext( cert ) ; + } +} + +const CERT_CONTEXT* X509Certificate_MSCryptImpl :: getMswcryCert() const { + if( m_pCertContext != NULL ) { + return m_pCertContext ; + } else { + return NULL ; + } +} + +void X509Certificate_MSCryptImpl :: setRawCert( Sequence< sal_Int8 > rawCert ) throw ( ::com::sun::star::uno::RuntimeException) { + if( m_pCertContext != NULL ) { + CertFreeCertificateContext( m_pCertContext ) ; + m_pCertContext = NULL ; + } + + if( rawCert.getLength() != 0 ) { + m_pCertContext = CertCreateCertificateContext( X509_ASN_ENCODING, ( const BYTE* )&rawCert[0], rawCert.getLength() ) ; + } +} + +/* XUnoTunnel */ +sal_Int64 SAL_CALL X509Certificate_MSCryptImpl :: getSomething( const Sequence< sal_Int8 >& aIdentifier ) throw( RuntimeException ) { + if( aIdentifier.getLength() == 16 && 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(), aIdentifier.getConstArray(), 16 ) ) { + return ( sal_Int64 )this ; + } + return 0 ; +} + +/* XUnoTunnel extension */ +const Sequence< sal_Int8>& X509Certificate_MSCryptImpl :: getUnoTunnelId() { + static Sequence< sal_Int8 >* pSeq = 0 ; + if( !pSeq ) { + ::osl::Guard< ::osl::Mutex > aGuard( ::osl::Mutex::getGlobalMutex() ) ; + if( !pSeq ) { + static Sequence< sal_Int8> aSeq( 16 ) ; + rtl_createUuid( ( sal_uInt8* )aSeq.getArray() , 0 , sal_True ) ; + pSeq = &aSeq ; + } + } + return *pSeq ; +} + +/* XUnoTunnel extension */ +X509Certificate_MSCryptImpl* X509Certificate_MSCryptImpl :: getImplementation( const Reference< XInterface > xObj ) { + Reference< XUnoTunnel > xUT( xObj , UNO_QUERY ) ; + if( xUT.is() ) { + return ( X509Certificate_MSCryptImpl* )xUT->getSomething( getUnoTunnelId() ) ; + } else + return NULL ; +} + diff --git a/xmlsecurity/source/xmlsec/mscrypt/x509certificate_mscryptimpl.hxx b/xmlsecurity/source/xmlsec/mscrypt/x509certificate_mscryptimpl.hxx new file mode 100644 index 000000000000..ac184938cf35 --- /dev/null +++ b/xmlsecurity/source/xmlsec/mscrypt/x509certificate_mscryptimpl.hxx @@ -0,0 +1,147 @@ +/************************************************************************* + * + * $RCSfile: x509certificate_mscryptimpl.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:22 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _X509CERTIFICATE_MSCRYPTIMPL_HXX_ +#define _X509CERTIFICATE_MSCRYPTIMPL_HXX_ + +#ifndef _SAL_CONFIG_H_ +#include +#endif + +#ifndef _RTL_USTRING_HXX_ +#include +#endif + +#ifndef _CPPUHELPER_FACTORY_HXX_ +#include +#endif + +#ifndef _CPPUHELPER_IMPLBASE2_HXX_ +#include +#endif + +#ifndef _COM_SUN_STAR_UNO_EXCEPTION_HPP_ +#include +#endif + +#ifndef _COM_SUN_STAR_LANG_XUNOTUNNEL_HPP_ +#include +#endif + +#ifndef _COM_SUN_STAR_UNO_SECURITYEXCEPTION_HPP_ +#include +#endif + +#ifndef _COM_SUN_STAR_SECURITY_XCERTIFICATE_HPP_ +#include +#endif + +#include "Windows.h" +#include "WinCrypt.h" + +class X509Certificate_MSCryptImpl : public ::cppu::WeakImplHelper2< + ::com::sun::star::security::XCertificate , + ::com::sun::star::lang::XUnoTunnel > +{ + private : + const CERT_CONTEXT* m_pCertContext ; + + public : + X509Certificate_MSCryptImpl() ; + virtual ~X509Certificate_MSCryptImpl() ; + + //Methods from XCertificate + virtual sal_Int16 SAL_CALL getVersion() throw ( ::com::sun::star::uno::RuntimeException) ; + + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getSerialNumber() throw ( ::com::sun::star::uno::RuntimeException) ; + + virtual ::rtl::OUString SAL_CALL getIssuerName() throw ( ::com::sun::star::uno::RuntimeException) ; + + virtual ::rtl::OUString SAL_CALL getSubjectName() throw ( ::com::sun::star::uno::RuntimeException) ; + + virtual ::com::sun::star::util::DateTime SAL_CALL getNotBefore() throw ( ::com::sun::star::uno::RuntimeException) ; + + virtual ::com::sun::star::util::DateTime SAL_CALL getNotAfter() throw ( ::com::sun::star::uno::RuntimeException) ; + + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getIssuerUniqueID() throw ( ::com::sun::star::uno::RuntimeException) ; + + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getSubjectUniqueID() throw ( ::com::sun::star::uno::RuntimeException) ; + + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::security::XCertificateExtension > > SAL_CALL getExtensions() throw ( ::com::sun::star::uno::RuntimeException) ; + + virtual ::com::sun::star::uno::Reference< ::com::sun::star::security::XCertificateExtension > SAL_CALL findCertExtension( const ::com::sun::star::uno::Sequence< sal_Int8 >& oid ) throw (::com::sun::star::uno::RuntimeException) ; + + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getEncoded() throw ( ::com::sun::star::uno::RuntimeException) ; + + //Methods from XUnoTunnel + virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw (com::sun::star::uno::RuntimeException); + + static const ::com::sun::star::uno::Sequence< sal_Int8 >& getUnoTunnelId() ; + static X509Certificate_MSCryptImpl* getImplementation( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > xObj ) ; + + //Helper methods + void setMswcryCert( const CERT_CONTEXT* cert ) ; + const CERT_CONTEXT* getMswcryCert() const ; + void setRawCert( ::com::sun::star::uno::Sequence< sal_Int8 > rawCert ) throw ( ::com::sun::star::uno::RuntimeException) ; +} ; + +#endif // _X509CERTIFICATE_MSCRYPTIMPL_HXX_ + diff --git a/xmlsecurity/source/xmlsec/mscrypt/xmlencryption_mscryptimpl.cxx b/xmlsecurity/source/xmlsec/mscrypt/xmlencryption_mscryptimpl.cxx new file mode 100644 index 000000000000..9a4f0a0e6cc7 --- /dev/null +++ b/xmlsecurity/source/xmlsec/mscrypt/xmlencryption_mscryptimpl.cxx @@ -0,0 +1,403 @@ +/************************************************************************* + * + * $RCSfile: xmlencryption_mscryptimpl.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:22 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _SAL_CONFIG_H_ +#include +#endif + +#ifndef _RTL_UUID_H_ +#include +#endif + +#ifndef _XMLENCRYPTION_MSCRYPTIMPL_HXX_ +#include "xmlencryption_mscryptimpl.hxx" +#endif + +#ifndef _XMLDOCUMENTWRAPPER_XMLSECIMPL_HXX_ +#include "xmldocumentwrapper_xmlsecimpl.hxx" +#endif + +#ifndef _XMLELEMENTWRAPPER_XMLSECIMPL_HXX_ +#include "xmlelementwrapper_xmlsecimpl.hxx" +#endif + +#ifndef _XMLSECURITYCONTEXT_MSCRYPTIMPL_HXX_ +#include "xmlsecuritycontext_mscryptimpl.hxx" +#endif + +#include "xmlsec/xmlsec.h" +#include "xmlsec/xmltree.h" +#include "xmlsec/xmlenc.h" +#include "xmlsec/crypto.h" + +#ifdef UNX +#define stricmp strcasecmp +#endif + +using namespace ::com::sun::star::uno ; +using namespace ::com::sun::star::lang ; +using ::com::sun::star::lang::XMultiServiceFactory ; +using ::com::sun::star::lang::XSingleServiceFactory ; +using ::rtl::OUString ; + +using ::com::sun::star::xml::wrapper::XXMLElementWrapper ; +using ::com::sun::star::xml::wrapper::XXMLDocumentWrapper ; +using ::com::sun::star::xml::crypto::XSecurityEnvironment ; +using ::com::sun::star::xml::crypto::XXMLEncryption ; +using ::com::sun::star::xml::crypto::XXMLEncryptionTemplate ; +using ::com::sun::star::xml::crypto::XXMLSecurityContext ; + +XMLEncryption_MSCryptImpl :: XMLEncryption_MSCryptImpl( const Reference< XMultiServiceFactory >& aFactory ) : m_xServiceManager( aFactory ) { +} + +XMLEncryption_MSCryptImpl :: ~XMLEncryption_MSCryptImpl() { +} + +/* XXMLEncryption */ +Reference< XXMLEncryptionTemplate > +SAL_CALL XMLEncryption_MSCryptImpl :: encrypt( + const Reference< XXMLEncryptionTemplate >& aTemplate , + const Reference< XXMLSecurityContext >& aSecurityCtx +) throw( com::sun::star::xml::crypto::XMLEncryptionException, + com::sun::star::uno::SecurityException ) +{ + xmlSecKeysMngrPtr pMngr = NULL ; + xmlSecEncCtxPtr pEncCtx = NULL ; + xmlNodePtr pEncryptedData = NULL ; + xmlNodePtr pEncryptedKey = NULL ; + xmlNodePtr pContent = NULL ; + + if( !aTemplate.is() ) + throw RuntimeException() ; + + if( !aSecurityCtx.is() ) + throw RuntimeException() ; + + //Get Keys Manager + Reference< XUnoTunnel > xSecTunnel( aSecurityCtx , UNO_QUERY ) ; + if( !xSecTunnel.is() ) { + throw RuntimeException() ; + } + + XMLSecurityContext_MSCryptImpl* pSecCtxt = ( XMLSecurityContext_MSCryptImpl* )xSecTunnel->getSomething( XMLSecurityContext_MSCryptImpl::getUnoTunnelId() ) ; + if( pSecCtxt == NULL ) + throw RuntimeException() ; + + pMngr = pSecCtxt->keysManager() ; + + + //Create Encryption context + pEncCtx = xmlSecEncCtxCreate( pMngr ) ; + if( pEncCtx == NULL ) + throw RuntimeException() ; + + + //Get the encryption template + Reference< XXMLElementWrapper > xTemplate = aTemplate->getTemplate() ; + if( !xTemplate.is() ) { + xmlSecEncCtxDestroy( pEncCtx ) ; + throw RuntimeException() ; + } + + Reference< XUnoTunnel > xTplTunnel( xTemplate , UNO_QUERY ) ; + if( !xTplTunnel.is() ) { + xmlSecEncCtxDestroy( pEncCtx ) ; + throw RuntimeException() ; + } + + XMLElementWrapper_XmlSecImpl* pTemplate = ( XMLElementWrapper_XmlSecImpl* )xTplTunnel->getSomething( XMLElementWrapper_XmlSecImpl::getUnoTunnelImplementationId() ) ; + if( pTemplate == NULL ) { + xmlSecEncCtxDestroy( pEncCtx ) ; + throw RuntimeException() ; + } + + pEncryptedData = pTemplate->getNativeElement() ; + + //Find the element to be encrypted. + //This element is wrapped in the CipherValue sub-element. + xmlNodePtr pCipherData = pEncryptedData->children; + while (pCipherData != NULL && stricmp((const char *)(pCipherData->name), "CipherData")) + { + pCipherData = pCipherData->next; + } + + if( pCipherData == NULL ) { + xmlSecEncCtxDestroy( pEncCtx ) ; + throw RuntimeException() ; + } + + xmlNodePtr pCipherValue = pCipherData->children; + while (pCipherValue != NULL && stricmp((const char *)(pCipherValue->name), "CipherValue")) + { + pCipherValue = pCipherValue->next; + } + + if( pCipherValue == NULL ) { + xmlSecEncCtxDestroy( pEncCtx ) ; + throw RuntimeException() ; + } + + pContent = pCipherValue->children; + + if( pContent == NULL ) { + xmlSecEncCtxDestroy( pEncCtx ) ; + throw RuntimeException() ; + } + + xmlUnlinkNode(pContent); + xmlAddNextSibling(pEncryptedData, pContent); + + //remember the position of the element to be signed + sal_Bool isParentRef = sal_True; + xmlNodePtr pParent = pEncryptedData->parent; + xmlNodePtr referenceNode; + + if (pEncryptedData == pParent->children) + { + referenceNode = pParent; + } + else + { + referenceNode = pEncryptedData->prev; + isParentRef = sal_False; + } + + //Encrypt the template + if( xmlSecEncCtxXmlEncrypt( pEncCtx , pEncryptedData , pContent ) < 0 ) { + xmlSecEncCtxDestroy( pEncCtx ) ; + throw RuntimeException() ; + } + + xmlSecEncCtxDestroy( pEncCtx ) ; + + //get the new EncryptedData element + if (isParentRef) + { + pTemplate->setNativeElement(referenceNode->children) ; + } + else + { + pTemplate->setNativeElement(referenceNode->next); + } + + return aTemplate ; +} + +/* XXMLEncryption */ +Reference< XXMLElementWrapper > SAL_CALL +XMLEncryption_MSCryptImpl :: decrypt( + const Reference< XXMLEncryptionTemplate >& aTemplate , + const Reference< XXMLSecurityContext >& aSecurityCtx +) throw( com::sun::star::xml::crypto::XMLEncryptionException , + com::sun::star::uno::SecurityException) { + xmlSecKeysMngrPtr pMngr = NULL ; + xmlSecEncCtxPtr pEncCtx = NULL ; + xmlNodePtr pEncryptedData = NULL ; + xmlNodePtr pContent = NULL ; + + if( !aTemplate.is() ) + throw RuntimeException() ; + + if( !aSecurityCtx.is() ) + throw RuntimeException() ; + + //Get Keys Manager + Reference< XUnoTunnel > xSecTunnel( aSecurityCtx , UNO_QUERY ) ; + if( !xSecTunnel.is() ) { + throw RuntimeException() ; + } + + XMLSecurityContext_MSCryptImpl* pSecCtxt = ( XMLSecurityContext_MSCryptImpl* )xSecTunnel->getSomething( XMLSecurityContext_MSCryptImpl::getUnoTunnelId() ) ; + if( pSecCtxt == NULL ) + throw RuntimeException() ; + + pMngr = pSecCtxt->keysManager() ; + + + //Create Encryption context + pEncCtx = xmlSecEncCtxCreate( pMngr ) ; + if( pEncCtx == NULL ) + throw RuntimeException() ; + + + //Get the encryption template + Reference< XXMLElementWrapper > xTemplate = aTemplate->getTemplate() ; + if( !xTemplate.is() ) { + xmlSecEncCtxDestroy( pEncCtx ) ; + throw RuntimeException() ; + } + + Reference< XUnoTunnel > xTplTunnel( xTemplate , UNO_QUERY ) ; + if( !xTplTunnel.is() ) { + xmlSecEncCtxDestroy( pEncCtx ) ; + throw RuntimeException() ; + } + + XMLElementWrapper_XmlSecImpl* pTemplate = ( XMLElementWrapper_XmlSecImpl* )xTplTunnel->getSomething( XMLElementWrapper_XmlSecImpl::getUnoTunnelImplementationId() ) ; + if( pTemplate == NULL ) { + xmlSecEncCtxDestroy( pEncCtx ) ; + throw RuntimeException() ; + } + + pEncryptedData = pTemplate->getNativeElement() ; + + //remember the position of the element to be signed + sal_Bool isParentRef = sal_True; + xmlNodePtr pParent = pEncryptedData->parent; + xmlNodePtr referenceNode; + + if (pEncryptedData == pParent->children) + { + referenceNode = pParent; + } + else + { + referenceNode = pEncryptedData->prev; + isParentRef = sal_False; + } + + //Decrypt the template + if( xmlSecEncCtxDecrypt( pEncCtx , pEncryptedData ) < 0 || pEncCtx->result == NULL ) { + xmlSecEncCtxDestroy( pEncCtx ) ; + throw RuntimeException() ; + } + /*---------------------------------------- + if( pEncCtx->resultReplaced != 0 ) { + pContent = pEncryptedData ; + + Reference< XUnoTunnel > xTunnel( ret , UNO_QUERY ) ; + if( !xTunnel.is() ) { + xmlSecEncCtxDestroy( pEncCtx ) ; + throw RuntimeException() ; + } + XMLElementWrapper_XmlSecImpl* pNode = ( XMLElementWrapper_XmlSecImpl* )xTunnel->getSomething( XMLElementWrapper_XmlSecImpl::getUnoTunnelImplementationId() ) ; + if( pNode == NULL ) { + xmlSecEncCtxDestroy( pEncCtx ) ; + throw RuntimeException() ; + } + + pNode->setNativeElement( pContent ) ; + } else { + xmlSecEncCtxDestroy( pEncCtx ) ; + throw RuntimeException() ; + } + ----------------------------------------*/ + + //Destroy the encryption context + xmlSecEncCtxDestroy( pEncCtx ) ; + + //get the decrypted element + XMLElementWrapper_XmlSecImpl * ret = new XMLElementWrapper_XmlSecImpl(isParentRef? + (referenceNode->children):(referenceNode->next)); + + return ret; +} + +/* XInitialization */ +void SAL_CALL XMLEncryption_MSCryptImpl :: initialize( const Sequence< Any >& aArguments ) throw( Exception, RuntimeException ) { + // TBD +} ; + +/* XServiceInfo */ +OUString SAL_CALL XMLEncryption_MSCryptImpl :: getImplementationName() throw( RuntimeException ) { + return impl_getImplementationName() ; +} + +/* XServiceInfo */ +sal_Bool SAL_CALL XMLEncryption_MSCryptImpl :: supportsService( const OUString& serviceName) throw( RuntimeException ) { + Sequence< OUString > seqServiceNames = getSupportedServiceNames() ; + const OUString* pArray = seqServiceNames.getConstArray() ; + for( sal_Int32 i = 0 ; i < seqServiceNames.getLength() ; i ++ ) { + if( *( pArray + i ) == serviceName ) + return sal_True ; + } + return sal_False ; +} + +/* XServiceInfo */ +Sequence< OUString > SAL_CALL XMLEncryption_MSCryptImpl :: getSupportedServiceNames() throw( RuntimeException ) { + return impl_getSupportedServiceNames() ; +} + +//Helper for XServiceInfo +Sequence< OUString > XMLEncryption_MSCryptImpl :: impl_getSupportedServiceNames() { + ::osl::Guard< ::osl::Mutex > aGuard( ::osl::Mutex::getGlobalMutex() ) ; + Sequence< OUString > seqServiceNames( 1 ) ; + seqServiceNames.getArray()[0] = OUString::createFromAscii( "com.sun.star.xml.crypto.XMLEncryption" ) ; + return seqServiceNames ; +} + +OUString XMLEncryption_MSCryptImpl :: impl_getImplementationName() throw( RuntimeException ) { + return OUString::createFromAscii( "com.sun.star.xml.security.bridge.xmlsec.XMLEncryption_MSCryptImpl" ) ; +} + +//Helper for registry +Reference< XInterface > SAL_CALL XMLEncryption_MSCryptImpl :: impl_createInstance( const Reference< XMultiServiceFactory >& aServiceManager ) throw( RuntimeException ) { + return Reference< XInterface >( *new XMLEncryption_MSCryptImpl( aServiceManager ) ) ; +} + +Reference< XSingleServiceFactory > XMLEncryption_MSCryptImpl :: impl_createFactory( const Reference< XMultiServiceFactory >& aServiceManager ) { + //Reference< XSingleServiceFactory > xFactory ; + //xFactory = ::cppu::createSingleFactory( aServiceManager , impl_getImplementationName , impl_createInstance , impl_getSupportedServiceNames ) ; + //return xFactory ; + return ::cppu::createSingleFactory( aServiceManager , impl_getImplementationName() , impl_createInstance , impl_getSupportedServiceNames() ) ; +} + diff --git a/xmlsecurity/source/xmlsec/mscrypt/xmlencryption_mscryptimpl.hxx b/xmlsecurity/source/xmlsec/mscrypt/xmlencryption_mscryptimpl.hxx new file mode 100644 index 000000000000..a65fa54cefd7 --- /dev/null +++ b/xmlsecurity/source/xmlsec/mscrypt/xmlencryption_mscryptimpl.hxx @@ -0,0 +1,165 @@ +/************************************************************************* + * + * $RCSfile: xmlencryption_mscryptimpl.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:22 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _XMLENCRYPTION_MSCRYPTIMPL_HXX_ +#define _XMLENCRYPTION_MSCRYPTIMPL_HXX_ + +#ifndef _SAL_CONFIG_H_ +#include +#endif + +#ifndef _RTL_USTRING_HXX_ +#include +#endif + +#ifndef _CPPUHELPER_FACTORY_HXX_ +#include +#endif + +#ifndef _CPPUHELPER_IMPLBASE3_HXX_ +#include +#endif + +#ifndef _COM_SUN_STAR_UNO_EXCEPTION_HPP_ +#include +#endif + +#ifndef _COM_SUN_STAR_UNO_REFERENCE_HPP_ +#include +#endif + +#ifndef _COM_SUN_STAR_LANG_XSINGLESERVICEFACTORY_HPP_ +#include +#endif + +#ifndef _COM_SUN_STAR_LANG_XSECVICEINFO_HPP_ +#include +#endif + +#ifndef _COM_SUN_STAR_LANG_XINITIALIZATION_HPP_ +#include +#endif + +#ifndef _COM_SUN_STAR_XML_CRYPTO_XXMLENCRYPTION_HPP_ +#include +#endif + +#ifndef _COM_SUN_STAR_XML_CRYPTO_XXMLENCRYPTIONTEMPLATE_HPP_ +#include +#endif + +#ifndef _COM_SUN_STAR_XML_CRYPTO_XXMLSECURITYCONTEXT_HPP_ +#include +#endif + +class XMLEncryption_MSCryptImpl : public ::cppu::WeakImplHelper3< + ::com::sun::star::xml::crypto::XXMLEncryption , + ::com::sun::star::lang::XInitialization , + ::com::sun::star::lang::XServiceInfo > +{ + private : + ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xServiceManager ; + + public : + XMLEncryption_MSCryptImpl( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& aFactory ) ; + virtual ~XMLEncryption_MSCryptImpl() ; + + //Methods from XXMLEncryption + virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::crypto::XXMLEncryptionTemplate > SAL_CALL encrypt( + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::crypto::XXMLEncryptionTemplate >& aTemplate , + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::crypto::XXMLSecurityContext >& aContext) + // ) throw( ::com::sun::star::uno::Exception , ::com::sun::star::uno::RuntimeException ) ; + throw ( com::sun::star::xml::crypto::XMLEncryptionException , + com::sun::star::uno::SecurityException); + + virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::wrapper::XXMLElementWrapper > SAL_CALL decrypt( + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::crypto::XXMLEncryptionTemplate >& aTemplate , + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::crypto::XXMLSecurityContext >& aContext + ) throw( com::sun::star::xml::crypto::XMLEncryptionException , + com::sun::star::uno::SecurityException) ; + + //Methods from XInitialization + virtual void SAL_CALL initialize( + const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments + ) throw( ::com::sun::star::uno::Exception , ::com::sun::star::uno::RuntimeException ) ; + + //Methods from XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName() throw( ::com::sun::star::uno::RuntimeException ) ; + + virtual sal_Bool SAL_CALL supportsService( + const ::rtl::OUString& ServiceName + ) throw( ::com::sun::star::uno::RuntimeException ) ; + + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw( ::com::sun::star::uno::RuntimeException ) ; + + //Helper for XServiceInfo + static ::com::sun::star::uno::Sequence< ::rtl::OUString > impl_getSupportedServiceNames() ; + + static ::rtl::OUString impl_getImplementationName() throw( ::com::sun::star::uno::RuntimeException ) ; + + //Helper for registry + static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL impl_createInstance( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& aServiceManager ) throw( ::com::sun::star::uno::RuntimeException ) ; + + static ::com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleServiceFactory > impl_createFactory( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& aServiceManager ) ; +} ; + +#endif // _XMLENCRYPTION_MSCRYPTIMPL_HXX_ + diff --git a/xmlsecurity/source/xmlsec/mscrypt/xmlsecuritycontext_mscryptimpl.cxx b/xmlsecurity/source/xmlsec/mscrypt/xmlsecuritycontext_mscryptimpl.cxx new file mode 100644 index 000000000000..41119ad96eab --- /dev/null +++ b/xmlsecurity/source/xmlsec/mscrypt/xmlsecuritycontext_mscryptimpl.cxx @@ -0,0 +1,331 @@ +/************************************************************************* + * + * $RCSfile: xmlsecuritycontext_mscryptimpl.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:22 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _SAL_CONFIG_H_ +#include +#endif + +#ifndef _RTL_UUID_H_ +#include +#endif + +#ifndef _XSECURITYENVIRONMENT_MSCRYPTIMPL_HXX_ +#include "securityenvironment_mscryptimpl.hxx" +#endif + +#ifndef _XMLSECURITYCONTEXT_MSCRYPTIMPL_HXX_ +#include "xmlsecuritycontext_mscryptimpl.hxx" +#endif + +#ifndef _XMLSTREAMIO_XMLSECIMPL_HXX_ +#include "xmlstreamio.hxx" +#endif + +#include "xmlsec/xmlsec.h" +#include "xmlsec/keysmngr.h" +#include "xmlsec/crypto.h" +#include "xmlsec/mscrypto/akmngr.h" + +using namespace ::com::sun::star::uno ; +using namespace ::com::sun::star::lang ; +using ::com::sun::star::lang::XMultiServiceFactory ; +using ::com::sun::star::lang::XSingleServiceFactory ; +using ::rtl::OUString ; + +using ::com::sun::star::xml::crypto::XSecurityEnvironment ; +using ::com::sun::star::xml::crypto::XXMLSecurityContext ; + +XMLSecurityContext_MSCryptImpl :: XMLSecurityContext_MSCryptImpl( const Reference< XMultiServiceFactory >& aFactory ) : m_pKeysMngr( NULL ) , m_xServiceManager( aFactory ) , m_xSecurityEnvironment( NULL ) { + //Init xmlsec library + if( xmlSecInit() < 0 ) { + throw RuntimeException() ; + } + + //Init xmlsec crypto engine library + if( xmlSecCryptoInit() < 0 ) { + xmlSecShutdown() ; + throw RuntimeException() ; + } + + //Enable external stream handlers + if( xmlEnableStreamInputCallbacks() < 0 ) { + xmlSecCryptoShutdown() ; + xmlSecShutdown() ; + throw RuntimeException() ; + } +} + +XMLSecurityContext_MSCryptImpl :: ~XMLSecurityContext_MSCryptImpl() { + if( m_pKeysMngr != NULL ) { + xmlSecKeysMngrDestroy( m_pKeysMngr ) ; + } + + xmlDisableStreamInputCallbacks() ; + xmlSecCryptoShutdown() ; + xmlSecShutdown() ; +} + +/* XXMLSecurityContext */ +void SAL_CALL XMLSecurityContext_MSCryptImpl :: setSecurityEnvironment( const Reference< XSecurityEnvironment >& aSecurityEnvironment ) throw( com::sun::star::security::SecurityInfrastructureException ) { + HCERTSTORE hkeyStore ; + HCERTSTORE hCertStore ; + HCRYPTKEY symKey ; + HCRYPTKEY pubKey ; + HCRYPTKEY priKey ; + unsigned int i ; + + if( !aSecurityEnvironment.is() ) + throw RuntimeException() ; + + m_xSecurityEnvironment = aSecurityEnvironment ; + + //Clear key manager + if( m_pKeysMngr != NULL ) { + xmlSecKeysMngrDestroy( m_pKeysMngr ) ; + m_pKeysMngr = NULL ; + } + + //Create key manager + Reference< XUnoTunnel > xEnvTunnel( m_xSecurityEnvironment , UNO_QUERY ) ; + if( !xEnvTunnel.is() ) { + throw RuntimeException() ; + } + + SecurityEnvironment_MSCryptImpl* pSecEnv = ( SecurityEnvironment_MSCryptImpl* )xEnvTunnel->getSomething( SecurityEnvironment_MSCryptImpl::getUnoTunnelId() ) ; + if( pSecEnv == NULL ) + throw RuntimeException() ; + + hkeyStore = pSecEnv->getCryptoSlot() ; + hCertStore = pSecEnv->getCertDb() ; + + /*- + * The following lines is based on the of xmlsec-mscrypto crypto engine + */ + m_pKeysMngr = xmlSecMSCryptoAppliedKeysMngrCreate( hkeyStore , hCertStore ) ; + if( m_pKeysMngr == NULL ) + throw RuntimeException() ; + + /*- + * Adopt symmetric key into keys manager + */ + for( i = 0 ; ( symKey = pSecEnv->getSymKey( i ) ) != NULL ; i ++ ) { + if( xmlSecMSCryptoAppliedKeysMngrSymKeyLoad( m_pKeysMngr, symKey ) < 0 ) { + throw RuntimeException() ; + } + } + + /*- + * Adopt asymmetric public key into keys manager + */ + for( i = 0 ; ( pubKey = pSecEnv->getPubKey( i ) ) != NULL ; i ++ ) { + if( xmlSecMSCryptoAppliedKeysMngrPubKeyLoad( m_pKeysMngr, pubKey ) < 0 ) { + throw RuntimeException() ; + } + } + + /*- + * Adopt asymmetric private key into keys manager + */ + for( i = 0 ; ( priKey = pSecEnv->getPriKey( i ) ) != NULL ; i ++ ) { + if( xmlSecMSCryptoAppliedKeysMngrPriKeyLoad( m_pKeysMngr, priKey ) < 0 ) { + throw RuntimeException() ; + } + } + + /*- + * Adopt system default certificate store. + */ + if( pSecEnv->defaultEnabled() ) { + HCERTSTORE hSystemStore ; + + //Add system key store into the keys manager. + hSystemStore = CertOpenSystemStore( 0, "MY" ) ; + if( hSystemStore != NULL ) { + if( xmlSecMSCryptoAppliedKeysMngrAdoptKeyStore( m_pKeysMngr, hSystemStore ) < 0 ) { + CertCloseStore( hSystemStore, CERT_CLOSE_STORE_CHECK_FLAG ) ; + throw RuntimeException() ; + } + } + + //Add system root store into the keys manager. + hSystemStore = CertOpenSystemStore( 0, "Root" ) ; + if( hSystemStore != NULL ) { + if( xmlSecMSCryptoAppliedKeysMngrAdoptTrustedStore( m_pKeysMngr, hSystemStore ) < 0 ) { + CertCloseStore( hSystemStore, CERT_CLOSE_STORE_CHECK_FLAG ) ; + throw RuntimeException() ; + } + } + + //Add system trusted store into the keys manager. + hSystemStore = CertOpenSystemStore( 0, "Trust" ) ; + if( hSystemStore != NULL ) { + if( xmlSecMSCryptoAppliedKeysMngrAdoptUntrustedStore( m_pKeysMngr, hSystemStore ) < 0 ) { + CertCloseStore( hSystemStore, CERT_CLOSE_STORE_CHECK_FLAG ) ; + throw RuntimeException() ; + } + } + + //Add system CA store into the keys manager. + hSystemStore = CertOpenSystemStore( 0, "CA" ) ; + if( hSystemStore != NULL ) { + if( xmlSecMSCryptoAppliedKeysMngrAdoptUntrustedStore( m_pKeysMngr, hSystemStore ) < 0 ) { + CertCloseStore( hSystemStore, CERT_CLOSE_STORE_CHECK_FLAG ) ; + throw RuntimeException() ; + } + } + } +} + +/* XXMLSecurityContext */ +Reference< XSecurityEnvironment > SAL_CALL XMLSecurityContext_MSCryptImpl :: getSecurityEnvironment() + throw (RuntimeException) +{ + return m_xSecurityEnvironment ; +} + +/* XInitialization */ +void SAL_CALL XMLSecurityContext_MSCryptImpl :: initialize( const Sequence< Any >& aArguments ) throw( Exception, RuntimeException ) { + // TBD +} ; + +/* XServiceInfo */ +OUString SAL_CALL XMLSecurityContext_MSCryptImpl :: getImplementationName() throw( RuntimeException ) { + return impl_getImplementationName() ; +} + +/* XServiceInfo */ +sal_Bool SAL_CALL XMLSecurityContext_MSCryptImpl :: supportsService( const OUString& serviceName) throw( RuntimeException ) { + Sequence< OUString > seqServiceNames = getSupportedServiceNames() ; + const OUString* pArray = seqServiceNames.getConstArray() ; + for( sal_Int32 i = 0 ; i < seqServiceNames.getLength() ; i ++ ) { + if( *( pArray + i ) == serviceName ) + return sal_True ; + } + return sal_False ; +} + +/* XServiceInfo */ +Sequence< OUString > SAL_CALL XMLSecurityContext_MSCryptImpl :: getSupportedServiceNames() throw( RuntimeException ) { + return impl_getSupportedServiceNames() ; +} + +//Helper for XServiceInfo +Sequence< OUString > XMLSecurityContext_MSCryptImpl :: impl_getSupportedServiceNames() { + ::osl::Guard< ::osl::Mutex > aGuard( ::osl::Mutex::getGlobalMutex() ) ; + Sequence< OUString > seqServiceNames( 1 ) ; + seqServiceNames.getArray()[0] = OUString::createFromAscii( "com.sun.star.xml.crypto.XMLSecurityContext" ) ; + return seqServiceNames ; +} + +OUString XMLSecurityContext_MSCryptImpl :: impl_getImplementationName() throw( RuntimeException ) { + return OUString::createFromAscii( "com.sun.star.xml.security.bridge.xmlsec.XMLSecurityContext_MSCryptImpl" ) ; +} + +//Helper for registry +Reference< XInterface > SAL_CALL XMLSecurityContext_MSCryptImpl :: impl_createInstance( const Reference< XMultiServiceFactory >& aServiceManager ) throw( RuntimeException ) { + return Reference< XInterface >( *new XMLSecurityContext_MSCryptImpl( aServiceManager ) ) ; +} + +Reference< XSingleServiceFactory > XMLSecurityContext_MSCryptImpl :: impl_createFactory( const Reference< XMultiServiceFactory >& aServiceManager ) { + //Reference< XSingleServiceFactory > xFactory ; + //xFactory = ::cppu::createSingleFactory( aServiceManager , impl_getImplementationName , impl_createInstance , impl_getSupportedServiceNames ) ; + //return xFactory ; + return ::cppu::createSingleFactory( aServiceManager , impl_getImplementationName() , impl_createInstance , impl_getSupportedServiceNames() ) ; +} + +/* XUnoTunnel */ +sal_Int64 SAL_CALL XMLSecurityContext_MSCryptImpl :: getSomething( const Sequence< sal_Int8 >& aIdentifier ) +throw (RuntimeException) +{ + if( aIdentifier.getLength() == 16 && 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(), aIdentifier.getConstArray(), 16 ) ) { + return ( sal_Int64 )this ; + } + return 0 ; +} + +/* XUnoTunnel extension */ +const Sequence< sal_Int8>& XMLSecurityContext_MSCryptImpl :: getUnoTunnelId() { + static Sequence< sal_Int8 >* pSeq = 0 ; + if( !pSeq ) { + ::osl::Guard< ::osl::Mutex > aGuard( ::osl::Mutex::getGlobalMutex() ) ; + if( !pSeq ) { + static Sequence< sal_Int8> aSeq( 16 ) ; + rtl_createUuid( ( sal_uInt8* )aSeq.getArray() , 0 , sal_True ) ; + pSeq = &aSeq ; + } + } + return *pSeq ; +} + +/* XUnoTunnel extension */ +XMLSecurityContext_MSCryptImpl* XMLSecurityContext_MSCryptImpl :: getImplementation( const Reference< XInterface > xObj ) { + Reference< XUnoTunnel > xUT( xObj , UNO_QUERY ) ; + if( xUT.is() ) { + return ( XMLSecurityContext_MSCryptImpl* )xUT->getSomething( getUnoTunnelId() ) ; + } else + return NULL ; +} + +/* Native methods */ +xmlSecKeysMngrPtr XMLSecurityContext_MSCryptImpl :: keysManager() throw( Exception, RuntimeException ) { + return m_pKeysMngr ; +} + diff --git a/xmlsecurity/source/xmlsec/mscrypt/xmlsecuritycontext_mscryptimpl.hxx b/xmlsecurity/source/xmlsec/mscrypt/xmlsecuritycontext_mscryptimpl.hxx new file mode 100644 index 000000000000..bc8143350c27 --- /dev/null +++ b/xmlsecurity/source/xmlsec/mscrypt/xmlsecuritycontext_mscryptimpl.hxx @@ -0,0 +1,174 @@ +/************************************************************************* + * + * $RCSfile: xmlsecuritycontext_mscryptimpl.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:22 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _XMLSIGNATURECONTEXT_MSCRYPTIMPL_HXX_ +#define _XMLSIGNATURECONTEXT_MSCRYPTIMPL_HXX_ + +#ifndef _SAL_CONFIG_H_ +#include +#endif + +#ifndef _RTL_USTRING_HXX_ +#include +#endif + +#ifndef _CPPUHELPER_FACTORY_HXX_ +#include +#endif + +#ifndef _CPPUHELPER_IMPLBASE4_HXX_ +#include +#endif + +#ifndef _COM_SUN_STAR_UNO_EXCEPTION_HPP_ +#include +#endif + +#ifndef _COM_SUN_STAR_UNO_REFERENCE_HPP_ +#include +#endif + +#ifndef _COM_SUN_STAR_LANG_XSINGLESERVICEFACTORY_HPP_ +#include +#endif + +#ifndef _COM_SUN_STAR_LANG_XSECVICEINFO_HPP_ +#include +#endif + +#ifndef _COM_SUN_STAR_LANG_XINITIALIZATION_HPP_ +#include +#endif + +#ifndef _COM_SUN_STAR_LANG_XUNOTUNNEL_HPP_ +#include +#endif + +#ifndef _COM_SUN_STAR_XML_CRYPTO_XSECURITYENVIRONMENT_HPP_ +#include +#endif + +#ifndef _COM_SUN_STAR_XML_CRYPTO_XXMLSECURITYCONTEXT_HPP_ +#include +#endif + +#include "xmlsec/xmlsec.h" + +class XMLSecurityContext_MSCryptImpl : public ::cppu::WeakImplHelper4< + ::com::sun::star::xml::crypto::XXMLSecurityContext , + ::com::sun::star::lang::XInitialization , + ::com::sun::star::lang::XServiceInfo , + ::com::sun::star::lang::XUnoTunnel > +{ + private : + xmlSecKeysMngrPtr m_pKeysMngr ; + ::com::sun::star::uno::Reference< ::com::sun::star::xml::crypto::XSecurityEnvironment > m_xSecurityEnvironment ; + ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xServiceManager ; + + public : + XMLSecurityContext_MSCryptImpl( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& aFactory ) ; + virtual ~XMLSecurityContext_MSCryptImpl() ; + + //Methods from XXMLSecurityContext + virtual void SAL_CALL setSecurityEnvironment( + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::crypto::XSecurityEnvironment >& aSecurityEnvironment + ) throw( com::sun::star::security::SecurityInfrastructureException) ; + + virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::crypto::XSecurityEnvironment > SAL_CALL getSecurityEnvironment() + throw(::com::sun::star::uno::RuntimeException); + + //Methods from XInitialization + virtual void SAL_CALL initialize( + const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments + ) throw( ::com::sun::star::uno::Exception , ::com::sun::star::uno::RuntimeException ) ; + + //Methods from XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName() throw( ::com::sun::star::uno::RuntimeException ) ; + + virtual sal_Bool SAL_CALL supportsService( + const ::rtl::OUString& ServiceName + ) throw( ::com::sun::star::uno::RuntimeException ) ; + + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw( ::com::sun::star::uno::RuntimeException ) ; + + //Helper for XServiceInfo + static ::com::sun::star::uno::Sequence< ::rtl::OUString > impl_getSupportedServiceNames() ; + + static ::rtl::OUString impl_getImplementationName() throw( ::com::sun::star::uno::RuntimeException ) ; + + //Helper for registry + static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL impl_createInstance( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& aServiceManager ) throw( ::com::sun::star::uno::RuntimeException ) ; + + static ::com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleServiceFactory > impl_createFactory( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& aServiceManager ) ; + + //Methods from XUnoTunnel + virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) + throw (com::sun::star::uno::RuntimeException); + + static const ::com::sun::star::uno::Sequence< sal_Int8 >& getUnoTunnelId() ; + static XMLSecurityContext_MSCryptImpl* getImplementation( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > xObj ) ; + + //Native mehtods + virtual xmlSecKeysMngrPtr keysManager() throw( ::com::sun::star::uno::Exception , ::com::sun::star::uno::RuntimeException ) ; +} ; + +#endif // _XMLSIGNATURECONTEXT_MSCRYPTIMPL_HXX_ + diff --git a/xmlsecurity/source/xmlsec/mscrypt/xmlsignature_mscryptimpl.cxx b/xmlsecurity/source/xmlsec/mscrypt/xmlsignature_mscryptimpl.cxx new file mode 100644 index 000000000000..8e027e1a0022 --- /dev/null +++ b/xmlsecurity/source/xmlsec/mscrypt/xmlsignature_mscryptimpl.cxx @@ -0,0 +1,336 @@ +/************************************************************************* + * + * $RCSfile: xmlsignature_mscryptimpl.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:22 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _SAL_CONFIG_H_ +#include +#endif + +#ifndef _RTL_UUID_H_ +#include +#endif + +#ifndef _XMLSIGNATURE_MSCRYPTIMPL_HXX_ +#include "xmlsignature_mscryptimpl.hxx" +#endif + +#ifndef _XMLDOCUMENTWRAPPER_XMLSECIMPL_HXX_ +#include "xmldocumentwrapper_xmlsecimpl.hxx" +#endif + +#ifndef _XMLELEMENTWRAPPER_XMLSECIMPL_HXX_ +#include "xmlelementwrapper_xmlsecimpl.hxx" +#endif + +#ifndef _XMLSECURITYCONTEXT_MSCRYPTIMPL_HXX_ +#include "xmlsecuritycontext_mscryptimpl.hxx" +#endif + +#ifndef _XMLSTREAMIO_XMLSECIMPL_HXX_ +#include "xmlstreamio.hxx" +#endif + +#include "xmlsec/xmlsec.h" +#include "xmlsec/xmldsig.h" +#include "xmlsec/crypto.h" + +using namespace ::com::sun::star::uno ; +using namespace ::com::sun::star::lang ; +using ::com::sun::star::lang::XMultiServiceFactory ; +using ::com::sun::star::lang::XSingleServiceFactory ; +using ::rtl::OUString ; + +using ::com::sun::star::xml::wrapper::XXMLElementWrapper ; +using ::com::sun::star::xml::wrapper::XXMLDocumentWrapper ; +using ::com::sun::star::xml::crypto::XSecurityEnvironment ; +using ::com::sun::star::xml::crypto::XXMLSignature ; +using ::com::sun::star::xml::crypto::XXMLSignatureTemplate ; +using ::com::sun::star::xml::crypto::XXMLSecurityContext ; +using ::com::sun::star::xml::crypto::XUriBinding ; + +XMLSignature_MSCryptImpl :: XMLSignature_MSCryptImpl( const Reference< XMultiServiceFactory >& aFactory ) : m_xServiceManager( aFactory ) { +} + +XMLSignature_MSCryptImpl :: ~XMLSignature_MSCryptImpl() { +} + +/* XXMLSignature */ +Reference< XXMLSignatureTemplate > +SAL_CALL XMLSignature_MSCryptImpl :: generate( + const Reference< XXMLSignatureTemplate >& aTemplate , + const Reference< XXMLSecurityContext >& aSecurityCtx +) throw( com::sun::star::xml::crypto::XMLSignatureException, + com::sun::star::uno::SecurityException ) +{ + xmlSecKeysMngrPtr pMngr = NULL ; + xmlSecDSigCtxPtr pDsigCtx = NULL ; + xmlNodePtr pNode = NULL ; + + if( !aTemplate.is() ) + throw RuntimeException() ; + + if( !aSecurityCtx.is() ) + throw RuntimeException() ; + + //Get the xml node + Reference< XXMLElementWrapper > xElement = aTemplate->getTemplate() ; + if( !xElement.is() ) { + throw RuntimeException() ; + } + + Reference< XUnoTunnel > xNodTunnel( xElement , UNO_QUERY ) ; + if( !xNodTunnel.is() ) { + throw RuntimeException() ; + } + + XMLElementWrapper_XmlSecImpl* pElement = ( XMLElementWrapper_XmlSecImpl* )xNodTunnel->getSomething( XMLElementWrapper_XmlSecImpl::getUnoTunnelImplementationId() ) ; + if( pElement == NULL ) { + throw RuntimeException() ; + } + + pNode = pElement->getNativeElement() ; + + //Get the stream/URI binding + Reference< XUriBinding > xUriBinding = aTemplate->getBinding() ; + if( xUriBinding.is() ) { + //Register the stream input callbacks into libxml2 + if( xmlRegisterStreamInputCallbacks( xUriBinding ) < 0 ) + throw RuntimeException() ; + } + + //Get Keys Manager + Reference< XUnoTunnel > xSecTunnel( aSecurityCtx , UNO_QUERY ) ; + if( !xSecTunnel.is() ) { + throw RuntimeException() ; + } + + XMLSecurityContext_MSCryptImpl* pSecCtxt = ( XMLSecurityContext_MSCryptImpl* )xSecTunnel->getSomething( XMLSecurityContext_MSCryptImpl::getUnoTunnelId() ) ; + if( pSecCtxt == NULL ) + throw RuntimeException() ; + + pMngr = pSecCtxt->keysManager() ; + + //Create Signature context + pDsigCtx = xmlSecDSigCtxCreate( pMngr ) ; + if( pDsigCtx == NULL ) + throw RuntimeException() ; + + //Sign the template + if( xmlSecDSigCtxSign( pDsigCtx , pNode ) < 0 ) { + xmlSecDSigCtxDestroy( pDsigCtx ) ; + + //Unregistered the stream/URI binding + if( xUriBinding.is() ) + xmlUnregisterStreamInputCallbacks() ; + + throw RuntimeException() ; + } + + xmlSecDSigCtxDestroy( pDsigCtx ) ; + + //Unregistered the stream/URI binding + if( xUriBinding.is() ) + xmlUnregisterStreamInputCallbacks() ; + + return aTemplate ; +} + +/* XXMLSignature */ +sal_Bool SAL_CALL +XMLSignature_MSCryptImpl :: validate( + const Reference< XXMLSignatureTemplate >& aTemplate , + const Reference< XXMLSecurityContext >& aSecurityCtx +) throw( com::sun::star::uno::RuntimeException, + com::sun::star::uno::SecurityException, + com::sun::star::xml::crypto::XMLSignatureException ) { + xmlSecKeysMngrPtr pMngr = NULL ; + xmlSecDSigCtxPtr pDsigCtx = NULL ; + xmlNodePtr pNode = NULL ; + sal_Bool valid ; + + if( !aTemplate.is() ) + throw RuntimeException() ; + + if( !aSecurityCtx.is() ) + throw RuntimeException() ; + + //Get the xml node + Reference< XXMLElementWrapper > xElement = aTemplate->getTemplate() ; + if( !xElement.is() ) + throw RuntimeException() ; + + Reference< XUnoTunnel > xNodTunnel( xElement , UNO_QUERY ) ; + if( !xNodTunnel.is() ) { + throw RuntimeException() ; + } + + XMLElementWrapper_XmlSecImpl* pElement = ( XMLElementWrapper_XmlSecImpl* )xNodTunnel->getSomething( XMLElementWrapper_XmlSecImpl::getUnoTunnelImplementationId() ) ; + if( pElement == NULL ) + throw RuntimeException() ; + + pNode = pElement->getNativeElement() ; + + //Get the stream/URI binding + Reference< XUriBinding > xUriBinding = aTemplate->getBinding() ; + if( xUriBinding.is() ) { + //Register the stream input callbacks into libxml2 + if( xmlRegisterStreamInputCallbacks( xUriBinding ) < 0 ) + throw RuntimeException() ; + } + + //added for test: save the result + /* + { + FILE *dstFile = fopen( "c:\\1.txt", "w" ) ; + xmlDocDump( dstFile, pNode->doc) ; + fclose( dstFile ) ; + } + */ + + //Get Keys Manager + Reference< XUnoTunnel > xSecTunnel( aSecurityCtx , UNO_QUERY ) ; + if( !xSecTunnel.is() ) { + throw RuntimeException() ; + } + + XMLSecurityContext_MSCryptImpl* pSecCtxt = ( XMLSecurityContext_MSCryptImpl* )xSecTunnel->getSomething( XMLSecurityContext_MSCryptImpl::getUnoTunnelId() ) ; + if( pSecCtxt == NULL ) + throw RuntimeException() ; + + pMngr = pSecCtxt->keysManager() ; + + //Create Signature context + pDsigCtx = xmlSecDSigCtxCreate( pMngr ) ; + if( pDsigCtx == NULL ) + throw RuntimeException() ; + + + //Verify signature + if( xmlSecDSigCtxVerify( pDsigCtx , pNode ) < 0 ) { + xmlSecDSigCtxDestroy( pDsigCtx ) ; + + //Unregistered the stream/URI binding + if( xUriBinding.is() ) + xmlUnregisterStreamInputCallbacks() ; + + throw RuntimeException() ; + } + + valid = ( pDsigCtx->status == xmlSecDSigStatusSucceeded ) ; + + xmlSecDSigCtxDestroy( pDsigCtx ) ; + + //Unregistered the stream/URI binding + if( xUriBinding.is() ) + xmlUnregisterStreamInputCallbacks() ; + + return valid ; +} + +/* XInitialization */ +void SAL_CALL XMLSignature_MSCryptImpl :: initialize( const Sequence< Any >& aArguments ) throw( Exception, RuntimeException ) { + // TBD +} ; + +/* XServiceInfo */ +OUString SAL_CALL XMLSignature_MSCryptImpl :: getImplementationName() throw( RuntimeException ) { + return impl_getImplementationName() ; +} + +/* XServiceInfo */ +sal_Bool SAL_CALL XMLSignature_MSCryptImpl :: supportsService( const OUString& serviceName) throw( RuntimeException ) { + Sequence< OUString > seqServiceNames = getSupportedServiceNames() ; + const OUString* pArray = seqServiceNames.getConstArray() ; + for( sal_Int32 i = 0 ; i < seqServiceNames.getLength() ; i ++ ) { + if( *( pArray + i ) == serviceName ) + return sal_True ; + } + return sal_False ; +} + +/* XServiceInfo */ +Sequence< OUString > SAL_CALL XMLSignature_MSCryptImpl :: getSupportedServiceNames() throw( RuntimeException ) { + return impl_getSupportedServiceNames() ; +} + +//Helper for XServiceInfo +Sequence< OUString > XMLSignature_MSCryptImpl :: impl_getSupportedServiceNames() { + ::osl::Guard< ::osl::Mutex > aGuard( ::osl::Mutex::getGlobalMutex() ) ; + Sequence< OUString > seqServiceNames( 1 ) ; + seqServiceNames.getArray()[0] = OUString::createFromAscii( "com.sun.star.xml.crypto.XMLSignature" ) ; + return seqServiceNames ; +} + +OUString XMLSignature_MSCryptImpl :: impl_getImplementationName() throw( RuntimeException ) { + return OUString::createFromAscii( "com.sun.star.xml.security.bridge.xmlsec.XMLSignature_MSCryptImpl" ) ; +} + +//Helper for registry +Reference< XInterface > SAL_CALL XMLSignature_MSCryptImpl :: impl_createInstance( const Reference< XMultiServiceFactory >& aServiceManager ) throw( RuntimeException ) { + return Reference< XInterface >( *new XMLSignature_MSCryptImpl( aServiceManager ) ) ; +} + +Reference< XSingleServiceFactory > XMLSignature_MSCryptImpl :: impl_createFactory( const Reference< XMultiServiceFactory >& aServiceManager ) { + //Reference< XSingleServiceFactory > xFactory ; + //xFactory = ::cppu::createSingleFactory( aServiceManager , impl_getImplementationName , impl_createInstance , impl_getSupportedServiceNames ) ; + //return xFactory ; + return ::cppu::createSingleFactory( aServiceManager , impl_getImplementationName() , impl_createInstance , impl_getSupportedServiceNames() ) ; +} + diff --git a/xmlsecurity/source/xmlsec/mscrypt/xmlsignature_mscryptimpl.hxx b/xmlsecurity/source/xmlsec/mscrypt/xmlsignature_mscryptimpl.hxx new file mode 100644 index 000000000000..8f401a86c824 --- /dev/null +++ b/xmlsecurity/source/xmlsec/mscrypt/xmlsignature_mscryptimpl.hxx @@ -0,0 +1,165 @@ +/************************************************************************* + * + * $RCSfile: xmlsignature_mscryptimpl.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:22 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _XMLSIGNATURE_MSCRYPTIMPL_HXX_ +#define _XMLSIGNATURE_MSCRYPTIMPL_HXX_ + +#ifndef _SAL_CONFIG_H_ +#include +#endif + +#ifndef _RTL_USTRING_HXX_ +#include +#endif + +#ifndef _CPPUHELPER_FACTORY_HXX_ +#include +#endif + +#ifndef _CPPUHELPER_IMPLBASE3_HXX_ +#include +#endif + +#ifndef _COM_SUN_STAR_UNO_EXCEPTION_HPP_ +#include +#endif + +#ifndef _COM_SUN_STAR_UNO_REFERENCE_HPP_ +#include +#endif + +#ifndef _COM_SUN_STAR_LANG_XSINGLESERVICEFACTORY_HPP_ +#include +#endif + +#ifndef _COM_SUN_STAR_LANG_XSECVICEINFO_HPP_ +#include +#endif + +#ifndef _COM_SUN_STAR_LANG_XINITIALIZATION_HPP_ +#include +#endif + +#ifndef _COM_SUN_STAR_XML_CRYPTO_XXMLSIGNATURE_HPP_ +#include +#endif + +#ifndef _COM_SUN_STAR_XML_CRYPTO_XXMLSIGNATURETEMPLATE_HPP_ +#include +#endif + +#ifndef _COM_SUN_STAR_XML_CRYPTO_XXMLSECURITYCONTEXT_HPP_ +#include +#endif + +class XMLSignature_MSCryptImpl : public ::cppu::WeakImplHelper3< + ::com::sun::star::xml::crypto::XXMLSignature , + ::com::sun::star::lang::XInitialization , + ::com::sun::star::lang::XServiceInfo > +{ + private : + ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xServiceManager ; + + public : + XMLSignature_MSCryptImpl( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& aFactory ) ; + virtual ~XMLSignature_MSCryptImpl() ; + + //Methods from XXMLSignature + virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::crypto::XXMLSignatureTemplate > SAL_CALL generate( + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::crypto::XXMLSignatureTemplate >& aTemplate , + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::crypto::XXMLSecurityContext >& aContext + ) throw( com::sun::star::xml::crypto::XMLSignatureException, + com::sun::star::uno::SecurityException) ; + + virtual sal_Bool SAL_CALL validate( + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::crypto::XXMLSignatureTemplate >& aTemplate , + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::crypto::XXMLSecurityContext >& aContext + ) throw( com::sun::star::uno::RuntimeException, + com::sun::star::uno::SecurityException, + com::sun::star::xml::crypto::XMLSignatureException); + + //Methods from XInitialization + virtual void SAL_CALL initialize( + const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments + ) throw( ::com::sun::star::uno::Exception , ::com::sun::star::uno::RuntimeException ) ; + + //Methods from XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName() throw( ::com::sun::star::uno::RuntimeException ) ; + + virtual sal_Bool SAL_CALL supportsService( + const ::rtl::OUString& ServiceName + ) throw( ::com::sun::star::uno::RuntimeException ) ; + + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw( ::com::sun::star::uno::RuntimeException ) ; + + //Helper for XServiceInfo + static ::com::sun::star::uno::Sequence< ::rtl::OUString > impl_getSupportedServiceNames() ; + + static ::rtl::OUString impl_getImplementationName() throw( ::com::sun::star::uno::RuntimeException ) ; + + //Helper for registry + static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL impl_createInstance( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& aServiceManager ) throw( ::com::sun::star::uno::RuntimeException ) ; + + static ::com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleServiceFactory > impl_createFactory( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& aServiceManager ) ; +} ; + +#endif // _XMLSIGNATURE_MSCRYPTIMPL_HXX_ + diff --git a/xmlsecurity/source/xmlsec/mscrypt/xsec_mscrypt.cxx b/xmlsecurity/source/xmlsec/mscrypt/xsec_mscrypt.cxx new file mode 100644 index 000000000000..59e93dccde14 --- /dev/null +++ b/xmlsecurity/source/xmlsec/mscrypt/xsec_mscrypt.cxx @@ -0,0 +1,198 @@ +/************************************************************************* + * + * $RCSfile: xsec_mscrypt.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:22 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#include +#include + +#include +#include +#include + +#ifndef _COM_SUN_STAR_LANG_XSINGLESERVICEFACTORY_HPP_ +#include +#endif + +#include "seinitializer_mscryptimpl.hxx" +#include "xmlsignature_mscryptimpl.hxx" +#include "xmlencryption_mscryptimpl.hxx" +#include "xmlsecuritycontext_mscryptimpl.hxx" +#include "securityenvironment_mscryptimpl.hxx" + +using namespace ::rtl; +using namespace ::cppu; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::registry; + +extern "C" +{ + +sal_Bool SAL_CALL mscrypt_component_writeInfo( void* pServiceManager , void* pRegistryKey ) +{ + sal_Bool result = sal_False; + sal_Int32 i ; + OUString sKeyName ; + Reference< XRegistryKey > xNewKey ; + Sequence< OUString > seqServices ; + Reference< XRegistryKey > xKey( reinterpret_cast< XRegistryKey* >( pRegistryKey ) ) ; + + if( xKey.is() ) { + // try { + // XMLSignature_MSCryptImpl + sKeyName = OUString( RTL_CONSTASCII_USTRINGPARAM( "/" ) ) ; + sKeyName += XMLSignature_MSCryptImpl::impl_getImplementationName() ; + sKeyName += OUString::createFromAscii( "/UNO/SERVICES" ) ; + + xNewKey = xKey->createKey( sKeyName ) ; + if( xNewKey.is() ) { + seqServices = XMLSignature_MSCryptImpl::impl_getSupportedServiceNames() ; + for( i = seqServices.getLength() ; i -- ; ) + xNewKey->createKey( seqServices.getConstArray()[i] ) ; + } + + // XMLEncryption_MSCryptImpl + sKeyName = OUString( RTL_CONSTASCII_USTRINGPARAM( "/" ) ) ; + sKeyName += XMLEncryption_MSCryptImpl::impl_getImplementationName() ; + sKeyName += OUString::createFromAscii( "/UNO/SERVICES" ) ; + + xNewKey = xKey->createKey( sKeyName ) ; + if( xNewKey.is() ) { + seqServices = XMLEncryption_MSCryptImpl::impl_getSupportedServiceNames() ; + for( i = seqServices.getLength() ; i -- ; ) + xNewKey->createKey( seqServices.getConstArray()[i] ) ; + } + + // XMLSecurityContext_MSCryptImpl + sKeyName = OUString( RTL_CONSTASCII_USTRINGPARAM( "/" ) ) ; + sKeyName += XMLSecurityContext_MSCryptImpl::impl_getImplementationName() ; + sKeyName += OUString::createFromAscii( "/UNO/SERVICES" ) ; + + xNewKey = xKey->createKey( sKeyName ) ; + if( xNewKey.is() ) { + seqServices = XMLSecurityContext_MSCryptImpl::impl_getSupportedServiceNames() ; + for( i = seqServices.getLength() ; i -- ; ) + xNewKey->createKey( seqServices.getConstArray()[i] ) ; + } + + // SecurityEnvironment_MSCryptImpl + sKeyName = OUString( RTL_CONSTASCII_USTRINGPARAM( "/" ) ) ; + sKeyName += SecurityEnvironment_MSCryptImpl::impl_getImplementationName() ; + sKeyName += OUString::createFromAscii( "/UNO/SERVICES" ) ; + + xNewKey = xKey->createKey( sKeyName ) ; + if( xNewKey.is() ) { + seqServices = SecurityEnvironment_MSCryptImpl::impl_getSupportedServiceNames() ; + for( i = seqServices.getLength() ; i -- ; ) + xNewKey->createKey( seqServices.getConstArray()[i] ) ; + } + + // SEInitializer_MSCryptImpl + sKeyName = OUString( RTL_CONSTASCII_USTRINGPARAM( "/" ) ) ; + sKeyName += SEInitializer_MSCryptImpl_getImplementationName() ; + sKeyName += OUString::createFromAscii( "/UNO/SERVICES" ) ; + + xNewKey = xKey->createKey( sKeyName ) ; + if( xNewKey.is() ) { + seqServices = SEInitializer_MSCryptImpl_getSupportedServiceNames() ; + for( i = seqServices.getLength() ; i -- ; ) + xNewKey->createKey( seqServices.getConstArray()[i] ) ; + } + + return sal_True; + //} catch( InvalidRegistryException & ) { + // //we should not ignore exceptions + // return sal_False ; + //} + } + return result; +} + +void* SAL_CALL mscrypt_component_getFactory( const sal_Char* pImplName , void* pServiceManager , void* pRegistryKey ) +{ + void* pRet = 0; + Reference< XSingleServiceFactory > xFactory ; + + if( pImplName != NULL && pServiceManager != NULL ) { + if( XMLSignature_MSCryptImpl::impl_getImplementationName().equals( OUString::createFromAscii( pImplName ) ) ) { + xFactory = XMLSignature_MSCryptImpl::impl_createFactory( reinterpret_cast< XMultiServiceFactory* >( pServiceManager ) ) ; + } else if( XMLSecurityContext_MSCryptImpl::impl_getImplementationName().equals( OUString::createFromAscii( pImplName ) ) ) { + xFactory = XMLSecurityContext_MSCryptImpl::impl_createFactory( reinterpret_cast< XMultiServiceFactory* >( pServiceManager ) ) ; + } else if( SecurityEnvironment_MSCryptImpl::impl_getImplementationName().equals( OUString::createFromAscii( pImplName ) ) ) { + xFactory = SecurityEnvironment_MSCryptImpl::impl_createFactory( reinterpret_cast< XMultiServiceFactory* >( pServiceManager ) ) ; + } else if( XMLEncryption_MSCryptImpl::impl_getImplementationName().equals( OUString::createFromAscii( pImplName ) ) ) { + xFactory = XMLEncryption_MSCryptImpl::impl_createFactory( reinterpret_cast< XMultiServiceFactory* >( pServiceManager ) ) ; + } else if( SEInitializer_MSCryptImpl_getImplementationName().equals( OUString::createFromAscii( pImplName ) ) ) { + xFactory = Reference< XSingleServiceFactory >( createSingleFactory( + reinterpret_cast< XMultiServiceFactory * >( pServiceManager ), + OUString::createFromAscii( pImplName ), + SEInitializer_MSCryptImpl_createInstance, SEInitializer_MSCryptImpl_getSupportedServiceNames() ) ); + } + } + + if( xFactory.is() ) { + xFactory->acquire() ; + pRet = xFactory.get() ; + } + + return pRet ; +} + +} diff --git a/xmlsecurity/source/xmlsec/nss/makefile.mk b/xmlsecurity/source/xmlsec/nss/makefile.mk new file mode 100644 index 000000000000..a52e6abf1893 --- /dev/null +++ b/xmlsecurity/source/xmlsec/nss/makefile.mk @@ -0,0 +1,158 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1.1.1 $ +# +# last change: $Author: mt $ $Date: 2004-07-12 13:15:21 $ +# +# The Contents of this file are made available subject to the terms of +# either of the following licenses +# +# - GNU Lesser General Public License Version 2.1 +# - Sun Industry Standards Source License Version 1.1 +# +# Sun Microsystems Inc., October, 2000 +# +# GNU Lesser General Public License Version 2.1 +# ============================================= +# Copyright 2000 by Sun Microsystems, Inc. +# 901 San Antonio Road, Palo Alto, CA 94303, USA +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License version 2.1, as published by the Free Software Foundation. +# +# This library 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 for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, +# MA 02111-1307 USA +# +# +# Sun Industry Standards Source License Version 1.1 +# ================================================= +# The contents of this file are subject to the Sun Industry Standards +# Source License Version 1.1 (the "License"); You may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at http://www.openoffice.org/license.html. +# +# Software provided under this License is provided on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, +# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, +# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. +# See the License for the specific provisions governing your rights and +# obligations concerning the Software. +# +# The Initial Developer of the Original Code is: Sun Microsystems, Inc. +# +# Copyright: 2000 by Sun Microsystems, Inc. +# +# All Rights Reserved. +# +# Contributor(s): _______________________________________ +# +# +# +#************************************************************************* + +PRJ=..$/..$/.. + +PRJNAME = xmlsecurity +TARGET = xs_nss + +ENABLE_EXCEPTIONS = TRUE + +# --- Settings ----------------------------------------------------- + +.INCLUDE : svpre.mk +.INCLUDE : settings.mk +.INCLUDE : sv.mk +.INCLUDE : $(PRJ)$/util$/target.pmk + +.IF "$(CRYPTO_ENGINE)" != "nss" +LIBTARGET=NO +.ENDIF + +.IF "$(CRYPTO_ENGINE)" == "nss" + +MOZ_INC = $(SOLARVERSION)$/$(INPATH)$/inc$(UPDMINOREXT)$/mozilla +NSS_INC = $(MOZ_INC)$/nss +NSPR_INC = $(MOZ_INC)$/nspr + + +.IF "$(GUI)"=="UNX" +.IF "$(COMNAME)"=="sunpro5" +CFLAGS += -features=tmplife +#This flag is needed to build mozilla 1.7 code +.ENDIF # "$(COMNAME)"=="sunpro5" +.ENDIF + +.IF "$(GUI)" == "WNT" +.IF "$(DBG_LEVEL)" == "0" +INCPRE += \ + -I$(MOZ_INC)$/xpcom \ +-I$(MOZ_INC)$/profile \ +-I$(MOZ_INC)$/string \ +-I$(MOZ_INC)$/embed_base +CFLAGS += -GR- -W3 -Gy -MD -UDEBUG +.ELSE +INCPRE += \ + -I$(MOZ_INC)$/xpcom \ +-I$(MOZ_INC)$/profile \ +-I$(MOZ_INC)$/string \ +-I$(MOZ_INC)$/embed_base +CFLAGS += -Zi -GR- -W3 -Gy -MDd -UNDEBUG +.ENDIF +.ENDIF +.IF "$(GUI)" == "UNX" +INCPOST += \ +$(MOZ_INC)$/xpcom \ +-I$(MOZ_INC)$/profile \ +-I$(MOZ_INC)$/string \ +-I$(MOZ_INC)$/embed_base +.IF "$(OS)" == "LINUX" +CFLAGS += -fPIC -g +CFLAGSCXX += \ + -fno-rtti -Wall -Wconversion -Wpointer-arith \ + -Wbad-function-cast -Wcast-align -Woverloaded-virtual -Wsynth \ + -Wno-long-long -pthread +CDEFS += -DTRACING +.ELIF "$(OS)" == "NETBSD" +CFLAGS += -fPIC +CFLAGSCXX += \ + -fno-rtti -Wall -Wconversion -Wpointer-arith \ + -Wbad-function-cast -Wcast-align -Woverloaded-virtual -Wsynth \ + -Wno-long-long +CDEFS += -DTRACING +.ENDIF +.ENDIF + +CDEFS += -DXMLSEC_CRYPTO_NSS -DXMLSEC_NO_XSLT + +# --- Files -------------------------------------------------------- +SOLARINC += \ + -I$(MOZ_INC) \ +-I$(NSPR_INC) \ +-I$(NSS_INC) \ +-I$(PRJ)$/source$/xmlsec + +SLOFILES = \ + $(SLO)$/securityenvironment_nssimpl.obj \ + $(SLO)$/xmlencryption_nssimpl.obj \ + $(SLO)$/xmlsecuritycontext_nssimpl.obj \ + $(SLO)$/xmlsignature_nssimpl.obj \ + $(SLO)$/x509certificate_nssimpl.obj \ + $(SLO)$/seinitializer_nssimpl.obj \ + $(SLO)$/xsec_nss.obj + + +.ENDIF + +# --- Targets ------------------------------------------------------ + +.INCLUDE : target.mk diff --git a/xmlsecurity/source/xmlsec/nss/securityenvironment_nssimpl.cxx b/xmlsecurity/source/xmlsec/nss/securityenvironment_nssimpl.cxx new file mode 100644 index 000000000000..c59d8b1dd97e --- /dev/null +++ b/xmlsecurity/source/xmlsec/nss/securityenvironment_nssimpl.cxx @@ -0,0 +1,832 @@ +/************************************************************************* + * + * $RCSfile: securityenvironment_nssimpl.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:21 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _SAL_CONFIG_H_ +#include +#endif + +#ifndef _XSECURITYENVIRONMENT_NSSIMPL_HXX_ +#include "securityenvironment_nssimpl.hxx" +#endif + +#ifndef _X509CERTIFICATE_NSSIMPL_HXX_ +#include "x509certificate_nssimpl.hxx" +#endif + +#ifndef _RTL_UUID_H_ +#include +#endif + +#include "nspr.h" +#include "nss.h" +#include "secport.h" +#include "secitem.h" +#include "secder.h" +#include "limits.h" + +#include "xmlsec/xmlsec.h" +#include "xmlsec/keysmngr.h" +#include "xmlsec/crypto.h" +#include +#include "xmlsec/strings.h" + +#include + +#include +#include +#include + +#ifndef _COM_SUN_STAR_TASK_XINTERACTIONHANDLER_HPP_ +#include +#endif + +// MM : added for password exception +#include +using namespace ::com::sun::star::security; + +using namespace com::sun::star; +using namespace ::com::sun::star::uno ; +using namespace ::com::sun::star::lang ; +using ::com::sun::star::lang::XMultiServiceFactory ; +using ::com::sun::star::lang::XSingleServiceFactory ; +using ::rtl::OUString ; + +using ::com::sun::star::xml::crypto::XSecurityEnvironment ; +using ::com::sun::star::security::XCertificate ; + +extern X509Certificate_NssImpl* NssCertToXCert( CERTCertificate* cert ) ; +extern X509Certificate_NssImpl* NssPrivKeyToXCert( SECKEYPrivateKey* ) ; +extern Sequence< sal_Int8 > numericStringToBigInteger( OUString ) ; +extern OUString bigIntegerToNumericString( Sequence< sal_Int8 > serial ) ; + +char* GetPasswordFunction( PK11SlotInfo* pSlot, PRBool bRetry, void* arg ) +{ + char* pPassword = NULL; + + uno::Reference< lang::XMultiServiceFactory > xMSF( ::comphelper::getProcessServiceFactory() ); + if ( xMSF.is() ) + { + uno::Reference < task::XInteractionHandler > xInteractionHandler( + xMSF->createInstance( rtl::OUString::createFromAscii("com.sun.star.task.InteractionHandler") ), uno::UNO_QUERY ); + + if ( xInteractionHandler.is() ) + { + task::PasswordRequestMode eMode = bRetry ? task::PasswordRequestMode_PASSWORD_REENTER : task::PasswordRequestMode_PASSWORD_ENTER; + RequestDocumentPassword* pPasswordRequest = new RequestDocumentPassword( eMode, ::rtl::OUString() ); + + uno::Reference< task::XInteractionRequest > xRequest( pPasswordRequest ); + xInteractionHandler->handle( xRequest ); + + if ( pPasswordRequest->isPassword() ) + { + // We need TOOLS anyway, because of class RequestDocumentPassword. + // If this changes, use rtl String functions for this... + ByteString aPassword = ByteString( String( pPasswordRequest->getPassword() ), gsl_getSystemTextEncoding() ); + USHORT nLen = aPassword.Len(); + pPassword = (char*) PORT_Alloc( nLen+1 ) ; + pPassword[nLen] = 0; + memcpy( pPassword, aPassword.GetBuffer(), nLen ); + } + } + } +#ifdef DEBUG + else + { + // TEST Password is 'sceri' + pPassword = ( char* )PORT_Alloc( 20 ) ; + pPassword[0]='s'; + pPassword[1]='c'; + pPassword[2]='e'; + pPassword[3]='r'; + pPassword[4]='i'; + pPassword[5]=0x0; + } +#endif + + return pPassword; +} + +SecurityEnvironment_NssImpl :: SecurityEnvironment_NssImpl( const Reference< XMultiServiceFactory >& aFactory ) : m_pSlot( NULL ) , m_pHandler( NULL ) , m_tSymKeyList() , m_tPubKeyList() , m_tPriKeyList() { + + PK11_SetPasswordFunc( GetPasswordFunction ) ; +} + +SecurityEnvironment_NssImpl :: ~SecurityEnvironment_NssImpl() { + + PK11_SetPasswordFunc( NULL ) ; + + if( m_pSlot != NULL ) { + PK11_FreeSlot( m_pSlot ) ; + m_pSlot = NULL ; + } + + if( !m_tSymKeyList.empty() ) { + std::list< PK11SymKey* >::iterator symKeyIt ; + + for( symKeyIt = m_tSymKeyList.begin() ; symKeyIt != m_tSymKeyList.end() ; symKeyIt ++ ) + PK11_FreeSymKey( *symKeyIt ) ; + } + + if( !m_tPubKeyList.empty() ) { + std::list< SECKEYPublicKey* >::iterator pubKeyIt ; + + for( pubKeyIt = m_tPubKeyList.begin() ; pubKeyIt != m_tPubKeyList.end() ; pubKeyIt ++ ) + SECKEY_DestroyPublicKey( *pubKeyIt ) ; + } + + if( !m_tPriKeyList.empty() ) { + std::list< SECKEYPrivateKey* >::iterator priKeyIt ; + + for( priKeyIt = m_tPriKeyList.begin() ; priKeyIt != m_tPriKeyList.end() ; priKeyIt ++ ) + SECKEY_DestroyPrivateKey( *priKeyIt ) ; + } +} + +/* XInitialization */ +void SAL_CALL SecurityEnvironment_NssImpl :: initialize( const Sequence< Any >& aArguments ) throw( Exception, RuntimeException ) { + // TBD +} ; + +/* XServiceInfo */ +OUString SAL_CALL SecurityEnvironment_NssImpl :: getImplementationName() throw( RuntimeException ) { + return impl_getImplementationName() ; +} + +/* XServiceInfo */ +sal_Bool SAL_CALL SecurityEnvironment_NssImpl :: supportsService( const OUString& serviceName) throw( RuntimeException ) { + Sequence< OUString > seqServiceNames = getSupportedServiceNames() ; + const OUString* pArray = seqServiceNames.getConstArray() ; + for( sal_Int32 i = 0 ; i < seqServiceNames.getLength() ; i ++ ) { + if( *( pArray + i ) == serviceName ) + return sal_True ; + } + return sal_False ; +} + +/* XServiceInfo */ +Sequence< OUString > SAL_CALL SecurityEnvironment_NssImpl :: getSupportedServiceNames() throw( RuntimeException ) { + return impl_getSupportedServiceNames() ; +} + +//Helper for XServiceInfo +Sequence< OUString > SecurityEnvironment_NssImpl :: impl_getSupportedServiceNames() { + ::osl::Guard< ::osl::Mutex > aGuard( ::osl::Mutex::getGlobalMutex() ) ; + Sequence< OUString > seqServiceNames( 1 ) ; + seqServiceNames.getArray()[0] = OUString::createFromAscii( "com.sun.star.xml.crypto.SecurityEnvironment" ) ; + return seqServiceNames ; +} + +OUString SecurityEnvironment_NssImpl :: impl_getImplementationName() throw( RuntimeException ) { + return OUString::createFromAscii( "com.sun.star.xml.security.bridge.xmlsec.SecurityEnvironment_NssImpl" ) ; +} + +//Helper for registry +Reference< XInterface > SAL_CALL SecurityEnvironment_NssImpl :: impl_createInstance( const Reference< XMultiServiceFactory >& aServiceManager ) throw( RuntimeException ) { + return Reference< XInterface >( *new SecurityEnvironment_NssImpl( aServiceManager ) ) ; +} + +Reference< XSingleServiceFactory > SecurityEnvironment_NssImpl :: impl_createFactory( const Reference< XMultiServiceFactory >& aServiceManager ) { + //Reference< XSingleServiceFactory > xFactory ; + //xFactory = ::cppu::createSingleFactory( aServiceManager , impl_getImplementationName , impl_createInstance , impl_getSupportedServiceNames ) ; + //return xFactory ; + return ::cppu::createSingleFactory( aServiceManager , impl_getImplementationName() , impl_createInstance , impl_getSupportedServiceNames() ) ; +} + +/* XUnoTunnel */ +sal_Int64 SAL_CALL SecurityEnvironment_NssImpl :: getSomething( const Sequence< sal_Int8 >& aIdentifier ) + throw( RuntimeException ) +{ + if( aIdentifier.getLength() == 16 && 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(), aIdentifier.getConstArray(), 16 ) ) { + return ( sal_Int64 )this ; + } + return 0 ; +} + +/* XUnoTunnel extension */ +const Sequence< sal_Int8>& SecurityEnvironment_NssImpl :: getUnoTunnelId() { + static Sequence< sal_Int8 >* pSeq = 0 ; + if( !pSeq ) { + ::osl::Guard< ::osl::Mutex > aGuard( ::osl::Mutex::getGlobalMutex() ) ; + if( !pSeq ) { + static Sequence< sal_Int8> aSeq( 16 ) ; + rtl_createUuid( ( sal_uInt8* )aSeq.getArray() , 0 , sal_True ) ; + pSeq = &aSeq ; + } + } + return *pSeq ; +} + +/* XUnoTunnel extension */ +SecurityEnvironment_NssImpl* SecurityEnvironment_NssImpl :: getImplementation( const Reference< XInterface > xObj ) { + Reference< XUnoTunnel > xUT( xObj , UNO_QUERY ) ; + if( xUT.is() ) { + return ( SecurityEnvironment_NssImpl* )xUT->getSomething( getUnoTunnelId() ) ; + } else + return NULL ; +} + +/* Native methods */ +PK11SlotInfo* SecurityEnvironment_NssImpl :: getCryptoSlot() throw( Exception , RuntimeException ) { + return m_pSlot ; +} + +void SecurityEnvironment_NssImpl :: setCryptoSlot( PK11SlotInfo* aSlot) throw( Exception , RuntimeException ) { + if( m_pSlot != NULL ) { + PK11_FreeSlot( m_pSlot ) ; + m_pSlot = NULL ; + } + + if( aSlot != NULL ) { + m_pSlot = PK11_ReferenceSlot( aSlot ) ; + } +} + +CERTCertDBHandle* SecurityEnvironment_NssImpl :: getCertDb() throw( Exception , RuntimeException ) { + return m_pHandler ; +} + +void SecurityEnvironment_NssImpl :: setCertDb( CERTCertDBHandle* aCertDb ) throw( Exception , RuntimeException ) { + m_pHandler = aCertDb ; +} + +void SecurityEnvironment_NssImpl :: adoptSymKey( PK11SymKey* aSymKey ) throw( Exception , RuntimeException ) { + PK11SymKey* symkey ; + std::list< PK11SymKey* >::iterator keyIt ; + + if( aSymKey != NULL ) { + //First try to find the key in the list + for( keyIt = m_tSymKeyList.begin() ; keyIt != m_tSymKeyList.end() ; keyIt ++ ) { + if( *keyIt == aSymKey ) + return ; + } + + //If we do not find the key in the list, add a new node + symkey = PK11_ReferenceSymKey( aSymKey ) ; + if( symkey == NULL ) + throw RuntimeException() ; + + try { + m_tSymKeyList.push_back( symkey ) ; + } catch ( Exception& ) { + PK11_FreeSymKey( symkey ) ; + } + } +} + +void SecurityEnvironment_NssImpl :: rejectSymKey( PK11SymKey* aSymKey ) throw( Exception , RuntimeException ) { + PK11SymKey* symkey ; + std::list< PK11SymKey* >::iterator keyIt ; + + if( aSymKey != NULL ) { + for( keyIt = m_tSymKeyList.begin() ; keyIt != m_tSymKeyList.end() ; keyIt ++ ) { + if( *keyIt == aSymKey ) { + symkey = *keyIt ; + PK11_FreeSymKey( symkey ) ; + m_tSymKeyList.erase( keyIt ) ; + break ; + } + } + } +} + +PK11SymKey* SecurityEnvironment_NssImpl :: getSymKey( unsigned int position ) throw( Exception , RuntimeException ) { + PK11SymKey* symkey ; + std::list< PK11SymKey* >::iterator keyIt ; + unsigned int pos ; + + symkey = NULL ; + for( pos = 0, keyIt = m_tSymKeyList.begin() ; pos < position && keyIt != m_tSymKeyList.end() ; pos ++ , keyIt ++ ) ; + + if( pos == position && keyIt != m_tSymKeyList.end() ) + symkey = *keyIt ; + + return symkey ; +} + +void SecurityEnvironment_NssImpl :: adoptPubKey( SECKEYPublicKey* aPubKey ) throw( Exception , RuntimeException ) { + SECKEYPublicKey* pubkey ; + std::list< SECKEYPublicKey* >::iterator keyIt ; + + if( aPubKey != NULL ) { + //First try to find the key in the list + for( keyIt = m_tPubKeyList.begin() ; keyIt != m_tPubKeyList.end() ; keyIt ++ ) { + if( *keyIt == aPubKey ) + return ; + } + + //If we do not find the key in the list, add a new node + pubkey = SECKEY_CopyPublicKey( aPubKey ) ; + if( pubkey == NULL ) + throw RuntimeException() ; + + try { + m_tPubKeyList.push_back( pubkey ) ; + } catch ( Exception& ) { + SECKEY_DestroyPublicKey( pubkey ) ; + } + } +} + +void SecurityEnvironment_NssImpl :: rejectPubKey( SECKEYPublicKey* aPubKey ) throw( Exception , RuntimeException ) { + SECKEYPublicKey* pubkey ; + std::list< SECKEYPublicKey* >::iterator keyIt ; + + if( aPubKey != NULL ) { + for( keyIt = m_tPubKeyList.begin() ; keyIt != m_tPubKeyList.end() ; keyIt ++ ) { + if( *keyIt == aPubKey ) { + pubkey = *keyIt ; + SECKEY_DestroyPublicKey( pubkey ) ; + m_tPubKeyList.erase( keyIt ) ; + break ; + } + } + } +} + +SECKEYPublicKey* SecurityEnvironment_NssImpl :: getPubKey( unsigned int position ) throw( Exception , RuntimeException ) { + SECKEYPublicKey* pubkey ; + std::list< SECKEYPublicKey* >::iterator keyIt ; + unsigned int pos ; + + pubkey = NULL ; + for( pos = 0, keyIt = m_tPubKeyList.begin() ; pos < position && keyIt != m_tPubKeyList.end() ; pos ++ , keyIt ++ ) ; + + if( pos == position && keyIt != m_tPubKeyList.end() ) + pubkey = *keyIt ; + + return pubkey ; +} + +void SecurityEnvironment_NssImpl :: adoptPriKey( SECKEYPrivateKey* aPriKey ) throw( Exception , RuntimeException ) { + SECKEYPrivateKey* prikey ; + std::list< SECKEYPrivateKey* >::iterator keyIt ; + + if( aPriKey != NULL ) { + //First try to find the key in the list + for( keyIt = m_tPriKeyList.begin() ; keyIt != m_tPriKeyList.end() ; keyIt ++ ) { + if( *keyIt == aPriKey ) + return ; + } + + //If we do not find the key in the list, add a new node + prikey = SECKEY_CopyPrivateKey( aPriKey ) ; + if( prikey == NULL ) + throw RuntimeException() ; + + try { + m_tPriKeyList.push_back( prikey ) ; + } catch ( Exception& ) { + SECKEY_DestroyPrivateKey( prikey ) ; + } + } +} + +void SecurityEnvironment_NssImpl :: rejectPriKey( SECKEYPrivateKey* aPriKey ) throw( Exception , RuntimeException ) { + SECKEYPrivateKey* prikey ; + std::list< SECKEYPrivateKey* >::iterator keyIt ; + + if( aPriKey != NULL ) { + for( keyIt = m_tPriKeyList.begin() ; keyIt != m_tPriKeyList.end() ; keyIt ++ ) { + if( *keyIt == aPriKey ) { + prikey = *keyIt ; + SECKEY_DestroyPrivateKey( prikey ) ; + m_tPriKeyList.erase( keyIt ) ; + break ; + } + } + } +} + +SECKEYPrivateKey* SecurityEnvironment_NssImpl :: getPriKey( unsigned int position ) throw( ::com::sun::star::uno::Exception , ::com::sun::star::uno::RuntimeException ) { + SECKEYPrivateKey* prikey ; + std::list< SECKEYPrivateKey* >::iterator keyIt ; + unsigned int pos ; + + prikey = NULL ; + for( pos = 0, keyIt = m_tPriKeyList.begin() ; pos < position && keyIt != m_tPriKeyList.end() ; pos ++ , keyIt ++ ) ; + + if( pos == position && keyIt != m_tPriKeyList.end() ) + prikey = *keyIt ; + + return prikey ; +} + +Sequence< Reference < XCertificate > > SecurityEnvironment_NssImpl :: getPersonalCertificates() throw( SecurityException , RuntimeException ) { + sal_Int32 length ; + X509Certificate_NssImpl* xcert ; + std::list< X509Certificate_NssImpl* > certsList ; + + //firstly, we try to find private keys in slot + if( m_pSlot != NULL ) { + SECKEYPrivateKeyList* priKeyList ; + SECKEYPrivateKeyListNode* curPri ; + + if( PK11_NeedLogin( m_pSlot ) ) { + SECStatus nRet = PK11_Authenticate( m_pSlot, PR_TRUE, NULL ); + if( nRet != SECSuccess ) { + throw NoPasswordException(); + } + } + + priKeyList = PK11_ListPrivateKeysInSlot( m_pSlot ) ; + if( priKeyList != NULL ) { + for( curPri = PRIVKEY_LIST_HEAD( priKeyList ); !PRIVKEY_LIST_END( curPri, priKeyList ) && curPri != NULL ; curPri = PRIVKEY_LIST_NEXT( curPri ) ) { + xcert = NssPrivKeyToXCert( curPri->key ) ; + if( xcert != NULL ) + certsList.push_back( xcert ) ; + } + } + + SECKEY_DestroyPrivateKeyList( priKeyList ) ; + } + + //Deprecated + /*------- + { + PK11SlotList* soltList ; + PK11SlotListElement* soltEle ; + + SECKEYPrivateKeyList* priKeyList ; + SECKEYPrivateKeyListNode* curPri ; + + soltList = PK11_GetAllTokens( CKM_INVALID_MECHANISM, PR_FALSE, PR_FALSE, NULL ) ; + if( soltList != NULL ) { + for( soltEle = soltList->head; soltEle != NULL; soltEle = soltEle->next ) { + if( PK11_NeedLogin( soltEle->slot ) ) { + if( PK11_Authenticate( soltEle->slot, PR_TRUE, NULL ) != SECSuccess ) { + return NULL ; + } + } + + priKeyList = PK11_ListPrivateKeysInSlot( soltEle->slot ) ; + if( priKeyList != NULL ) { + for( curPri = PRIVKEY_LIST_HEAD( priKeyList ); !PRIVKEY_LIST_END( curPri, priKeyList ) && curPri != NULL ; curPri = PRIVKEY_LIST_NEXT( curPri ) ) { + xcert = NssPrivKeyToXCert( curPri->key ) ; + if( xcert != NULL ) + certsList.push_back( xcert ) ; + } + } + + SECKEY_DestroyPrivateKeyList( priKeyList ) ; + } + } + } + ----------*/ + + //secondly, we try to find certificate from registered private keys. + if( !m_tPriKeyList.empty() ) { + std::list< SECKEYPrivateKey* >::iterator priKeyIt ; + + for( priKeyIt = m_tPriKeyList.begin() ; priKeyIt != m_tPriKeyList.end() ; priKeyIt ++ ) { + xcert = NssPrivKeyToXCert( *priKeyIt ) ; + if( xcert != NULL ) + certsList.push_back( xcert ) ; + } + } + + length = certsList.size() ; + if( length != 0 ) { + int i ; + std::list< X509Certificate_NssImpl* >::iterator xcertIt ; + Sequence< Reference< XCertificate > > certSeq( length ) ; + + for( i = 0, xcertIt = certsList.begin(); xcertIt != certsList.end(); xcertIt ++, i++ ) { + certSeq[i] = *xcertIt ; + } + + return certSeq ; + } + + return NULL ; +} + +Reference< XCertificate > SecurityEnvironment_NssImpl :: getCertificate( const OUString& issuerName, const Sequence< sal_Int8 >& serialNumber ) throw( SecurityException , RuntimeException ) { + X509Certificate_NssImpl* xcert ; + + if( m_pHandler != NULL ) { + CERTIssuerAndSN issuerAndSN ; + CERTCertificate* cert ; + CERTName* nmIssuer ; + char* chIssuer ; + SECItem* derIssuer ; + PRArenaPool* arena ; + + arena = PORT_NewArena( DER_DEFAULT_CHUNKSIZE ) ; + if( arena == NULL ) + throw RuntimeException() ; + + rtl::OString ostr = rtl::OUStringToOString( issuerName , RTL_TEXTENCODING_ASCII_US ) ; + chIssuer = PL_strndup( ( char* )ostr.getStr(), ( int )ostr.getLength() ) ; + nmIssuer = CERT_AsciiToName( chIssuer ) ; + if( nmIssuer == NULL ) { + PL_strfree( chIssuer ) ; + PORT_FreeArena( arena, PR_FALSE ) ; + throw RuntimeException() ; + } + + derIssuer = SEC_ASN1EncodeItem( arena, NULL, ( void* )nmIssuer, SEC_ASN1_GET( CERT_NameTemplate ) ) ; + if( derIssuer == NULL ) { + PL_strfree( chIssuer ) ; + CERT_DestroyName( nmIssuer ) ; + PORT_FreeArena( arena, PR_FALSE ) ; + throw RuntimeException() ; + } + + memset( &issuerAndSN, 0, sizeof( issuerAndSN ) ) ; + + issuerAndSN.derIssuer.data = derIssuer->data ; + issuerAndSN.derIssuer.len = derIssuer->len ; + + issuerAndSN.serialNumber.data = ( unsigned char* )&serialNumber[0] ; + issuerAndSN.serialNumber.len = serialNumber.getLength() ; + + cert = CERT_FindCertByIssuerAndSN( m_pHandler, &issuerAndSN ) ; + if( cert != NULL ) { + xcert = NssCertToXCert( cert ) ; + } else { + xcert = NULL ; + } + + PL_strfree( chIssuer ) ; + CERT_DestroyName( nmIssuer ) ; + //SECITEM_FreeItem( derIssuer, PR_FALSE ) ; + CERT_DestroyCertificate( cert ) ; + PORT_FreeArena( arena, PR_FALSE ) ; + } else { + xcert = NULL ; + } + + return xcert ; +} + +Reference< XCertificate > SecurityEnvironment_NssImpl :: getCertificate( const OUString& issuerName, const OUString& serialNumber ) throw( SecurityException , RuntimeException ) { + Sequence< sal_Int8 > serial = numericStringToBigInteger( serialNumber ) ; + return getCertificate( issuerName, serial ) ; +} + +Sequence< Reference < XCertificate > > SecurityEnvironment_NssImpl :: buildCertificatePath( const Reference< XCertificate >& begin ) throw( SecurityException , RuntimeException ) { + const X509Certificate_NssImpl* xcert ; + const CERTCertificate* cert ; + CERTCertList* certChain ; + + Reference< XUnoTunnel > xCertTunnel( begin, UNO_QUERY ) ; + if( !xCertTunnel.is() ) { + throw RuntimeException() ; + } + + xcert = ( X509Certificate_NssImpl* )xCertTunnel->getSomething( X509Certificate_NssImpl::getUnoTunnelId() ) ; + if( xcert == NULL ) { + throw RuntimeException() ; + } + + cert = xcert->getNssCert() ; + if( cert != NULL ) { + int64 timeboundary ; + + //Get the system clock time + timeboundary = PR_Now() ; + + certChain = CERT_GetCertChainFromCert( ( CERTCertificate* )cert, timeboundary, certUsageAnyCA ) ; + } else { + certChain = NULL ; + } + + if( certChain != NULL ) { + X509Certificate_NssImpl* pCert ; + CERTCertListNode* node ; + int len ; + + for( len = 0, node = CERT_LIST_HEAD( certChain ); !CERT_LIST_END( node, certChain ); node = CERT_LIST_NEXT( node ), len ++ ) ; + Sequence< Reference< XCertificate > > xCertChain( len ) ; + + for( len = 0, node = CERT_LIST_HEAD( certChain ); !CERT_LIST_END( node, certChain ); node = CERT_LIST_NEXT( node ), len ++ ) { + pCert = new X509Certificate_NssImpl() ; + if( pCert == NULL ) { + CERT_DestroyCertList( certChain ) ; + throw RuntimeException() ; + } + + pCert->setCert( node->cert ) ; + + xCertChain[len] = pCert ; + } + + CERT_DestroyCertList( certChain ) ; + + return xCertChain ; + } + + return NULL ; +} + +Reference< XCertificate > SecurityEnvironment_NssImpl :: createCertificateFromRaw( const Sequence< sal_Int8 >& rawCertificate ) throw( SecurityException , RuntimeException ) { + X509Certificate_NssImpl* xcert ; + + if( rawCertificate.getLength() > 0 ) { + xcert = new X509Certificate_NssImpl() ; + if( xcert == NULL ) + throw RuntimeException() ; + + xcert->setRawCert( rawCertificate ) ; + } else { + xcert = NULL ; + } + + return xcert ; +} + +Reference< XCertificate > SecurityEnvironment_NssImpl :: createCertificateFromAscii( const OUString& asciiCertificate ) throw( SecurityException , RuntimeException ) { + xmlChar* chCert ; + xmlSecSize certSize ; + + rtl::OString oscert = rtl::OUStringToOString( asciiCertificate , RTL_TEXTENCODING_ASCII_US ) ; + + chCert = xmlStrndup( ( const xmlChar* )oscert.getStr(), ( int )oscert.getLength() ) ; + + certSize = xmlSecBase64Decode( chCert, ( xmlSecByte* )chCert, xmlStrlen( chCert ) ) ; + + Sequence< sal_Int8 > rawCert( certSize ) ; + for( unsigned int i = 0 ; i < certSize ; i ++ ) + rawCert[i] = *( chCert + i ) ; + + xmlFree( chCert ) ; + + return createCertificateFromRaw( rawCert ) ; +} + +X509Certificate_NssImpl* NssCertToXCert( CERTCertificate* cert ) +{ + X509Certificate_NssImpl* xcert ; + + if( cert != NULL ) { + xcert = new X509Certificate_NssImpl() ; + if( xcert == NULL ) { + xcert = NULL ; + } else { + xcert->setCert( cert ) ; + } + } else { + xcert = NULL ; + } + + return xcert ; +} + +X509Certificate_NssImpl* NssPrivKeyToXCert( SECKEYPrivateKey* priKey ) +{ + CERTCertificate* cert ; + X509Certificate_NssImpl* xcert ; + + if( priKey != NULL ) { + cert = PK11_GetCertFromPrivateKey( priKey ) ; + + if( cert != NULL ) { + xcert = NssCertToXCert( cert ) ; + } else { + xcert = NULL ; + } + + CERT_DestroyCertificate( cert ) ; + } else { + xcert = NULL ; + } + + return xcert ; +} + +/*- + * This is just one temporary conversion + */ +Sequence< sal_Int8 > numericStringToBigInteger ( + OUString serialNumber +) { + char* chSerial ; + unsigned long ui ; + unsigned char bb[5] ; + int len ; + + rtl::OString oseri = rtl::OUStringToOString( serialNumber , RTL_TEXTENCODING_ASCII_US ) ; + + chSerial = PL_strndup( ( char* )oseri.getStr(), ( int )oseri.getLength() ) ; + ui = PORT_Atoi( chSerial ) ; + PL_strfree( chSerial ) ; + + bb[0] = 0; + bb[1] = (unsigned char) (ui >> 24); + bb[2] = (unsigned char) (ui >> 16); + bb[3] = (unsigned char) (ui >> 8); + bb[4] = (unsigned char) (ui); + + /* + ** Small integers are encoded in a single byte. Larger integers + ** require progressively more space. + */ + if (ui > 0x7f) { + if (ui > 0x7fff) { + if (ui > 0x7fffffL) { + if (ui >= 0x80000000L) { + len = 5; + } else { + len = 4; + } + } else { + len = 3; + } + } else { + len = 2; + } + } else { + len = 1; + } + + Sequence< sal_Int8 > serial( len ) ; + for( int i = 0 ; i < len ; i ++ ) + serial[i] = *( bb + sizeof( bb ) - len + i ) ; + + return serial ; +} + +/*- + * This is just one temporary conversion + */ +OUString bigIntegerToNumericString ( Sequence< sal_Int8 > serial) +{ + OUString aRet; + + if ( serial.getLength() ) + { + SECItem snItem ; + long sn ; + + snItem.data = ( unsigned char* )&serial[0] ; + snItem.len = serial.getLength() ; + + sn = DER_GetInteger( &snItem ) ; + if( sn != ULONG_MAX ) + { + char str[10] ; + int len ; + len = sprintf( str, "%d", sn ) ; + aRet = OUString::createFromAscii( str ) ; + } + } + return aRet; +} diff --git a/xmlsecurity/source/xmlsec/nss/securityenvironment_nssimpl.hxx b/xmlsecurity/source/xmlsec/nss/securityenvironment_nssimpl.hxx new file mode 100644 index 000000000000..54d771544075 --- /dev/null +++ b/xmlsecurity/source/xmlsec/nss/securityenvironment_nssimpl.hxx @@ -0,0 +1,210 @@ +/************************************************************************* + * + * $RCSfile: securityenvironment_nssimpl.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:21 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _XSECURITYENVIRONMENT_NSSIMPL_HXX_ +#define _XSECURITYENVIRONMENT_NSSIMPL_HXX_ + +#ifndef _SAL_CONFIG_H_ +#include +#endif + +#ifndef _RTL_USTRING_HXX_ +#include +#endif + +#ifndef _CPPUHELPER_FACTORY_HXX_ +#include +#endif + +#ifndef _CPPUHELPER_IMPLBASE4_HXX_ +#include +#endif + +#ifndef _COM_SUN_STAR_UNO_EXCEPTION_HPP_ +#include +#endif + +#ifndef _COM_SUN_STAR_UNO_REFERENCE_HPP_ +#include +#endif + +#ifndef _COM_SUN_STAR_LANG_XSINGLESERVICEFACTORY_HPP_ +#include +#endif + +#ifndef _COM_SUN_STAR_LANG_XSECVICEINFO_HPP_ +#include +#endif + +#ifndef _COM_SUN_STAR_LANG_XINITIALIZATION_HPP_ +#include +#endif + +#ifndef _COM_SUN_STAR_XML_CRYPTO_XSECURITYENVIRONMENT_HPP_ +#include +#endif + +#ifndef _COM_SUN_STAR_SECURITY_XCERTIFICATE_HPP_ +#include +#endif + +#ifndef _COM_SUN_STAR_LANG_XUNOTUNNEL_HPP_ +#include +#endif + +#include "pk11func.h" +#include "keyhi.h" +#include "certdb.h" +#include "list" + +class SecurityEnvironment_NssImpl : public ::cppu::WeakImplHelper4< + ::com::sun::star::xml::crypto::XSecurityEnvironment , + ::com::sun::star::lang::XInitialization , + ::com::sun::star::lang::XServiceInfo , + ::com::sun::star::lang::XUnoTunnel > +{ + private : + PK11SlotInfo* m_pSlot ; + CERTCertDBHandle* m_pHandler ; + std::list< PK11SymKey* > m_tSymKeyList ; + std::list< SECKEYPublicKey* > m_tPubKeyList ; + std::list< SECKEYPrivateKey* > m_tPriKeyList ; + ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xServiceManager ; + + public : + SecurityEnvironment_NssImpl( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& aFactory ) ; + virtual ~SecurityEnvironment_NssImpl() ; + + //Methods from XSecurityEnvironment + + //Methods from XInitialization + virtual void SAL_CALL initialize( + const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments + ) throw( ::com::sun::star::uno::Exception , ::com::sun::star::uno::RuntimeException ) ; + + //Methods from XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName() throw( ::com::sun::star::uno::RuntimeException ) ; + + virtual sal_Bool SAL_CALL supportsService( + const ::rtl::OUString& ServiceName + ) throw( ::com::sun::star::uno::RuntimeException ) ; + + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw( ::com::sun::star::uno::RuntimeException ) ; + + //Helper for XServiceInfo + static ::com::sun::star::uno::Sequence< ::rtl::OUString > impl_getSupportedServiceNames() ; + + static ::rtl::OUString impl_getImplementationName() throw( ::com::sun::star::uno::RuntimeException ) ; + + //Helper for registry + static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL impl_createInstance( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& aServiceManager ) throw( ::com::sun::star::uno::RuntimeException ) ; + + static ::com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleServiceFactory > impl_createFactory( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& aServiceManager ) ; + + //Methods from XUnoTunnel + virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) + throw (::com::sun::star::uno::RuntimeException); + + static const ::com::sun::star::uno::Sequence< sal_Int8 >& getUnoTunnelId() ; + static SecurityEnvironment_NssImpl* getImplementation( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > xObj ) ; + + //Native mehtods + virtual PK11SlotInfo* getCryptoSlot() throw( ::com::sun::star::uno::Exception , ::com::sun::star::uno::RuntimeException ) ; + + virtual void setCryptoSlot( PK11SlotInfo* aSlot ) throw( ::com::sun::star::uno::Exception , ::com::sun::star::uno::RuntimeException ) ; + + virtual CERTCertDBHandle* getCertDb() throw( ::com::sun::star::uno::Exception , ::com::sun::star::uno::RuntimeException ) ; + + virtual void setCertDb( CERTCertDBHandle* aCertDb ) throw( ::com::sun::star::uno::Exception , ::com::sun::star::uno::RuntimeException ) ; + + virtual void adoptSymKey( PK11SymKey* aSymKey ) throw( ::com::sun::star::uno::Exception , ::com::sun::star::uno::RuntimeException ) ; + + virtual void rejectSymKey( PK11SymKey* aSymKey ) throw( ::com::sun::star::uno::Exception , ::com::sun::star::uno::RuntimeException ) ; + + virtual PK11SymKey* getSymKey( unsigned int position ) throw( ::com::sun::star::uno::Exception , ::com::sun::star::uno::RuntimeException ) ; + + virtual void adoptPubKey( SECKEYPublicKey* aPubKey ) throw( ::com::sun::star::uno::Exception , ::com::sun::star::uno::RuntimeException ) ; + + virtual void rejectPubKey( SECKEYPublicKey* aPubKey ) throw( ::com::sun::star::uno::Exception , ::com::sun::star::uno::RuntimeException ) ; + + virtual SECKEYPublicKey* getPubKey( unsigned int position ) throw( ::com::sun::star::uno::Exception , ::com::sun::star::uno::RuntimeException ) ; + + virtual void adoptPriKey( SECKEYPrivateKey* aPriKey ) throw( ::com::sun::star::uno::Exception , ::com::sun::star::uno::RuntimeException ) ; + + virtual void rejectPriKey( SECKEYPrivateKey* aPriKey ) throw( ::com::sun::star::uno::Exception , ::com::sun::star::uno::RuntimeException ) ; + + virtual SECKEYPrivateKey* getPriKey( unsigned int position ) throw( ::com::sun::star::uno::Exception , ::com::sun::star::uno::RuntimeException ) ; + + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::security::XCertificate > > SAL_CALL getPersonalCertificates() throw( ::com::sun::star::uno::SecurityException , ::com::sun::star::uno::RuntimeException ) ; + + virtual ::com::sun::star::uno::Reference< ::com::sun::star::security::XCertificate > SAL_CALL getCertificate( const ::rtl::OUString& issuerName, const ::com::sun::star::uno::Sequence< sal_Int8 >& serialNumber ) throw( ::com::sun::star::uno::SecurityException , ::com::sun::star::uno::RuntimeException ) ; + + virtual ::com::sun::star::uno::Reference< ::com::sun::star::security::XCertificate > SAL_CALL getCertificate( const ::rtl::OUString& issuerName, const ::rtl::OUString& serialNumber ) throw( ::com::sun::star::uno::SecurityException , ::com::sun::star::uno::RuntimeException ) ; + + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::security::XCertificate > > SAL_CALL buildCertificatePath( const ::com::sun::star::uno::Reference< ::com::sun::star::security::XCertificate >& beginCert ) throw( ::com::sun::star::uno::SecurityException , ::com::sun::star::uno::RuntimeException ) ; + + virtual ::com::sun::star::uno::Reference< ::com::sun::star::security::XCertificate > SAL_CALL createCertificateFromRaw( const ::com::sun::star::uno::Sequence< sal_Int8 >& rawCertificate ) throw( ::com::sun::star::uno::SecurityException , ::com::sun::star::uno::RuntimeException ) ; + + virtual ::com::sun::star::uno::Reference< ::com::sun::star::security::XCertificate > SAL_CALL createCertificateFromAscii( const ::rtl::OUString& asciiCertificate ) throw( ::com::sun::star::uno::SecurityException , ::com::sun::star::uno::RuntimeException ) ; +} ; + +#endif // _XSECURITYENVIRONMENT_NSSIMPL_HXX_ + diff --git a/xmlsecurity/source/xmlsec/nss/seinitializer_nssimpl.cxx b/xmlsecurity/source/xmlsec/nss/seinitializer_nssimpl.cxx new file mode 100644 index 000000000000..a9bea86e4d85 --- /dev/null +++ b/xmlsecurity/source/xmlsec/nss/seinitializer_nssimpl.cxx @@ -0,0 +1,390 @@ +/************************************************************************* + * + * $RCSfile: seinitializer_nssimpl.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:21 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +/* + * Turn off DEBUG Assertions + */ +#ifdef _DEBUG + #define _DEBUG_WAS_DEFINED _DEBUG + #undef _DEBUG +#else + #undef _DEBUG_WAS_DEFINED +#endif + +/* + * and turn off the additional virtual methods which are part of some interfaces when compiled + * with debug + */ +#ifdef DEBUG + #define DEBUG_WAS_DEFINED DEBUG + #undef DEBUG +#else + #undef DEBUG_WAS_DEFINED +#endif + +/* + * header files needed for getCurrentProfilePath + */ +#include "nsIServiceManager.h" +#include "nsIProfileInternal.h" +#include "nsString.h" +#include "nsEmbedAPI.h" +#include + + +#include "seinitializer_nssimpl.hxx" + +#include "securityenvironment_nssimpl.hxx" + +#include "nspr.h" +#include "prtypes.h" +#include "pk11func.h" +#include "cert.h" +#include "cryptohi.h" +#include "certdb.h" +#include "nss.h" + +namespace cssu = com::sun::star::uno; +namespace cssl = com::sun::star::lang; +namespace cssxc = com::sun::star::xml::crypto; + +using namespace com::sun::star; + +#define SERVICE_NAME "com.sun.star.xml.crypto.SEInitializer" +#define IMPLEMENTATION_NAME "com.sun.star.xml.security.bridge.xmlsec.SEInitializer_NssImpl" +#define SECURITY_ENVIRONMENT "com.sun.star.xml.crypto.SecurityEnvironment" +#define SECURITY_CONTEXT "com.sun.star.xml.crypto.XMLSecurityContext" + +/* + * MM : get the current user profile + */ + +// MM : By now, the XPCOM is initialized only once in the current thread, and it will +// not be shutdown until StarOffice exits. +// This is a bug, because any other component who will initialize the XPCOM afterward +// will always fail. +// This bug will be fixed when there is solution. +static nsIServiceManager *sServiceManager = nsnull; +static nsIDirectoryServiceProvider *appFileLocProvider = nsnull; +static NS_DEFINE_CID(kProfileCID, NS_PROFILE_CID); + +char* getCurrentProfilePath( ) +{ + nsCOMPtr binDir; + + if (sServiceManager == nsnull) + { + NS_InitXPCOM2(&sServiceManager, binDir, appFileLocProvider); + } + + if (!sServiceManager) + return NULL; + + nsresult rv; + nsCOMPtr< nsIProfile > theProfile = do_GetService( kProfileCID, &rv ); + if (NS_SUCCEEDED(rv)) + { + nsXPIDLString profileName; + rv = theProfile->GetCurrentProfile(getter_Copies(profileName)); + if (NS_SUCCEEDED(rv)) + { + nsCOMPtr curProfileDir; + PRBool exists = PR_FALSE; + nsCOMPtr profileInternal=do_QueryInterface(theProfile); + if (NS_SUCCEEDED(rv)) + { + rv = profileInternal->GetProfileDir(profileName, getter_AddRefs(curProfileDir)); + if (NS_SUCCEEDED(rv)) + { + nsCOMPtr localFile(do_QueryInterface(curProfileDir)); + + nsAutoString path; + rv = localFile->GetPath(path); + if (NS_SUCCEEDED(rv)) + { + char cs[1024]; + path.ToCString(cs, 1024); + + // MM : I can't shutdown, because the XPCom can't be initialized twice in + // one program + //NS_RELEASE(sServiceManager); + //NS_ShutdownXPCOM(sServiceManager); + + return (strdup(cs)); + } + } + } + } + } + + + // MM : I can't shutdown, because the XPCom can't be initialized twice in + // one program + //NS_RELEASE(sServiceManager); + //NS_ShutdownXPCOM(sServiceManager); + + return NULL; +} + +/* + * get the current user profile (end) + */ + +SEInitializer_NssImpl::SEInitializer_NssImpl( + const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > &rxMSF) + :mxMSF( rxMSF ) +{ +} + +SEInitializer_NssImpl::~SEInitializer_NssImpl() +{ +} + +/* XSEInitializer */ +cssu::Reference< cssxc::XXMLSecurityContext > SAL_CALL + SEInitializer_NssImpl::createSecurityContext( + const rtl::OUString& sCertDB ) + throw (cssu::RuntimeException) +{ + CERTCertDBHandle* pCertHandle = NULL ; + PK11SlotInfo* pSlot = NULL ; + + rtl::OString sCertDir; + if( sCertDB.getLength() > 0 ) + { + sCertDir = rtl::OString(sCertDB, sCertDB.getLength(), RTL_TEXTENCODING_ASCII_US); + } + else + { + char *pCurrentProfilePath = getCurrentProfilePath(); + + if (pCurrentProfilePath == NULL) + { + return NULL; + } + else + { + sCertDir = rtl::OString(pCurrentProfilePath); + free(pCurrentProfilePath); + } + } + + /* Initialize NSPR and NSS */ + PR_Init( PR_SYSTEM_THREAD, PR_PRIORITY_NORMAL, 1 ) ; + + if (NSS_Init(sCertDir.getStr()) != SECSuccess ) + { + PK11_LogoutAll(); + return NULL; + } + + pCertHandle = CERT_GetDefaultCertDB() ; + pSlot = PK11_GetInternalKeySlot() ; + + if (pSlot == NULL) + { + PK11_LogoutAll(); + NSS_Shutdown(); + return NULL; + } + + PK11SymKey* pSymKey = PK11_KeyGen( pSlot , CKM_DES3_CBC, NULL, 128, NULL ) ; + if( pSymKey == NULL ) + { + PK11_FreeSlot( pSlot ) ; + PK11_LogoutAll(); + NSS_Shutdown(); + return NULL; + } + + try + { + /* Build Security Environment */ + const rtl::OUString sSecyrutyEnvironment ( RTL_CONSTASCII_USTRINGPARAM( SECURITY_ENVIRONMENT ) ); + cssu::Reference< cssxc::XSecurityEnvironment > xSecEnv( mxMSF->createInstance ( sSecyrutyEnvironment ), cssu::UNO_QUERY ); + if( !xSecEnv.is() ) + { + PK11_FreeSymKey( pSymKey ) ; + PK11_FreeSlot( pSlot ) ; + PK11_LogoutAll(); + NSS_Shutdown(); + return NULL; + } + + /* Setup key slot and certDb */ + cssu::Reference< cssl::XUnoTunnel > xEnvTunnel( xSecEnv , cssu::UNO_QUERY ) ; + if( !xEnvTunnel.is() ) + { + PK11_FreeSymKey( pSymKey ) ; + PK11_FreeSlot( pSlot ) ; + PK11_LogoutAll(); + NSS_Shutdown(); + return NULL; + } + + SecurityEnvironment_NssImpl* pSecEnv = ( SecurityEnvironment_NssImpl* )xEnvTunnel->getSomething( SecurityEnvironment_NssImpl::getUnoTunnelId() ) ; + if( pSecEnv == NULL ) + { + PK11_FreeSymKey( pSymKey ) ; + PK11_FreeSlot( pSlot ) ; + PK11_LogoutAll(); + NSS_Shutdown(); + return NULL; + } + + pSecEnv->setCryptoSlot( pSlot ) ; + PK11_FreeSlot( pSlot ) ; + pSlot = NULL; + + pSecEnv->setCertDb( pCertHandle ) ; + + pSecEnv->adoptSymKey( pSymKey ) ; + PK11_FreeSymKey( pSymKey ) ; + pSymKey = NULL; + + /* Build XML Security Context */ + const rtl::OUString sSecyrutyContext ( RTL_CONSTASCII_USTRINGPARAM( SECURITY_CONTEXT ) ); + cssu::Reference< cssxc::XXMLSecurityContext > xSecCtx( mxMSF->createInstance ( sSecyrutyContext ), cssu::UNO_QUERY ); + if( !xSecCtx.is() ) + { + PK11_LogoutAll(); + NSS_Shutdown(); + return NULL; + } + + xSecCtx->setSecurityEnvironment( xSecEnv ) ; + return xSecCtx; + } + catch( cssu::Exception& ) + { + if (pSymKey != NULL) + { + PK11_FreeSymKey( pSymKey ) ; + } + + if (pSlot != NULL) + { + PK11_FreeSlot( pSlot ) ; + } + + PK11_LogoutAll(); + NSS_Shutdown(); + return NULL; + } +} + +void SAL_CALL SEInitializer_NssImpl::freeSecurityContext( const cssu::Reference< cssxc::XXMLSecurityContext >& securityContext ) + throw (cssu::RuntimeException) +{ + /* + * because the security context will free all its content when it + * is destructed, so here no free process for the security context + * is needed. + */ + PK11_LogoutAll(); + NSS_Shutdown(); +} + +rtl::OUString SEInitializer_NssImpl_getImplementationName () + throw (cssu::RuntimeException) +{ + return rtl::OUString ( RTL_CONSTASCII_USTRINGPARAM ( IMPLEMENTATION_NAME ) ); +} + +sal_Bool SAL_CALL SEInitializer_NssImpl_supportsService( const rtl::OUString& ServiceName ) + throw (cssu::RuntimeException) +{ + return ServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( SERVICE_NAME )); +} + +cssu::Sequence< rtl::OUString > SAL_CALL SEInitializer_NssImpl_getSupportedServiceNames( ) + throw (cssu::RuntimeException) +{ + cssu::Sequence < rtl::OUString > aRet(1); + rtl::OUString* pArray = aRet.getArray(); + pArray[0] = rtl::OUString ( RTL_CONSTASCII_USTRINGPARAM ( SERVICE_NAME ) ); + return aRet; +} +#undef SERVICE_NAME + +cssu::Reference< cssu::XInterface > SAL_CALL SEInitializer_NssImpl_createInstance( const cssu::Reference< cssl::XMultiServiceFactory > & rSMgr) + throw( cssu::Exception ) +{ + return (cppu::OWeakObject*) new SEInitializer_NssImpl(rSMgr); +} + +/* XServiceInfo */ +rtl::OUString SAL_CALL SEInitializer_NssImpl::getImplementationName( ) + throw (cssu::RuntimeException) +{ + return SEInitializer_NssImpl_getImplementationName(); +} +sal_Bool SAL_CALL SEInitializer_NssImpl::supportsService( const rtl::OUString& rServiceName ) + throw (cssu::RuntimeException) +{ + return SEInitializer_NssImpl_supportsService( rServiceName ); +} +cssu::Sequence< rtl::OUString > SAL_CALL SEInitializer_NssImpl::getSupportedServiceNames( ) + throw (cssu::RuntimeException) +{ + return SEInitializer_NssImpl_getSupportedServiceNames(); +} + diff --git a/xmlsecurity/source/xmlsec/nss/seinitializer_nssimpl.hxx b/xmlsecurity/source/xmlsec/nss/seinitializer_nssimpl.hxx new file mode 100644 index 000000000000..dcca7207b05b --- /dev/null +++ b/xmlsecurity/source/xmlsec/nss/seinitializer_nssimpl.hxx @@ -0,0 +1,152 @@ +/************************************************************************* + * + * $RCSfile: seinitializer_nssimpl.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:21 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _SEINITIALIZERIMPL_HXX +#define _SEINITIALIZERIMPL_HXX + +#ifndef _COM_SUN_STAR_XML_CRYPTO_XXMLSECURITYCONTEXT_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_XML_CRYPTO_SEINITIALIZER_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_LANG_XUNOTUNNEL_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_ +#include +#endif +#ifndef _CPPUHELPER_IMPLBASE2_HXX_ +#include +#endif + +#include + +class SEInitializer_NssImpl : public cppu::WeakImplHelper2 +< + com::sun::star::xml::crypto::XSEInitializer, + com::sun::star::lang::XServiceInfo +> +/****** SEInitializer_NssImpl.hxx/CLASS SEInitializer_NssImpl *********** + * + * NAME + * SEInitializer_NssImpl -- Class to initialize a Security Context + * instance + * + * FUNCTION + * Use this class to initialize a XmlSec based Security Context + * instance. After this instance is used up, use this class to free this + * instance. + * + * HISTORY + * 05.01.2004 - Interface supported: XSEInitializer, XSEInitializer + * + * AUTHOR + * Michael Mi + * Email: michael.mi@sun.com + ******************************************************************************/ +{ +private: + com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > mxMSF; + +public: + SEInitializer_NssImpl(const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > &rxMSF); + virtual ~SEInitializer_NssImpl(); + + /* XSEInitializer */ + virtual com::sun::star::uno::Reference< + com::sun::star::xml::crypto::XXMLSecurityContext > + SAL_CALL createSecurityContext( const rtl::OUString& certDB ) + throw (com::sun::star::uno::RuntimeException); + + virtual void SAL_CALL freeSecurityContext( const com::sun::star::uno::Reference< + com::sun::star::xml::crypto::XXMLSecurityContext >& securityContext ) + throw (com::sun::star::uno::RuntimeException); + + /* XServiceInfo */ + virtual rtl::OUString SAL_CALL getImplementationName( ) + throw (com::sun::star::uno::RuntimeException); + + virtual sal_Bool SAL_CALL supportsService( const rtl::OUString& ServiceName ) + throw (com::sun::star::uno::RuntimeException); + + virtual com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames( ) + throw (com::sun::star::uno::RuntimeException); +}; + +rtl::OUString SEInitializer_NssImpl_getImplementationName() + throw ( com::sun::star::uno::RuntimeException ); + +sal_Bool SAL_CALL SEInitializer_NssImpl_supportsService( const rtl::OUString& ServiceName ) + throw ( com::sun::star::uno::RuntimeException ); + +com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL SEInitializer_NssImpl_getSupportedServiceNames( ) + throw ( com::sun::star::uno::RuntimeException ); + +com::sun::star::uno::Reference< com::sun::star::uno::XInterface > +SAL_CALL SEInitializer_NssImpl_createInstance( const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > & rSMgr) + throw ( com::sun::star::uno::Exception ); + +#endif + diff --git a/xmlsecurity/source/xmlsec/nss/x509certificate_nssimpl.cxx b/xmlsecurity/source/xmlsec/nss/x509certificate_nssimpl.cxx new file mode 100644 index 000000000000..13a1be861811 --- /dev/null +++ b/xmlsecurity/source/xmlsec/nss/x509certificate_nssimpl.cxx @@ -0,0 +1,360 @@ +/************************************************************************* + * + * $RCSfile: x509certificate_nssimpl.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:21 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _SAL_CONFIG_H_ +#include +#endif + +#ifndef _RTL_UUID_H_ +#include +#endif + +#ifndef _X509CERTIFICATE_NSSIMPL_HXX_ +#include "x509certificate_nssimpl.hxx" +#endif + +#ifndef _CERTIFICATEEXTENSION_NSSIMPL_HXX_ +#include "certificateextension_xmlsecimpl.hxx" +#endif + +#include "nspr.h" +#include "nss.h" +#include "secder.h" + +using namespace ::com::sun::star::uno ; +using namespace ::com::sun::star::security ; +using ::rtl::OUString ; + +using ::com::sun::star::security::XCertificate ; +using ::com::sun::star::util::DateTime ; + +X509Certificate_NssImpl :: X509Certificate_NssImpl() : + m_pCert( NULL ) +{ +} + +X509Certificate_NssImpl :: ~X509Certificate_NssImpl() { + if( m_pCert != NULL ) { + CERT_DestroyCertificate( m_pCert ) ; + } +} + +//Methods from XCertificate +sal_Int16 SAL_CALL X509Certificate_NssImpl :: getVersion() throw ( ::com::sun::star::uno::RuntimeException) { + if( m_pCert != NULL ) { + if( m_pCert->version.len > 0 ) { + return ( char )*( m_pCert->version.data ) ; + } else + return 0 ; + } else { + return -1 ; + } +} + +::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL X509Certificate_NssImpl :: getSerialNumber() throw ( ::com::sun::star::uno::RuntimeException) { + if( m_pCert != NULL && m_pCert->serialNumber.len > 0 ) { + Sequence< sal_Int8 > serial( m_pCert->serialNumber.len ) ; + for( unsigned int i = 0 ; i < m_pCert->serialNumber.len ; i ++ ) + serial[i] = *( m_pCert->serialNumber.data + i ) ; + + return serial ; + } else { + return NULL ; + } +} + +::rtl::OUString SAL_CALL X509Certificate_NssImpl :: getIssuerName() throw ( ::com::sun::star::uno::RuntimeException) { + if( m_pCert != NULL ) { + return OUString::createFromAscii( m_pCert->issuerName ) ; + } else { + return OUString() ; + } +} + +::rtl::OUString SAL_CALL X509Certificate_NssImpl :: getSubjectName() throw ( ::com::sun::star::uno::RuntimeException) { + if( m_pCert != NULL ) { + return OUString::createFromAscii( m_pCert->subjectName ) ; + } else { + return OUString() ; + } +} + +::com::sun::star::util::DateTime SAL_CALL X509Certificate_NssImpl :: getNotBefore() throw ( ::com::sun::star::uno::RuntimeException) { + if( m_pCert != NULL ) { + SECStatus rv ; + PRTime notBefore ; + PRExplodedTime explTime ; + DateTime dateTime ; + + rv = DER_DecodeTimeChoice( ¬Before, &m_pCert->validity.notBefore ) ; + if( rv ) { + return DateTime() ; + } + + //Convert the time to readable local time + PR_ExplodeTime( notBefore, PR_LocalTimeParameters, &explTime ) ; + + dateTime.HundredthSeconds = explTime.tm_usec / 1000 ; + dateTime.Seconds = explTime.tm_sec ; + dateTime.Minutes = explTime.tm_min ; + dateTime.Hours = explTime.tm_hour ; + dateTime.Day = explTime.tm_mday ; + dateTime.Month = explTime.tm_month ; + dateTime.Year = explTime.tm_year ; + + return dateTime ; + } else { + return DateTime() ; + } +} + +::com::sun::star::util::DateTime SAL_CALL X509Certificate_NssImpl :: getNotAfter() throw ( ::com::sun::star::uno::RuntimeException) { + if( m_pCert != NULL ) { + SECStatus rv ; + PRTime notAfter ; + PRExplodedTime explTime ; + DateTime dateTime ; + + rv = DER_DecodeTimeChoice( ¬After, &m_pCert->validity.notAfter ) ; + if( rv ) { + return DateTime() ; + } + + //Convert the time to readable local time + PR_ExplodeTime( notAfter, PR_LocalTimeParameters, &explTime ) ; + + dateTime.HundredthSeconds = explTime.tm_usec / 1000 ; + dateTime.Seconds = explTime.tm_sec ; + dateTime.Minutes = explTime.tm_min ; + dateTime.Hours = explTime.tm_hour ; + dateTime.Day = explTime.tm_mday ; + dateTime.Month = explTime.tm_month ; + dateTime.Year = explTime.tm_year ; + + return dateTime ; + } else { + return DateTime() ; + } +} + +::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL X509Certificate_NssImpl :: getIssuerUniqueID() throw ( ::com::sun::star::uno::RuntimeException) { + if( m_pCert != NULL && m_pCert->issuerID.len > 0 ) { + Sequence< sal_Int8 > issuerUid( m_pCert->issuerID.len ) ; + for( unsigned int i = 0 ; i < m_pCert->issuerID.len ; i ++ ) + issuerUid[i] = *( m_pCert->issuerID.data + i ) ; + + return issuerUid ; + } else { + return NULL ; + } +} + +::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL X509Certificate_NssImpl :: getSubjectUniqueID() throw ( ::com::sun::star::uno::RuntimeException) { + if( m_pCert != NULL && m_pCert->subjectID.len > 0 ) { + Sequence< sal_Int8 > subjectUid( m_pCert->subjectID.len ) ; + for( unsigned int i = 0 ; i < m_pCert->subjectID.len ; i ++ ) + subjectUid[i] = *( m_pCert->subjectID.data + i ) ; + + return subjectUid ; + } else { + return NULL ; + } +} + +::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::security::XCertificateExtension > > SAL_CALL X509Certificate_NssImpl :: getExtensions() throw ( ::com::sun::star::uno::RuntimeException) { + if( m_pCert != NULL && m_pCert->extensions != NULL ) { + CERTCertExtension** extns ; + CertificateExtension_XmlSecImpl* pExtn ; + sal_Bool crit ; + int len ; + + for( len = 0, extns = m_pCert->extensions; *extns != NULL; len ++, extns ++ ) ; + Sequence< Reference< XCertificateExtension > > xExtns( len ) ; + + for( extns = m_pCert->extensions, len = 0; *extns != NULL; extns ++, len ++ ) { + pExtn = new CertificateExtension_XmlSecImpl() ; + if( (*extns)->critical.data == NULL ) + crit = sal_False ; + else + crit = ( (*extns)->critical.data[0] == 0xFF ) ? sal_True : sal_False ; + pExtn->setCertExtn( (*extns)->value.data, (*extns)->value.len, (*extns)->id.data, (*extns)->id.len, crit ) ; + + xExtns[len] = pExtn ; + } + + return xExtns ; + } else { + return NULL ; + } +} + +::com::sun::star::uno::Reference< ::com::sun::star::security::XCertificateExtension > SAL_CALL X509Certificate_NssImpl :: findCertExtension( const ::com::sun::star::uno::Sequence< sal_Int8 >& oid ) throw (::com::sun::star::uno::RuntimeException) { + if( m_pCert != NULL && m_pCert->extensions != NULL ) { + CertificateExtension_XmlSecImpl* pExtn ; + CERTCertExtension** extns ; + SECItem idItem ; + sal_Bool crit ; + + idItem.data = ( unsigned char* )&oid[0] ; + idItem.len = oid.getLength() ; + + pExtn = NULL ; + for( extns = m_pCert->extensions; *extns != NULL; extns ++ ) { + if( SECITEM_CompareItem( &idItem, &(*extns)->id ) == SECEqual ) { + pExtn = new CertificateExtension_XmlSecImpl() ; + if( (*extns)->critical.data == NULL ) + crit = sal_False ; + else + crit = ( (*extns)->critical.data[0] == 0xFF ) ? sal_True : sal_False ; + pExtn->setCertExtn( (*extns)->value.data, (*extns)->value.len, (*extns)->id.data, (*extns)->id.len, crit ) ; + } + } + + return pExtn ; + } else { + return NULL ; + } +} + + +::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL X509Certificate_NssImpl :: getEncoded() throw ( ::com::sun::star::uno::RuntimeException) { + if( m_pCert != NULL && m_pCert->derCert.len > 0 ) { + Sequence< sal_Int8 > rawCert( m_pCert->derCert.len ) ; + + for( unsigned int i = 0 ; i < m_pCert->derCert.len ; i ++ ) + rawCert[i] = *( m_pCert->derCert.data + i ) ; + + return rawCert ; + } else { + return NULL ; + } +} + +//Helper methods +void X509Certificate_NssImpl :: setCert( CERTCertificate* cert ) { + if( m_pCert != NULL ) { + CERT_DestroyCertificate( m_pCert ) ; + m_pCert = NULL ; + } + + if( cert != NULL ) { + m_pCert = CERT_DupCertificate( cert ) ; + } +} + +const CERTCertificate* X509Certificate_NssImpl :: getNssCert() const { + if( m_pCert != NULL ) { + return m_pCert ; + } else { + return NULL ; + } +} + +void X509Certificate_NssImpl :: setRawCert( Sequence< sal_Int8 > rawCert ) throw ( ::com::sun::star::uno::RuntimeException) { + CERTCertificate* cert ; + SECItem certItem ; + + certItem.data = ( unsigned char* )&rawCert[0] ; + certItem.len = rawCert.getLength() ; + + cert = CERT_DecodeDERCertificate( &certItem, PR_TRUE, NULL ) ; + if( cert == NULL ) + throw RuntimeException() ; + + if( m_pCert != NULL ) { + CERT_DestroyCertificate( m_pCert ) ; + m_pCert = NULL ; + } + + m_pCert = cert ; +} + +/* XUnoTunnel */ +sal_Int64 SAL_CALL X509Certificate_NssImpl :: getSomething( const Sequence< sal_Int8 >& aIdentifier ) throw( RuntimeException ) { + if( aIdentifier.getLength() == 16 && 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(), aIdentifier.getConstArray(), 16 ) ) { + return ( sal_Int64 )this ; + } + return 0 ; +} + +/* XUnoTunnel extension */ +const Sequence< sal_Int8>& X509Certificate_NssImpl :: getUnoTunnelId() { + static Sequence< sal_Int8 >* pSeq = 0 ; + if( !pSeq ) { + ::osl::Guard< ::osl::Mutex > aGuard( ::osl::Mutex::getGlobalMutex() ) ; + if( !pSeq ) { + static Sequence< sal_Int8> aSeq( 16 ) ; + rtl_createUuid( ( sal_uInt8* )aSeq.getArray() , 0 , sal_True ) ; + pSeq = &aSeq ; + } + } + return *pSeq ; +} + +/* XUnoTunnel extension */ +X509Certificate_NssImpl* X509Certificate_NssImpl :: getImplementation( const Reference< XInterface > xObj ) { + Reference< XUnoTunnel > xUT( xObj , UNO_QUERY ) ; + if( xUT.is() ) { + return ( X509Certificate_NssImpl* )xUT->getSomething( getUnoTunnelId() ) ; + } else + return NULL ; +} + diff --git a/xmlsecurity/source/xmlsec/nss/x509certificate_nssimpl.hxx b/xmlsecurity/source/xmlsec/nss/x509certificate_nssimpl.hxx new file mode 100644 index 000000000000..3078ad16c64c --- /dev/null +++ b/xmlsecurity/source/xmlsec/nss/x509certificate_nssimpl.hxx @@ -0,0 +1,146 @@ +/************************************************************************* + * + * $RCSfile: x509certificate_nssimpl.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:21 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _X509CERTIFICATE_NSSIMPL_HXX_ +#define _X509CERTIFICATE_NSSIMPL_HXX_ + +#ifndef _SAL_CONFIG_H_ +#include +#endif + +#ifndef _RTL_USTRING_HXX_ +#include +#endif + +#ifndef _CPPUHELPER_FACTORY_HXX_ +#include +#endif + +#ifndef _CPPUHELPER_IMPLBASE2_HXX_ +#include +#endif + +#ifndef _COM_SUN_STAR_UNO_EXCEPTION_HPP_ +#include +#endif + +#ifndef _COM_SUN_STAR_LANG_XUNOTUNNEL_HPP_ +#include +#endif + +#ifndef _COM_SUN_STAR_UNO_SECURITYEXCEPTION_HPP_ +#include "com/sun/star/uno/SecurityException.hpp" +#endif + +#ifndef _COM_SUN_STAR_SECURITY_XCERTIFICATE_HPP_ +#include +#endif + +#include "cert.h" + +class X509Certificate_NssImpl : public ::cppu::WeakImplHelper2< + ::com::sun::star::security::XCertificate , + ::com::sun::star::lang::XUnoTunnel > +{ + private : + CERTCertificate* m_pCert ; + + public : + X509Certificate_NssImpl() ; + virtual ~X509Certificate_NssImpl() ; + + //Methods from XCertificate + virtual sal_Int16 SAL_CALL getVersion( ) throw ( ::com::sun::star::uno::RuntimeException) ; + + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getSerialNumber( ) throw ( ::com::sun::star::uno::RuntimeException) ; + + virtual ::rtl::OUString SAL_CALL getIssuerName( ) throw ( ::com::sun::star::uno::RuntimeException) ; + + virtual ::rtl::OUString SAL_CALL getSubjectName( ) throw ( ::com::sun::star::uno::RuntimeException) ; + + virtual ::com::sun::star::util::DateTime SAL_CALL getNotBefore( ) throw ( ::com::sun::star::uno::RuntimeException) ; + + virtual ::com::sun::star::util::DateTime SAL_CALL getNotAfter( ) throw ( ::com::sun::star::uno::RuntimeException) ; + + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getIssuerUniqueID( ) throw ( ::com::sun::star::uno::RuntimeException) ; + + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getSubjectUniqueID( ) throw ( ::com::sun::star::uno::RuntimeException) ; + + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::security::XCertificateExtension > > SAL_CALL getExtensions( ) throw ( ::com::sun::star::uno::RuntimeException) ; + + virtual ::com::sun::star::uno::Reference< ::com::sun::star::security::XCertificateExtension > SAL_CALL findCertExtension( const ::com::sun::star::uno::Sequence< sal_Int8 >& oid ) throw (::com::sun::star::uno::RuntimeException) ; + + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getEncoded( ) throw ( ::com::sun::star::uno::RuntimeException) ; + + //Methods from XUnoTunnel + virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw (com::sun::star::uno::RuntimeException); + + static const ::com::sun::star::uno::Sequence< sal_Int8 >& getUnoTunnelId() ; + static X509Certificate_NssImpl* getImplementation( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > xObj ) ; + + //Helper methods + void setCert( CERTCertificate* cert ) ; + const CERTCertificate* getNssCert() const ; + void setRawCert( ::com::sun::star::uno::Sequence< sal_Int8 > rawCert ) throw ( ::com::sun::star::uno::RuntimeException) ; +} ; + +#endif // _X509CERTIFICATE_NSSIMPL_HXX_ + diff --git a/xmlsecurity/source/xmlsec/nss/xmlencryption_nssimpl.cxx b/xmlsecurity/source/xmlsec/nss/xmlencryption_nssimpl.cxx new file mode 100644 index 000000000000..79d11247ebf5 --- /dev/null +++ b/xmlsecurity/source/xmlsec/nss/xmlencryption_nssimpl.cxx @@ -0,0 +1,429 @@ +/************************************************************************* + * + * $RCSfile: xmlencryption_nssimpl.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:21 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _SAL_CONFIG_H_ +#include +#endif + +#ifndef _RTL_UUID_H_ +#include +#endif + +#ifndef _XMLENCRYPTION_NSSIMPL_HXX_ +#include "xmlencryption_nssimpl.hxx" +#endif + +#ifndef _XMLDOCUMENTWRAPPER_XMLSECIMPL_HXX_ +#include "xmldocumentwrapper_xmlsecimpl.hxx" +#endif + +#ifndef _XMLELEMENTWRAPPER_XMLSECIMPL_HXX_ +#include "xmlelementwrapper_xmlsecimpl.hxx" +#endif + +#ifndef _XMLSECURITYCONTEXT_NSSIMPL_HXX_ +#include "xmlsecuritycontext_nssimpl.hxx" +#endif + +#include "xmlsec/xmlsec.h" +#include "xmlsec/xmltree.h" +#include "xmlsec/xmlenc.h" +#include "xmlsec/crypto.h" + +#ifdef UNX +#define stricmp strcasecmp +#endif + +using namespace ::com::sun::star::uno ; +using namespace ::com::sun::star::lang ; +using ::com::sun::star::lang::XMultiServiceFactory ; +using ::com::sun::star::lang::XSingleServiceFactory ; +using ::rtl::OUString ; + +using ::com::sun::star::xml::wrapper::XXMLElementWrapper ; +using ::com::sun::star::xml::wrapper::XXMLDocumentWrapper ; +using ::com::sun::star::xml::crypto::XSecurityEnvironment ; +using ::com::sun::star::xml::crypto::XXMLEncryption ; +using ::com::sun::star::xml::crypto::XXMLEncryptionTemplate ; +using ::com::sun::star::xml::crypto::XXMLSecurityContext ; + +XMLEncryption_NssImpl :: XMLEncryption_NssImpl( const Reference< XMultiServiceFactory >& aFactory ) : m_xServiceManager( aFactory ) { +} + +XMLEncryption_NssImpl :: ~XMLEncryption_NssImpl() { +} + +/* XXMLEncryption */ +Reference< XXMLEncryptionTemplate > +SAL_CALL XMLEncryption_NssImpl :: encrypt( + const Reference< XXMLEncryptionTemplate >& aTemplate , + const Reference< XXMLSecurityContext >& aSecurityCtx +) throw( com::sun::star::xml::crypto::XMLEncryptionException, + com::sun::star::uno::SecurityException ) +{ + xmlSecKeysMngrPtr pMngr = NULL ; + xmlSecEncCtxPtr pEncCtx = NULL ; + xmlNodePtr pEncryptedData = NULL ; + xmlNodePtr pEncryptedKey = NULL ; + xmlNodePtr pContent = NULL ; + + if( !aTemplate.is() ) + throw RuntimeException() ; + + if( !aSecurityCtx.is() ) + throw RuntimeException() ; + + //Get Keys Manager + Reference< XUnoTunnel > xSecTunnel( aSecurityCtx , UNO_QUERY ) ; + if( !xSecTunnel.is() ) { + throw RuntimeException() ; + } + + XMLSecurityContext_NssImpl* pSecCtxt = ( XMLSecurityContext_NssImpl* )xSecTunnel->getSomething( XMLSecurityContext_NssImpl::getUnoTunnelId() ) ; + if( pSecCtxt == NULL ) + throw RuntimeException() ; + + pMngr = pSecCtxt->keysManager() ; + + + //Create Encryption context + pEncCtx = xmlSecEncCtxCreate( pMngr ) ; + if( pEncCtx == NULL ) + throw RuntimeException() ; + + + //Get the encryption template + Reference< XXMLElementWrapper > xTemplate = aTemplate->getTemplate() ; + if( !xTemplate.is() ) { + xmlSecEncCtxDestroy( pEncCtx ) ; + throw RuntimeException() ; + } + + Reference< XUnoTunnel > xTplTunnel( xTemplate , UNO_QUERY ) ; + if( !xTplTunnel.is() ) { + xmlSecEncCtxDestroy( pEncCtx ) ; + throw RuntimeException() ; + } + + XMLElementWrapper_XmlSecImpl* pTemplate = ( XMLElementWrapper_XmlSecImpl* )xTplTunnel->getSomething( XMLElementWrapper_XmlSecImpl::getUnoTunnelImplementationId() ) ; + if( pTemplate == NULL ) { + xmlSecEncCtxDestroy( pEncCtx ) ; + throw RuntimeException() ; + } + + pEncryptedData = pTemplate->getNativeElement() ; + + //Find the element to be encrypted. + /* MM : remove the old method to get the target element + //This element is wrapped in the CipherValue sub-element. + xmlNodePtr pCipherData = pEncryptedData->children; + while (pCipherData != NULL && stricmp((const char *)(pCipherData->name), "CipherData")) + { + pCipherData = pCipherData->next; + } + + if( pCipherData == NULL ) { + xmlSecEncCtxDestroy( pEncCtx ) ; + throw RuntimeException() ; + } + + xmlNodePtr pCipherValue = pCipherData->children; + while (pCipherValue != NULL && stricmp((const char *)(pCipherValue->name), "CipherValue")) + { + pCipherValue = pCipherValue->next; + } + + if( pCipherValue == NULL ) { + xmlSecEncCtxDestroy( pEncCtx ) ; + throw RuntimeException() ; + } + + pContent = pCipherValue->children; + */ + + //MM : Get the element to be encrypted + Reference< XXMLElementWrapper > xTarget = aTemplate->getTarget() ; + if( !xTarget.is() ) { + xmlSecEncCtxDestroy( pEncCtx ) ; + throw RuntimeException() ; + } + + Reference< XUnoTunnel > xTgtTunnel( xTarget , UNO_QUERY ) ; + if( !xTgtTunnel.is() ) { + xmlSecEncCtxDestroy( pEncCtx ) ; + throw RuntimeException() ; + } + + XMLElementWrapper_XmlSecImpl* pTarget = ( XMLElementWrapper_XmlSecImpl* )xTgtTunnel->getSomething( XMLElementWrapper_XmlSecImpl::getUnoTunnelImplementationId() ) ; + if( pTarget == NULL ) { + xmlSecEncCtxDestroy( pEncCtx ) ; + throw RuntimeException() ; + } + + pContent = pTarget->getNativeElement() ; + //MM : end + + if( pContent == NULL ) { + xmlSecEncCtxDestroy( pEncCtx ) ; + throw RuntimeException() ; + } + + /* MM : remove the following 2 lines + xmlUnlinkNode(pContent); + xmlAddNextSibling(pEncryptedData, pContent); + */ + + //remember the position of the element to be signed + sal_Bool isParentRef = sal_True; + xmlNodePtr pParent = pEncryptedData->parent; + xmlNodePtr referenceNode; + + if (pEncryptedData == pParent->children) + { + referenceNode = pParent; + } + else + { + referenceNode = pEncryptedData->prev; + isParentRef = sal_False; + } + + //Encrypt the template + if( xmlSecEncCtxXmlEncrypt( pEncCtx , pEncryptedData , pContent ) < 0 ) { + xmlSecEncCtxDestroy( pEncCtx ) ; + throw RuntimeException() ; + } + + xmlSecEncCtxDestroy( pEncCtx ) ; + + //get the new EncryptedData element + if (isParentRef) + { + pTemplate->setNativeElement(referenceNode->children) ; + } + else + { + pTemplate->setNativeElement(referenceNode->next); + } + + return aTemplate ; +} + +/* XXMLEncryption */ +Reference< XXMLElementWrapper > SAL_CALL +XMLEncryption_NssImpl :: decrypt( + const Reference< XXMLEncryptionTemplate >& aTemplate , + const Reference< XXMLSecurityContext >& aSecurityCtx +) throw( com::sun::star::xml::crypto::XMLEncryptionException , + com::sun::star::uno::SecurityException) { + xmlSecKeysMngrPtr pMngr = NULL ; + xmlSecEncCtxPtr pEncCtx = NULL ; + xmlNodePtr pEncryptedData = NULL ; + xmlNodePtr pContent = NULL ; + + if( !aTemplate.is() ) + throw RuntimeException() ; + + if( !aSecurityCtx.is() ) + throw RuntimeException() ; + + //Get Keys Manager + Reference< XUnoTunnel > xSecTunnel( aSecurityCtx , UNO_QUERY ) ; + if( !xSecTunnel.is() ) { + throw RuntimeException() ; + } + + XMLSecurityContext_NssImpl* pSecCtxt = ( XMLSecurityContext_NssImpl* )xSecTunnel->getSomething( XMLSecurityContext_NssImpl::getUnoTunnelId() ) ; + if( pSecCtxt == NULL ) + throw RuntimeException() ; + + pMngr = pSecCtxt->keysManager() ; + + + //Create Encryption context + pEncCtx = xmlSecEncCtxCreate( pMngr ) ; + if( pEncCtx == NULL ) + throw RuntimeException() ; + + + //Get the encryption template + Reference< XXMLElementWrapper > xTemplate = aTemplate->getTemplate() ; + if( !xTemplate.is() ) { + xmlSecEncCtxDestroy( pEncCtx ) ; + throw RuntimeException() ; + } + + Reference< XUnoTunnel > xTplTunnel( xTemplate , UNO_QUERY ) ; + if( !xTplTunnel.is() ) { + xmlSecEncCtxDestroy( pEncCtx ) ; + throw RuntimeException() ; + } + + XMLElementWrapper_XmlSecImpl* pTemplate = ( XMLElementWrapper_XmlSecImpl* )xTplTunnel->getSomething( XMLElementWrapper_XmlSecImpl::getUnoTunnelImplementationId() ) ; + if( pTemplate == NULL ) { + xmlSecEncCtxDestroy( pEncCtx ) ; + throw RuntimeException() ; + } + + pEncryptedData = pTemplate->getNativeElement() ; + + //remember the position of the element to be signed + sal_Bool isParentRef = sal_True; + xmlNodePtr pParent = pEncryptedData->parent; + xmlNodePtr referenceNode; + + if (pEncryptedData == pParent->children) + { + referenceNode = pParent; + } + else + { + referenceNode = pEncryptedData->prev; + isParentRef = sal_False; + } + + //Decrypt the template + if( xmlSecEncCtxDecrypt( pEncCtx , pEncryptedData ) < 0 || pEncCtx->result == NULL ) { + xmlSecEncCtxDestroy( pEncCtx ) ; + throw RuntimeException() ; + } + /*---------------------------------------- + if( pEncCtx->resultReplaced != 0 ) { + pContent = pEncryptedData ; + + Reference< XUnoTunnel > xTunnel( ret , UNO_QUERY ) ; + if( !xTunnel.is() ) { + xmlSecEncCtxDestroy( pEncCtx ) ; + throw RuntimeException() ; + } + XMLElementWrapper_XmlSecImpl* pNode = ( XMLElementWrapper_XmlSecImpl* )xTunnel->getSomething( XMLElementWrapper_XmlSecImpl::getUnoTunnelImplementationId() ) ; + if( pNode == NULL ) { + xmlSecEncCtxDestroy( pEncCtx ) ; + throw RuntimeException() ; + } + + pNode->setNativeElement( pContent ) ; + } else { + xmlSecEncCtxDestroy( pEncCtx ) ; + throw RuntimeException() ; + } + ----------------------------------------*/ + + //Destroy the encryption context + xmlSecEncCtxDestroy( pEncCtx ) ; + + //get the decrypted element + XMLElementWrapper_XmlSecImpl * ret = new XMLElementWrapper_XmlSecImpl(isParentRef? + (referenceNode->children):(referenceNode->next)); + + return ret; +} + +/* XInitialization */ +void SAL_CALL XMLEncryption_NssImpl :: initialize( const Sequence< Any >& aArguments ) throw( Exception, RuntimeException ) { + // TBD +} ; + +/* XServiceInfo */ +OUString SAL_CALL XMLEncryption_NssImpl :: getImplementationName() throw( RuntimeException ) { + return impl_getImplementationName() ; +} + +/* XServiceInfo */ +sal_Bool SAL_CALL XMLEncryption_NssImpl :: supportsService( const OUString& serviceName) throw( RuntimeException ) { + Sequence< OUString > seqServiceNames = getSupportedServiceNames() ; + const OUString* pArray = seqServiceNames.getConstArray() ; + for( sal_Int32 i = 0 ; i < seqServiceNames.getLength() ; i ++ ) { + if( *( pArray + i ) == serviceName ) + return sal_True ; + } + return sal_False ; +} + +/* XServiceInfo */ +Sequence< OUString > SAL_CALL XMLEncryption_NssImpl :: getSupportedServiceNames() throw( RuntimeException ) { + return impl_getSupportedServiceNames() ; +} + +//Helper for XServiceInfo +Sequence< OUString > XMLEncryption_NssImpl :: impl_getSupportedServiceNames() { + ::osl::Guard< ::osl::Mutex > aGuard( ::osl::Mutex::getGlobalMutex() ) ; + Sequence< OUString > seqServiceNames( 1 ) ; + seqServiceNames.getArray()[0] = OUString::createFromAscii( "com.sun.star.xml.crypto.XMLEncryption" ) ; + return seqServiceNames ; +} + +OUString XMLEncryption_NssImpl :: impl_getImplementationName() throw( RuntimeException ) { + return OUString::createFromAscii( "com.sun.star.xml.security.bridge.xmlsec.XMLEncryption_NssImpl" ) ; +} + +//Helper for registry +Reference< XInterface > SAL_CALL XMLEncryption_NssImpl :: impl_createInstance( const Reference< XMultiServiceFactory >& aServiceManager ) throw( RuntimeException ) { + return Reference< XInterface >( *new XMLEncryption_NssImpl( aServiceManager ) ) ; +} + +Reference< XSingleServiceFactory > XMLEncryption_NssImpl :: impl_createFactory( const Reference< XMultiServiceFactory >& aServiceManager ) { + //Reference< XSingleServiceFactory > xFactory ; + //xFactory = ::cppu::createSingleFactory( aServiceManager , impl_getImplementationName , impl_createInstance , impl_getSupportedServiceNames ) ; + //return xFactory ; + return ::cppu::createSingleFactory( aServiceManager , impl_getImplementationName() , impl_createInstance , impl_getSupportedServiceNames() ) ; +} + diff --git a/xmlsecurity/source/xmlsec/nss/xmlencryption_nssimpl.hxx b/xmlsecurity/source/xmlsec/nss/xmlencryption_nssimpl.hxx new file mode 100644 index 000000000000..92e20f99f0ad --- /dev/null +++ b/xmlsecurity/source/xmlsec/nss/xmlencryption_nssimpl.hxx @@ -0,0 +1,165 @@ +/************************************************************************* + * + * $RCSfile: xmlencryption_nssimpl.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:21 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _XMLENCRYPTION_NSSIMPL_HXX_ +#define _XMLENCRYPTION_NSSIMPL_HXX_ + +#ifndef _SAL_CONFIG_H_ +#include +#endif + +#ifndef _RTL_USTRING_HXX_ +#include +#endif + +#ifndef _CPPUHELPER_FACTORY_HXX_ +#include +#endif + +#ifndef _CPPUHELPER_IMPLBASE3_HXX_ +#include +#endif + +#ifndef _COM_SUN_STAR_UNO_EXCEPTION_HPP_ +#include +#endif + +#ifndef _COM_SUN_STAR_UNO_REFERENCE_HPP_ +#include +#endif + +#ifndef _COM_SUN_STAR_LANG_XSINGLESERVICEFACTORY_HPP_ +#include +#endif + +#ifndef _COM_SUN_STAR_LANG_XSECVICEINFO_HPP_ +#include +#endif + +#ifndef _COM_SUN_STAR_LANG_XINITIALIZATION_HPP_ +#include +#endif + +#ifndef _COM_SUN_STAR_XML_CRYPTO_XXMLENCRYPTION_HPP_ +#include +#endif + +#ifndef _COM_SUN_STAR_XML_CRYPTO_XXMLENCRYPTIONTEMPLATE_HPP_ +#include +#endif + +#ifndef _COM_SUN_STAR_XML_CRYPTO_XXMLSECURITYCONTEXT_HPP_ +#include +#endif + +class XMLEncryption_NssImpl : public ::cppu::WeakImplHelper3< + ::com::sun::star::xml::crypto::XXMLEncryption , + ::com::sun::star::lang::XInitialization , + ::com::sun::star::lang::XServiceInfo > +{ + private : + ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xServiceManager ; + + public : + XMLEncryption_NssImpl( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& aFactory ) ; + virtual ~XMLEncryption_NssImpl() ; + + //Methods from XXMLEncryption + virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::crypto::XXMLEncryptionTemplate > SAL_CALL encrypt( + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::crypto::XXMLEncryptionTemplate >& aTemplate , + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::crypto::XXMLSecurityContext >& aContext) + // ) throw( ::com::sun::star::uno::Exception , ::com::sun::star::uno::RuntimeException ) ; + throw ( com::sun::star::xml::crypto::XMLEncryptionException , + com::sun::star::uno::SecurityException); + + virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::wrapper::XXMLElementWrapper > SAL_CALL decrypt( + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::crypto::XXMLEncryptionTemplate >& aTemplate , + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::crypto::XXMLSecurityContext >& aContext + ) throw( com::sun::star::xml::crypto::XMLEncryptionException , + com::sun::star::uno::SecurityException) ; + + //Methods from XInitialization + virtual void SAL_CALL initialize( + const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments + ) throw( ::com::sun::star::uno::Exception , ::com::sun::star::uno::RuntimeException ) ; + + //Methods from XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName() throw( ::com::sun::star::uno::RuntimeException ) ; + + virtual sal_Bool SAL_CALL supportsService( + const ::rtl::OUString& ServiceName + ) throw( ::com::sun::star::uno::RuntimeException ) ; + + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw( ::com::sun::star::uno::RuntimeException ) ; + + //Helper for XServiceInfo + static ::com::sun::star::uno::Sequence< ::rtl::OUString > impl_getSupportedServiceNames() ; + + static ::rtl::OUString impl_getImplementationName() throw( ::com::sun::star::uno::RuntimeException ) ; + + //Helper for registry + static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL impl_createInstance( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& aServiceManager ) throw( ::com::sun::star::uno::RuntimeException ) ; + + static ::com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleServiceFactory > impl_createFactory( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& aServiceManager ) ; +} ; + +#endif // _XMLENCRYPTION_NSSIMPL_HXX_ + diff --git a/xmlsecurity/source/xmlsec/nss/xmlsecuritycontext_nssimpl.cxx b/xmlsecurity/source/xmlsec/nss/xmlsecuritycontext_nssimpl.cxx new file mode 100644 index 000000000000..5bf5ae59a2e8 --- /dev/null +++ b/xmlsecurity/source/xmlsec/nss/xmlsecuritycontext_nssimpl.cxx @@ -0,0 +1,290 @@ +/************************************************************************* + * + * $RCSfile: xmlsecuritycontext_nssimpl.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:21 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _SAL_CONFIG_H_ +#include +#endif + +#ifndef _RTL_UUID_H_ +#include +#endif + +#ifndef _XSECURITYENVIRONMENT_NSSIMPL_HXX_ +#include "securityenvironment_nssimpl.hxx" +#endif + +#ifndef _XMLSECURITYCONTEXT_NSSIMPL_HXX_ +#include "xmlsecuritycontext_nssimpl.hxx" +#endif + +#ifndef _XMLSTREAMIO_XMLSECIMPL_HXX_ +#include "xmlstreamio.hxx" +#endif + +#include "xmlsec/xmlsec.h" +#include "xmlsec/keysmngr.h" +#include "xmlsec/crypto.h" + +using namespace ::com::sun::star::uno ; +using namespace ::com::sun::star::lang ; +using ::com::sun::star::lang::XMultiServiceFactory ; +using ::com::sun::star::lang::XSingleServiceFactory ; +using ::rtl::OUString ; + +using ::com::sun::star::xml::crypto::XSecurityEnvironment ; +using ::com::sun::star::xml::crypto::XXMLSecurityContext ; + +XMLSecurityContext_NssImpl :: XMLSecurityContext_NssImpl( const Reference< XMultiServiceFactory >& aFactory ) : m_pKeysMngr( NULL ) , m_xServiceManager( aFactory ) , m_xSecurityEnvironment( NULL ) { + //Init xmlsec library + if( xmlSecInit() < 0 ) { + throw RuntimeException() ; + } + + //Init xmlsec crypto engine library + if( xmlSecCryptoInit() < 0 ) { + xmlSecShutdown() ; + throw RuntimeException() ; + } + + //Enable external stream handlers + if( xmlEnableStreamInputCallbacks() < 0 ) { + xmlSecCryptoShutdown() ; + xmlSecShutdown() ; + throw RuntimeException() ; + } +} + +XMLSecurityContext_NssImpl :: ~XMLSecurityContext_NssImpl() { + if( m_pKeysMngr != NULL ) { + xmlSecKeysMngrDestroy( m_pKeysMngr ) ; + } + + xmlDisableStreamInputCallbacks() ; + xmlSecCryptoShutdown() ; + xmlSecShutdown() ; +} + +/* XXMLSecurityContext */ +void SAL_CALL XMLSecurityContext_NssImpl :: setSecurityEnvironment( const Reference< XSecurityEnvironment >& aSecurityEnvironment ) throw( com::sun::star::security::SecurityInfrastructureException ) { + PK11SlotInfo* slot ; + CERTCertDBHandle* handler ; + //xmlSecKeyPtr key ; + //xmlSecKeyDataPtr keyData ; + PK11SymKey* symKey ; + SECKEYPublicKey* pubKey ; + SECKEYPrivateKey* priKey ; + unsigned int i ; + + if( !aSecurityEnvironment.is() ) + throw RuntimeException() ; + + m_xSecurityEnvironment = aSecurityEnvironment ; + + //Clear key manager + if( m_pKeysMngr != NULL ) { + xmlSecKeysMngrDestroy( m_pKeysMngr ) ; + m_pKeysMngr = NULL ; + } + + //Create key manager + Reference< XUnoTunnel > xEnvTunnel( m_xSecurityEnvironment , UNO_QUERY ) ; + if( !xEnvTunnel.is() ) { + throw RuntimeException() ; + } + + SecurityEnvironment_NssImpl* pSecEnv = ( SecurityEnvironment_NssImpl* )xEnvTunnel->getSomething( SecurityEnvironment_NssImpl::getUnoTunnelId() ) ; + if( pSecEnv == NULL ) + throw RuntimeException() ; + + slot = pSecEnv->getCryptoSlot() ; + handler = pSecEnv->getCertDb() ; + + /*- + * The following lines is based on the private version of xmlSec-NSS + * crypto engine + */ + m_pKeysMngr = xmlSecNssAppliedKeysMngrCreate( slot , handler ) ; + if( m_pKeysMngr == NULL ) + throw RuntimeException() ; + + /*- + * Adopt symmetric key into keys manager + */ + for( i = 0 ; ( symKey = pSecEnv->getSymKey( i ) ) != NULL ; i ++ ) { + if( xmlSecNssAppliedKeysMngrSymKeyLoad( m_pKeysMngr, symKey ) < 0 ) { + throw RuntimeException() ; + } + } + + /*- + * Adopt asymmetric public key into keys manager + */ + for( i = 0 ; ( pubKey = pSecEnv->getPubKey( i ) ) != NULL ; i ++ ) { + if( xmlSecNssAppliedKeysMngrPubKeyLoad( m_pKeysMngr, pubKey ) < 0 ) { + throw RuntimeException() ; + } + } + + /*- + * Adopt asymmetric private key into keys manager + */ + for( i = 0 ; ( priKey = pSecEnv->getPriKey( i ) ) != NULL ; i ++ ) { + if( xmlSecNssAppliedKeysMngrPriKeyLoad( m_pKeysMngr, priKey ) < 0 ) { + throw RuntimeException() ; + } + } +} + +/* XXMLSecurityContext */ +Reference< XSecurityEnvironment > SAL_CALL XMLSecurityContext_NssImpl :: getSecurityEnvironment() + throw (RuntimeException) +{ + return m_xSecurityEnvironment ; +} + +/* XInitialization */ +void SAL_CALL XMLSecurityContext_NssImpl :: initialize( const Sequence< Any >& aArguments ) throw( Exception, RuntimeException ) { + // TBD +} ; + +/* XServiceInfo */ +OUString SAL_CALL XMLSecurityContext_NssImpl :: getImplementationName() throw( RuntimeException ) { + return impl_getImplementationName() ; +} + +/* XServiceInfo */ +sal_Bool SAL_CALL XMLSecurityContext_NssImpl :: supportsService( const OUString& serviceName) throw( RuntimeException ) { + Sequence< OUString > seqServiceNames = getSupportedServiceNames() ; + const OUString* pArray = seqServiceNames.getConstArray() ; + for( sal_Int32 i = 0 ; i < seqServiceNames.getLength() ; i ++ ) { + if( *( pArray + i ) == serviceName ) + return sal_True ; + } + return sal_False ; +} + +/* XServiceInfo */ +Sequence< OUString > SAL_CALL XMLSecurityContext_NssImpl :: getSupportedServiceNames() throw( RuntimeException ) { + return impl_getSupportedServiceNames() ; +} + +//Helper for XServiceInfo +Sequence< OUString > XMLSecurityContext_NssImpl :: impl_getSupportedServiceNames() { + ::osl::Guard< ::osl::Mutex > aGuard( ::osl::Mutex::getGlobalMutex() ) ; + Sequence< OUString > seqServiceNames( 1 ) ; + seqServiceNames.getArray()[0] = OUString::createFromAscii( "com.sun.star.xml.crypto.XMLSecurityContext" ) ; + return seqServiceNames ; +} + +OUString XMLSecurityContext_NssImpl :: impl_getImplementationName() throw( RuntimeException ) { + return OUString::createFromAscii( "com.sun.star.xml.security.bridge.xmlsec.XMLSecurityContext_NssImpl" ) ; +} + +//Helper for registry +Reference< XInterface > SAL_CALL XMLSecurityContext_NssImpl :: impl_createInstance( const Reference< XMultiServiceFactory >& aServiceManager ) throw( RuntimeException ) { + return Reference< XInterface >( *new XMLSecurityContext_NssImpl( aServiceManager ) ) ; +} + +Reference< XSingleServiceFactory > XMLSecurityContext_NssImpl :: impl_createFactory( const Reference< XMultiServiceFactory >& aServiceManager ) { + //Reference< XSingleServiceFactory > xFactory ; + //xFactory = ::cppu::createSingleFactory( aServiceManager , impl_getImplementationName , impl_createInstance , impl_getSupportedServiceNames ) ; + //return xFactory ; + return ::cppu::createSingleFactory( aServiceManager , impl_getImplementationName() , impl_createInstance , impl_getSupportedServiceNames() ) ; +} + +/* XUnoTunnel */ +sal_Int64 SAL_CALL XMLSecurityContext_NssImpl :: getSomething( const Sequence< sal_Int8 >& aIdentifier ) +throw (RuntimeException) +{ + if( aIdentifier.getLength() == 16 && 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(), aIdentifier.getConstArray(), 16 ) ) { + return ( sal_Int64 )this ; + } + return 0 ; +} + +/* XUnoTunnel extension */ +const Sequence< sal_Int8>& XMLSecurityContext_NssImpl :: getUnoTunnelId() { + static Sequence< sal_Int8 >* pSeq = 0 ; + if( !pSeq ) { + ::osl::Guard< ::osl::Mutex > aGuard( ::osl::Mutex::getGlobalMutex() ) ; + if( !pSeq ) { + static Sequence< sal_Int8> aSeq( 16 ) ; + rtl_createUuid( ( sal_uInt8* )aSeq.getArray() , 0 , sal_True ) ; + pSeq = &aSeq ; + } + } + return *pSeq ; +} + +/* XUnoTunnel extension */ +XMLSecurityContext_NssImpl* XMLSecurityContext_NssImpl :: getImplementation( const Reference< XInterface > xObj ) { + Reference< XUnoTunnel > xUT( xObj , UNO_QUERY ) ; + if( xUT.is() ) { + return ( XMLSecurityContext_NssImpl* )xUT->getSomething( getUnoTunnelId() ) ; + } else + return NULL ; +} + +/* Native methods */ +xmlSecKeysMngrPtr XMLSecurityContext_NssImpl :: keysManager() throw( Exception, RuntimeException ) { + return m_pKeysMngr ; +} + diff --git a/xmlsecurity/source/xmlsec/nss/xmlsecuritycontext_nssimpl.hxx b/xmlsecurity/source/xmlsec/nss/xmlsecuritycontext_nssimpl.hxx new file mode 100644 index 000000000000..a5b33a720f27 --- /dev/null +++ b/xmlsecurity/source/xmlsec/nss/xmlsecuritycontext_nssimpl.hxx @@ -0,0 +1,174 @@ +/************************************************************************* + * + * $RCSfile: xmlsecuritycontext_nssimpl.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:21 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _XMLSIGNATURECONTEXT_NSSIMPL_HXX_ +#define _XMLSIGNATURECONTEXT_NSSIMPL_HXX_ + +#ifndef _SAL_CONFIG_H_ +#include +#endif + +#ifndef _RTL_USTRING_HXX_ +#include +#endif + +#ifndef _CPPUHELPER_FACTORY_HXX_ +#include +#endif + +#ifndef _CPPUHELPER_IMPLBASE4_HXX_ +#include +#endif + +#ifndef _COM_SUN_STAR_UNO_EXCEPTION_HPP_ +#include +#endif + +#ifndef _COM_SUN_STAR_UNO_REFERENCE_HPP_ +#include +#endif + +#ifndef _COM_SUN_STAR_LANG_XSINGLESERVICEFACTORY_HPP_ +#include +#endif + +#ifndef _COM_SUN_STAR_LANG_XSECVICEINFO_HPP_ +#include +#endif + +#ifndef _COM_SUN_STAR_LANG_XINITIALIZATION_HPP_ +#include +#endif + +#ifndef _COM_SUN_STAR_LANG_XUNOTUNNEL_HPP_ +#include +#endif + +#ifndef _COM_SUN_STAR_XML_CRYPTO_XSECURITYENVIRONMENT_HPP_ +#include +#endif + +#ifndef _COM_SUN_STAR_XML_CRYPTO_XXMLSECURITYCONTEXT_HPP_ +#include +#endif + +#include "xmlsec/xmlsec.h" + +class XMLSecurityContext_NssImpl : public ::cppu::WeakImplHelper4< + ::com::sun::star::xml::crypto::XXMLSecurityContext , + ::com::sun::star::lang::XInitialization , + ::com::sun::star::lang::XServiceInfo , + ::com::sun::star::lang::XUnoTunnel > +{ + private : + xmlSecKeysMngrPtr m_pKeysMngr ; + ::com::sun::star::uno::Reference< ::com::sun::star::xml::crypto::XSecurityEnvironment > m_xSecurityEnvironment ; + ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xServiceManager ; + + public : + XMLSecurityContext_NssImpl( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& aFactory ) ; + virtual ~XMLSecurityContext_NssImpl() ; + + //Methods from XXMLSecurityContext + virtual void SAL_CALL setSecurityEnvironment( + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::crypto::XSecurityEnvironment >& aSecurityEnvironment + ) throw( com::sun::star::security::SecurityInfrastructureException) ; + + virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::crypto::XSecurityEnvironment > SAL_CALL getSecurityEnvironment() + throw(::com::sun::star::uno::RuntimeException); + + //Methods from XInitialization + virtual void SAL_CALL initialize( + const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments + ) throw( ::com::sun::star::uno::Exception , ::com::sun::star::uno::RuntimeException ) ; + + //Methods from XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName() throw( ::com::sun::star::uno::RuntimeException ) ; + + virtual sal_Bool SAL_CALL supportsService( + const ::rtl::OUString& ServiceName + ) throw( ::com::sun::star::uno::RuntimeException ) ; + + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw( ::com::sun::star::uno::RuntimeException ) ; + + //Helper for XServiceInfo + static ::com::sun::star::uno::Sequence< ::rtl::OUString > impl_getSupportedServiceNames() ; + + static ::rtl::OUString impl_getImplementationName() throw( ::com::sun::star::uno::RuntimeException ) ; + + //Helper for registry + static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL impl_createInstance( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& aServiceManager ) throw( ::com::sun::star::uno::RuntimeException ) ; + + static ::com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleServiceFactory > impl_createFactory( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& aServiceManager ) ; + + //Methods from XUnoTunnel + virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) + throw (com::sun::star::uno::RuntimeException); + + static const ::com::sun::star::uno::Sequence< sal_Int8 >& getUnoTunnelId() ; + static XMLSecurityContext_NssImpl* getImplementation( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > xObj ) ; + + //Native mehtods + virtual xmlSecKeysMngrPtr keysManager() throw( ::com::sun::star::uno::Exception , ::com::sun::star::uno::RuntimeException ) ; +} ; + +#endif // _XMLSIGNATURECONTEXT_NSSIMPL_HXX_ + diff --git a/xmlsecurity/source/xmlsec/nss/xmlsignature_nssimpl.cxx b/xmlsecurity/source/xmlsec/nss/xmlsignature_nssimpl.cxx new file mode 100644 index 000000000000..1f9ad4115265 --- /dev/null +++ b/xmlsecurity/source/xmlsec/nss/xmlsignature_nssimpl.cxx @@ -0,0 +1,336 @@ +/************************************************************************* + * + * $RCSfile: xmlsignature_nssimpl.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:21 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _SAL_CONFIG_H_ +#include +#endif + +#ifndef _RTL_UUID_H_ +#include +#endif + +#ifndef _XMLSIGNATURE_NSSIMPL_HXX_ +#include "xmlsignature_nssimpl.hxx" +#endif + +#ifndef _XMLDOCUMENTWRAPPER_XMLSECIMPL_HXX_ +#include "xmldocumentwrapper_xmlsecimpl.hxx" +#endif + +#ifndef _XMLELEMENTWRAPPER_XMLSECIMPL_HXX_ +#include "xmlelementwrapper_xmlsecimpl.hxx" +#endif + +#ifndef _XMLSECURITYCONTEXT_NSSIMPL_HXX_ +#include "xmlsecuritycontext_nssimpl.hxx" +#endif + +#ifndef _XMLSTREAMIO_XMLSECIMPL_HXX_ +#include "xmlstreamio.hxx" +#endif + +#include "xmlsec/xmlsec.h" +#include "xmlsec/xmldsig.h" +#include "xmlsec/crypto.h" + +using namespace ::com::sun::star::uno ; +using namespace ::com::sun::star::lang ; +using ::com::sun::star::lang::XMultiServiceFactory ; +using ::com::sun::star::lang::XSingleServiceFactory ; +using ::rtl::OUString ; + +using ::com::sun::star::xml::wrapper::XXMLElementWrapper ; +using ::com::sun::star::xml::wrapper::XXMLDocumentWrapper ; +using ::com::sun::star::xml::crypto::XSecurityEnvironment ; +using ::com::sun::star::xml::crypto::XXMLSignature ; +using ::com::sun::star::xml::crypto::XXMLSignatureTemplate ; +using ::com::sun::star::xml::crypto::XXMLSecurityContext ; +using ::com::sun::star::xml::crypto::XUriBinding ; + +XMLSignature_NssImpl :: XMLSignature_NssImpl( const Reference< XMultiServiceFactory >& aFactory ) : m_xServiceManager( aFactory ) { +} + +XMLSignature_NssImpl :: ~XMLSignature_NssImpl() { +} + +/* XXMLSignature */ +Reference< XXMLSignatureTemplate > +SAL_CALL XMLSignature_NssImpl :: generate( + const Reference< XXMLSignatureTemplate >& aTemplate , + const Reference< XXMLSecurityContext >& aSecurityCtx +) throw( com::sun::star::xml::crypto::XMLSignatureException, + com::sun::star::uno::SecurityException ) +{ + xmlSecKeysMngrPtr pMngr = NULL ; + xmlSecDSigCtxPtr pDsigCtx = NULL ; + xmlNodePtr pNode = NULL ; + + if( !aTemplate.is() ) + throw RuntimeException() ; + + if( !aSecurityCtx.is() ) + throw RuntimeException() ; + + //Get the xml node + Reference< XXMLElementWrapper > xElement = aTemplate->getTemplate() ; + if( !xElement.is() ) { + throw RuntimeException() ; + } + + Reference< XUnoTunnel > xNodTunnel( xElement , UNO_QUERY ) ; + if( !xNodTunnel.is() ) { + throw RuntimeException() ; + } + + XMLElementWrapper_XmlSecImpl* pElement = ( XMLElementWrapper_XmlSecImpl* )xNodTunnel->getSomething( XMLElementWrapper_XmlSecImpl::getUnoTunnelImplementationId() ) ; + if( pElement == NULL ) { + throw RuntimeException() ; + } + + pNode = pElement->getNativeElement() ; + + //Get the stream/URI binding + Reference< XUriBinding > xUriBinding = aTemplate->getBinding() ; + if( xUriBinding.is() ) { + //Register the stream input callbacks into libxml2 + if( xmlRegisterStreamInputCallbacks( xUriBinding ) < 0 ) + throw RuntimeException() ; + } + + //Get Keys Manager + Reference< XUnoTunnel > xSecTunnel( aSecurityCtx , UNO_QUERY ) ; + if( !xSecTunnel.is() ) { + throw RuntimeException() ; + } + + XMLSecurityContext_NssImpl* pSecCtxt = ( XMLSecurityContext_NssImpl* )xSecTunnel->getSomething( XMLSecurityContext_NssImpl::getUnoTunnelId() ) ; + if( pSecCtxt == NULL ) + throw RuntimeException() ; + + pMngr = pSecCtxt->keysManager() ; + + //Create Signature context + pDsigCtx = xmlSecDSigCtxCreate( pMngr ) ; + if( pDsigCtx == NULL ) + throw RuntimeException() ; + + //Sign the template + if( xmlSecDSigCtxSign( pDsigCtx , pNode ) < 0 ) { + xmlSecDSigCtxDestroy( pDsigCtx ) ; + + //Unregistered the stream/URI binding + if( xUriBinding.is() ) + xmlUnregisterStreamInputCallbacks() ; + + throw RuntimeException() ; + } + + xmlSecDSigCtxDestroy( pDsigCtx ) ; + + //Unregistered the stream/URI binding + if( xUriBinding.is() ) + xmlUnregisterStreamInputCallbacks() ; + + return aTemplate ; +} + +/* XXMLSignature */ +sal_Bool SAL_CALL +XMLSignature_NssImpl :: validate( + const Reference< XXMLSignatureTemplate >& aTemplate , + const Reference< XXMLSecurityContext >& aSecurityCtx +) throw( com::sun::star::uno::RuntimeException, + com::sun::star::uno::SecurityException, + com::sun::star::xml::crypto::XMLSignatureException ) { + xmlSecKeysMngrPtr pMngr = NULL ; + xmlSecDSigCtxPtr pDsigCtx = NULL ; + xmlNodePtr pNode = NULL ; + sal_Bool valid ; + + if( !aTemplate.is() ) + throw RuntimeException() ; + + if( !aSecurityCtx.is() ) + throw RuntimeException() ; + + //Get the xml node + Reference< XXMLElementWrapper > xElement = aTemplate->getTemplate() ; + if( !xElement.is() ) + throw RuntimeException() ; + + Reference< XUnoTunnel > xNodTunnel( xElement , UNO_QUERY ) ; + if( !xNodTunnel.is() ) { + throw RuntimeException() ; + } + + XMLElementWrapper_XmlSecImpl* pElement = ( XMLElementWrapper_XmlSecImpl* )xNodTunnel->getSomething( XMLElementWrapper_XmlSecImpl::getUnoTunnelImplementationId() ) ; + if( pElement == NULL ) + throw RuntimeException() ; + + pNode = pElement->getNativeElement() ; + + //Get the stream/URI binding + Reference< XUriBinding > xUriBinding = aTemplate->getBinding() ; + if( xUriBinding.is() ) { + //Register the stream input callbacks into libxml2 + if( xmlRegisterStreamInputCallbacks( xUriBinding ) < 0 ) + throw RuntimeException() ; + } + + //added for test: save the result + /* + { + FILE *dstFile = fopen( "c:\\1.txt", "w" ) ; + xmlDocDump( dstFile, pNode->doc) ; + fclose( dstFile ) ; + } + */ + + //Get Keys Manager + Reference< XUnoTunnel > xSecTunnel( aSecurityCtx , UNO_QUERY ) ; + if( !xSecTunnel.is() ) { + throw RuntimeException() ; + } + + XMLSecurityContext_NssImpl* pSecCtxt = ( XMLSecurityContext_NssImpl* )xSecTunnel->getSomething( XMLSecurityContext_NssImpl::getUnoTunnelId() ) ; + if( pSecCtxt == NULL ) + throw RuntimeException() ; + + pMngr = pSecCtxt->keysManager() ; + + //Create Signature context + pDsigCtx = xmlSecDSigCtxCreate( pMngr ) ; + if( pDsigCtx == NULL ) + throw RuntimeException() ; + + + //Verify signature + if( xmlSecDSigCtxVerify( pDsigCtx , pNode ) < 0 ) { + xmlSecDSigCtxDestroy( pDsigCtx ) ; + + //Unregistered the stream/URI binding + if( xUriBinding.is() ) + xmlUnregisterStreamInputCallbacks() ; + + throw RuntimeException() ; + } + + valid = ( pDsigCtx->status == xmlSecDSigStatusSucceeded ) ; + + xmlSecDSigCtxDestroy( pDsigCtx ) ; + + //Unregistered the stream/URI binding + if( xUriBinding.is() ) + xmlUnregisterStreamInputCallbacks() ; + + return valid ; +} + +/* XInitialization */ +void SAL_CALL XMLSignature_NssImpl :: initialize( const Sequence< Any >& aArguments ) throw( Exception, RuntimeException ) { + // TBD +} ; + +/* XServiceInfo */ +OUString SAL_CALL XMLSignature_NssImpl :: getImplementationName() throw( RuntimeException ) { + return impl_getImplementationName() ; +} + +/* XServiceInfo */ +sal_Bool SAL_CALL XMLSignature_NssImpl :: supportsService( const OUString& serviceName) throw( RuntimeException ) { + Sequence< OUString > seqServiceNames = getSupportedServiceNames() ; + const OUString* pArray = seqServiceNames.getConstArray() ; + for( sal_Int32 i = 0 ; i < seqServiceNames.getLength() ; i ++ ) { + if( *( pArray + i ) == serviceName ) + return sal_True ; + } + return sal_False ; +} + +/* XServiceInfo */ +Sequence< OUString > SAL_CALL XMLSignature_NssImpl :: getSupportedServiceNames() throw( RuntimeException ) { + return impl_getSupportedServiceNames() ; +} + +//Helper for XServiceInfo +Sequence< OUString > XMLSignature_NssImpl :: impl_getSupportedServiceNames() { + ::osl::Guard< ::osl::Mutex > aGuard( ::osl::Mutex::getGlobalMutex() ) ; + Sequence< OUString > seqServiceNames( 1 ) ; + seqServiceNames.getArray()[0] = OUString::createFromAscii( "com.sun.star.xml.crypto.XMLSignature" ) ; + return seqServiceNames ; +} + +OUString XMLSignature_NssImpl :: impl_getImplementationName() throw( RuntimeException ) { + return OUString::createFromAscii( "com.sun.star.xml.security.bridge.xmlsec.XMLSignature_NssImpl" ) ; +} + +//Helper for registry +Reference< XInterface > SAL_CALL XMLSignature_NssImpl :: impl_createInstance( const Reference< XMultiServiceFactory >& aServiceManager ) throw( RuntimeException ) { + return Reference< XInterface >( *new XMLSignature_NssImpl( aServiceManager ) ) ; +} + +Reference< XSingleServiceFactory > XMLSignature_NssImpl :: impl_createFactory( const Reference< XMultiServiceFactory >& aServiceManager ) { + //Reference< XSingleServiceFactory > xFactory ; + //xFactory = ::cppu::createSingleFactory( aServiceManager , impl_getImplementationName , impl_createInstance , impl_getSupportedServiceNames ) ; + //return xFactory ; + return ::cppu::createSingleFactory( aServiceManager , impl_getImplementationName() , impl_createInstance , impl_getSupportedServiceNames() ) ; +} + diff --git a/xmlsecurity/source/xmlsec/nss/xmlsignature_nssimpl.hxx b/xmlsecurity/source/xmlsec/nss/xmlsignature_nssimpl.hxx new file mode 100644 index 000000000000..644813bdcc2c --- /dev/null +++ b/xmlsecurity/source/xmlsec/nss/xmlsignature_nssimpl.hxx @@ -0,0 +1,165 @@ +/************************************************************************* + * + * $RCSfile: xmlsignature_nssimpl.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:21 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _XMLSIGNATURE_NSSIMPL_HXX_ +#define _XMLSIGNATURE_NSSIMPL_HXX_ + +#ifndef _SAL_CONFIG_H_ +#include +#endif + +#ifndef _RTL_USTRING_HXX_ +#include +#endif + +#ifndef _CPPUHELPER_FACTORY_HXX_ +#include +#endif + +#ifndef _CPPUHELPER_IMPLBASE3_HXX_ +#include +#endif + +#ifndef _COM_SUN_STAR_UNO_EXCEPTION_HPP_ +#include +#endif + +#ifndef _COM_SUN_STAR_UNO_REFERENCE_HPP_ +#include +#endif + +#ifndef _COM_SUN_STAR_LANG_XSINGLESERVICEFACTORY_HPP_ +#include +#endif + +#ifndef _COM_SUN_STAR_LANG_XSECVICEINFO_HPP_ +#include +#endif + +#ifndef _COM_SUN_STAR_LANG_XINITIALIZATION_HPP_ +#include +#endif + +#ifndef _COM_SUN_STAR_XML_CRYPTO_XXMLSIGNATURE_HPP_ +#include +#endif + +#ifndef _COM_SUN_STAR_XML_CRYPTO_XXMLSIGNATURETEMPLATE_HPP_ +#include +#endif + +#ifndef _COM_SUN_STAR_XML_CRYPTO_XXMLSECURITYCONTEXT_HPP_ +#include +#endif + +class XMLSignature_NssImpl : public ::cppu::WeakImplHelper3< + ::com::sun::star::xml::crypto::XXMLSignature , + ::com::sun::star::lang::XInitialization , + ::com::sun::star::lang::XServiceInfo > +{ + private : + ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xServiceManager ; + + public : + XMLSignature_NssImpl( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& aFactory ) ; + virtual ~XMLSignature_NssImpl() ; + + //Methods from XXMLSignature + virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::crypto::XXMLSignatureTemplate > SAL_CALL generate( + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::crypto::XXMLSignatureTemplate >& aTemplate , + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::crypto::XXMLSecurityContext >& aContext + ) throw( com::sun::star::xml::crypto::XMLSignatureException, + com::sun::star::uno::SecurityException) ; + + virtual sal_Bool SAL_CALL validate( + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::crypto::XXMLSignatureTemplate >& aTemplate , + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::crypto::XXMLSecurityContext >& aContext + ) throw( com::sun::star::uno::RuntimeException, + com::sun::star::uno::SecurityException, + com::sun::star::xml::crypto::XMLSignatureException); + + //Methods from XInitialization + virtual void SAL_CALL initialize( + const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments + ) throw( ::com::sun::star::uno::Exception , ::com::sun::star::uno::RuntimeException ) ; + + //Methods from XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName() throw( ::com::sun::star::uno::RuntimeException ) ; + + virtual sal_Bool SAL_CALL supportsService( + const ::rtl::OUString& ServiceName + ) throw( ::com::sun::star::uno::RuntimeException ) ; + + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw( ::com::sun::star::uno::RuntimeException ) ; + + //Helper for XServiceInfo + static ::com::sun::star::uno::Sequence< ::rtl::OUString > impl_getSupportedServiceNames() ; + + static ::rtl::OUString impl_getImplementationName() throw( ::com::sun::star::uno::RuntimeException ) ; + + //Helper for registry + static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL impl_createInstance( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& aServiceManager ) throw( ::com::sun::star::uno::RuntimeException ) ; + + static ::com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleServiceFactory > impl_createFactory( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& aServiceManager ) ; +} ; + +#endif // _XMLSIGNATURE_NSSIMPL_HXX_ + diff --git a/xmlsecurity/source/xmlsec/nss/xsec_nss.cxx b/xmlsecurity/source/xmlsec/nss/xsec_nss.cxx new file mode 100644 index 000000000000..002f17b17935 --- /dev/null +++ b/xmlsecurity/source/xmlsec/nss/xsec_nss.cxx @@ -0,0 +1,199 @@ +/************************************************************************* + * + * $RCSfile: xsec_nss.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:21 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#include +#include + +#include +#include +#include + +#ifndef _COM_SUN_STAR_LANG_XSINGLESERVICEFACTORY_HPP_ +#include +#endif + +#include "seinitializer_nssimpl.hxx" +#include "xmlsignature_nssimpl.hxx" +#include "xmlencryption_nssimpl.hxx" +#include "xmlsecuritycontext_nssimpl.hxx" +#include "securityenvironment_nssimpl.hxx" + +using namespace ::rtl; +using namespace ::cppu; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::registry; + +extern "C" +{ + +sal_Bool SAL_CALL nss_component_writeInfo( void* pServiceManager , void* pRegistryKey ) +{ + sal_Bool result = sal_False; + sal_Int32 i ; + OUString sKeyName ; + Reference< XRegistryKey > xNewKey ; + Sequence< OUString > seqServices ; + Reference< XRegistryKey > xKey( reinterpret_cast< XRegistryKey* >( pRegistryKey ) ) ; + + if( xKey.is() ) { + // try { + // XMLSignature_NssImpl + sKeyName = OUString( RTL_CONSTASCII_USTRINGPARAM( "/" ) ) ; + sKeyName += XMLSignature_NssImpl::impl_getImplementationName() ; + sKeyName += OUString::createFromAscii( "/UNO/SERVICES" ) ; + + xNewKey = xKey->createKey( sKeyName ) ; + if( xNewKey.is() ) { + seqServices = XMLSignature_NssImpl::impl_getSupportedServiceNames() ; + for( i = seqServices.getLength() ; i -- ; ) + xNewKey->createKey( seqServices.getConstArray()[i] ) ; + } + + // XMLEncryption_NssImpl + sKeyName = OUString( RTL_CONSTASCII_USTRINGPARAM( "/" ) ) ; + sKeyName += XMLEncryption_NssImpl::impl_getImplementationName() ; + sKeyName += OUString::createFromAscii( "/UNO/SERVICES" ) ; + + xNewKey = xKey->createKey( sKeyName ) ; + if( xNewKey.is() ) { + seqServices = XMLEncryption_NssImpl::impl_getSupportedServiceNames() ; + for( i = seqServices.getLength() ; i -- ; ) + xNewKey->createKey( seqServices.getConstArray()[i] ) ; + } + + // XMLSecurityContext_NssImpl + sKeyName = OUString( RTL_CONSTASCII_USTRINGPARAM( "/" ) ) ; + sKeyName += XMLSecurityContext_NssImpl::impl_getImplementationName() ; + sKeyName += OUString::createFromAscii( "/UNO/SERVICES" ) ; + + xNewKey = xKey->createKey( sKeyName ) ; + if( xNewKey.is() ) { + seqServices = XMLSecurityContext_NssImpl::impl_getSupportedServiceNames() ; + for( i = seqServices.getLength() ; i -- ; ) + xNewKey->createKey( seqServices.getConstArray()[i] ) ; + } + + // SecurityEnvironment_NssImpl + sKeyName = OUString( RTL_CONSTASCII_USTRINGPARAM( "/" ) ) ; + sKeyName += SecurityEnvironment_NssImpl::impl_getImplementationName() ; + sKeyName += OUString::createFromAscii( "/UNO/SERVICES" ) ; + + xNewKey = xKey->createKey( sKeyName ) ; + if( xNewKey.is() ) { + seqServices = SecurityEnvironment_NssImpl::impl_getSupportedServiceNames() ; + for( i = seqServices.getLength() ; i -- ; ) + xNewKey->createKey( seqServices.getConstArray()[i] ) ; + } + + // SEInitializer_NssImpl + sKeyName = OUString( RTL_CONSTASCII_USTRINGPARAM( "/" ) ) ; + sKeyName += SEInitializer_NssImpl_getImplementationName() ; + sKeyName += OUString::createFromAscii( "/UNO/SERVICES" ) ; + + xNewKey = xKey->createKey( sKeyName ) ; + if( xNewKey.is() ) { + seqServices = SEInitializer_NssImpl_getSupportedServiceNames() ; + for( i = seqServices.getLength() ; i -- ; ) + xNewKey->createKey( seqServices.getConstArray()[i] ) ; + } + + return sal_True; + //} catch( InvalidRegistryException & ) { + // //we should not ignore exceptions + // return sal_False ; + //} + } + return result; +} + +void* SAL_CALL nss_component_getFactory( const sal_Char* pImplName , void* pServiceManager , void* pRegistryKey ) +{ + void* pRet = 0; + Reference< XSingleServiceFactory > xFactory ; + + if( pImplName != NULL && pServiceManager != NULL ) { + if( XMLSignature_NssImpl::impl_getImplementationName().equals( OUString::createFromAscii( pImplName ) ) ) { + xFactory = XMLSignature_NssImpl::impl_createFactory( reinterpret_cast< XMultiServiceFactory* >( pServiceManager ) ) ; + } else if( XMLSecurityContext_NssImpl::impl_getImplementationName().equals( OUString::createFromAscii( pImplName ) ) ) { + xFactory = XMLSecurityContext_NssImpl::impl_createFactory( reinterpret_cast< XMultiServiceFactory* >( pServiceManager ) ) ; + } else if( SecurityEnvironment_NssImpl::impl_getImplementationName().equals( OUString::createFromAscii( pImplName ) ) ) { + xFactory = SecurityEnvironment_NssImpl::impl_createFactory( reinterpret_cast< XMultiServiceFactory* >( pServiceManager ) ) ; + } else if( XMLEncryption_NssImpl::impl_getImplementationName().equals( OUString::createFromAscii( pImplName ) ) ) { + xFactory = XMLEncryption_NssImpl::impl_createFactory( reinterpret_cast< XMultiServiceFactory* >( pServiceManager ) ) ; + } else if( SEInitializer_NssImpl_getImplementationName().equals( OUString::createFromAscii( pImplName ) ) ) { + xFactory = Reference< XSingleServiceFactory >( createSingleFactory( + reinterpret_cast< XMultiServiceFactory * >( pServiceManager ), + OUString::createFromAscii( pImplName ), + SEInitializer_NssImpl_createInstance, SEInitializer_NssImpl_getSupportedServiceNames() ) ); + } + } + + if( xFactory.is() ) { + xFactory->acquire() ; + pRet = xFactory.get() ; + } + + return pRet ; +} + +} + diff --git a/xmlsecurity/source/xmlsec/saxhelper.cxx b/xmlsecurity/source/xmlsec/saxhelper.cxx new file mode 100644 index 000000000000..b95c5baacce8 --- /dev/null +++ b/xmlsecurity/source/xmlsec/saxhelper.cxx @@ -0,0 +1,465 @@ +/************************************************************************* + * + * $RCSfile: saxhelper.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:21 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#include + +#include "saxhelper.hxx" +#include "libxml/parserInternals.h" + +#ifndef XMLSEC_NO_XSLT +#include "libxslt/xslt.h" +#endif + +namespace cssu = com::sun::star::uno; +namespace cssxs = com::sun::star::xml::sax; +namespace cssxcsax = com::sun::star::xml::csax; + +/** + * The return value is NULL terminated. The application has the responsibilty to + * deallocte the return value. + */ +xmlChar* ous_to_xmlstr( const rtl::OUString& oustr ) +{ + rtl::OString ostr = rtl::OUStringToOString( oustr , RTL_TEXTENCODING_UTF8 ) ; + return xmlStrndup( ( xmlChar* )ostr.getStr(), ( int )ostr.getLength() ) ; +} + +/** + * The return value is NULL terminated. The application has the responsibilty to + * deallocte the return value. + */ +xmlChar* ous_to_nxmlstr( const rtl::OUString& oustr, int& length ) +{ + rtl::OString ostr = rtl::OUStringToOString( oustr , RTL_TEXTENCODING_UTF8 ) ; + length = ostr.getLength(); + + return xmlStrndup( ( xmlChar* )ostr.getStr(), length ) ; +} + +/** + * The input parameter isn't necessaryly NULL terminated. + */ +rtl::OUString xmlchar_to_ous( const xmlChar* pChar, int length ) +{ + if( pChar != NULL ) + { + return rtl::OUString( ( sal_Char* )pChar , length , RTL_TEXTENCODING_UTF8 ) ; + } + else + { + return rtl::OUString() ; + } +} + +/** + * The input parameter is NULL terminated + */ +rtl::OUString xmlstr_to_ous( const xmlChar* pStr ) +{ + if( pStr != NULL ) + { + return xmlchar_to_ous( pStr , xmlStrlen( pStr ) ) ; + } + else + { + return rtl::OUString() ; + } +} + +/** + * The return value and the referenced value must be NULL terminated. + * The application has the responsibilty to deallocte the return value. + */ +const xmlChar** attrlist_to_nxmlstr( const cssu::Sequence< cssxcsax::XMLAttribute >& aAttributes ) +{ + xmlChar* attname = NULL ; + xmlChar* attvalue = NULL ; + const xmlChar** attrs = NULL ; + rtl::OUString oustr ; + + sal_Int32 nLength = aAttributes.getLength();; + + if( nLength != 0 ) + { + attrs = ( const xmlChar** )xmlMalloc( ( nLength * 2 + 2 ) * sizeof( xmlChar* ) ) ; + } + else + { + return NULL ; + } + + for( int i = 0 , j = 0 ; j < nLength ; ++j ) + { + attname = ous_to_xmlstr( aAttributes[j].sName ) ; + attvalue = ous_to_xmlstr( aAttributes[j].sValue ) ; + + if( attname != NULL && attvalue != NULL ) + { + attrs[i++] = attname ; + attrs[i++] = attvalue ; + attrs[i] = NULL ; + attrs[i+1] = NULL ; + } + else + { + if( attname != NULL ) + xmlFree( attname ) ; + if( attvalue != NULL ) + xmlFree( attvalue ) ; + } + } + + return attrs ; +} + +/** + * Constructor + * + * In this constructor, a libxml sax parser context is initialized. a libxml + * default sax handler is initialized with the context. + */ +SAXHelper::SAXHelper( ) + : m_pParserCtxt( NULL ), + m_pSaxHandler( NULL ) +{ + xmlInitParser() ; + LIBXML_TEST_VERSION ; + + /* + * compile error: + * xmlLoadExtDtdDefaultValue = XML_DETECT_IDS | XML_COMPLETE_ATTRS ; + */ + xmlSubstituteEntitiesDefault( 1 ) ; + +#ifndef XMLSEC_NO_XSLT + xmlIndentTreeOutput = 1 ; +#endif /* XMLSEC_NO_XSLT */ + + m_pParserCtxt = xmlNewParserCtxt() ; + if( m_pParserCtxt->inputTab[0] != NULL ) + { + m_pParserCtxt->inputTab[0] = NULL ; + } + + if( m_pParserCtxt == NULL ) + { +#ifndef XMLSEC_NO_XSLT + xsltCleanupGlobals() ; +#endif + xmlCleanupParser() ; + throw cssu::RuntimeException() ; + } + else if( m_pParserCtxt->sax == NULL ) + { + xmlFreeParserCtxt( m_pParserCtxt ) ; + +#ifndef XMLSEC_NO_XSLT + xsltCleanupGlobals() ; +#endif + xmlCleanupParser() ; + m_pParserCtxt = NULL ; + throw cssu::RuntimeException() ; + } + else + { + m_pSaxHandler = m_pParserCtxt->sax ; + + //Adjust the context + m_pParserCtxt->recovery = 1 ; + } +} + +/** + * Destructor + * + * In this destructor, a libxml sax parser context is desturcted. The XML tree + * in the context is not deallocated because the tree is bind with a document + * model by the setTargetDocument method, which delegate the target document to + * destruct the xml tree. + */ +SAXHelper::~SAXHelper() { + if( m_pParserCtxt != NULL ) + { + /* + * In the situation that no object refer the Document, this destructor + * must deallocate the Document memory + */ + if( m_pSaxHandler == m_pParserCtxt->sax ) + { + m_pSaxHandler = NULL ; + } + + xmlFreeParserCtxt( m_pParserCtxt ) ; + m_pParserCtxt = NULL ; + } + + if( m_pSaxHandler != NULL ) + { + xmlFree( m_pSaxHandler ) ; + m_pSaxHandler = NULL ; + } + + xmlCleanupParser() ; +} + +xmlNodePtr SAXHelper::getCurrentNode() +{ + return m_pParserCtxt->node; +} + +void SAXHelper::setCurrentNode(const xmlNodePtr pNode) +{ + /* + * This is really a black trick. + * When the current node is replaced, the nodeTab + * stack's top has to been replaced with the same + * node, in order to make compatibility. + */ + m_pParserCtxt->nodeTab[m_pParserCtxt->nodeNr - 1] + = m_pParserCtxt->node + = pNode; +} + +xmlDocPtr SAXHelper::getDocument() +{ + return m_pParserCtxt->myDoc; +} + +/** + * XDocumentHandler -- start an xml document + */ +void SAXHelper::startDocument( void ) + throw( cssxs::SAXException , cssu::RuntimeException ) +{ + /* + * Adjust inputTab + */ + xmlParserInputPtr pInput = xmlNewInputStream( m_pParserCtxt ) ; + + if( m_pParserCtxt->inputTab != NULL && m_pParserCtxt->inputMax != 0 ) + { + m_pParserCtxt->inputTab[0] = pInput ; + m_pParserCtxt->input = pInput ; + } + + m_pSaxHandler->startDocument( m_pParserCtxt ) ; + + if( m_pParserCtxt == NULL || m_pParserCtxt->myDoc == NULL ) + { + throw cssu::RuntimeException() ; + } +} + +/** + * XDocumentHandler -- end an xml document + */ +void SAXHelper::endDocument( void ) + throw( cssxs::SAXException , cssu::RuntimeException ) +{ + m_pSaxHandler->endDocument( m_pParserCtxt ) ; +} + +/** + * XDocumentHandler -- start an xml element + */ +void SAXHelper::startElement( + const rtl::OUString& aName, + const cssu::Sequence< cssxcsax::XMLAttribute >& aAttributes ) + throw( cssxs::SAXException , cssu::RuntimeException ) +{ + const xmlChar* fullName = NULL ; + const xmlChar** attrs = NULL ; + + fullName = ous_to_xmlstr( aName ) ; + attrs = attrlist_to_nxmlstr( aAttributes ) ; + + if( fullName != NULL || attrs != NULL ) + { + m_pSaxHandler->startElement( m_pParserCtxt , fullName , attrs ) ; + } + + if( fullName != NULL ) + { + xmlFree( ( xmlChar* )fullName ) ; + fullName = NULL ; + } + + if( attrs != NULL ) + { + for( int i = 0 ; attrs[i] != NULL ; ++i ) + { + xmlFree( ( xmlChar* )attrs[i] ) ; + attrs[i] = NULL ; + } + + xmlFree( ( void* ) attrs ) ; + attrs = NULL ; + } +} + +/** + * XDocumentHandler -- end an xml element + */ +void SAXHelper::endElement( const rtl::OUString& aName ) + throw( cssxs::SAXException , cssu::RuntimeException ) +{ + xmlChar* fullname = NULL ; + + fullname = ous_to_xmlstr( aName ) ; + m_pSaxHandler->endElement( m_pParserCtxt , fullname ) ; + + if( fullname != NULL ) + { + xmlFree( ( xmlChar* )fullname ) ; + fullname = NULL ; + } +} + +/** + * XDocumentHandler -- an xml element or cdata characters + */ +void SAXHelper::characters( const rtl::OUString& aChars ) + throw( cssxs::SAXException , cssu::RuntimeException ) +{ + const xmlChar* chars = NULL ; + int length = 0 ; + + chars = ous_to_nxmlstr( aChars, length ) ; + m_pSaxHandler->characters( m_pParserCtxt , chars , length ) ; + + if( chars != NULL ) + { + xmlFree( ( xmlChar* )chars ) ; + } +} + +/** + * XDocumentHandler -- ignorable xml white space + */ +void SAXHelper::ignorableWhitespace( const rtl::OUString& aWhitespaces ) + throw( cssxs::SAXException , cssu::RuntimeException ) +{ + const xmlChar* chars = NULL ; + int length = 0 ; + + chars = ous_to_nxmlstr( aWhitespaces, length ) ; + m_pSaxHandler->ignorableWhitespace( m_pParserCtxt , chars , length ) ; + + if( chars != NULL ) + { + xmlFree( ( xmlChar* )chars ) ; + } +} + +/** + * XDocumentHandler -- preaorocessing instruction + */ +void SAXHelper::processingInstruction( + const rtl::OUString& aTarget, + const rtl::OUString& aData ) + throw( cssxs::SAXException , cssu::RuntimeException ) +{ + xmlChar* target = NULL ; + xmlChar* data = NULL ; + + target = ous_to_xmlstr( aTarget ) ; + data = ous_to_xmlstr( aData ) ; + + m_pSaxHandler->processingInstruction( m_pParserCtxt , target , data ) ; + + if( target != NULL ) + { + xmlFree( ( xmlChar* )target ) ; + target = NULL ; + } + + if( data != NULL ) + { + xmlFree( ( xmlChar* )data ) ; + data = NULL ; + } +} + +/** + * XDocumentHandler -- set document locator + * In this case, locator is useless. + */ +void SAXHelper::setDocumentLocator( + const cssu::Reference< cssxs::XLocator > & xLocator ) + throw( cssxs::SAXException , cssu::RuntimeException ) +{ + //--Pseudo code if necessary + //--m_pSaxLocator is a member defined as xmlSAXHabdlerPtr + //--m_pSaxLocatorHdl is a member defined as Sax_Locator + + //if( m_pSaxLocator != NULL ) { + // //Deallocate the memory + //} + //if( m_pSaxLocatorHdl != NULL ) { + // //Deallocate the memory + //} + + //m_pSaxLocatorHdl = new Sax_Locator( xLocator ) ; + //m_pSaxLocator = { m_pSaxLocatorHdl->getPublicId , m_pSaxLocatorHdl->getSystemId , m_pSaxLocatorHdl->getLineNumber , m_pSaxLocatorHdl->getColumnNumber } ; + + //m_pSaxHandler->setDocumentLocator( m_pParserCtxt , m_pSaxLocator ) ; +} + diff --git a/xmlsecurity/source/xmlsec/saxhelper.hxx b/xmlsecurity/source/xmlsec/saxhelper.hxx new file mode 100644 index 000000000000..2642c05177c5 --- /dev/null +++ b/xmlsecurity/source/xmlsec/saxhelper.hxx @@ -0,0 +1,123 @@ +/************************************************************************* + * + * $RCSfile: saxhelper.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:21 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _SAXHELPER_HXX +#define _SAXHELPER_HXX + +#include "libxml/tree.h" + +#include +#include +#include +#include + +#ifndef _COM_SUN_STAR_XML_CSAX_XMLATTRIBUTE_HPP_ +#include +#endif + + +class SAXHelper +{ + private : + xmlParserCtxtPtr m_pParserCtxt ; + xmlSAXHandlerPtr m_pSaxHandler ; + + public: + SAXHelper( ) ; + virtual ~SAXHelper() ; + + xmlNodePtr getCurrentNode(); + void setCurrentNode(const xmlNodePtr pNode); + xmlDocPtr getDocument(); + + void startDocument( void ) + throw( ::com::sun::star::xml::sax::SAXException , ::com::sun::star::uno::RuntimeException ) ; + + void endDocument( void ) + throw( ::com::sun::star::xml::sax::SAXException , ::com::sun::star::uno::RuntimeException ) ; + + void startElement( + const ::rtl::OUString& aName , + const com::sun::star::uno::Sequence< + com::sun::star::xml::csax::XMLAttribute >& aAttributes ) + throw( ::com::sun::star::xml::sax::SAXException , ::com::sun::star::uno::RuntimeException ) ; + + void endElement( const ::rtl::OUString& aName ) + throw( ::com::sun::star::xml::sax::SAXException , ::com::sun::star::uno::RuntimeException ) ; + + void characters( const ::rtl::OUString& aChars ) + throw( ::com::sun::star::xml::sax::SAXException , ::com::sun::star::uno::RuntimeException ) ; + + void ignorableWhitespace( const ::rtl::OUString& aWhitespaces ) + throw( ::com::sun::star::xml::sax::SAXException , ::com::sun::star::uno::RuntimeException ) ; + + void processingInstruction( + const ::rtl::OUString& aTarget , + const ::rtl::OUString& aData ) + throw( ::com::sun::star::xml::sax::SAXException , ::com::sun::star::uno::RuntimeException ) ; + + void setDocumentLocator( const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XLocator > & xLocator ) + throw( ::com::sun::star::xml::sax::SAXException , ::com::sun::star::uno::RuntimeException ) ; +} ; + +#endif + diff --git a/xmlsecurity/source/xmlsec/xmldocumentwrapper_xmlsecimpl.cxx b/xmlsecurity/source/xmlsec/xmldocumentwrapper_xmlsecimpl.cxx new file mode 100644 index 000000000000..795ac4a8d225 --- /dev/null +++ b/xmlsecurity/source/xmlsec/xmldocumentwrapper_xmlsecimpl.cxx @@ -0,0 +1,1187 @@ +/************************************************************************* + * + * $RCSfile: xmldocumentwrapper_xmlsecimpl.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:21 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#include "xmldocumentwrapper_xmlsecimpl.hxx" + +#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_ +#include +#endif + +#include +#include "xmlelementwrapper_xmlsecimpl.hxx" + +#include +#include +#include +#include + +/* + * Deleted by AF +#include + */ + +#include +#include + +#ifndef INCLUDED_VECTOR +#include +#define INCLUDED_VECTOR +#endif + +#ifdef UNX +#define stricmp strcasecmp +#endif + +namespace cssu = com::sun::star::uno; +namespace cssl = com::sun::star::lang; +namespace cssxc = com::sun::star::xml::crypto; +namespace cssxcsax = com::sun::star::xml::csax; +namespace cssxs = com::sun::star::xml::sax; +namespace cssxw = com::sun::star::xml::wrapper; + +#define SERVICE_NAME "com.sun.star.xml.wrapper.XMLDocumentWrapper" +#define IMPLEMENTATION_NAME "com.sun.star.xml.security.bridge.xmlsec.XMLDocumentWrapper_XmlSecImpl" + +#define STRXMLNS "xmlns" + +#define RTL_ASCII_USTRINGPARAM( asciiStr ) asciiStr, strlen( asciiStr ), RTL_TEXTENCODING_ASCII_US +#define RTL_UTF8_USTRINGPARAM( asciiStr ) asciiStr, strlen( asciiStr ), RTL_TEXTENCODING_UTF8 + +/* used by the recursiveDelete method */ +#define NODE_REMOVED 0 +#define NODE_NOTREMOVED 1 +#define NODE_STOPED 2 + +XMLDocumentWrapper_XmlSecImpl::XMLDocumentWrapper_XmlSecImpl( ) +{ + saxHelper.startDocument(); + m_pDocument = saxHelper.getDocument(); + + /* + * creates the virtual root element + */ + saxHelper.startElement(rtl::OUString(RTL_UTF8_USTRINGPARAM( "root" )), NULL); + + m_pRootElement = saxHelper.getCurrentNode(); + m_pCurrentElement = m_pRootElement; +} + +XMLDocumentWrapper_XmlSecImpl::~XMLDocumentWrapper_XmlSecImpl() +{ + saxHelper.endDocument(); + xmlFreeDoc(m_pDocument); +} + +void XMLDocumentWrapper_XmlSecImpl::getNextSAXEvent() +/****** XMLDocumentWrapper_XmlSecImpl/getNextSAXEvent ************************* + * + * NAME + * getNextSAXEvent -- Prepares the next SAX event to be manipulate + * + * SYNOPSIS + * getNextSAXEvent(); + * + * FUNCTION + * When converting the document into SAX events, this method is used to + * decide the next SAX event to be generated. + * Two member variables are checked to make the decision, the + * m_pCurrentElement and the m_nCurrentPosition. + * The m_pCurrentElement represents the node which have been covered, and + * the m_nCurrentPosition represents the event which have been sent. + * For example, suppose that the m_pCurrentElement + * points to element A, and the m_nCurrentPosition equals to + * NODEPOSITION_STARTELEMENT, then the next SAX event should be the + * endElement for element A if A has no child, or startElement for the + * first child element of element A otherwise. + * The m_nCurrentPosition can be one of following values: + * NODEPOSITION_STARTELEMENT for startElement; + * NODEPOSITION_ENDELEMENT for endElement; + * NODEPOSITION_NORMAL for other SAX events; + * + * INPUTS + * empty + * + * RESULT + * empty + * + * HISTORY + * 05.01.2004 - implemented + * + * AUTHOR + * Michael Mi + * Email: michael.mi@sun.com + ******************************************************************************/ +{ + OSL_ASSERT( m_pCurrentElement != NULL ); + + /* + * Get the next event through tree order. + * + * if the current event is a startElement, then the next + * event depends on whether or not the current node has + * children. + */ + if (m_nCurrentPosition == NODEPOSITION_STARTELEMENT) + { + /* + * If the current node has children, then its first child + * should be next current node, and the next event will be + * startElement or charaters(PI) based on that child's node + * type. Otherwise, the endElement of current node is the + * next event. + */ + if (m_pCurrentElement->children != NULL) + { + m_pCurrentElement = m_pCurrentElement->children; + m_nCurrentPosition + = (m_pCurrentElement->type == XML_ELEMENT_NODE)? + NODEPOSITION_STARTELEMENT:NODEPOSITION_NORMAL; + } + else + { + m_nCurrentPosition = NODEPOSITION_ENDELEMENT; + } + } + /* + * if the current event is a not startElement, then the next + * event depends on whether or not the current node has + * following sibling. + */ + else if (m_nCurrentPosition == NODEPOSITION_ENDELEMENT || m_nCurrentPosition == NODEPOSITION_NORMAL) + { + xmlNodePtr pNextSibling = m_pCurrentElement->next; + + /* + * If the current node has following sibling, that sibling + * should be next current node, and the next event will be + * startElement or charaters(PI) based on that sibling's node + * type. Otherwise, the endElement of current node's parent + * becomes the next event. + */ + if (pNextSibling != NULL) + { + m_pCurrentElement = pNextSibling; + m_nCurrentPosition + = (m_pCurrentElement->type == XML_ELEMENT_NODE)? + NODEPOSITION_STARTELEMENT:NODEPOSITION_NORMAL; + } + else + { + m_pCurrentElement = m_pCurrentElement->parent; + m_nCurrentPosition = NODEPOSITION_ENDELEMENT; + } + } +} + +void XMLDocumentWrapper_XmlSecImpl::sendStartElement( + const cssu::Reference< cssxs::XDocumentHandler >& xHandler, + const cssu::Reference< cssxs::XDocumentHandler >& xHandler2, + const xmlNodePtr pNode) const + throw (cssxs::SAXException) +/****** XMLDocumentWrapper_XmlSecImpl/sendStartElement ************************ + * + * NAME + * sendStartElement -- Constructs a startElement SAX event + * + * SYNOPSIS + * sendStartElement(xHandler, xHandler2, pNode); + * + * FUNCTION + * Used when converting the document into SAX event stream. + * This method constructs a startElement SAX event for a particular + * element, then calls the startElement methods of the XDocumentHandlers. + * + * INPUTS + * xHandler - the first XDocumentHandler interface to receive the + * startElement SAX event. It can be NULL. + * xHandler2 - the second XDocumentHandler interface to receive the + * startElement SAX event. It can't be NULL. + * pNode - the node on which the startElement should be generated. + * This node must be a element type. + * + * RESULT + * empty + * + * HISTORY + * 05.01.2004 - implemented + * + * AUTHOR + * Michael Mi + * Email: michael.mi@sun.com + ******************************************************************************/ +{ + SvXMLAttributeList* pAttributeList = new SvXMLAttributeList(); + cssu::Reference < cssxs::XAttributeList > xAttrList = cssu::Reference< cssxs::XAttributeList > (pAttributeList); + + xmlNsPtr pNsDef = pNode->nsDef; + + while (pNsDef != NULL) + { + const xmlChar* pNsPrefix = pNsDef->prefix; + const xmlChar* pNsHref = pNsDef->href; + + if (pNsDef->prefix == NULL) + { + pAttributeList->AddAttribute( + rtl::OUString(RTL_UTF8_USTRINGPARAM( STRXMLNS )), + rtl::OUString(RTL_UTF8_USTRINGPARAM( (sal_Char*)pNsHref ))); + } + else + { + pAttributeList->AddAttribute( + rtl::OUString(RTL_UTF8_USTRINGPARAM( STRXMLNS )) + +rtl::OUString(RTL_UTF8_USTRINGPARAM( ":" )) + +rtl::OUString(RTL_UTF8_USTRINGPARAM( (sal_Char*)pNsPrefix )), + rtl::OUString(RTL_UTF8_USTRINGPARAM( (sal_Char*)pNsHref ))); + } + + pNsDef = pNsDef->next; + } + + xmlAttrPtr pAttr = pNode->properties; + + while (pAttr != NULL) + { + const xmlChar* pAttrName = pAttr->name; + xmlNsPtr pAttrNs = pAttr->ns; + + rtl::OUString ouAttrName; + if (pAttrNs == NULL) + { + ouAttrName = rtl::OUString(RTL_UTF8_USTRINGPARAM( (sal_Char*)pAttrName )); + } + else + { + ouAttrName = rtl::OUString(RTL_UTF8_USTRINGPARAM( (sal_Char*)pAttrNs->prefix)) + +rtl::OUString(RTL_UTF8_USTRINGPARAM( (sal_Char*)":" )) + +rtl::OUString(RTL_UTF8_USTRINGPARAM( (sal_Char*)pAttrName )); + } + + pAttributeList->AddAttribute( + ouAttrName, + rtl::OUString(RTL_UTF8_USTRINGPARAM( (sal_Char*)(pAttr->children->content)))); + pAttr = pAttr->next; + } + + rtl::OString sNodeName = getNodeQName(pNode); + + if (xHandler.is()) + { + xHandler->startElement( + rtl::OUString(RTL_UTF8_USTRINGPARAM ( ((sal_Char*)(sNodeName.getStr())) )), + xAttrList); + } + + xHandler2->startElement( + rtl::OUString(RTL_UTF8_USTRINGPARAM ( ((sal_Char*)(sNodeName.getStr())) )), + xAttrList); +} + +void XMLDocumentWrapper_XmlSecImpl::sendEndElement( + const cssu::Reference< cssxs::XDocumentHandler >& xHandler, + const cssu::Reference< cssxs::XDocumentHandler >& xHandler2, + const xmlNodePtr pNode) const + throw (cssxs::SAXException) +/****** XMLDocumentWrapper_XmlSecImpl/sendEndElement ************************** + * + * NAME + * sendEndElement -- Constructs a endElement SAX event + * + * SYNOPSIS + * sendEndElement(xHandler, xHandler2, pNode); + * + * FUNCTION + * Used when converting the document into SAX event stream. + * This method constructs a endElement SAX event for a particular + * element, then calls the endElement methods of the XDocumentHandlers. + * + * INPUTS + * xHandler - the first XDocumentHandler interface to receive the + * endElement SAX event. It can be NULL. + * xHandler2 - the second XDocumentHandler interface to receive the + * endElement SAX event. It can't be NULL. + * pNode - the node on which the endElement should be generated. + * This node must be a element type. + * + * RESULT + * empty + * + * HISTORY + * 05.01.2004 - implemented + * + * AUTHOR + * Michael Mi + * Email: michael.mi@sun.com + ******************************************************************************/ +{ + rtl::OString sNodeName = getNodeQName(pNode); + + if (xHandler.is()) + { + xHandler->endElement(rtl::OUString(RTL_UTF8_USTRINGPARAM ( ((sal_Char*)(sNodeName.getStr())) ))); + } + + xHandler2->endElement(rtl::OUString(RTL_UTF8_USTRINGPARAM ( ((sal_Char*)(sNodeName.getStr())) ))); +} + +void XMLDocumentWrapper_XmlSecImpl::sendNode( + const cssu::Reference< cssxs::XDocumentHandler >& xHandler, + const cssu::Reference< cssxs::XDocumentHandler >& xHandler2, + const xmlNodePtr pNode) const + throw (cssxs::SAXException) +/****** XMLDocumentWrapper_XmlSecImpl/sendNode ******************************** + * + * NAME + * sendNode -- Constructs a characters SAX event or a + * processingInstruction SAX event + * + * SYNOPSIS + * sendNode(xHandler, xHandler2, pNode); + * + * FUNCTION + * Used when converting the document into SAX event stream. + * This method constructs a characters SAX event or a + * processingInstructionfor SAX event based on the type of a particular + * element, then calls the corresponding methods of the XDocumentHandlers. + * + * INPUTS + * xHandler - the first XDocumentHandler interface to receive the + * SAX event. It can be NULL. + * xHandler2 - the second XDocumentHandler interface to receive the + * SAX event. It can't be NULL. + * pNode - the node on which the endElement should be generated. + * If it is a text node, then a characters SAX event is + * generated; if it is a PI node, then a + * processingInstructionfor SAX event is generated. + * + * RESULT + * empty + * + * HISTORY + * 05.01.2004 - implemented + * + * AUTHOR + * Michael Mi + * Email: michael.mi@sun.com + ******************************************************************************/ +{ + xmlElementType type = pNode->type; + + if (type == XML_TEXT_NODE) + { + if (xHandler.is()) + { + xHandler->characters(rtl::OUString(RTL_UTF8_USTRINGPARAM ( ((sal_Char*)(pNode->content)) ))); + } + + xHandler2->characters(rtl::OUString(RTL_UTF8_USTRINGPARAM ( ((sal_Char*)(pNode->content)) ))); + } + else if (type == XML_PI_NODE) + { + if (xHandler.is()) + { + xHandler->processingInstruction( + rtl::OUString(RTL_UTF8_USTRINGPARAM ( ((sal_Char*)(pNode->name)) )), + rtl::OUString(RTL_UTF8_USTRINGPARAM ( ((sal_Char*)(pNode->content)) ))); + } + + xHandler2->processingInstruction( + rtl::OUString(RTL_UTF8_USTRINGPARAM ( ((sal_Char*)(pNode->name)) )), + rtl::OUString(RTL_UTF8_USTRINGPARAM ( ((sal_Char*)(pNode->content)) ))); + } +} + +rtl::OString XMLDocumentWrapper_XmlSecImpl::getNodeQName(const xmlNodePtr pNode) const +/****** XMLDocumentWrapper_XmlSecImpl/getNodeQName **************************** + * + * NAME + * getNodeQName -- Retrives the qualified name of a node + * + * SYNOPSIS + * name = getNodeQName(pNode); + * + * FUNCTION + * see NAME + * + * INPUTS + * pNode - the node whose name will be retrived + * + * RESULT + * name - the node's qualified name + * + * HISTORY + * 05.01.2004 - implemented + * + * AUTHOR + * Michael Mi + * Email: michael.mi@sun.com + ******************************************************************************/ +{ + rtl::OString sNodeName((const sal_Char*)pNode->name); + if (pNode->ns != NULL) + { + xmlNsPtr pNs = pNode->ns; + + if (pNs->prefix != NULL) + { + rtl::OString sPrefix((const sal_Char*)pNs->prefix); + sNodeName = sPrefix+rtl::OString(":")+sNodeName; + } + } + + return sNodeName; +} + +xmlNodePtr XMLDocumentWrapper_XmlSecImpl::checkElement( const cssu::Reference< cssxw::XXMLElementWrapper >& xXMLElement) const +/****** XMLDocumentWrapper_XmlSecImpl/checkElement **************************** + * + * NAME + * checkElement -- Retrives the node wrapped by an XXMLElementWrapper + * interface + * + * SYNOPSIS + * node = checkElement(xXMLElement); + * + * FUNCTION + * see NAME + * + * INPUTS + * xXMLElement - the XXMLElementWrapper interface wraping a node + * + * RESULT + * node - the node wrapped in the XXMLElementWrapper interface + * + * HISTORY + * 05.01.2004 - implemented + * + * AUTHOR + * Michael Mi + * Email: michael.mi@sun.com + ******************************************************************************/ +{ + xmlNodePtr rc = NULL; + + if (xXMLElement.is()) + { + cssu::Reference< cssl::XUnoTunnel > xNodTunnel( xXMLElement, cssu::UNO_QUERY ) ; + if( !xNodTunnel.is() ) + { + throw cssu::RuntimeException() ; + } + + XMLElementWrapper_XmlSecImpl* pElement + = ( XMLElementWrapper_XmlSecImpl* )xNodTunnel->getSomething( + XMLElementWrapper_XmlSecImpl::getUnoTunnelImplementationId() ) ; + + if( pElement == NULL ) { + throw cssu::RuntimeException() ; + } + + rc = pElement->getNativeElement(); + } + + return rc; +} + +sal_Int32 XMLDocumentWrapper_XmlSecImpl::recursiveDelete( + const xmlNodePtr pNode) +/****** XMLDocumentWrapper_XmlSecImpl/recursiveDelete ************************* + * + * NAME + * recursiveDelete -- Deletes a paticular node with its branch. + * + * SYNOPSIS + * result = recursiveDelete(pNode); + * + * FUNCTION + * Deletes a paticular node with its branch, while reserving the nodes + * (and their brance) listed in the m_aReservedNodes. + * The deletion process is preformed in the tree order, that is, a node + * is deleted after its previous sibling node is deleted, a parent node + * is deleted after its branch is deleted. + * During the deletion process when the m_pStopAtNode is reached, the + * progress is interrupted at once. + * + * INPUTS + * pNode - the node to be deleted + * + * RESULT + * result - the result of the deletion process, can be one of following + * values: + * NODE_STOPED - the process is interrupted by meeting the + * m_pStopAtNode + * NODE_NOTREMOVED - the pNode is not completely removed + * because there is its descendant in the + * m_aReservedNodes list + * NODE_REMOVED - the pNode and its branch are completely + * removed + * + * NOTES + * The node in the m_aReservedNodes list must be in the tree order, otherwise + * the result is unpredictable. + * + * HISTORY + * 05.01.2004 - implemented + * + * AUTHOR + * Michael Mi + * Email: michael.mi@sun.com + ******************************************************************************/ +{ + if (pNode == m_pStopAtNode) + { + return NODE_STOPED; + } + + if (pNode != m_pCurrentReservedNode) + { + xmlNodePtr pChild = pNode->children; + + xmlNodePtr pNextSibling; + bool bIsRemoved = true; + sal_Int32 nResult; + + while( pChild != NULL ) + { + pNextSibling = pChild->next; + nResult = recursiveDelete(pChild); + + switch (nResult) + { + case NODE_STOPED: + return NODE_STOPED; + case NODE_NOTREMOVED: + bIsRemoved = false; + break; + case NODE_REMOVED: + removeNode(pChild); + break; + default: + throw cssu::RuntimeException(); + break; + } + + pChild = pNextSibling; + } + + if (pNode == m_pCurrentElement) + { + bIsRemoved = false; + } + + return bIsRemoved?NODE_REMOVED:NODE_NOTREMOVED; + } + else + { + getNextReservedNode(); + return NODE_NOTREMOVED; + } +} + +void XMLDocumentWrapper_XmlSecImpl::getNextReservedNode() +/****** XMLDocumentWrapper_XmlSecImpl/getNextReservedNode ********************* + * + * NAME + * getNextReservedNode -- Highlights the next reserved node in the + * reserved node list + * + * SYNOPSIS + * getNextReservedNode(); + * + * FUNCTION + * The m_aReservedNodes array holds a node list, while the + * m_pCurrentReservedNode points to the one currently highlighted. + * This method is used to highlight the next node in the node list. + * This method is called at the time when the current highlighted node + * has been already processed, and the next node should be ready. + * + * INPUTS + * empty + * + * RESULT + * empty + * + * HISTORY + * 05.01.2004 - implemented + * + * AUTHOR + * Michael Mi + * Email: michael.mi@sun.com + ******************************************************************************/ +{ + if (m_nReservedNodeIndex < m_aReservedNodes.getLength()) + { + m_pCurrentReservedNode = checkElement( m_aReservedNodes[m_nReservedNodeIndex] ); + m_nReservedNodeIndex ++; + } + else + { + m_pCurrentReservedNode = NULL; + } +} + +void XMLDocumentWrapper_XmlSecImpl::removeNode(const xmlNodePtr pNode) const +/****** XMLDocumentWrapper_XmlSecImpl/removeNode ****************************** + * + * NAME + * removeNode -- Deletes a node with its branch unconditionaly + * + * SYNOPSIS + * removeNode( pNode ); + * + * FUNCTION + * Delete the node along with its branch from the document. + * + * INPUTS + * pNode - the node to be deleted + * + * RESULT + * empty + * + * HISTORY + * 05.01.2004 - implemented + * + * AUTHOR + * Michael Mi + * Email: michael.mi@sun.com + ******************************************************************************/ +{ + /* you can't remove the current node */ + OSL_ASSERT( m_pCurrentElement != pNode ); + + xmlAttrPtr pAttr = pNode->properties; + + while (pAttr != NULL) + { + if (!stricmp((sal_Char*)pAttr->name,"id")) + { + xmlRemoveID(m_pDocument, pAttr); + } + + pAttr = pAttr->next; + } + + xmlUnlinkNode(pNode); + xmlFreeNode(pNode); +} + +void XMLDocumentWrapper_XmlSecImpl::buildIDAttr(xmlNodePtr pNode) const +/****** XMLDocumentWrapper_XmlSecImpl/buildIDAttr ***************************** + * + * NAME + * buildIDAttr -- build the ID attribute of a node + * + * SYNOPSIS + * buildIDAttr( pNode ); + * + * FUNCTION + * see NAME + * + * INPUTS + * pNode - the node whose id attribute will be built + * + * RESULT + * empty + * + * HISTORY + * 14.06.2004 - implemented + * + * AUTHOR + * Michael Mi + * Email: michael.mi@sun.com + ******************************************************************************/ +{ + xmlAttrPtr idAttr = xmlHasProp( pNode, (const unsigned char *)"id" ); + if (idAttr == NULL) + { + idAttr = xmlHasProp( pNode, (const unsigned char *)"Id" ); + } + + if (idAttr != NULL) + { + xmlChar* idValue = xmlNodeListGetString( m_pDocument, idAttr->children, 1 ) ; + xmlAddID( NULL, m_pDocument, idValue, idAttr ); + } +} + +void XMLDocumentWrapper_XmlSecImpl::rebuildIDLink(xmlNodePtr pNode) const +/****** XMLDocumentWrapper_XmlSecImpl/rebuildIDLink *************************** + * + * NAME + * rebuildIDLink -- rebuild the ID link for the branch + * + * SYNOPSIS + * rebuildIDLink( pNode ); + * + * FUNCTION + * see NAME + * + * INPUTS + * pNode - the node, from which the branch will be rebuilt + * + * RESULT + * empty + * + * HISTORY + * 14.06.2004 - implemented + * + * AUTHOR + * Michael Mi + * Email: michael.mi@sun.com + ******************************************************************************/ +{ + if (pNode != NULL && pNode->type == XML_ELEMENT_NODE) + { + buildIDAttr( pNode ); + + xmlNodePtr child = pNode->children; + while (child != NULL) + { + rebuildIDLink(child); + child = child->next; + } + } +} + +/* XXMLDocumentWrapper */ +cssu::Reference< cssxw::XXMLElementWrapper > SAL_CALL XMLDocumentWrapper_XmlSecImpl::getCurrentElement( ) + throw (cssu::RuntimeException) +{ + XMLElementWrapper_XmlSecImpl* pElement = new XMLElementWrapper_XmlSecImpl(m_pCurrentElement); + return (cssu::Reference< cssxw::XXMLElementWrapper >)pElement; +} + +void SAL_CALL XMLDocumentWrapper_XmlSecImpl::setCurrentElement( const cssu::Reference< cssxw::XXMLElementWrapper >& element ) + throw (cssu::RuntimeException) +{ + m_pCurrentElement = checkElement( element ); + saxHelper.setCurrentNode( m_pCurrentElement ); +} + +void SAL_CALL XMLDocumentWrapper_XmlSecImpl::removeCurrentElement( ) + throw (cssu::RuntimeException) +{ + OSL_ASSERT( m_pCurrentElement != NULL ); + + xmlNodePtr pOldCurrentElement = m_pCurrentElement; + + /* + * pop the top node in the parser context's + * nodeTab stack, then the parent of that node will + * automatically become the new stack top, and + * the current node as well. + */ + saxHelper.endElement( + rtl::OUString( + RTL_UTF8_USTRINGPARAM ( + (sal_Char*)(pOldCurrentElement->name) + ))); + m_pCurrentElement = saxHelper.getCurrentNode(); + + /* + * remove the node + */ + removeNode(pOldCurrentElement); +} + +sal_Bool SAL_CALL XMLDocumentWrapper_XmlSecImpl::isCurrent( const cssu::Reference< cssxw::XXMLElementWrapper >& node ) + throw (cssu::RuntimeException) +{ + xmlNodePtr pNode = checkElement(node); + return (pNode == m_pCurrentElement); +} + +sal_Bool SAL_CALL XMLDocumentWrapper_XmlSecImpl::isCurrentElementEmpty( ) + throw (cssu::RuntimeException) +{ + sal_Bool rc = sal_False; + + if (m_pCurrentElement->children == NULL) + { + rc = sal_True; + } + + return rc; +} + +rtl::OUString SAL_CALL XMLDocumentWrapper_XmlSecImpl::getNodeName( const cssu::Reference< cssxw::XXMLElementWrapper >& node ) + throw (cssu::RuntimeException) +{ + xmlNodePtr pNode = checkElement(node); + return rtl::OUString(RTL_UTF8_USTRINGPARAM ( (sal_Char*)pNode->name )); +} + +void SAL_CALL XMLDocumentWrapper_XmlSecImpl::clearUselessData( + const cssu::Reference< cssxw::XXMLElementWrapper >& node, + const cssu::Sequence< cssu::Reference< cssxw::XXMLElementWrapper > >& reservedDescendants, + const cssu::Reference< cssxw::XXMLElementWrapper >& stopAtNode ) + throw (cssu::RuntimeException) +{ + xmlNodePtr pTargetNode = checkElement(node); + + m_pStopAtNode = checkElement(stopAtNode); + m_aReservedNodes = reservedDescendants; + m_nReservedNodeIndex = 0; + + getNextReservedNode(); + + recursiveDelete(pTargetNode); +} + +void SAL_CALL XMLDocumentWrapper_XmlSecImpl::collapse( const cssu::Reference< cssxw::XXMLElementWrapper >& node ) + throw (cssu::RuntimeException) +{ + xmlNodePtr pTargetNode = checkElement(node); + xmlNodePtr pParent; + + while (pTargetNode != NULL) + { + if (pTargetNode->children != NULL || pTargetNode == m_pCurrentElement) + { + break; + } + + pParent = pTargetNode->parent; + removeNode(pTargetNode); + pTargetNode = pParent; + } +} + +void SAL_CALL XMLDocumentWrapper_XmlSecImpl::getTree( const cssu::Reference< cssxs::XDocumentHandler >& handler ) + throw (cssxs::SAXException, cssu::RuntimeException) +{ + if (m_pRootElement != NULL) + { + xmlNodePtr pTempCurrentElement = m_pCurrentElement; + sal_Int32 nTempCurrentPosition = m_nCurrentPosition; + + m_pCurrentElement = m_pRootElement; + + m_nCurrentPosition = NODEPOSITION_STARTELEMENT; + cssu::Reference< cssxs::XDocumentHandler > xHandler = handler; + + while(true) + { + switch (m_nCurrentPosition) + { + case NODEPOSITION_STARTELEMENT: + sendStartElement(NULL, xHandler, m_pCurrentElement); + break; + case NODEPOSITION_ENDELEMENT: + sendEndElement(NULL, xHandler, m_pCurrentElement); + break; + case NODEPOSITION_NORMAL: + sendNode(NULL, xHandler, m_pCurrentElement); + break; + } + + if ( (m_pCurrentElement == m_pRootElement) && (m_nCurrentPosition == NODEPOSITION_ENDELEMENT )) + { + break; + } + + getNextSAXEvent(); + } + + m_pCurrentElement = pTempCurrentElement; + m_nCurrentPosition = nTempCurrentPosition; + } +} + +void SAL_CALL XMLDocumentWrapper_XmlSecImpl::generateSAXEvents( + const cssu::Reference< cssxs::XDocumentHandler >& handler, + const cssu::Reference< cssxs::XDocumentHandler >& xEventKeeperHandler, + const cssu::Reference< cssxw::XXMLElementWrapper >& startNode, + const cssu::Reference< cssxw::XXMLElementWrapper >& endNode ) + throw (cssxs::SAXException, cssu::RuntimeException) +{ + /* + * The first SAX event is the startElement of the startNode + * element. + */ + bool bHasCurrentElementChild = (m_pCurrentElement->children != NULL); + + xmlNodePtr pTempCurrentElement = m_pCurrentElement; + + m_pCurrentElement = checkElement(startNode); + + if (m_pCurrentElement->type == XML_ELEMENT_NODE) + { + m_nCurrentPosition = NODEPOSITION_STARTELEMENT; + } + else + { + m_nCurrentPosition = NODEPOSITION_NORMAL; + } + + xmlNodePtr pEndNode = checkElement(endNode); + + cssu::Reference < cssxc::sax::XSAXEventKeeper > xSAXEventKeeper( xEventKeeperHandler, cssu::UNO_QUERY ); + + cssu::Reference< cssxs::XDocumentHandler > xHandler = handler; + + while(true) + { + switch (m_nCurrentPosition) + { + case NODEPOSITION_STARTELEMENT: + sendStartElement(xHandler, xEventKeeperHandler, m_pCurrentElement); + break; + case NODEPOSITION_ENDELEMENT: + sendEndElement(xHandler, xEventKeeperHandler, m_pCurrentElement); + break; + case NODEPOSITION_NORMAL: + sendNode(xHandler, xEventKeeperHandler, m_pCurrentElement); + break; + default: + throw cssu::RuntimeException(); + break; + } + + if (xSAXEventKeeper->isBlocking()) + { + xHandler = NULL; + } + + if (pEndNode == NULL && + ((bHasCurrentElementChild && m_pCurrentElement == xmlGetLastChild(pTempCurrentElement) && m_nCurrentPosition != NODEPOSITION_STARTELEMENT) || + (!bHasCurrentElementChild && m_pCurrentElement == pTempCurrentElement && m_nCurrentPosition == NODEPOSITION_STARTELEMENT))) + { + break; + } + + getNextSAXEvent(); + + /* + * If there is an end point specified, then check whether + * the current node equals to the end point. If so, stop + * generating. + */ + if (pEndNode != NULL && m_pCurrentElement == pEndNode) + { + break; + } + } + + m_pCurrentElement = pTempCurrentElement; +} + +void SAL_CALL XMLDocumentWrapper_XmlSecImpl::rebuildIDLink( + const com::sun::star::uno::Reference< com::sun::star::xml::wrapper::XXMLElementWrapper >& node ) + throw (com::sun::star::uno::RuntimeException) +{ + xmlNodePtr pNode = checkElement( node ); + rebuildIDLink(pNode); +} + + +/* cssxs::XDocumentHandler */ +void SAL_CALL XMLDocumentWrapper_XmlSecImpl::startDocument( ) + throw (cssxs::SAXException, cssu::RuntimeException) +{ +} + +void SAL_CALL XMLDocumentWrapper_XmlSecImpl::endDocument( ) + throw (cssxs::SAXException, cssu::RuntimeException) +{ +} + +void SAL_CALL XMLDocumentWrapper_XmlSecImpl::startElement( const rtl::OUString& aName, const cssu::Reference< cssxs::XAttributeList >& xAttribs ) + throw (cssxs::SAXException, cssu::RuntimeException) +{ + sal_Int32 nLength = xAttribs->getLength(); + cssu::Sequence< cssxcsax::XMLAttribute > aAttributes (nLength); + + for (int i = 0; i < nLength; ++i) + { + aAttributes[i].sName = xAttribs->getNameByIndex((short)i); + aAttributes[i].sValue =xAttribs->getValueByIndex((short)i); + } + + _startElement(aName, aAttributes); +} + +void SAL_CALL XMLDocumentWrapper_XmlSecImpl::endElement( const rtl::OUString& aName ) + throw (cssxs::SAXException, cssu::RuntimeException) +{ + saxHelper.endElement(aName); + m_pCurrentElement = saxHelper.getCurrentNode(); +} + +void SAL_CALL XMLDocumentWrapper_XmlSecImpl::characters( const rtl::OUString& aChars ) + throw (cssxs::SAXException, cssu::RuntimeException) +{ + saxHelper.characters(aChars); +} + +void SAL_CALL XMLDocumentWrapper_XmlSecImpl::ignorableWhitespace( const rtl::OUString& aWhitespaces ) + throw (cssxs::SAXException, cssu::RuntimeException) +{ + saxHelper.ignorableWhitespace(aWhitespaces); +} + +void SAL_CALL XMLDocumentWrapper_XmlSecImpl::processingInstruction( const rtl::OUString& aTarget, const rtl::OUString& aData ) + throw (cssxs::SAXException, cssu::RuntimeException) +{ + saxHelper.processingInstruction(aTarget, aData); +} + +void SAL_CALL XMLDocumentWrapper_XmlSecImpl::setDocumentLocator( const cssu::Reference< cssxs::XLocator >& xLocator ) + throw (cssxs::SAXException, cssu::RuntimeException) +{ + saxHelper.setDocumentLocator(xLocator); +} + +/* XCompressedDocumentHandler */ +void SAL_CALL XMLDocumentWrapper_XmlSecImpl::_startDocument( ) + throw (cssxs::SAXException, cssu::RuntimeException) +{ +} + +void SAL_CALL XMLDocumentWrapper_XmlSecImpl::_endDocument( ) + throw (cssxs::SAXException, cssu::RuntimeException) +{ +} + +void SAL_CALL XMLDocumentWrapper_XmlSecImpl::_startElement( const rtl::OUString& aName, const cssu::Sequence< cssxcsax::XMLAttribute >& aAttributes ) + throw (cssxs::SAXException, cssu::RuntimeException) +{ + saxHelper.startElement(aName, aAttributes); + m_pCurrentElement = saxHelper.getCurrentNode(); + + buildIDAttr( m_pCurrentElement ); +} + +void SAL_CALL XMLDocumentWrapper_XmlSecImpl::_endElement( const rtl::OUString& aName ) + throw (cssxs::SAXException, cssu::RuntimeException) +{ + endElement( aName ); +} + +void SAL_CALL XMLDocumentWrapper_XmlSecImpl::_characters( const rtl::OUString& aChars ) + throw (cssxs::SAXException, cssu::RuntimeException) +{ + characters( aChars ); +} + +void SAL_CALL XMLDocumentWrapper_XmlSecImpl::_ignorableWhitespace( const rtl::OUString& aWhitespaces ) + throw (cssxs::SAXException, cssu::RuntimeException) +{ + ignorableWhitespace( aWhitespaces ); +} + +void SAL_CALL XMLDocumentWrapper_XmlSecImpl::_processingInstruction( const rtl::OUString& aTarget, const rtl::OUString& aData ) + throw (cssxs::SAXException, cssu::RuntimeException) +{ + processingInstruction( aTarget, aData ); +} + +void SAL_CALL XMLDocumentWrapper_XmlSecImpl::_setDocumentLocator( sal_Int32 columnNumber, sal_Int32 lineNumber, const rtl::OUString& publicId, const rtl::OUString& systemId ) + throw (cssxs::SAXException, cssu::RuntimeException) +{ +} + +rtl::OUString XMLDocumentWrapper_XmlSecImpl_getImplementationName () + throw (cssu::RuntimeException) +{ + return rtl::OUString ( RTL_ASCII_USTRINGPARAM ( IMPLEMENTATION_NAME ) ); +} + +sal_Bool SAL_CALL XMLDocumentWrapper_XmlSecImpl_supportsService( const rtl::OUString& ServiceName ) + throw (cssu::RuntimeException) +{ + return ServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( SERVICE_NAME )); +} + +cssu::Sequence< rtl::OUString > SAL_CALL XMLDocumentWrapper_XmlSecImpl_getSupportedServiceNames( ) + throw (cssu::RuntimeException) +{ + cssu::Sequence < rtl::OUString > aRet(1); + rtl::OUString* pArray = aRet.getArray(); + pArray[0] = rtl::OUString ( RTL_ASCII_USTRINGPARAM ( SERVICE_NAME ) ); + return aRet; +} +#undef SERVICE_NAME + +cssu::Reference< cssu::XInterface > SAL_CALL XMLDocumentWrapper_XmlSecImpl_createInstance( + const cssu::Reference< cssl::XMultiServiceFactory > & rSMgr) + throw( cssu::Exception ) +{ + return (cppu::OWeakObject*) new XMLDocumentWrapper_XmlSecImpl( ); +} + +/* XServiceInfo */ +rtl::OUString SAL_CALL XMLDocumentWrapper_XmlSecImpl::getImplementationName( ) + throw (cssu::RuntimeException) +{ + return XMLDocumentWrapper_XmlSecImpl_getImplementationName(); +} +sal_Bool SAL_CALL XMLDocumentWrapper_XmlSecImpl::supportsService( const rtl::OUString& rServiceName ) + throw (cssu::RuntimeException) +{ + return XMLDocumentWrapper_XmlSecImpl_supportsService( rServiceName ); +} +cssu::Sequence< rtl::OUString > SAL_CALL XMLDocumentWrapper_XmlSecImpl::getSupportedServiceNames( ) + throw (cssu::RuntimeException) +{ + return XMLDocumentWrapper_XmlSecImpl_getSupportedServiceNames(); +} + diff --git a/xmlsecurity/source/xmlsec/xmldocumentwrapper_xmlsecimpl.hxx b/xmlsecurity/source/xmlsec/xmldocumentwrapper_xmlsecimpl.hxx new file mode 100644 index 000000000000..8cdbfd1fcdc0 --- /dev/null +++ b/xmlsecurity/source/xmlsec/xmldocumentwrapper_xmlsecimpl.hxx @@ -0,0 +1,328 @@ +/************************************************************************* + * + * $RCSfile: xmldocumentwrapper_xmlsecimpl.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:21 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _XMLDOCUMENTWRAPPER_XMLSECIMPL_HXX +#define _XMLDOCUMENTWRAPPER_XMLSECIMPL_HXX + +#ifndef _COM_SUN_STAR_XML_WRAPPER_XXMLDOCUMENTWRAPPER_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_XML_CSAX_XCOMPRESSEDDOCUMENTHANDLER_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_XML_CRYPTO_SAX_XSAXEVENTKEEPER_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_ +#include +#endif +#ifndef _CPPUHELPER_IMPLBASE4_HXX_ +#include +#endif + +#include "saxhelper.hxx" +//#include "libxml/parserInternals.h" +//#include "libxslt/xslt.h" + +#define NODEPOSITION_NORMAL 1 +#define NODEPOSITION_STARTELEMENT 2 +#define NODEPOSITION_ENDELEMENT 3 + +#include + +class XMLDocumentWrapper_XmlSecImpl : public cppu::WeakImplHelper4 +< + com::sun::star::xml::wrapper::XXMLDocumentWrapper, + com::sun::star::xml::sax::XDocumentHandler, + com::sun::star::xml::csax::XCompressedDocumentHandler, + com::sun::star::lang::XServiceInfo +> +/****** XMLDocumentWrapper_XmlSecImpl.hxx/CLASS XMLDocumentWrapper_XmlSecImpl * + * + * NAME + * XMLDocumentWrapper_XmlSecImpl -- Class to manipulate a libxml2 + * document + * + * FUNCTION + * Converts SAX events into a libxml2 document, converts the document back + * into SAX event stream, and manipulate nodes in the document. + * + * HISTORY + * 05.01.2004 - Interface supported: XXMLDocumentWrapper, + * XDocumentHandler, XCompressedDocumentHandler, + * XServiceInfo + * + * AUTHOR + * Michael Mi + * Email: michael.mi@sun.com + ******************************************************************************/ +{ +private: + /* the sax helper */ + SAXHelper saxHelper; + + /* the document used to convert SAX events to */ + xmlDocPtr m_pDocument; + + /* the root element */ + xmlNodePtr m_pRootElement; + + /* + * the current active element. The next incoming SAX event will be + * appended to this element + */ + xmlNodePtr m_pCurrentElement; + + /* + * This variable is used when converting the document or part of it into + * SAX events. See getNextSAXEvent method. + */ + sal_Int32 m_nCurrentPosition; + + /* + * used for recursive deletion. See recursiveDelete method + */ + xmlNodePtr m_pStopAtNode; + xmlNodePtr m_pCurrentReservedNode; + com::sun::star::uno::Sequence< com::sun::star::uno::Reference< + com::sun::star::xml::wrapper::XXMLElementWrapper > > m_aReservedNodes; + sal_Int32 m_nReservedNodeIndex; + +private: + void getNextSAXEvent(); + + void sendStartElement( + const com::sun::star::uno::Reference< com::sun::star::xml::sax::XDocumentHandler >& xHandler, + const com::sun::star::uno::Reference< com::sun::star::xml::sax::XDocumentHandler >& xHandler2, + const xmlNodePtr pNode) const + throw (com::sun::star::xml::sax::SAXException); + + void sendEndElement( + const com::sun::star::uno::Reference< com::sun::star::xml::sax::XDocumentHandler >& xHandler, + const com::sun::star::uno::Reference< com::sun::star::xml::sax::XDocumentHandler >& xHandler2, + const xmlNodePtr pNode) const + throw (com::sun::star::xml::sax::SAXException); + + void sendNode( + const com::sun::star::uno::Reference< com::sun::star::xml::sax::XDocumentHandler >& xHandler, + const com::sun::star::uno::Reference< com::sun::star::xml::sax::XDocumentHandler >& xHandler2, + const xmlNodePtr pNode) const + throw (com::sun::star::xml::sax::SAXException); + + rtl::OString getNodeQName(const xmlNodePtr pNode) const; + + sal_Int32 recursiveDelete( const xmlNodePtr pNode); + + void getNextReservedNode(); + + void removeNode( const xmlNodePtr pNode) const; + + xmlNodePtr checkElement( + const com::sun::star::uno::Reference< + com::sun::star::xml::wrapper::XXMLElementWrapper >& xXMLElement) const; + + void buildIDAttr( xmlNodePtr pNode ) const; + void rebuildIDLink( xmlNodePtr pNode ) const; + +public: + XMLDocumentWrapper_XmlSecImpl(); + virtual ~XMLDocumentWrapper_XmlSecImpl(); + + /* com::sun::star::xml::wrapper::XXMLDocumentWrapper */ + virtual com::sun::star::uno::Reference< + com::sun::star::xml::wrapper::XXMLElementWrapper > SAL_CALL getCurrentElement( ) + throw (com::sun::star::uno::RuntimeException); + + virtual void SAL_CALL setCurrentElement( const com::sun::star::uno::Reference< + com::sun::star::xml::wrapper::XXMLElementWrapper >& element ) + throw (com::sun::star::uno::RuntimeException); + + virtual void SAL_CALL removeCurrentElement( ) + throw (com::sun::star::uno::RuntimeException); + + virtual sal_Bool SAL_CALL isCurrent( const com::sun::star::uno::Reference< + com::sun::star::xml::wrapper::XXMLElementWrapper >& node ) + throw (com::sun::star::uno::RuntimeException); + + virtual sal_Bool SAL_CALL isCurrentElementEmpty( ) + throw (com::sun::star::uno::RuntimeException); + + virtual rtl::OUString SAL_CALL getNodeName( const com::sun::star::uno::Reference< + com::sun::star::xml::wrapper::XXMLElementWrapper >& node ) + throw (com::sun::star::uno::RuntimeException); + + virtual void SAL_CALL clearUselessData( + const com::sun::star::uno::Reference< + com::sun::star::xml::wrapper::XXMLElementWrapper >& node, + const com::sun::star::uno::Sequence< com::sun::star::uno::Reference< + com::sun::star::xml::wrapper::XXMLElementWrapper > >& reservedDescendants, + const com::sun::star::uno::Reference< + com::sun::star::xml::wrapper::XXMLElementWrapper >& stopAtNode ) + throw (com::sun::star::uno::RuntimeException); + + virtual void SAL_CALL collapse( const com::sun::star::uno::Reference< + com::sun::star::xml::wrapper::XXMLElementWrapper >& node ) + throw (com::sun::star::uno::RuntimeException); + + virtual void SAL_CALL generateSAXEvents( + const com::sun::star::uno::Reference< com::sun::star::xml::sax::XDocumentHandler >& handler, + const com::sun::star::uno::Reference< com::sun::star::xml::sax::XDocumentHandler >& xEventKeeperHandler, + const com::sun::star::uno::Reference< + com::sun::star::xml::wrapper::XXMLElementWrapper >& startNode, + const com::sun::star::uno::Reference< + com::sun::star::xml::wrapper::XXMLElementWrapper >& endNode ) + throw (com::sun::star::xml::sax::SAXException, com::sun::star::uno::RuntimeException); + + virtual void SAL_CALL getTree( + const com::sun::star::uno::Reference< com::sun::star::xml::sax::XDocumentHandler >& handler ) + throw (com::sun::star::xml::sax::SAXException, com::sun::star::uno::RuntimeException); + + virtual void SAL_CALL rebuildIDLink( + const com::sun::star::uno::Reference< com::sun::star::xml::wrapper::XXMLElementWrapper >& node ) + throw (com::sun::star::uno::RuntimeException); + + /* com::sun::star::xml::sax::XDocumentHandler */ + virtual void SAL_CALL startDocument( ) + throw (com::sun::star::xml::sax::SAXException, com::sun::star::uno::RuntimeException); + + virtual void SAL_CALL endDocument( ) + throw (com::sun::star::xml::sax::SAXException, com::sun::star::uno::RuntimeException); + + virtual void SAL_CALL startElement( + const rtl::OUString& aName, + const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList >& xAttribs ) + throw (com::sun::star::xml::sax::SAXException, com::sun::star::uno::RuntimeException); + + virtual void SAL_CALL endElement( const rtl::OUString& aName ) + throw (com::sun::star::xml::sax::SAXException, com::sun::star::uno::RuntimeException); + + virtual void SAL_CALL characters( const rtl::OUString& aChars ) + throw (com::sun::star::xml::sax::SAXException, com::sun::star::uno::RuntimeException); + + virtual void SAL_CALL ignorableWhitespace( const rtl::OUString& aWhitespaces ) + throw (com::sun::star::xml::sax::SAXException, com::sun::star::uno::RuntimeException); + + virtual void SAL_CALL processingInstruction( const rtl::OUString& aTarget, const rtl::OUString& aData ) + throw (com::sun::star::xml::sax::SAXException, com::sun::star::uno::RuntimeException); + + virtual void SAL_CALL setDocumentLocator( const com::sun::star::uno::Reference< com::sun::star::xml::sax::XLocator >& xLocator ) + throw (com::sun::star::xml::sax::SAXException, com::sun::star::uno::RuntimeException); + + /* com::sun::star::xml::csax::XCompressedDocumentHandler */ + virtual void SAL_CALL _startDocument( ) + throw (com::sun::star::xml::sax::SAXException, com::sun::star::uno::RuntimeException); + + virtual void SAL_CALL _endDocument( ) + throw (com::sun::star::xml::sax::SAXException, com::sun::star::uno::RuntimeException); + + virtual void SAL_CALL _startElement( + const rtl::OUString& aName, + const com::sun::star::uno::Sequence< + com::sun::star::xml::csax::XMLAttribute >& aAttributes ) + throw (com::sun::star::xml::sax::SAXException, com::sun::star::uno::RuntimeException); + + virtual void SAL_CALL _endElement( const rtl::OUString& aName ) + throw (com::sun::star::xml::sax::SAXException, com::sun::star::uno::RuntimeException); + + virtual void SAL_CALL _characters( const rtl::OUString& aChars ) + throw (com::sun::star::xml::sax::SAXException, com::sun::star::uno::RuntimeException); + + virtual void SAL_CALL _ignorableWhitespace( const rtl::OUString& aWhitespaces ) + throw (com::sun::star::xml::sax::SAXException, com::sun::star::uno::RuntimeException); + + virtual void SAL_CALL _processingInstruction( const rtl::OUString& aTarget, const rtl::OUString& aData ) + throw (com::sun::star::xml::sax::SAXException, com::sun::star::uno::RuntimeException); + + virtual void SAL_CALL _setDocumentLocator( + sal_Int32 columnNumber, + sal_Int32 lineNumber, + const rtl::OUString& publicId, + const rtl::OUString& systemId ) + throw (com::sun::star::xml::sax::SAXException, com::sun::star::uno::RuntimeException); + + /* com::sun::star::lang::XServiceInfo */ + virtual rtl::OUString SAL_CALL getImplementationName( ) + throw (com::sun::star::uno::RuntimeException); + + virtual sal_Bool SAL_CALL supportsService( const rtl::OUString& ServiceName ) + throw (com::sun::star::uno::RuntimeException); + + virtual com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames( ) + throw (com::sun::star::uno::RuntimeException); +}; + +rtl::OUString XMLDocumentWrapper_XmlSecImpl_getImplementationName() + throw ( com::sun::star::uno::RuntimeException ); + +sal_Bool SAL_CALL XMLDocumentWrapper_XmlSecImpl_supportsService( const rtl::OUString& ServiceName ) + throw ( com::sun::star::uno::RuntimeException ); + +com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL + XMLDocumentWrapper_XmlSecImpl_getSupportedServiceNames( ) + throw ( com::sun::star::uno::RuntimeException ); + +com::sun::star::uno::Reference< com::sun::star::uno::XInterface > +SAL_CALL XMLDocumentWrapper_XmlSecImpl_createInstance( + const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > & rSMgr) + throw ( com::sun::star::uno::Exception ); + +#endif + diff --git a/xmlsecurity/source/xmlsec/xmlelementwrapper_xmlsecimpl.cxx b/xmlsecurity/source/xmlsec/xmlelementwrapper_xmlsecimpl.cxx new file mode 100644 index 000000000000..9b396fed8615 --- /dev/null +++ b/xmlsecurity/source/xmlsec/xmlelementwrapper_xmlsecimpl.cxx @@ -0,0 +1,221 @@ +/************************************************************************* + * + * $RCSfile: xmlelementwrapper_xmlsecimpl.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:21 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#include "xmlelementwrapper_xmlsecimpl.hxx" + +#ifndef _CPPUHELPER_TYPEPROVIDER_HXX_ +#include +#endif + +namespace cssu = com::sun::star::uno; +namespace cssl = com::sun::star::lang; + +#define SERVICE_NAME "com.sun.star.xml.wrapper.XMLElementWrapper" +#define IMPLEMENTATION_NAME "com.sun.star.xml.security.bridge.xmlsec.XMLElementWrapper_XmlSecImpl" + +XMLElementWrapper_XmlSecImpl::XMLElementWrapper_XmlSecImpl(const xmlNodePtr pNode) + : m_pElement( pNode ) +{ +} + +/* XXMLElementWrapper */ + + +/* XUnoTunnel */ +cssu::Sequence< sal_Int8 > XMLElementWrapper_XmlSecImpl::getUnoTunnelImplementationId( void ) + throw (cssu::RuntimeException) +{ + static ::cppu::OImplementationId* pId = 0; + if (! pId) + { + ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); + if (! pId) + { + static ::cppu::OImplementationId aId; + pId = &aId; + } + } + return pId->getImplementationId(); +} + +sal_Int64 SAL_CALL XMLElementWrapper_XmlSecImpl::getSomething( const cssu::Sequence< sal_Int8 >& aIdentifier ) + throw (cssu::RuntimeException) +{ + if (aIdentifier.getLength() == 16 && + 0 == rtl_compareMemory( + getUnoTunnelImplementationId().getConstArray(), + aIdentifier.getConstArray(), + 16 )) + { + return reinterpret_cast < sal_Int64 > ( this ); + } + else + { + return 0; + } +} + + +rtl::OUString XMLElementWrapper_XmlSecImpl_getImplementationName () + throw (cssu::RuntimeException) +{ + return rtl::OUString ( RTL_CONSTASCII_USTRINGPARAM ( IMPLEMENTATION_NAME ) ); +} + +sal_Bool SAL_CALL XMLElementWrapper_XmlSecImpl_supportsService( const rtl::OUString& ServiceName ) + throw (cssu::RuntimeException) +{ + return ServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( SERVICE_NAME )); +} + +cssu::Sequence< rtl::OUString > SAL_CALL XMLElementWrapper_XmlSecImpl_getSupportedServiceNames( ) + throw (cssu::RuntimeException) +{ + cssu::Sequence < rtl::OUString > aRet(1); + rtl::OUString* pArray = aRet.getArray(); + pArray[0] = rtl::OUString ( RTL_CONSTASCII_USTRINGPARAM ( SERVICE_NAME ) ); + return aRet; +} +#undef SERVICE_NAME + +cssu::Reference< cssu::XInterface > SAL_CALL + XMLElementWrapper_XmlSecImpl_createInstance( + const cssu::Reference< cssl::XMultiServiceFactory > & rSMgr) + throw( cssu::Exception ) +{ + return (cppu::OWeakObject*) new XMLElementWrapper_XmlSecImpl(NULL); +} + +/* XServiceInfo */ +rtl::OUString SAL_CALL XMLElementWrapper_XmlSecImpl::getImplementationName( ) + throw (cssu::RuntimeException) +{ + return XMLElementWrapper_XmlSecImpl_getImplementationName(); +} +sal_Bool SAL_CALL XMLElementWrapper_XmlSecImpl::supportsService( const rtl::OUString& rServiceName ) + throw (cssu::RuntimeException) +{ + return XMLElementWrapper_XmlSecImpl_supportsService( rServiceName ); +} +cssu::Sequence< rtl::OUString > SAL_CALL XMLElementWrapper_XmlSecImpl::getSupportedServiceNames( ) + throw (cssu::RuntimeException) +{ + return XMLElementWrapper_XmlSecImpl_getSupportedServiceNames(); +} + +xmlNodePtr XMLElementWrapper_XmlSecImpl::getNativeElement( ) const +/****** XMLElementWrapper_XmlSecImpl/getNativeElement ************************* + * + * NAME + * getNativeElement -- Retrieves the libxml2 node wrapped by this object + * + * SYNOPSIS + * pNode = getNativeElement(); + * + * FUNCTION + * see NAME + * + * INPUTS + * empty + * + * RESULT + * pNode - the libxml2 node wrapped by this object + * + * HISTORY + * 05.01.2004 - implemented + * + * AUTHOR + * Michael Mi + * Email: michael.mi@sun.com + ******************************************************************************/ +{ + return m_pElement; +} + +void XMLElementWrapper_XmlSecImpl::setNativeElement(const xmlNodePtr pNode) +/****** XMLElementWrapper_XmlSecImpl/setNativeElement ************************* + * + * NAME + * setNativeElement -- Configures the libxml2 node wrapped by this object + * + * SYNOPSIS + * setNativeElement( pNode ); + * + * FUNCTION + * see NAME + * + * INPUTS + * pNode - the new libxml2 node to be wrapped by this object + * + * RESULT + * empty + * + * HISTORY + * 05.01.2004 - implemented + * + * AUTHOR + * Michael Mi + * Email: michael.mi@sun.com + ******************************************************************************/ +{ + m_pElement = pNode; +} + diff --git a/xmlsecurity/source/xmlsec/xmlelementwrapper_xmlsecimpl.hxx b/xmlsecurity/source/xmlsec/xmlelementwrapper_xmlsecimpl.hxx new file mode 100644 index 000000000000..d9d614d07136 --- /dev/null +++ b/xmlsecurity/source/xmlsec/xmlelementwrapper_xmlsecimpl.hxx @@ -0,0 +1,152 @@ +/************************************************************************* + * + * $RCSfile: xmlelementwrapper_xmlsecimpl.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:21 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _XMLELEMENTWRAPPER_XMLSECIMPL_HXX +#define _XMLELEMENTWRAPPER_XMLSECIMPL_HXX + +#ifndef _COM_SUN_STAR_XML_WRAPPER_XXMLELEMENTWRAPPER_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_LANG_XUNOTUNNEL_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_LANG_XINITIALIZATION_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_ +#include +#endif +#ifndef _CPPUHELPER_IMPLBASE3_HXX_ +#include +#endif + +#include + +class XMLElementWrapper_XmlSecImpl : public cppu::WeakImplHelper3 +< + com::sun::star::xml::wrapper::XXMLElementWrapper, + com::sun::star::lang::XUnoTunnel, + com::sun::star::lang::XServiceInfo +> +/****** XMLElementWrapper_XmlSecImpl.hxx/CLASS XMLElementWrapper_XmlSecImpl *** + * + * NAME + * XMLElementWrapper_XmlSecImpl -- Class to wrap a libxml2 node + * + * FUNCTION + * Used as a wrapper class to transfer a libxml2 node structure + * between different UNO components. + * + * HISTORY + * 05.01.2004 - Interface supported: XXMLElementWrapper, XUnoTunnel + * XServiceInfo + * + * AUTHOR + * Michael Mi + * Email: michael.mi@sun.com + ******************************************************************************/ +{ +private: + /* the libxml2 node wrapped by this object */ + xmlNodePtr m_pElement; + +public: + explicit XMLElementWrapper_XmlSecImpl(const xmlNodePtr pNode); + virtual ~XMLElementWrapper_XmlSecImpl() {}; + + /* XXMLElementWrapper */ + + /* com::sun::star::lang::XUnoTunnel */ + virtual sal_Int64 SAL_CALL getSomething( const com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) + throw (com::sun::star::uno::RuntimeException); + static com::sun::star::uno::Sequence < sal_Int8 > getUnoTunnelImplementationId( void ) + throw(com::sun::star::uno::RuntimeException); + + /* com::sun::star::lang::XServiceInfo */ + virtual rtl::OUString SAL_CALL getImplementationName( ) + throw (com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsService( const rtl::OUString& ServiceName ) + throw (com::sun::star::uno::RuntimeException); + virtual com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames( ) + throw (com::sun::star::uno::RuntimeException); + +public: + xmlNodePtr getNativeElement( ) const; + void setNativeElement(const xmlNodePtr pNode); +}; + +rtl::OUString XMLElementWrapper_XmlSecImpl_getImplementationName() + throw ( com::sun::star::uno::RuntimeException ); + +sal_Bool SAL_CALL XMLElementWrapper_XmlSecImpl_supportsService( const rtl::OUString& ServiceName ) + throw ( com::sun::star::uno::RuntimeException ); + +com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL XMLElementWrapper_XmlSecImpl_getSupportedServiceNames( ) + throw ( com::sun::star::uno::RuntimeException ); + +com::sun::star::uno::Reference< com::sun::star::uno::XInterface > +SAL_CALL XMLElementWrapper_XmlSecImpl_createInstance( + const com::sun::star::uno::Reference< + com::sun::star::lang::XMultiServiceFactory > & rSMgr) + throw ( com::sun::star::uno::Exception ); + +#endif + diff --git a/xmlsecurity/source/xmlsec/xmlstreamio.cxx b/xmlsecurity/source/xmlsec/xmlstreamio.cxx new file mode 100644 index 000000000000..e11355f6103e --- /dev/null +++ b/xmlsecurity/source/xmlsec/xmlstreamio.cxx @@ -0,0 +1,244 @@ +/************************************************************************* + * + * $RCSfile: xmlstreamio.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:21 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +/* + * Implementation of the I/O interfaces based on stream and URI binding + */ +#ifndef _XMLSTREAMIO_XMLSECIMPL_HXX_ +#include "xmlstreamio.hxx" +#endif + +#ifndef _RTL_USTRING_HXX_ +#include +#endif + +#include +#include + +#define XMLSTREAMIO_INITIALIZED 0x01 +#define XMLSTREAMIO_REGISTERED 0x02 + +/* Global variables */ +/*- + * Enable stream I/O or not. + */ +static char enableXmlStreamIO = 0x00 ; + +::com::sun::star::uno::Reference< ::com::sun::star::xml::crypto::XUriBinding > m_xUriBinding ; + +int xmlStreamMatch( const char* uri ) +{ + ::com::sun::star::uno::Reference< com::sun::star::io::XInputStream > xInputStream ; + + if( ( enableXmlStreamIO & XMLSTREAMIO_INITIALIZED ) && + ( enableXmlStreamIO & XMLSTREAMIO_REGISTERED ) ) { + if( uri == NULL || !m_xUriBinding.is() ) + return 0 ; + + xInputStream = m_xUriBinding->getUriBinding( ::rtl::OUString::createFromAscii( uri ) ) ; + if( xInputStream.is() ) + return 1 ; + } + + return 0 ; +} + +void* xmlStreamOpen( const char* uri ) +{ + ::com::sun::star::uno::Reference< com::sun::star::io::XInputStream > xInputStream ; + ::com::sun::star::io::XInputStream* pInputStream ; + + if( ( enableXmlStreamIO & XMLSTREAMIO_INITIALIZED ) && + ( enableXmlStreamIO & XMLSTREAMIO_REGISTERED ) ) { + if( uri == NULL || !m_xUriBinding.is() ) + return NULL ; + + xInputStream = m_xUriBinding->getUriBinding( ::rtl::OUString::createFromAscii( uri ) ) ; + if( xInputStream.is() ) { + pInputStream = xInputStream.get() ; + pInputStream->acquire() ; + return ( void* )pInputStream ; + } + } + + return NULL ; +} + +int xmlStreamRead( void* context, char* buffer, int len ) +{ + int numbers ; + ::com::sun::star::uno::Reference< com::sun::star::io::XInputStream > xInputStream ; + ::com::sun::star::uno::Sequence< sal_Int8 > outSeqs( len ) ; + + numbers = 0 ; + if( ( enableXmlStreamIO & XMLSTREAMIO_INITIALIZED ) && + ( enableXmlStreamIO & XMLSTREAMIO_REGISTERED ) ) { + if( context != NULL ) { + xInputStream = ( com::sun::star::io::XInputStream* )context ; + if( !xInputStream.is() ) + return 0 ; + + numbers = xInputStream->readBytes( outSeqs, len ) ; + const sal_Int8* readBytes = ( const sal_Int8* )outSeqs.getArray() ; + for( int i = 0 ; i < numbers ; i ++ ) + *( buffer + i ) = *( readBytes + i ) ; + } + } + + return numbers ; +} + +int xmlStreamClose( void * context ) +{ + ::com::sun::star::io::XInputStream* pInputStream ; + + if( ( enableXmlStreamIO & XMLSTREAMIO_INITIALIZED ) && + ( enableXmlStreamIO & XMLSTREAMIO_REGISTERED ) ) { + if( context != NULL ) { + pInputStream = ( ::com::sun::star::io::XInputStream* )context ; + pInputStream->release() ; + } + } + + return 0 ; +} + +int xmlEnableStreamInputCallbacks() +{ + int cbs = 0 ; + + if( !( enableXmlStreamIO & XMLSTREAMIO_INITIALIZED ) ) { + //Register the callbacks into libxml2 + //cbs = xmlRegisterInputCallbacks( + // xmlStreamMatch, + // xmlStreamOpen, + // xmlStreamRead, + // xmlStreamClose ) ; + //if( cbs < 0 ) { + // return -1 ; + //} + + //Register the callbacks into xmlSec + //In order to make the xmlsec io finding the callbacks firstly, + //I put the callbacks at the very begining. + + //Cleanup the older callbacks. + //Notes: all none default callbacks will lose. + xmlSecIOCleanupCallbacks() ; + + //Register my classbacks. + cbs = xmlSecIORegisterCallbacks( + xmlStreamMatch, + xmlStreamOpen, + xmlStreamRead, + xmlStreamClose ) ; + if( cbs < 0 ) { + return -1 ; + } + + //Register the default callbacks. + //Notes: the error will cause xmlsec working problems. + cbs = xmlSecIORegisterDefaultCallbacks() ; + if( cbs < 0 ) { + return -1 ; + } + + enableXmlStreamIO |= XMLSTREAMIO_INITIALIZED ; + } + + return 0 ; +} + +int xmlRegisterStreamInputCallbacks( + ::com::sun::star::uno::Reference< ::com::sun::star::xml::crypto::XUriBinding >& aUriBinding +) { + if( !( enableXmlStreamIO & XMLSTREAMIO_INITIALIZED ) ) { + if( xmlEnableStreamInputCallbacks() < 0 ) + return -1 ; + } + + if( !( enableXmlStreamIO & XMLSTREAMIO_REGISTERED ) ) { + enableXmlStreamIO |= XMLSTREAMIO_REGISTERED ; + } + + m_xUriBinding = aUriBinding ; + + return 0 ; +} + +int xmlUnregisterStreamInputCallbacks( void ) +{ + if( ( enableXmlStreamIO & XMLSTREAMIO_REGISTERED ) ) { + //Clear the uir-stream binding + m_xUriBinding.clear() ; + + //disable the registered flag + enableXmlStreamIO &= ~XMLSTREAMIO_REGISTERED ; + } + + return 0 ; +} + +void xmlDisableStreamInputCallbacks() { + xmlUnregisterStreamInputCallbacks() ; + enableXmlStreamIO &= ~XMLSTREAMIO_INITIALIZED ; +} + diff --git a/xmlsecurity/source/xmlsec/xmlstreamio.hxx b/xmlsecurity/source/xmlsec/xmlstreamio.hxx new file mode 100644 index 000000000000..bad8162a5b01 --- /dev/null +++ b/xmlsecurity/source/xmlsec/xmlstreamio.hxx @@ -0,0 +1,83 @@ +/************************************************************************* + * + * $RCSfile: xmlstreamio.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:21 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _XMLSTREAMIO_XMLSECIMPL_HXX_ +#define _XMLSTREAMIO_XMLSECIMPL_HXX_ + +#ifndef _COM_SUN_STAR_UNO_REFERENCE_HPP_ +#include +#endif + +#ifndef _COM_SUN_STAR_XML_CRYPTO_XURIBINDING_HPP_ +#include +#endif + +int xmlEnableStreamInputCallbacks( void ) ; +void xmlDisableStreamInputCallbacks( void ) ; + +int xmlRegisterStreamInputCallbacks( + ::com::sun::star::uno::Reference< ::com::sun::star::xml::crypto::XUriBinding >& aUriBinding +) ; + +int xmlUnregisterStreamInputCallbacks( void ) ; + +#endif //_XMLSTREAMIO_XMLSECIMPL_HXX_ + diff --git a/xmlsecurity/source/xmlsec/xsec_xmlsec.cxx b/xmlsecurity/source/xmlsec/xsec_xmlsec.cxx new file mode 100644 index 000000000000..1b96d54ae962 --- /dev/null +++ b/xmlsecurity/source/xmlsec/xsec_xmlsec.cxx @@ -0,0 +1,201 @@ +/************************************************************************* + * + * $RCSfile: xsec_xmlsec.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:21 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#include +#include + +#include +#include +#include + +#ifndef _COM_SUN_STAR_LANG_XSINGLESERVICEFACTORY_HPP_ +#include +#endif + +#include "xmlelementwrapper_xmlsecimpl.hxx" +#include "xmldocumentwrapper_xmlsecimpl.hxx" + +using namespace ::rtl; +using namespace ::cppu; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::registry; + +extern "C" +{ + +#if defined( XMLSEC_CRYPTO_NSS ) +extern sal_Bool nss_component_writeInfo( void*, void* ); +extern void* nss_component_getFactory( const sal_Char*, void*, void* ); +#endif + +#if defined( XMLSEC_CRYPTO_MSCRYPTO ) +extern sal_Bool mscrypt_component_writeInfo( void*, void* ); +extern void* mscrypt_component_getFactory( const sal_Char*, void*, void* ); +#endif + +void SAL_CALL component_getImplementationEnvironment( + const sal_Char ** ppEnvTypeName, uno_Environment ** ppEnv ) +{ + *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; +} + + +sal_Bool SAL_CALL component_writeInfo( void* pServiceManager , void* pRegistryKey ) +{ + sal_Bool result = sal_False; + sal_Int32 i ; + OUString sKeyName ; + Reference< XRegistryKey > xNewKey ; + Sequence< OUString > seqServices ; + Reference< XRegistryKey > xKey( reinterpret_cast< XRegistryKey* >( pRegistryKey ) ) ; + + if( xKey.is() ) { + // try { + // XMLElementWrapper_XmlSecImpl + sKeyName = OUString( RTL_CONSTASCII_USTRINGPARAM( "/" ) ) ; + sKeyName += XMLElementWrapper_XmlSecImpl_getImplementationName() ; + sKeyName += OUString::createFromAscii( "/UNO/SERVICES" ) ; + + xNewKey = xKey->createKey( sKeyName ) ; + if( xNewKey.is() ) { + seqServices = XMLElementWrapper_XmlSecImpl_getSupportedServiceNames() ; + for( i = seqServices.getLength() ; i -- ; ) + xNewKey->createKey( seqServices.getConstArray()[i] ) ; + } + + // XMLDocumentWrapper_XmlSecImpl + sKeyName = OUString( RTL_CONSTASCII_USTRINGPARAM( "/" ) ) ; + sKeyName += XMLDocumentWrapper_XmlSecImpl_getImplementationName() ; + sKeyName += OUString::createFromAscii( "/UNO/SERVICES" ) ; + + xNewKey = xKey->createKey( sKeyName ) ; + if( xNewKey.is() ) { + seqServices = XMLDocumentWrapper_XmlSecImpl_getSupportedServiceNames() ; + for( i = seqServices.getLength() ; i -- ; ) + xNewKey->createKey( seqServices.getConstArray()[i] ) ; + } + +#if defined( XMLSEC_CRYPTO_NSS ) + result = nss_component_writeInfo( pServiceManager, pRegistryKey ) ; + if( !result ) + return sal_False ; +#endif + +#if defined( XMLSEC_CRYPTO_MSCRYPTO ) + result = mscrypt_component_writeInfo( pServiceManager, pRegistryKey ) ; + if( !result ) + return sal_False ; +#endif + + //} catch( InvalidRegistryException & ) { + // //we should not ignore exceptions + // return sal_False ; + //} + } + + return result; +} + +void* SAL_CALL component_getFactory( const sal_Char* pImplName , void* pServiceManager , void* pRegistryKey ) +{ + void* pRet = 0; + Reference< XSingleServiceFactory > xFactory ; + + if( pImplName != NULL && pServiceManager != NULL ) { + if( XMLElementWrapper_XmlSecImpl_getImplementationName().equals( OUString::createFromAscii( pImplName ) ) ) + { + xFactory = Reference< XSingleServiceFactory >( createSingleFactory( + reinterpret_cast< XMultiServiceFactory * >( pServiceManager ), + OUString::createFromAscii( pImplName ), + XMLElementWrapper_XmlSecImpl_createInstance, XMLElementWrapper_XmlSecImpl_getSupportedServiceNames() ) ); + } + else if( XMLDocumentWrapper_XmlSecImpl_getImplementationName().equals( OUString::createFromAscii( pImplName ) ) ) + { + xFactory = Reference< XSingleServiceFactory >( createSingleFactory( + reinterpret_cast< XMultiServiceFactory * >( pServiceManager ), + OUString::createFromAscii( pImplName ), + XMLDocumentWrapper_XmlSecImpl_createInstance, XMLDocumentWrapper_XmlSecImpl_getSupportedServiceNames() ) ); + } + } + + if( xFactory.is() ) { + xFactory->acquire() ; + pRet = xFactory.get() ; + } else { +#if defined( XMLSEC_CRYPTO_NSS ) + pRet = nss_component_getFactory( pImplName, pServiceManager, pRegistryKey ) ; + if( pRet != NULL ) + return pRet ; +#endif + +#if defined( XMLSEC_CRYPTO_MSCRYPTO ) + pRet = mscrypt_component_getFactory( pImplName, pServiceManager, pRegistryKey ) ; + if( pRet != NULL ) + return pRet ; +#endif + } + + return pRet ; +} + +} + diff --git a/xmlsecurity/tools/demo/makefile.mk b/xmlsecurity/tools/demo/makefile.mk new file mode 100644 index 000000000000..83845157c9bc --- /dev/null +++ b/xmlsecurity/tools/demo/makefile.mk @@ -0,0 +1,151 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1.1.1 $ +# +# last change: $Author: mt $ $Date: 2004-07-12 13:15:30 $ +# +# The Contents of this file are made available subject to the terms of +# either of the following licenses +# +# - GNU Lesser General Public License Version 2.1 +# - Sun Industry Standards Source License Version 1.1 +# +# Sun Microsystems Inc., October, 2000 +# +# GNU Lesser General Public License Version 2.1 +# ============================================= +# Copyright 2000 by Sun Microsystems, Inc. +# 901 San Antonio Road, Palo Alto, CA 94303, USA +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License version 2.1, as published by the Free Software Foundation. +# +# This library 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 for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, +# MA 02111-1307 USA +# +# +# Sun Industry Standards Source License Version 1.1 +# ================================================= +# The contents of this file are subject to the Sun Industry Standards +# Source License Version 1.1 (the "License"); You may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at http://www.openoffice.org/license.html. +# +# Software provided under this License is provided on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, +# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, +# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. +# See the License for the specific provisions governing your rights and +# obligations concerning the Software. +# +# The Initial Developer of the Original Code is: Sun Microsystems, Inc. +# +# Copyright: 2000 by Sun Microsystems, Inc. +# +# All Rights Reserved. +# +# Contributor(s): _______________________________________ +# +# +# +#************************************************************************* + +PRJ=..$/.. + +PRJNAME=xmlsecurity +TARGET=demo + +# --- Settings ----------------------------------------------------- + +.INCLUDE : svpre.mk +.INCLUDE : settings.mk +.INCLUDE : sv.mk +.INCLUDE : $(PRJ)$/util$/target.pmk + + +CDEFS += -DXMLSEC_CRYPTO_NSS -DXMLSEC_NO_XSLT + +ENABLE_EXCEPTIONS=TRUE +NO_BSYMBOLIC=TRUE +LIBTARGET=NO + +# --- Files -------------------------------------------------------- + +SHARE_LIBS = \ + $(CPPULIB) \ + $(CPPUHELPERLIB) \ + $(SALLIB) \ + $(UCBHELPERLIB) \ + $(UNOTOOLSLIB) \ + $(TOOLSLIB) \ + $(XMLOFFLIB) + + +.IF "$(GUI)"=="WNT" +SHARE_LIBS+= "ixml2.lib" "nss3.lib" "nspr4.lib" "xmlsec.lib" "xmlsec-nss.lib" "xsecctl.lib" "helper.lib" "xsec_xmlsec.lib" +.ELSE +SHARE_LIBS+= "-lxml2" "-lnss3" "-lnspr4" "-lxmlsec" "-lxmlsec-nss" "-lxsecctl" "-lhelper" "-lxsec_xmlsec" +.ENDIF + +SHARE_OBJS = \ + $(OBJ)$/util.obj + +# +# The 1st application +# +APP1TARGET= signdemo +APP1OBJS= \ + $(SHARE_OBJS) \ + $(OBJ)$/signdemo.obj + +.IF "$(OS)" == "LINUX" +APP1STDLIBS+= -lstdc++ +.ENDIF + +APP1STDLIBS+= \ + $(SHARE_LIBS) + +# +# The 2rd application +# +APP2TARGET= verifydemo +APP2OBJS= \ + $(SHARE_OBJS) \ + $(OBJ)$/verifydemo.obj + +.IF "$(OS)" == "LINUX" +APP2STDLIBS+= -lstdc++ +.ENDIF + +APP2STDLIBS+= \ + $(SHARE_LIBS) + +# +# The 3rd application +# +APP3TARGET= multisigdemo +APP3OBJS= \ + $(SHARE_OBJS) \ + $(OBJ)$/multisigdemo.obj + +.IF "$(OS)" == "LINUX" +APP3STDLIBS+= -lstdc++ +.ENDIF + +APP3STDLIBS+= \ + $(SHARE_LIBS) + +# --- Targets ------------------------------------------------------ + +.INCLUDE : target.mk + diff --git a/xmlsecurity/tools/demo/multisigdemo.cxx b/xmlsecurity/tools/demo/multisigdemo.cxx new file mode 100644 index 000000000000..0396282c7cc1 --- /dev/null +++ b/xmlsecurity/tools/demo/multisigdemo.cxx @@ -0,0 +1,353 @@ +/************************************************************************* + * + * $RCSfile: multisigdemo.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:30 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#include +#include "util.hxx" + +#include +#include +#include +#include +#include + +namespace cssu = com::sun::star::uno; +namespace cssl = com::sun::star::lang; +namespace cssxc = com::sun::star::xml::crypto; +namespace cssi = com::sun::star::io; + +long denyVerifyHandler( void *, void * ) +{ + return 0; +} + +long startVerifyHandler( void *, void * ) +{ + char answer; + fprintf( stdout, + "A signature is found, whether to verify it(y/n)?[y]:" ); + fscanf( stdin, "%c", &answer); + + return (answer == 'n')?0:1; +} + +int SAL_CALL main( int argc, char **argv ) +{ + if( argc != 7 ) + { + fprintf( stderr, "Usage: %s \n" , argv[0] ) ; + return -1 ; + } + + /* + * creates a component factory from local rdb file. + */ + cssu::Reference< cssl::XMultiServiceFactory > xManager = NULL ; + cssu::Reference< cssu::XComponentContext > xContext = NULL ; + try + { + xManager = serviceManager( xContext , rtl::OUString::createFromAscii( "local" ), rtl::OUString::createFromAscii( argv[1] ) ) ; + OSL_ENSURE( xManager.is() , + "ServicesManager - " + "Cannot get service manager" ); + + fprintf( stdout , "xManager created.\n" ) ; + } + catch( cssu::Exception& e ) + { + fprintf( stderr , "Error Message: %s\n" , rtl::OUStringToOString( e.Message , RTL_TEXTENCODING_ASCII_US ).getStr() ) ; + return -1; + } + + rtl::OUString aXMLFileName = rtl::OUString::createFromAscii(argv[3]); + rtl::OUString aBINFileName = rtl::OUString::createFromAscii(argv[4]); + rtl::OUString aSIGFileName = rtl::OUString::createFromAscii(argv[2]); + rtl::OUString aSIGFileName2 = rtl::OUString::createFromAscii(argv[6]); + sal_Int32 nSecurityId; + SvFileStream* pStream; + ULONG nBytes; + SvLockBytesRef xLockBytes; + cssu::Reference< cssi::XOutputStream > xOutputStream; + cssu::Reference< cssi::XInputStream > xInputStream; + bool bDone; + SignatureInformations signatureInformations; + cssu::Reference< ::com::sun::star::xml::sax::XDocumentHandler> xDocumentHandler; + + XMLSignatureHelper aSignatureHelper( xManager ); + + bool bInit = aSignatureHelper.Init( rtl::OUString::createFromAscii(argv[5]) ); + if ( !bInit ) + { + fprintf( stderr, "Error initializing security context!\n" ); + return -1; + } + + fprintf( stdout, "------ Mission 1 : create the first signature file ...\n"); + + aSignatureHelper.StartMission(); + + /* + * select a private key certificate + */ + cssu::Reference< cssxc::XSecurityEnvironment > xSecurityEnvironment = aSignatureHelper.GetSecurityEnvironment(); + cssu::Sequence< cssu::Reference< ::com::sun::star::security::XCertificate > > xPersonalCerts + = xSecurityEnvironment->getPersonalCertificates() ; + + nSecurityId = aSignatureHelper.GetNewSecurityId(); + + /* + * use no.3 certificate to configure the X509 certificate + */ + aSignatureHelper.SetX509Certificate( + nSecurityId, + xPersonalCerts[2]->getIssuerName(), + bigIntegerToNumericString( xPersonalCerts[2]->getSerialNumber())); + + aSignatureHelper.AddForSigning( nSecurityId, aXMLFileName, aXMLFileName, sal_False ); + aSignatureHelper.AddForSigning( nSecurityId, aBINFileName, aBINFileName, sal_True ); + + /* + * creates another signature on the xml stream, use no.4 certificate + */ + nSecurityId = aSignatureHelper.GetNewSecurityId(); + + aSignatureHelper.SetX509Certificate( + nSecurityId, + xPersonalCerts[3]->getIssuerName(), + bigIntegerToNumericString( xPersonalCerts[3]->getSerialNumber())); + aSignatureHelper.AddForSigning( nSecurityId, aXMLFileName, aXMLFileName, sal_False ); + + /* + * creates the output stream + */ + pStream = new SvFileStream( aSIGFileName, STREAM_WRITE ); + xLockBytes = new SvLockBytes( pStream, TRUE ); + xOutputStream = new utl::OOutputStreamHelper( xLockBytes ); + + /* + * creates signature + */ + bDone = aSignatureHelper.CreateAndWriteSignatue( xOutputStream ); + if ( !bDone ) + { + fprintf( stderr, "Error creating Signature!\n" ); + } + else + { + fprintf( stdout, "Signature successfully created!\n" ); + } + + aSignatureHelper.EndMission(); + + + fprintf( stdout, "------ Mission 2 : transfer the second signature to a new signature file ...\n"); + + /* + * You can use an uninitialized SignatureHelper to perform this mission. + */ + + /* + * configures the start-verify handler + */ + aSignatureHelper.SetStartVerifySignatureHdl( Link( NULL, denyVerifyHandler ) ); + aSignatureHelper.StartMission(); + + pStream = new SvFileStream( aSIGFileName, STREAM_READ ); + pStream->Seek( STREAM_SEEK_TO_END ); + nBytes = pStream->Tell(); + pStream->Seek( STREAM_SEEK_TO_BEGIN ); + xLockBytes = new SvLockBytes( pStream, TRUE ); + xInputStream = new utl::OInputStreamHelper( xLockBytes, nBytes ); + + bDone = aSignatureHelper.ReadAndVerifySignatue( xInputStream ); + xInputStream->closeInput(); + + if ( !bDone ) + { + fprintf( stderr, "Error in reading Signature!\n" ); + } + else + { + fprintf( stdout, "Signature successfully transfered!\n" ); + } + + /* + * get all signature information + */ + signatureInformations = aSignatureHelper.GetSignatureInformations(); + + /* + * write the first signature into the second signature file. + */ + pStream = new SvFileStream( aSIGFileName2, STREAM_WRITE ); + xLockBytes = new SvLockBytes( pStream, TRUE ); + xOutputStream = new utl::OOutputStreamHelper( xLockBytes ); + + xDocumentHandler = aSignatureHelper.CreateDocumentHandlerWithHeader( xOutputStream); + + aSignatureHelper.ExportSignature( xDocumentHandler, signatureInformations[1]); + aSignatureHelper.CloseDocumentHandler( xDocumentHandler); + aSignatureHelper.EndMission(); + + fprintf( stdout, "------ Mission 3 : insert a new signature to the first signature file ...\n"); + + aSignatureHelper.StartMission(); + + nSecurityId = aSignatureHelper.GetNewSecurityId(); + + /* + * use no.5 certificate to the new signature + */ + aSignatureHelper.SetX509Certificate( + nSecurityId, + xPersonalCerts[4]->getIssuerName(), + bigIntegerToNumericString( xPersonalCerts[4]->getSerialNumber())); + + aSignatureHelper.AddForSigning( nSecurityId, aBINFileName, aBINFileName, sal_True ); + + pStream = new SvFileStream( aSIGFileName, STREAM_WRITE ); + xLockBytes = new SvLockBytes( pStream, TRUE ); + xOutputStream = new utl::OOutputStreamHelper( xLockBytes ); + + xDocumentHandler = aSignatureHelper.CreateDocumentHandlerWithHeader( xOutputStream); + + aSignatureHelper.ExportSignature( xDocumentHandler, signatureInformations[0]); + bDone = aSignatureHelper.CreateAndWriteSignatue( xDocumentHandler ); + aSignatureHelper.ExportSignature( xDocumentHandler, signatureInformations[1]); + aSignatureHelper.CloseDocumentHandler( xDocumentHandler); + + if ( !bDone ) + { + fprintf( stderr, "Error creating Signature!\n" ); + } + else + { + fprintf( stdout, "Signature successfully created!\n" ); + } + + aSignatureHelper.EndMission(); + + fprintf( stdout, "------ Mission 4 : verify the first signature file ...\n"); + + aSignatureHelper.SetStartVerifySignatureHdl( Link( NULL, startVerifyHandler ) ); + + aSignatureHelper.StartMission(); + + pStream = new SvFileStream( aSIGFileName, STREAM_READ ); + pStream->Seek( STREAM_SEEK_TO_END ); + nBytes = pStream->Tell(); + pStream->Seek( STREAM_SEEK_TO_BEGIN ); + xLockBytes = new SvLockBytes( pStream, TRUE ); + xInputStream = new utl::OInputStreamHelper( xLockBytes, nBytes ); + + bDone = aSignatureHelper.ReadAndVerifySignatue( xInputStream ); + xInputStream->closeInput(); + + if ( !bDone ) + { + fprintf( stderr, "Error in Signature!\n" ); + } + else + { + fprintf( stdout, "Signatures verified without any problems!\n" ); + } + + aSignatureHelper.EndMission(); + + fprintf( stdout, "------------- Signature details -------------\n" ); + fprintf( stdout, "%s", + rtl::OUStringToOString( + getSignatureInformations(aSignatureHelper.GetSignatureInformations(), aSignatureHelper.GetSecurityEnvironment()), + RTL_TEXTENCODING_UTF8).getStr()); + + fprintf( stdout, "------ Mission 5 : verify the second signature file ...\n"); + + aSignatureHelper.StartMission(); + + pStream = new SvFileStream( aSIGFileName2, STREAM_READ ); + pStream->Seek( STREAM_SEEK_TO_END ); + nBytes = pStream->Tell(); + pStream->Seek( STREAM_SEEK_TO_BEGIN ); + xLockBytes = new SvLockBytes( pStream, TRUE ); + xInputStream = new utl::OInputStreamHelper( xLockBytes, nBytes ); + + bDone = aSignatureHelper.ReadAndVerifySignatue( xInputStream ); + xInputStream->closeInput(); + + if ( !bDone ) + { + fprintf( stderr, "Error in Signature!\n" ); + } + else + { + fprintf( stdout, "Signatures verified without any problems!\n" ); + } + + aSignatureHelper.EndMission(); + + fprintf( stdout, "------------- Signature details -------------\n" ); + fprintf( stdout, "%s", + rtl::OUStringToOString( + getSignatureInformations(aSignatureHelper.GetSignatureInformations(), aSignatureHelper.GetSecurityEnvironment()), + RTL_TEXTENCODING_UTF8).getStr()); + + return 0; +} + diff --git a/xmlsecurity/tools/demo/signdemo.cxx b/xmlsecurity/tools/demo/signdemo.cxx new file mode 100644 index 000000000000..908a9b794cdb --- /dev/null +++ b/xmlsecurity/tools/demo/signdemo.cxx @@ -0,0 +1,223 @@ +/************************************************************************* + * + * $RCSfile: signdemo.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:30 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#include +#include "util.hxx" + +#include +#include +#include +#include +#include + +namespace cssu = com::sun::star::uno; +namespace cssl = com::sun::star::lang; +namespace cssxc = com::sun::star::xml::crypto; +namespace cssi = com::sun::star::io; + +int SAL_CALL main( int argc, char **argv ) +{ + if( argc != 6 ) + { + fprintf( stderr, "Usage: %s \n" , argv[0] ) ; + return -1 ; + } + + /* + * creates a component factory from local rdb file. + */ + cssu::Reference< cssl::XMultiServiceFactory > xManager = NULL ; + cssu::Reference< cssu::XComponentContext > xContext = NULL ; + try + { + xManager = serviceManager( xContext , rtl::OUString::createFromAscii( "local" ), rtl::OUString::createFromAscii( argv[1] ) ) ; + OSL_ENSURE( xManager.is() , + "ServicesManager - " + "Cannot get service manager" ); + + fprintf( stdout , "xManager created.\n" ) ; + } + catch( cssu::Exception& e ) + { + fprintf( stderr , "Error Message: %s\n" , rtl::OUStringToOString( e.Message , RTL_TEXTENCODING_ASCII_US ).getStr() ) ; + return -1; + } + + /* + * creates a signature helper + */ + XMLSignatureHelper aSignatureHelper( xManager ); + + /* + * creates a security context. + */ + bool bInit = aSignatureHelper.Init( rtl::OUString::createFromAscii(argv[5]) ); + if ( !bInit ) + { + fprintf( stderr, "Error initializing security context!\n" ); + return -1; + } + + aSignatureHelper.StartMission(); + + /* + * select a private key certificate + */ + cssu::Reference< cssxc::XSecurityEnvironment > xSecurityEnvironment = aSignatureHelper.GetSecurityEnvironment(); + cssu::Sequence< cssu::Reference< ::com::sun::star::security::XCertificate > > xPersonalCerts + = xSecurityEnvironment->getPersonalCertificates() ; + int length = xPersonalCerts.getLength(); + int i; + + fprintf( stdout, "\nSelect a private key certificate for the new signature\n" ) ; + fprintf( stdout, "================================================================================\n" ) ; + for( i = 0; i < length; i ++ ) + { + fprintf( stdout, "%d:issuer=[%s] subject=[%s]\n", + i+1, + rtl::OUStringToOString( xPersonalCerts[i]->getIssuerName(), RTL_TEXTENCODING_ASCII_US ).getStr(), + rtl::OUStringToOString( xPersonalCerts[i]->getSubjectName(), RTL_TEXTENCODING_ASCII_US ).getStr()); + } + + fprintf( stdout, "================================================================================\n" ) ; + bool bInvalid = false; + int sel = 0; + + do + { + if (bInvalid) + { + fprintf( stdout, "Invalid value! " ); + } + + fprintf( stdout, "Select <1-%d>:", length ) ; + fscanf( stdin, "%d", &sel ) ; + bInvalid = true; + }while(sel<1 || sel>length); + + sel--; + + /* + * creates a new signature id + */ + sal_Int32 nSecurityId = aSignatureHelper.GetNewSecurityId(); + + /* + * configures the X509 certificate + */ + aSignatureHelper.SetX509Certificate( + nSecurityId, + xPersonalCerts[sel]->getIssuerName(), + bigIntegerToNumericString( xPersonalCerts[sel]->getSerialNumber())); + + /* + * configures date/time + */ + aSignatureHelper.SetDateTime( + nSecurityId, + rtl::OUString::createFromAscii("2002-07-06"), + rtl::OUString::createFromAscii("15:25:20")); + + /* + * signs the xml stream + */ + rtl::OUString aXMLFileName = rtl::OUString::createFromAscii(argv[3]); + aSignatureHelper.AddForSigning( nSecurityId, aXMLFileName, aXMLFileName, sal_False ); + + /* + * signs the binary stream + */ + rtl::OUString aBINFileName = rtl::OUString::createFromAscii(argv[4]); + aSignatureHelper.AddForSigning( nSecurityId, aBINFileName, aBINFileName, sal_True ); + + /* + * creates the output stream + */ + rtl::OUString aSIGFileName = rtl::OUString::createFromAscii(argv[2]); + SvFileStream* pStream = new SvFileStream( aSIGFileName, STREAM_WRITE ); + SvLockBytesRef xLockBytes = new SvLockBytes( pStream, TRUE ); + cssu::Reference< cssi::XOutputStream > xOutputStream = new utl::OOutputStreamHelper( xLockBytes ); + + /* + * creates signature + */ + bool bDone = aSignatureHelper.CreateAndWriteSignatue( xOutputStream ); + + if ( !bDone ) + { + fprintf( stderr, "Error creating Signature!\n" ); + } + else + { + fprintf( stdout, "Signature successfully created!\n" ); + } + + aSignatureHelper.EndMission(); + + fprintf( stdout, "------------- Signature details -------------\n" ); + fprintf( stdout, "%s", + rtl::OUStringToOString( + getSignatureInformations(aSignatureHelper.GetSignatureInformations(), aSignatureHelper.GetSecurityEnvironment()), + RTL_TEXTENCODING_UTF8).getStr()); + + return 0; +} + diff --git a/xmlsecurity/tools/demo/util.cxx b/xmlsecurity/tools/demo/util.cxx new file mode 100644 index 000000000000..a73179805a5e --- /dev/null +++ b/xmlsecurity/tools/demo/util.cxx @@ -0,0 +1,215 @@ +/************************************************************************* + * + * $RCSfile: util.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:30 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#include "util.hxx" + +#include +#include + +namespace cssu = com::sun::star::uno; +namespace cssl = com::sun::star::lang; + +cssu::Reference< cssl::XMultiServiceFactory > serviceManager( + cssu::Reference< cssu::XComponentContext > &xContext, + rtl::OUString sUnoUrl, + rtl::OUString sRdbUrl ) + throw( cssu::RuntimeException , cssu::Exception ) +{ + cssu::Reference< cssl::XMultiComponentFactory > xLocalServiceManager = NULL ; + cssu::Reference< cssu::XComponentContext > xLocalComponentContext = NULL ; + + cssu::Reference< ::com::sun::star::registry::XSimpleRegistry > xSimpleRegistry + = ::cppu::createSimpleRegistry(); + OSL_ENSURE( xSimpleRegistry.is(), + "serviceManager - " + "Cannot create simple registry" ) ; + + xSimpleRegistry->open(sRdbUrl, sal_True, sal_False); + OSL_ENSURE( xSimpleRegistry->isValid() , + "serviceManager - " + "Cannot open xml security registry rdb" ) ; + + xLocalComponentContext = ::cppu::bootstrap_InitialComponentContext( xSimpleRegistry ) ; + OSL_ENSURE( xLocalComponentContext.is() , + "serviceManager - " + "Cannot create intial component context" ) ; + + xLocalServiceManager = xLocalComponentContext->getServiceManager() ; + OSL_ENSURE( xLocalServiceManager.is() , + "serviceManager - " + "Cannot create intial service manager" ) ; + + xContext = xLocalComponentContext ; + return cssu::Reference< cssl::XMultiServiceFactory >(xLocalServiceManager, cssu::UNO_QUERY) ; +} + +::rtl::OUString getSignatureInformation( + const SignatureInformation& infor, + cssu::Reference< ::com::sun::star::xml::crypto::XSecurityEnvironment >& xSecurityEnvironment ) +{ + char* status[5]={"INIT", "CREATION_SUCCEED", "CREATION_FAIL", "VERIFY_SUCCEED", "VERIFY_FAIL"}; + + rtl::OUString result; + + result += rtl::OUString::createFromAscii( "Security Id : " ) + +rtl::OUString::valueOf(infor.nSecurityId) + +rtl::OUString::createFromAscii( "\n" ); + result += rtl::OUString::createFromAscii( "Status : " ) + +rtl::OUString::createFromAscii( status[infor.nStatus] ) + +rtl::OUString::createFromAscii( "\n" ); + + const SignatureReferenceInformations& rInfors = infor.vSignatureReferenceInfors; + int i; + int size = rInfors.size(); + + result += rtl::OUString::createFromAscii( "--References :\n" ); + for (i=0; i0) + { + result += rtl::OUString::createFromAscii( "--X509IssuerName :\n" ); + result += infor.ouX509IssuerName; + result += rtl::OUString::createFromAscii( "\n" ); + } + + if (infor.ouX509SerialNumber.getLength()>0) + { + result += rtl::OUString::createFromAscii( "--X509SerialNumber :\n" ); + result += infor.ouX509SerialNumber; + result += rtl::OUString::createFromAscii( "\n" ); + } + + if (infor.ouX509Certificate.getLength()>0) + { + result += rtl::OUString::createFromAscii( "--X509Certificate :\n" ); + result += infor.ouX509Certificate; + result += rtl::OUString::createFromAscii( "\n" ); + } + + if (infor.ouSignatureValue.getLength()>0) + { + result += rtl::OUString::createFromAscii( "--SignatureValue :\n" ); + result += infor.ouSignatureValue; + result += rtl::OUString::createFromAscii( "\n" ); + } + + if (infor.ouDate.getLength()>0) + { + result += rtl::OUString::createFromAscii( "--Date :\n" ); + result += infor.ouDate; + result += rtl::OUString::createFromAscii( "\n" ); + } + + if (infor.ouTime.getLength()>0) + { + result += rtl::OUString::createFromAscii( "--Time :\n" ); + result += infor.ouTime; + result += rtl::OUString::createFromAscii( "\n" ); + } + + if (infor.ouX509IssuerName.getLength()>0 && infor.ouX509SerialNumber.getLength()>0 && xSecurityEnvironment.is()) + { + result += rtl::OUString::createFromAscii( "--Certificate Path :\n" ); + cssu::Reference< ::com::sun::star::security::XCertificate > xCert + = xSecurityEnvironment->getCertificate( infor.ouX509IssuerName, numericStringToBigInteger(infor.ouX509SerialNumber) ); + + cssu::Sequence < cssu::Reference< ::com::sun::star::security::XCertificate > > xCertPath + = xSecurityEnvironment->buildCertificatePath( xCert ) ; + + for( int i = 0; i < xCertPath.getLength(); i++ ) + { + result += xCertPath[i]->getSubjectName(); + result += rtl::OUString::createFromAscii( " << " ); + } + + result += rtl::OUString::createFromAscii( "\n" ); + } + + result += rtl::OUString::createFromAscii( "\n" ); + return result; +} + +::rtl::OUString getSignatureInformations( + const SignatureInformations& SignatureInformations, + cssu::Reference< ::com::sun::star::xml::crypto::XSecurityEnvironment >& xSecurityEnvironment ) +{ + rtl::OUString result; + int i; + int size = SignatureInformations.size(); + + for (i=0; i + +#include + +#include +#include + +#include + +#include + +/* + * get service manager and context + */ +::com::sun::star::uno::Reference< + ::com::sun::star::lang::XMultiServiceFactory > + serviceManager( ::com::sun::star::uno::Reference< + ::com::sun::star::uno::XComponentContext > &xContext, + ::rtl::OUString sUnoUrl, + ::rtl::OUString sRdbUrl) + throw( ::com::sun::star::uno::RuntimeException , ::com::sun::star::uno::Exception ); + +::rtl::OUString getSignatureInformations( + const SignatureInformations& SignatureInformations, + ::com::sun::star::uno::Reference< ::drafts::com::sun::star::xml::crypto::XSecurityEnvironment >& xSecurityEnvironment ); + \ No newline at end of file diff --git a/xmlsecurity/tools/demo/verifydemo.cxx b/xmlsecurity/tools/demo/verifydemo.cxx new file mode 100644 index 000000000000..0ba3e65c9d6d --- /dev/null +++ b/xmlsecurity/tools/demo/verifydemo.cxx @@ -0,0 +1,180 @@ +/************************************************************************* + * + * $RCSfile: verifydemo.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:30 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#include +#include "util.hxx" + +#include +#include +#include +#include +#include + +namespace cssu = com::sun::star::uno; +namespace cssl = com::sun::star::lang; +namespace cssxc = com::sun::star::xml::crypto; +namespace cssi = com::sun::star::io; + +long startVerifyHandler( void *, void * ) +{ + char answer; + fprintf( stdout, + "A signature is found, whether to verify it(y/n)?[y]:" ); + fscanf( stdin, "%c", &answer); + + return (answer == 'n')?0:1; +} + +int SAL_CALL main( int argc, char **argv ) +{ + if( argc != 4 ) + { + fprintf( stderr, "Usage: %s \n" , argv[0] ) ; + return -1 ; + } + + /* + * creates a component factory from local rdb file. + */ + cssu::Reference< cssl::XMultiServiceFactory > xManager = NULL ; + cssu::Reference< cssu::XComponentContext > xContext = NULL ; + try + { + xManager = serviceManager( xContext , rtl::OUString::createFromAscii( "local" ), rtl::OUString::createFromAscii( argv[1] ) ) ; + OSL_ENSURE( xManager.is() , + "ServicesManager - " + "Cannot get service manager" ); + + fprintf( stdout , "xManager created.\n" ) ; + } + catch( cssu::Exception& e ) + { + fprintf( stderr , "Error Message: %s\n" , rtl::OUStringToOString( e.Message , RTL_TEXTENCODING_ASCII_US ).getStr() ) ; + return -1; + } + + /* + * creates a signature helper + */ + XMLSignatureHelper aSignatureHelper( xManager ); + + /* + * creates a security context. + */ + bool bInit = aSignatureHelper.Init( rtl::OUString::createFromAscii(argv[3]) ); + if ( !bInit ) + { + fprintf( stderr, "Error initializing security context!" ); + return -1; + } + + /* + * configures the start-verify handler + */ + aSignatureHelper.SetStartVerifySignatureHdl( Link( NULL, startVerifyHandler ) ); + + aSignatureHelper.StartMission(); + + /* + * prepares the signature stream. + */ + rtl::OUString aSIGFileName = rtl::OUString::createFromAscii(argv[2]); + SvFileStream* pStream = new SvFileStream( aSIGFileName, STREAM_READ ); + pStream->Seek( STREAM_SEEK_TO_END ); + ULONG nBytes = pStream->Tell(); + pStream->Seek( STREAM_SEEK_TO_BEGIN ); + SvLockBytesRef xLockBytes = new SvLockBytes( pStream, TRUE ); + + /* + * creates the signature stream. + */ + cssu::Reference< cssi::XInputStream > xInputStream = new utl::OInputStreamHelper( xLockBytes, nBytes ); + + /* + * verifies the signature + */ + bool bDone = aSignatureHelper.ReadAndVerifySignatue( xInputStream ); + + /* + * closes the signature stream + */ + xInputStream->closeInput(); + + if ( !bDone ) + { + fprintf( stderr, "Error in Signature!\n" ); + } + else + { + fprintf( stdout, "Signatures verified without any problems!\n" ); + } + + aSignatureHelper.EndMission(); + + fprintf( stdout, "------------- Signature details -------------\n" ); + fprintf( stdout, "%s", + rtl::OUStringToOString( + getSignatureInformations(aSignatureHelper.GetSignatureInformations(), aSignatureHelper.GetSecurityEnvironment()), + RTL_TEXTENCODING_UTF8).getStr()); + + return 0; +} + diff --git a/xmlsecurity/tools/examples/demo-sample.gif b/xmlsecurity/tools/examples/demo-sample.gif new file mode 100644 index 000000000000..92b2a025f05e Binary files /dev/null and b/xmlsecurity/tools/examples/demo-sample.gif differ diff --git a/xmlsecurity/tools/examples/demo-sample.sxw b/xmlsecurity/tools/examples/demo-sample.sxw new file mode 100644 index 000000000000..dc1472129b71 Binary files /dev/null and b/xmlsecurity/tools/examples/demo-sample.sxw differ diff --git a/xmlsecurity/tools/examples/demo-sample.xml b/xmlsecurity/tools/examples/demo-sample.xml new file mode 100644 index 000000000000..c4c1cd00b7b3 --- /dev/null +++ b/xmlsecurity/tools/examples/demo-sample.xml @@ -0,0 +1,3 @@ + + +abc \ No newline at end of file diff --git a/xmlsecurity/tools/examples/enc-1.xml b/xmlsecurity/tools/examples/enc-1.xml new file mode 100644 index 000000000000..bfd2f11195e8 --- /dev/null +++ b/xmlsecurity/tools/examples/enc-1.xml @@ -0,0 +1,31 @@ + + + + The encrypted data is Hello, World! + + + + + + + + + CN=Test Issuer + 123450001 + + + + + + + + + + + + + Hello, World! + + diff --git a/xmlsecurity/tools/examples/enc-2.xml b/xmlsecurity/tools/examples/enc-2.xml new file mode 100644 index 000000000000..98fc553c0c08 --- /dev/null +++ b/xmlsecurity/tools/examples/enc-2.xml @@ -0,0 +1,58 @@ + + + + The encrypted data is Hello, World! + + + + + + + + + CN=Test Issuer + 123450001 + + + + + + + + + + + + + + Hello, World! + + + + + + + + + CN=Test Issuer + 123450001 + + + + + + + + + + + + + + This is an embeded encryption! + + + + diff --git a/xmlsecurity/tools/examples/eval_export.txt b/xmlsecurity/tools/examples/eval_export.txt new file mode 100644 index 000000000000..ccf8e43b7c34 --- /dev/null +++ b/xmlsecurity/tools/examples/eval_export.txt @@ -0,0 +1,7 @@ +C:\temp-folder\examples\warmup.xml +C:\temp-folder\examples\sign-0.xml +C:\temp-folder\examples\sign-1.xml +C:\temp-folder\examples\sign-2.xml +C:\temp-folder\examples\sign-3.xml +C:\temp-folder\examples\sign-4.xml +C:\temp-folder\examples\sign-5.xml \ No newline at end of file diff --git a/xmlsecurity/tools/examples/eval_import.txt b/xmlsecurity/tools/examples/eval_import.txt new file mode 100644 index 000000000000..9d675a8b20ec --- /dev/null +++ b/xmlsecurity/tools/examples/eval_import.txt @@ -0,0 +1,14 @@ +C:\temp-folder\examples\warmup-ex.xml +C:\temp-folder\examples\sign-0-ex.xml +C:\temp-folder\examples\sign-1-ex.xml +C:\temp-folder\examples\sign-2-ex.xml +C:\temp-folder\examples\sign-3-ex.xml +C:\temp-folder\examples\sign-4-ex.xml +C:\temp-folder\examples\sign-5-ex.xml +C:\temp-folder\examples\warmup-ex2.xml +C:\temp-folder\examples\sign-0-ex2.xml +C:\temp-folder\examples\sign-1-ex2.xml +C:\temp-folder\examples\sign-2-ex2.xml +C:\temp-folder\examples\sign-3-ex2.xml +C:\temp-folder\examples\sign-4-ex2.xml +C:\temp-folder\examples\sign-5-ex2.xml \ No newline at end of file diff --git a/xmlsecurity/tools/examples/evaluate_win.bat b/xmlsecurity/tools/examples/evaluate_win.bat new file mode 100644 index 000000000000..5bb73b0110a8 --- /dev/null +++ b/xmlsecurity/tools/examples/evaluate_win.bat @@ -0,0 +1,142 @@ +set SO_DRIVE=D: +set SO_PATH=2000Soft/OOo1.1 +set WS_PATH=e:/mybuild/SRC680 +set TEMP_DRIVE=C: +set TEMP_FOLDER=temp-folder + +@echo off +echo ============================================= +echo step - 1 create a temporary folder +echo ============================================= +@echo on +%TEMP_DRIVE% +cd / +mkdir %TEMP_FOLDER% + +@echo off +echo ============================================= +echo step - 2 copy the xsecsim.rdb +echo ============================================= +@echo on + +cp %WS_PATH%/xmlsecurity/wntmsci8.pro/bin/xsecsim.rdb %TEMP_DRIVE%/%TEMP_FOLDER%/. + +@echo off +echo ============================================= +echo step - 3 copy services.rdb and types.rdb +echo ============================================= +@echo on + +cp %SO_DRIVE%/%SO_PATH%/program/services.rdb %TEMP_DRIVE%/%TEMP_FOLDER%/. +cp %SO_DRIVE%/%SO_PATH%/program/types.rdb %TEMP_DRIVE%/%TEMP_FOLDER%/. + +@echo off +echo ============================================= +echo step - 4 add types.rdb, xsecsim.rdb to services.rdb +echo ============================================= +@echo on + +cd %TEMP_FOLDER% +regmerge services.rdb / types.rdb +regmerge services.rdb / xsecsim.rdb + +@echo off +echo ============================================= +echo step - 5 register new component +echo ============================================= +@echo on + +mkdir windows.plt +cp %WS_PATH%/xmlsecurity/wntmsci8.pro/bin/xsec_sim.dll windows.plt/. +cp %WS_PATH%/xmlsecurity/wntmsci8.pro/bin/xsecsim.rdb windows.plt/. +cp %WS_PATH%/xmlsecurity/wntmsci8.pro/class/jflatfilter.jar windows.plt/. +zip xsec_sim.zip windows.plt\*.* +rm -R windows.plt + +%SO_DRIVE% +cd %SO_DRIVE%/%SO_PATH%/program +pkgchk -s %TEMP_DRIVE%/%TEMP_FOLDER%/xsec_sim.zip + +%TEMP_DRIVE% + +@echo off +echo ============================================= +echo step - 6 copy dynamic libraries +echo ============================================= +@echo on + +cp %SO_DRIVE%/%SO_PATH%/program/*.dll ./. + +@echo off +echo ============================================= +echo step - 7 copy testtool program +echo ============================================= +@echo on + +cp %WS_PATH%/xmlsecurity/wntmsci8.pro/bin/testtool.exe ./. + +@echo off +echo ============================================= +echo step - 8 start OpenOffice +echo ============================================= +@echo on + +@echo off +echo please start up OpenOffice with "-accept=socket,host=0,port=2002;urp;" +pause Press Enter when finished... +@echo on + +@echo off +echo ============================================= +echo step - 9 run the testtool program +echo ============================================= +@echo on + +mkdir examples +cd examples +cp %WS_PATH%/xmlsecurity/tools/examples/warmup.xml ./. +cp %WS_PATH%/xmlsecurity/tools/examples/sign-0.xml ./. +cp %WS_PATH%/xmlsecurity/tools/examples/sign-1.xml ./. +cp %WS_PATH%/xmlsecurity/tools/examples/sign-2.xml ./. +cp %WS_PATH%/xmlsecurity/tools/examples/sign-3.xml ./. +cp %WS_PATH%/xmlsecurity/tools/examples/sign-4.xml ./. +cp %WS_PATH%/xmlsecurity/tools/examples/sign-5.xml ./. +cd .. +cp %WS_PATH%/xmlsecurity/tools/examples/eval_import.txt ./. +cp %WS_PATH%/xmlsecurity/tools/examples/eval_export.txt ./. + +testtool %WS_PATH%/xmlsecurity/tools/cryptoken/jks/testToken.jks %WS_PATH%/xmlsecurity/tools/cryptoken/nss %TEMP_DRIVE%/%TEMP_FOLDER%/eval_export.txt %TEMP_DRIVE%/%TEMP_FOLDER%/eval_import.txt + +@echo off +echo ============================================= +echo step - 10 stop OpenOffice +echo ============================================= +@echo on + +@echo off +echo please stop the OpenOffice application +pause Press Enter when finished... +@echo on + +@echo off +echo ============================================= +echo step - 11 remove new component +echo ============================================= +@echo on + +rm %SO_DRIVE%/%SO_PATH%/user/uno_packages/xsec_sim.zip +%SO_DRIVE% +cd %SO_DRIVE%/%SO_PATH%/program + +pkgchk -s -d xsec_sim.zip + +%TEMP_DRIVE% + +@echo off +echo ============================================= +echo step - 12 remove the temporary folder +echo ============================================= +@echo on + +cd .. +rm -R %TEMP_FOLDER% diff --git a/xmlsecurity/tools/examples/s-in-e-1.xml b/xmlsecurity/tools/examples/s-in-e-1.xml new file mode 100644 index 000000000000..d4c0c0eba80c --- /dev/null +++ b/xmlsecurity/tools/examples/s-in-e-1.xml @@ -0,0 +1,53 @@ + + + + a signature in an encryption. + + + + + + + + + CN=Test Issuer + 123450001 + + + + + + + + + + + + + + Hello, World! the Following is a Signature + + + + + + + + + + + + + + CN=Test Issuer + 123450005 + + + + + Signed Data + + + diff --git a/xmlsecurity/tools/examples/s-in-e-2.xml b/xmlsecurity/tools/examples/s-in-e-2.xml new file mode 100644 index 000000000000..fd3ba0cb5f9c --- /dev/null +++ b/xmlsecurity/tools/examples/s-in-e-2.xml @@ -0,0 +1,53 @@ + + + + a signature in an encryption. + + + + + + + + + CN=Test Issuer + 123450001 + + + + + + + + + + + + + + Hello, World! the Following is a Signature + + + + + + + + + + + + + + CN=Test Issuer + 123450005 + + + + + + Signed Data + + diff --git a/xmlsecurity/tools/examples/sign-0.xml b/xmlsecurity/tools/examples/sign-0.xml new file mode 100644 index 000000000000..7fc834f8fd40 --- /dev/null +++ b/xmlsecurity/tools/examples/sign-0.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + CN=Test Issuer + 123450005 + + + + + + +Programmer's ManualPlanned OutlinePreface (3 Pages)First Steps (24 Pages)Programming with UNOFields of Application for UNOGetting StartedRequired FilesConfigurationFirst ConnectionHow to get Objects in [PRODUCTNAME]How to work with ObjectsExampleServicesQuerying InterfacesUsing PropertiesElementAccessSimple TypesStringsEnums and Constant GroupsStructsAnySequenceHow to find the solution for a problemFinding your Way through the API ReferenceCommon MechanismsTextTableDrawingUNO in Professional Projects (145)IntroductionUNO/API constituents: How UNOIDL/API, ServiceManager, Bridges, CoreReflection work togetherAPI ConceptsAPI is a language independent, abstract specification for UNO objects which are used in [PRODUCTNAME]Types in the API ReferenceSimple TypesThe Any TypeInterfacesServicesModulesStructsConstant Groups and EnumsSequencesExceptionsAPI PrinciplesRelationship between Specification, Implementation and InstancesObject CompositionUNO ConceptsUNO is an environment for networked object communicationInterprocess ConnectionsServiceManager and ComponentContextUsing UNO InterfacesUsing PropertiesUsing Collections and ContainersEvent ModelException HandlingLifetime ControlObject IdentityLanguage BindingsIntroduction for language bindingJava Language BindingC++ BindingAccess for [PRODUCTNAME] BasicAutomationWriting UNO componentsSpecifying a new ComponentUNOIDL language specificationImplementing a ComponentComponent Development BasicsIntroductionMandatory interfaces: XInterface, XServiceInfo ((from UseInterfaces.CoreInterfaces))"Should be implemented" interfaces: XTypeProvider ((from UseInterfaces.CoreInterfaces ))optional interface: XMain for standalone executionSimple Component in JavaGetting the service manager ((Chapter Java components from unoBindingJava))simple component chapterC++ Component((Automation Component?))Deployment Options for ComponentsComponent RegistrationService Manager ConfigurationXSet InterfaceAdding components during runtime, particularly interesting during developmentServiceManager ContentDynamically modifying the ServiceManagerBootstrapping the Service Manager ((from CppBind chapter))Simple Test ApplicationConfiguring Your Application with Bootstrap ParametersThe UNO ExecutableStandalone Runtime EnvironmentThe UNO executable and XMainConfiguring the Java Runtime EnvironmentThe office and Java ((from UnoBindingJava))Advanced UNODesign PatternsBridging conceptsRequirements for Language Bindings and BridgesNew Scripting EnginesServiceManager and loaderSpecial Interfaces for internal useXUNOTunnelXAggregationUNO Reflection APITypeLibrary and TypeProvidersDifferences from CorbaOffice DevelopmentGlobal Object StructureDesktop EnvironmentFrames and Frame HierarchiesFrame-Controller-Model ParadigmLoading and Saving Office ComponentsDispatch FrameworkCommon FeaturesCommon DialogsDocumentInfoStylesSearch and ReplaceNumber FormatsPackage File FormatsInternationalizationLinguisticSystem IntegrationClipboardFile PickerBridging to the Window SystemText Documents (51,5 Pages)OverviewHandling Text FilesWorking with Text DocumentsNavigatingUsing TextTablesText FieldsBookmarksIndexes and Index MarksReference MarksFootnotes and EndnotesShape Objects in TextRedlineRubyGlobal Document FeaturesControlling a Text DocumentSpreadsheet DocumentsOverviewHandling Spreadsheet FilesWorking with Spreadsheet DocumentsNavigatingEditing SpreadsheetsGlobal Document FeaturesControlling a Spreadsheet DocumentExtending Capabilities of Spreadsheet DocumentsDrawings and PresentationsOverviewHandling Draw/Impress FilesSavingPrintingRunning PresentationsWorking with a Draw/Impress DocumentNavigatingWorking with Draw/Impress DocumentsGlobal Document FeaturesControlling a Draw/Impress DocumentChartsChart BasicsCreating a Chart DocumentEditing a Chart DocumentCommon Diagram APIDifferent Chart TypesExtending Capabilities of Chart DocumentsBasic and DialogsIntroductionLibrary OrganizationIDE with Dialogs and EventsUsing [PRODUCTNAME] BasicToolkit Controls and their PropertiesCreating Dialogs at RuntimeDatabase AccessFeatures of the [PRODUCTNAME] Database IntegrationCapabilitiesSDBC, SDBCX, SDB ArchitectureAccessing Datasources with [PRODUCTNAME]DataSourcesAdding and Editing Datasources Establishing a ConnectionGetting ConnectionsDriver specificsConnection PoolingWorking with Saved QueriesWorking with DataExecuting StatementsResultsetsMetadataRowsetsWorking with the Database DesignUsing DDL to change the DB DesignUsing SDBCX to access the DB DesignUsing DBMS FeaturesStored ProceduresTransaction HandlingExecuting Prepared StatementsWriting Database DriversFormsConceptsModels and ViewsForm Elements in the Document ModelSpecial Form ComponentsEventsData AwarenessRecipesMaking it easier to work with a FormControlling the Data InputCollecting Data automaticallyTaking Advantage of Database Server FeaturesAdding new FunctionalityHandling ErrorsUCBPurpose of UCBAccessing ContentsOpening Folder ContentsOpening Document Contents as StreamsWorking with Content PropertiesCreating, Moving and Copying Document and Folder ContentsWorking with Additional CommandsWriting a Content Provider[PRODUCTNAME] ConfigurationAccessing configuration dataWriting Configuration DataAppendix + + + \ No newline at end of file diff --git a/xmlsecurity/tools/examples/sign-1.xml b/xmlsecurity/tools/examples/sign-1.xml new file mode 100644 index 000000000000..c6e1a40dc987 --- /dev/null +++ b/xmlsecurity/tools/examples/sign-1.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + CN=Test Issuer + 123450005 + + + + + + +Programmer's ManualPlanned OutlinePreface (3 Pages)First Steps (24 Pages)Programming with UNOFields of Application for UNOGetting StartedRequired FilesConfigurationFirst ConnectionHow to get Objects in [PRODUCTNAME]How to work with ObjectsExampleServicesQuerying InterfacesUsing PropertiesElementAccessSimple TypesStringsEnums and Constant GroupsStructsAnySequenceHow to find the solution for a problemFinding your Way through the API ReferenceCommon MechanismsTextTableDrawingUNO in Professional Projects (145)IntroductionUNO/API constituents: How UNOIDL/API, ServiceManager, Bridges, CoreReflection work togetherAPI ConceptsAPI is a language independent, abstract specification for UNO objects which are used in [PRODUCTNAME]Types in the API ReferenceSimple TypesThe Any TypeInterfacesServicesModulesStructsConstant Groups and EnumsSequencesExceptionsAPI PrinciplesRelationship between Specification, Implementation and InstancesObject CompositionUNO ConceptsUNO is an environment for networked object communicationInterprocess ConnectionsServiceManager and ComponentContextUsing UNO InterfacesUsing PropertiesUsing Collections and ContainersEvent ModelException HandlingLifetime ControlObject IdentityLanguage BindingsIntroduction for language bindingJava Language BindingC++ BindingAccess for [PRODUCTNAME] BasicAutomationWriting UNO componentsSpecifying a new ComponentUNOIDL language specificationImplementing a ComponentComponent Development BasicsIntroductionMandatory interfaces: XInterface, XServiceInfo ((from UseInterfaces.CoreInterfaces))"Should be implemented" interfaces: XTypeProvider ((from UseInterfaces.CoreInterfaces ))optional interface: XMain for standalone executionSimple Component in JavaGetting the service manager ((Chapter Java components from unoBindingJava))simple component chapterC++ Component((Automation Component?))Deployment Options for ComponentsComponent RegistrationService Manager ConfigurationXSet InterfaceAdding components during runtime, particularly interesting during developmentServiceManager ContentDynamically modifying the ServiceManagerBootstrapping the Service Manager ((from CppBind chapter))Simple Test ApplicationConfiguring Your Application with Bootstrap ParametersThe UNO ExecutableStandalone Runtime EnvironmentThe UNO executable and XMainConfiguring the Java Runtime EnvironmentThe office and Java ((from UnoBindingJava))Advanced UNODesign PatternsBridging conceptsRequirements for Language Bindings and BridgesNew Scripting EnginesServiceManager and loaderSpecial Interfaces for internal useXUNOTunnelXAggregationUNO Reflection APITypeLibrary and TypeProvidersDifferences from CorbaOffice DevelopmentGlobal Object StructureDesktop EnvironmentFrames and Frame HierarchiesFrame-Controller-Model ParadigmLoading and Saving Office ComponentsDispatch FrameworkCommon FeaturesCommon DialogsDocumentInfoStylesSearch and ReplaceNumber FormatsPackage File FormatsInternationalizationLinguisticSystem IntegrationClipboardFile PickerBridging to the Window SystemText Documents (51,5 Pages)OverviewHandling Text FilesWorking with Text DocumentsNavigatingUsing TextTablesText FieldsBookmarksIndexes and Index MarksReference MarksFootnotes and EndnotesShape Objects in TextRedlineRubyGlobal Document FeaturesControlling a Text DocumentSpreadsheet DocumentsOverviewHandling Spreadsheet FilesWorking with Spreadsheet DocumentsNavigatingEditing SpreadsheetsGlobal Document FeaturesControlling a Spreadsheet DocumentExtending Capabilities of Spreadsheet DocumentsDrawings and PresentationsOverviewHandling Draw/Impress FilesSavingPrintingRunning PresentationsWorking with a Draw/Impress DocumentNavigatingWorking with Draw/Impress DocumentsGlobal Document FeaturesControlling a Draw/Impress DocumentChartsChart BasicsCreating a Chart DocumentEditing a Chart DocumentCommon Diagram APIDifferent Chart TypesExtending Capabilities of Chart DocumentsBasic and DialogsIntroductionLibrary OrganizationIDE with Dialogs and EventsUsing [PRODUCTNAME] BasicToolkit Controls and their PropertiesCreating Dialogs at RuntimeDatabase AccessFeatures of the [PRODUCTNAME] Database IntegrationCapabilitiesSDBC, SDBCX, SDB ArchitectureAccessing Datasources with [PRODUCTNAME]DataSourcesAdding and Editing Datasources Establishing a ConnectionGetting ConnectionsDriver specificsConnection PoolingWorking with Saved QueriesWorking with DataExecuting StatementsResultsetsMetadataRowsetsWorking with the Database DesignUsing DDL to change the DB DesignUsing SDBCX to access the DB DesignUsing DBMS FeaturesStored ProceduresTransaction HandlingExecuting Prepared StatementsWriting Database DriversFormsConceptsModels and ViewsForm Elements in the Document ModelSpecial Form ComponentsEventsData AwarenessRecipesMaking it easier to work with a FormControlling the Data InputCollecting Data automaticallyTaking Advantage of Database Server FeaturesAdding new FunctionalityHandling ErrorsUCBPurpose of UCBAccessing ContentsOpening Folder ContentsOpening Document Contents as StreamsWorking with Content PropertiesCreating, Moving and Copying Document and Folder ContentsWorking with Additional CommandsWriting a Content Provider[PRODUCTNAME] ConfigurationAccessing configuration dataWriting Configuration DataAppendix + +Programmer's ManualPlanned OutlinePreface (3 Pages)First Steps (24 Pages)Programming with UNOFields of Application for UNOGetting StartedRequired FilesConfigurationFirst ConnectionHow to get Objects in [PRODUCTNAME]How to work with ObjectsExampleServicesQuerying InterfacesUsing PropertiesElementAccessSimple TypesStringsEnums and Constant GroupsStructsAnySequenceHow to find the solution for a problemFinding your Way through the API ReferenceCommon MechanismsTextTableDrawingUNO in Professional Projects (145)IntroductionUNO/API constituents: How UNOIDL/API, ServiceManager, Bridges, CoreReflection work togetherAPI ConceptsAPI is a language independent, abstract specification for UNO objects which are used in [PRODUCTNAME]Types in the API ReferenceSimple TypesThe Any TypeInterfacesServicesModulesStructsConstant Groups and EnumsSequencesExceptionsAPI PrinciplesRelationship between Specification, Implementation and InstancesObject CompositionUNO ConceptsUNO is an environment for networked object communicationInterprocess ConnectionsServiceManager and ComponentContextUsing UNO InterfacesUsing PropertiesUsing Collections and ContainersEvent ModelException HandlingLifetime ControlObject IdentityLanguage BindingsIntroduction for language bindingJava Language BindingC++ BindingAccess for [PRODUCTNAME] BasicAutomationWriting UNO componentsSpecifying a new ComponentUNOIDL language specificationImplementing a ComponentComponent Development BasicsIntroductionMandatory interfaces: XInterface, XServiceInfo ((from UseInterfaces.CoreInterfaces))"Should be implemented" interfaces: XTypeProvider ((from UseInterfaces.CoreInterfaces ))optional interface: XMain for standalone executionSimple Component in JavaGetting the service manager ((Chapter Java components from unoBindingJava))simple component chapterC++ Component((Automation Component?))Deployment Options for ComponentsComponent RegistrationService Manager ConfigurationXSet InterfaceAdding components during runtime, particularly interesting during developmentServiceManager ContentDynamically modifying the ServiceManagerBootstrapping the Service Manager ((from CppBind chapter))Simple Test ApplicationConfiguring Your Application with Bootstrap ParametersThe UNO ExecutableStandalone Runtime EnvironmentThe UNO executable and XMainConfiguring the Java Runtime EnvironmentThe office and Java ((from UnoBindingJava))Advanced UNODesign PatternsBridging conceptsRequirements for Language Bindings and BridgesNew Scripting EnginesServiceManager and loaderSpecial Interfaces for internal useXUNOTunnelXAggregationUNO Reflection APITypeLibrary and TypeProvidersDifferences from CorbaOffice DevelopmentGlobal Object StructureDesktop EnvironmentFrames and Frame HierarchiesFrame-Controller-Model ParadigmLoading and Saving Office ComponentsDispatch FrameworkCommon FeaturesCommon DialogsDocumentInfoStylesSearch and ReplaceNumber FormatsPackage File FormatsInternationalizationLinguisticSystem IntegrationClipboardFile PickerBridging to the Window SystemText Documents (51,5 Pages)OverviewHandling Text FilesWorking with Text DocumentsNavigatingUsing TextTablesText FieldsBookmarksIndexes and Index MarksReference MarksFootnotes and EndnotesShape Objects in TextRedlineRubyGlobal Document FeaturesControlling a Text DocumentSpreadsheet DocumentsOverviewHandling Spreadsheet FilesWorking with Spreadsheet DocumentsNavigatingEditing SpreadsheetsGlobal Document FeaturesControlling a Spreadsheet DocumentExtending Capabilities of Spreadsheet DocumentsDrawings and PresentationsOverviewHandling Draw/Impress FilesSavingPrintingRunning PresentationsWorking with a Draw/Impress DocumentNavigatingWorking with Draw/Impress DocumentsGlobal Document FeaturesControlling a Draw/Impress DocumentChartsChart BasicsCreating a Chart DocumentEditing a Chart DocumentCommon Diagram APIDifferent Chart TypesExtending Capabilities of Chart DocumentsBasic and DialogsIntroductionLibrary OrganizationIDE with Dialogs and EventsUsing [PRODUCTNAME] BasicToolkit Controls and their PropertiesCreating Dialogs at RuntimeDatabase AccessFeatures of the [PRODUCTNAME] Database IntegrationCapabilitiesSDBC, SDBCX, SDB ArchitectureAccessing Datasources with [PRODUCTNAME]DataSourcesAdding and Editing Datasources Establishing a ConnectionGetting ConnectionsDriver specificsConnection PoolingWorking with Saved QueriesWorking with DataExecuting StatementsResultsetsMetadataRowsetsWorking with the Database DesignUsing DDL to change the DB DesignUsing SDBCX to access the DB DesignUsing DBMS FeaturesStored ProceduresTransaction HandlingExecuting Prepared StatementsWriting Database DriversFormsConceptsModels and ViewsForm Elements in the Document ModelSpecial Form ComponentsEventsData AwarenessRecipesMaking it easier to work with a FormControlling the Data InputCollecting Data automaticallyTaking Advantage of Database Server FeaturesAdding new FunctionalityHandling ErrorsUCBPurpose of UCBAccessing ContentsOpening Folder ContentsOpening Document Contents as StreamsWorking with Content PropertiesCreating, Moving and Copying Document and Folder ContentsWorking with Additional CommandsWriting a Content Provider[PRODUCTNAME] ConfigurationAccessing configuration dataWriting Configuration DataAppendix + + + \ No newline at end of file diff --git a/xmlsecurity/tools/examples/sign-2.xml b/xmlsecurity/tools/examples/sign-2.xml new file mode 100644 index 000000000000..e3da49f22d3f --- /dev/null +++ b/xmlsecurity/tools/examples/sign-2.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + CN=Test Issuer + 123450005 + + + + + + +Programmer's ManualPlanned OutlinePreface (3 Pages)First Steps (24 Pages)Programming with UNOFields of Application for UNOGetting StartedRequired FilesConfigurationFirst ConnectionHow to get Objects in [PRODUCTNAME]How to work with ObjectsExampleServicesQuerying InterfacesUsing PropertiesElementAccessSimple TypesStringsEnums and Constant GroupsStructsAnySequenceHow to find the solution for a problemFinding your Way through the API ReferenceCommon MechanismsTextTableDrawingUNO in Professional Projects (145)IntroductionUNO/API constituents: How UNOIDL/API, ServiceManager, Bridges, CoreReflection work togetherAPI ConceptsAPI is a language independent, abstract specification for UNO objects which are used in [PRODUCTNAME]Types in the API ReferenceSimple TypesThe Any TypeInterfacesServicesModulesStructsConstant Groups and EnumsSequencesExceptionsAPI PrinciplesRelationship between Specification, Implementation and InstancesObject CompositionUNO ConceptsUNO is an environment for networked object communicationInterprocess ConnectionsServiceManager and ComponentContextUsing UNO InterfacesUsing PropertiesUsing Collections and ContainersEvent ModelException HandlingLifetime ControlObject IdentityLanguage BindingsIntroduction for language bindingJava Language BindingC++ BindingAccess for [PRODUCTNAME] BasicAutomationWriting UNO componentsSpecifying a new ComponentUNOIDL language specificationImplementing a ComponentComponent Development BasicsIntroductionMandatory interfaces: XInterface, XServiceInfo ((from UseInterfaces.CoreInterfaces))"Should be implemented" interfaces: XTypeProvider ((from UseInterfaces.CoreInterfaces ))optional interface: XMain for standalone executionSimple Component in JavaGetting the service manager ((Chapter Java components from unoBindingJava))simple component chapterC++ Component((Automation Component?))Deployment Options for ComponentsComponent RegistrationService Manager ConfigurationXSet InterfaceAdding components during runtime, particularly interesting during developmentServiceManager ContentDynamically modifying the ServiceManagerBootstrapping the Service Manager ((from CppBind chapter))Simple Test ApplicationConfiguring Your Application with Bootstrap ParametersThe UNO ExecutableStandalone Runtime EnvironmentThe UNO executable and XMainConfiguring the Java Runtime EnvironmentThe office and Java ((from UnoBindingJava))Advanced UNODesign PatternsBridging conceptsRequirements for Language Bindings and BridgesNew Scripting EnginesServiceManager and loaderSpecial Interfaces for internal useXUNOTunnelXAggregationUNO Reflection APITypeLibrary and TypeProvidersDifferences from CorbaOffice DevelopmentGlobal Object StructureDesktop EnvironmentFrames and Frame HierarchiesFrame-Controller-Model ParadigmLoading and Saving Office ComponentsDispatch FrameworkCommon FeaturesCommon DialogsDocumentInfoStylesSearch and ReplaceNumber FormatsPackage File FormatsInternationalizationLinguisticSystem IntegrationClipboardFile PickerBridging to the Window SystemText Documents (51,5 Pages)OverviewHandling Text FilesWorking with Text DocumentsNavigatingUsing TextTablesText FieldsBookmarksIndexes and Index MarksReference MarksFootnotes and EndnotesShape Objects in TextRedlineRubyGlobal Document FeaturesControlling a Text DocumentSpreadsheet DocumentsOverviewHandling Spreadsheet FilesWorking with Spreadsheet DocumentsNavigatingEditing SpreadsheetsGlobal Document FeaturesControlling a Spreadsheet DocumentExtending Capabilities of Spreadsheet DocumentsDrawings and PresentationsOverviewHandling Draw/Impress FilesSavingPrintingRunning PresentationsWorking with a Draw/Impress DocumentNavigatingWorking with Draw/Impress DocumentsGlobal Document FeaturesControlling a Draw/Impress DocumentChartsChart BasicsCreating a Chart DocumentEditing a Chart DocumentCommon Diagram APIDifferent Chart TypesExtending Capabilities of Chart DocumentsBasic and DialogsIntroductionLibrary OrganizationIDE with Dialogs and EventsUsing [PRODUCTNAME] BasicToolkit Controls and their PropertiesCreating Dialogs at RuntimeDatabase AccessFeatures of the [PRODUCTNAME] Database IntegrationCapabilitiesSDBC, SDBCX, SDB ArchitectureAccessing Datasources with [PRODUCTNAME]DataSourcesAdding and Editing Datasources Establishing a ConnectionGetting ConnectionsDriver specificsConnection PoolingWorking with Saved QueriesWorking with DataExecuting StatementsResultsetsMetadataRowsetsWorking with the Database DesignUsing DDL to change the DB DesignUsing SDBCX to access the DB DesignUsing DBMS FeaturesStored ProceduresTransaction HandlingExecuting Prepared StatementsWriting Database DriversFormsConceptsModels and ViewsForm Elements in the Document ModelSpecial Form ComponentsEventsData AwarenessRecipesMaking it easier to work with a FormControlling the Data InputCollecting Data automaticallyTaking Advantage of Database Server FeaturesAdding new FunctionalityHandling ErrorsUCBPurpose of UCBAccessing ContentsOpening Folder ContentsOpening Document Contents as StreamsWorking with Content PropertiesCreating, Moving and Copying Document and Folder ContentsWorking with Additional CommandsWriting a Content Provider[PRODUCTNAME] ConfigurationAccessing configuration dataWriting Configuration DataAppendix + +Programmer's ManualPlanned OutlinePreface (3 Pages)First Steps (24 Pages)Programming with UNOFields of Application for UNOGetting StartedRequired FilesConfigurationFirst ConnectionHow to get Objects in [PRODUCTNAME]How to work with ObjectsExampleServicesQuerying InterfacesUsing PropertiesElementAccessSimple TypesStringsEnums and Constant GroupsStructsAnySequenceHow to find the solution for a problemFinding your Way through the API ReferenceCommon MechanismsTextTableDrawingUNO in Professional Projects (145)IntroductionUNO/API constituents: How UNOIDL/API, ServiceManager, Bridges, CoreReflection work togetherAPI ConceptsAPI is a language independent, abstract specification for UNO objects which are used in [PRODUCTNAME]Types in the API ReferenceSimple TypesThe Any TypeInterfacesServicesModulesStructsConstant Groups and EnumsSequencesExceptionsAPI PrinciplesRelationship between Specification, Implementation and InstancesObject CompositionUNO ConceptsUNO is an environment for networked object communicationInterprocess ConnectionsServiceManager and ComponentContextUsing UNO InterfacesUsing PropertiesUsing Collections and ContainersEvent ModelException HandlingLifetime ControlObject IdentityLanguage BindingsIntroduction for language bindingJava Language BindingC++ BindingAccess for [PRODUCTNAME] BasicAutomationWriting UNO componentsSpecifying a new ComponentUNOIDL language specificationImplementing a ComponentComponent Development BasicsIntroductionMandatory interfaces: XInterface, XServiceInfo ((from UseInterfaces.CoreInterfaces))"Should be implemented" interfaces: XTypeProvider ((from UseInterfaces.CoreInterfaces ))optional interface: XMain for standalone executionSimple Component in JavaGetting the service manager ((Chapter Java components from unoBindingJava))simple component chapterC++ Component((Automation Component?))Deployment Options for ComponentsComponent RegistrationService Manager ConfigurationXSet InterfaceAdding components during runtime, particularly interesting during developmentServiceManager ContentDynamically modifying the ServiceManagerBootstrapping the Service Manager ((from CppBind chapter))Simple Test ApplicationConfiguring Your Application with Bootstrap ParametersThe UNO ExecutableStandalone Runtime EnvironmentThe UNO executable and XMainConfiguring the Java Runtime EnvironmentThe office and Java ((from UnoBindingJava))Advanced UNODesign PatternsBridging conceptsRequirements for Language Bindings and BridgesNew Scripting EnginesServiceManager and loaderSpecial Interfaces for internal useXUNOTunnelXAggregationUNO Reflection APITypeLibrary and TypeProvidersDifferences from CorbaOffice DevelopmentGlobal Object StructureDesktop EnvironmentFrames and Frame HierarchiesFrame-Controller-Model ParadigmLoading and Saving Office ComponentsDispatch FrameworkCommon FeaturesCommon DialogsDocumentInfoStylesSearch and ReplaceNumber FormatsPackage File FormatsInternationalizationLinguisticSystem IntegrationClipboardFile PickerBridging to the Window SystemText Documents (51,5 Pages)OverviewHandling Text FilesWorking with Text DocumentsNavigatingUsing TextTablesText FieldsBookmarksIndexes and Index MarksReference MarksFootnotes and EndnotesShape Objects in TextRedlineRubyGlobal Document FeaturesControlling a Text DocumentSpreadsheet DocumentsOverviewHandling Spreadsheet FilesWorking with Spreadsheet DocumentsNavigatingEditing SpreadsheetsGlobal Document FeaturesControlling a Spreadsheet DocumentExtending Capabilities of Spreadsheet DocumentsDrawings and PresentationsOverviewHandling Draw/Impress FilesSavingPrintingRunning PresentationsWorking with a Draw/Impress DocumentNavigatingWorking with Draw/Impress DocumentsGlobal Document FeaturesControlling a Draw/Impress DocumentChartsChart BasicsCreating a Chart DocumentEditing a Chart DocumentCommon Diagram APIDifferent Chart TypesExtending Capabilities of Chart DocumentsBasic and DialogsIntroductionLibrary OrganizationIDE with Dialogs and EventsUsing [PRODUCTNAME] BasicToolkit Controls and their PropertiesCreating Dialogs at RuntimeDatabase AccessFeatures of the [PRODUCTNAME] Database IntegrationCapabilitiesSDBC, SDBCX, SDB ArchitectureAccessing Datasources with [PRODUCTNAME]DataSourcesAdding and Editing Datasources Establishing a ConnectionGetting ConnectionsDriver specificsConnection PoolingWorking with Saved QueriesWorking with DataExecuting StatementsResultsetsMetadataRowsetsWorking with the Database DesignUsing DDL to change the DB DesignUsing SDBCX to access the DB DesignUsing DBMS FeaturesStored ProceduresTransaction HandlingExecuting Prepared StatementsWriting Database DriversFormsConceptsModels and ViewsForm Elements in the Document ModelSpecial Form ComponentsEventsData AwarenessRecipesMaking it easier to work with a FormControlling the Data InputCollecting Data automaticallyTaking Advantage of Database Server FeaturesAdding new FunctionalityHandling ErrorsUCBPurpose of UCBAccessing ContentsOpening Folder ContentsOpening Document Contents as StreamsWorking with Content PropertiesCreating, Moving and Copying Document and Folder ContentsWorking with Additional CommandsWriting a Content Provider[PRODUCTNAME] ConfigurationAccessing configuration dataWriting Configuration DataAppendix + +Programmer's ManualPlanned OutlinePreface (3 Pages)First Steps (24 Pages)Programming with UNOFields of Application for UNOGetting StartedRequired FilesConfigurationFirst ConnectionHow to get Objects in [PRODUCTNAME]How to work with ObjectsExampleServicesQuerying InterfacesUsing PropertiesElementAccessSimple TypesStringsEnums and Constant GroupsStructsAnySequenceHow to find the solution for a problemFinding your Way through the API ReferenceCommon MechanismsTextTableDrawingUNO in Professional Projects (145)IntroductionUNO/API constituents: How UNOIDL/API, ServiceManager, Bridges, CoreReflection work togetherAPI ConceptsAPI is a language independent, abstract specification for UNO objects which are used in [PRODUCTNAME]Types in the API ReferenceSimple TypesThe Any TypeInterfacesServicesModulesStructsConstant Groups and EnumsSequencesExceptionsAPI PrinciplesRelationship between Specification, Implementation and InstancesObject CompositionUNO ConceptsUNO is an environment for networked object communicationInterprocess ConnectionsServiceManager and ComponentContextUsing UNO InterfacesUsing PropertiesUsing Collections and ContainersEvent ModelException HandlingLifetime ControlObject IdentityLanguage BindingsIntroduction for language bindingJava Language BindingC++ BindingAccess for [PRODUCTNAME] BasicAutomationWriting UNO componentsSpecifying a new ComponentUNOIDL language specificationImplementing a ComponentComponent Development BasicsIntroductionMandatory interfaces: XInterface, XServiceInfo ((from UseInterfaces.CoreInterfaces))"Should be implemented" interfaces: XTypeProvider ((from UseInterfaces.CoreInterfaces ))optional interface: XMain for standalone executionSimple Component in JavaGetting the service manager ((Chapter Java components from unoBindingJava))simple component chapterC++ Component((Automation Component?))Deployment Options for ComponentsComponent RegistrationService Manager ConfigurationXSet InterfaceAdding components during runtime, particularly interesting during developmentServiceManager ContentDynamically modifying the ServiceManagerBootstrapping the Service Manager ((from CppBind chapter))Simple Test ApplicationConfiguring Your Application with Bootstrap ParametersThe UNO ExecutableStandalone Runtime EnvironmentThe UNO executable and XMainConfiguring the Java Runtime EnvironmentThe office and Java ((from UnoBindingJava))Advanced UNODesign PatternsBridging conceptsRequirements for Language Bindings and BridgesNew Scripting EnginesServiceManager and loaderSpecial Interfaces for internal useXUNOTunnelXAggregationUNO Reflection APITypeLibrary and TypeProvidersDifferences from CorbaOffice DevelopmentGlobal Object StructureDesktop EnvironmentFrames and Frame HierarchiesFrame-Controller-Model ParadigmLoading and Saving Office ComponentsDispatch FrameworkCommon FeaturesCommon DialogsDocumentInfoStylesSearch and ReplaceNumber FormatsPackage File FormatsInternationalizationLinguisticSystem IntegrationClipboardFile PickerBridging to the Window SystemText Documents (51,5 Pages)OverviewHandling Text FilesWorking with Text DocumentsNavigatingUsing TextTablesText FieldsBookmarksIndexes and Index MarksReference MarksFootnotes and EndnotesShape Objects in TextRedlineRubyGlobal Document FeaturesControlling a Text DocumentSpreadsheet DocumentsOverviewHandling Spreadsheet FilesWorking with Spreadsheet DocumentsNavigatingEditing SpreadsheetsGlobal Document FeaturesControlling a Spreadsheet DocumentExtending Capabilities of Spreadsheet DocumentsDrawings and PresentationsOverviewHandling Draw/Impress FilesSavingPrintingRunning PresentationsWorking with a Draw/Impress DocumentNavigatingWorking with Draw/Impress DocumentsGlobal Document FeaturesControlling a Draw/Impress DocumentChartsChart BasicsCreating a Chart DocumentEditing a Chart DocumentCommon Diagram APIDifferent Chart TypesExtending Capabilities of Chart DocumentsBasic and DialogsIntroductionLibrary OrganizationIDE with Dialogs and EventsUsing [PRODUCTNAME] BasicToolkit Controls and their PropertiesCreating Dialogs at RuntimeDatabase AccessFeatures of the [PRODUCTNAME] Database IntegrationCapabilitiesSDBC, SDBCX, SDB ArchitectureAccessing Datasources with [PRODUCTNAME]DataSourcesAdding and Editing Datasources Establishing a ConnectionGetting ConnectionsDriver specificsConnection PoolingWorking with Saved QueriesWorking with DataExecuting StatementsResultsetsMetadataRowsetsWorking with the Database DesignUsing DDL to change the DB DesignUsing SDBCX to access the DB DesignUsing DBMS FeaturesStored ProceduresTransaction HandlingExecuting Prepared StatementsWriting Database DriversFormsConceptsModels and ViewsForm Elements in the Document ModelSpecial Form ComponentsEventsData AwarenessRecipesMaking it easier to work with a FormControlling the Data InputCollecting Data automaticallyTaking Advantage of Database Server FeaturesAdding new FunctionalityHandling ErrorsUCBPurpose of UCBAccessing ContentsOpening Folder ContentsOpening Document Contents as StreamsWorking with Content PropertiesCreating, Moving and Copying Document and Folder ContentsWorking with Additional CommandsWriting a Content Provider[PRODUCTNAME] ConfigurationAccessing configuration dataWriting Configuration DataAppendix + +Programmer's ManualPlanned OutlinePreface (3 Pages)First Steps (24 Pages)Programming with UNOFields of Application for UNOGetting StartedRequired FilesConfigurationFirst ConnectionHow to get Objects in [PRODUCTNAME]How to work with ObjectsExampleServicesQuerying InterfacesUsing PropertiesElementAccessSimple TypesStringsEnums and Constant GroupsStructsAnySequenceHow to find the solution for a problemFinding your Way through the API ReferenceCommon MechanismsTextTableDrawingUNO in Professional Projects (145)IntroductionUNO/API constituents: How UNOIDL/API, ServiceManager, Bridges, CoreReflection work togetherAPI ConceptsAPI is a language independent, abstract specification for UNO objects which are used in [PRODUCTNAME]Types in the API ReferenceSimple TypesThe Any TypeInterfacesServicesModulesStructsConstant Groups and EnumsSequencesExceptionsAPI PrinciplesRelationship between Specification, Implementation and InstancesObject CompositionUNO ConceptsUNO is an environment for networked object communicationInterprocess ConnectionsServiceManager and ComponentContextUsing UNO InterfacesUsing PropertiesUsing Collections and ContainersEvent ModelException HandlingLifetime ControlObject IdentityLanguage BindingsIntroduction for language bindingJava Language BindingC++ BindingAccess for [PRODUCTNAME] BasicAutomationWriting UNO componentsSpecifying a new ComponentUNOIDL language specificationImplementing a ComponentComponent Development BasicsIntroductionMandatory interfaces: XInterface, XServiceInfo ((from UseInterfaces.CoreInterfaces))"Should be implemented" interfaces: XTypeProvider ((from UseInterfaces.CoreInterfaces ))optional interface: XMain for standalone executionSimple Component in JavaGetting the service manager ((Chapter Java components from unoBindingJava))simple component chapterC++ Component((Automation Component?))Deployment Options for ComponentsComponent RegistrationService Manager ConfigurationXSet InterfaceAdding components during runtime, particularly interesting during developmentServiceManager ContentDynamically modifying the ServiceManagerBootstrapping the Service Manager ((from CppBind chapter))Simple Test ApplicationConfiguring Your Application with Bootstrap ParametersThe UNO ExecutableStandalone Runtime EnvironmentThe UNO executable and XMainConfiguring the Java Runtime EnvironmentThe office and Java ((from UnoBindingJava))Advanced UNODesign PatternsBridging conceptsRequirements for Language Bindings and BridgesNew Scripting EnginesServiceManager and loaderSpecial Interfaces for internal useXUNOTunnelXAggregationUNO Reflection APITypeLibrary and TypeProvidersDifferences from CorbaOffice DevelopmentGlobal Object StructureDesktop EnvironmentFrames and Frame HierarchiesFrame-Controller-Model ParadigmLoading and Saving Office ComponentsDispatch FrameworkCommon FeaturesCommon DialogsDocumentInfoStylesSearch and ReplaceNumber FormatsPackage File FormatsInternationalizationLinguisticSystem IntegrationClipboardFile PickerBridging to the Window SystemText Documents (51,5 Pages)OverviewHandling Text FilesWorking with Text DocumentsNavigatingUsing TextTablesText FieldsBookmarksIndexes and Index MarksReference MarksFootnotes and EndnotesShape Objects in TextRedlineRubyGlobal Document FeaturesControlling a Text DocumentSpreadsheet DocumentsOverviewHandling Spreadsheet FilesWorking with Spreadsheet DocumentsNavigatingEditing SpreadsheetsGlobal Document FeaturesControlling a Spreadsheet DocumentExtending Capabilities of Spreadsheet DocumentsDrawings and PresentationsOverviewHandling Draw/Impress FilesSavingPrintingRunning PresentationsWorking with a Draw/Impress DocumentNavigatingWorking with Draw/Impress DocumentsGlobal Document FeaturesControlling a Draw/Impress DocumentChartsChart BasicsCreating a Chart DocumentEditing a Chart DocumentCommon Diagram APIDifferent Chart TypesExtending Capabilities of Chart DocumentsBasic and DialogsIntroductionLibrary OrganizationIDE with Dialogs and EventsUsing [PRODUCTNAME] BasicToolkit Controls and their PropertiesCreating Dialogs at RuntimeDatabase AccessFeatures of the [PRODUCTNAME] Database IntegrationCapabilitiesSDBC, SDBCX, SDB ArchitectureAccessing Datasources with [PRODUCTNAME]DataSourcesAdding and Editing Datasources Establishing a ConnectionGetting ConnectionsDriver specificsConnection PoolingWorking with Saved QueriesWorking with DataExecuting StatementsResultsetsMetadataRowsetsWorking with the Database DesignUsing DDL to change the DB DesignUsing SDBCX to access the DB DesignUsing DBMS FeaturesStored ProceduresTransaction HandlingExecuting Prepared StatementsWriting Database DriversFormsConceptsModels and ViewsForm Elements in the Document ModelSpecial Form ComponentsEventsData AwarenessRecipesMaking it easier to work with a FormControlling the Data InputCollecting Data automaticallyTaking Advantage of Database Server FeaturesAdding new FunctionalityHandling ErrorsUCBPurpose of UCBAccessing ContentsOpening Folder ContentsOpening Document Contents as StreamsWorking with Content PropertiesCreating, Moving and Copying Document and Folder ContentsWorking with Additional CommandsWriting a Content Provider[PRODUCTNAME] ConfigurationAccessing configuration dataWriting Configuration DataAppendix + + + \ No newline at end of file diff --git a/xmlsecurity/tools/examples/sign-3.xml b/xmlsecurity/tools/examples/sign-3.xml new file mode 100644 index 000000000000..61a9f3cf378f --- /dev/null +++ b/xmlsecurity/tools/examples/sign-3.xml @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + CN=Test Issuer + 123450005 + + + + + + +Programmer's ManualPlanned OutlinePreface (3 Pages)First Steps (24 Pages)Programming with UNOFields of Application for UNOGetting StartedRequired FilesConfigurationFirst ConnectionHow to get Objects in [PRODUCTNAME]How to work with ObjectsExampleServicesQuerying InterfacesUsing PropertiesElementAccessSimple TypesStringsEnums and Constant GroupsStructsAnySequenceHow to find the solution for a problemFinding your Way through the API ReferenceCommon MechanismsTextTableDrawingUNO in Professional Projects (145)IntroductionUNO/API constituents: How UNOIDL/API, ServiceManager, Bridges, CoreReflection work togetherAPI ConceptsAPI is a language independent, abstract specification for UNO objects which are used in [PRODUCTNAME]Types in the API ReferenceSimple TypesThe Any TypeInterfacesServicesModulesStructsConstant Groups and EnumsSequencesExceptionsAPI PrinciplesRelationship between Specification, Implementation and InstancesObject CompositionUNO ConceptsUNO is an environment for networked object communicationInterprocess ConnectionsServiceManager and ComponentContextUsing UNO InterfacesUsing PropertiesUsing Collections and ContainersEvent ModelException HandlingLifetime ControlObject IdentityLanguage BindingsIntroduction for language bindingJava Language BindingC++ BindingAccess for [PRODUCTNAME] BasicAutomationWriting UNO componentsSpecifying a new ComponentUNOIDL language specificationImplementing a ComponentComponent Development BasicsIntroductionMandatory interfaces: XInterface, XServiceInfo ((from UseInterfaces.CoreInterfaces))"Should be implemented" interfaces: XTypeProvider ((from UseInterfaces.CoreInterfaces ))optional interface: XMain for standalone executionSimple Component in JavaGetting the service manager ((Chapter Java components from unoBindingJava))simple component chapterC++ Component((Automation Component?))Deployment Options for ComponentsComponent RegistrationService Manager ConfigurationXSet InterfaceAdding components during runtime, particularly interesting during developmentServiceManager ContentDynamically modifying the ServiceManagerBootstrapping the Service Manager ((from CppBind chapter))Simple Test ApplicationConfiguring Your Application with Bootstrap ParametersThe UNO ExecutableStandalone Runtime EnvironmentThe UNO executable and XMainConfiguring the Java Runtime EnvironmentThe office and Java ((from UnoBindingJava))Advanced UNODesign PatternsBridging conceptsRequirements for Language Bindings and BridgesNew Scripting EnginesServiceManager and loaderSpecial Interfaces for internal useXUNOTunnelXAggregationUNO Reflection APITypeLibrary and TypeProvidersDifferences from CorbaOffice DevelopmentGlobal Object StructureDesktop EnvironmentFrames and Frame HierarchiesFrame-Controller-Model ParadigmLoading and Saving Office ComponentsDispatch FrameworkCommon FeaturesCommon DialogsDocumentInfoStylesSearch and ReplaceNumber FormatsPackage File FormatsInternationalizationLinguisticSystem IntegrationClipboardFile PickerBridging to the Window SystemText Documents (51,5 Pages)OverviewHandling Text FilesWorking with Text DocumentsNavigatingUsing TextTablesText FieldsBookmarksIndexes and Index MarksReference MarksFootnotes and EndnotesShape Objects in TextRedlineRubyGlobal Document FeaturesControlling a Text DocumentSpreadsheet DocumentsOverviewHandling Spreadsheet FilesWorking with Spreadsheet DocumentsNavigatingEditing SpreadsheetsGlobal Document FeaturesControlling a Spreadsheet DocumentExtending Capabilities of Spreadsheet DocumentsDrawings and PresentationsOverviewHandling Draw/Impress FilesSavingPrintingRunning PresentationsWorking with a Draw/Impress DocumentNavigatingWorking with Draw/Impress DocumentsGlobal Document FeaturesControlling a Draw/Impress DocumentChartsChart BasicsCreating a Chart DocumentEditing a Chart DocumentCommon Diagram APIDifferent Chart TypesExtending Capabilities of Chart DocumentsBasic and DialogsIntroductionLibrary OrganizationIDE with Dialogs and EventsUsing [PRODUCTNAME] BasicToolkit Controls and their PropertiesCreating Dialogs at RuntimeDatabase AccessFeatures of the [PRODUCTNAME] Database IntegrationCapabilitiesSDBC, SDBCX, SDB ArchitectureAccessing Datasources with [PRODUCTNAME]DataSourcesAdding and Editing Datasources Establishing a ConnectionGetting ConnectionsDriver specificsConnection PoolingWorking with Saved QueriesWorking with DataExecuting StatementsResultsetsMetadataRowsetsWorking with the Database DesignUsing DDL to change the DB DesignUsing SDBCX to access the DB DesignUsing DBMS FeaturesStored ProceduresTransaction HandlingExecuting Prepared StatementsWriting Database DriversFormsConceptsModels and ViewsForm Elements in the Document ModelSpecial Form ComponentsEventsData AwarenessRecipesMaking it easier to work with a FormControlling the Data InputCollecting Data automaticallyTaking Advantage of Database Server FeaturesAdding new FunctionalityHandling ErrorsUCBPurpose of UCBAccessing ContentsOpening Folder ContentsOpening Document Contents as StreamsWorking with Content PropertiesCreating, Moving and Copying Document and Folder ContentsWorking with Additional CommandsWriting a Content Provider[PRODUCTNAME] ConfigurationAccessing configuration dataWriting Configuration DataAppendix + +Programmer's ManualPlanned OutlinePreface (3 Pages)First Steps (24 Pages)Programming with UNOFields of Application for UNOGetting StartedRequired FilesConfigurationFirst ConnectionHow to get Objects in [PRODUCTNAME]How to work with ObjectsExampleServicesQuerying InterfacesUsing PropertiesElementAccessSimple TypesStringsEnums and Constant GroupsStructsAnySequenceHow to find the solution for a problemFinding your Way through the API ReferenceCommon MechanismsTextTableDrawingUNO in Professional Projects (145)IntroductionUNO/API constituents: How UNOIDL/API, ServiceManager, Bridges, CoreReflection work togetherAPI ConceptsAPI is a language independent, abstract specification for UNO objects which are used in [PRODUCTNAME]Types in the API ReferenceSimple TypesThe Any TypeInterfacesServicesModulesStructsConstant Groups and EnumsSequencesExceptionsAPI PrinciplesRelationship between Specification, Implementation and InstancesObject CompositionUNO ConceptsUNO is an environment for networked object communicationInterprocess ConnectionsServiceManager and ComponentContextUsing UNO InterfacesUsing PropertiesUsing Collections and ContainersEvent ModelException HandlingLifetime ControlObject IdentityLanguage BindingsIntroduction for language bindingJava Language BindingC++ BindingAccess for [PRODUCTNAME] BasicAutomationWriting UNO componentsSpecifying a new ComponentUNOIDL language specificationImplementing a ComponentComponent Development BasicsIntroductionMandatory interfaces: XInterface, XServiceInfo ((from UseInterfaces.CoreInterfaces))"Should be implemented" interfaces: XTypeProvider ((from UseInterfaces.CoreInterfaces ))optional interface: XMain for standalone executionSimple Component in JavaGetting the service manager ((Chapter Java components from unoBindingJava))simple component chapterC++ Component((Automation Component?))Deployment Options for ComponentsComponent RegistrationService Manager ConfigurationXSet InterfaceAdding components during runtime, particularly interesting during developmentServiceManager ContentDynamically modifying the ServiceManagerBootstrapping the Service Manager ((from CppBind chapter))Simple Test ApplicationConfiguring Your Application with Bootstrap ParametersThe UNO ExecutableStandalone Runtime EnvironmentThe UNO executable and XMainConfiguring the Java Runtime EnvironmentThe office and Java ((from UnoBindingJava))Advanced UNODesign PatternsBridging conceptsRequirements for Language Bindings and BridgesNew Scripting EnginesServiceManager and loaderSpecial Interfaces for internal useXUNOTunnelXAggregationUNO Reflection APITypeLibrary and TypeProvidersDifferences from CorbaOffice DevelopmentGlobal Object StructureDesktop EnvironmentFrames and Frame HierarchiesFrame-Controller-Model ParadigmLoading and Saving Office ComponentsDispatch FrameworkCommon FeaturesCommon DialogsDocumentInfoStylesSearch and ReplaceNumber FormatsPackage File FormatsInternationalizationLinguisticSystem IntegrationClipboardFile PickerBridging to the Window SystemText Documents (51,5 Pages)OverviewHandling Text FilesWorking with Text DocumentsNavigatingUsing TextTablesText FieldsBookmarksIndexes and Index MarksReference MarksFootnotes and EndnotesShape Objects in TextRedlineRubyGlobal Document FeaturesControlling a Text DocumentSpreadsheet DocumentsOverviewHandling Spreadsheet FilesWorking with Spreadsheet DocumentsNavigatingEditing SpreadsheetsGlobal Document FeaturesControlling a Spreadsheet DocumentExtending Capabilities of Spreadsheet DocumentsDrawings and PresentationsOverviewHandling Draw/Impress FilesSavingPrintingRunning PresentationsWorking with a Draw/Impress DocumentNavigatingWorking with Draw/Impress DocumentsGlobal Document FeaturesControlling a Draw/Impress DocumentChartsChart BasicsCreating a Chart DocumentEditing a Chart DocumentCommon Diagram APIDifferent Chart TypesExtending Capabilities of Chart DocumentsBasic and DialogsIntroductionLibrary OrganizationIDE with Dialogs and EventsUsing [PRODUCTNAME] BasicToolkit Controls and their PropertiesCreating Dialogs at RuntimeDatabase AccessFeatures of the [PRODUCTNAME] Database IntegrationCapabilitiesSDBC, SDBCX, SDB ArchitectureAccessing Datasources with [PRODUCTNAME]DataSourcesAdding and Editing Datasources Establishing a ConnectionGetting ConnectionsDriver specificsConnection PoolingWorking with Saved QueriesWorking with DataExecuting StatementsResultsetsMetadataRowsetsWorking with the Database DesignUsing DDL to change the DB DesignUsing SDBCX to access the DB DesignUsing DBMS FeaturesStored ProceduresTransaction HandlingExecuting Prepared StatementsWriting Database DriversFormsConceptsModels and ViewsForm Elements in the Document ModelSpecial Form ComponentsEventsData AwarenessRecipesMaking it easier to work with a FormControlling the Data InputCollecting Data automaticallyTaking Advantage of Database Server FeaturesAdding new FunctionalityHandling ErrorsUCBPurpose of UCBAccessing ContentsOpening Folder ContentsOpening Document Contents as StreamsWorking with Content PropertiesCreating, Moving and Copying Document and Folder ContentsWorking with Additional CommandsWriting a Content Provider[PRODUCTNAME] ConfigurationAccessing configuration dataWriting Configuration DataAppendix + +Programmer's ManualPlanned OutlinePreface (3 Pages)First Steps (24 Pages)Programming with UNOFields of Application for UNOGetting StartedRequired FilesConfigurationFirst ConnectionHow to get Objects in [PRODUCTNAME]How to work with ObjectsExampleServicesQuerying InterfacesUsing PropertiesElementAccessSimple TypesStringsEnums and Constant GroupsStructsAnySequenceHow to find the solution for a problemFinding your Way through the API ReferenceCommon MechanismsTextTableDrawingUNO in Professional Projects (145)IntroductionUNO/API constituents: How UNOIDL/API, ServiceManager, Bridges, CoreReflection work togetherAPI ConceptsAPI is a language independent, abstract specification for UNO objects which are used in [PRODUCTNAME]Types in the API ReferenceSimple TypesThe Any TypeInterfacesServicesModulesStructsConstant Groups and EnumsSequencesExceptionsAPI PrinciplesRelationship between Specification, Implementation and InstancesObject CompositionUNO ConceptsUNO is an environment for networked object communicationInterprocess ConnectionsServiceManager and ComponentContextUsing UNO InterfacesUsing PropertiesUsing Collections and ContainersEvent ModelException HandlingLifetime ControlObject IdentityLanguage BindingsIntroduction for language bindingJava Language BindingC++ BindingAccess for [PRODUCTNAME] BasicAutomationWriting UNO componentsSpecifying a new ComponentUNOIDL language specificationImplementing a ComponentComponent Development BasicsIntroductionMandatory interfaces: XInterface, XServiceInfo ((from UseInterfaces.CoreInterfaces))"Should be implemented" interfaces: XTypeProvider ((from UseInterfaces.CoreInterfaces ))optional interface: XMain for standalone executionSimple Component in JavaGetting the service manager ((Chapter Java components from unoBindingJava))simple component chapterC++ Component((Automation Component?))Deployment Options for ComponentsComponent RegistrationService Manager ConfigurationXSet InterfaceAdding components during runtime, particularly interesting during developmentServiceManager ContentDynamically modifying the ServiceManagerBootstrapping the Service Manager ((from CppBind chapter))Simple Test ApplicationConfiguring Your Application with Bootstrap ParametersThe UNO ExecutableStandalone Runtime EnvironmentThe UNO executable and XMainConfiguring the Java Runtime EnvironmentThe office and Java ((from UnoBindingJava))Advanced UNODesign PatternsBridging conceptsRequirements for Language Bindings and BridgesNew Scripting EnginesServiceManager and loaderSpecial Interfaces for internal useXUNOTunnelXAggregationUNO Reflection APITypeLibrary and TypeProvidersDifferences from CorbaOffice DevelopmentGlobal Object StructureDesktop EnvironmentFrames and Frame HierarchiesFrame-Controller-Model ParadigmLoading and Saving Office ComponentsDispatch FrameworkCommon FeaturesCommon DialogsDocumentInfoStylesSearch and ReplaceNumber FormatsPackage File FormatsInternationalizationLinguisticSystem IntegrationClipboardFile PickerBridging to the Window SystemText Documents (51,5 Pages)OverviewHandling Text FilesWorking with Text DocumentsNavigatingUsing TextTablesText FieldsBookmarksIndexes and Index MarksReference MarksFootnotes and EndnotesShape Objects in TextRedlineRubyGlobal Document FeaturesControlling a Text DocumentSpreadsheet DocumentsOverviewHandling Spreadsheet FilesWorking with Spreadsheet DocumentsNavigatingEditing SpreadsheetsGlobal Document FeaturesControlling a Spreadsheet DocumentExtending Capabilities of Spreadsheet DocumentsDrawings and PresentationsOverviewHandling Draw/Impress FilesSavingPrintingRunning PresentationsWorking with a Draw/Impress DocumentNavigatingWorking with Draw/Impress DocumentsGlobal Document FeaturesControlling a Draw/Impress DocumentChartsChart BasicsCreating a Chart DocumentEditing a Chart DocumentCommon Diagram APIDifferent Chart TypesExtending Capabilities of Chart DocumentsBasic and DialogsIntroductionLibrary OrganizationIDE with Dialogs and EventsUsing [PRODUCTNAME] BasicToolkit Controls and their PropertiesCreating Dialogs at RuntimeDatabase AccessFeatures of the [PRODUCTNAME] Database IntegrationCapabilitiesSDBC, SDBCX, SDB ArchitectureAccessing Datasources with [PRODUCTNAME]DataSourcesAdding and Editing Datasources Establishing a ConnectionGetting ConnectionsDriver specificsConnection PoolingWorking with Saved QueriesWorking with DataExecuting StatementsResultsetsMetadataRowsetsWorking with the Database DesignUsing DDL to change the DB DesignUsing SDBCX to access the DB DesignUsing DBMS FeaturesStored ProceduresTransaction HandlingExecuting Prepared StatementsWriting Database DriversFormsConceptsModels and ViewsForm Elements in the Document ModelSpecial Form ComponentsEventsData AwarenessRecipesMaking it easier to work with a FormControlling the Data InputCollecting Data automaticallyTaking Advantage of Database Server FeaturesAdding new FunctionalityHandling ErrorsUCBPurpose of UCBAccessing ContentsOpening Folder ContentsOpening Document Contents as StreamsWorking with Content PropertiesCreating, Moving and Copying Document and Folder ContentsWorking with Additional CommandsWriting a Content Provider[PRODUCTNAME] ConfigurationAccessing configuration dataWriting Configuration DataAppendix + +Programmer's ManualPlanned OutlinePreface (3 Pages)First Steps (24 Pages)Programming with UNOFields of Application for UNOGetting StartedRequired FilesConfigurationFirst ConnectionHow to get Objects in [PRODUCTNAME]How to work with ObjectsExampleServicesQuerying InterfacesUsing PropertiesElementAccessSimple TypesStringsEnums and Constant GroupsStructsAnySequenceHow to find the solution for a problemFinding your Way through the API ReferenceCommon MechanismsTextTableDrawingUNO in Professional Projects (145)IntroductionUNO/API constituents: How UNOIDL/API, ServiceManager, Bridges, CoreReflection work togetherAPI ConceptsAPI is a language independent, abstract specification for UNO objects which are used in [PRODUCTNAME]Types in the API ReferenceSimple TypesThe Any TypeInterfacesServicesModulesStructsConstant Groups and EnumsSequencesExceptionsAPI PrinciplesRelationship between Specification, Implementation and InstancesObject CompositionUNO ConceptsUNO is an environment for networked object communicationInterprocess ConnectionsServiceManager and ComponentContextUsing UNO InterfacesUsing PropertiesUsing Collections and ContainersEvent ModelException HandlingLifetime ControlObject IdentityLanguage BindingsIntroduction for language bindingJava Language BindingC++ BindingAccess for [PRODUCTNAME] BasicAutomationWriting UNO componentsSpecifying a new ComponentUNOIDL language specificationImplementing a ComponentComponent Development BasicsIntroductionMandatory interfaces: XInterface, XServiceInfo ((from UseInterfaces.CoreInterfaces))"Should be implemented" interfaces: XTypeProvider ((from UseInterfaces.CoreInterfaces ))optional interface: XMain for standalone executionSimple Component in JavaGetting the service manager ((Chapter Java components from unoBindingJava))simple component chapterC++ Component((Automation Component?))Deployment Options for ComponentsComponent RegistrationService Manager ConfigurationXSet InterfaceAdding components during runtime, particularly interesting during developmentServiceManager ContentDynamically modifying the ServiceManagerBootstrapping the Service Manager ((from CppBind chapter))Simple Test ApplicationConfiguring Your Application with Bootstrap ParametersThe UNO ExecutableStandalone Runtime EnvironmentThe UNO executable and XMainConfiguring the Java Runtime EnvironmentThe office and Java ((from UnoBindingJava))Advanced UNODesign PatternsBridging conceptsRequirements for Language Bindings and BridgesNew Scripting EnginesServiceManager and loaderSpecial Interfaces for internal useXUNOTunnelXAggregationUNO Reflection APITypeLibrary and TypeProvidersDifferences from CorbaOffice DevelopmentGlobal Object StructureDesktop EnvironmentFrames and Frame HierarchiesFrame-Controller-Model ParadigmLoading and Saving Office ComponentsDispatch FrameworkCommon FeaturesCommon DialogsDocumentInfoStylesSearch and ReplaceNumber FormatsPackage File FormatsInternationalizationLinguisticSystem IntegrationClipboardFile PickerBridging to the Window SystemText Documents (51,5 Pages)OverviewHandling Text FilesWorking with Text DocumentsNavigatingUsing TextTablesText FieldsBookmarksIndexes and Index MarksReference MarksFootnotes and EndnotesShape Objects in TextRedlineRubyGlobal Document FeaturesControlling a Text DocumentSpreadsheet DocumentsOverviewHandling Spreadsheet FilesWorking with Spreadsheet DocumentsNavigatingEditing SpreadsheetsGlobal Document FeaturesControlling a Spreadsheet DocumentExtending Capabilities of Spreadsheet DocumentsDrawings and PresentationsOverviewHandling Draw/Impress FilesSavingPrintingRunning PresentationsWorking with a Draw/Impress DocumentNavigatingWorking with Draw/Impress DocumentsGlobal Document FeaturesControlling a Draw/Impress DocumentChartsChart BasicsCreating a Chart DocumentEditing a Chart DocumentCommon Diagram APIDifferent Chart TypesExtending Capabilities of Chart DocumentsBasic and DialogsIntroductionLibrary OrganizationIDE with Dialogs and EventsUsing [PRODUCTNAME] BasicToolkit Controls and their PropertiesCreating Dialogs at RuntimeDatabase AccessFeatures of the [PRODUCTNAME] Database IntegrationCapabilitiesSDBC, SDBCX, SDB ArchitectureAccessing Datasources with [PRODUCTNAME]DataSourcesAdding and Editing Datasources Establishing a ConnectionGetting ConnectionsDriver specificsConnection PoolingWorking with Saved QueriesWorking with DataExecuting StatementsResultsetsMetadataRowsetsWorking with the Database DesignUsing DDL to change the DB DesignUsing SDBCX to access the DB DesignUsing DBMS FeaturesStored ProceduresTransaction HandlingExecuting Prepared StatementsWriting Database DriversFormsConceptsModels and ViewsForm Elements in the Document ModelSpecial Form ComponentsEventsData AwarenessRecipesMaking it easier to work with a FormControlling the Data InputCollecting Data automaticallyTaking Advantage of Database Server FeaturesAdding new FunctionalityHandling ErrorsUCBPurpose of UCBAccessing ContentsOpening Folder ContentsOpening Document Contents as StreamsWorking with Content PropertiesCreating, Moving and Copying Document and Folder ContentsWorking with Additional CommandsWriting a Content Provider[PRODUCTNAME] ConfigurationAccessing configuration dataWriting Configuration DataAppendix + +Programmer's ManualPlanned OutlinePreface (3 Pages)First Steps (24 Pages)Programming with UNOFields of Application for UNOGetting StartedRequired FilesConfigurationFirst ConnectionHow to get Objects in [PRODUCTNAME]How to work with ObjectsExampleServicesQuerying InterfacesUsing PropertiesElementAccessSimple TypesStringsEnums and Constant GroupsStructsAnySequenceHow to find the solution for a problemFinding your Way through the API ReferenceCommon MechanismsTextTableDrawingUNO in Professional Projects (145)IntroductionUNO/API constituents: How UNOIDL/API, ServiceManager, Bridges, CoreReflection work togetherAPI ConceptsAPI is a language independent, abstract specification for UNO objects which are used in [PRODUCTNAME]Types in the API ReferenceSimple TypesThe Any TypeInterfacesServicesModulesStructsConstant Groups and EnumsSequencesExceptionsAPI PrinciplesRelationship between Specification, Implementation and InstancesObject CompositionUNO ConceptsUNO is an environment for networked object communicationInterprocess ConnectionsServiceManager and ComponentContextUsing UNO InterfacesUsing PropertiesUsing Collections and ContainersEvent ModelException HandlingLifetime ControlObject IdentityLanguage BindingsIntroduction for language bindingJava Language BindingC++ BindingAccess for [PRODUCTNAME] BasicAutomationWriting UNO componentsSpecifying a new ComponentUNOIDL language specificationImplementing a ComponentComponent Development BasicsIntroductionMandatory interfaces: XInterface, XServiceInfo ((from UseInterfaces.CoreInterfaces))"Should be implemented" interfaces: XTypeProvider ((from UseInterfaces.CoreInterfaces ))optional interface: XMain for standalone executionSimple Component in JavaGetting the service manager ((Chapter Java components from unoBindingJava))simple component chapterC++ Component((Automation Component?))Deployment Options for ComponentsComponent RegistrationService Manager ConfigurationXSet InterfaceAdding components during runtime, particularly interesting during developmentServiceManager ContentDynamically modifying the ServiceManagerBootstrapping the Service Manager ((from CppBind chapter))Simple Test ApplicationConfiguring Your Application with Bootstrap ParametersThe UNO ExecutableStandalone Runtime EnvironmentThe UNO executable and XMainConfiguring the Java Runtime EnvironmentThe office and Java ((from UnoBindingJava))Advanced UNODesign PatternsBridging conceptsRequirements for Language Bindings and BridgesNew Scripting EnginesServiceManager and loaderSpecial Interfaces for internal useXUNOTunnelXAggregationUNO Reflection APITypeLibrary and TypeProvidersDifferences from CorbaOffice DevelopmentGlobal Object StructureDesktop EnvironmentFrames and Frame HierarchiesFrame-Controller-Model ParadigmLoading and Saving Office ComponentsDispatch FrameworkCommon FeaturesCommon DialogsDocumentInfoStylesSearch and ReplaceNumber FormatsPackage File FormatsInternationalizationLinguisticSystem IntegrationClipboardFile PickerBridging to the Window SystemText Documents (51,5 Pages)OverviewHandling Text FilesWorking with Text DocumentsNavigatingUsing TextTablesText FieldsBookmarksIndexes and Index MarksReference MarksFootnotes and EndnotesShape Objects in TextRedlineRubyGlobal Document FeaturesControlling a Text DocumentSpreadsheet DocumentsOverviewHandling Spreadsheet FilesWorking with Spreadsheet DocumentsNavigatingEditing SpreadsheetsGlobal Document FeaturesControlling a Spreadsheet DocumentExtending Capabilities of Spreadsheet DocumentsDrawings and PresentationsOverviewHandling Draw/Impress FilesSavingPrintingRunning PresentationsWorking with a Draw/Impress DocumentNavigatingWorking with Draw/Impress DocumentsGlobal Document FeaturesControlling a Draw/Impress DocumentChartsChart BasicsCreating a Chart DocumentEditing a Chart DocumentCommon Diagram APIDifferent Chart TypesExtending Capabilities of Chart DocumentsBasic and DialogsIntroductionLibrary OrganizationIDE with Dialogs and EventsUsing [PRODUCTNAME] BasicToolkit Controls and their PropertiesCreating Dialogs at RuntimeDatabase AccessFeatures of the [PRODUCTNAME] Database IntegrationCapabilitiesSDBC, SDBCX, SDB ArchitectureAccessing Datasources with [PRODUCTNAME]DataSourcesAdding and Editing Datasources Establishing a ConnectionGetting ConnectionsDriver specificsConnection PoolingWorking with Saved QueriesWorking with DataExecuting StatementsResultsetsMetadataRowsetsWorking with the Database DesignUsing DDL to change the DB DesignUsing SDBCX to access the DB DesignUsing DBMS FeaturesStored ProceduresTransaction HandlingExecuting Prepared StatementsWriting Database DriversFormsConceptsModels and ViewsForm Elements in the Document ModelSpecial Form ComponentsEventsData AwarenessRecipesMaking it easier to work with a FormControlling the Data InputCollecting Data automaticallyTaking Advantage of Database Server FeaturesAdding new FunctionalityHandling ErrorsUCBPurpose of UCBAccessing ContentsOpening Folder ContentsOpening Document Contents as StreamsWorking with Content PropertiesCreating, Moving and Copying Document and Folder ContentsWorking with Additional CommandsWriting a Content Provider[PRODUCTNAME] ConfigurationAccessing configuration dataWriting Configuration DataAppendix + +Programmer's ManualPlanned OutlinePreface (3 Pages)First Steps (24 Pages)Programming with UNOFields of Application for UNOGetting StartedRequired FilesConfigurationFirst ConnectionHow to get Objects in [PRODUCTNAME]How to work with ObjectsExampleServicesQuerying InterfacesUsing PropertiesElementAccessSimple TypesStringsEnums and Constant GroupsStructsAnySequenceHow to find the solution for a problemFinding your Way through the API ReferenceCommon MechanismsTextTableDrawingUNO in Professional Projects (145)IntroductionUNO/API constituents: How UNOIDL/API, ServiceManager, Bridges, CoreReflection work togetherAPI ConceptsAPI is a language independent, abstract specification for UNO objects which are used in [PRODUCTNAME]Types in the API ReferenceSimple TypesThe Any TypeInterfacesServicesModulesStructsConstant Groups and EnumsSequencesExceptionsAPI PrinciplesRelationship between Specification, Implementation and InstancesObject CompositionUNO ConceptsUNO is an environment for networked object communicationInterprocess ConnectionsServiceManager and ComponentContextUsing UNO InterfacesUsing PropertiesUsing Collections and ContainersEvent ModelException HandlingLifetime ControlObject IdentityLanguage BindingsIntroduction for language bindingJava Language BindingC++ BindingAccess for [PRODUCTNAME] BasicAutomationWriting UNO componentsSpecifying a new ComponentUNOIDL language specificationImplementing a ComponentComponent Development BasicsIntroductionMandatory interfaces: XInterface, XServiceInfo ((from UseInterfaces.CoreInterfaces))"Should be implemented" interfaces: XTypeProvider ((from UseInterfaces.CoreInterfaces ))optional interface: XMain for standalone executionSimple Component in JavaGetting the service manager ((Chapter Java components from unoBindingJava))simple component chapterC++ Component((Automation Component?))Deployment Options for ComponentsComponent RegistrationService Manager ConfigurationXSet InterfaceAdding components during runtime, particularly interesting during developmentServiceManager ContentDynamically modifying the ServiceManagerBootstrapping the Service Manager ((from CppBind chapter))Simple Test ApplicationConfiguring Your Application with Bootstrap ParametersThe UNO ExecutableStandalone Runtime EnvironmentThe UNO executable and XMainConfiguring the Java Runtime EnvironmentThe office and Java ((from UnoBindingJava))Advanced UNODesign PatternsBridging conceptsRequirements for Language Bindings and BridgesNew Scripting EnginesServiceManager and loaderSpecial Interfaces for internal useXUNOTunnelXAggregationUNO Reflection APITypeLibrary and TypeProvidersDifferences from CorbaOffice DevelopmentGlobal Object StructureDesktop EnvironmentFrames and Frame HierarchiesFrame-Controller-Model ParadigmLoading and Saving Office ComponentsDispatch FrameworkCommon FeaturesCommon DialogsDocumentInfoStylesSearch and ReplaceNumber FormatsPackage File FormatsInternationalizationLinguisticSystem IntegrationClipboardFile PickerBridging to the Window SystemText Documents (51,5 Pages)OverviewHandling Text FilesWorking with Text DocumentsNavigatingUsing TextTablesText FieldsBookmarksIndexes and Index MarksReference MarksFootnotes and EndnotesShape Objects in TextRedlineRubyGlobal Document FeaturesControlling a Text DocumentSpreadsheet DocumentsOverviewHandling Spreadsheet FilesWorking with Spreadsheet DocumentsNavigatingEditing SpreadsheetsGlobal Document FeaturesControlling a Spreadsheet DocumentExtending Capabilities of Spreadsheet DocumentsDrawings and PresentationsOverviewHandling Draw/Impress FilesSavingPrintingRunning PresentationsWorking with a Draw/Impress DocumentNavigatingWorking with Draw/Impress DocumentsGlobal Document FeaturesControlling a Draw/Impress DocumentChartsChart BasicsCreating a Chart DocumentEditing a Chart DocumentCommon Diagram APIDifferent Chart TypesExtending Capabilities of Chart DocumentsBasic and DialogsIntroductionLibrary OrganizationIDE with Dialogs and EventsUsing [PRODUCTNAME] BasicToolkit Controls and their PropertiesCreating Dialogs at RuntimeDatabase AccessFeatures of the [PRODUCTNAME] Database IntegrationCapabilitiesSDBC, SDBCX, SDB ArchitectureAccessing Datasources with [PRODUCTNAME]DataSourcesAdding and Editing Datasources Establishing a ConnectionGetting ConnectionsDriver specificsConnection PoolingWorking with Saved QueriesWorking with DataExecuting StatementsResultsetsMetadataRowsetsWorking with the Database DesignUsing DDL to change the DB DesignUsing SDBCX to access the DB DesignUsing DBMS FeaturesStored ProceduresTransaction HandlingExecuting Prepared StatementsWriting Database DriversFormsConceptsModels and ViewsForm Elements in the Document ModelSpecial Form ComponentsEventsData AwarenessRecipesMaking it easier to work with a FormControlling the Data InputCollecting Data automaticallyTaking Advantage of Database Server FeaturesAdding new FunctionalityHandling ErrorsUCBPurpose of UCBAccessing ContentsOpening Folder ContentsOpening Document Contents as StreamsWorking with Content PropertiesCreating, Moving and Copying Document and Folder ContentsWorking with Additional CommandsWriting a Content Provider[PRODUCTNAME] ConfigurationAccessing configuration dataWriting Configuration DataAppendix + +Programmer's ManualPlanned OutlinePreface (3 Pages)First Steps (24 Pages)Programming with UNOFields of Application for UNOGetting StartedRequired FilesConfigurationFirst ConnectionHow to get Objects in [PRODUCTNAME]How to work with ObjectsExampleServicesQuerying InterfacesUsing PropertiesElementAccessSimple TypesStringsEnums and Constant GroupsStructsAnySequenceHow to find the solution for a problemFinding your Way through the API ReferenceCommon MechanismsTextTableDrawingUNO in Professional Projects (145)IntroductionUNO/API constituents: How UNOIDL/API, ServiceManager, Bridges, CoreReflection work togetherAPI ConceptsAPI is a language independent, abstract specification for UNO objects which are used in [PRODUCTNAME]Types in the API ReferenceSimple TypesThe Any TypeInterfacesServicesModulesStructsConstant Groups and EnumsSequencesExceptionsAPI PrinciplesRelationship between Specification, Implementation and InstancesObject CompositionUNO ConceptsUNO is an environment for networked object communicationInterprocess ConnectionsServiceManager and ComponentContextUsing UNO InterfacesUsing PropertiesUsing Collections and ContainersEvent ModelException HandlingLifetime ControlObject IdentityLanguage BindingsIntroduction for language bindingJava Language BindingC++ BindingAccess for [PRODUCTNAME] BasicAutomationWriting UNO componentsSpecifying a new ComponentUNOIDL language specificationImplementing a ComponentComponent Development BasicsIntroductionMandatory interfaces: XInterface, XServiceInfo ((from UseInterfaces.CoreInterfaces))"Should be implemented" interfaces: XTypeProvider ((from UseInterfaces.CoreInterfaces ))optional interface: XMain for standalone executionSimple Component in JavaGetting the service manager ((Chapter Java components from unoBindingJava))simple component chapterC++ Component((Automation Component?))Deployment Options for ComponentsComponent RegistrationService Manager ConfigurationXSet InterfaceAdding components during runtime, particularly interesting during developmentServiceManager ContentDynamically modifying the ServiceManagerBootstrapping the Service Manager ((from CppBind chapter))Simple Test ApplicationConfiguring Your Application with Bootstrap ParametersThe UNO ExecutableStandalone Runtime EnvironmentThe UNO executable and XMainConfiguring the Java Runtime EnvironmentThe office and Java ((from UnoBindingJava))Advanced UNODesign PatternsBridging conceptsRequirements for Language Bindings and BridgesNew Scripting EnginesServiceManager and loaderSpecial Interfaces for internal useXUNOTunnelXAggregationUNO Reflection APITypeLibrary and TypeProvidersDifferences from CorbaOffice DevelopmentGlobal Object StructureDesktop EnvironmentFrames and Frame HierarchiesFrame-Controller-Model ParadigmLoading and Saving Office ComponentsDispatch FrameworkCommon FeaturesCommon DialogsDocumentInfoStylesSearch and ReplaceNumber FormatsPackage File FormatsInternationalizationLinguisticSystem IntegrationClipboardFile PickerBridging to the Window SystemText Documents (51,5 Pages)OverviewHandling Text FilesWorking with Text DocumentsNavigatingUsing TextTablesText FieldsBookmarksIndexes and Index MarksReference MarksFootnotes and EndnotesShape Objects in TextRedlineRubyGlobal Document FeaturesControlling a Text DocumentSpreadsheet DocumentsOverviewHandling Spreadsheet FilesWorking with Spreadsheet DocumentsNavigatingEditing SpreadsheetsGlobal Document FeaturesControlling a Spreadsheet DocumentExtending Capabilities of Spreadsheet DocumentsDrawings and PresentationsOverviewHandling Draw/Impress FilesSavingPrintingRunning PresentationsWorking with a Draw/Impress DocumentNavigatingWorking with Draw/Impress DocumentsGlobal Document FeaturesControlling a Draw/Impress DocumentChartsChart BasicsCreating a Chart DocumentEditing a Chart DocumentCommon Diagram APIDifferent Chart TypesExtending Capabilities of Chart DocumentsBasic and DialogsIntroductionLibrary OrganizationIDE with Dialogs and EventsUsing [PRODUCTNAME] BasicToolkit Controls and their PropertiesCreating Dialogs at RuntimeDatabase AccessFeatures of the [PRODUCTNAME] Database IntegrationCapabilitiesSDBC, SDBCX, SDB ArchitectureAccessing Datasources with [PRODUCTNAME]DataSourcesAdding and Editing Datasources Establishing a ConnectionGetting ConnectionsDriver specificsConnection PoolingWorking with Saved QueriesWorking with DataExecuting StatementsResultsetsMetadataRowsetsWorking with the Database DesignUsing DDL to change the DB DesignUsing SDBCX to access the DB DesignUsing DBMS FeaturesStored ProceduresTransaction HandlingExecuting Prepared StatementsWriting Database DriversFormsConceptsModels and ViewsForm Elements in the Document ModelSpecial Form ComponentsEventsData AwarenessRecipesMaking it easier to work with a FormControlling the Data InputCollecting Data automaticallyTaking Advantage of Database Server FeaturesAdding new FunctionalityHandling ErrorsUCBPurpose of UCBAccessing ContentsOpening Folder ContentsOpening Document Contents as StreamsWorking with Content PropertiesCreating, Moving and Copying Document and Folder ContentsWorking with Additional CommandsWriting a Content Provider[PRODUCTNAME] ConfigurationAccessing configuration dataWriting Configuration DataAppendix + +Programmer's ManualPlanned OutlinePreface (3 Pages)First Steps (24 Pages)Programming with UNOFields of Application for UNOGetting StartedRequired FilesConfigurationFirst ConnectionHow to get Objects in [PRODUCTNAME]How to work with ObjectsExampleServicesQuerying InterfacesUsing PropertiesElementAccessSimple TypesStringsEnums and Constant GroupsStructsAnySequenceHow to find the solution for a problemFinding your Way through the API ReferenceCommon MechanismsTextTableDrawingUNO in Professional Projects (145)IntroductionUNO/API constituents: How UNOIDL/API, ServiceManager, Bridges, CoreReflection work togetherAPI ConceptsAPI is a language independent, abstract specification for UNO objects which are used in [PRODUCTNAME]Types in the API ReferenceSimple TypesThe Any TypeInterfacesServicesModulesStructsConstant Groups and EnumsSequencesExceptionsAPI PrinciplesRelationship between Specification, Implementation and InstancesObject CompositionUNO ConceptsUNO is an environment for networked object communicationInterprocess ConnectionsServiceManager and ComponentContextUsing UNO InterfacesUsing PropertiesUsing Collections and ContainersEvent ModelException HandlingLifetime ControlObject IdentityLanguage BindingsIntroduction for language bindingJava Language BindingC++ BindingAccess for [PRODUCTNAME] BasicAutomationWriting UNO componentsSpecifying a new ComponentUNOIDL language specificationImplementing a ComponentComponent Development BasicsIntroductionMandatory interfaces: XInterface, XServiceInfo ((from UseInterfaces.CoreInterfaces))"Should be implemented" interfaces: XTypeProvider ((from UseInterfaces.CoreInterfaces ))optional interface: XMain for standalone executionSimple Component in JavaGetting the service manager ((Chapter Java components from unoBindingJava))simple component chapterC++ Component((Automation Component?))Deployment Options for ComponentsComponent RegistrationService Manager ConfigurationXSet InterfaceAdding components during runtime, particularly interesting during developmentServiceManager ContentDynamically modifying the ServiceManagerBootstrapping the Service Manager ((from CppBind chapter))Simple Test ApplicationConfiguring Your Application with Bootstrap ParametersThe UNO ExecutableStandalone Runtime EnvironmentThe UNO executable and XMainConfiguring the Java Runtime EnvironmentThe office and Java ((from UnoBindingJava))Advanced UNODesign PatternsBridging conceptsRequirements for Language Bindings and BridgesNew Scripting EnginesServiceManager and loaderSpecial Interfaces for internal useXUNOTunnelXAggregationUNO Reflection APITypeLibrary and TypeProvidersDifferences from CorbaOffice DevelopmentGlobal Object StructureDesktop EnvironmentFrames and Frame HierarchiesFrame-Controller-Model ParadigmLoading and Saving Office ComponentsDispatch FrameworkCommon FeaturesCommon DialogsDocumentInfoStylesSearch and ReplaceNumber FormatsPackage File FormatsInternationalizationLinguisticSystem IntegrationClipboardFile PickerBridging to the Window SystemText Documents (51,5 Pages)OverviewHandling Text FilesWorking with Text DocumentsNavigatingUsing TextTablesText FieldsBookmarksIndexes and Index MarksReference MarksFootnotes and EndnotesShape Objects in TextRedlineRubyGlobal Document FeaturesControlling a Text DocumentSpreadsheet DocumentsOverviewHandling Spreadsheet FilesWorking with Spreadsheet DocumentsNavigatingEditing SpreadsheetsGlobal Document FeaturesControlling a Spreadsheet DocumentExtending Capabilities of Spreadsheet DocumentsDrawings and PresentationsOverviewHandling Draw/Impress FilesSavingPrintingRunning PresentationsWorking with a Draw/Impress DocumentNavigatingWorking with Draw/Impress DocumentsGlobal Document FeaturesControlling a Draw/Impress DocumentChartsChart BasicsCreating a Chart DocumentEditing a Chart DocumentCommon Diagram APIDifferent Chart TypesExtending Capabilities of Chart DocumentsBasic and DialogsIntroductionLibrary OrganizationIDE with Dialogs and EventsUsing [PRODUCTNAME] BasicToolkit Controls and their PropertiesCreating Dialogs at RuntimeDatabase AccessFeatures of the [PRODUCTNAME] Database IntegrationCapabilitiesSDBC, SDBCX, SDB ArchitectureAccessing Datasources with [PRODUCTNAME]DataSourcesAdding and Editing Datasources Establishing a ConnectionGetting ConnectionsDriver specificsConnection PoolingWorking with Saved QueriesWorking with DataExecuting StatementsResultsetsMetadataRowsetsWorking with the Database DesignUsing DDL to change the DB DesignUsing SDBCX to access the DB DesignUsing DBMS FeaturesStored ProceduresTransaction HandlingExecuting Prepared StatementsWriting Database DriversFormsConceptsModels and ViewsForm Elements in the Document ModelSpecial Form ComponentsEventsData AwarenessRecipesMaking it easier to work with a FormControlling the Data InputCollecting Data automaticallyTaking Advantage of Database Server FeaturesAdding new FunctionalityHandling ErrorsUCBPurpose of UCBAccessing ContentsOpening Folder ContentsOpening Document Contents as StreamsWorking with Content PropertiesCreating, Moving and Copying Document and Folder ContentsWorking with Additional CommandsWriting a Content Provider[PRODUCTNAME] ConfigurationAccessing configuration dataWriting Configuration DataAppendix + + + \ No newline at end of file diff --git a/xmlsecurity/tools/examples/sign-4.xml b/xmlsecurity/tools/examples/sign-4.xml new file mode 100644 index 000000000000..b8450045006c --- /dev/null +++ b/xmlsecurity/tools/examples/sign-4.xml @@ -0,0 +1,57 @@ + + + + + + + + + + + + + + + + CN=Test Issuer + 123450005 + + + + + + +Programmer's ManualPlanned OutlinePreface (3 Pages)First Steps (24 Pages)Programming with UNOFields of Application for UNOGetting StartedRequired FilesConfigurationFirst ConnectionHow to get Objects in [PRODUCTNAME]How to work with ObjectsExampleServicesQuerying InterfacesUsing PropertiesElementAccessSimple TypesStringsEnums and Constant GroupsStructsAnySequenceHow to find the solution for a problemFinding your Way through the API ReferenceCommon MechanismsTextTableDrawingUNO in Professional Projects (145)IntroductionUNO/API constituents: How UNOIDL/API, ServiceManager, Bridges, CoreReflection work togetherAPI ConceptsAPI is a language independent, abstract specification for UNO objects which are used in [PRODUCTNAME]Types in the API ReferenceSimple TypesThe Any TypeInterfacesServicesModulesStructsConstant Groups and EnumsSequencesExceptionsAPI PrinciplesRelationship between Specification, Implementation and InstancesObject CompositionUNO ConceptsUNO is an environment for networked object communicationInterprocess ConnectionsServiceManager and ComponentContextUsing UNO InterfacesUsing PropertiesUsing Collections and ContainersEvent ModelException HandlingLifetime ControlObject IdentityLanguage BindingsIntroduction for language bindingJava Language BindingC++ BindingAccess for [PRODUCTNAME] BasicAutomationWriting UNO componentsSpecifying a new ComponentUNOIDL language specificationImplementing a ComponentComponent Development BasicsIntroductionMandatory interfaces: XInterface, XServiceInfo ((from UseInterfaces.CoreInterfaces))"Should be implemented" interfaces: XTypeProvider ((from UseInterfaces.CoreInterfaces ))optional interface: XMain for standalone executionSimple Component in JavaGetting the service manager ((Chapter Java components from unoBindingJava))simple component chapterC++ Component((Automation Component?))Deployment Options for ComponentsComponent RegistrationService Manager ConfigurationXSet InterfaceAdding components during runtime, particularly interesting during developmentServiceManager ContentDynamically modifying the ServiceManagerBootstrapping the Service Manager ((from CppBind chapter))Simple Test ApplicationConfiguring Your Application with Bootstrap ParametersThe UNO ExecutableStandalone Runtime EnvironmentThe UNO executable and XMainConfiguring the Java Runtime EnvironmentThe office and Java ((from UnoBindingJava))Advanced UNODesign PatternsBridging conceptsRequirements for Language Bindings and BridgesNew Scripting EnginesServiceManager and loaderSpecial Interfaces for internal useXUNOTunnelXAggregationUNO Reflection APITypeLibrary and TypeProvidersDifferences from CorbaOffice DevelopmentGlobal Object StructureDesktop EnvironmentFrames and Frame HierarchiesFrame-Controller-Model ParadigmLoading and Saving Office ComponentsDispatch FrameworkCommon FeaturesCommon DialogsDocumentInfoStylesSearch and ReplaceNumber FormatsPackage File FormatsInternationalizationLinguisticSystem IntegrationClipboardFile PickerBridging to the Window SystemText Documents (51,5 Pages)OverviewHandling Text FilesWorking with Text DocumentsNavigatingUsing TextTablesText FieldsBookmarksIndexes and Index MarksReference MarksFootnotes and EndnotesShape Objects in TextRedlineRubyGlobal Document FeaturesControlling a Text DocumentSpreadsheet DocumentsOverviewHandling Spreadsheet FilesWorking with Spreadsheet DocumentsNavigatingEditing SpreadsheetsGlobal Document FeaturesControlling a Spreadsheet DocumentExtending Capabilities of Spreadsheet DocumentsDrawings and PresentationsOverviewHandling Draw/Impress FilesSavingPrintingRunning PresentationsWorking with a Draw/Impress DocumentNavigatingWorking with Draw/Impress DocumentsGlobal Document FeaturesControlling a Draw/Impress DocumentChartsChart BasicsCreating a Chart DocumentEditing a Chart DocumentCommon Diagram APIDifferent Chart TypesExtending Capabilities of Chart DocumentsBasic and DialogsIntroductionLibrary OrganizationIDE with Dialogs and EventsUsing [PRODUCTNAME] BasicToolkit Controls and their PropertiesCreating Dialogs at RuntimeDatabase AccessFeatures of the [PRODUCTNAME] Database IntegrationCapabilitiesSDBC, SDBCX, SDB ArchitectureAccessing Datasources with [PRODUCTNAME]DataSourcesAdding and Editing Datasources Establishing a ConnectionGetting ConnectionsDriver specificsConnection PoolingWorking with Saved QueriesWorking with DataExecuting StatementsResultsetsMetadataRowsetsWorking with the Database DesignUsing DDL to change the DB DesignUsing SDBCX to access the DB DesignUsing DBMS FeaturesStored ProceduresTransaction HandlingExecuting Prepared StatementsWriting Database DriversFormsConceptsModels and ViewsForm Elements in the Document ModelSpecial Form ComponentsEventsData AwarenessRecipesMaking it easier to work with a FormControlling the Data InputCollecting Data automaticallyTaking Advantage of Database Server FeaturesAdding new FunctionalityHandling ErrorsUCBPurpose of UCBAccessing ContentsOpening Folder ContentsOpening Document Contents as StreamsWorking with Content PropertiesCreating, Moving and Copying Document and Folder ContentsWorking with Additional CommandsWriting a Content Provider[PRODUCTNAME] ConfigurationAccessing configuration dataWriting Configuration DataAppendix + +Programmer's ManualPlanned OutlinePreface (3 Pages)First Steps (24 Pages)Programming with UNOFields of Application for UNOGetting StartedRequired FilesConfigurationFirst ConnectionHow to get Objects in [PRODUCTNAME]How to work with ObjectsExampleServicesQuerying InterfacesUsing PropertiesElementAccessSimple TypesStringsEnums and Constant GroupsStructsAnySequenceHow to find the solution for a problemFinding your Way through the API ReferenceCommon MechanismsTextTableDrawingUNO in Professional Projects (145)IntroductionUNO/API constituents: How UNOIDL/API, ServiceManager, Bridges, CoreReflection work togetherAPI ConceptsAPI is a language independent, abstract specification for UNO objects which are used in [PRODUCTNAME]Types in the API ReferenceSimple TypesThe Any TypeInterfacesServicesModulesStructsConstant Groups and EnumsSequencesExceptionsAPI PrinciplesRelationship between Specification, Implementation and InstancesObject CompositionUNO ConceptsUNO is an environment for networked object communicationInterprocess ConnectionsServiceManager and ComponentContextUsing UNO InterfacesUsing PropertiesUsing Collections and ContainersEvent ModelException HandlingLifetime ControlObject IdentityLanguage BindingsIntroduction for language bindingJava Language BindingC++ BindingAccess for [PRODUCTNAME] BasicAutomationWriting UNO componentsSpecifying a new ComponentUNOIDL language specificationImplementing a ComponentComponent Development BasicsIntroductionMandatory interfaces: XInterface, XServiceInfo ((from UseInterfaces.CoreInterfaces))"Should be implemented" interfaces: XTypeProvider ((from UseInterfaces.CoreInterfaces ))optional interface: XMain for standalone executionSimple Component in JavaGetting the service manager ((Chapter Java components from unoBindingJava))simple component chapterC++ Component((Automation Component?))Deployment Options for ComponentsComponent RegistrationService Manager ConfigurationXSet InterfaceAdding components during runtime, particularly interesting during developmentServiceManager ContentDynamically modifying the ServiceManagerBootstrapping the Service Manager ((from CppBind chapter))Simple Test ApplicationConfiguring Your Application with Bootstrap ParametersThe UNO ExecutableStandalone Runtime EnvironmentThe UNO executable and XMainConfiguring the Java Runtime EnvironmentThe office and Java ((from UnoBindingJava))Advanced UNODesign PatternsBridging conceptsRequirements for Language Bindings and BridgesNew Scripting EnginesServiceManager and loaderSpecial Interfaces for internal useXUNOTunnelXAggregationUNO Reflection APITypeLibrary and TypeProvidersDifferences from CorbaOffice DevelopmentGlobal Object StructureDesktop EnvironmentFrames and Frame HierarchiesFrame-Controller-Model ParadigmLoading and Saving Office ComponentsDispatch FrameworkCommon FeaturesCommon DialogsDocumentInfoStylesSearch and ReplaceNumber FormatsPackage File FormatsInternationalizationLinguisticSystem IntegrationClipboardFile PickerBridging to the Window SystemText Documents (51,5 Pages)OverviewHandling Text FilesWorking with Text DocumentsNavigatingUsing TextTablesText FieldsBookmarksIndexes and Index MarksReference MarksFootnotes and EndnotesShape Objects in TextRedlineRubyGlobal Document FeaturesControlling a Text DocumentSpreadsheet DocumentsOverviewHandling Spreadsheet FilesWorking with Spreadsheet DocumentsNavigatingEditing SpreadsheetsGlobal Document FeaturesControlling a Spreadsheet DocumentExtending Capabilities of Spreadsheet DocumentsDrawings and PresentationsOverviewHandling Draw/Impress FilesSavingPrintingRunning PresentationsWorking with a Draw/Impress DocumentNavigatingWorking with Draw/Impress DocumentsGlobal Document FeaturesControlling a Draw/Impress DocumentChartsChart BasicsCreating a Chart DocumentEditing a Chart DocumentCommon Diagram APIDifferent Chart TypesExtending Capabilities of Chart DocumentsBasic and DialogsIntroductionLibrary OrganizationIDE with Dialogs and EventsUsing [PRODUCTNAME] BasicToolkit Controls and their PropertiesCreating Dialogs at RuntimeDatabase AccessFeatures of the [PRODUCTNAME] Database IntegrationCapabilitiesSDBC, SDBCX, SDB ArchitectureAccessing Datasources with [PRODUCTNAME]DataSourcesAdding and Editing Datasources Establishing a ConnectionGetting ConnectionsDriver specificsConnection PoolingWorking with Saved QueriesWorking with DataExecuting StatementsResultsetsMetadataRowsetsWorking with the Database DesignUsing DDL to change the DB DesignUsing SDBCX to access the DB DesignUsing DBMS FeaturesStored ProceduresTransaction HandlingExecuting Prepared StatementsWriting Database DriversFormsConceptsModels and ViewsForm Elements in the Document ModelSpecial Form ComponentsEventsData AwarenessRecipesMaking it easier to work with a FormControlling the Data InputCollecting Data automaticallyTaking Advantage of Database Server FeaturesAdding new FunctionalityHandling ErrorsUCBPurpose of UCBAccessing ContentsOpening Folder ContentsOpening Document Contents as StreamsWorking with Content PropertiesCreating, Moving and Copying Document and Folder ContentsWorking with Additional CommandsWriting a Content Provider[PRODUCTNAME] ConfigurationAccessing configuration dataWriting Configuration DataAppendix + +Programmer's ManualPlanned OutlinePreface (3 Pages)First Steps (24 Pages)Programming with UNOFields of Application for UNOGetting StartedRequired FilesConfigurationFirst ConnectionHow to get Objects in [PRODUCTNAME]How to work with ObjectsExampleServicesQuerying InterfacesUsing PropertiesElementAccessSimple TypesStringsEnums and Constant GroupsStructsAnySequenceHow to find the solution for a problemFinding your Way through the API ReferenceCommon MechanismsTextTableDrawingUNO in Professional Projects (145)IntroductionUNO/API constituents: How UNOIDL/API, ServiceManager, Bridges, CoreReflection work togetherAPI ConceptsAPI is a language independent, abstract specification for UNO objects which are used in [PRODUCTNAME]Types in the API ReferenceSimple TypesThe Any TypeInterfacesServicesModulesStructsConstant Groups and EnumsSequencesExceptionsAPI PrinciplesRelationship between Specification, Implementation and InstancesObject CompositionUNO ConceptsUNO is an environment for networked object communicationInterprocess ConnectionsServiceManager and ComponentContextUsing UNO InterfacesUsing PropertiesUsing Collections and ContainersEvent ModelException HandlingLifetime ControlObject IdentityLanguage BindingsIntroduction for language bindingJava Language BindingC++ BindingAccess for [PRODUCTNAME] BasicAutomationWriting UNO componentsSpecifying a new ComponentUNOIDL language specificationImplementing a ComponentComponent Development BasicsIntroductionMandatory interfaces: XInterface, XServiceInfo ((from UseInterfaces.CoreInterfaces))"Should be implemented" interfaces: XTypeProvider ((from UseInterfaces.CoreInterfaces ))optional interface: XMain for standalone executionSimple Component in JavaGetting the service manager ((Chapter Java components from unoBindingJava))simple component chapterC++ Component((Automation Component?))Deployment Options for ComponentsComponent RegistrationService Manager ConfigurationXSet InterfaceAdding components during runtime, particularly interesting during developmentServiceManager ContentDynamically modifying the ServiceManagerBootstrapping the Service Manager ((from CppBind chapter))Simple Test ApplicationConfiguring Your Application with Bootstrap ParametersThe UNO ExecutableStandalone Runtime EnvironmentThe UNO executable and XMainConfiguring the Java Runtime EnvironmentThe office and Java ((from UnoBindingJava))Advanced UNODesign PatternsBridging conceptsRequirements for Language Bindings and BridgesNew Scripting EnginesServiceManager and loaderSpecial Interfaces for internal useXUNOTunnelXAggregationUNO Reflection APITypeLibrary and TypeProvidersDifferences from CorbaOffice DevelopmentGlobal Object StructureDesktop EnvironmentFrames and Frame HierarchiesFrame-Controller-Model ParadigmLoading and Saving Office ComponentsDispatch FrameworkCommon FeaturesCommon DialogsDocumentInfoStylesSearch and ReplaceNumber FormatsPackage File FormatsInternationalizationLinguisticSystem IntegrationClipboardFile PickerBridging to the Window SystemText Documents (51,5 Pages)OverviewHandling Text FilesWorking with Text DocumentsNavigatingUsing TextTablesText FieldsBookmarksIndexes and Index MarksReference MarksFootnotes and EndnotesShape Objects in TextRedlineRubyGlobal Document FeaturesControlling a Text DocumentSpreadsheet DocumentsOverviewHandling Spreadsheet FilesWorking with Spreadsheet DocumentsNavigatingEditing SpreadsheetsGlobal Document FeaturesControlling a Spreadsheet DocumentExtending Capabilities of Spreadsheet DocumentsDrawings and PresentationsOverviewHandling Draw/Impress FilesSavingPrintingRunning PresentationsWorking with a Draw/Impress DocumentNavigatingWorking with Draw/Impress DocumentsGlobal Document FeaturesControlling a Draw/Impress DocumentChartsChart BasicsCreating a Chart DocumentEditing a Chart DocumentCommon Diagram APIDifferent Chart TypesExtending Capabilities of Chart DocumentsBasic and DialogsIntroductionLibrary OrganizationIDE with Dialogs and EventsUsing [PRODUCTNAME] BasicToolkit Controls and their PropertiesCreating Dialogs at RuntimeDatabase AccessFeatures of the [PRODUCTNAME] Database IntegrationCapabilitiesSDBC, SDBCX, SDB ArchitectureAccessing Datasources with [PRODUCTNAME]DataSourcesAdding and Editing Datasources Establishing a ConnectionGetting ConnectionsDriver specificsConnection PoolingWorking with Saved QueriesWorking with DataExecuting StatementsResultsetsMetadataRowsetsWorking with the Database DesignUsing DDL to change the DB DesignUsing SDBCX to access the DB DesignUsing DBMS FeaturesStored ProceduresTransaction HandlingExecuting Prepared StatementsWriting Database DriversFormsConceptsModels and ViewsForm Elements in the Document ModelSpecial Form ComponentsEventsData AwarenessRecipesMaking it easier to work with a FormControlling the Data InputCollecting Data automaticallyTaking Advantage of Database Server FeaturesAdding new FunctionalityHandling ErrorsUCBPurpose of UCBAccessing ContentsOpening Folder ContentsOpening Document Contents as StreamsWorking with Content PropertiesCreating, Moving and Copying Document and Folder ContentsWorking with Additional CommandsWriting a Content Provider[PRODUCTNAME] ConfigurationAccessing configuration dataWriting Configuration DataAppendix + +Programmer's ManualPlanned OutlinePreface (3 Pages)First Steps (24 Pages)Programming with UNOFields of Application for UNOGetting StartedRequired FilesConfigurationFirst ConnectionHow to get Objects in [PRODUCTNAME]How to work with ObjectsExampleServicesQuerying InterfacesUsing PropertiesElementAccessSimple TypesStringsEnums and Constant GroupsStructsAnySequenceHow to find the solution for a problemFinding your Way through the API ReferenceCommon MechanismsTextTableDrawingUNO in Professional Projects (145)IntroductionUNO/API constituents: How UNOIDL/API, ServiceManager, Bridges, CoreReflection work togetherAPI ConceptsAPI is a language independent, abstract specification for UNO objects which are used in [PRODUCTNAME]Types in the API ReferenceSimple TypesThe Any TypeInterfacesServicesModulesStructsConstant Groups and EnumsSequencesExceptionsAPI PrinciplesRelationship between Specification, Implementation and InstancesObject CompositionUNO ConceptsUNO is an environment for networked object communicationInterprocess ConnectionsServiceManager and ComponentContextUsing UNO InterfacesUsing PropertiesUsing Collections and ContainersEvent ModelException HandlingLifetime ControlObject IdentityLanguage BindingsIntroduction for language bindingJava Language BindingC++ BindingAccess for [PRODUCTNAME] BasicAutomationWriting UNO componentsSpecifying a new ComponentUNOIDL language specificationImplementing a ComponentComponent Development BasicsIntroductionMandatory interfaces: XInterface, XServiceInfo ((from UseInterfaces.CoreInterfaces))"Should be implemented" interfaces: XTypeProvider ((from UseInterfaces.CoreInterfaces ))optional interface: XMain for standalone executionSimple Component in JavaGetting the service manager ((Chapter Java components from unoBindingJava))simple component chapterC++ Component((Automation Component?))Deployment Options for ComponentsComponent RegistrationService Manager ConfigurationXSet InterfaceAdding components during runtime, particularly interesting during developmentServiceManager ContentDynamically modifying the ServiceManagerBootstrapping the Service Manager ((from CppBind chapter))Simple Test ApplicationConfiguring Your Application with Bootstrap ParametersThe UNO ExecutableStandalone Runtime EnvironmentThe UNO executable and XMainConfiguring the Java Runtime EnvironmentThe office and Java ((from UnoBindingJava))Advanced UNODesign PatternsBridging conceptsRequirements for Language Bindings and BridgesNew Scripting EnginesServiceManager and loaderSpecial Interfaces for internal useXUNOTunnelXAggregationUNO Reflection APITypeLibrary and TypeProvidersDifferences from CorbaOffice DevelopmentGlobal Object StructureDesktop EnvironmentFrames and Frame HierarchiesFrame-Controller-Model ParadigmLoading and Saving Office ComponentsDispatch FrameworkCommon FeaturesCommon DialogsDocumentInfoStylesSearch and ReplaceNumber FormatsPackage File FormatsInternationalizationLinguisticSystem IntegrationClipboardFile PickerBridging to the Window SystemText Documents (51,5 Pages)OverviewHandling Text FilesWorking with Text DocumentsNavigatingUsing TextTablesText FieldsBookmarksIndexes and Index MarksReference MarksFootnotes and EndnotesShape Objects in TextRedlineRubyGlobal Document FeaturesControlling a Text DocumentSpreadsheet DocumentsOverviewHandling Spreadsheet FilesWorking with Spreadsheet DocumentsNavigatingEditing SpreadsheetsGlobal Document FeaturesControlling a Spreadsheet DocumentExtending Capabilities of Spreadsheet DocumentsDrawings and PresentationsOverviewHandling Draw/Impress FilesSavingPrintingRunning PresentationsWorking with a Draw/Impress DocumentNavigatingWorking with Draw/Impress DocumentsGlobal Document FeaturesControlling a Draw/Impress DocumentChartsChart BasicsCreating a Chart DocumentEditing a Chart DocumentCommon Diagram APIDifferent Chart TypesExtending Capabilities of Chart DocumentsBasic and DialogsIntroductionLibrary OrganizationIDE with Dialogs and EventsUsing [PRODUCTNAME] BasicToolkit Controls and their PropertiesCreating Dialogs at RuntimeDatabase AccessFeatures of the [PRODUCTNAME] Database IntegrationCapabilitiesSDBC, SDBCX, SDB ArchitectureAccessing Datasources with [PRODUCTNAME]DataSourcesAdding and Editing Datasources Establishing a ConnectionGetting ConnectionsDriver specificsConnection PoolingWorking with Saved QueriesWorking with DataExecuting StatementsResultsetsMetadataRowsetsWorking with the Database DesignUsing DDL to change the DB DesignUsing SDBCX to access the DB DesignUsing DBMS FeaturesStored ProceduresTransaction HandlingExecuting Prepared StatementsWriting Database DriversFormsConceptsModels and ViewsForm Elements in the Document ModelSpecial Form ComponentsEventsData AwarenessRecipesMaking it easier to work with a FormControlling the Data InputCollecting Data automaticallyTaking Advantage of Database Server FeaturesAdding new FunctionalityHandling ErrorsUCBPurpose of UCBAccessing ContentsOpening Folder ContentsOpening Document Contents as StreamsWorking with Content PropertiesCreating, Moving and Copying Document and Folder ContentsWorking with Additional CommandsWriting a Content Provider[PRODUCTNAME] ConfigurationAccessing configuration dataWriting Configuration DataAppendix + +Programmer's ManualPlanned OutlinePreface (3 Pages)First Steps (24 Pages)Programming with UNOFields of Application for UNOGetting StartedRequired FilesConfigurationFirst ConnectionHow to get Objects in [PRODUCTNAME]How to work with ObjectsExampleServicesQuerying InterfacesUsing PropertiesElementAccessSimple TypesStringsEnums and Constant GroupsStructsAnySequenceHow to find the solution for a problemFinding your Way through the API ReferenceCommon MechanismsTextTableDrawingUNO in Professional Projects (145)IntroductionUNO/API constituents: How UNOIDL/API, ServiceManager, Bridges, CoreReflection work togetherAPI ConceptsAPI is a language independent, abstract specification for UNO objects which are used in [PRODUCTNAME]Types in the API ReferenceSimple TypesThe Any TypeInterfacesServicesModulesStructsConstant Groups and EnumsSequencesExceptionsAPI PrinciplesRelationship between Specification, Implementation and InstancesObject CompositionUNO ConceptsUNO is an environment for networked object communicationInterprocess ConnectionsServiceManager and ComponentContextUsing UNO InterfacesUsing PropertiesUsing Collections and ContainersEvent ModelException HandlingLifetime ControlObject IdentityLanguage BindingsIntroduction for language bindingJava Language BindingC++ BindingAccess for [PRODUCTNAME] BasicAutomationWriting UNO componentsSpecifying a new ComponentUNOIDL language specificationImplementing a ComponentComponent Development BasicsIntroductionMandatory interfaces: XInterface, XServiceInfo ((from UseInterfaces.CoreInterfaces))"Should be implemented" interfaces: XTypeProvider ((from UseInterfaces.CoreInterfaces ))optional interface: XMain for standalone executionSimple Component in JavaGetting the service manager ((Chapter Java components from unoBindingJava))simple component chapterC++ Component((Automation Component?))Deployment Options for ComponentsComponent RegistrationService Manager ConfigurationXSet InterfaceAdding components during runtime, particularly interesting during developmentServiceManager ContentDynamically modifying the ServiceManagerBootstrapping the Service Manager ((from CppBind chapter))Simple Test ApplicationConfiguring Your Application with Bootstrap ParametersThe UNO ExecutableStandalone Runtime EnvironmentThe UNO executable and XMainConfiguring the Java Runtime EnvironmentThe office and Java ((from UnoBindingJava))Advanced UNODesign PatternsBridging conceptsRequirements for Language Bindings and BridgesNew Scripting EnginesServiceManager and loaderSpecial Interfaces for internal useXUNOTunnelXAggregationUNO Reflection APITypeLibrary and TypeProvidersDifferences from CorbaOffice DevelopmentGlobal Object StructureDesktop EnvironmentFrames and Frame HierarchiesFrame-Controller-Model ParadigmLoading and Saving Office ComponentsDispatch FrameworkCommon FeaturesCommon DialogsDocumentInfoStylesSearch and ReplaceNumber FormatsPackage File FormatsInternationalizationLinguisticSystem IntegrationClipboardFile PickerBridging to the Window SystemText Documents (51,5 Pages)OverviewHandling Text FilesWorking with Text DocumentsNavigatingUsing TextTablesText FieldsBookmarksIndexes and Index MarksReference MarksFootnotes and EndnotesShape Objects in TextRedlineRubyGlobal Document FeaturesControlling a Text DocumentSpreadsheet DocumentsOverviewHandling Spreadsheet FilesWorking with Spreadsheet DocumentsNavigatingEditing SpreadsheetsGlobal Document FeaturesControlling a Spreadsheet DocumentExtending Capabilities of Spreadsheet DocumentsDrawings and PresentationsOverviewHandling Draw/Impress FilesSavingPrintingRunning PresentationsWorking with a Draw/Impress DocumentNavigatingWorking with Draw/Impress DocumentsGlobal Document FeaturesControlling a Draw/Impress DocumentChartsChart BasicsCreating a Chart DocumentEditing a Chart DocumentCommon Diagram APIDifferent Chart TypesExtending Capabilities of Chart DocumentsBasic and DialogsIntroductionLibrary OrganizationIDE with Dialogs and EventsUsing [PRODUCTNAME] BasicToolkit Controls and their PropertiesCreating Dialogs at RuntimeDatabase AccessFeatures of the [PRODUCTNAME] Database IntegrationCapabilitiesSDBC, SDBCX, SDB ArchitectureAccessing Datasources with [PRODUCTNAME]DataSourcesAdding and Editing Datasources Establishing a ConnectionGetting ConnectionsDriver specificsConnection PoolingWorking with Saved QueriesWorking with DataExecuting StatementsResultsetsMetadataRowsetsWorking with the Database DesignUsing DDL to change the DB DesignUsing SDBCX to access the DB DesignUsing DBMS FeaturesStored ProceduresTransaction HandlingExecuting Prepared StatementsWriting Database DriversFormsConceptsModels and ViewsForm Elements in the Document ModelSpecial Form ComponentsEventsData AwarenessRecipesMaking it easier to work with a FormControlling the Data InputCollecting Data automaticallyTaking Advantage of Database Server FeaturesAdding new FunctionalityHandling ErrorsUCBPurpose of UCBAccessing ContentsOpening Folder ContentsOpening Document Contents as StreamsWorking with Content PropertiesCreating, Moving and Copying Document and Folder ContentsWorking with Additional CommandsWriting a Content Provider[PRODUCTNAME] ConfigurationAccessing configuration dataWriting Configuration DataAppendix + +Programmer's ManualPlanned OutlinePreface (3 Pages)First Steps (24 Pages)Programming with UNOFields of Application for UNOGetting StartedRequired FilesConfigurationFirst ConnectionHow to get Objects in [PRODUCTNAME]How to work with ObjectsExampleServicesQuerying InterfacesUsing PropertiesElementAccessSimple TypesStringsEnums and Constant GroupsStructsAnySequenceHow to find the solution for a problemFinding your Way through the API ReferenceCommon MechanismsTextTableDrawingUNO in Professional Projects (145)IntroductionUNO/API constituents: How UNOIDL/API, ServiceManager, Bridges, CoreReflection work togetherAPI ConceptsAPI is a language independent, abstract specification for UNO objects which are used in [PRODUCTNAME]Types in the API ReferenceSimple TypesThe Any TypeInterfacesServicesModulesStructsConstant Groups and EnumsSequencesExceptionsAPI PrinciplesRelationship between Specification, Implementation and InstancesObject CompositionUNO ConceptsUNO is an environment for networked object communicationInterprocess ConnectionsServiceManager and ComponentContextUsing UNO InterfacesUsing PropertiesUsing Collections and ContainersEvent ModelException HandlingLifetime ControlObject IdentityLanguage BindingsIntroduction for language bindingJava Language BindingC++ BindingAccess for [PRODUCTNAME] BasicAutomationWriting UNO componentsSpecifying a new ComponentUNOIDL language specificationImplementing a ComponentComponent Development BasicsIntroductionMandatory interfaces: XInterface, XServiceInfo ((from UseInterfaces.CoreInterfaces))"Should be implemented" interfaces: XTypeProvider ((from UseInterfaces.CoreInterfaces ))optional interface: XMain for standalone executionSimple Component in JavaGetting the service manager ((Chapter Java components from unoBindingJava))simple component chapterC++ Component((Automation Component?))Deployment Options for ComponentsComponent RegistrationService Manager ConfigurationXSet InterfaceAdding components during runtime, particularly interesting during developmentServiceManager ContentDynamically modifying the ServiceManagerBootstrapping the Service Manager ((from CppBind chapter))Simple Test ApplicationConfiguring Your Application with Bootstrap ParametersThe UNO ExecutableStandalone Runtime EnvironmentThe UNO executable and XMainConfiguring the Java Runtime EnvironmentThe office and Java ((from UnoBindingJava))Advanced UNODesign PatternsBridging conceptsRequirements for Language Bindings and BridgesNew Scripting EnginesServiceManager and loaderSpecial Interfaces for internal useXUNOTunnelXAggregationUNO Reflection APITypeLibrary and TypeProvidersDifferences from CorbaOffice DevelopmentGlobal Object StructureDesktop EnvironmentFrames and Frame HierarchiesFrame-Controller-Model ParadigmLoading and Saving Office ComponentsDispatch FrameworkCommon FeaturesCommon DialogsDocumentInfoStylesSearch and ReplaceNumber FormatsPackage File FormatsInternationalizationLinguisticSystem IntegrationClipboardFile PickerBridging to the Window SystemText Documents (51,5 Pages)OverviewHandling Text FilesWorking with Text DocumentsNavigatingUsing TextTablesText FieldsBookmarksIndexes and Index MarksReference MarksFootnotes and EndnotesShape Objects in TextRedlineRubyGlobal Document FeaturesControlling a Text DocumentSpreadsheet DocumentsOverviewHandling Spreadsheet FilesWorking with Spreadsheet DocumentsNavigatingEditing SpreadsheetsGlobal Document FeaturesControlling a Spreadsheet DocumentExtending Capabilities of Spreadsheet DocumentsDrawings and PresentationsOverviewHandling Draw/Impress FilesSavingPrintingRunning PresentationsWorking with a Draw/Impress DocumentNavigatingWorking with Draw/Impress DocumentsGlobal Document FeaturesControlling a Draw/Impress DocumentChartsChart BasicsCreating a Chart DocumentEditing a Chart DocumentCommon Diagram APIDifferent Chart TypesExtending Capabilities of Chart DocumentsBasic and DialogsIntroductionLibrary OrganizationIDE with Dialogs and EventsUsing [PRODUCTNAME] BasicToolkit Controls and their PropertiesCreating Dialogs at RuntimeDatabase AccessFeatures of the [PRODUCTNAME] Database IntegrationCapabilitiesSDBC, SDBCX, SDB ArchitectureAccessing Datasources with [PRODUCTNAME]DataSourcesAdding and Editing Datasources Establishing a ConnectionGetting ConnectionsDriver specificsConnection PoolingWorking with Saved QueriesWorking with DataExecuting StatementsResultsetsMetadataRowsetsWorking with the Database DesignUsing DDL to change the DB DesignUsing SDBCX to access the DB DesignUsing DBMS FeaturesStored ProceduresTransaction HandlingExecuting Prepared StatementsWriting Database DriversFormsConceptsModels and ViewsForm Elements in the Document ModelSpecial Form ComponentsEventsData AwarenessRecipesMaking it easier to work with a FormControlling the Data InputCollecting Data automaticallyTaking Advantage of Database Server FeaturesAdding new FunctionalityHandling ErrorsUCBPurpose of UCBAccessing ContentsOpening Folder ContentsOpening Document Contents as StreamsWorking with Content PropertiesCreating, Moving and Copying Document and Folder ContentsWorking with Additional CommandsWriting a Content Provider[PRODUCTNAME] ConfigurationAccessing configuration dataWriting Configuration DataAppendix + +Programmer's ManualPlanned OutlinePreface (3 Pages)First Steps (24 Pages)Programming with UNOFields of Application for UNOGetting StartedRequired FilesConfigurationFirst ConnectionHow to get Objects in [PRODUCTNAME]How to work with ObjectsExampleServicesQuerying InterfacesUsing PropertiesElementAccessSimple TypesStringsEnums and Constant GroupsStructsAnySequenceHow to find the solution for a problemFinding your Way through the API ReferenceCommon MechanismsTextTableDrawingUNO in Professional Projects (145)IntroductionUNO/API constituents: How UNOIDL/API, ServiceManager, Bridges, CoreReflection work togetherAPI ConceptsAPI is a language independent, abstract specification for UNO objects which are used in [PRODUCTNAME]Types in the API ReferenceSimple TypesThe Any TypeInterfacesServicesModulesStructsConstant Groups and EnumsSequencesExceptionsAPI PrinciplesRelationship between Specification, Implementation and InstancesObject CompositionUNO ConceptsUNO is an environment for networked object communicationInterprocess ConnectionsServiceManager and ComponentContextUsing UNO InterfacesUsing PropertiesUsing Collections and ContainersEvent ModelException HandlingLifetime ControlObject IdentityLanguage BindingsIntroduction for language bindingJava Language BindingC++ BindingAccess for [PRODUCTNAME] BasicAutomationWriting UNO componentsSpecifying a new ComponentUNOIDL language specificationImplementing a ComponentComponent Development BasicsIntroductionMandatory interfaces: XInterface, XServiceInfo ((from UseInterfaces.CoreInterfaces))"Should be implemented" interfaces: XTypeProvider ((from UseInterfaces.CoreInterfaces ))optional interface: XMain for standalone executionSimple Component in JavaGetting the service manager ((Chapter Java components from unoBindingJava))simple component chapterC++ Component((Automation Component?))Deployment Options for ComponentsComponent RegistrationService Manager ConfigurationXSet InterfaceAdding components during runtime, particularly interesting during developmentServiceManager ContentDynamically modifying the ServiceManagerBootstrapping the Service Manager ((from CppBind chapter))Simple Test ApplicationConfiguring Your Application with Bootstrap ParametersThe UNO ExecutableStandalone Runtime EnvironmentThe UNO executable and XMainConfiguring the Java Runtime EnvironmentThe office and Java ((from UnoBindingJava))Advanced UNODesign PatternsBridging conceptsRequirements for Language Bindings and BridgesNew Scripting EnginesServiceManager and loaderSpecial Interfaces for internal useXUNOTunnelXAggregationUNO Reflection APITypeLibrary and TypeProvidersDifferences from CorbaOffice DevelopmentGlobal Object StructureDesktop EnvironmentFrames and Frame HierarchiesFrame-Controller-Model ParadigmLoading and Saving Office ComponentsDispatch FrameworkCommon FeaturesCommon DialogsDocumentInfoStylesSearch and ReplaceNumber FormatsPackage File FormatsInternationalizationLinguisticSystem IntegrationClipboardFile PickerBridging to the Window SystemText Documents (51,5 Pages)OverviewHandling Text FilesWorking with Text DocumentsNavigatingUsing TextTablesText FieldsBookmarksIndexes and Index MarksReference MarksFootnotes and EndnotesShape Objects in TextRedlineRubyGlobal Document FeaturesControlling a Text DocumentSpreadsheet DocumentsOverviewHandling Spreadsheet FilesWorking with Spreadsheet DocumentsNavigatingEditing SpreadsheetsGlobal Document FeaturesControlling a Spreadsheet DocumentExtending Capabilities of Spreadsheet DocumentsDrawings and PresentationsOverviewHandling Draw/Impress FilesSavingPrintingRunning PresentationsWorking with a Draw/Impress DocumentNavigatingWorking with Draw/Impress DocumentsGlobal Document FeaturesControlling a Draw/Impress DocumentChartsChart BasicsCreating a Chart DocumentEditing a Chart DocumentCommon Diagram APIDifferent Chart TypesExtending Capabilities of Chart DocumentsBasic and DialogsIntroductionLibrary OrganizationIDE with Dialogs and EventsUsing [PRODUCTNAME] BasicToolkit Controls and their PropertiesCreating Dialogs at RuntimeDatabase AccessFeatures of the [PRODUCTNAME] Database IntegrationCapabilitiesSDBC, SDBCX, SDB ArchitectureAccessing Datasources with [PRODUCTNAME]DataSourcesAdding and Editing Datasources Establishing a ConnectionGetting ConnectionsDriver specificsConnection PoolingWorking with Saved QueriesWorking with DataExecuting StatementsResultsetsMetadataRowsetsWorking with the Database DesignUsing DDL to change the DB DesignUsing SDBCX to access the DB DesignUsing DBMS FeaturesStored ProceduresTransaction HandlingExecuting Prepared StatementsWriting Database DriversFormsConceptsModels and ViewsForm Elements in the Document ModelSpecial Form ComponentsEventsData AwarenessRecipesMaking it easier to work with a FormControlling the Data InputCollecting Data automaticallyTaking Advantage of Database Server FeaturesAdding new FunctionalityHandling ErrorsUCBPurpose of UCBAccessing ContentsOpening Folder ContentsOpening Document Contents as StreamsWorking with Content PropertiesCreating, Moving and Copying Document and Folder ContentsWorking with Additional CommandsWriting a Content Provider[PRODUCTNAME] ConfigurationAccessing configuration dataWriting Configuration DataAppendix + +Programmer's ManualPlanned OutlinePreface (3 Pages)First Steps (24 Pages)Programming with UNOFields of Application for UNOGetting StartedRequired FilesConfigurationFirst ConnectionHow to get Objects in [PRODUCTNAME]How to work with ObjectsExampleServicesQuerying InterfacesUsing PropertiesElementAccessSimple TypesStringsEnums and Constant GroupsStructsAnySequenceHow to find the solution for a problemFinding your Way through the API ReferenceCommon MechanismsTextTableDrawingUNO in Professional Projects (145)IntroductionUNO/API constituents: How UNOIDL/API, ServiceManager, Bridges, CoreReflection work togetherAPI ConceptsAPI is a language independent, abstract specification for UNO objects which are used in [PRODUCTNAME]Types in the API ReferenceSimple TypesThe Any TypeInterfacesServicesModulesStructsConstant Groups and EnumsSequencesExceptionsAPI PrinciplesRelationship between Specification, Implementation and InstancesObject CompositionUNO ConceptsUNO is an environment for networked object communicationInterprocess ConnectionsServiceManager and ComponentContextUsing UNO InterfacesUsing PropertiesUsing Collections and ContainersEvent ModelException HandlingLifetime ControlObject IdentityLanguage BindingsIntroduction for language bindingJava Language BindingC++ BindingAccess for [PRODUCTNAME] BasicAutomationWriting UNO componentsSpecifying a new ComponentUNOIDL language specificationImplementing a ComponentComponent Development BasicsIntroductionMandatory interfaces: XInterface, XServiceInfo ((from UseInterfaces.CoreInterfaces))"Should be implemented" interfaces: XTypeProvider ((from UseInterfaces.CoreInterfaces ))optional interface: XMain for standalone executionSimple Component in JavaGetting the service manager ((Chapter Java components from unoBindingJava))simple component chapterC++ Component((Automation Component?))Deployment Options for ComponentsComponent RegistrationService Manager ConfigurationXSet InterfaceAdding components during runtime, particularly interesting during developmentServiceManager ContentDynamically modifying the ServiceManagerBootstrapping the Service Manager ((from CppBind chapter))Simple Test ApplicationConfiguring Your Application with Bootstrap ParametersThe UNO ExecutableStandalone Runtime EnvironmentThe UNO executable and XMainConfiguring the Java Runtime EnvironmentThe office and Java ((from UnoBindingJava))Advanced UNODesign PatternsBridging conceptsRequirements for Language Bindings and BridgesNew Scripting EnginesServiceManager and loaderSpecial Interfaces for internal useXUNOTunnelXAggregationUNO Reflection APITypeLibrary and TypeProvidersDifferences from CorbaOffice DevelopmentGlobal Object StructureDesktop EnvironmentFrames and Frame HierarchiesFrame-Controller-Model ParadigmLoading and Saving Office ComponentsDispatch FrameworkCommon FeaturesCommon DialogsDocumentInfoStylesSearch and ReplaceNumber FormatsPackage File FormatsInternationalizationLinguisticSystem IntegrationClipboardFile PickerBridging to the Window SystemText Documents (51,5 Pages)OverviewHandling Text FilesWorking with Text DocumentsNavigatingUsing TextTablesText FieldsBookmarksIndexes and Index MarksReference MarksFootnotes and EndnotesShape Objects in TextRedlineRubyGlobal Document FeaturesControlling a Text DocumentSpreadsheet DocumentsOverviewHandling Spreadsheet FilesWorking with Spreadsheet DocumentsNavigatingEditing SpreadsheetsGlobal Document FeaturesControlling a Spreadsheet DocumentExtending Capabilities of Spreadsheet DocumentsDrawings and PresentationsOverviewHandling Draw/Impress FilesSavingPrintingRunning PresentationsWorking with a Draw/Impress DocumentNavigatingWorking with Draw/Impress DocumentsGlobal Document FeaturesControlling a Draw/Impress DocumentChartsChart BasicsCreating a Chart DocumentEditing a Chart DocumentCommon Diagram APIDifferent Chart TypesExtending Capabilities of Chart DocumentsBasic and DialogsIntroductionLibrary OrganizationIDE with Dialogs and EventsUsing [PRODUCTNAME] BasicToolkit Controls and their PropertiesCreating Dialogs at RuntimeDatabase AccessFeatures of the [PRODUCTNAME] Database IntegrationCapabilitiesSDBC, SDBCX, SDB ArchitectureAccessing Datasources with [PRODUCTNAME]DataSourcesAdding and Editing Datasources Establishing a ConnectionGetting ConnectionsDriver specificsConnection PoolingWorking with Saved QueriesWorking with DataExecuting StatementsResultsetsMetadataRowsetsWorking with the Database DesignUsing DDL to change the DB DesignUsing SDBCX to access the DB DesignUsing DBMS FeaturesStored ProceduresTransaction HandlingExecuting Prepared StatementsWriting Database DriversFormsConceptsModels and ViewsForm Elements in the Document ModelSpecial Form ComponentsEventsData AwarenessRecipesMaking it easier to work with a FormControlling the Data InputCollecting Data automaticallyTaking Advantage of Database Server FeaturesAdding new FunctionalityHandling ErrorsUCBPurpose of UCBAccessing ContentsOpening Folder ContentsOpening Document Contents as StreamsWorking with Content PropertiesCreating, Moving and Copying Document and Folder ContentsWorking with Additional CommandsWriting a Content Provider[PRODUCTNAME] ConfigurationAccessing configuration dataWriting Configuration DataAppendix + +Programmer's ManualPlanned OutlinePreface (3 Pages)First Steps (24 Pages)Programming with UNOFields of Application for UNOGetting StartedRequired FilesConfigurationFirst ConnectionHow to get Objects in [PRODUCTNAME]How to work with ObjectsExampleServicesQuerying InterfacesUsing PropertiesElementAccessSimple TypesStringsEnums and Constant GroupsStructsAnySequenceHow to find the solution for a problemFinding your Way through the API ReferenceCommon MechanismsTextTableDrawingUNO in Professional Projects (145)IntroductionUNO/API constituents: How UNOIDL/API, ServiceManager, Bridges, CoreReflection work togetherAPI ConceptsAPI is a language independent, abstract specification for UNO objects which are used in [PRODUCTNAME]Types in the API ReferenceSimple TypesThe Any TypeInterfacesServicesModulesStructsConstant Groups and EnumsSequencesExceptionsAPI PrinciplesRelationship between Specification, Implementation and InstancesObject CompositionUNO ConceptsUNO is an environment for networked object communicationInterprocess ConnectionsServiceManager and ComponentContextUsing UNO InterfacesUsing PropertiesUsing Collections and ContainersEvent ModelException HandlingLifetime ControlObject IdentityLanguage BindingsIntroduction for language bindingJava Language BindingC++ BindingAccess for [PRODUCTNAME] BasicAutomationWriting UNO componentsSpecifying a new ComponentUNOIDL language specificationImplementing a ComponentComponent Development BasicsIntroductionMandatory interfaces: XInterface, XServiceInfo ((from UseInterfaces.CoreInterfaces))"Should be implemented" interfaces: XTypeProvider ((from UseInterfaces.CoreInterfaces ))optional interface: XMain for standalone executionSimple Component in JavaGetting the service manager ((Chapter Java components from unoBindingJava))simple component chapterC++ Component((Automation Component?))Deployment Options for ComponentsComponent RegistrationService Manager ConfigurationXSet InterfaceAdding components during runtime, particularly interesting during developmentServiceManager ContentDynamically modifying the ServiceManagerBootstrapping the Service Manager ((from CppBind chapter))Simple Test ApplicationConfiguring Your Application with Bootstrap ParametersThe UNO ExecutableStandalone Runtime EnvironmentThe UNO executable and XMainConfiguring the Java Runtime EnvironmentThe office and Java ((from UnoBindingJava))Advanced UNODesign PatternsBridging conceptsRequirements for Language Bindings and BridgesNew Scripting EnginesServiceManager and loaderSpecial Interfaces for internal useXUNOTunnelXAggregationUNO Reflection APITypeLibrary and TypeProvidersDifferences from CorbaOffice DevelopmentGlobal Object StructureDesktop EnvironmentFrames and Frame HierarchiesFrame-Controller-Model ParadigmLoading and Saving Office ComponentsDispatch FrameworkCommon FeaturesCommon DialogsDocumentInfoStylesSearch and ReplaceNumber FormatsPackage File FormatsInternationalizationLinguisticSystem IntegrationClipboardFile PickerBridging to the Window SystemText Documents (51,5 Pages)OverviewHandling Text FilesWorking with Text DocumentsNavigatingUsing TextTablesText FieldsBookmarksIndexes and Index MarksReference MarksFootnotes and EndnotesShape Objects in TextRedlineRubyGlobal Document FeaturesControlling a Text DocumentSpreadsheet DocumentsOverviewHandling Spreadsheet FilesWorking with Spreadsheet DocumentsNavigatingEditing SpreadsheetsGlobal Document FeaturesControlling a Spreadsheet DocumentExtending Capabilities of Spreadsheet DocumentsDrawings and PresentationsOverviewHandling Draw/Impress FilesSavingPrintingRunning PresentationsWorking with a Draw/Impress DocumentNavigatingWorking with Draw/Impress DocumentsGlobal Document FeaturesControlling a Draw/Impress DocumentChartsChart BasicsCreating a Chart DocumentEditing a Chart DocumentCommon Diagram APIDifferent Chart TypesExtending Capabilities of Chart DocumentsBasic and DialogsIntroductionLibrary OrganizationIDE with Dialogs and EventsUsing [PRODUCTNAME] BasicToolkit Controls and their PropertiesCreating Dialogs at RuntimeDatabase AccessFeatures of the [PRODUCTNAME] Database IntegrationCapabilitiesSDBC, SDBCX, SDB ArchitectureAccessing Datasources with [PRODUCTNAME]DataSourcesAdding and Editing Datasources Establishing a ConnectionGetting ConnectionsDriver specificsConnection PoolingWorking with Saved QueriesWorking with DataExecuting StatementsResultsetsMetadataRowsetsWorking with the Database DesignUsing DDL to change the DB DesignUsing SDBCX to access the DB DesignUsing DBMS FeaturesStored ProceduresTransaction HandlingExecuting Prepared StatementsWriting Database DriversFormsConceptsModels and ViewsForm Elements in the Document ModelSpecial Form ComponentsEventsData AwarenessRecipesMaking it easier to work with a FormControlling the Data InputCollecting Data automaticallyTaking Advantage of Database Server FeaturesAdding new FunctionalityHandling ErrorsUCBPurpose of UCBAccessing ContentsOpening Folder ContentsOpening Document Contents as StreamsWorking with Content PropertiesCreating, Moving and Copying Document and Folder ContentsWorking with Additional CommandsWriting a Content Provider[PRODUCTNAME] ConfigurationAccessing configuration dataWriting Configuration DataAppendix + +Programmer's ManualPlanned OutlinePreface (3 Pages)First Steps (24 Pages)Programming with UNOFields of Application for UNOGetting StartedRequired FilesConfigurationFirst ConnectionHow to get Objects in [PRODUCTNAME]How to work with ObjectsExampleServicesQuerying InterfacesUsing PropertiesElementAccessSimple TypesStringsEnums and Constant GroupsStructsAnySequenceHow to find the solution for a problemFinding your Way through the API ReferenceCommon MechanismsTextTableDrawingUNO in Professional Projects (145)IntroductionUNO/API constituents: How UNOIDL/API, ServiceManager, Bridges, CoreReflection work togetherAPI ConceptsAPI is a language independent, abstract specification for UNO objects which are used in [PRODUCTNAME]Types in the API ReferenceSimple TypesThe Any TypeInterfacesServicesModulesStructsConstant Groups and EnumsSequencesExceptionsAPI PrinciplesRelationship between Specification, Implementation and InstancesObject CompositionUNO ConceptsUNO is an environment for networked object communicationInterprocess ConnectionsServiceManager and ComponentContextUsing UNO InterfacesUsing PropertiesUsing Collections and ContainersEvent ModelException HandlingLifetime ControlObject IdentityLanguage BindingsIntroduction for language bindingJava Language BindingC++ BindingAccess for [PRODUCTNAME] BasicAutomationWriting UNO componentsSpecifying a new ComponentUNOIDL language specificationImplementing a ComponentComponent Development BasicsIntroductionMandatory interfaces: XInterface, XServiceInfo ((from UseInterfaces.CoreInterfaces))"Should be implemented" interfaces: XTypeProvider ((from UseInterfaces.CoreInterfaces ))optional interface: XMain for standalone executionSimple Component in JavaGetting the service manager ((Chapter Java components from unoBindingJava))simple component chapterC++ Component((Automation Component?))Deployment Options for ComponentsComponent RegistrationService Manager ConfigurationXSet InterfaceAdding components during runtime, particularly interesting during developmentServiceManager ContentDynamically modifying the ServiceManagerBootstrapping the Service Manager ((from CppBind chapter))Simple Test ApplicationConfiguring Your Application with Bootstrap ParametersThe UNO ExecutableStandalone Runtime EnvironmentThe UNO executable and XMainConfiguring the Java Runtime EnvironmentThe office and Java ((from UnoBindingJava))Advanced UNODesign PatternsBridging conceptsRequirements for Language Bindings and BridgesNew Scripting EnginesServiceManager and loaderSpecial Interfaces for internal useXUNOTunnelXAggregationUNO Reflection APITypeLibrary and TypeProvidersDifferences from CorbaOffice DevelopmentGlobal Object StructureDesktop EnvironmentFrames and Frame HierarchiesFrame-Controller-Model ParadigmLoading and Saving Office ComponentsDispatch FrameworkCommon FeaturesCommon DialogsDocumentInfoStylesSearch and ReplaceNumber FormatsPackage File FormatsInternationalizationLinguisticSystem IntegrationClipboardFile PickerBridging to the Window SystemText Documents (51,5 Pages)OverviewHandling Text FilesWorking with Text DocumentsNavigatingUsing TextTablesText FieldsBookmarksIndexes and Index MarksReference MarksFootnotes and EndnotesShape Objects in TextRedlineRubyGlobal Document FeaturesControlling a Text DocumentSpreadsheet DocumentsOverviewHandling Spreadsheet FilesWorking with Spreadsheet DocumentsNavigatingEditing SpreadsheetsGlobal Document FeaturesControlling a Spreadsheet DocumentExtending Capabilities of Spreadsheet DocumentsDrawings and PresentationsOverviewHandling Draw/Impress FilesSavingPrintingRunning PresentationsWorking with a Draw/Impress DocumentNavigatingWorking with Draw/Impress DocumentsGlobal Document FeaturesControlling a Draw/Impress DocumentChartsChart BasicsCreating a Chart DocumentEditing a Chart DocumentCommon Diagram APIDifferent Chart TypesExtending Capabilities of Chart DocumentsBasic and DialogsIntroductionLibrary OrganizationIDE with Dialogs and EventsUsing [PRODUCTNAME] BasicToolkit Controls and their PropertiesCreating Dialogs at RuntimeDatabase AccessFeatures of the [PRODUCTNAME] Database IntegrationCapabilitiesSDBC, SDBCX, SDB ArchitectureAccessing Datasources with [PRODUCTNAME]DataSourcesAdding and Editing Datasources Establishing a ConnectionGetting ConnectionsDriver specificsConnection PoolingWorking with Saved QueriesWorking with DataExecuting StatementsResultsetsMetadataRowsetsWorking with the Database DesignUsing DDL to change the DB DesignUsing SDBCX to access the DB DesignUsing DBMS FeaturesStored ProceduresTransaction HandlingExecuting Prepared StatementsWriting Database DriversFormsConceptsModels and ViewsForm Elements in the Document ModelSpecial Form ComponentsEventsData AwarenessRecipesMaking it easier to work with a FormControlling the Data InputCollecting Data automaticallyTaking Advantage of Database Server FeaturesAdding new FunctionalityHandling ErrorsUCBPurpose of UCBAccessing ContentsOpening Folder ContentsOpening Document Contents as StreamsWorking with Content PropertiesCreating, Moving and Copying Document and Folder ContentsWorking with Additional CommandsWriting a Content Provider[PRODUCTNAME] ConfigurationAccessing configuration dataWriting Configuration DataAppendix + +Programmer's ManualPlanned OutlinePreface (3 Pages)First Steps (24 Pages)Programming with UNOFields of Application for UNOGetting StartedRequired FilesConfigurationFirst ConnectionHow to get Objects in [PRODUCTNAME]How to work with ObjectsExampleServicesQuerying InterfacesUsing PropertiesElementAccessSimple TypesStringsEnums and Constant GroupsStructsAnySequenceHow to find the solution for a problemFinding your Way through the API ReferenceCommon MechanismsTextTableDrawingUNO in Professional Projects (145)IntroductionUNO/API constituents: How UNOIDL/API, ServiceManager, Bridges, CoreReflection work togetherAPI ConceptsAPI is a language independent, abstract specification for UNO objects which are used in [PRODUCTNAME]Types in the API ReferenceSimple TypesThe Any TypeInterfacesServicesModulesStructsConstant Groups and EnumsSequencesExceptionsAPI PrinciplesRelationship between Specification, Implementation and InstancesObject CompositionUNO ConceptsUNO is an environment for networked object communicationInterprocess ConnectionsServiceManager and ComponentContextUsing UNO InterfacesUsing PropertiesUsing Collections and ContainersEvent ModelException HandlingLifetime ControlObject IdentityLanguage BindingsIntroduction for language bindingJava Language BindingC++ BindingAccess for [PRODUCTNAME] BasicAutomationWriting UNO componentsSpecifying a new ComponentUNOIDL language specificationImplementing a ComponentComponent Development BasicsIntroductionMandatory interfaces: XInterface, XServiceInfo ((from UseInterfaces.CoreInterfaces))"Should be implemented" interfaces: XTypeProvider ((from UseInterfaces.CoreInterfaces ))optional interface: XMain for standalone executionSimple Component in JavaGetting the service manager ((Chapter Java components from unoBindingJava))simple component chapterC++ Component((Automation Component?))Deployment Options for ComponentsComponent RegistrationService Manager ConfigurationXSet InterfaceAdding components during runtime, particularly interesting during developmentServiceManager ContentDynamically modifying the ServiceManagerBootstrapping the Service Manager ((from CppBind chapter))Simple Test ApplicationConfiguring Your Application with Bootstrap ParametersThe UNO ExecutableStandalone Runtime EnvironmentThe UNO executable and XMainConfiguring the Java Runtime EnvironmentThe office and Java ((from UnoBindingJava))Advanced UNODesign PatternsBridging conceptsRequirements for Language Bindings and BridgesNew Scripting EnginesServiceManager and loaderSpecial Interfaces for internal useXUNOTunnelXAggregationUNO Reflection APITypeLibrary and TypeProvidersDifferences from CorbaOffice DevelopmentGlobal Object StructureDesktop EnvironmentFrames and Frame HierarchiesFrame-Controller-Model ParadigmLoading and Saving Office ComponentsDispatch FrameworkCommon FeaturesCommon DialogsDocumentInfoStylesSearch and ReplaceNumber FormatsPackage File FormatsInternationalizationLinguisticSystem IntegrationClipboardFile PickerBridging to the Window SystemText Documents (51,5 Pages)OverviewHandling Text FilesWorking with Text DocumentsNavigatingUsing TextTablesText FieldsBookmarksIndexes and Index MarksReference MarksFootnotes and EndnotesShape Objects in TextRedlineRubyGlobal Document FeaturesControlling a Text DocumentSpreadsheet DocumentsOverviewHandling Spreadsheet FilesWorking with Spreadsheet DocumentsNavigatingEditing SpreadsheetsGlobal Document FeaturesControlling a Spreadsheet DocumentExtending Capabilities of Spreadsheet DocumentsDrawings and PresentationsOverviewHandling Draw/Impress FilesSavingPrintingRunning PresentationsWorking with a Draw/Impress DocumentNavigatingWorking with Draw/Impress DocumentsGlobal Document FeaturesControlling a Draw/Impress DocumentChartsChart BasicsCreating a Chart DocumentEditing a Chart DocumentCommon Diagram APIDifferent Chart TypesExtending Capabilities of Chart DocumentsBasic and DialogsIntroductionLibrary OrganizationIDE with Dialogs and EventsUsing [PRODUCTNAME] BasicToolkit Controls and their PropertiesCreating Dialogs at RuntimeDatabase AccessFeatures of the [PRODUCTNAME] Database IntegrationCapabilitiesSDBC, SDBCX, SDB ArchitectureAccessing Datasources with [PRODUCTNAME]DataSourcesAdding and Editing Datasources Establishing a ConnectionGetting ConnectionsDriver specificsConnection PoolingWorking with Saved QueriesWorking with DataExecuting StatementsResultsetsMetadataRowsetsWorking with the Database DesignUsing DDL to change the DB DesignUsing SDBCX to access the DB DesignUsing DBMS FeaturesStored ProceduresTransaction HandlingExecuting Prepared StatementsWriting Database DriversFormsConceptsModels and ViewsForm Elements in the Document ModelSpecial Form ComponentsEventsData AwarenessRecipesMaking it easier to work with a FormControlling the Data InputCollecting Data automaticallyTaking Advantage of Database Server FeaturesAdding new FunctionalityHandling ErrorsUCBPurpose of UCBAccessing ContentsOpening Folder ContentsOpening Document Contents as StreamsWorking with Content PropertiesCreating, Moving and Copying Document and Folder ContentsWorking with Additional CommandsWriting a Content Provider[PRODUCTNAME] ConfigurationAccessing configuration dataWriting Configuration DataAppendix + +Programmer's ManualPlanned OutlinePreface (3 Pages)First Steps (24 Pages)Programming with UNOFields of Application for UNOGetting StartedRequired FilesConfigurationFirst ConnectionHow to get Objects in [PRODUCTNAME]How to work with ObjectsExampleServicesQuerying InterfacesUsing PropertiesElementAccessSimple TypesStringsEnums and Constant GroupsStructsAnySequenceHow to find the solution for a problemFinding your Way through the API ReferenceCommon MechanismsTextTableDrawingUNO in Professional Projects (145)IntroductionUNO/API constituents: How UNOIDL/API, ServiceManager, Bridges, CoreReflection work togetherAPI ConceptsAPI is a language independent, abstract specification for UNO objects which are used in [PRODUCTNAME]Types in the API ReferenceSimple TypesThe Any TypeInterfacesServicesModulesStructsConstant Groups and EnumsSequencesExceptionsAPI PrinciplesRelationship between Specification, Implementation and InstancesObject CompositionUNO ConceptsUNO is an environment for networked object communicationInterprocess ConnectionsServiceManager and ComponentContextUsing UNO InterfacesUsing PropertiesUsing Collections and ContainersEvent ModelException HandlingLifetime ControlObject IdentityLanguage BindingsIntroduction for language bindingJava Language BindingC++ BindingAccess for [PRODUCTNAME] BasicAutomationWriting UNO componentsSpecifying a new ComponentUNOIDL language specificationImplementing a ComponentComponent Development BasicsIntroductionMandatory interfaces: XInterface, XServiceInfo ((from UseInterfaces.CoreInterfaces))"Should be implemented" interfaces: XTypeProvider ((from UseInterfaces.CoreInterfaces ))optional interface: XMain for standalone executionSimple Component in JavaGetting the service manager ((Chapter Java components from unoBindingJava))simple component chapterC++ Component((Automation Component?))Deployment Options for ComponentsComponent RegistrationService Manager ConfigurationXSet InterfaceAdding components during runtime, particularly interesting during developmentServiceManager ContentDynamically modifying the ServiceManagerBootstrapping the Service Manager ((from CppBind chapter))Simple Test ApplicationConfiguring Your Application with Bootstrap ParametersThe UNO ExecutableStandalone Runtime EnvironmentThe UNO executable and XMainConfiguring the Java Runtime EnvironmentThe office and Java ((from UnoBindingJava))Advanced UNODesign PatternsBridging conceptsRequirements for Language Bindings and BridgesNew Scripting EnginesServiceManager and loaderSpecial Interfaces for internal useXUNOTunnelXAggregationUNO Reflection APITypeLibrary and TypeProvidersDifferences from CorbaOffice DevelopmentGlobal Object StructureDesktop EnvironmentFrames and Frame HierarchiesFrame-Controller-Model ParadigmLoading and Saving Office ComponentsDispatch FrameworkCommon FeaturesCommon DialogsDocumentInfoStylesSearch and ReplaceNumber FormatsPackage File FormatsInternationalizationLinguisticSystem IntegrationClipboardFile PickerBridging to the Window SystemText Documents (51,5 Pages)OverviewHandling Text FilesWorking with Text DocumentsNavigatingUsing TextTablesText FieldsBookmarksIndexes and Index MarksReference MarksFootnotes and EndnotesShape Objects in TextRedlineRubyGlobal Document FeaturesControlling a Text DocumentSpreadsheet DocumentsOverviewHandling Spreadsheet FilesWorking with Spreadsheet DocumentsNavigatingEditing SpreadsheetsGlobal Document FeaturesControlling a Spreadsheet DocumentExtending Capabilities of Spreadsheet DocumentsDrawings and PresentationsOverviewHandling Draw/Impress FilesSavingPrintingRunning PresentationsWorking with a Draw/Impress DocumentNavigatingWorking with Draw/Impress DocumentsGlobal Document FeaturesControlling a Draw/Impress DocumentChartsChart BasicsCreating a Chart DocumentEditing a Chart DocumentCommon Diagram APIDifferent Chart TypesExtending Capabilities of Chart DocumentsBasic and DialogsIntroductionLibrary OrganizationIDE with Dialogs and EventsUsing [PRODUCTNAME] BasicToolkit Controls and their PropertiesCreating Dialogs at RuntimeDatabase AccessFeatures of the [PRODUCTNAME] Database IntegrationCapabilitiesSDBC, SDBCX, SDB ArchitectureAccessing Datasources with [PRODUCTNAME]DataSourcesAdding and Editing Datasources Establishing a ConnectionGetting ConnectionsDriver specificsConnection PoolingWorking with Saved QueriesWorking with DataExecuting StatementsResultsetsMetadataRowsetsWorking with the Database DesignUsing DDL to change the DB DesignUsing SDBCX to access the DB DesignUsing DBMS FeaturesStored ProceduresTransaction HandlingExecuting Prepared StatementsWriting Database DriversFormsConceptsModels and ViewsForm Elements in the Document ModelSpecial Form ComponentsEventsData AwarenessRecipesMaking it easier to work with a FormControlling the Data InputCollecting Data automaticallyTaking Advantage of Database Server FeaturesAdding new FunctionalityHandling ErrorsUCBPurpose of UCBAccessing ContentsOpening Folder ContentsOpening Document Contents as StreamsWorking with Content PropertiesCreating, Moving and Copying Document and Folder ContentsWorking with Additional CommandsWriting a Content Provider[PRODUCTNAME] ConfigurationAccessing configuration dataWriting Configuration DataAppendix + +Programmer's ManualPlanned OutlinePreface (3 Pages)First Steps (24 Pages)Programming with UNOFields of Application for UNOGetting StartedRequired FilesConfigurationFirst ConnectionHow to get Objects in [PRODUCTNAME]How to work with ObjectsExampleServicesQuerying InterfacesUsing PropertiesElementAccessSimple TypesStringsEnums and Constant GroupsStructsAnySequenceHow to find the solution for a problemFinding your Way through the API ReferenceCommon MechanismsTextTableDrawingUNO in Professional Projects (145)IntroductionUNO/API constituents: How UNOIDL/API, ServiceManager, Bridges, CoreReflection work togetherAPI ConceptsAPI is a language independent, abstract specification for UNO objects which are used in [PRODUCTNAME]Types in the API ReferenceSimple TypesThe Any TypeInterfacesServicesModulesStructsConstant Groups and EnumsSequencesExceptionsAPI PrinciplesRelationship between Specification, Implementation and InstancesObject CompositionUNO ConceptsUNO is an environment for networked object communicationInterprocess ConnectionsServiceManager and ComponentContextUsing UNO InterfacesUsing PropertiesUsing Collections and ContainersEvent ModelException HandlingLifetime ControlObject IdentityLanguage BindingsIntroduction for language bindingJava Language BindingC++ BindingAccess for [PRODUCTNAME] BasicAutomationWriting UNO componentsSpecifying a new ComponentUNOIDL language specificationImplementing a ComponentComponent Development BasicsIntroductionMandatory interfaces: XInterface, XServiceInfo ((from UseInterfaces.CoreInterfaces))"Should be implemented" interfaces: XTypeProvider ((from UseInterfaces.CoreInterfaces ))optional interface: XMain for standalone executionSimple Component in JavaGetting the service manager ((Chapter Java components from unoBindingJava))simple component chapterC++ Component((Automation Component?))Deployment Options for ComponentsComponent RegistrationService Manager ConfigurationXSet InterfaceAdding components during runtime, particularly interesting during developmentServiceManager ContentDynamically modifying the ServiceManagerBootstrapping the Service Manager ((from CppBind chapter))Simple Test ApplicationConfiguring Your Application with Bootstrap ParametersThe UNO ExecutableStandalone Runtime EnvironmentThe UNO executable and XMainConfiguring the Java Runtime EnvironmentThe office and Java ((from UnoBindingJava))Advanced UNODesign PatternsBridging conceptsRequirements for Language Bindings and BridgesNew Scripting EnginesServiceManager and loaderSpecial Interfaces for internal useXUNOTunnelXAggregationUNO Reflection APITypeLibrary and TypeProvidersDifferences from CorbaOffice DevelopmentGlobal Object StructureDesktop EnvironmentFrames and Frame HierarchiesFrame-Controller-Model ParadigmLoading and Saving Office ComponentsDispatch FrameworkCommon FeaturesCommon DialogsDocumentInfoStylesSearch and ReplaceNumber FormatsPackage File FormatsInternationalizationLinguisticSystem IntegrationClipboardFile PickerBridging to the Window SystemText Documents (51,5 Pages)OverviewHandling Text FilesWorking with Text DocumentsNavigatingUsing TextTablesText FieldsBookmarksIndexes and Index MarksReference MarksFootnotes and EndnotesShape Objects in TextRedlineRubyGlobal Document FeaturesControlling a Text DocumentSpreadsheet DocumentsOverviewHandling Spreadsheet FilesWorking with Spreadsheet DocumentsNavigatingEditing SpreadsheetsGlobal Document FeaturesControlling a Spreadsheet DocumentExtending Capabilities of Spreadsheet DocumentsDrawings and PresentationsOverviewHandling Draw/Impress FilesSavingPrintingRunning PresentationsWorking with a Draw/Impress DocumentNavigatingWorking with Draw/Impress DocumentsGlobal Document FeaturesControlling a Draw/Impress DocumentChartsChart BasicsCreating a Chart DocumentEditing a Chart DocumentCommon Diagram APIDifferent Chart TypesExtending Capabilities of Chart DocumentsBasic and DialogsIntroductionLibrary OrganizationIDE with Dialogs and EventsUsing [PRODUCTNAME] BasicToolkit Controls and their PropertiesCreating Dialogs at RuntimeDatabase AccessFeatures of the [PRODUCTNAME] Database IntegrationCapabilitiesSDBC, SDBCX, SDB ArchitectureAccessing Datasources with [PRODUCTNAME]DataSourcesAdding and Editing Datasources Establishing a ConnectionGetting ConnectionsDriver specificsConnection PoolingWorking with Saved QueriesWorking with DataExecuting StatementsResultsetsMetadataRowsetsWorking with the Database DesignUsing DDL to change the DB DesignUsing SDBCX to access the DB DesignUsing DBMS FeaturesStored ProceduresTransaction HandlingExecuting Prepared StatementsWriting Database DriversFormsConceptsModels and ViewsForm Elements in the Document ModelSpecial Form ComponentsEventsData AwarenessRecipesMaking it easier to work with a FormControlling the Data InputCollecting Data automaticallyTaking Advantage of Database Server FeaturesAdding new FunctionalityHandling ErrorsUCBPurpose of UCBAccessing ContentsOpening Folder ContentsOpening Document Contents as StreamsWorking with Content PropertiesCreating, Moving and Copying Document and Folder ContentsWorking with Additional CommandsWriting a Content Provider[PRODUCTNAME] ConfigurationAccessing configuration dataWriting Configuration DataAppendix + +Programmer's ManualPlanned OutlinePreface (3 Pages)First Steps (24 Pages)Programming with UNOFields of Application for UNOGetting StartedRequired FilesConfigurationFirst ConnectionHow to get Objects in [PRODUCTNAME]How to work with ObjectsExampleServicesQuerying InterfacesUsing PropertiesElementAccessSimple TypesStringsEnums and Constant GroupsStructsAnySequenceHow to find the solution for a problemFinding your Way through the API ReferenceCommon MechanismsTextTableDrawingUNO in Professional Projects (145)IntroductionUNO/API constituents: How UNOIDL/API, ServiceManager, Bridges, CoreReflection work togetherAPI ConceptsAPI is a language independent, abstract specification for UNO objects which are used in [PRODUCTNAME]Types in the API ReferenceSimple TypesThe Any TypeInterfacesServicesModulesStructsConstant Groups and EnumsSequencesExceptionsAPI PrinciplesRelationship between Specification, Implementation and InstancesObject CompositionUNO ConceptsUNO is an environment for networked object communicationInterprocess ConnectionsServiceManager and ComponentContextUsing UNO InterfacesUsing PropertiesUsing Collections and ContainersEvent ModelException HandlingLifetime ControlObject IdentityLanguage BindingsIntroduction for language bindingJava Language BindingC++ BindingAccess for [PRODUCTNAME] BasicAutomationWriting UNO componentsSpecifying a new ComponentUNOIDL language specificationImplementing a ComponentComponent Development BasicsIntroductionMandatory interfaces: XInterface, XServiceInfo ((from UseInterfaces.CoreInterfaces))"Should be implemented" interfaces: XTypeProvider ((from UseInterfaces.CoreInterfaces ))optional interface: XMain for standalone executionSimple Component in JavaGetting the service manager ((Chapter Java components from unoBindingJava))simple component chapterC++ Component((Automation Component?))Deployment Options for ComponentsComponent RegistrationService Manager ConfigurationXSet InterfaceAdding components during runtime, particularly interesting during developmentServiceManager ContentDynamically modifying the ServiceManagerBootstrapping the Service Manager ((from CppBind chapter))Simple Test ApplicationConfiguring Your Application with Bootstrap ParametersThe UNO ExecutableStandalone Runtime EnvironmentThe UNO executable and XMainConfiguring the Java Runtime EnvironmentThe office and Java ((from UnoBindingJava))Advanced UNODesign PatternsBridging conceptsRequirements for Language Bindings and BridgesNew Scripting EnginesServiceManager and loaderSpecial Interfaces for internal useXUNOTunnelXAggregationUNO Reflection APITypeLibrary and TypeProvidersDifferences from CorbaOffice DevelopmentGlobal Object StructureDesktop EnvironmentFrames and Frame HierarchiesFrame-Controller-Model ParadigmLoading and Saving Office ComponentsDispatch FrameworkCommon FeaturesCommon DialogsDocumentInfoStylesSearch and ReplaceNumber FormatsPackage File FormatsInternationalizationLinguisticSystem IntegrationClipboardFile PickerBridging to the Window SystemText Documents (51,5 Pages)OverviewHandling Text FilesWorking with Text DocumentsNavigatingUsing TextTablesText FieldsBookmarksIndexes and Index MarksReference MarksFootnotes and EndnotesShape Objects in TextRedlineRubyGlobal Document FeaturesControlling a Text DocumentSpreadsheet DocumentsOverviewHandling Spreadsheet FilesWorking with Spreadsheet DocumentsNavigatingEditing SpreadsheetsGlobal Document FeaturesControlling a Spreadsheet DocumentExtending Capabilities of Spreadsheet DocumentsDrawings and PresentationsOverviewHandling Draw/Impress FilesSavingPrintingRunning PresentationsWorking with a Draw/Impress DocumentNavigatingWorking with Draw/Impress DocumentsGlobal Document FeaturesControlling a Draw/Impress DocumentChartsChart BasicsCreating a Chart DocumentEditing a Chart DocumentCommon Diagram APIDifferent Chart TypesExtending Capabilities of Chart DocumentsBasic and DialogsIntroductionLibrary OrganizationIDE with Dialogs and EventsUsing [PRODUCTNAME] BasicToolkit Controls and their PropertiesCreating Dialogs at RuntimeDatabase AccessFeatures of the [PRODUCTNAME] Database IntegrationCapabilitiesSDBC, SDBCX, SDB ArchitectureAccessing Datasources with [PRODUCTNAME]DataSourcesAdding and Editing Datasources Establishing a ConnectionGetting ConnectionsDriver specificsConnection PoolingWorking with Saved QueriesWorking with DataExecuting StatementsResultsetsMetadataRowsetsWorking with the Database DesignUsing DDL to change the DB DesignUsing SDBCX to access the DB DesignUsing DBMS FeaturesStored ProceduresTransaction HandlingExecuting Prepared StatementsWriting Database DriversFormsConceptsModels and ViewsForm Elements in the Document ModelSpecial Form ComponentsEventsData AwarenessRecipesMaking it easier to work with a FormControlling the Data InputCollecting Data automaticallyTaking Advantage of Database Server FeaturesAdding new FunctionalityHandling ErrorsUCBPurpose of UCBAccessing ContentsOpening Folder ContentsOpening Document Contents as StreamsWorking with Content PropertiesCreating, Moving and Copying Document and Folder ContentsWorking with Additional CommandsWriting a Content Provider[PRODUCTNAME] ConfigurationAccessing configuration dataWriting Configuration DataAppendix + +Programmer's ManualPlanned OutlinePreface (3 Pages)First Steps (24 Pages)Programming with UNOFields of Application for UNOGetting StartedRequired FilesConfigurationFirst ConnectionHow to get Objects in [PRODUCTNAME]How to work with ObjectsExampleServicesQuerying InterfacesUsing PropertiesElementAccessSimple TypesStringsEnums and Constant GroupsStructsAnySequenceHow to find the solution for a problemFinding your Way through the API ReferenceCommon MechanismsTextTableDrawingUNO in Professional Projects (145)IntroductionUNO/API constituents: How UNOIDL/API, ServiceManager, Bridges, CoreReflection work togetherAPI ConceptsAPI is a language independent, abstract specification for UNO objects which are used in [PRODUCTNAME]Types in the API ReferenceSimple TypesThe Any TypeInterfacesServicesModulesStructsConstant Groups and EnumsSequencesExceptionsAPI PrinciplesRelationship between Specification, Implementation and InstancesObject CompositionUNO ConceptsUNO is an environment for networked object communicationInterprocess ConnectionsServiceManager and ComponentContextUsing UNO InterfacesUsing PropertiesUsing Collections and ContainersEvent ModelException HandlingLifetime ControlObject IdentityLanguage BindingsIntroduction for language bindingJava Language BindingC++ BindingAccess for [PRODUCTNAME] BasicAutomationWriting UNO componentsSpecifying a new ComponentUNOIDL language specificationImplementing a ComponentComponent Development BasicsIntroductionMandatory interfaces: XInterface, XServiceInfo ((from UseInterfaces.CoreInterfaces))"Should be implemented" interfaces: XTypeProvider ((from UseInterfaces.CoreInterfaces ))optional interface: XMain for standalone executionSimple Component in JavaGetting the service manager ((Chapter Java components from unoBindingJava))simple component chapterC++ Component((Automation Component?))Deployment Options for ComponentsComponent RegistrationService Manager ConfigurationXSet InterfaceAdding components during runtime, particularly interesting during developmentServiceManager ContentDynamically modifying the ServiceManagerBootstrapping the Service Manager ((from CppBind chapter))Simple Test ApplicationConfiguring Your Application with Bootstrap ParametersThe UNO ExecutableStandalone Runtime EnvironmentThe UNO executable and XMainConfiguring the Java Runtime EnvironmentThe office and Java ((from UnoBindingJava))Advanced UNODesign PatternsBridging conceptsRequirements for Language Bindings and BridgesNew Scripting EnginesServiceManager and loaderSpecial Interfaces for internal useXUNOTunnelXAggregationUNO Reflection APITypeLibrary and TypeProvidersDifferences from CorbaOffice DevelopmentGlobal Object StructureDesktop EnvironmentFrames and Frame HierarchiesFrame-Controller-Model ParadigmLoading and Saving Office ComponentsDispatch FrameworkCommon FeaturesCommon DialogsDocumentInfoStylesSearch and ReplaceNumber FormatsPackage File FormatsInternationalizationLinguisticSystem IntegrationClipboardFile PickerBridging to the Window SystemText Documents (51,5 Pages)OverviewHandling Text FilesWorking with Text DocumentsNavigatingUsing TextTablesText FieldsBookmarksIndexes and Index MarksReference MarksFootnotes and EndnotesShape Objects in TextRedlineRubyGlobal Document FeaturesControlling a Text DocumentSpreadsheet DocumentsOverviewHandling Spreadsheet FilesWorking with Spreadsheet DocumentsNavigatingEditing SpreadsheetsGlobal Document FeaturesControlling a Spreadsheet DocumentExtending Capabilities of Spreadsheet DocumentsDrawings and PresentationsOverviewHandling Draw/Impress FilesSavingPrintingRunning PresentationsWorking with a Draw/Impress DocumentNavigatingWorking with Draw/Impress DocumentsGlobal Document FeaturesControlling a Draw/Impress DocumentChartsChart BasicsCreating a Chart DocumentEditing a Chart DocumentCommon Diagram APIDifferent Chart TypesExtending Capabilities of Chart DocumentsBasic and DialogsIntroductionLibrary OrganizationIDE with Dialogs and EventsUsing [PRODUCTNAME] BasicToolkit Controls and their PropertiesCreating Dialogs at RuntimeDatabase AccessFeatures of the [PRODUCTNAME] Database IntegrationCapabilitiesSDBC, SDBCX, SDB ArchitectureAccessing Datasources with [PRODUCTNAME]DataSourcesAdding and Editing Datasources Establishing a ConnectionGetting ConnectionsDriver specificsConnection PoolingWorking with Saved QueriesWorking with DataExecuting StatementsResultsetsMetadataRowsetsWorking with the Database DesignUsing DDL to change the DB DesignUsing SDBCX to access the DB DesignUsing DBMS FeaturesStored ProceduresTransaction HandlingExecuting Prepared StatementsWriting Database DriversFormsConceptsModels and ViewsForm Elements in the Document ModelSpecial Form ComponentsEventsData AwarenessRecipesMaking it easier to work with a FormControlling the Data InputCollecting Data automaticallyTaking Advantage of Database Server FeaturesAdding new FunctionalityHandling ErrorsUCBPurpose of UCBAccessing ContentsOpening Folder ContentsOpening Document Contents as StreamsWorking with Content PropertiesCreating, Moving and Copying Document and Folder ContentsWorking with Additional CommandsWriting a Content Provider[PRODUCTNAME] ConfigurationAccessing configuration dataWriting Configuration DataAppendix + +Programmer's ManualPlanned OutlinePreface (3 Pages)First Steps (24 Pages)Programming with UNOFields of Application for UNOGetting StartedRequired FilesConfigurationFirst ConnectionHow to get Objects in [PRODUCTNAME]How to work with ObjectsExampleServicesQuerying InterfacesUsing PropertiesElementAccessSimple TypesStringsEnums and Constant GroupsStructsAnySequenceHow to find the solution for a problemFinding your Way through the API ReferenceCommon MechanismsTextTableDrawingUNO in Professional Projects (145)IntroductionUNO/API constituents: How UNOIDL/API, ServiceManager, Bridges, CoreReflection work togetherAPI ConceptsAPI is a language independent, abstract specification for UNO objects which are used in [PRODUCTNAME]Types in the API ReferenceSimple TypesThe Any TypeInterfacesServicesModulesStructsConstant Groups and EnumsSequencesExceptionsAPI PrinciplesRelationship between Specification, Implementation and InstancesObject CompositionUNO ConceptsUNO is an environment for networked object communicationInterprocess ConnectionsServiceManager and ComponentContextUsing UNO InterfacesUsing PropertiesUsing Collections and ContainersEvent ModelException HandlingLifetime ControlObject IdentityLanguage BindingsIntroduction for language bindingJava Language BindingC++ BindingAccess for [PRODUCTNAME] BasicAutomationWriting UNO componentsSpecifying a new ComponentUNOIDL language specificationImplementing a ComponentComponent Development BasicsIntroductionMandatory interfaces: XInterface, XServiceInfo ((from UseInterfaces.CoreInterfaces))"Should be implemented" interfaces: XTypeProvider ((from UseInterfaces.CoreInterfaces ))optional interface: XMain for standalone executionSimple Component in JavaGetting the service manager ((Chapter Java components from unoBindingJava))simple component chapterC++ Component((Automation Component?))Deployment Options for ComponentsComponent RegistrationService Manager ConfigurationXSet InterfaceAdding components during runtime, particularly interesting during developmentServiceManager ContentDynamically modifying the ServiceManagerBootstrapping the Service Manager ((from CppBind chapter))Simple Test ApplicationConfiguring Your Application with Bootstrap ParametersThe UNO ExecutableStandalone Runtime EnvironmentThe UNO executable and XMainConfiguring the Java Runtime EnvironmentThe office and Java ((from UnoBindingJava))Advanced UNODesign PatternsBridging conceptsRequirements for Language Bindings and BridgesNew Scripting EnginesServiceManager and loaderSpecial Interfaces for internal useXUNOTunnelXAggregationUNO Reflection APITypeLibrary and TypeProvidersDifferences from CorbaOffice DevelopmentGlobal Object StructureDesktop EnvironmentFrames and Frame HierarchiesFrame-Controller-Model ParadigmLoading and Saving Office ComponentsDispatch FrameworkCommon FeaturesCommon DialogsDocumentInfoStylesSearch and ReplaceNumber FormatsPackage File FormatsInternationalizationLinguisticSystem IntegrationClipboardFile PickerBridging to the Window SystemText Documents (51,5 Pages)OverviewHandling Text FilesWorking with Text DocumentsNavigatingUsing TextTablesText FieldsBookmarksIndexes and Index MarksReference MarksFootnotes and EndnotesShape Objects in TextRedlineRubyGlobal Document FeaturesControlling a Text DocumentSpreadsheet DocumentsOverviewHandling Spreadsheet FilesWorking with Spreadsheet DocumentsNavigatingEditing SpreadsheetsGlobal Document FeaturesControlling a Spreadsheet DocumentExtending Capabilities of Spreadsheet DocumentsDrawings and PresentationsOverviewHandling Draw/Impress FilesSavingPrintingRunning PresentationsWorking with a Draw/Impress DocumentNavigatingWorking with Draw/Impress DocumentsGlobal Document FeaturesControlling a Draw/Impress DocumentChartsChart BasicsCreating a Chart DocumentEditing a Chart DocumentCommon Diagram APIDifferent Chart TypesExtending Capabilities of Chart DocumentsBasic and DialogsIntroductionLibrary OrganizationIDE with Dialogs and EventsUsing [PRODUCTNAME] BasicToolkit Controls and their PropertiesCreating Dialogs at RuntimeDatabase AccessFeatures of the [PRODUCTNAME] Database IntegrationCapabilitiesSDBC, SDBCX, SDB ArchitectureAccessing Datasources with [PRODUCTNAME]DataSourcesAdding and Editing Datasources Establishing a ConnectionGetting ConnectionsDriver specificsConnection PoolingWorking with Saved QueriesWorking with DataExecuting StatementsResultsetsMetadataRowsetsWorking with the Database DesignUsing DDL to change the DB DesignUsing SDBCX to access the DB DesignUsing DBMS FeaturesStored ProceduresTransaction HandlingExecuting Prepared StatementsWriting Database DriversFormsConceptsModels and ViewsForm Elements in the Document ModelSpecial Form ComponentsEventsData AwarenessRecipesMaking it easier to work with a FormControlling the Data InputCollecting Data automaticallyTaking Advantage of Database Server FeaturesAdding new FunctionalityHandling ErrorsUCBPurpose of UCBAccessing ContentsOpening Folder ContentsOpening Document Contents as StreamsWorking with Content PropertiesCreating, Moving and Copying Document and Folder ContentsWorking with Additional CommandsWriting a Content Provider[PRODUCTNAME] ConfigurationAccessing configuration dataWriting Configuration DataAppendix + + + \ No newline at end of file diff --git a/xmlsecurity/tools/examples/sign-5.xml b/xmlsecurity/tools/examples/sign-5.xml new file mode 100644 index 000000000000..46cb6d609fe5 --- /dev/null +++ b/xmlsecurity/tools/examples/sign-5.xml @@ -0,0 +1,89 @@ + + + + + + + + + + + + + + + + CN=Test Issuer + 123450005 + + + + + + +Programmer's ManualPlanned OutlinePreface (3 Pages)First Steps (24 Pages)Programming with UNOFields of Application for UNOGetting StartedRequired FilesConfigurationFirst ConnectionHow to get Objects in [PRODUCTNAME]How to work with ObjectsExampleServicesQuerying InterfacesUsing PropertiesElementAccessSimple TypesStringsEnums and Constant GroupsStructsAnySequenceHow to find the solution for a problemFinding your Way through the API ReferenceCommon MechanismsTextTableDrawingUNO in Professional Projects (145)IntroductionUNO/API constituents: How UNOIDL/API, ServiceManager, Bridges, CoreReflection work togetherAPI ConceptsAPI is a language independent, abstract specification for UNO objects which are used in [PRODUCTNAME]Types in the API ReferenceSimple TypesThe Any TypeInterfacesServicesModulesStructsConstant Groups and EnumsSequencesExceptionsAPI PrinciplesRelationship between Specification, Implementation and InstancesObject CompositionUNO ConceptsUNO is an environment for networked object communicationInterprocess ConnectionsServiceManager and ComponentContextUsing UNO InterfacesUsing PropertiesUsing Collections and ContainersEvent ModelException HandlingLifetime ControlObject IdentityLanguage BindingsIntroduction for language bindingJava Language BindingC++ BindingAccess for [PRODUCTNAME] BasicAutomationWriting UNO componentsSpecifying a new ComponentUNOIDL language specificationImplementing a ComponentComponent Development BasicsIntroductionMandatory interfaces: XInterface, XServiceInfo ((from UseInterfaces.CoreInterfaces))"Should be implemented" interfaces: XTypeProvider ((from UseInterfaces.CoreInterfaces ))optional interface: XMain for standalone executionSimple Component in JavaGetting the service manager ((Chapter Java components from unoBindingJava))simple component chapterC++ Component((Automation Component?))Deployment Options for ComponentsComponent RegistrationService Manager ConfigurationXSet InterfaceAdding components during runtime, particularly interesting during developmentServiceManager ContentDynamically modifying the ServiceManagerBootstrapping the Service Manager ((from CppBind chapter))Simple Test ApplicationConfiguring Your Application with Bootstrap ParametersThe UNO ExecutableStandalone Runtime EnvironmentThe UNO executable and XMainConfiguring the Java Runtime EnvironmentThe office and Java ((from UnoBindingJava))Advanced UNODesign PatternsBridging conceptsRequirements for Language Bindings and BridgesNew Scripting EnginesServiceManager and loaderSpecial Interfaces for internal useXUNOTunnelXAggregationUNO Reflection APITypeLibrary and TypeProvidersDifferences from CorbaOffice DevelopmentGlobal Object StructureDesktop EnvironmentFrames and Frame HierarchiesFrame-Controller-Model ParadigmLoading and Saving Office ComponentsDispatch FrameworkCommon FeaturesCommon DialogsDocumentInfoStylesSearch and ReplaceNumber FormatsPackage File FormatsInternationalizationLinguisticSystem IntegrationClipboardFile PickerBridging to the Window SystemText Documents (51,5 Pages)OverviewHandling Text FilesWorking with Text DocumentsNavigatingUsing TextTablesText FieldsBookmarksIndexes and Index MarksReference MarksFootnotes and EndnotesShape Objects in TextRedlineRubyGlobal Document FeaturesControlling a Text DocumentSpreadsheet DocumentsOverviewHandling Spreadsheet FilesWorking with Spreadsheet DocumentsNavigatingEditing SpreadsheetsGlobal Document FeaturesControlling a Spreadsheet DocumentExtending Capabilities of Spreadsheet DocumentsDrawings and PresentationsOverviewHandling Draw/Impress FilesSavingPrintingRunning PresentationsWorking with a Draw/Impress DocumentNavigatingWorking with Draw/Impress DocumentsGlobal Document FeaturesControlling a Draw/Impress DocumentChartsChart BasicsCreating a Chart DocumentEditing a Chart DocumentCommon Diagram APIDifferent Chart TypesExtending Capabilities of Chart DocumentsBasic and DialogsIntroductionLibrary OrganizationIDE with Dialogs and EventsUsing [PRODUCTNAME] BasicToolkit Controls and their PropertiesCreating Dialogs at RuntimeDatabase AccessFeatures of the [PRODUCTNAME] Database IntegrationCapabilitiesSDBC, SDBCX, SDB ArchitectureAccessing Datasources with [PRODUCTNAME]DataSourcesAdding and Editing Datasources Establishing a ConnectionGetting ConnectionsDriver specificsConnection PoolingWorking with Saved QueriesWorking with DataExecuting StatementsResultsetsMetadataRowsetsWorking with the Database DesignUsing DDL to change the DB DesignUsing SDBCX to access the DB DesignUsing DBMS FeaturesStored ProceduresTransaction HandlingExecuting Prepared StatementsWriting Database DriversFormsConceptsModels and ViewsForm Elements in the Document ModelSpecial Form ComponentsEventsData AwarenessRecipesMaking it easier to work with a FormControlling the Data InputCollecting Data automaticallyTaking Advantage of Database Server FeaturesAdding new FunctionalityHandling ErrorsUCBPurpose of UCBAccessing ContentsOpening Folder ContentsOpening Document Contents as StreamsWorking with Content PropertiesCreating, Moving and Copying Document and Folder ContentsWorking with Additional CommandsWriting a Content Provider[PRODUCTNAME] ConfigurationAccessing configuration dataWriting Configuration DataAppendix + +Programmer's ManualPlanned OutlinePreface (3 Pages)First Steps (24 Pages)Programming with UNOFields of Application for UNOGetting StartedRequired FilesConfigurationFirst ConnectionHow to get Objects in [PRODUCTNAME]How to work with ObjectsExampleServicesQuerying InterfacesUsing PropertiesElementAccessSimple TypesStringsEnums and Constant GroupsStructsAnySequenceHow to find the solution for a problemFinding your Way through the API ReferenceCommon MechanismsTextTableDrawingUNO in Professional Projects (145)IntroductionUNO/API constituents: How UNOIDL/API, ServiceManager, Bridges, CoreReflection work togetherAPI ConceptsAPI is a language independent, abstract specification for UNO objects which are used in [PRODUCTNAME]Types in the API ReferenceSimple TypesThe Any TypeInterfacesServicesModulesStructsConstant Groups and EnumsSequencesExceptionsAPI PrinciplesRelationship between Specification, Implementation and InstancesObject CompositionUNO ConceptsUNO is an environment for networked object communicationInterprocess ConnectionsServiceManager and ComponentContextUsing UNO InterfacesUsing PropertiesUsing Collections and ContainersEvent ModelException HandlingLifetime ControlObject IdentityLanguage BindingsIntroduction for language bindingJava Language BindingC++ BindingAccess for [PRODUCTNAME] BasicAutomationWriting UNO componentsSpecifying a new ComponentUNOIDL language specificationImplementing a ComponentComponent Development BasicsIntroductionMandatory interfaces: XInterface, XServiceInfo ((from UseInterfaces.CoreInterfaces))"Should be implemented" interfaces: XTypeProvider ((from UseInterfaces.CoreInterfaces ))optional interface: XMain for standalone executionSimple Component in JavaGetting the service manager ((Chapter Java components from unoBindingJava))simple component chapterC++ Component((Automation Component?))Deployment Options for ComponentsComponent RegistrationService Manager ConfigurationXSet InterfaceAdding components during runtime, particularly interesting during developmentServiceManager ContentDynamically modifying the ServiceManagerBootstrapping the Service Manager ((from CppBind chapter))Simple Test ApplicationConfiguring Your Application with Bootstrap ParametersThe UNO ExecutableStandalone Runtime EnvironmentThe UNO executable and XMainConfiguring the Java Runtime EnvironmentThe office and Java ((from UnoBindingJava))Advanced UNODesign PatternsBridging conceptsRequirements for Language Bindings and BridgesNew Scripting EnginesServiceManager and loaderSpecial Interfaces for internal useXUNOTunnelXAggregationUNO Reflection APITypeLibrary and TypeProvidersDifferences from CorbaOffice DevelopmentGlobal Object StructureDesktop EnvironmentFrames and Frame HierarchiesFrame-Controller-Model ParadigmLoading and Saving Office ComponentsDispatch FrameworkCommon FeaturesCommon DialogsDocumentInfoStylesSearch and ReplaceNumber FormatsPackage File FormatsInternationalizationLinguisticSystem IntegrationClipboardFile PickerBridging to the Window SystemText Documents (51,5 Pages)OverviewHandling Text FilesWorking with Text DocumentsNavigatingUsing TextTablesText FieldsBookmarksIndexes and Index MarksReference MarksFootnotes and EndnotesShape Objects in TextRedlineRubyGlobal Document FeaturesControlling a Text DocumentSpreadsheet DocumentsOverviewHandling Spreadsheet FilesWorking with Spreadsheet DocumentsNavigatingEditing SpreadsheetsGlobal Document FeaturesControlling a Spreadsheet DocumentExtending Capabilities of Spreadsheet DocumentsDrawings and PresentationsOverviewHandling Draw/Impress FilesSavingPrintingRunning PresentationsWorking with a Draw/Impress DocumentNavigatingWorking with Draw/Impress DocumentsGlobal Document FeaturesControlling a Draw/Impress DocumentChartsChart BasicsCreating a Chart DocumentEditing a Chart DocumentCommon Diagram APIDifferent Chart TypesExtending Capabilities of Chart DocumentsBasic and DialogsIntroductionLibrary OrganizationIDE with Dialogs and EventsUsing [PRODUCTNAME] BasicToolkit Controls and their PropertiesCreating Dialogs at RuntimeDatabase AccessFeatures of the [PRODUCTNAME] Database IntegrationCapabilitiesSDBC, SDBCX, SDB ArchitectureAccessing Datasources with [PRODUCTNAME]DataSourcesAdding and Editing Datasources Establishing a ConnectionGetting ConnectionsDriver specificsConnection PoolingWorking with Saved QueriesWorking with DataExecuting StatementsResultsetsMetadataRowsetsWorking with the Database DesignUsing DDL to change the DB DesignUsing SDBCX to access the DB DesignUsing DBMS FeaturesStored ProceduresTransaction HandlingExecuting Prepared StatementsWriting Database DriversFormsConceptsModels and ViewsForm Elements in the Document ModelSpecial Form ComponentsEventsData AwarenessRecipesMaking it easier to work with a FormControlling the Data InputCollecting Data automaticallyTaking Advantage of Database Server FeaturesAdding new FunctionalityHandling ErrorsUCBPurpose of UCBAccessing ContentsOpening Folder ContentsOpening Document Contents as StreamsWorking with Content PropertiesCreating, Moving and Copying Document and Folder ContentsWorking with Additional CommandsWriting a Content Provider[PRODUCTNAME] ConfigurationAccessing configuration dataWriting Configuration DataAppendix + +Programmer's ManualPlanned OutlinePreface (3 Pages)First Steps (24 Pages)Programming with UNOFields of Application for UNOGetting StartedRequired FilesConfigurationFirst ConnectionHow to get Objects in [PRODUCTNAME]How to work with ObjectsExampleServicesQuerying InterfacesUsing PropertiesElementAccessSimple TypesStringsEnums and Constant GroupsStructsAnySequenceHow to find the solution for a problemFinding your Way through the API ReferenceCommon MechanismsTextTableDrawingUNO in Professional Projects (145)IntroductionUNO/API constituents: How UNOIDL/API, ServiceManager, Bridges, CoreReflection work togetherAPI ConceptsAPI is a language independent, abstract specification for UNO objects which are used in [PRODUCTNAME]Types in the API ReferenceSimple TypesThe Any TypeInterfacesServicesModulesStructsConstant Groups and EnumsSequencesExceptionsAPI PrinciplesRelationship between Specification, Implementation and InstancesObject CompositionUNO ConceptsUNO is an environment for networked object communicationInterprocess ConnectionsServiceManager and ComponentContextUsing UNO InterfacesUsing PropertiesUsing Collections and ContainersEvent ModelException HandlingLifetime ControlObject IdentityLanguage BindingsIntroduction for language bindingJava Language BindingC++ BindingAccess for [PRODUCTNAME] BasicAutomationWriting UNO componentsSpecifying a new ComponentUNOIDL language specificationImplementing a ComponentComponent Development BasicsIntroductionMandatory interfaces: XInterface, XServiceInfo ((from UseInterfaces.CoreInterfaces))"Should be implemented" interfaces: XTypeProvider ((from UseInterfaces.CoreInterfaces ))optional interface: XMain for standalone executionSimple Component in JavaGetting the service manager ((Chapter Java components from unoBindingJava))simple component chapterC++ Component((Automation Component?))Deployment Options for ComponentsComponent RegistrationService Manager ConfigurationXSet InterfaceAdding components during runtime, particularly interesting during developmentServiceManager ContentDynamically modifying the ServiceManagerBootstrapping the Service Manager ((from CppBind chapter))Simple Test ApplicationConfiguring Your Application with Bootstrap ParametersThe UNO ExecutableStandalone Runtime EnvironmentThe UNO executable and XMainConfiguring the Java Runtime EnvironmentThe office and Java ((from UnoBindingJava))Advanced UNODesign PatternsBridging conceptsRequirements for Language Bindings and BridgesNew Scripting EnginesServiceManager and loaderSpecial Interfaces for internal useXUNOTunnelXAggregationUNO Reflection APITypeLibrary and TypeProvidersDifferences from CorbaOffice DevelopmentGlobal Object StructureDesktop EnvironmentFrames and Frame HierarchiesFrame-Controller-Model ParadigmLoading and Saving Office ComponentsDispatch FrameworkCommon FeaturesCommon DialogsDocumentInfoStylesSearch and ReplaceNumber FormatsPackage File FormatsInternationalizationLinguisticSystem IntegrationClipboardFile PickerBridging to the Window SystemText Documents (51,5 Pages)OverviewHandling Text FilesWorking with Text DocumentsNavigatingUsing TextTablesText FieldsBookmarksIndexes and Index MarksReference MarksFootnotes and EndnotesShape Objects in TextRedlineRubyGlobal Document FeaturesControlling a Text DocumentSpreadsheet DocumentsOverviewHandling Spreadsheet FilesWorking with Spreadsheet DocumentsNavigatingEditing SpreadsheetsGlobal Document FeaturesControlling a Spreadsheet DocumentExtending Capabilities of Spreadsheet DocumentsDrawings and PresentationsOverviewHandling Draw/Impress FilesSavingPrintingRunning PresentationsWorking with a Draw/Impress DocumentNavigatingWorking with Draw/Impress DocumentsGlobal Document FeaturesControlling a Draw/Impress DocumentChartsChart BasicsCreating a Chart DocumentEditing a Chart DocumentCommon Diagram APIDifferent Chart TypesExtending Capabilities of Chart DocumentsBasic and DialogsIntroductionLibrary OrganizationIDE with Dialogs and EventsUsing [PRODUCTNAME] BasicToolkit Controls and their PropertiesCreating Dialogs at RuntimeDatabase AccessFeatures of the [PRODUCTNAME] Database IntegrationCapabilitiesSDBC, SDBCX, SDB ArchitectureAccessing Datasources with [PRODUCTNAME]DataSourcesAdding and Editing Datasources Establishing a ConnectionGetting ConnectionsDriver specificsConnection PoolingWorking with Saved QueriesWorking with DataExecuting StatementsResultsetsMetadataRowsetsWorking with the Database DesignUsing DDL to change the DB DesignUsing SDBCX to access the DB DesignUsing DBMS FeaturesStored ProceduresTransaction HandlingExecuting Prepared StatementsWriting Database DriversFormsConceptsModels and ViewsForm Elements in the Document ModelSpecial Form ComponentsEventsData AwarenessRecipesMaking it easier to work with a FormControlling the Data InputCollecting Data automaticallyTaking Advantage of Database Server FeaturesAdding new FunctionalityHandling ErrorsUCBPurpose of UCBAccessing ContentsOpening Folder ContentsOpening Document Contents as StreamsWorking with Content PropertiesCreating, Moving and Copying Document and Folder ContentsWorking with Additional CommandsWriting a Content Provider[PRODUCTNAME] ConfigurationAccessing configuration dataWriting Configuration DataAppendix + +Programmer's ManualPlanned OutlinePreface (3 Pages)First Steps (24 Pages)Programming with UNOFields of Application for UNOGetting StartedRequired FilesConfigurationFirst ConnectionHow to get Objects in [PRODUCTNAME]How to work with ObjectsExampleServicesQuerying InterfacesUsing PropertiesElementAccessSimple TypesStringsEnums and Constant GroupsStructsAnySequenceHow to find the solution for a problemFinding your Way through the API ReferenceCommon MechanismsTextTableDrawingUNO in Professional Projects (145)IntroductionUNO/API constituents: How UNOIDL/API, ServiceManager, Bridges, CoreReflection work togetherAPI ConceptsAPI is a language independent, abstract specification for UNO objects which are used in [PRODUCTNAME]Types in the API ReferenceSimple TypesThe Any TypeInterfacesServicesModulesStructsConstant Groups and EnumsSequencesExceptionsAPI PrinciplesRelationship between Specification, Implementation and InstancesObject CompositionUNO ConceptsUNO is an environment for networked object communicationInterprocess ConnectionsServiceManager and ComponentContextUsing UNO InterfacesUsing PropertiesUsing Collections and ContainersEvent ModelException HandlingLifetime ControlObject IdentityLanguage BindingsIntroduction for language bindingJava Language BindingC++ BindingAccess for [PRODUCTNAME] BasicAutomationWriting UNO componentsSpecifying a new ComponentUNOIDL language specificationImplementing a ComponentComponent Development BasicsIntroductionMandatory interfaces: XInterface, XServiceInfo ((from UseInterfaces.CoreInterfaces))"Should be implemented" interfaces: XTypeProvider ((from UseInterfaces.CoreInterfaces ))optional interface: XMain for standalone executionSimple Component in JavaGetting the service manager ((Chapter Java components from unoBindingJava))simple component chapterC++ Component((Automation Component?))Deployment Options for ComponentsComponent RegistrationService Manager ConfigurationXSet InterfaceAdding components during runtime, particularly interesting during developmentServiceManager ContentDynamically modifying the ServiceManagerBootstrapping the Service Manager ((from CppBind chapter))Simple Test ApplicationConfiguring Your Application with Bootstrap ParametersThe UNO ExecutableStandalone Runtime EnvironmentThe UNO executable and XMainConfiguring the Java Runtime EnvironmentThe office and Java ((from UnoBindingJava))Advanced UNODesign PatternsBridging conceptsRequirements for Language Bindings and BridgesNew Scripting EnginesServiceManager and loaderSpecial Interfaces for internal useXUNOTunnelXAggregationUNO Reflection APITypeLibrary and TypeProvidersDifferences from CorbaOffice DevelopmentGlobal Object StructureDesktop EnvironmentFrames and Frame HierarchiesFrame-Controller-Model ParadigmLoading and Saving Office ComponentsDispatch FrameworkCommon FeaturesCommon DialogsDocumentInfoStylesSearch and ReplaceNumber FormatsPackage File FormatsInternationalizationLinguisticSystem IntegrationClipboardFile PickerBridging to the Window SystemText Documents (51,5 Pages)OverviewHandling Text FilesWorking with Text DocumentsNavigatingUsing TextTablesText FieldsBookmarksIndexes and Index MarksReference MarksFootnotes and EndnotesShape Objects in TextRedlineRubyGlobal Document FeaturesControlling a Text DocumentSpreadsheet DocumentsOverviewHandling Spreadsheet FilesWorking with Spreadsheet DocumentsNavigatingEditing SpreadsheetsGlobal Document FeaturesControlling a Spreadsheet DocumentExtending Capabilities of Spreadsheet DocumentsDrawings and PresentationsOverviewHandling Draw/Impress FilesSavingPrintingRunning PresentationsWorking with a Draw/Impress DocumentNavigatingWorking with Draw/Impress DocumentsGlobal Document FeaturesControlling a Draw/Impress DocumentChartsChart BasicsCreating a Chart DocumentEditing a Chart DocumentCommon Diagram APIDifferent Chart TypesExtending Capabilities of Chart DocumentsBasic and DialogsIntroductionLibrary OrganizationIDE with Dialogs and EventsUsing [PRODUCTNAME] BasicToolkit Controls and their PropertiesCreating Dialogs at RuntimeDatabase AccessFeatures of the [PRODUCTNAME] Database IntegrationCapabilitiesSDBC, SDBCX, SDB ArchitectureAccessing Datasources with [PRODUCTNAME]DataSourcesAdding and Editing Datasources Establishing a ConnectionGetting ConnectionsDriver specificsConnection PoolingWorking with Saved QueriesWorking with DataExecuting StatementsResultsetsMetadataRowsetsWorking with the Database DesignUsing DDL to change the DB DesignUsing SDBCX to access the DB DesignUsing DBMS FeaturesStored ProceduresTransaction HandlingExecuting Prepared StatementsWriting Database DriversFormsConceptsModels and ViewsForm Elements in the Document ModelSpecial Form ComponentsEventsData AwarenessRecipesMaking it easier to work with a FormControlling the Data InputCollecting Data automaticallyTaking Advantage of Database Server FeaturesAdding new FunctionalityHandling ErrorsUCBPurpose of UCBAccessing ContentsOpening Folder ContentsOpening Document Contents as StreamsWorking with Content PropertiesCreating, Moving and Copying Document and Folder ContentsWorking with Additional CommandsWriting a Content Provider[PRODUCTNAME] ConfigurationAccessing configuration dataWriting Configuration DataAppendix + +Programmer's ManualPlanned OutlinePreface (3 Pages)First Steps (24 Pages)Programming with UNOFields of Application for UNOGetting StartedRequired FilesConfigurationFirst ConnectionHow to get Objects in [PRODUCTNAME]How to work with ObjectsExampleServicesQuerying InterfacesUsing PropertiesElementAccessSimple TypesStringsEnums and Constant GroupsStructsAnySequenceHow to find the solution for a problemFinding your Way through the API ReferenceCommon MechanismsTextTableDrawingUNO in Professional Projects (145)IntroductionUNO/API constituents: How UNOIDL/API, ServiceManager, Bridges, CoreReflection work togetherAPI ConceptsAPI is a language independent, abstract specification for UNO objects which are used in [PRODUCTNAME]Types in the API ReferenceSimple TypesThe Any TypeInterfacesServicesModulesStructsConstant Groups and EnumsSequencesExceptionsAPI PrinciplesRelationship between Specification, Implementation and InstancesObject CompositionUNO ConceptsUNO is an environment for networked object communicationInterprocess ConnectionsServiceManager and ComponentContextUsing UNO InterfacesUsing PropertiesUsing Collections and ContainersEvent ModelException HandlingLifetime ControlObject IdentityLanguage BindingsIntroduction for language bindingJava Language BindingC++ BindingAccess for [PRODUCTNAME] BasicAutomationWriting UNO componentsSpecifying a new ComponentUNOIDL language specificationImplementing a ComponentComponent Development BasicsIntroductionMandatory interfaces: XInterface, XServiceInfo ((from UseInterfaces.CoreInterfaces))"Should be implemented" interfaces: XTypeProvider ((from UseInterfaces.CoreInterfaces ))optional interface: XMain for standalone executionSimple Component in JavaGetting the service manager ((Chapter Java components from unoBindingJava))simple component chapterC++ Component((Automation Component?))Deployment Options for ComponentsComponent RegistrationService Manager ConfigurationXSet InterfaceAdding components during runtime, particularly interesting during developmentServiceManager ContentDynamically modifying the ServiceManagerBootstrapping the Service Manager ((from CppBind chapter))Simple Test ApplicationConfiguring Your Application with Bootstrap ParametersThe UNO ExecutableStandalone Runtime EnvironmentThe UNO executable and XMainConfiguring the Java Runtime EnvironmentThe office and Java ((from UnoBindingJava))Advanced UNODesign PatternsBridging conceptsRequirements for Language Bindings and BridgesNew Scripting EnginesServiceManager and loaderSpecial Interfaces for internal useXUNOTunnelXAggregationUNO Reflection APITypeLibrary and TypeProvidersDifferences from CorbaOffice DevelopmentGlobal Object StructureDesktop EnvironmentFrames and Frame HierarchiesFrame-Controller-Model ParadigmLoading and Saving Office ComponentsDispatch FrameworkCommon FeaturesCommon DialogsDocumentInfoStylesSearch and ReplaceNumber FormatsPackage File FormatsInternationalizationLinguisticSystem IntegrationClipboardFile PickerBridging to the Window SystemText Documents (51,5 Pages)OverviewHandling Text FilesWorking with Text DocumentsNavigatingUsing TextTablesText FieldsBookmarksIndexes and Index MarksReference MarksFootnotes and EndnotesShape Objects in TextRedlineRubyGlobal Document FeaturesControlling a Text DocumentSpreadsheet DocumentsOverviewHandling Spreadsheet FilesWorking with Spreadsheet DocumentsNavigatingEditing SpreadsheetsGlobal Document FeaturesControlling a Spreadsheet DocumentExtending Capabilities of Spreadsheet DocumentsDrawings and PresentationsOverviewHandling Draw/Impress FilesSavingPrintingRunning PresentationsWorking with a Draw/Impress DocumentNavigatingWorking with Draw/Impress DocumentsGlobal Document FeaturesControlling a Draw/Impress DocumentChartsChart BasicsCreating a Chart DocumentEditing a Chart DocumentCommon Diagram APIDifferent Chart TypesExtending Capabilities of Chart DocumentsBasic and DialogsIntroductionLibrary OrganizationIDE with Dialogs and EventsUsing [PRODUCTNAME] BasicToolkit Controls and their PropertiesCreating Dialogs at RuntimeDatabase AccessFeatures of the [PRODUCTNAME] Database IntegrationCapabilitiesSDBC, SDBCX, SDB ArchitectureAccessing Datasources with [PRODUCTNAME]DataSourcesAdding and Editing Datasources Establishing a ConnectionGetting ConnectionsDriver specificsConnection PoolingWorking with Saved QueriesWorking with DataExecuting StatementsResultsetsMetadataRowsetsWorking with the Database DesignUsing DDL to change the DB DesignUsing SDBCX to access the DB DesignUsing DBMS FeaturesStored ProceduresTransaction HandlingExecuting Prepared StatementsWriting Database DriversFormsConceptsModels and ViewsForm Elements in the Document ModelSpecial Form ComponentsEventsData AwarenessRecipesMaking it easier to work with a FormControlling the Data InputCollecting Data automaticallyTaking Advantage of Database Server FeaturesAdding new FunctionalityHandling ErrorsUCBPurpose of UCBAccessing ContentsOpening Folder ContentsOpening Document Contents as StreamsWorking with Content PropertiesCreating, Moving and Copying Document and Folder ContentsWorking with Additional CommandsWriting a Content Provider[PRODUCTNAME] ConfigurationAccessing configuration dataWriting Configuration DataAppendix + +Programmer's ManualPlanned OutlinePreface (3 Pages)First Steps (24 Pages)Programming with UNOFields of Application for UNOGetting StartedRequired FilesConfigurationFirst ConnectionHow to get Objects in [PRODUCTNAME]How to work with ObjectsExampleServicesQuerying InterfacesUsing PropertiesElementAccessSimple TypesStringsEnums and Constant GroupsStructsAnySequenceHow to find the solution for a problemFinding your Way through the API ReferenceCommon MechanismsTextTableDrawingUNO in Professional Projects (145)IntroductionUNO/API constituents: How UNOIDL/API, ServiceManager, Bridges, CoreReflection work togetherAPI ConceptsAPI is a language independent, abstract specification for UNO objects which are used in [PRODUCTNAME]Types in the API ReferenceSimple TypesThe Any TypeInterfacesServicesModulesStructsConstant Groups and EnumsSequencesExceptionsAPI PrinciplesRelationship between Specification, Implementation and InstancesObject CompositionUNO ConceptsUNO is an environment for networked object communicationInterprocess ConnectionsServiceManager and ComponentContextUsing UNO InterfacesUsing PropertiesUsing Collections and ContainersEvent ModelException HandlingLifetime ControlObject IdentityLanguage BindingsIntroduction for language bindingJava Language BindingC++ BindingAccess for [PRODUCTNAME] BasicAutomationWriting UNO componentsSpecifying a new ComponentUNOIDL language specificationImplementing a ComponentComponent Development BasicsIntroductionMandatory interfaces: XInterface, XServiceInfo ((from UseInterfaces.CoreInterfaces))"Should be implemented" interfaces: XTypeProvider ((from UseInterfaces.CoreInterfaces ))optional interface: XMain for standalone executionSimple Component in JavaGetting the service manager ((Chapter Java components from unoBindingJava))simple component chapterC++ Component((Automation Component?))Deployment Options for ComponentsComponent RegistrationService Manager ConfigurationXSet InterfaceAdding components during runtime, particularly interesting during developmentServiceManager ContentDynamically modifying the ServiceManagerBootstrapping the Service Manager ((from CppBind chapter))Simple Test ApplicationConfiguring Your Application with Bootstrap ParametersThe UNO ExecutableStandalone Runtime EnvironmentThe UNO executable and XMainConfiguring the Java Runtime EnvironmentThe office and Java ((from UnoBindingJava))Advanced UNODesign PatternsBridging conceptsRequirements for Language Bindings and BridgesNew Scripting EnginesServiceManager and loaderSpecial Interfaces for internal useXUNOTunnelXAggregationUNO Reflection APITypeLibrary and TypeProvidersDifferences from CorbaOffice DevelopmentGlobal Object StructureDesktop EnvironmentFrames and Frame HierarchiesFrame-Controller-Model ParadigmLoading and Saving Office ComponentsDispatch FrameworkCommon FeaturesCommon DialogsDocumentInfoStylesSearch and ReplaceNumber FormatsPackage File FormatsInternationalizationLinguisticSystem IntegrationClipboardFile PickerBridging to the Window SystemText Documents (51,5 Pages)OverviewHandling Text FilesWorking with Text DocumentsNavigatingUsing TextTablesText FieldsBookmarksIndexes and Index MarksReference MarksFootnotes and EndnotesShape Objects in TextRedlineRubyGlobal Document FeaturesControlling a Text DocumentSpreadsheet DocumentsOverviewHandling Spreadsheet FilesWorking with Spreadsheet DocumentsNavigatingEditing SpreadsheetsGlobal Document FeaturesControlling a Spreadsheet DocumentExtending Capabilities of Spreadsheet DocumentsDrawings and PresentationsOverviewHandling Draw/Impress FilesSavingPrintingRunning PresentationsWorking with a Draw/Impress DocumentNavigatingWorking with Draw/Impress DocumentsGlobal Document FeaturesControlling a Draw/Impress DocumentChartsChart BasicsCreating a Chart DocumentEditing a Chart DocumentCommon Diagram APIDifferent Chart TypesExtending Capabilities of Chart DocumentsBasic and DialogsIntroductionLibrary OrganizationIDE with Dialogs and EventsUsing [PRODUCTNAME] BasicToolkit Controls and their PropertiesCreating Dialogs at RuntimeDatabase AccessFeatures of the [PRODUCTNAME] Database IntegrationCapabilitiesSDBC, SDBCX, SDB ArchitectureAccessing Datasources with [PRODUCTNAME]DataSourcesAdding and Editing Datasources Establishing a ConnectionGetting ConnectionsDriver specificsConnection PoolingWorking with Saved QueriesWorking with DataExecuting StatementsResultsetsMetadataRowsetsWorking with the Database DesignUsing DDL to change the DB DesignUsing SDBCX to access the DB DesignUsing DBMS FeaturesStored ProceduresTransaction HandlingExecuting Prepared StatementsWriting Database DriversFormsConceptsModels and ViewsForm Elements in the Document ModelSpecial Form ComponentsEventsData AwarenessRecipesMaking it easier to work with a FormControlling the Data InputCollecting Data automaticallyTaking Advantage of Database Server FeaturesAdding new FunctionalityHandling ErrorsUCBPurpose of UCBAccessing ContentsOpening Folder ContentsOpening Document Contents as StreamsWorking with Content PropertiesCreating, Moving and Copying Document and Folder ContentsWorking with Additional CommandsWriting a Content Provider[PRODUCTNAME] ConfigurationAccessing configuration dataWriting Configuration DataAppendix + +Programmer's ManualPlanned OutlinePreface (3 Pages)First Steps (24 Pages)Programming with UNOFields of Application for UNOGetting StartedRequired FilesConfigurationFirst ConnectionHow to get Objects in [PRODUCTNAME]How to work with ObjectsExampleServicesQuerying InterfacesUsing PropertiesElementAccessSimple TypesStringsEnums and Constant GroupsStructsAnySequenceHow to find the solution for a problemFinding your Way through the API ReferenceCommon MechanismsTextTableDrawingUNO in Professional Projects (145)IntroductionUNO/API constituents: How UNOIDL/API, ServiceManager, Bridges, CoreReflection work togetherAPI ConceptsAPI is a language independent, abstract specification for UNO objects which are used in [PRODUCTNAME]Types in the API ReferenceSimple TypesThe Any TypeInterfacesServicesModulesStructsConstant Groups and EnumsSequencesExceptionsAPI PrinciplesRelationship between Specification, Implementation and InstancesObject CompositionUNO ConceptsUNO is an environment for networked object communicationInterprocess ConnectionsServiceManager and ComponentContextUsing UNO InterfacesUsing PropertiesUsing Collections and ContainersEvent ModelException HandlingLifetime ControlObject IdentityLanguage BindingsIntroduction for language bindingJava Language BindingC++ BindingAccess for [PRODUCTNAME] BasicAutomationWriting UNO componentsSpecifying a new ComponentUNOIDL language specificationImplementing a ComponentComponent Development BasicsIntroductionMandatory interfaces: XInterface, XServiceInfo ((from UseInterfaces.CoreInterfaces))"Should be implemented" interfaces: XTypeProvider ((from UseInterfaces.CoreInterfaces ))optional interface: XMain for standalone executionSimple Component in JavaGetting the service manager ((Chapter Java components from unoBindingJava))simple component chapterC++ Component((Automation Component?))Deployment Options for ComponentsComponent RegistrationService Manager ConfigurationXSet InterfaceAdding components during runtime, particularly interesting during developmentServiceManager ContentDynamically modifying the ServiceManagerBootstrapping the Service Manager ((from CppBind chapter))Simple Test ApplicationConfiguring Your Application with Bootstrap ParametersThe UNO ExecutableStandalone Runtime EnvironmentThe UNO executable and XMainConfiguring the Java Runtime EnvironmentThe office and Java ((from UnoBindingJava))Advanced UNODesign PatternsBridging conceptsRequirements for Language Bindings and BridgesNew Scripting EnginesServiceManager and loaderSpecial Interfaces for internal useXUNOTunnelXAggregationUNO Reflection APITypeLibrary and TypeProvidersDifferences from CorbaOffice DevelopmentGlobal Object StructureDesktop EnvironmentFrames and Frame HierarchiesFrame-Controller-Model ParadigmLoading and Saving Office ComponentsDispatch FrameworkCommon FeaturesCommon DialogsDocumentInfoStylesSearch and ReplaceNumber FormatsPackage File FormatsInternationalizationLinguisticSystem IntegrationClipboardFile PickerBridging to the Window SystemText Documents (51,5 Pages)OverviewHandling Text FilesWorking with Text DocumentsNavigatingUsing TextTablesText FieldsBookmarksIndexes and Index MarksReference MarksFootnotes and EndnotesShape Objects in TextRedlineRubyGlobal Document FeaturesControlling a Text DocumentSpreadsheet DocumentsOverviewHandling Spreadsheet FilesWorking with Spreadsheet DocumentsNavigatingEditing SpreadsheetsGlobal Document FeaturesControlling a Spreadsheet DocumentExtending Capabilities of Spreadsheet DocumentsDrawings and PresentationsOverviewHandling Draw/Impress FilesSavingPrintingRunning PresentationsWorking with a Draw/Impress DocumentNavigatingWorking with Draw/Impress DocumentsGlobal Document FeaturesControlling a Draw/Impress DocumentChartsChart BasicsCreating a Chart DocumentEditing a Chart DocumentCommon Diagram APIDifferent Chart TypesExtending Capabilities of Chart DocumentsBasic and DialogsIntroductionLibrary OrganizationIDE with Dialogs and EventsUsing [PRODUCTNAME] BasicToolkit Controls and their PropertiesCreating Dialogs at RuntimeDatabase AccessFeatures of the [PRODUCTNAME] Database IntegrationCapabilitiesSDBC, SDBCX, SDB ArchitectureAccessing Datasources with [PRODUCTNAME]DataSourcesAdding and Editing Datasources Establishing a ConnectionGetting ConnectionsDriver specificsConnection PoolingWorking with Saved QueriesWorking with DataExecuting StatementsResultsetsMetadataRowsetsWorking with the Database DesignUsing DDL to change the DB DesignUsing SDBCX to access the DB DesignUsing DBMS FeaturesStored ProceduresTransaction HandlingExecuting Prepared StatementsWriting Database DriversFormsConceptsModels and ViewsForm Elements in the Document ModelSpecial Form ComponentsEventsData AwarenessRecipesMaking it easier to work with a FormControlling the Data InputCollecting Data automaticallyTaking Advantage of Database Server FeaturesAdding new FunctionalityHandling ErrorsUCBPurpose of UCBAccessing ContentsOpening Folder ContentsOpening Document Contents as StreamsWorking with Content PropertiesCreating, Moving and Copying Document and Folder ContentsWorking with Additional CommandsWriting a Content Provider[PRODUCTNAME] ConfigurationAccessing configuration dataWriting Configuration DataAppendix + +Programmer's ManualPlanned OutlinePreface (3 Pages)First Steps (24 Pages)Programming with UNOFields of Application for UNOGetting StartedRequired FilesConfigurationFirst ConnectionHow to get Objects in [PRODUCTNAME]How to work with ObjectsExampleServicesQuerying InterfacesUsing PropertiesElementAccessSimple TypesStringsEnums and Constant GroupsStructsAnySequenceHow to find the solution for a problemFinding your Way through the API ReferenceCommon MechanismsTextTableDrawingUNO in Professional Projects (145)IntroductionUNO/API constituents: How UNOIDL/API, ServiceManager, Bridges, CoreReflection work togetherAPI ConceptsAPI is a language independent, abstract specification for UNO objects which are used in [PRODUCTNAME]Types in the API ReferenceSimple TypesThe Any TypeInterfacesServicesModulesStructsConstant Groups and EnumsSequencesExceptionsAPI PrinciplesRelationship between Specification, Implementation and InstancesObject CompositionUNO ConceptsUNO is an environment for networked object communicationInterprocess ConnectionsServiceManager and ComponentContextUsing UNO InterfacesUsing PropertiesUsing Collections and ContainersEvent ModelException HandlingLifetime ControlObject IdentityLanguage BindingsIntroduction for language bindingJava Language BindingC++ BindingAccess for [PRODUCTNAME] BasicAutomationWriting UNO componentsSpecifying a new ComponentUNOIDL language specificationImplementing a ComponentComponent Development BasicsIntroductionMandatory interfaces: XInterface, XServiceInfo ((from UseInterfaces.CoreInterfaces))"Should be implemented" interfaces: XTypeProvider ((from UseInterfaces.CoreInterfaces ))optional interface: XMain for standalone executionSimple Component in JavaGetting the service manager ((Chapter Java components from unoBindingJava))simple component chapterC++ Component((Automation Component?))Deployment Options for ComponentsComponent RegistrationService Manager ConfigurationXSet InterfaceAdding components during runtime, particularly interesting during developmentServiceManager ContentDynamically modifying the ServiceManagerBootstrapping the Service Manager ((from CppBind chapter))Simple Test ApplicationConfiguring Your Application with Bootstrap ParametersThe UNO ExecutableStandalone Runtime EnvironmentThe UNO executable and XMainConfiguring the Java Runtime EnvironmentThe office and Java ((from UnoBindingJava))Advanced UNODesign PatternsBridging conceptsRequirements for Language Bindings and BridgesNew Scripting EnginesServiceManager and loaderSpecial Interfaces for internal useXUNOTunnelXAggregationUNO Reflection APITypeLibrary and TypeProvidersDifferences from CorbaOffice DevelopmentGlobal Object StructureDesktop EnvironmentFrames and Frame HierarchiesFrame-Controller-Model ParadigmLoading and Saving Office ComponentsDispatch FrameworkCommon FeaturesCommon DialogsDocumentInfoStylesSearch and ReplaceNumber FormatsPackage File FormatsInternationalizationLinguisticSystem IntegrationClipboardFile PickerBridging to the Window SystemText Documents (51,5 Pages)OverviewHandling Text FilesWorking with Text DocumentsNavigatingUsing TextTablesText FieldsBookmarksIndexes and Index MarksReference MarksFootnotes and EndnotesShape Objects in TextRedlineRubyGlobal Document FeaturesControlling a Text DocumentSpreadsheet DocumentsOverviewHandling Spreadsheet FilesWorking with Spreadsheet DocumentsNavigatingEditing SpreadsheetsGlobal Document FeaturesControlling a Spreadsheet DocumentExtending Capabilities of Spreadsheet DocumentsDrawings and PresentationsOverviewHandling Draw/Impress FilesSavingPrintingRunning PresentationsWorking with a Draw/Impress DocumentNavigatingWorking with Draw/Impress DocumentsGlobal Document FeaturesControlling a Draw/Impress DocumentChartsChart BasicsCreating a Chart DocumentEditing a Chart DocumentCommon Diagram APIDifferent Chart TypesExtending Capabilities of Chart DocumentsBasic and DialogsIntroductionLibrary OrganizationIDE with Dialogs and EventsUsing [PRODUCTNAME] BasicToolkit Controls and their PropertiesCreating Dialogs at RuntimeDatabase AccessFeatures of the [PRODUCTNAME] Database IntegrationCapabilitiesSDBC, SDBCX, SDB ArchitectureAccessing Datasources with [PRODUCTNAME]DataSourcesAdding and Editing Datasources Establishing a ConnectionGetting ConnectionsDriver specificsConnection PoolingWorking with Saved QueriesWorking with DataExecuting StatementsResultsetsMetadataRowsetsWorking with the Database DesignUsing DDL to change the DB DesignUsing SDBCX to access the DB DesignUsing DBMS FeaturesStored ProceduresTransaction HandlingExecuting Prepared StatementsWriting Database DriversFormsConceptsModels and ViewsForm Elements in the Document ModelSpecial Form ComponentsEventsData AwarenessRecipesMaking it easier to work with a FormControlling the Data InputCollecting Data automaticallyTaking Advantage of Database Server FeaturesAdding new FunctionalityHandling ErrorsUCBPurpose of UCBAccessing ContentsOpening Folder ContentsOpening Document Contents as StreamsWorking with Content PropertiesCreating, Moving and Copying Document and Folder ContentsWorking with Additional CommandsWriting a Content Provider[PRODUCTNAME] ConfigurationAccessing configuration dataWriting Configuration DataAppendix + +Programmer's ManualPlanned OutlinePreface (3 Pages)First Steps (24 Pages)Programming with UNOFields of Application for UNOGetting StartedRequired FilesConfigurationFirst ConnectionHow to get Objects in [PRODUCTNAME]How to work with ObjectsExampleServicesQuerying InterfacesUsing PropertiesElementAccessSimple TypesStringsEnums and Constant GroupsStructsAnySequenceHow to find the solution for a problemFinding your Way through the API ReferenceCommon MechanismsTextTableDrawingUNO in Professional Projects (145)IntroductionUNO/API constituents: How UNOIDL/API, ServiceManager, Bridges, CoreReflection work togetherAPI ConceptsAPI is a language independent, abstract specification for UNO objects which are used in [PRODUCTNAME]Types in the API ReferenceSimple TypesThe Any TypeInterfacesServicesModulesStructsConstant Groups and EnumsSequencesExceptionsAPI PrinciplesRelationship between Specification, Implementation and InstancesObject CompositionUNO ConceptsUNO is an environment for networked object communicationInterprocess ConnectionsServiceManager and ComponentContextUsing UNO InterfacesUsing PropertiesUsing Collections and ContainersEvent ModelException HandlingLifetime ControlObject IdentityLanguage BindingsIntroduction for language bindingJava Language BindingC++ BindingAccess for [PRODUCTNAME] BasicAutomationWriting UNO componentsSpecifying a new ComponentUNOIDL language specificationImplementing a ComponentComponent Development BasicsIntroductionMandatory interfaces: XInterface, XServiceInfo ((from UseInterfaces.CoreInterfaces))"Should be implemented" interfaces: XTypeProvider ((from UseInterfaces.CoreInterfaces ))optional interface: XMain for standalone executionSimple Component in JavaGetting the service manager ((Chapter Java components from unoBindingJava))simple component chapterC++ Component((Automation Component?))Deployment Options for ComponentsComponent RegistrationService Manager ConfigurationXSet InterfaceAdding components during runtime, particularly interesting during developmentServiceManager ContentDynamically modifying the ServiceManagerBootstrapping the Service Manager ((from CppBind chapter))Simple Test ApplicationConfiguring Your Application with Bootstrap ParametersThe UNO ExecutableStandalone Runtime EnvironmentThe UNO executable and XMainConfiguring the Java Runtime EnvironmentThe office and Java ((from UnoBindingJava))Advanced UNODesign PatternsBridging conceptsRequirements for Language Bindings and BridgesNew Scripting EnginesServiceManager and loaderSpecial Interfaces for internal useXUNOTunnelXAggregationUNO Reflection APITypeLibrary and TypeProvidersDifferences from CorbaOffice DevelopmentGlobal Object StructureDesktop EnvironmentFrames and Frame HierarchiesFrame-Controller-Model ParadigmLoading and Saving Office ComponentsDispatch FrameworkCommon FeaturesCommon DialogsDocumentInfoStylesSearch and ReplaceNumber FormatsPackage File FormatsInternationalizationLinguisticSystem IntegrationClipboardFile PickerBridging to the Window SystemText Documents (51,5 Pages)OverviewHandling Text FilesWorking with Text DocumentsNavigatingUsing TextTablesText FieldsBookmarksIndexes and Index MarksReference MarksFootnotes and EndnotesShape Objects in TextRedlineRubyGlobal Document FeaturesControlling a Text DocumentSpreadsheet DocumentsOverviewHandling Spreadsheet FilesWorking with Spreadsheet DocumentsNavigatingEditing SpreadsheetsGlobal Document FeaturesControlling a Spreadsheet DocumentExtending Capabilities of Spreadsheet DocumentsDrawings and PresentationsOverviewHandling Draw/Impress FilesSavingPrintingRunning PresentationsWorking with a Draw/Impress DocumentNavigatingWorking with Draw/Impress DocumentsGlobal Document FeaturesControlling a Draw/Impress DocumentChartsChart BasicsCreating a Chart DocumentEditing a Chart DocumentCommon Diagram APIDifferent Chart TypesExtending Capabilities of Chart DocumentsBasic and DialogsIntroductionLibrary OrganizationIDE with Dialogs and EventsUsing [PRODUCTNAME] BasicToolkit Controls and their PropertiesCreating Dialogs at RuntimeDatabase AccessFeatures of the [PRODUCTNAME] Database IntegrationCapabilitiesSDBC, SDBCX, SDB ArchitectureAccessing Datasources with [PRODUCTNAME]DataSourcesAdding and Editing Datasources Establishing a ConnectionGetting ConnectionsDriver specificsConnection PoolingWorking with Saved QueriesWorking with DataExecuting StatementsResultsetsMetadataRowsetsWorking with the Database DesignUsing DDL to change the DB DesignUsing SDBCX to access the DB DesignUsing DBMS FeaturesStored ProceduresTransaction HandlingExecuting Prepared StatementsWriting Database DriversFormsConceptsModels and ViewsForm Elements in the Document ModelSpecial Form ComponentsEventsData AwarenessRecipesMaking it easier to work with a FormControlling the Data InputCollecting Data automaticallyTaking Advantage of Database Server FeaturesAdding new FunctionalityHandling ErrorsUCBPurpose of UCBAccessing ContentsOpening Folder ContentsOpening Document Contents as StreamsWorking with Content PropertiesCreating, Moving and Copying Document and Folder ContentsWorking with Additional CommandsWriting a Content Provider[PRODUCTNAME] ConfigurationAccessing configuration dataWriting Configuration DataAppendix + +Programmer's ManualPlanned OutlinePreface (3 Pages)First Steps (24 Pages)Programming with UNOFields of Application for UNOGetting StartedRequired FilesConfigurationFirst ConnectionHow to get Objects in [PRODUCTNAME]How to work with ObjectsExampleServicesQuerying InterfacesUsing PropertiesElementAccessSimple TypesStringsEnums and Constant GroupsStructsAnySequenceHow to find the solution for a problemFinding your Way through the API ReferenceCommon MechanismsTextTableDrawingUNO in Professional Projects (145)IntroductionUNO/API constituents: How UNOIDL/API, ServiceManager, Bridges, CoreReflection work togetherAPI ConceptsAPI is a language independent, abstract specification for UNO objects which are used in [PRODUCTNAME]Types in the API ReferenceSimple TypesThe Any TypeInterfacesServicesModulesStructsConstant Groups and EnumsSequencesExceptionsAPI PrinciplesRelationship between Specification, Implementation and InstancesObject CompositionUNO ConceptsUNO is an environment for networked object communicationInterprocess ConnectionsServiceManager and ComponentContextUsing UNO InterfacesUsing PropertiesUsing Collections and ContainersEvent ModelException HandlingLifetime ControlObject IdentityLanguage BindingsIntroduction for language bindingJava Language BindingC++ BindingAccess for [PRODUCTNAME] BasicAutomationWriting UNO componentsSpecifying a new ComponentUNOIDL language specificationImplementing a ComponentComponent Development BasicsIntroductionMandatory interfaces: XInterface, XServiceInfo ((from UseInterfaces.CoreInterfaces))"Should be implemented" interfaces: XTypeProvider ((from UseInterfaces.CoreInterfaces ))optional interface: XMain for standalone executionSimple Component in JavaGetting the service manager ((Chapter Java components from unoBindingJava))simple component chapterC++ Component((Automation Component?))Deployment Options for ComponentsComponent RegistrationService Manager ConfigurationXSet InterfaceAdding components during runtime, particularly interesting during developmentServiceManager ContentDynamically modifying the ServiceManagerBootstrapping the Service Manager ((from CppBind chapter))Simple Test ApplicationConfiguring Your Application with Bootstrap ParametersThe UNO ExecutableStandalone Runtime EnvironmentThe UNO executable and XMainConfiguring the Java Runtime EnvironmentThe office and Java ((from UnoBindingJava))Advanced UNODesign PatternsBridging conceptsRequirements for Language Bindings and BridgesNew Scripting EnginesServiceManager and loaderSpecial Interfaces for internal useXUNOTunnelXAggregationUNO Reflection APITypeLibrary and TypeProvidersDifferences from CorbaOffice DevelopmentGlobal Object StructureDesktop EnvironmentFrames and Frame HierarchiesFrame-Controller-Model ParadigmLoading and Saving Office ComponentsDispatch FrameworkCommon FeaturesCommon DialogsDocumentInfoStylesSearch and ReplaceNumber FormatsPackage File FormatsInternationalizationLinguisticSystem IntegrationClipboardFile PickerBridging to the Window SystemText Documents (51,5 Pages)OverviewHandling Text FilesWorking with Text DocumentsNavigatingUsing TextTablesText FieldsBookmarksIndexes and Index MarksReference MarksFootnotes and EndnotesShape Objects in TextRedlineRubyGlobal Document FeaturesControlling a Text DocumentSpreadsheet DocumentsOverviewHandling Spreadsheet FilesWorking with Spreadsheet DocumentsNavigatingEditing SpreadsheetsGlobal Document FeaturesControlling a Spreadsheet DocumentExtending Capabilities of Spreadsheet DocumentsDrawings and PresentationsOverviewHandling Draw/Impress FilesSavingPrintingRunning PresentationsWorking with a Draw/Impress DocumentNavigatingWorking with Draw/Impress DocumentsGlobal Document FeaturesControlling a Draw/Impress DocumentChartsChart BasicsCreating a Chart DocumentEditing a Chart DocumentCommon Diagram APIDifferent Chart TypesExtending Capabilities of Chart DocumentsBasic and DialogsIntroductionLibrary OrganizationIDE with Dialogs and EventsUsing [PRODUCTNAME] BasicToolkit Controls and their PropertiesCreating Dialogs at RuntimeDatabase AccessFeatures of the [PRODUCTNAME] Database IntegrationCapabilitiesSDBC, SDBCX, SDB ArchitectureAccessing Datasources with [PRODUCTNAME]DataSourcesAdding and Editing Datasources Establishing a ConnectionGetting ConnectionsDriver specificsConnection PoolingWorking with Saved QueriesWorking with DataExecuting StatementsResultsetsMetadataRowsetsWorking with the Database DesignUsing DDL to change the DB DesignUsing SDBCX to access the DB DesignUsing DBMS FeaturesStored ProceduresTransaction HandlingExecuting Prepared StatementsWriting Database DriversFormsConceptsModels and ViewsForm Elements in the Document ModelSpecial Form ComponentsEventsData AwarenessRecipesMaking it easier to work with a FormControlling the Data InputCollecting Data automaticallyTaking Advantage of Database Server FeaturesAdding new FunctionalityHandling ErrorsUCBPurpose of UCBAccessing ContentsOpening Folder ContentsOpening Document Contents as StreamsWorking with Content PropertiesCreating, Moving and Copying Document and Folder ContentsWorking with Additional CommandsWriting a Content Provider[PRODUCTNAME] ConfigurationAccessing configuration dataWriting Configuration DataAppendix + +Programmer's ManualPlanned OutlinePreface (3 Pages)First Steps (24 Pages)Programming with UNOFields of Application for UNOGetting StartedRequired FilesConfigurationFirst ConnectionHow to get Objects in [PRODUCTNAME]How to work with ObjectsExampleServicesQuerying InterfacesUsing PropertiesElementAccessSimple TypesStringsEnums and Constant GroupsStructsAnySequenceHow to find the solution for a problemFinding your Way through the API ReferenceCommon MechanismsTextTableDrawingUNO in Professional Projects (145)IntroductionUNO/API constituents: How UNOIDL/API, ServiceManager, Bridges, CoreReflection work togetherAPI ConceptsAPI is a language independent, abstract specification for UNO objects which are used in [PRODUCTNAME]Types in the API ReferenceSimple TypesThe Any TypeInterfacesServicesModulesStructsConstant Groups and EnumsSequencesExceptionsAPI PrinciplesRelationship between Specification, Implementation and InstancesObject CompositionUNO ConceptsUNO is an environment for networked object communicationInterprocess ConnectionsServiceManager and ComponentContextUsing UNO InterfacesUsing PropertiesUsing Collections and ContainersEvent ModelException HandlingLifetime ControlObject IdentityLanguage BindingsIntroduction for language bindingJava Language BindingC++ BindingAccess for [PRODUCTNAME] BasicAutomationWriting UNO componentsSpecifying a new ComponentUNOIDL language specificationImplementing a ComponentComponent Development BasicsIntroductionMandatory interfaces: XInterface, XServiceInfo ((from UseInterfaces.CoreInterfaces))"Should be implemented" interfaces: XTypeProvider ((from UseInterfaces.CoreInterfaces ))optional interface: XMain for standalone executionSimple Component in JavaGetting the service manager ((Chapter Java components from unoBindingJava))simple component chapterC++ Component((Automation Component?))Deployment Options for ComponentsComponent RegistrationService Manager ConfigurationXSet InterfaceAdding components during runtime, particularly interesting during developmentServiceManager ContentDynamically modifying the ServiceManagerBootstrapping the Service Manager ((from CppBind chapter))Simple Test ApplicationConfiguring Your Application with Bootstrap ParametersThe UNO ExecutableStandalone Runtime EnvironmentThe UNO executable and XMainConfiguring the Java Runtime EnvironmentThe office and Java ((from UnoBindingJava))Advanced UNODesign PatternsBridging conceptsRequirements for Language Bindings and BridgesNew Scripting EnginesServiceManager and loaderSpecial Interfaces for internal useXUNOTunnelXAggregationUNO Reflection APITypeLibrary and TypeProvidersDifferences from CorbaOffice DevelopmentGlobal Object StructureDesktop EnvironmentFrames and Frame HierarchiesFrame-Controller-Model ParadigmLoading and Saving Office ComponentsDispatch FrameworkCommon FeaturesCommon DialogsDocumentInfoStylesSearch and ReplaceNumber FormatsPackage File FormatsInternationalizationLinguisticSystem IntegrationClipboardFile PickerBridging to the Window SystemText Documents (51,5 Pages)OverviewHandling Text FilesWorking with Text DocumentsNavigatingUsing TextTablesText FieldsBookmarksIndexes and Index MarksReference MarksFootnotes and EndnotesShape Objects in TextRedlineRubyGlobal Document FeaturesControlling a Text DocumentSpreadsheet DocumentsOverviewHandling Spreadsheet FilesWorking with Spreadsheet DocumentsNavigatingEditing SpreadsheetsGlobal Document FeaturesControlling a Spreadsheet DocumentExtending Capabilities of Spreadsheet DocumentsDrawings and PresentationsOverviewHandling Draw/Impress FilesSavingPrintingRunning PresentationsWorking with a Draw/Impress DocumentNavigatingWorking with Draw/Impress DocumentsGlobal Document FeaturesControlling a Draw/Impress DocumentChartsChart BasicsCreating a Chart DocumentEditing a Chart DocumentCommon Diagram APIDifferent Chart TypesExtending Capabilities of Chart DocumentsBasic and DialogsIntroductionLibrary OrganizationIDE with Dialogs and EventsUsing [PRODUCTNAME] BasicToolkit Controls and their PropertiesCreating Dialogs at RuntimeDatabase AccessFeatures of the [PRODUCTNAME] Database IntegrationCapabilitiesSDBC, SDBCX, SDB ArchitectureAccessing Datasources with [PRODUCTNAME]DataSourcesAdding and Editing Datasources Establishing a ConnectionGetting ConnectionsDriver specificsConnection PoolingWorking with Saved QueriesWorking with DataExecuting StatementsResultsetsMetadataRowsetsWorking with the Database DesignUsing DDL to change the DB DesignUsing SDBCX to access the DB DesignUsing DBMS FeaturesStored ProceduresTransaction HandlingExecuting Prepared StatementsWriting Database DriversFormsConceptsModels and ViewsForm Elements in the Document ModelSpecial Form ComponentsEventsData AwarenessRecipesMaking it easier to work with a FormControlling the Data InputCollecting Data automaticallyTaking Advantage of Database Server FeaturesAdding new FunctionalityHandling ErrorsUCBPurpose of UCBAccessing ContentsOpening Folder ContentsOpening Document Contents as StreamsWorking with Content PropertiesCreating, Moving and Copying Document and Folder ContentsWorking with Additional CommandsWriting a Content Provider[PRODUCTNAME] ConfigurationAccessing configuration dataWriting Configuration DataAppendix + +Programmer's ManualPlanned OutlinePreface (3 Pages)First Steps (24 Pages)Programming with UNOFields of Application for UNOGetting StartedRequired FilesConfigurationFirst ConnectionHow to get Objects in [PRODUCTNAME]How to work with ObjectsExampleServicesQuerying InterfacesUsing PropertiesElementAccessSimple TypesStringsEnums and Constant GroupsStructsAnySequenceHow to find the solution for a problemFinding your Way through the API ReferenceCommon MechanismsTextTableDrawingUNO in Professional Projects (145)IntroductionUNO/API constituents: How UNOIDL/API, ServiceManager, Bridges, CoreReflection work togetherAPI ConceptsAPI is a language independent, abstract specification for UNO objects which are used in [PRODUCTNAME]Types in the API ReferenceSimple TypesThe Any TypeInterfacesServicesModulesStructsConstant Groups and EnumsSequencesExceptionsAPI PrinciplesRelationship between Specification, Implementation and InstancesObject CompositionUNO ConceptsUNO is an environment for networked object communicationInterprocess ConnectionsServiceManager and ComponentContextUsing UNO InterfacesUsing PropertiesUsing Collections and ContainersEvent ModelException HandlingLifetime ControlObject IdentityLanguage BindingsIntroduction for language bindingJava Language BindingC++ BindingAccess for [PRODUCTNAME] BasicAutomationWriting UNO componentsSpecifying a new ComponentUNOIDL language specificationImplementing a ComponentComponent Development BasicsIntroductionMandatory interfaces: XInterface, XServiceInfo ((from UseInterfaces.CoreInterfaces))"Should be implemented" interfaces: XTypeProvider ((from UseInterfaces.CoreInterfaces ))optional interface: XMain for standalone executionSimple Component in JavaGetting the service manager ((Chapter Java components from unoBindingJava))simple component chapterC++ Component((Automation Component?))Deployment Options for ComponentsComponent RegistrationService Manager ConfigurationXSet InterfaceAdding components during runtime, particularly interesting during developmentServiceManager ContentDynamically modifying the ServiceManagerBootstrapping the Service Manager ((from CppBind chapter))Simple Test ApplicationConfiguring Your Application with Bootstrap ParametersThe UNO ExecutableStandalone Runtime EnvironmentThe UNO executable and XMainConfiguring the Java Runtime EnvironmentThe office and Java ((from UnoBindingJava))Advanced UNODesign PatternsBridging conceptsRequirements for Language Bindings and BridgesNew Scripting EnginesServiceManager and loaderSpecial Interfaces for internal useXUNOTunnelXAggregationUNO Reflection APITypeLibrary and TypeProvidersDifferences from CorbaOffice DevelopmentGlobal Object StructureDesktop EnvironmentFrames and Frame HierarchiesFrame-Controller-Model ParadigmLoading and Saving Office ComponentsDispatch FrameworkCommon FeaturesCommon DialogsDocumentInfoStylesSearch and ReplaceNumber FormatsPackage File FormatsInternationalizationLinguisticSystem IntegrationClipboardFile PickerBridging to the Window SystemText Documents (51,5 Pages)OverviewHandling Text FilesWorking with Text DocumentsNavigatingUsing TextTablesText FieldsBookmarksIndexes and Index MarksReference MarksFootnotes and EndnotesShape Objects in TextRedlineRubyGlobal Document FeaturesControlling a Text DocumentSpreadsheet DocumentsOverviewHandling Spreadsheet FilesWorking with Spreadsheet DocumentsNavigatingEditing SpreadsheetsGlobal Document FeaturesControlling a Spreadsheet DocumentExtending Capabilities of Spreadsheet DocumentsDrawings and PresentationsOverviewHandling Draw/Impress FilesSavingPrintingRunning PresentationsWorking with a Draw/Impress DocumentNavigatingWorking with Draw/Impress DocumentsGlobal Document FeaturesControlling a Draw/Impress DocumentChartsChart BasicsCreating a Chart DocumentEditing a Chart DocumentCommon Diagram APIDifferent Chart TypesExtending Capabilities of Chart DocumentsBasic and DialogsIntroductionLibrary OrganizationIDE with Dialogs and EventsUsing [PRODUCTNAME] BasicToolkit Controls and their PropertiesCreating Dialogs at RuntimeDatabase AccessFeatures of the [PRODUCTNAME] Database IntegrationCapabilitiesSDBC, SDBCX, SDB ArchitectureAccessing Datasources with [PRODUCTNAME]DataSourcesAdding and Editing Datasources Establishing a ConnectionGetting ConnectionsDriver specificsConnection PoolingWorking with Saved QueriesWorking with DataExecuting StatementsResultsetsMetadataRowsetsWorking with the Database DesignUsing DDL to change the DB DesignUsing SDBCX to access the DB DesignUsing DBMS FeaturesStored ProceduresTransaction HandlingExecuting Prepared StatementsWriting Database DriversFormsConceptsModels and ViewsForm Elements in the Document ModelSpecial Form ComponentsEventsData AwarenessRecipesMaking it easier to work with a FormControlling the Data InputCollecting Data automaticallyTaking Advantage of Database Server FeaturesAdding new FunctionalityHandling ErrorsUCBPurpose of UCBAccessing ContentsOpening Folder ContentsOpening Document Contents as StreamsWorking with Content PropertiesCreating, Moving and Copying Document and Folder ContentsWorking with Additional CommandsWriting a Content Provider[PRODUCTNAME] ConfigurationAccessing configuration dataWriting Configuration DataAppendix + +Programmer's ManualPlanned OutlinePreface (3 Pages)First Steps (24 Pages)Programming with UNOFields of Application for UNOGetting StartedRequired FilesConfigurationFirst ConnectionHow to get Objects in [PRODUCTNAME]How to work with ObjectsExampleServicesQuerying InterfacesUsing PropertiesElementAccessSimple TypesStringsEnums and Constant GroupsStructsAnySequenceHow to find the solution for a problemFinding your Way through the API ReferenceCommon MechanismsTextTableDrawingUNO in Professional Projects (145)IntroductionUNO/API constituents: How UNOIDL/API, ServiceManager, Bridges, CoreReflection work togetherAPI ConceptsAPI is a language independent, abstract specification for UNO objects which are used in [PRODUCTNAME]Types in the API ReferenceSimple TypesThe Any TypeInterfacesServicesModulesStructsConstant Groups and EnumsSequencesExceptionsAPI PrinciplesRelationship between Specification, Implementation and InstancesObject CompositionUNO ConceptsUNO is an environment for networked object communicationInterprocess ConnectionsServiceManager and ComponentContextUsing UNO InterfacesUsing PropertiesUsing Collections and ContainersEvent ModelException HandlingLifetime ControlObject IdentityLanguage BindingsIntroduction for language bindingJava Language BindingC++ BindingAccess for [PRODUCTNAME] BasicAutomationWriting UNO componentsSpecifying a new ComponentUNOIDL language specificationImplementing a ComponentComponent Development BasicsIntroductionMandatory interfaces: XInterface, XServiceInfo ((from UseInterfaces.CoreInterfaces))"Should be implemented" interfaces: XTypeProvider ((from UseInterfaces.CoreInterfaces ))optional interface: XMain for standalone executionSimple Component in JavaGetting the service manager ((Chapter Java components from unoBindingJava))simple component chapterC++ Component((Automation Component?))Deployment Options for ComponentsComponent RegistrationService Manager ConfigurationXSet InterfaceAdding components during runtime, particularly interesting during developmentServiceManager ContentDynamically modifying the ServiceManagerBootstrapping the Service Manager ((from CppBind chapter))Simple Test ApplicationConfiguring Your Application with Bootstrap ParametersThe UNO ExecutableStandalone Runtime EnvironmentThe UNO executable and XMainConfiguring the Java Runtime EnvironmentThe office and Java ((from UnoBindingJava))Advanced UNODesign PatternsBridging conceptsRequirements for Language Bindings and BridgesNew Scripting EnginesServiceManager and loaderSpecial Interfaces for internal useXUNOTunnelXAggregationUNO Reflection APITypeLibrary and TypeProvidersDifferences from CorbaOffice DevelopmentGlobal Object StructureDesktop EnvironmentFrames and Frame HierarchiesFrame-Controller-Model ParadigmLoading and Saving Office ComponentsDispatch FrameworkCommon FeaturesCommon DialogsDocumentInfoStylesSearch and ReplaceNumber FormatsPackage File FormatsInternationalizationLinguisticSystem IntegrationClipboardFile PickerBridging to the Window SystemText Documents (51,5 Pages)OverviewHandling Text FilesWorking with Text DocumentsNavigatingUsing TextTablesText FieldsBookmarksIndexes and Index MarksReference MarksFootnotes and EndnotesShape Objects in TextRedlineRubyGlobal Document FeaturesControlling a Text DocumentSpreadsheet DocumentsOverviewHandling Spreadsheet FilesWorking with Spreadsheet DocumentsNavigatingEditing SpreadsheetsGlobal Document FeaturesControlling a Spreadsheet DocumentExtending Capabilities of Spreadsheet DocumentsDrawings and PresentationsOverviewHandling Draw/Impress FilesSavingPrintingRunning PresentationsWorking with a Draw/Impress DocumentNavigatingWorking with Draw/Impress DocumentsGlobal Document FeaturesControlling a Draw/Impress DocumentChartsChart BasicsCreating a Chart DocumentEditing a Chart DocumentCommon Diagram APIDifferent Chart TypesExtending Capabilities of Chart DocumentsBasic and DialogsIntroductionLibrary OrganizationIDE with Dialogs and EventsUsing [PRODUCTNAME] BasicToolkit Controls and their PropertiesCreating Dialogs at RuntimeDatabase AccessFeatures of the [PRODUCTNAME] Database IntegrationCapabilitiesSDBC, SDBCX, SDB ArchitectureAccessing Datasources with [PRODUCTNAME]DataSourcesAdding and Editing Datasources Establishing a ConnectionGetting ConnectionsDriver specificsConnection PoolingWorking with Saved QueriesWorking with DataExecuting StatementsResultsetsMetadataRowsetsWorking with the Database DesignUsing DDL to change the DB DesignUsing SDBCX to access the DB DesignUsing DBMS FeaturesStored ProceduresTransaction HandlingExecuting Prepared StatementsWriting Database DriversFormsConceptsModels and ViewsForm Elements in the Document ModelSpecial Form ComponentsEventsData AwarenessRecipesMaking it easier to work with a FormControlling the Data InputCollecting Data automaticallyTaking Advantage of Database Server FeaturesAdding new FunctionalityHandling ErrorsUCBPurpose of UCBAccessing ContentsOpening Folder ContentsOpening Document Contents as StreamsWorking with Content PropertiesCreating, Moving and Copying Document and Folder ContentsWorking with Additional CommandsWriting a Content Provider[PRODUCTNAME] ConfigurationAccessing configuration dataWriting Configuration DataAppendix + +Programmer's ManualPlanned OutlinePreface (3 Pages)First Steps (24 Pages)Programming with UNOFields of Application for UNOGetting StartedRequired FilesConfigurationFirst ConnectionHow to get Objects in [PRODUCTNAME]How to work with ObjectsExampleServicesQuerying InterfacesUsing PropertiesElementAccessSimple TypesStringsEnums and Constant GroupsStructsAnySequenceHow to find the solution for a problemFinding your Way through the API ReferenceCommon MechanismsTextTableDrawingUNO in Professional Projects (145)IntroductionUNO/API constituents: How UNOIDL/API, ServiceManager, Bridges, CoreReflection work togetherAPI ConceptsAPI is a language independent, abstract specification for UNO objects which are used in [PRODUCTNAME]Types in the API ReferenceSimple TypesThe Any TypeInterfacesServicesModulesStructsConstant Groups and EnumsSequencesExceptionsAPI PrinciplesRelationship between Specification, Implementation and InstancesObject CompositionUNO ConceptsUNO is an environment for networked object communicationInterprocess ConnectionsServiceManager and ComponentContextUsing UNO InterfacesUsing PropertiesUsing Collections and ContainersEvent ModelException HandlingLifetime ControlObject IdentityLanguage BindingsIntroduction for language bindingJava Language BindingC++ BindingAccess for [PRODUCTNAME] BasicAutomationWriting UNO componentsSpecifying a new ComponentUNOIDL language specificationImplementing a ComponentComponent Development BasicsIntroductionMandatory interfaces: XInterface, XServiceInfo ((from UseInterfaces.CoreInterfaces))"Should be implemented" interfaces: XTypeProvider ((from UseInterfaces.CoreInterfaces ))optional interface: XMain for standalone executionSimple Component in JavaGetting the service manager ((Chapter Java components from unoBindingJava))simple component chapterC++ Component((Automation Component?))Deployment Options for ComponentsComponent RegistrationService Manager ConfigurationXSet InterfaceAdding components during runtime, particularly interesting during developmentServiceManager ContentDynamically modifying the ServiceManagerBootstrapping the Service Manager ((from CppBind chapter))Simple Test ApplicationConfiguring Your Application with Bootstrap ParametersThe UNO ExecutableStandalone Runtime EnvironmentThe UNO executable and XMainConfiguring the Java Runtime EnvironmentThe office and Java ((from UnoBindingJava))Advanced UNODesign PatternsBridging conceptsRequirements for Language Bindings and BridgesNew Scripting EnginesServiceManager and loaderSpecial Interfaces for internal useXUNOTunnelXAggregationUNO Reflection APITypeLibrary and TypeProvidersDifferences from CorbaOffice DevelopmentGlobal Object StructureDesktop EnvironmentFrames and Frame HierarchiesFrame-Controller-Model ParadigmLoading and Saving Office ComponentsDispatch FrameworkCommon FeaturesCommon DialogsDocumentInfoStylesSearch and ReplaceNumber FormatsPackage File FormatsInternationalizationLinguisticSystem IntegrationClipboardFile PickerBridging to the Window SystemText Documents (51,5 Pages)OverviewHandling Text FilesWorking with Text DocumentsNavigatingUsing TextTablesText FieldsBookmarksIndexes and Index MarksReference MarksFootnotes and EndnotesShape Objects in TextRedlineRubyGlobal Document FeaturesControlling a Text DocumentSpreadsheet DocumentsOverviewHandling Spreadsheet FilesWorking with Spreadsheet DocumentsNavigatingEditing SpreadsheetsGlobal Document FeaturesControlling a Spreadsheet DocumentExtending Capabilities of Spreadsheet DocumentsDrawings and PresentationsOverviewHandling Draw/Impress FilesSavingPrintingRunning PresentationsWorking with a Draw/Impress DocumentNavigatingWorking with Draw/Impress DocumentsGlobal Document FeaturesControlling a Draw/Impress DocumentChartsChart BasicsCreating a Chart DocumentEditing a Chart DocumentCommon Diagram APIDifferent Chart TypesExtending Capabilities of Chart DocumentsBasic and DialogsIntroductionLibrary OrganizationIDE with Dialogs and EventsUsing [PRODUCTNAME] BasicToolkit Controls and their PropertiesCreating Dialogs at RuntimeDatabase AccessFeatures of the [PRODUCTNAME] Database IntegrationCapabilitiesSDBC, SDBCX, SDB ArchitectureAccessing Datasources with [PRODUCTNAME]DataSourcesAdding and Editing Datasources Establishing a ConnectionGetting ConnectionsDriver specificsConnection PoolingWorking with Saved QueriesWorking with DataExecuting StatementsResultsetsMetadataRowsetsWorking with the Database DesignUsing DDL to change the DB DesignUsing SDBCX to access the DB DesignUsing DBMS FeaturesStored ProceduresTransaction HandlingExecuting Prepared StatementsWriting Database DriversFormsConceptsModels and ViewsForm Elements in the Document ModelSpecial Form ComponentsEventsData AwarenessRecipesMaking it easier to work with a FormControlling the Data InputCollecting Data automaticallyTaking Advantage of Database Server FeaturesAdding new FunctionalityHandling ErrorsUCBPurpose of UCBAccessing ContentsOpening Folder ContentsOpening Document Contents as StreamsWorking with Content PropertiesCreating, Moving and Copying Document and Folder ContentsWorking with Additional CommandsWriting a Content Provider[PRODUCTNAME] ConfigurationAccessing configuration dataWriting Configuration DataAppendix + +Programmer's ManualPlanned OutlinePreface (3 Pages)First Steps (24 Pages)Programming with UNOFields of Application for UNOGetting StartedRequired FilesConfigurationFirst ConnectionHow to get Objects in [PRODUCTNAME]How to work with ObjectsExampleServicesQuerying InterfacesUsing PropertiesElementAccessSimple TypesStringsEnums and Constant GroupsStructsAnySequenceHow to find the solution for a problemFinding your Way through the API ReferenceCommon MechanismsTextTableDrawingUNO in Professional Projects (145)IntroductionUNO/API constituents: How UNOIDL/API, ServiceManager, Bridges, CoreReflection work togetherAPI ConceptsAPI is a language independent, abstract specification for UNO objects which are used in [PRODUCTNAME]Types in the API ReferenceSimple TypesThe Any TypeInterfacesServicesModulesStructsConstant Groups and EnumsSequencesExceptionsAPI PrinciplesRelationship between Specification, Implementation and InstancesObject CompositionUNO ConceptsUNO is an environment for networked object communicationInterprocess ConnectionsServiceManager and ComponentContextUsing UNO InterfacesUsing PropertiesUsing Collections and ContainersEvent ModelException HandlingLifetime ControlObject IdentityLanguage BindingsIntroduction for language bindingJava Language BindingC++ BindingAccess for [PRODUCTNAME] BasicAutomationWriting UNO componentsSpecifying a new ComponentUNOIDL language specificationImplementing a ComponentComponent Development BasicsIntroductionMandatory interfaces: XInterface, XServiceInfo ((from UseInterfaces.CoreInterfaces))"Should be implemented" interfaces: XTypeProvider ((from UseInterfaces.CoreInterfaces ))optional interface: XMain for standalone executionSimple Component in JavaGetting the service manager ((Chapter Java components from unoBindingJava))simple component chapterC++ Component((Automation Component?))Deployment Options for ComponentsComponent RegistrationService Manager ConfigurationXSet InterfaceAdding components during runtime, particularly interesting during developmentServiceManager ContentDynamically modifying the ServiceManagerBootstrapping the Service Manager ((from CppBind chapter))Simple Test ApplicationConfiguring Your Application with Bootstrap ParametersThe UNO ExecutableStandalone Runtime EnvironmentThe UNO executable and XMainConfiguring the Java Runtime EnvironmentThe office and Java ((from UnoBindingJava))Advanced UNODesign PatternsBridging conceptsRequirements for Language Bindings and BridgesNew Scripting EnginesServiceManager and loaderSpecial Interfaces for internal useXUNOTunnelXAggregationUNO Reflection APITypeLibrary and TypeProvidersDifferences from CorbaOffice DevelopmentGlobal Object StructureDesktop EnvironmentFrames and Frame HierarchiesFrame-Controller-Model ParadigmLoading and Saving Office ComponentsDispatch FrameworkCommon FeaturesCommon DialogsDocumentInfoStylesSearch and ReplaceNumber FormatsPackage File FormatsInternationalizationLinguisticSystem IntegrationClipboardFile PickerBridging to the Window SystemText Documents (51,5 Pages)OverviewHandling Text FilesWorking with Text DocumentsNavigatingUsing TextTablesText FieldsBookmarksIndexes and Index MarksReference MarksFootnotes and EndnotesShape Objects in TextRedlineRubyGlobal Document FeaturesControlling a Text DocumentSpreadsheet DocumentsOverviewHandling Spreadsheet FilesWorking with Spreadsheet DocumentsNavigatingEditing SpreadsheetsGlobal Document FeaturesControlling a Spreadsheet DocumentExtending Capabilities of Spreadsheet DocumentsDrawings and PresentationsOverviewHandling Draw/Impress FilesSavingPrintingRunning PresentationsWorking with a Draw/Impress DocumentNavigatingWorking with Draw/Impress DocumentsGlobal Document FeaturesControlling a Draw/Impress DocumentChartsChart BasicsCreating a Chart DocumentEditing a Chart DocumentCommon Diagram APIDifferent Chart TypesExtending Capabilities of Chart DocumentsBasic and DialogsIntroductionLibrary OrganizationIDE with Dialogs and EventsUsing [PRODUCTNAME] BasicToolkit Controls and their PropertiesCreating Dialogs at RuntimeDatabase AccessFeatures of the [PRODUCTNAME] Database IntegrationCapabilitiesSDBC, SDBCX, SDB ArchitectureAccessing Datasources with [PRODUCTNAME]DataSourcesAdding and Editing Datasources Establishing a ConnectionGetting ConnectionsDriver specificsConnection PoolingWorking with Saved QueriesWorking with DataExecuting StatementsResultsetsMetadataRowsetsWorking with the Database DesignUsing DDL to change the DB DesignUsing SDBCX to access the DB DesignUsing DBMS FeaturesStored ProceduresTransaction HandlingExecuting Prepared StatementsWriting Database DriversFormsConceptsModels and ViewsForm Elements in the Document ModelSpecial Form ComponentsEventsData AwarenessRecipesMaking it easier to work with a FormControlling the Data InputCollecting Data automaticallyTaking Advantage of Database Server FeaturesAdding new FunctionalityHandling ErrorsUCBPurpose of UCBAccessing ContentsOpening Folder ContentsOpening Document Contents as StreamsWorking with Content PropertiesCreating, Moving and Copying Document and Folder ContentsWorking with Additional CommandsWriting a Content Provider[PRODUCTNAME] ConfigurationAccessing configuration dataWriting Configuration DataAppendix + +Programmer's ManualPlanned OutlinePreface (3 Pages)First Steps (24 Pages)Programming with UNOFields of Application for UNOGetting StartedRequired FilesConfigurationFirst ConnectionHow to get Objects in [PRODUCTNAME]How to work with ObjectsExampleServicesQuerying InterfacesUsing PropertiesElementAccessSimple TypesStringsEnums and Constant GroupsStructsAnySequenceHow to find the solution for a problemFinding your Way through the API ReferenceCommon MechanismsTextTableDrawingUNO in Professional Projects (145)IntroductionUNO/API constituents: How UNOIDL/API, ServiceManager, Bridges, CoreReflection work togetherAPI ConceptsAPI is a language independent, abstract specification for UNO objects which are used in [PRODUCTNAME]Types in the API ReferenceSimple TypesThe Any TypeInterfacesServicesModulesStructsConstant Groups and EnumsSequencesExceptionsAPI PrinciplesRelationship between Specification, Implementation and InstancesObject CompositionUNO ConceptsUNO is an environment for networked object communicationInterprocess ConnectionsServiceManager and ComponentContextUsing UNO InterfacesUsing PropertiesUsing Collections and ContainersEvent ModelException HandlingLifetime ControlObject IdentityLanguage BindingsIntroduction for language bindingJava Language BindingC++ BindingAccess for [PRODUCTNAME] BasicAutomationWriting UNO componentsSpecifying a new ComponentUNOIDL language specificationImplementing a ComponentComponent Development BasicsIntroductionMandatory interfaces: XInterface, XServiceInfo ((from UseInterfaces.CoreInterfaces))"Should be implemented" interfaces: XTypeProvider ((from UseInterfaces.CoreInterfaces ))optional interface: XMain for standalone executionSimple Component in JavaGetting the service manager ((Chapter Java components from unoBindingJava))simple component chapterC++ Component((Automation Component?))Deployment Options for ComponentsComponent RegistrationService Manager ConfigurationXSet InterfaceAdding components during runtime, particularly interesting during developmentServiceManager ContentDynamically modifying the ServiceManagerBootstrapping the Service Manager ((from CppBind chapter))Simple Test ApplicationConfiguring Your Application with Bootstrap ParametersThe UNO ExecutableStandalone Runtime EnvironmentThe UNO executable and XMainConfiguring the Java Runtime EnvironmentThe office and Java ((from UnoBindingJava))Advanced UNODesign PatternsBridging conceptsRequirements for Language Bindings and BridgesNew Scripting EnginesServiceManager and loaderSpecial Interfaces for internal useXUNOTunnelXAggregationUNO Reflection APITypeLibrary and TypeProvidersDifferences from CorbaOffice DevelopmentGlobal Object StructureDesktop EnvironmentFrames and Frame HierarchiesFrame-Controller-Model ParadigmLoading and Saving Office ComponentsDispatch FrameworkCommon FeaturesCommon DialogsDocumentInfoStylesSearch and ReplaceNumber FormatsPackage File FormatsInternationalizationLinguisticSystem IntegrationClipboardFile PickerBridging to the Window SystemText Documents (51,5 Pages)OverviewHandling Text FilesWorking with Text DocumentsNavigatingUsing TextTablesText FieldsBookmarksIndexes and Index MarksReference MarksFootnotes and EndnotesShape Objects in TextRedlineRubyGlobal Document FeaturesControlling a Text DocumentSpreadsheet DocumentsOverviewHandling Spreadsheet FilesWorking with Spreadsheet DocumentsNavigatingEditing SpreadsheetsGlobal Document FeaturesControlling a Spreadsheet DocumentExtending Capabilities of Spreadsheet DocumentsDrawings and PresentationsOverviewHandling Draw/Impress FilesSavingPrintingRunning PresentationsWorking with a Draw/Impress DocumentNavigatingWorking with Draw/Impress DocumentsGlobal Document FeaturesControlling a Draw/Impress DocumentChartsChart BasicsCreating a Chart DocumentEditing a Chart DocumentCommon Diagram APIDifferent Chart TypesExtending Capabilities of Chart DocumentsBasic and DialogsIntroductionLibrary OrganizationIDE with Dialogs and EventsUsing [PRODUCTNAME] BasicToolkit Controls and their PropertiesCreating Dialogs at RuntimeDatabase AccessFeatures of the [PRODUCTNAME] Database IntegrationCapabilitiesSDBC, SDBCX, SDB ArchitectureAccessing Datasources with [PRODUCTNAME]DataSourcesAdding and Editing Datasources Establishing a ConnectionGetting ConnectionsDriver specificsConnection PoolingWorking with Saved QueriesWorking with DataExecuting StatementsResultsetsMetadataRowsetsWorking with the Database DesignUsing DDL to change the DB DesignUsing SDBCX to access the DB DesignUsing DBMS FeaturesStored ProceduresTransaction HandlingExecuting Prepared StatementsWriting Database DriversFormsConceptsModels and ViewsForm Elements in the Document ModelSpecial Form ComponentsEventsData AwarenessRecipesMaking it easier to work with a FormControlling the Data InputCollecting Data automaticallyTaking Advantage of Database Server FeaturesAdding new FunctionalityHandling ErrorsUCBPurpose of UCBAccessing ContentsOpening Folder ContentsOpening Document Contents as StreamsWorking with Content PropertiesCreating, Moving and Copying Document and Folder ContentsWorking with Additional CommandsWriting a Content Provider[PRODUCTNAME] ConfigurationAccessing configuration dataWriting Configuration DataAppendix + +Programmer's ManualPlanned OutlinePreface (3 Pages)First Steps (24 Pages)Programming with UNOFields of Application for UNOGetting StartedRequired FilesConfigurationFirst ConnectionHow to get Objects in [PRODUCTNAME]How to work with ObjectsExampleServicesQuerying InterfacesUsing PropertiesElementAccessSimple TypesStringsEnums and Constant GroupsStructsAnySequenceHow to find the solution for a problemFinding your Way through the API ReferenceCommon MechanismsTextTableDrawingUNO in Professional Projects (145)IntroductionUNO/API constituents: How UNOIDL/API, ServiceManager, Bridges, CoreReflection work togetherAPI ConceptsAPI is a language independent, abstract specification for UNO objects which are used in [PRODUCTNAME]Types in the API ReferenceSimple TypesThe Any TypeInterfacesServicesModulesStructsConstant Groups and EnumsSequencesExceptionsAPI PrinciplesRelationship between Specification, Implementation and InstancesObject CompositionUNO ConceptsUNO is an environment for networked object communicationInterprocess ConnectionsServiceManager and ComponentContextUsing UNO InterfacesUsing PropertiesUsing Collections and ContainersEvent ModelException HandlingLifetime ControlObject IdentityLanguage BindingsIntroduction for language bindingJava Language BindingC++ BindingAccess for [PRODUCTNAME] BasicAutomationWriting UNO componentsSpecifying a new ComponentUNOIDL language specificationImplementing a ComponentComponent Development BasicsIntroductionMandatory interfaces: XInterface, XServiceInfo ((from UseInterfaces.CoreInterfaces))"Should be implemented" interfaces: XTypeProvider ((from UseInterfaces.CoreInterfaces ))optional interface: XMain for standalone executionSimple Component in JavaGetting the service manager ((Chapter Java components from unoBindingJava))simple component chapterC++ Component((Automation Component?))Deployment Options for ComponentsComponent RegistrationService Manager ConfigurationXSet InterfaceAdding components during runtime, particularly interesting during developmentServiceManager ContentDynamically modifying the ServiceManagerBootstrapping the Service Manager ((from CppBind chapter))Simple Test ApplicationConfiguring Your Application with Bootstrap ParametersThe UNO ExecutableStandalone Runtime EnvironmentThe UNO executable and XMainConfiguring the Java Runtime EnvironmentThe office and Java ((from UnoBindingJava))Advanced UNODesign PatternsBridging conceptsRequirements for Language Bindings and BridgesNew Scripting EnginesServiceManager and loaderSpecial Interfaces for internal useXUNOTunnelXAggregationUNO Reflection APITypeLibrary and TypeProvidersDifferences from CorbaOffice DevelopmentGlobal Object StructureDesktop EnvironmentFrames and Frame HierarchiesFrame-Controller-Model ParadigmLoading and Saving Office ComponentsDispatch FrameworkCommon FeaturesCommon DialogsDocumentInfoStylesSearch and ReplaceNumber FormatsPackage File FormatsInternationalizationLinguisticSystem IntegrationClipboardFile PickerBridging to the Window SystemText Documents (51,5 Pages)OverviewHandling Text FilesWorking with Text DocumentsNavigatingUsing TextTablesText FieldsBookmarksIndexes and Index MarksReference MarksFootnotes and EndnotesShape Objects in TextRedlineRubyGlobal Document FeaturesControlling a Text DocumentSpreadsheet DocumentsOverviewHandling Spreadsheet FilesWorking with Spreadsheet DocumentsNavigatingEditing SpreadsheetsGlobal Document FeaturesControlling a Spreadsheet DocumentExtending Capabilities of Spreadsheet DocumentsDrawings and PresentationsOverviewHandling Draw/Impress FilesSavingPrintingRunning PresentationsWorking with a Draw/Impress DocumentNavigatingWorking with Draw/Impress DocumentsGlobal Document FeaturesControlling a Draw/Impress DocumentChartsChart BasicsCreating a Chart DocumentEditing a Chart DocumentCommon Diagram APIDifferent Chart TypesExtending Capabilities of Chart DocumentsBasic and DialogsIntroductionLibrary OrganizationIDE with Dialogs and EventsUsing [PRODUCTNAME] BasicToolkit Controls and their PropertiesCreating Dialogs at RuntimeDatabase AccessFeatures of the [PRODUCTNAME] Database IntegrationCapabilitiesSDBC, SDBCX, SDB ArchitectureAccessing Datasources with [PRODUCTNAME]DataSourcesAdding and Editing Datasources Establishing a ConnectionGetting ConnectionsDriver specificsConnection PoolingWorking with Saved QueriesWorking with DataExecuting StatementsResultsetsMetadataRowsetsWorking with the Database DesignUsing DDL to change the DB DesignUsing SDBCX to access the DB DesignUsing DBMS FeaturesStored ProceduresTransaction HandlingExecuting Prepared StatementsWriting Database DriversFormsConceptsModels and ViewsForm Elements in the Document ModelSpecial Form ComponentsEventsData AwarenessRecipesMaking it easier to work with a FormControlling the Data InputCollecting Data automaticallyTaking Advantage of Database Server FeaturesAdding new FunctionalityHandling ErrorsUCBPurpose of UCBAccessing ContentsOpening Folder ContentsOpening Document Contents as StreamsWorking with Content PropertiesCreating, Moving and Copying Document and Folder ContentsWorking with Additional CommandsWriting a Content Provider[PRODUCTNAME] ConfigurationAccessing configuration dataWriting Configuration DataAppendix + +Programmer's ManualPlanned OutlinePreface (3 Pages)First Steps (24 Pages)Programming with UNOFields of Application for UNOGetting StartedRequired FilesConfigurationFirst ConnectionHow to get Objects in [PRODUCTNAME]How to work with ObjectsExampleServicesQuerying InterfacesUsing PropertiesElementAccessSimple TypesStringsEnums and Constant GroupsStructsAnySequenceHow to find the solution for a problemFinding your Way through the API ReferenceCommon MechanismsTextTableDrawingUNO in Professional Projects (145)IntroductionUNO/API constituents: How UNOIDL/API, ServiceManager, Bridges, CoreReflection work togetherAPI ConceptsAPI is a language independent, abstract specification for UNO objects which are used in [PRODUCTNAME]Types in the API ReferenceSimple TypesThe Any TypeInterfacesServicesModulesStructsConstant Groups and EnumsSequencesExceptionsAPI PrinciplesRelationship between Specification, Implementation and InstancesObject CompositionUNO ConceptsUNO is an environment for networked object communicationInterprocess ConnectionsServiceManager and ComponentContextUsing UNO InterfacesUsing PropertiesUsing Collections and ContainersEvent ModelException HandlingLifetime ControlObject IdentityLanguage BindingsIntroduction for language bindingJava Language BindingC++ BindingAccess for [PRODUCTNAME] BasicAutomationWriting UNO componentsSpecifying a new ComponentUNOIDL language specificationImplementing a ComponentComponent Development BasicsIntroductionMandatory interfaces: XInterface, XServiceInfo ((from UseInterfaces.CoreInterfaces))"Should be implemented" interfaces: XTypeProvider ((from UseInterfaces.CoreInterfaces ))optional interface: XMain for standalone executionSimple Component in JavaGetting the service manager ((Chapter Java components from unoBindingJava))simple component chapterC++ Component((Automation Component?))Deployment Options for ComponentsComponent RegistrationService Manager ConfigurationXSet InterfaceAdding components during runtime, particularly interesting during developmentServiceManager ContentDynamically modifying the ServiceManagerBootstrapping the Service Manager ((from CppBind chapter))Simple Test ApplicationConfiguring Your Application with Bootstrap ParametersThe UNO ExecutableStandalone Runtime EnvironmentThe UNO executable and XMainConfiguring the Java Runtime EnvironmentThe office and Java ((from UnoBindingJava))Advanced UNODesign PatternsBridging conceptsRequirements for Language Bindings and BridgesNew Scripting EnginesServiceManager and loaderSpecial Interfaces for internal useXUNOTunnelXAggregationUNO Reflection APITypeLibrary and TypeProvidersDifferences from CorbaOffice DevelopmentGlobal Object StructureDesktop EnvironmentFrames and Frame HierarchiesFrame-Controller-Model ParadigmLoading and Saving Office ComponentsDispatch FrameworkCommon FeaturesCommon DialogsDocumentInfoStylesSearch and ReplaceNumber FormatsPackage File FormatsInternationalizationLinguisticSystem IntegrationClipboardFile PickerBridging to the Window SystemText Documents (51,5 Pages)OverviewHandling Text FilesWorking with Text DocumentsNavigatingUsing TextTablesText FieldsBookmarksIndexes and Index MarksReference MarksFootnotes and EndnotesShape Objects in TextRedlineRubyGlobal Document FeaturesControlling a Text DocumentSpreadsheet DocumentsOverviewHandling Spreadsheet FilesWorking with Spreadsheet DocumentsNavigatingEditing SpreadsheetsGlobal Document FeaturesControlling a Spreadsheet DocumentExtending Capabilities of Spreadsheet DocumentsDrawings and PresentationsOverviewHandling Draw/Impress FilesSavingPrintingRunning PresentationsWorking with a Draw/Impress DocumentNavigatingWorking with Draw/Impress DocumentsGlobal Document FeaturesControlling a Draw/Impress DocumentChartsChart BasicsCreating a Chart DocumentEditing a Chart DocumentCommon Diagram APIDifferent Chart TypesExtending Capabilities of Chart DocumentsBasic and DialogsIntroductionLibrary OrganizationIDE with Dialogs and EventsUsing [PRODUCTNAME] BasicToolkit Controls and their PropertiesCreating Dialogs at RuntimeDatabase AccessFeatures of the [PRODUCTNAME] Database IntegrationCapabilitiesSDBC, SDBCX, SDB ArchitectureAccessing Datasources with [PRODUCTNAME]DataSourcesAdding and Editing Datasources Establishing a ConnectionGetting ConnectionsDriver specificsConnection PoolingWorking with Saved QueriesWorking with DataExecuting StatementsResultsetsMetadataRowsetsWorking with the Database DesignUsing DDL to change the DB DesignUsing SDBCX to access the DB DesignUsing DBMS FeaturesStored ProceduresTransaction HandlingExecuting Prepared StatementsWriting Database DriversFormsConceptsModels and ViewsForm Elements in the Document ModelSpecial Form ComponentsEventsData AwarenessRecipesMaking it easier to work with a FormControlling the Data InputCollecting Data automaticallyTaking Advantage of Database Server FeaturesAdding new FunctionalityHandling ErrorsUCBPurpose of UCBAccessing ContentsOpening Folder ContentsOpening Document Contents as StreamsWorking with Content PropertiesCreating, Moving and Copying Document and Folder ContentsWorking with Additional CommandsWriting a Content Provider[PRODUCTNAME] ConfigurationAccessing configuration dataWriting Configuration DataAppendix + +Programmer's ManualPlanned OutlinePreface (3 Pages)First Steps (24 Pages)Programming with UNOFields of Application for UNOGetting StartedRequired FilesConfigurationFirst ConnectionHow to get Objects in [PRODUCTNAME]How to work with ObjectsExampleServicesQuerying InterfacesUsing PropertiesElementAccessSimple TypesStringsEnums and Constant GroupsStructsAnySequenceHow to find the solution for a problemFinding your Way through the API ReferenceCommon MechanismsTextTableDrawingUNO in Professional Projects (145)IntroductionUNO/API constituents: How UNOIDL/API, ServiceManager, Bridges, CoreReflection work togetherAPI ConceptsAPI is a language independent, abstract specification for UNO objects which are used in [PRODUCTNAME]Types in the API ReferenceSimple TypesThe Any TypeInterfacesServicesModulesStructsConstant Groups and EnumsSequencesExceptionsAPI PrinciplesRelationship between Specification, Implementation and InstancesObject CompositionUNO ConceptsUNO is an environment for networked object communicationInterprocess ConnectionsServiceManager and ComponentContextUsing UNO InterfacesUsing PropertiesUsing Collections and ContainersEvent ModelException HandlingLifetime ControlObject IdentityLanguage BindingsIntroduction for language bindingJava Language BindingC++ BindingAccess for [PRODUCTNAME] BasicAutomationWriting UNO componentsSpecifying a new ComponentUNOIDL language specificationImplementing a ComponentComponent Development BasicsIntroductionMandatory interfaces: XInterface, XServiceInfo ((from UseInterfaces.CoreInterfaces))"Should be implemented" interfaces: XTypeProvider ((from UseInterfaces.CoreInterfaces ))optional interface: XMain for standalone executionSimple Component in JavaGetting the service manager ((Chapter Java components from unoBindingJava))simple component chapterC++ Component((Automation Component?))Deployment Options for ComponentsComponent RegistrationService Manager ConfigurationXSet InterfaceAdding components during runtime, particularly interesting during developmentServiceManager ContentDynamically modifying the ServiceManagerBootstrapping the Service Manager ((from CppBind chapter))Simple Test ApplicationConfiguring Your Application with Bootstrap ParametersThe UNO ExecutableStandalone Runtime EnvironmentThe UNO executable and XMainConfiguring the Java Runtime EnvironmentThe office and Java ((from UnoBindingJava))Advanced UNODesign PatternsBridging conceptsRequirements for Language Bindings and BridgesNew Scripting EnginesServiceManager and loaderSpecial Interfaces for internal useXUNOTunnelXAggregationUNO Reflection APITypeLibrary and TypeProvidersDifferences from CorbaOffice DevelopmentGlobal Object StructureDesktop EnvironmentFrames and Frame HierarchiesFrame-Controller-Model ParadigmLoading and Saving Office ComponentsDispatch FrameworkCommon FeaturesCommon DialogsDocumentInfoStylesSearch and ReplaceNumber FormatsPackage File FormatsInternationalizationLinguisticSystem IntegrationClipboardFile PickerBridging to the Window SystemText Documents (51,5 Pages)OverviewHandling Text FilesWorking with Text DocumentsNavigatingUsing TextTablesText FieldsBookmarksIndexes and Index MarksReference MarksFootnotes and EndnotesShape Objects in TextRedlineRubyGlobal Document FeaturesControlling a Text DocumentSpreadsheet DocumentsOverviewHandling Spreadsheet FilesWorking with Spreadsheet DocumentsNavigatingEditing SpreadsheetsGlobal Document FeaturesControlling a Spreadsheet DocumentExtending Capabilities of Spreadsheet DocumentsDrawings and PresentationsOverviewHandling Draw/Impress FilesSavingPrintingRunning PresentationsWorking with a Draw/Impress DocumentNavigatingWorking with Draw/Impress DocumentsGlobal Document FeaturesControlling a Draw/Impress DocumentChartsChart BasicsCreating a Chart DocumentEditing a Chart DocumentCommon Diagram APIDifferent Chart TypesExtending Capabilities of Chart DocumentsBasic and DialogsIntroductionLibrary OrganizationIDE with Dialogs and EventsUsing [PRODUCTNAME] BasicToolkit Controls and their PropertiesCreating Dialogs at RuntimeDatabase AccessFeatures of the [PRODUCTNAME] Database IntegrationCapabilitiesSDBC, SDBCX, SDB ArchitectureAccessing Datasources with [PRODUCTNAME]DataSourcesAdding and Editing Datasources Establishing a ConnectionGetting ConnectionsDriver specificsConnection PoolingWorking with Saved QueriesWorking with DataExecuting StatementsResultsetsMetadataRowsetsWorking with the Database DesignUsing DDL to change the DB DesignUsing SDBCX to access the DB DesignUsing DBMS FeaturesStored ProceduresTransaction HandlingExecuting Prepared StatementsWriting Database DriversFormsConceptsModels and ViewsForm Elements in the Document ModelSpecial Form ComponentsEventsData AwarenessRecipesMaking it easier to work with a FormControlling the Data InputCollecting Data automaticallyTaking Advantage of Database Server FeaturesAdding new FunctionalityHandling ErrorsUCBPurpose of UCBAccessing ContentsOpening Folder ContentsOpening Document Contents as StreamsWorking with Content PropertiesCreating, Moving and Copying Document and Folder ContentsWorking with Additional CommandsWriting a Content Provider[PRODUCTNAME] ConfigurationAccessing configuration dataWriting Configuration DataAppendix + +Programmer's ManualPlanned OutlinePreface (3 Pages)First Steps (24 Pages)Programming with UNOFields of Application for UNOGetting StartedRequired FilesConfigurationFirst ConnectionHow to get Objects in [PRODUCTNAME]How to work with ObjectsExampleServicesQuerying InterfacesUsing PropertiesElementAccessSimple TypesStringsEnums and Constant GroupsStructsAnySequenceHow to find the solution for a problemFinding your Way through the API ReferenceCommon MechanismsTextTableDrawingUNO in Professional Projects (145)IntroductionUNO/API constituents: How UNOIDL/API, ServiceManager, Bridges, CoreReflection work togetherAPI ConceptsAPI is a language independent, abstract specification for UNO objects which are used in [PRODUCTNAME]Types in the API ReferenceSimple TypesThe Any TypeInterfacesServicesModulesStructsConstant Groups and EnumsSequencesExceptionsAPI PrinciplesRelationship between Specification, Implementation and InstancesObject CompositionUNO ConceptsUNO is an environment for networked object communicationInterprocess ConnectionsServiceManager and ComponentContextUsing UNO InterfacesUsing PropertiesUsing Collections and ContainersEvent ModelException HandlingLifetime ControlObject IdentityLanguage BindingsIntroduction for language bindingJava Language BindingC++ BindingAccess for [PRODUCTNAME] BasicAutomationWriting UNO componentsSpecifying a new ComponentUNOIDL language specificationImplementing a ComponentComponent Development BasicsIntroductionMandatory interfaces: XInterface, XServiceInfo ((from UseInterfaces.CoreInterfaces))"Should be implemented" interfaces: XTypeProvider ((from UseInterfaces.CoreInterfaces ))optional interface: XMain for standalone executionSimple Component in JavaGetting the service manager ((Chapter Java components from unoBindingJava))simple component chapterC++ Component((Automation Component?))Deployment Options for ComponentsComponent RegistrationService Manager ConfigurationXSet InterfaceAdding components during runtime, particularly interesting during developmentServiceManager ContentDynamically modifying the ServiceManagerBootstrapping the Service Manager ((from CppBind chapter))Simple Test ApplicationConfiguring Your Application with Bootstrap ParametersThe UNO ExecutableStandalone Runtime EnvironmentThe UNO executable and XMainConfiguring the Java Runtime EnvironmentThe office and Java ((from UnoBindingJava))Advanced UNODesign PatternsBridging conceptsRequirements for Language Bindings and BridgesNew Scripting EnginesServiceManager and loaderSpecial Interfaces for internal useXUNOTunnelXAggregationUNO Reflection APITypeLibrary and TypeProvidersDifferences from CorbaOffice DevelopmentGlobal Object StructureDesktop EnvironmentFrames and Frame HierarchiesFrame-Controller-Model ParadigmLoading and Saving Office ComponentsDispatch FrameworkCommon FeaturesCommon DialogsDocumentInfoStylesSearch and ReplaceNumber FormatsPackage File FormatsInternationalizationLinguisticSystem IntegrationClipboardFile PickerBridging to the Window SystemText Documents (51,5 Pages)OverviewHandling Text FilesWorking with Text DocumentsNavigatingUsing TextTablesText FieldsBookmarksIndexes and Index MarksReference MarksFootnotes and EndnotesShape Objects in TextRedlineRubyGlobal Document FeaturesControlling a Text DocumentSpreadsheet DocumentsOverviewHandling Spreadsheet FilesWorking with Spreadsheet DocumentsNavigatingEditing SpreadsheetsGlobal Document FeaturesControlling a Spreadsheet DocumentExtending Capabilities of Spreadsheet DocumentsDrawings and PresentationsOverviewHandling Draw/Impress FilesSavingPrintingRunning PresentationsWorking with a Draw/Impress DocumentNavigatingWorking with Draw/Impress DocumentsGlobal Document FeaturesControlling a Draw/Impress DocumentChartsChart BasicsCreating a Chart DocumentEditing a Chart DocumentCommon Diagram APIDifferent Chart TypesExtending Capabilities of Chart DocumentsBasic and DialogsIntroductionLibrary OrganizationIDE with Dialogs and EventsUsing [PRODUCTNAME] BasicToolkit Controls and their PropertiesCreating Dialogs at RuntimeDatabase AccessFeatures of the [PRODUCTNAME] Database IntegrationCapabilitiesSDBC, SDBCX, SDB ArchitectureAccessing Datasources with [PRODUCTNAME]DataSourcesAdding and Editing Datasources Establishing a ConnectionGetting ConnectionsDriver specificsConnection PoolingWorking with Saved QueriesWorking with DataExecuting StatementsResultsetsMetadataRowsetsWorking with the Database DesignUsing DDL to change the DB DesignUsing SDBCX to access the DB DesignUsing DBMS FeaturesStored ProceduresTransaction HandlingExecuting Prepared StatementsWriting Database DriversFormsConceptsModels and ViewsForm Elements in the Document ModelSpecial Form ComponentsEventsData AwarenessRecipesMaking it easier to work with a FormControlling the Data InputCollecting Data automaticallyTaking Advantage of Database Server FeaturesAdding new FunctionalityHandling ErrorsUCBPurpose of UCBAccessing ContentsOpening Folder ContentsOpening Document Contents as StreamsWorking with Content PropertiesCreating, Moving and Copying Document and Folder ContentsWorking with Additional CommandsWriting a Content Provider[PRODUCTNAME] ConfigurationAccessing configuration dataWriting Configuration DataAppendix + +Programmer's ManualPlanned OutlinePreface (3 Pages)First Steps (24 Pages)Programming with UNOFields of Application for UNOGetting StartedRequired FilesConfigurationFirst ConnectionHow to get Objects in [PRODUCTNAME]How to work with ObjectsExampleServicesQuerying InterfacesUsing PropertiesElementAccessSimple TypesStringsEnums and Constant GroupsStructsAnySequenceHow to find the solution for a problemFinding your Way through the API ReferenceCommon MechanismsTextTableDrawingUNO in Professional Projects (145)IntroductionUNO/API constituents: How UNOIDL/API, ServiceManager, Bridges, CoreReflection work togetherAPI ConceptsAPI is a language independent, abstract specification for UNO objects which are used in [PRODUCTNAME]Types in the API ReferenceSimple TypesThe Any TypeInterfacesServicesModulesStructsConstant Groups and EnumsSequencesExceptionsAPI PrinciplesRelationship between Specification, Implementation and InstancesObject CompositionUNO ConceptsUNO is an environment for networked object communicationInterprocess ConnectionsServiceManager and ComponentContextUsing UNO InterfacesUsing PropertiesUsing Collections and ContainersEvent ModelException HandlingLifetime ControlObject IdentityLanguage BindingsIntroduction for language bindingJava Language BindingC++ BindingAccess for [PRODUCTNAME] BasicAutomationWriting UNO componentsSpecifying a new ComponentUNOIDL language specificationImplementing a ComponentComponent Development BasicsIntroductionMandatory interfaces: XInterface, XServiceInfo ((from UseInterfaces.CoreInterfaces))"Should be implemented" interfaces: XTypeProvider ((from UseInterfaces.CoreInterfaces ))optional interface: XMain for standalone executionSimple Component in JavaGetting the service manager ((Chapter Java components from unoBindingJava))simple component chapterC++ Component((Automation Component?))Deployment Options for ComponentsComponent RegistrationService Manager ConfigurationXSet InterfaceAdding components during runtime, particularly interesting during developmentServiceManager ContentDynamically modifying the ServiceManagerBootstrapping the Service Manager ((from CppBind chapter))Simple Test ApplicationConfiguring Your Application with Bootstrap ParametersThe UNO ExecutableStandalone Runtime EnvironmentThe UNO executable and XMainConfiguring the Java Runtime EnvironmentThe office and Java ((from UnoBindingJava))Advanced UNODesign PatternsBridging conceptsRequirements for Language Bindings and BridgesNew Scripting EnginesServiceManager and loaderSpecial Interfaces for internal useXUNOTunnelXAggregationUNO Reflection APITypeLibrary and TypeProvidersDifferences from CorbaOffice DevelopmentGlobal Object StructureDesktop EnvironmentFrames and Frame HierarchiesFrame-Controller-Model ParadigmLoading and Saving Office ComponentsDispatch FrameworkCommon FeaturesCommon DialogsDocumentInfoStylesSearch and ReplaceNumber FormatsPackage File FormatsInternationalizationLinguisticSystem IntegrationClipboardFile PickerBridging to the Window SystemText Documents (51,5 Pages)OverviewHandling Text FilesWorking with Text DocumentsNavigatingUsing TextTablesText FieldsBookmarksIndexes and Index MarksReference MarksFootnotes and EndnotesShape Objects in TextRedlineRubyGlobal Document FeaturesControlling a Text DocumentSpreadsheet DocumentsOverviewHandling Spreadsheet FilesWorking with Spreadsheet DocumentsNavigatingEditing SpreadsheetsGlobal Document FeaturesControlling a Spreadsheet DocumentExtending Capabilities of Spreadsheet DocumentsDrawings and PresentationsOverviewHandling Draw/Impress FilesSavingPrintingRunning PresentationsWorking with a Draw/Impress DocumentNavigatingWorking with Draw/Impress DocumentsGlobal Document FeaturesControlling a Draw/Impress DocumentChartsChart BasicsCreating a Chart DocumentEditing a Chart DocumentCommon Diagram APIDifferent Chart TypesExtending Capabilities of Chart DocumentsBasic and DialogsIntroductionLibrary OrganizationIDE with Dialogs and EventsUsing [PRODUCTNAME] BasicToolkit Controls and their PropertiesCreating Dialogs at RuntimeDatabase AccessFeatures of the [PRODUCTNAME] Database IntegrationCapabilitiesSDBC, SDBCX, SDB ArchitectureAccessing Datasources with [PRODUCTNAME]DataSourcesAdding and Editing Datasources Establishing a ConnectionGetting ConnectionsDriver specificsConnection PoolingWorking with Saved QueriesWorking with DataExecuting StatementsResultsetsMetadataRowsetsWorking with the Database DesignUsing DDL to change the DB DesignUsing SDBCX to access the DB DesignUsing DBMS FeaturesStored ProceduresTransaction HandlingExecuting Prepared StatementsWriting Database DriversFormsConceptsModels and ViewsForm Elements in the Document ModelSpecial Form ComponentsEventsData AwarenessRecipesMaking it easier to work with a FormControlling the Data InputCollecting Data automaticallyTaking Advantage of Database Server FeaturesAdding new FunctionalityHandling ErrorsUCBPurpose of UCBAccessing ContentsOpening Folder ContentsOpening Document Contents as StreamsWorking with Content PropertiesCreating, Moving and Copying Document and Folder ContentsWorking with Additional CommandsWriting a Content Provider[PRODUCTNAME] ConfigurationAccessing configuration dataWriting Configuration DataAppendix + +Programmer's ManualPlanned OutlinePreface (3 Pages)First Steps (24 Pages)Programming with UNOFields of Application for UNOGetting StartedRequired FilesConfigurationFirst ConnectionHow to get Objects in [PRODUCTNAME]How to work with ObjectsExampleServicesQuerying InterfacesUsing PropertiesElementAccessSimple TypesStringsEnums and Constant GroupsStructsAnySequenceHow to find the solution for a problemFinding your Way through the API ReferenceCommon MechanismsTextTableDrawingUNO in Professional Projects (145)IntroductionUNO/API constituents: How UNOIDL/API, ServiceManager, Bridges, CoreReflection work togetherAPI ConceptsAPI is a language independent, abstract specification for UNO objects which are used in [PRODUCTNAME]Types in the API ReferenceSimple TypesThe Any TypeInterfacesServicesModulesStructsConstant Groups and EnumsSequencesExceptionsAPI PrinciplesRelationship between Specification, Implementation and InstancesObject CompositionUNO ConceptsUNO is an environment for networked object communicationInterprocess ConnectionsServiceManager and ComponentContextUsing UNO InterfacesUsing PropertiesUsing Collections and ContainersEvent ModelException HandlingLifetime ControlObject IdentityLanguage BindingsIntroduction for language bindingJava Language BindingC++ BindingAccess for [PRODUCTNAME] BasicAutomationWriting UNO componentsSpecifying a new ComponentUNOIDL language specificationImplementing a ComponentComponent Development BasicsIntroductionMandatory interfaces: XInterface, XServiceInfo ((from UseInterfaces.CoreInterfaces))"Should be implemented" interfaces: XTypeProvider ((from UseInterfaces.CoreInterfaces ))optional interface: XMain for standalone executionSimple Component in JavaGetting the service manager ((Chapter Java components from unoBindingJava))simple component chapterC++ Component((Automation Component?))Deployment Options for ComponentsComponent RegistrationService Manager ConfigurationXSet InterfaceAdding components during runtime, particularly interesting during developmentServiceManager ContentDynamically modifying the ServiceManagerBootstrapping the Service Manager ((from CppBind chapter))Simple Test ApplicationConfiguring Your Application with Bootstrap ParametersThe UNO ExecutableStandalone Runtime EnvironmentThe UNO executable and XMainConfiguring the Java Runtime EnvironmentThe office and Java ((from UnoBindingJava))Advanced UNODesign PatternsBridging conceptsRequirements for Language Bindings and BridgesNew Scripting EnginesServiceManager and loaderSpecial Interfaces for internal useXUNOTunnelXAggregationUNO Reflection APITypeLibrary and TypeProvidersDifferences from CorbaOffice DevelopmentGlobal Object StructureDesktop EnvironmentFrames and Frame HierarchiesFrame-Controller-Model ParadigmLoading and Saving Office ComponentsDispatch FrameworkCommon FeaturesCommon DialogsDocumentInfoStylesSearch and ReplaceNumber FormatsPackage File FormatsInternationalizationLinguisticSystem IntegrationClipboardFile PickerBridging to the Window SystemText Documents (51,5 Pages)OverviewHandling Text FilesWorking with Text DocumentsNavigatingUsing TextTablesText FieldsBookmarksIndexes and Index MarksReference MarksFootnotes and EndnotesShape Objects in TextRedlineRubyGlobal Document FeaturesControlling a Text DocumentSpreadsheet DocumentsOverviewHandling Spreadsheet FilesWorking with Spreadsheet DocumentsNavigatingEditing SpreadsheetsGlobal Document FeaturesControlling a Spreadsheet DocumentExtending Capabilities of Spreadsheet DocumentsDrawings and PresentationsOverviewHandling Draw/Impress FilesSavingPrintingRunning PresentationsWorking with a Draw/Impress DocumentNavigatingWorking with Draw/Impress DocumentsGlobal Document FeaturesControlling a Draw/Impress DocumentChartsChart BasicsCreating a Chart DocumentEditing a Chart DocumentCommon Diagram APIDifferent Chart TypesExtending Capabilities of Chart DocumentsBasic and DialogsIntroductionLibrary OrganizationIDE with Dialogs and EventsUsing [PRODUCTNAME] BasicToolkit Controls and their PropertiesCreating Dialogs at RuntimeDatabase AccessFeatures of the [PRODUCTNAME] Database IntegrationCapabilitiesSDBC, SDBCX, SDB ArchitectureAccessing Datasources with [PRODUCTNAME]DataSourcesAdding and Editing Datasources Establishing a ConnectionGetting ConnectionsDriver specificsConnection PoolingWorking with Saved QueriesWorking with DataExecuting StatementsResultsetsMetadataRowsetsWorking with the Database DesignUsing DDL to change the DB DesignUsing SDBCX to access the DB DesignUsing DBMS FeaturesStored ProceduresTransaction HandlingExecuting Prepared StatementsWriting Database DriversFormsConceptsModels and ViewsForm Elements in the Document ModelSpecial Form ComponentsEventsData AwarenessRecipesMaking it easier to work with a FormControlling the Data InputCollecting Data automaticallyTaking Advantage of Database Server FeaturesAdding new FunctionalityHandling ErrorsUCBPurpose of UCBAccessing ContentsOpening Folder ContentsOpening Document Contents as StreamsWorking with Content PropertiesCreating, Moving and Copying Document and Folder ContentsWorking with Additional CommandsWriting a Content Provider[PRODUCTNAME] ConfigurationAccessing configuration dataWriting Configuration DataAppendix + +Programmer's ManualPlanned OutlinePreface (3 Pages)First Steps (24 Pages)Programming with UNOFields of Application for UNOGetting StartedRequired FilesConfigurationFirst ConnectionHow to get Objects in [PRODUCTNAME]How to work with ObjectsExampleServicesQuerying InterfacesUsing PropertiesElementAccessSimple TypesStringsEnums and Constant GroupsStructsAnySequenceHow to find the solution for a problemFinding your Way through the API ReferenceCommon MechanismsTextTableDrawingUNO in Professional Projects (145)IntroductionUNO/API constituents: How UNOIDL/API, ServiceManager, Bridges, CoreReflection work togetherAPI ConceptsAPI is a language independent, abstract specification for UNO objects which are used in [PRODUCTNAME]Types in the API ReferenceSimple TypesThe Any TypeInterfacesServicesModulesStructsConstant Groups and EnumsSequencesExceptionsAPI PrinciplesRelationship between Specification, Implementation and InstancesObject CompositionUNO ConceptsUNO is an environment for networked object communicationInterprocess ConnectionsServiceManager and ComponentContextUsing UNO InterfacesUsing PropertiesUsing Collections and ContainersEvent ModelException HandlingLifetime ControlObject IdentityLanguage BindingsIntroduction for language bindingJava Language BindingC++ BindingAccess for [PRODUCTNAME] BasicAutomationWriting UNO componentsSpecifying a new ComponentUNOIDL language specificationImplementing a ComponentComponent Development BasicsIntroductionMandatory interfaces: XInterface, XServiceInfo ((from UseInterfaces.CoreInterfaces))"Should be implemented" interfaces: XTypeProvider ((from UseInterfaces.CoreInterfaces ))optional interface: XMain for standalone executionSimple Component in JavaGetting the service manager ((Chapter Java components from unoBindingJava))simple component chapterC++ Component((Automation Component?))Deployment Options for ComponentsComponent RegistrationService Manager ConfigurationXSet InterfaceAdding components during runtime, particularly interesting during developmentServiceManager ContentDynamically modifying the ServiceManagerBootstrapping the Service Manager ((from CppBind chapter))Simple Test ApplicationConfiguring Your Application with Bootstrap ParametersThe UNO ExecutableStandalone Runtime EnvironmentThe UNO executable and XMainConfiguring the Java Runtime EnvironmentThe office and Java ((from UnoBindingJava))Advanced UNODesign PatternsBridging conceptsRequirements for Language Bindings and BridgesNew Scripting EnginesServiceManager and loaderSpecial Interfaces for internal useXUNOTunnelXAggregationUNO Reflection APITypeLibrary and TypeProvidersDifferences from CorbaOffice DevelopmentGlobal Object StructureDesktop EnvironmentFrames and Frame HierarchiesFrame-Controller-Model ParadigmLoading and Saving Office ComponentsDispatch FrameworkCommon FeaturesCommon DialogsDocumentInfoStylesSearch and ReplaceNumber FormatsPackage File FormatsInternationalizationLinguisticSystem IntegrationClipboardFile PickerBridging to the Window SystemText Documents (51,5 Pages)OverviewHandling Text FilesWorking with Text DocumentsNavigatingUsing TextTablesText FieldsBookmarksIndexes and Index MarksReference MarksFootnotes and EndnotesShape Objects in TextRedlineRubyGlobal Document FeaturesControlling a Text DocumentSpreadsheet DocumentsOverviewHandling Spreadsheet FilesWorking with Spreadsheet DocumentsNavigatingEditing SpreadsheetsGlobal Document FeaturesControlling a Spreadsheet DocumentExtending Capabilities of Spreadsheet DocumentsDrawings and PresentationsOverviewHandling Draw/Impress FilesSavingPrintingRunning PresentationsWorking with a Draw/Impress DocumentNavigatingWorking with Draw/Impress DocumentsGlobal Document FeaturesControlling a Draw/Impress DocumentChartsChart BasicsCreating a Chart DocumentEditing a Chart DocumentCommon Diagram APIDifferent Chart TypesExtending Capabilities of Chart DocumentsBasic and DialogsIntroductionLibrary OrganizationIDE with Dialogs and EventsUsing [PRODUCTNAME] BasicToolkit Controls and their PropertiesCreating Dialogs at RuntimeDatabase AccessFeatures of the [PRODUCTNAME] Database IntegrationCapabilitiesSDBC, SDBCX, SDB ArchitectureAccessing Datasources with [PRODUCTNAME]DataSourcesAdding and Editing Datasources Establishing a ConnectionGetting ConnectionsDriver specificsConnection PoolingWorking with Saved QueriesWorking with DataExecuting StatementsResultsetsMetadataRowsetsWorking with the Database DesignUsing DDL to change the DB DesignUsing SDBCX to access the DB DesignUsing DBMS FeaturesStored ProceduresTransaction HandlingExecuting Prepared StatementsWriting Database DriversFormsConceptsModels and ViewsForm Elements in the Document ModelSpecial Form ComponentsEventsData AwarenessRecipesMaking it easier to work with a FormControlling the Data InputCollecting Data automaticallyTaking Advantage of Database Server FeaturesAdding new FunctionalityHandling ErrorsUCBPurpose of UCBAccessing ContentsOpening Folder ContentsOpening Document Contents as StreamsWorking with Content PropertiesCreating, Moving and Copying Document and Folder ContentsWorking with Additional CommandsWriting a Content Provider[PRODUCTNAME] ConfigurationAccessing configuration dataWriting Configuration DataAppendix + +Programmer's ManualPlanned OutlinePreface (3 Pages)First Steps (24 Pages)Programming with UNOFields of Application for UNOGetting StartedRequired FilesConfigurationFirst ConnectionHow to get Objects in [PRODUCTNAME]How to work with ObjectsExampleServicesQuerying InterfacesUsing PropertiesElementAccessSimple TypesStringsEnums and Constant GroupsStructsAnySequenceHow to find the solution for a problemFinding your Way through the API ReferenceCommon MechanismsTextTableDrawingUNO in Professional Projects (145)IntroductionUNO/API constituents: How UNOIDL/API, ServiceManager, Bridges, CoreReflection work togetherAPI ConceptsAPI is a language independent, abstract specification for UNO objects which are used in [PRODUCTNAME]Types in the API ReferenceSimple TypesThe Any TypeInterfacesServicesModulesStructsConstant Groups and EnumsSequencesExceptionsAPI PrinciplesRelationship between Specification, Implementation and InstancesObject CompositionUNO ConceptsUNO is an environment for networked object communicationInterprocess ConnectionsServiceManager and ComponentContextUsing UNO InterfacesUsing PropertiesUsing Collections and ContainersEvent ModelException HandlingLifetime ControlObject IdentityLanguage BindingsIntroduction for language bindingJava Language BindingC++ BindingAccess for [PRODUCTNAME] BasicAutomationWriting UNO componentsSpecifying a new ComponentUNOIDL language specificationImplementing a ComponentComponent Development BasicsIntroductionMandatory interfaces: XInterface, XServiceInfo ((from UseInterfaces.CoreInterfaces))"Should be implemented" interfaces: XTypeProvider ((from UseInterfaces.CoreInterfaces ))optional interface: XMain for standalone executionSimple Component in JavaGetting the service manager ((Chapter Java components from unoBindingJava))simple component chapterC++ Component((Automation Component?))Deployment Options for ComponentsComponent RegistrationService Manager ConfigurationXSet InterfaceAdding components during runtime, particularly interesting during developmentServiceManager ContentDynamically modifying the ServiceManagerBootstrapping the Service Manager ((from CppBind chapter))Simple Test ApplicationConfiguring Your Application with Bootstrap ParametersThe UNO ExecutableStandalone Runtime EnvironmentThe UNO executable and XMainConfiguring the Java Runtime EnvironmentThe office and Java ((from UnoBindingJava))Advanced UNODesign PatternsBridging conceptsRequirements for Language Bindings and BridgesNew Scripting EnginesServiceManager and loaderSpecial Interfaces for internal useXUNOTunnelXAggregationUNO Reflection APITypeLibrary and TypeProvidersDifferences from CorbaOffice DevelopmentGlobal Object StructureDesktop EnvironmentFrames and Frame HierarchiesFrame-Controller-Model ParadigmLoading and Saving Office ComponentsDispatch FrameworkCommon FeaturesCommon DialogsDocumentInfoStylesSearch and ReplaceNumber FormatsPackage File FormatsInternationalizationLinguisticSystem IntegrationClipboardFile PickerBridging to the Window SystemText Documents (51,5 Pages)OverviewHandling Text FilesWorking with Text DocumentsNavigatingUsing TextTablesText FieldsBookmarksIndexes and Index MarksReference MarksFootnotes and EndnotesShape Objects in TextRedlineRubyGlobal Document FeaturesControlling a Text DocumentSpreadsheet DocumentsOverviewHandling Spreadsheet FilesWorking with Spreadsheet DocumentsNavigatingEditing SpreadsheetsGlobal Document FeaturesControlling a Spreadsheet DocumentExtending Capabilities of Spreadsheet DocumentsDrawings and PresentationsOverviewHandling Draw/Impress FilesSavingPrintingRunning PresentationsWorking with a Draw/Impress DocumentNavigatingWorking with Draw/Impress DocumentsGlobal Document FeaturesControlling a Draw/Impress DocumentChartsChart BasicsCreating a Chart DocumentEditing a Chart DocumentCommon Diagram APIDifferent Chart TypesExtending Capabilities of Chart DocumentsBasic and DialogsIntroductionLibrary OrganizationIDE with Dialogs and EventsUsing [PRODUCTNAME] BasicToolkit Controls and their PropertiesCreating Dialogs at RuntimeDatabase AccessFeatures of the [PRODUCTNAME] Database IntegrationCapabilitiesSDBC, SDBCX, SDB ArchitectureAccessing Datasources with [PRODUCTNAME]DataSourcesAdding and Editing Datasources Establishing a ConnectionGetting ConnectionsDriver specificsConnection PoolingWorking with Saved QueriesWorking with DataExecuting StatementsResultsetsMetadataRowsetsWorking with the Database DesignUsing DDL to change the DB DesignUsing SDBCX to access the DB DesignUsing DBMS FeaturesStored ProceduresTransaction HandlingExecuting Prepared StatementsWriting Database DriversFormsConceptsModels and ViewsForm Elements in the Document ModelSpecial Form ComponentsEventsData AwarenessRecipesMaking it easier to work with a FormControlling the Data InputCollecting Data automaticallyTaking Advantage of Database Server FeaturesAdding new FunctionalityHandling ErrorsUCBPurpose of UCBAccessing ContentsOpening Folder ContentsOpening Document Contents as StreamsWorking with Content PropertiesCreating, Moving and Copying Document and Folder ContentsWorking with Additional CommandsWriting a Content Provider[PRODUCTNAME] ConfigurationAccessing configuration dataWriting Configuration DataAppendix + +Programmer's ManualPlanned OutlinePreface (3 Pages)First Steps (24 Pages)Programming with UNOFields of Application for UNOGetting StartedRequired FilesConfigurationFirst ConnectionHow to get Objects in [PRODUCTNAME]How to work with ObjectsExampleServicesQuerying InterfacesUsing PropertiesElementAccessSimple TypesStringsEnums and Constant GroupsStructsAnySequenceHow to find the solution for a problemFinding your Way through the API ReferenceCommon MechanismsTextTableDrawingUNO in Professional Projects (145)IntroductionUNO/API constituents: How UNOIDL/API, ServiceManager, Bridges, CoreReflection work togetherAPI ConceptsAPI is a language independent, abstract specification for UNO objects which are used in [PRODUCTNAME]Types in the API ReferenceSimple TypesThe Any TypeInterfacesServicesModulesStructsConstant Groups and EnumsSequencesExceptionsAPI PrinciplesRelationship between Specification, Implementation and InstancesObject CompositionUNO ConceptsUNO is an environment for networked object communicationInterprocess ConnectionsServiceManager and ComponentContextUsing UNO InterfacesUsing PropertiesUsing Collections and ContainersEvent ModelException HandlingLifetime ControlObject IdentityLanguage BindingsIntroduction for language bindingJava Language BindingC++ BindingAccess for [PRODUCTNAME] BasicAutomationWriting UNO componentsSpecifying a new ComponentUNOIDL language specificationImplementing a ComponentComponent Development BasicsIntroductionMandatory interfaces: XInterface, XServiceInfo ((from UseInterfaces.CoreInterfaces))"Should be implemented" interfaces: XTypeProvider ((from UseInterfaces.CoreInterfaces ))optional interface: XMain for standalone executionSimple Component in JavaGetting the service manager ((Chapter Java components from unoBindingJava))simple component chapterC++ Component((Automation Component?))Deployment Options for ComponentsComponent RegistrationService Manager ConfigurationXSet InterfaceAdding components during runtime, particularly interesting during developmentServiceManager ContentDynamically modifying the ServiceManagerBootstrapping the Service Manager ((from CppBind chapter))Simple Test ApplicationConfiguring Your Application with Bootstrap ParametersThe UNO ExecutableStandalone Runtime EnvironmentThe UNO executable and XMainConfiguring the Java Runtime EnvironmentThe office and Java ((from UnoBindingJava))Advanced UNODesign PatternsBridging conceptsRequirements for Language Bindings and BridgesNew Scripting EnginesServiceManager and loaderSpecial Interfaces for internal useXUNOTunnelXAggregationUNO Reflection APITypeLibrary and TypeProvidersDifferences from CorbaOffice DevelopmentGlobal Object StructureDesktop EnvironmentFrames and Frame HierarchiesFrame-Controller-Model ParadigmLoading and Saving Office ComponentsDispatch FrameworkCommon FeaturesCommon DialogsDocumentInfoStylesSearch and ReplaceNumber FormatsPackage File FormatsInternationalizationLinguisticSystem IntegrationClipboardFile PickerBridging to the Window SystemText Documents (51,5 Pages)OverviewHandling Text FilesWorking with Text DocumentsNavigatingUsing TextTablesText FieldsBookmarksIndexes and Index MarksReference MarksFootnotes and EndnotesShape Objects in TextRedlineRubyGlobal Document FeaturesControlling a Text DocumentSpreadsheet DocumentsOverviewHandling Spreadsheet FilesWorking with Spreadsheet DocumentsNavigatingEditing SpreadsheetsGlobal Document FeaturesControlling a Spreadsheet DocumentExtending Capabilities of Spreadsheet DocumentsDrawings and PresentationsOverviewHandling Draw/Impress FilesSavingPrintingRunning PresentationsWorking with a Draw/Impress DocumentNavigatingWorking with Draw/Impress DocumentsGlobal Document FeaturesControlling a Draw/Impress DocumentChartsChart BasicsCreating a Chart DocumentEditing a Chart DocumentCommon Diagram APIDifferent Chart TypesExtending Capabilities of Chart DocumentsBasic and DialogsIntroductionLibrary OrganizationIDE with Dialogs and EventsUsing [PRODUCTNAME] BasicToolkit Controls and their PropertiesCreating Dialogs at RuntimeDatabase AccessFeatures of the [PRODUCTNAME] Database IntegrationCapabilitiesSDBC, SDBCX, SDB ArchitectureAccessing Datasources with [PRODUCTNAME]DataSourcesAdding and Editing Datasources Establishing a ConnectionGetting ConnectionsDriver specificsConnection PoolingWorking with Saved QueriesWorking with DataExecuting StatementsResultsetsMetadataRowsetsWorking with the Database DesignUsing DDL to change the DB DesignUsing SDBCX to access the DB DesignUsing DBMS FeaturesStored ProceduresTransaction HandlingExecuting Prepared StatementsWriting Database DriversFormsConceptsModels and ViewsForm Elements in the Document ModelSpecial Form ComponentsEventsData AwarenessRecipesMaking it easier to work with a FormControlling the Data InputCollecting Data automaticallyTaking Advantage of Database Server FeaturesAdding new FunctionalityHandling ErrorsUCBPurpose of UCBAccessing ContentsOpening Folder ContentsOpening Document Contents as StreamsWorking with Content PropertiesCreating, Moving and Copying Document and Folder ContentsWorking with Additional CommandsWriting a Content Provider[PRODUCTNAME] ConfigurationAccessing configuration dataWriting Configuration DataAppendix + +Programmer's ManualPlanned OutlinePreface (3 Pages)First Steps (24 Pages)Programming with UNOFields of Application for UNOGetting StartedRequired FilesConfigurationFirst ConnectionHow to get Objects in [PRODUCTNAME]How to work with ObjectsExampleServicesQuerying InterfacesUsing PropertiesElementAccessSimple TypesStringsEnums and Constant GroupsStructsAnySequenceHow to find the solution for a problemFinding your Way through the API ReferenceCommon MechanismsTextTableDrawingUNO in Professional Projects (145)IntroductionUNO/API constituents: How UNOIDL/API, ServiceManager, Bridges, CoreReflection work togetherAPI ConceptsAPI is a language independent, abstract specification for UNO objects which are used in [PRODUCTNAME]Types in the API ReferenceSimple TypesThe Any TypeInterfacesServicesModulesStructsConstant Groups and EnumsSequencesExceptionsAPI PrinciplesRelationship between Specification, Implementation and InstancesObject CompositionUNO ConceptsUNO is an environment for networked object communicationInterprocess ConnectionsServiceManager and ComponentContextUsing UNO InterfacesUsing PropertiesUsing Collections and ContainersEvent ModelException HandlingLifetime ControlObject IdentityLanguage BindingsIntroduction for language bindingJava Language BindingC++ BindingAccess for [PRODUCTNAME] BasicAutomationWriting UNO componentsSpecifying a new ComponentUNOIDL language specificationImplementing a ComponentComponent Development BasicsIntroductionMandatory interfaces: XInterface, XServiceInfo ((from UseInterfaces.CoreInterfaces))"Should be implemented" interfaces: XTypeProvider ((from UseInterfaces.CoreInterfaces ))optional interface: XMain for standalone executionSimple Component in JavaGetting the service manager ((Chapter Java components from unoBindingJava))simple component chapterC++ Component((Automation Component?))Deployment Options for ComponentsComponent RegistrationService Manager ConfigurationXSet InterfaceAdding components during runtime, particularly interesting during developmentServiceManager ContentDynamically modifying the ServiceManagerBootstrapping the Service Manager ((from CppBind chapter))Simple Test ApplicationConfiguring Your Application with Bootstrap ParametersThe UNO ExecutableStandalone Runtime EnvironmentThe UNO executable and XMainConfiguring the Java Runtime EnvironmentThe office and Java ((from UnoBindingJava))Advanced UNODesign PatternsBridging conceptsRequirements for Language Bindings and BridgesNew Scripting EnginesServiceManager and loaderSpecial Interfaces for internal useXUNOTunnelXAggregationUNO Reflection APITypeLibrary and TypeProvidersDifferences from CorbaOffice DevelopmentGlobal Object StructureDesktop EnvironmentFrames and Frame HierarchiesFrame-Controller-Model ParadigmLoading and Saving Office ComponentsDispatch FrameworkCommon FeaturesCommon DialogsDocumentInfoStylesSearch and ReplaceNumber FormatsPackage File FormatsInternationalizationLinguisticSystem IntegrationClipboardFile PickerBridging to the Window SystemText Documents (51,5 Pages)OverviewHandling Text FilesWorking with Text DocumentsNavigatingUsing TextTablesText FieldsBookmarksIndexes and Index MarksReference MarksFootnotes and EndnotesShape Objects in TextRedlineRubyGlobal Document FeaturesControlling a Text DocumentSpreadsheet DocumentsOverviewHandling Spreadsheet FilesWorking with Spreadsheet DocumentsNavigatingEditing SpreadsheetsGlobal Document FeaturesControlling a Spreadsheet DocumentExtending Capabilities of Spreadsheet DocumentsDrawings and PresentationsOverviewHandling Draw/Impress FilesSavingPrintingRunning PresentationsWorking with a Draw/Impress DocumentNavigatingWorking with Draw/Impress DocumentsGlobal Document FeaturesControlling a Draw/Impress DocumentChartsChart BasicsCreating a Chart DocumentEditing a Chart DocumentCommon Diagram APIDifferent Chart TypesExtending Capabilities of Chart DocumentsBasic and DialogsIntroductionLibrary OrganizationIDE with Dialogs and EventsUsing [PRODUCTNAME] BasicToolkit Controls and their PropertiesCreating Dialogs at RuntimeDatabase AccessFeatures of the [PRODUCTNAME] Database IntegrationCapabilitiesSDBC, SDBCX, SDB ArchitectureAccessing Datasources with [PRODUCTNAME]DataSourcesAdding and Editing Datasources Establishing a ConnectionGetting ConnectionsDriver specificsConnection PoolingWorking with Saved QueriesWorking with DataExecuting StatementsResultsetsMetadataRowsetsWorking with the Database DesignUsing DDL to change the DB DesignUsing SDBCX to access the DB DesignUsing DBMS FeaturesStored ProceduresTransaction HandlingExecuting Prepared StatementsWriting Database DriversFormsConceptsModels and ViewsForm Elements in the Document ModelSpecial Form ComponentsEventsData AwarenessRecipesMaking it easier to work with a FormControlling the Data InputCollecting Data automaticallyTaking Advantage of Database Server FeaturesAdding new FunctionalityHandling ErrorsUCBPurpose of UCBAccessing ContentsOpening Folder ContentsOpening Document Contents as StreamsWorking with Content PropertiesCreating, Moving and Copying Document and Folder ContentsWorking with Additional CommandsWriting a Content Provider[PRODUCTNAME] ConfigurationAccessing configuration dataWriting Configuration DataAppendix + +Programmer's ManualPlanned OutlinePreface (3 Pages)First Steps (24 Pages)Programming with UNOFields of Application for UNOGetting StartedRequired FilesConfigurationFirst ConnectionHow to get Objects in [PRODUCTNAME]How to work with ObjectsExampleServicesQuerying InterfacesUsing PropertiesElementAccessSimple TypesStringsEnums and Constant GroupsStructsAnySequenceHow to find the solution for a problemFinding your Way through the API ReferenceCommon MechanismsTextTableDrawingUNO in Professional Projects (145)IntroductionUNO/API constituents: How UNOIDL/API, ServiceManager, Bridges, CoreReflection work togetherAPI ConceptsAPI is a language independent, abstract specification for UNO objects which are used in [PRODUCTNAME]Types in the API ReferenceSimple TypesThe Any TypeInterfacesServicesModulesStructsConstant Groups and EnumsSequencesExceptionsAPI PrinciplesRelationship between Specification, Implementation and InstancesObject CompositionUNO ConceptsUNO is an environment for networked object communicationInterprocess ConnectionsServiceManager and ComponentContextUsing UNO InterfacesUsing PropertiesUsing Collections and ContainersEvent ModelException HandlingLifetime ControlObject IdentityLanguage BindingsIntroduction for language bindingJava Language BindingC++ BindingAccess for [PRODUCTNAME] BasicAutomationWriting UNO componentsSpecifying a new ComponentUNOIDL language specificationImplementing a ComponentComponent Development BasicsIntroductionMandatory interfaces: XInterface, XServiceInfo ((from UseInterfaces.CoreInterfaces))"Should be implemented" interfaces: XTypeProvider ((from UseInterfaces.CoreInterfaces ))optional interface: XMain for standalone executionSimple Component in JavaGetting the service manager ((Chapter Java components from unoBindingJava))simple component chapterC++ Component((Automation Component?))Deployment Options for ComponentsComponent RegistrationService Manager ConfigurationXSet InterfaceAdding components during runtime, particularly interesting during developmentServiceManager ContentDynamically modifying the ServiceManagerBootstrapping the Service Manager ((from CppBind chapter))Simple Test ApplicationConfiguring Your Application with Bootstrap ParametersThe UNO ExecutableStandalone Runtime EnvironmentThe UNO executable and XMainConfiguring the Java Runtime EnvironmentThe office and Java ((from UnoBindingJava))Advanced UNODesign PatternsBridging conceptsRequirements for Language Bindings and BridgesNew Scripting EnginesServiceManager and loaderSpecial Interfaces for internal useXUNOTunnelXAggregationUNO Reflection APITypeLibrary and TypeProvidersDifferences from CorbaOffice DevelopmentGlobal Object StructureDesktop EnvironmentFrames and Frame HierarchiesFrame-Controller-Model ParadigmLoading and Saving Office ComponentsDispatch FrameworkCommon FeaturesCommon DialogsDocumentInfoStylesSearch and ReplaceNumber FormatsPackage File FormatsInternationalizationLinguisticSystem IntegrationClipboardFile PickerBridging to the Window SystemText Documents (51,5 Pages)OverviewHandling Text FilesWorking with Text DocumentsNavigatingUsing TextTablesText FieldsBookmarksIndexes and Index MarksReference MarksFootnotes and EndnotesShape Objects in TextRedlineRubyGlobal Document FeaturesControlling a Text DocumentSpreadsheet DocumentsOverviewHandling Spreadsheet FilesWorking with Spreadsheet DocumentsNavigatingEditing SpreadsheetsGlobal Document FeaturesControlling a Spreadsheet DocumentExtending Capabilities of Spreadsheet DocumentsDrawings and PresentationsOverviewHandling Draw/Impress FilesSavingPrintingRunning PresentationsWorking with a Draw/Impress DocumentNavigatingWorking with Draw/Impress DocumentsGlobal Document FeaturesControlling a Draw/Impress DocumentChartsChart BasicsCreating a Chart DocumentEditing a Chart DocumentCommon Diagram APIDifferent Chart TypesExtending Capabilities of Chart DocumentsBasic and DialogsIntroductionLibrary OrganizationIDE with Dialogs and EventsUsing [PRODUCTNAME] BasicToolkit Controls and their PropertiesCreating Dialogs at RuntimeDatabase AccessFeatures of the [PRODUCTNAME] Database IntegrationCapabilitiesSDBC, SDBCX, SDB ArchitectureAccessing Datasources with [PRODUCTNAME]DataSourcesAdding and Editing Datasources Establishing a ConnectionGetting ConnectionsDriver specificsConnection PoolingWorking with Saved QueriesWorking with DataExecuting StatementsResultsetsMetadataRowsetsWorking with the Database DesignUsing DDL to change the DB DesignUsing SDBCX to access the DB DesignUsing DBMS FeaturesStored ProceduresTransaction HandlingExecuting Prepared StatementsWriting Database DriversFormsConceptsModels and ViewsForm Elements in the Document ModelSpecial Form ComponentsEventsData AwarenessRecipesMaking it easier to work with a FormControlling the Data InputCollecting Data automaticallyTaking Advantage of Database Server FeaturesAdding new FunctionalityHandling ErrorsUCBPurpose of UCBAccessing ContentsOpening Folder ContentsOpening Document Contents as StreamsWorking with Content PropertiesCreating, Moving and Copying Document and Folder ContentsWorking with Additional CommandsWriting a Content Provider[PRODUCTNAME] ConfigurationAccessing configuration dataWriting Configuration DataAppendix + +Programmer's ManualPlanned OutlinePreface (3 Pages)First Steps (24 Pages)Programming with UNOFields of Application for UNOGetting StartedRequired FilesConfigurationFirst ConnectionHow to get Objects in [PRODUCTNAME]How to work with ObjectsExampleServicesQuerying InterfacesUsing PropertiesElementAccessSimple TypesStringsEnums and Constant GroupsStructsAnySequenceHow to find the solution for a problemFinding your Way through the API ReferenceCommon MechanismsTextTableDrawingUNO in Professional Projects (145)IntroductionUNO/API constituents: How UNOIDL/API, ServiceManager, Bridges, CoreReflection work togetherAPI ConceptsAPI is a language independent, abstract specification for UNO objects which are used in [PRODUCTNAME]Types in the API ReferenceSimple TypesThe Any TypeInterfacesServicesModulesStructsConstant Groups and EnumsSequencesExceptionsAPI PrinciplesRelationship between Specification, Implementation and InstancesObject CompositionUNO ConceptsUNO is an environment for networked object communicationInterprocess ConnectionsServiceManager and ComponentContextUsing UNO InterfacesUsing PropertiesUsing Collections and ContainersEvent ModelException HandlingLifetime ControlObject IdentityLanguage BindingsIntroduction for language bindingJava Language BindingC++ BindingAccess for [PRODUCTNAME] BasicAutomationWriting UNO componentsSpecifying a new ComponentUNOIDL language specificationImplementing a ComponentComponent Development BasicsIntroductionMandatory interfaces: XInterface, XServiceInfo ((from UseInterfaces.CoreInterfaces))"Should be implemented" interfaces: XTypeProvider ((from UseInterfaces.CoreInterfaces ))optional interface: XMain for standalone executionSimple Component in JavaGetting the service manager ((Chapter Java components from unoBindingJava))simple component chapterC++ Component((Automation Component?))Deployment Options for ComponentsComponent RegistrationService Manager ConfigurationXSet InterfaceAdding components during runtime, particularly interesting during developmentServiceManager ContentDynamically modifying the ServiceManagerBootstrapping the Service Manager ((from CppBind chapter))Simple Test ApplicationConfiguring Your Application with Bootstrap ParametersThe UNO ExecutableStandalone Runtime EnvironmentThe UNO executable and XMainConfiguring the Java Runtime EnvironmentThe office and Java ((from UnoBindingJava))Advanced UNODesign PatternsBridging conceptsRequirements for Language Bindings and BridgesNew Scripting EnginesServiceManager and loaderSpecial Interfaces for internal useXUNOTunnelXAggregationUNO Reflection APITypeLibrary and TypeProvidersDifferences from CorbaOffice DevelopmentGlobal Object StructureDesktop EnvironmentFrames and Frame HierarchiesFrame-Controller-Model ParadigmLoading and Saving Office ComponentsDispatch FrameworkCommon FeaturesCommon DialogsDocumentInfoStylesSearch and ReplaceNumber FormatsPackage File FormatsInternationalizationLinguisticSystem IntegrationClipboardFile PickerBridging to the Window SystemText Documents (51,5 Pages)OverviewHandling Text FilesWorking with Text DocumentsNavigatingUsing TextTablesText FieldsBookmarksIndexes and Index MarksReference MarksFootnotes and EndnotesShape Objects in TextRedlineRubyGlobal Document FeaturesControlling a Text DocumentSpreadsheet DocumentsOverviewHandling Spreadsheet FilesWorking with Spreadsheet DocumentsNavigatingEditing SpreadsheetsGlobal Document FeaturesControlling a Spreadsheet DocumentExtending Capabilities of Spreadsheet DocumentsDrawings and PresentationsOverviewHandling Draw/Impress FilesSavingPrintingRunning PresentationsWorking with a Draw/Impress DocumentNavigatingWorking with Draw/Impress DocumentsGlobal Document FeaturesControlling a Draw/Impress DocumentChartsChart BasicsCreating a Chart DocumentEditing a Chart DocumentCommon Diagram APIDifferent Chart TypesExtending Capabilities of Chart DocumentsBasic and DialogsIntroductionLibrary OrganizationIDE with Dialogs and EventsUsing [PRODUCTNAME] BasicToolkit Controls and their PropertiesCreating Dialogs at RuntimeDatabase AccessFeatures of the [PRODUCTNAME] Database IntegrationCapabilitiesSDBC, SDBCX, SDB ArchitectureAccessing Datasources with [PRODUCTNAME]DataSourcesAdding and Editing Datasources Establishing a ConnectionGetting ConnectionsDriver specificsConnection PoolingWorking with Saved QueriesWorking with DataExecuting StatementsResultsetsMetadataRowsetsWorking with the Database DesignUsing DDL to change the DB DesignUsing SDBCX to access the DB DesignUsing DBMS FeaturesStored ProceduresTransaction HandlingExecuting Prepared StatementsWriting Database DriversFormsConceptsModels and ViewsForm Elements in the Document ModelSpecial Form ComponentsEventsData AwarenessRecipesMaking it easier to work with a FormControlling the Data InputCollecting Data automaticallyTaking Advantage of Database Server FeaturesAdding new FunctionalityHandling ErrorsUCBPurpose of UCBAccessing ContentsOpening Folder ContentsOpening Document Contents as StreamsWorking with Content PropertiesCreating, Moving and Copying Document and Folder ContentsWorking with Additional CommandsWriting a Content Provider[PRODUCTNAME] ConfigurationAccessing configuration dataWriting Configuration DataAppendix + +Programmer's ManualPlanned OutlinePreface (3 Pages)First Steps (24 Pages)Programming with UNOFields of Application for UNOGetting StartedRequired FilesConfigurationFirst ConnectionHow to get Objects in [PRODUCTNAME]How to work with ObjectsExampleServicesQuerying InterfacesUsing PropertiesElementAccessSimple TypesStringsEnums and Constant GroupsStructsAnySequenceHow to find the solution for a problemFinding your Way through the API ReferenceCommon MechanismsTextTableDrawingUNO in Professional Projects (145)IntroductionUNO/API constituents: How UNOIDL/API, ServiceManager, Bridges, CoreReflection work togetherAPI ConceptsAPI is a language independent, abstract specification for UNO objects which are used in [PRODUCTNAME]Types in the API ReferenceSimple TypesThe Any TypeInterfacesServicesModulesStructsConstant Groups and EnumsSequencesExceptionsAPI PrinciplesRelationship between Specification, Implementation and InstancesObject CompositionUNO ConceptsUNO is an environment for networked object communicationInterprocess ConnectionsServiceManager and ComponentContextUsing UNO InterfacesUsing PropertiesUsing Collections and ContainersEvent ModelException HandlingLifetime ControlObject IdentityLanguage BindingsIntroduction for language bindingJava Language BindingC++ BindingAccess for [PRODUCTNAME] BasicAutomationWriting UNO componentsSpecifying a new ComponentUNOIDL language specificationImplementing a ComponentComponent Development BasicsIntroductionMandatory interfaces: XInterface, XServiceInfo ((from UseInterfaces.CoreInterfaces))"Should be implemented" interfaces: XTypeProvider ((from UseInterfaces.CoreInterfaces ))optional interface: XMain for standalone executionSimple Component in JavaGetting the service manager ((Chapter Java components from unoBindingJava))simple component chapterC++ Component((Automation Component?))Deployment Options for ComponentsComponent RegistrationService Manager ConfigurationXSet InterfaceAdding components during runtime, particularly interesting during developmentServiceManager ContentDynamically modifying the ServiceManagerBootstrapping the Service Manager ((from CppBind chapter))Simple Test ApplicationConfiguring Your Application with Bootstrap ParametersThe UNO ExecutableStandalone Runtime EnvironmentThe UNO executable and XMainConfiguring the Java Runtime EnvironmentThe office and Java ((from UnoBindingJava))Advanced UNODesign PatternsBridging conceptsRequirements for Language Bindings and BridgesNew Scripting EnginesServiceManager and loaderSpecial Interfaces for internal useXUNOTunnelXAggregationUNO Reflection APITypeLibrary and TypeProvidersDifferences from CorbaOffice DevelopmentGlobal Object StructureDesktop EnvironmentFrames and Frame HierarchiesFrame-Controller-Model ParadigmLoading and Saving Office ComponentsDispatch FrameworkCommon FeaturesCommon DialogsDocumentInfoStylesSearch and ReplaceNumber FormatsPackage File FormatsInternationalizationLinguisticSystem IntegrationClipboardFile PickerBridging to the Window SystemText Documents (51,5 Pages)OverviewHandling Text FilesWorking with Text DocumentsNavigatingUsing TextTablesText FieldsBookmarksIndexes and Index MarksReference MarksFootnotes and EndnotesShape Objects in TextRedlineRubyGlobal Document FeaturesControlling a Text DocumentSpreadsheet DocumentsOverviewHandling Spreadsheet FilesWorking with Spreadsheet DocumentsNavigatingEditing SpreadsheetsGlobal Document FeaturesControlling a Spreadsheet DocumentExtending Capabilities of Spreadsheet DocumentsDrawings and PresentationsOverviewHandling Draw/Impress FilesSavingPrintingRunning PresentationsWorking with a Draw/Impress DocumentNavigatingWorking with Draw/Impress DocumentsGlobal Document FeaturesControlling a Draw/Impress DocumentChartsChart BasicsCreating a Chart DocumentEditing a Chart DocumentCommon Diagram APIDifferent Chart TypesExtending Capabilities of Chart DocumentsBasic and DialogsIntroductionLibrary OrganizationIDE with Dialogs and EventsUsing [PRODUCTNAME] BasicToolkit Controls and their PropertiesCreating Dialogs at RuntimeDatabase AccessFeatures of the [PRODUCTNAME] Database IntegrationCapabilitiesSDBC, SDBCX, SDB ArchitectureAccessing Datasources with [PRODUCTNAME]DataSourcesAdding and Editing Datasources Establishing a ConnectionGetting ConnectionsDriver specificsConnection PoolingWorking with Saved QueriesWorking with DataExecuting StatementsResultsetsMetadataRowsetsWorking with the Database DesignUsing DDL to change the DB DesignUsing SDBCX to access the DB DesignUsing DBMS FeaturesStored ProceduresTransaction HandlingExecuting Prepared StatementsWriting Database DriversFormsConceptsModels and ViewsForm Elements in the Document ModelSpecial Form ComponentsEventsData AwarenessRecipesMaking it easier to work with a FormControlling the Data InputCollecting Data automaticallyTaking Advantage of Database Server FeaturesAdding new FunctionalityHandling ErrorsUCBPurpose of UCBAccessing ContentsOpening Folder ContentsOpening Document Contents as StreamsWorking with Content PropertiesCreating, Moving and Copying Document and Folder ContentsWorking with Additional CommandsWriting a Content Provider[PRODUCTNAME] ConfigurationAccessing configuration dataWriting Configuration DataAppendix + +Programmer's ManualPlanned OutlinePreface (3 Pages)First Steps (24 Pages)Programming with UNOFields of Application for UNOGetting StartedRequired FilesConfigurationFirst ConnectionHow to get Objects in [PRODUCTNAME]How to work with ObjectsExampleServicesQuerying InterfacesUsing PropertiesElementAccessSimple TypesStringsEnums and Constant GroupsStructsAnySequenceHow to find the solution for a problemFinding your Way through the API ReferenceCommon MechanismsTextTableDrawingUNO in Professional Projects (145)IntroductionUNO/API constituents: How UNOIDL/API, ServiceManager, Bridges, CoreReflection work togetherAPI ConceptsAPI is a language independent, abstract specification for UNO objects which are used in [PRODUCTNAME]Types in the API ReferenceSimple TypesThe Any TypeInterfacesServicesModulesStructsConstant Groups and EnumsSequencesExceptionsAPI PrinciplesRelationship between Specification, Implementation and InstancesObject CompositionUNO ConceptsUNO is an environment for networked object communicationInterprocess ConnectionsServiceManager and ComponentContextUsing UNO InterfacesUsing PropertiesUsing Collections and ContainersEvent ModelException HandlingLifetime ControlObject IdentityLanguage BindingsIntroduction for language bindingJava Language BindingC++ BindingAccess for [PRODUCTNAME] BasicAutomationWriting UNO componentsSpecifying a new ComponentUNOIDL language specificationImplementing a ComponentComponent Development BasicsIntroductionMandatory interfaces: XInterface, XServiceInfo ((from UseInterfaces.CoreInterfaces))"Should be implemented" interfaces: XTypeProvider ((from UseInterfaces.CoreInterfaces ))optional interface: XMain for standalone executionSimple Component in JavaGetting the service manager ((Chapter Java components from unoBindingJava))simple component chapterC++ Component((Automation Component?))Deployment Options for ComponentsComponent RegistrationService Manager ConfigurationXSet InterfaceAdding components during runtime, particularly interesting during developmentServiceManager ContentDynamically modifying the ServiceManagerBootstrapping the Service Manager ((from CppBind chapter))Simple Test ApplicationConfiguring Your Application with Bootstrap ParametersThe UNO ExecutableStandalone Runtime EnvironmentThe UNO executable and XMainConfiguring the Java Runtime EnvironmentThe office and Java ((from UnoBindingJava))Advanced UNODesign PatternsBridging conceptsRequirements for Language Bindings and BridgesNew Scripting EnginesServiceManager and loaderSpecial Interfaces for internal useXUNOTunnelXAggregationUNO Reflection APITypeLibrary and TypeProvidersDifferences from CorbaOffice DevelopmentGlobal Object StructureDesktop EnvironmentFrames and Frame HierarchiesFrame-Controller-Model ParadigmLoading and Saving Office ComponentsDispatch FrameworkCommon FeaturesCommon DialogsDocumentInfoStylesSearch and ReplaceNumber FormatsPackage File FormatsInternationalizationLinguisticSystem IntegrationClipboardFile PickerBridging to the Window SystemText Documents (51,5 Pages)OverviewHandling Text FilesWorking with Text DocumentsNavigatingUsing TextTablesText FieldsBookmarksIndexes and Index MarksReference MarksFootnotes and EndnotesShape Objects in TextRedlineRubyGlobal Document FeaturesControlling a Text DocumentSpreadsheet DocumentsOverviewHandling Spreadsheet FilesWorking with Spreadsheet DocumentsNavigatingEditing SpreadsheetsGlobal Document FeaturesControlling a Spreadsheet DocumentExtending Capabilities of Spreadsheet DocumentsDrawings and PresentationsOverviewHandling Draw/Impress FilesSavingPrintingRunning PresentationsWorking with a Draw/Impress DocumentNavigatingWorking with Draw/Impress DocumentsGlobal Document FeaturesControlling a Draw/Impress DocumentChartsChart BasicsCreating a Chart DocumentEditing a Chart DocumentCommon Diagram APIDifferent Chart TypesExtending Capabilities of Chart DocumentsBasic and DialogsIntroductionLibrary OrganizationIDE with Dialogs and EventsUsing [PRODUCTNAME] BasicToolkit Controls and their PropertiesCreating Dialogs at RuntimeDatabase AccessFeatures of the [PRODUCTNAME] Database IntegrationCapabilitiesSDBC, SDBCX, SDB ArchitectureAccessing Datasources with [PRODUCTNAME]DataSourcesAdding and Editing Datasources Establishing a ConnectionGetting ConnectionsDriver specificsConnection PoolingWorking with Saved QueriesWorking with DataExecuting StatementsResultsetsMetadataRowsetsWorking with the Database DesignUsing DDL to change the DB DesignUsing SDBCX to access the DB DesignUsing DBMS FeaturesStored ProceduresTransaction HandlingExecuting Prepared StatementsWriting Database DriversFormsConceptsModels and ViewsForm Elements in the Document ModelSpecial Form ComponentsEventsData AwarenessRecipesMaking it easier to work with a FormControlling the Data InputCollecting Data automaticallyTaking Advantage of Database Server FeaturesAdding new FunctionalityHandling ErrorsUCBPurpose of UCBAccessing ContentsOpening Folder ContentsOpening Document Contents as StreamsWorking with Content PropertiesCreating, Moving and Copying Document and Folder ContentsWorking with Additional CommandsWriting a Content Provider[PRODUCTNAME] ConfigurationAccessing configuration dataWriting Configuration DataAppendix + +Programmer's ManualPlanned OutlinePreface (3 Pages)First Steps (24 Pages)Programming with UNOFields of Application for UNOGetting StartedRequired FilesConfigurationFirst ConnectionHow to get Objects in [PRODUCTNAME]How to work with ObjectsExampleServicesQuerying InterfacesUsing PropertiesElementAccessSimple TypesStringsEnums and Constant GroupsStructsAnySequenceHow to find the solution for a problemFinding your Way through the API ReferenceCommon MechanismsTextTableDrawingUNO in Professional Projects (145)IntroductionUNO/API constituents: How UNOIDL/API, ServiceManager, Bridges, CoreReflection work togetherAPI ConceptsAPI is a language independent, abstract specification for UNO objects which are used in [PRODUCTNAME]Types in the API ReferenceSimple TypesThe Any TypeInterfacesServicesModulesStructsConstant Groups and EnumsSequencesExceptionsAPI PrinciplesRelationship between Specification, Implementation and InstancesObject CompositionUNO ConceptsUNO is an environment for networked object communicationInterprocess ConnectionsServiceManager and ComponentContextUsing UNO InterfacesUsing PropertiesUsing Collections and ContainersEvent ModelException HandlingLifetime ControlObject IdentityLanguage BindingsIntroduction for language bindingJava Language BindingC++ BindingAccess for [PRODUCTNAME] BasicAutomationWriting UNO componentsSpecifying a new ComponentUNOIDL language specificationImplementing a ComponentComponent Development BasicsIntroductionMandatory interfaces: XInterface, XServiceInfo ((from UseInterfaces.CoreInterfaces))"Should be implemented" interfaces: XTypeProvider ((from UseInterfaces.CoreInterfaces ))optional interface: XMain for standalone executionSimple Component in JavaGetting the service manager ((Chapter Java components from unoBindingJava))simple component chapterC++ Component((Automation Component?))Deployment Options for ComponentsComponent RegistrationService Manager ConfigurationXSet InterfaceAdding components during runtime, particularly interesting during developmentServiceManager ContentDynamically modifying the ServiceManagerBootstrapping the Service Manager ((from CppBind chapter))Simple Test ApplicationConfiguring Your Application with Bootstrap ParametersThe UNO ExecutableStandalone Runtime EnvironmentThe UNO executable and XMainConfiguring the Java Runtime EnvironmentThe office and Java ((from UnoBindingJava))Advanced UNODesign PatternsBridging conceptsRequirements for Language Bindings and BridgesNew Scripting EnginesServiceManager and loaderSpecial Interfaces for internal useXUNOTunnelXAggregationUNO Reflection APITypeLibrary and TypeProvidersDifferences from CorbaOffice DevelopmentGlobal Object StructureDesktop EnvironmentFrames and Frame HierarchiesFrame-Controller-Model ParadigmLoading and Saving Office ComponentsDispatch FrameworkCommon FeaturesCommon DialogsDocumentInfoStylesSearch and ReplaceNumber FormatsPackage File FormatsInternationalizationLinguisticSystem IntegrationClipboardFile PickerBridging to the Window SystemText Documents (51,5 Pages)OverviewHandling Text FilesWorking with Text DocumentsNavigatingUsing TextTablesText FieldsBookmarksIndexes and Index MarksReference MarksFootnotes and EndnotesShape Objects in TextRedlineRubyGlobal Document FeaturesControlling a Text DocumentSpreadsheet DocumentsOverviewHandling Spreadsheet FilesWorking with Spreadsheet DocumentsNavigatingEditing SpreadsheetsGlobal Document FeaturesControlling a Spreadsheet DocumentExtending Capabilities of Spreadsheet DocumentsDrawings and PresentationsOverviewHandling Draw/Impress FilesSavingPrintingRunning PresentationsWorking with a Draw/Impress DocumentNavigatingWorking with Draw/Impress DocumentsGlobal Document FeaturesControlling a Draw/Impress DocumentChartsChart BasicsCreating a Chart DocumentEditing a Chart DocumentCommon Diagram APIDifferent Chart TypesExtending Capabilities of Chart DocumentsBasic and DialogsIntroductionLibrary OrganizationIDE with Dialogs and EventsUsing [PRODUCTNAME] BasicToolkit Controls and their PropertiesCreating Dialogs at RuntimeDatabase AccessFeatures of the [PRODUCTNAME] Database IntegrationCapabilitiesSDBC, SDBCX, SDB ArchitectureAccessing Datasources with [PRODUCTNAME]DataSourcesAdding and Editing Datasources Establishing a ConnectionGetting ConnectionsDriver specificsConnection PoolingWorking with Saved QueriesWorking with DataExecuting StatementsResultsetsMetadataRowsetsWorking with the Database DesignUsing DDL to change the DB DesignUsing SDBCX to access the DB DesignUsing DBMS FeaturesStored ProceduresTransaction HandlingExecuting Prepared StatementsWriting Database DriversFormsConceptsModels and ViewsForm Elements in the Document ModelSpecial Form ComponentsEventsData AwarenessRecipesMaking it easier to work with a FormControlling the Data InputCollecting Data automaticallyTaking Advantage of Database Server FeaturesAdding new FunctionalityHandling ErrorsUCBPurpose of UCBAccessing ContentsOpening Folder ContentsOpening Document Contents as StreamsWorking with Content PropertiesCreating, Moving and Copying Document and Folder ContentsWorking with Additional CommandsWriting a Content Provider[PRODUCTNAME] ConfigurationAccessing configuration dataWriting Configuration DataAppendix + +Programmer's ManualPlanned OutlinePreface (3 Pages)First Steps (24 Pages)Programming with UNOFields of Application for UNOGetting StartedRequired FilesConfigurationFirst ConnectionHow to get Objects in [PRODUCTNAME]How to work with ObjectsExampleServicesQuerying InterfacesUsing PropertiesElementAccessSimple TypesStringsEnums and Constant GroupsStructsAnySequenceHow to find the solution for a problemFinding your Way through the API ReferenceCommon MechanismsTextTableDrawingUNO in Professional Projects (145)IntroductionUNO/API constituents: How UNOIDL/API, ServiceManager, Bridges, CoreReflection work togetherAPI ConceptsAPI is a language independent, abstract specification for UNO objects which are used in [PRODUCTNAME]Types in the API ReferenceSimple TypesThe Any TypeInterfacesServicesModulesStructsConstant Groups and EnumsSequencesExceptionsAPI PrinciplesRelationship between Specification, Implementation and InstancesObject CompositionUNO ConceptsUNO is an environment for networked object communicationInterprocess ConnectionsServiceManager and ComponentContextUsing UNO InterfacesUsing PropertiesUsing Collections and ContainersEvent ModelException HandlingLifetime ControlObject IdentityLanguage BindingsIntroduction for language bindingJava Language BindingC++ BindingAccess for [PRODUCTNAME] BasicAutomationWriting UNO componentsSpecifying a new ComponentUNOIDL language specificationImplementing a ComponentComponent Development BasicsIntroductionMandatory interfaces: XInterface, XServiceInfo ((from UseInterfaces.CoreInterfaces))"Should be implemented" interfaces: XTypeProvider ((from UseInterfaces.CoreInterfaces ))optional interface: XMain for standalone executionSimple Component in JavaGetting the service manager ((Chapter Java components from unoBindingJava))simple component chapterC++ Component((Automation Component?))Deployment Options for ComponentsComponent RegistrationService Manager ConfigurationXSet InterfaceAdding components during runtime, particularly interesting during developmentServiceManager ContentDynamically modifying the ServiceManagerBootstrapping the Service Manager ((from CppBind chapter))Simple Test ApplicationConfiguring Your Application with Bootstrap ParametersThe UNO ExecutableStandalone Runtime EnvironmentThe UNO executable and XMainConfiguring the Java Runtime EnvironmentThe office and Java ((from UnoBindingJava))Advanced UNODesign PatternsBridging conceptsRequirements for Language Bindings and BridgesNew Scripting EnginesServiceManager and loaderSpecial Interfaces for internal useXUNOTunnelXAggregationUNO Reflection APITypeLibrary and TypeProvidersDifferences from CorbaOffice DevelopmentGlobal Object StructureDesktop EnvironmentFrames and Frame HierarchiesFrame-Controller-Model ParadigmLoading and Saving Office ComponentsDispatch FrameworkCommon FeaturesCommon DialogsDocumentInfoStylesSearch and ReplaceNumber FormatsPackage File FormatsInternationalizationLinguisticSystem IntegrationClipboardFile PickerBridging to the Window SystemText Documents (51,5 Pages)OverviewHandling Text FilesWorking with Text DocumentsNavigatingUsing TextTablesText FieldsBookmarksIndexes and Index MarksReference MarksFootnotes and EndnotesShape Objects in TextRedlineRubyGlobal Document FeaturesControlling a Text DocumentSpreadsheet DocumentsOverviewHandling Spreadsheet FilesWorking with Spreadsheet DocumentsNavigatingEditing SpreadsheetsGlobal Document FeaturesControlling a Spreadsheet DocumentExtending Capabilities of Spreadsheet DocumentsDrawings and PresentationsOverviewHandling Draw/Impress FilesSavingPrintingRunning PresentationsWorking with a Draw/Impress DocumentNavigatingWorking with Draw/Impress DocumentsGlobal Document FeaturesControlling a Draw/Impress DocumentChartsChart BasicsCreating a Chart DocumentEditing a Chart DocumentCommon Diagram APIDifferent Chart TypesExtending Capabilities of Chart DocumentsBasic and DialogsIntroductionLibrary OrganizationIDE with Dialogs and EventsUsing [PRODUCTNAME] BasicToolkit Controls and their PropertiesCreating Dialogs at RuntimeDatabase AccessFeatures of the [PRODUCTNAME] Database IntegrationCapabilitiesSDBC, SDBCX, SDB ArchitectureAccessing Datasources with [PRODUCTNAME]DataSourcesAdding and Editing Datasources Establishing a ConnectionGetting ConnectionsDriver specificsConnection PoolingWorking with Saved QueriesWorking with DataExecuting StatementsResultsetsMetadataRowsetsWorking with the Database DesignUsing DDL to change the DB DesignUsing SDBCX to access the DB DesignUsing DBMS FeaturesStored ProceduresTransaction HandlingExecuting Prepared StatementsWriting Database DriversFormsConceptsModels and ViewsForm Elements in the Document ModelSpecial Form ComponentsEventsData AwarenessRecipesMaking it easier to work with a FormControlling the Data InputCollecting Data automaticallyTaking Advantage of Database Server FeaturesAdding new FunctionalityHandling ErrorsUCBPurpose of UCBAccessing ContentsOpening Folder ContentsOpening Document Contents as StreamsWorking with Content PropertiesCreating, Moving and Copying Document and Folder ContentsWorking with Additional CommandsWriting a Content Provider[PRODUCTNAME] ConfigurationAccessing configuration dataWriting Configuration DataAppendix + + + \ No newline at end of file diff --git a/xmlsecurity/tools/examples/uno_win.bat b/xmlsecurity/tools/examples/uno_win.bat new file mode 100644 index 000000000000..7b0ffdac3c07 --- /dev/null +++ b/xmlsecurity/tools/examples/uno_win.bat @@ -0,0 +1,24 @@ +set WS_PATH=e:/mybuild/SRC680 +set SO_CLASSPATHPATH=d:/2000Soft/OOo1.1/program/classes + +@echo off +echo ============================================= +echo step - 1 start OpenOffice +echo ============================================= +@echo on + +@echo off +echo please start up OpenOffice with "-accept=socket,host=0,port=2002;urp;" +pause Press Enter when finished... +@echo on + +@echo off +echo ============================================= +echo step - 2 run the testtool class +echo ============================================= +@echo on + +cp %WS_PATH%/xmlsecurity/tools/uno/current.gif ./. +java -classpath %WS_PATH%/xmlsecurity/wntmsci8.pro/class;%SO_CLASSPATHPATH%/rt.jar;%SO_CLASSPATHPATH%/java_uno.jar;%SO_CLASSPATHPATH%/sandbox.jar;%SO_CLASSPATHPATH%/jurt.jar;%SO_CLASSPATHPATH%/unoil.jar;%SO_CLASSPATHPATH%/ridl.jar;%SO_CLASSPATHPATH%/juh.jar com.sun.star.xml.security.uno.TestTool %WS_PATH%/xmlsecurity/tools/cryptoken/jks/testToken.jks %WS_PATH%/xmlsecurity/tools/cryptoken/nss +rm ./current.gif + diff --git a/xmlsecurity/tools/examples/warmup.xml b/xmlsecurity/tools/examples/warmup.xml new file mode 100644 index 000000000000..70abf5cd4d34 --- /dev/null +++ b/xmlsecurity/tools/examples/warmup.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + CN=Test Issuer + 123450005 + + + + + + +你好 + + + \ No newline at end of file diff --git a/xmlsecurity/tools/standalone/csfit/certmngr.cxx b/xmlsecurity/tools/standalone/csfit/certmngr.cxx new file mode 100644 index 000000000000..bacf989e3ac1 --- /dev/null +++ b/xmlsecurity/tools/standalone/csfit/certmngr.cxx @@ -0,0 +1,201 @@ +/************************************************************************* + * + * $RCSfile: certmngr.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:25 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#include +#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 "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 + +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 ; + +extern OUString bigIntegerToNumericString( Sequence< sal_Int8 > serial ) ; + +int SAL_CALL main( int argc, char **argv ) +{ + CERTCertDBHandle* certHandle ; + PK11SlotInfo* slot = NULL ; + + if( argc != 3 ) { + fprintf( stderr, "Usage: %s < CertDir > \n\n" , argv[0] ) ; + return 1 ; + } + + for( ; getchar() != 'q' ; ) { + + //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() ; + + try { + Reference< XMultiComponentFactory > xManager = NULL ; + Reference< XComponentContext > xContext = NULL ; + + xManager = serviceManager( xContext , OUString::createFromAscii( "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::createFromAscii("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" ) ; + } + } + } 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; +} + diff --git a/xmlsecurity/tools/standalone/csfit/decrypter.cxx b/xmlsecurity/tools/standalone/csfit/decrypter.cxx new file mode 100644 index 000000000000..fb49fa9aa79f --- /dev/null +++ b/xmlsecurity/tools/standalone/csfit/decrypter.cxx @@ -0,0 +1,303 @@ +/************************************************************************* + * + * $RCSfile: decrypter.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:25 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#include +#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 +#include +#include + +#include +#include +#include +#include +#include +#include +#include + + +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 > \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::createFromAscii( "local" ), OUString::createFromAscii( argv[4] ) ) ; + + //Create encryption template + Reference< XInterface > tplElement = + xManager->createInstanceWithContext( OUString::createFromAscii( "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::createFromAscii("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::createFromAscii("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_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::createFromAscii("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::createFromAscii("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; +} + diff --git a/xmlsecurity/tools/standalone/csfit/encrypter.cxx b/xmlsecurity/tools/standalone/csfit/encrypter.cxx new file mode 100644 index 000000000000..fe73d3052a4f --- /dev/null +++ b/xmlsecurity/tools/standalone/csfit/encrypter.cxx @@ -0,0 +1,340 @@ +/************************************************************************* + * + * $RCSfile: encrypter.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:25 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#include +#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 +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +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 > \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::createFromAscii( "local" ), OUString::createFromAscii( argv[6] ) ) ; + + //Create encryption template + Reference< XInterface > tplElement = + xManager->createInstanceWithContext( OUString::createFromAscii( "com.sun.star.xml.xsec.XMLElementWrapper" ) , 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::createFromAscii( "com.sun.star.xml.xsec.XMLElementWrapper" ) , 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::createFromAscii("com.sun.star.xml.xsec.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::createFromAscii("com.sun.star.xml.xsec.SecurityEnvironment"), 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::createFromAscii("com.sun.star.xml.xsec.XMLSecurityContext"), 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::createFromAscii("com.sun.star.xml.xsec.XMLEncryption"), 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; +} + diff --git a/xmlsecurity/tools/standalone/csfit/helper.cxx b/xmlsecurity/tools/standalone/csfit/helper.cxx new file mode 100644 index 000000000000..f0b566c8a6bd --- /dev/null +++ b/xmlsecurity/tools/standalone/csfit/helper.cxx @@ -0,0 +1,297 @@ +/************************************************************************* + * + * $RCSfile: helper.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:25 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#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 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.equalsAscii( "" ) , + "serviceManager - " + "No uno URI specified" ) ; + + OSL_ENSURE( !sRdbUrl.equalsAscii( "" ) , + "serviceManager - " + "No rdb URI specified" ) ; + + if( sUnoUrl.equalsAscii( "local" ) ) { + Reference< XSimpleRegistry > xSimpleRegistry = createSimpleRegistry(); + OSL_ENSURE( xSimpleRegistry.is() , + "serviceManager - " + "Cannot create simple registry" ) ; + + //xSimpleRegistry->open(OUString::createFromAscii("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::createFromAscii( UCB_CONFIGURATION_KEY1_LOCAL ) ; + args[ 1 ] <<= OUString::createFromAscii( UCB_CONFIGURATION_KEY2_OFFICE ) ; + if( ! ::ucb::ContentBroker::initialize( xSvmg , args ) ) { + throw RuntimeException( OUString::createFromAscii( "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::createFromAscii("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::createFromAscii( "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::createFromAscii( "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::createFromAscii( "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::createFromAscii( "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 ; +} + diff --git a/xmlsecurity/tools/standalone/csfit/helper.hxx b/xmlsecurity/tools/standalone/csfit/helper.hxx new file mode 100644 index 000000000000..a8e63251dfbd --- /dev/null +++ b/xmlsecurity/tools/standalone/csfit/helper.hxx @@ -0,0 +1,275 @@ +/************************************************************************* + * + * $RCSfile: helper.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:25 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#include +/*#include +*/ + +#include +#include + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +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 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 ) ; + + diff --git a/xmlsecurity/tools/standalone/csfit/makefile.mk b/xmlsecurity/tools/standalone/csfit/makefile.mk new file mode 100644 index 000000000000..450233169461 --- /dev/null +++ b/xmlsecurity/tools/standalone/csfit/makefile.mk @@ -0,0 +1,187 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1.1.1 $ +# +# last change: $Author: mt $ $Date: 2004-07-12 13:15:25 $ +# +# The Contents of this file are made available subject to the terms of +# either of the following licenses +# +# - GNU Lesser General Public License Version 2.1 +# - Sun Industry Standards Source License Version 1.1 +# +# Sun Microsystems Inc., October, 2000 +# +# GNU Lesser General Public License Version 2.1 +# ============================================= +# Copyright 2000 by Sun Microsystems, Inc. +# 901 San Antonio Road, Palo Alto, CA 94303, USA +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License version 2.1, as published by the Free Software Foundation. +# +# This library 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 for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, +# MA 02111-1307 USA +# +# +# Sun Industry Standards Source License Version 1.1 +# ================================================= +# The contents of this file are subject to the Sun Industry Standards +# Source License Version 1.1 (the "License"); You may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at http://www.openoffice.org/license.html. +# +# Software provided under this License is provided on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, +# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, +# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. +# See the License for the specific provisions governing your rights and +# obligations concerning the Software. +# +# The Initial Developer of the Original Code is: Sun Microsystems, Inc. +# +# Copyright: 2000 by Sun Microsystems, Inc. +# +# All Rights Reserved. +# +# Contributor(s): _______________________________________ +# +# +# +#************************************************************************* + +PRJ=..$/..$/.. + +PRJNAME=xmlsecurity +TARGET=xmlsecurity-cxsfit +ENABLE_EXCEPTIONS=TRUE +NO_BSYMBOLIC=TRUE +TARGETTYPE=CUI +LIBTARGET=NO + +# --- Settings ----------------------------------------------------- + +.INCLUDE : svpre.mk +.INCLUDE : settings.mk +.INCLUDE : sv.mk +.INCLUDE : $(PRJ)$/util$/target.pmk + + +.IF "$(CRYPTO_ENGINE)" == "nss" + +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) \ + $(SALLIB) + +.IF "$(GUI)"=="WNT" +SHARE_LIBS+= "ixml2.lib" "nss3.lib" "nspr4.lib" "xmlsec.lib" "xmlsec-nss.lib" "xsec_xmlsec.lib" +.ELSE +SHARE_LIBS+= "-lxml2" "-lnss3" "-lnspr4" "-lxmlsec" "-lxmlsec-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 new file mode 100644 index 000000000000..b29acea17d15 --- /dev/null +++ b/xmlsecurity/tools/standalone/csfit/signer.cxx @@ -0,0 +1,388 @@ +/************************************************************************* + * + * $RCSfile: signer.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:25 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#include +#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 + +#include +#include +#include +#include +#include +#include +#include + +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 = NULL ; + 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 != 5 ) { + fprintf( stderr, "Usage: %s < CertDir > \n\n" , argv[0] ) ; + return 1 ; + } + + for( int hhh = 0 ; hhh < 2 ; 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 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 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::createFromAscii( "local" ), OUString::createFromAscii( argv[4] ) ) ; + OSL_ENSURE( xManager.is() , + "ServicesManager - " + "Cannot get service manager" ) ; + + //Create signature template + Reference< XInterface > element = + xManager->createInstanceWithContext( OUString::createFromAscii( "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::createFromAscii( "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::createFromAscii("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::createFromAscii("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::createFromAscii("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; +} + diff --git a/xmlsecurity/tools/standalone/csfit/util/makefile.mk b/xmlsecurity/tools/standalone/csfit/util/makefile.mk new file mode 100644 index 000000000000..ee39211b9f12 --- /dev/null +++ b/xmlsecurity/tools/standalone/csfit/util/makefile.mk @@ -0,0 +1,216 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1.1.1 $ +# +# last change: $Author: mt $ $Date: 2004-07-12 13:15:25 $ +# +# The Contents of this file are made available subject to the terms of +# either of the following licenses +# +# - GNU Lesser General Public License Version 2.1 +# - Sun Industry Standards Source License Version 1.1 +# +# Sun Microsystems Inc., October, 2000 +# +# GNU Lesser General Public License Version 2.1 +# ============================================= +# Copyright 2000 by Sun Microsystems, Inc. +# 901 San Antonio Road, Palo Alto, CA 94303, USA +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License version 2.1, as published by the Free Software Foundation. +# +# This library 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 for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, +# MA 02111-1307 USA +# +# +# Sun Industry Standards Source License Version 1.1 +# ================================================= +# The contents of this file are subject to the Sun Industry Standards +# Source License Version 1.1 (the "License"); You may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at http://www.openoffice.org/license.html. +# +# Software provided under this License is provided on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, +# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, +# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. +# See the License for the specific provisions governing your rights and +# obligations concerning the Software. +# +# The Initial Developer of the Original Code is: Sun Microsystems, Inc. +# +# Copyright: 2000 by Sun Microsystems, Inc. +# +# All Rights Reserved. +# +# Contributor(s): _______________________________________ +# +# +# +#************************************************************************* +PRJ=..$/..$/..$/.. + +PRJNAME=xmlsecurity +TARGET=xmlsecurity-secfit-boot +TARGETTYPE=GUI + +VERSION=$(UPD) +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$(UPD)$(DLLPOSTFIX)$(DLLPOST) \ + $(DLLPRE)mcnttype$(DLLPOST) + +# $(DLLPRE)i18n$(UPD)$(DLLPOSTFIX)$(DLLPOST) \ +# $(DLLPRE)i18npool$(UPD)$(DLLPOSTFIX)$(DLLPOST) \ +# $(DLLPRE)tk$(UPD)$(DLLPOSTFIX)$(DLLPOST) \ +# $(DLLPRE)mcnttype$(DLLPOST) + +# Additional libraries +DLLPRE_NO= +REGISTERLIBS+= \ + $(DLLPRE_NO)shlibloader.uno$(DLLPOST) \ + $(DLLPRE_NO)dynamicloader.uno$(DLLPOST) \ + $(DLLPRE_NO)namingservice.uno$(DLLPOST) \ + $(DLLPRE_NO)servicemgr.uno$(DLLPOST) \ + $(DLLPRE)xsec_fw$(DLLPOST) \ + $(DLLPRE)xsec_xmlsec$(DLLPOST) + +# $(DLLPRE)implreg.uno$(DLLPOST) \ +# $(DLLPRE)nestedreg.uno$(DLLPOST) \ +# $(DLLPRE)simplereg.uno$(DLLPOST) \ + + +.IF "$(GUI)" == "UNX" +MY_DLLDIR=$(SOLARLIBDIR) +REGISTERLIBS+= \ + $(DLLPRE)dtransX11$(UPD)$(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 sandbox.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 new file mode 100644 index 000000000000..2de2a424b9ca --- /dev/null +++ b/xmlsecurity/tools/standalone/csfit/verifier.cxx @@ -0,0 +1,371 @@ +/************************************************************************* + * + * $RCSfile: verifier.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:25 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#include +#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 +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +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 > \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::createFromAscii( "local" ), OUString::createFromAscii( argv[3] ) ) ; + + //Create signature template + Reference< XInterface > element = + xManager->createInstanceWithContext( OUString::createFromAscii( "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::createFromAscii("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::createFromAscii("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::createFromAscii("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::createFromAscii("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 ; +} + diff --git a/xmlsecurity/tools/standalone/mscsfit/certmngr.cxx b/xmlsecurity/tools/standalone/mscsfit/certmngr.cxx new file mode 100644 index 000000000000..8f234a0346f9 --- /dev/null +++ b/xmlsecurity/tools/standalone/mscsfit/certmngr.cxx @@ -0,0 +1,140 @@ +/** -- C++ Source File -- **/ +#include +#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 "xmlsec/strings.h" +#include "xmlsec/xmltree.h" +#include "xmlsec/mscrypto/app.h" + +#include + +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 ; + +extern OUString bigIntegerToNumericString( Sequence< sal_Int8 > serial ) ; + +int SAL_CALL main( int argc, char **argv ) +{ + const char* n_pCertStore ; + HCERTSTORE n_hStoreHandle ; + + if( argc != 3 && argc != 2 ) { + fprintf( stderr, "Usage: %s \n" , argv[0] ) ; + fprintf( stderr, "Or: \t%s < 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::createFromAscii( "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::createFromAscii("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" ) ; + } + } + } 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; +} + diff --git a/xmlsecurity/tools/standalone/mscsfit/decrypter.cxx b/xmlsecurity/tools/standalone/mscsfit/decrypter.cxx new file mode 100644 index 000000000000..17a758f0cf42 --- /dev/null +++ b/xmlsecurity/tools/standalone/mscsfit/decrypter.cxx @@ -0,0 +1,243 @@ +/** -- C++ Source File -- **/ +#include +#include "helper.hxx" + +#include "libxml/tree.h" +#include "libxml/parser.h" +#ifndef XMLSEC_NO_XSLT +#include "libxslt/xslt.h" +#endif + + +#include "SecurityEnvironment_XmlSecImpl.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 +#include +#include + +#include +#include +#include +#include +#include +#include +#include + + +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 > \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::createFromAscii( "local" ), OUString::createFromAscii( argv[4] ) ) ; + + //Create encryption template + Reference< XInterface > tplElement = + xManager->createInstanceWithContext( OUString::createFromAscii( "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::createFromAscii("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::createFromAscii("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::createFromAscii("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::createFromAscii("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; +} + diff --git a/xmlsecurity/tools/standalone/mscsfit/encrypter.cxx b/xmlsecurity/tools/standalone/mscsfit/encrypter.cxx new file mode 100644 index 000000000000..e0f88626ba65 --- /dev/null +++ b/xmlsecurity/tools/standalone/mscsfit/encrypter.cxx @@ -0,0 +1,294 @@ +/** -- C++ Source File -- **/ +#include +#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 +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +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 \n\n" , argv[0] ) ; + fprintf( stderr, "Usage: %s < 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::createFromAscii( "local" ), OUString::createFromAscii( argv[5] ) ) ; + + //Create encryption template + Reference< XInterface > tplElement = + xManager->createInstanceWithContext( OUString::createFromAscii( "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::createFromAscii( "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::createFromAscii("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::createFromAscii("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::createFromAscii("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->setSecurityEnvironment( xSecEnv ) ; + + //Get encrypter + Reference< XInterface > xmlencrypter = + xManager->createInstanceWithContext( OUString::createFromAscii("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 , 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[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; +} + diff --git a/xmlsecurity/tools/standalone/mscsfit/helper.cxx b/xmlsecurity/tools/standalone/mscsfit/helper.cxx new file mode 100644 index 000000000000..de11d89405bb --- /dev/null +++ b/xmlsecurity/tools/standalone/mscsfit/helper.cxx @@ -0,0 +1,217 @@ +#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 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.equalsAscii( "" ) , + "serviceManager - " + "No uno URI specified" ) ; + + OSL_ENSURE( !sRdbUrl.equalsAscii( "" ) , + "serviceManager - " + "No rdb URI specified" ) ; + + if( sUnoUrl.equalsAscii( "local" ) ) { + Reference< XSimpleRegistry > xSimpleRegistry = createSimpleRegistry(); + OSL_ENSURE( xSimpleRegistry.is() , + "serviceManager - " + "Cannot create simple registry" ) ; + + //xSimpleRegistry->open(OUString::createFromAscii("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::createFromAscii( UCB_CONFIGURATION_KEY1_LOCAL ) ; + args[ 1 ] <<= OUString::createFromAscii( UCB_CONFIGURATION_KEY2_OFFICE ) ; + if( ! ::ucb::ContentBroker::initialize( xSvmg , args ) ) { + throw RuntimeException( OUString::createFromAscii( "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::createFromAscii("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::createFromAscii( "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::createFromAscii( "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::createFromAscii( "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::createFromAscii( "DefaultContext" ) ) >>= xUsedComponentContext ; + OSL_ENSURE( xUsedComponentContext.is() , + "serviceManager - " + "Cannot create remote component context" ) ; + /********************************************************************/ + } + + xContext = xUsedComponentContext ; + return xUsedServiceManager ; +} + diff --git a/xmlsecurity/tools/standalone/mscsfit/helper.hxx b/xmlsecurity/tools/standalone/mscsfit/helper.hxx new file mode 100644 index 000000000000..0f95ef50c4ab --- /dev/null +++ b/xmlsecurity/tools/standalone/mscsfit/helper.hxx @@ -0,0 +1,204 @@ +#include +#include + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +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 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 ) ; + diff --git a/xmlsecurity/tools/standalone/mscsfit/makefile.mk b/xmlsecurity/tools/standalone/mscsfit/makefile.mk new file mode 100644 index 000000000000..8c28a824f68c --- /dev/null +++ b/xmlsecurity/tools/standalone/mscsfit/makefile.mk @@ -0,0 +1,184 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1.1.1 $ +# +# last change: $Author: mt $ $Date: 2004-07-12 13:15:25 $ +# +# The Contents of this file are made available subject to the terms of +# either of the following licenses +# +# - GNU Lesser General Public License Version 2.1 +# - Sun Industry Standards Source License Version 1.1 +# +# Sun Microsystems Inc., October, 2000 +# +# GNU Lesser General Public License Version 2.1 +# ============================================= +# Copyright 2000 by Sun Microsystems, Inc. +# 901 San Antonio Road, Palo Alto, CA 94303, USA +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License version 2.1, as published by the Free Software Foundation. +# +# This library 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 for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, +# MA 02111-1307 USA +# +# +# Sun Industry Standards Source License Version 1.1 +# ================================================= +# The contents of this file are subject to the Sun Industry Standards +# Source License Version 1.1 (the "License"); You may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at http://www.openoffice.org/license.html. +# +# Software provided under this License is provided on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, +# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, +# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. +# See the License for the specific provisions governing your rights and +# obligations concerning the Software. +# +# The Initial Developer of the Original Code is: Sun Microsystems, Inc. +# +# Copyright: 2000 by Sun Microsystems, Inc. +# +# All Rights Reserved. +# +# Contributor(s): _______________________________________ +# +# +# +#************************************************************************* + +PRJ=..$/..$/.. + +PRJNAME=xmlsecurity +TARGET=xmlsecurity-mscxsfit +ENABLE_EXCEPTIONS=TRUE +NO_BSYMBOLIC=TRUE +TARGETTYPE=CUI +LIBTARGET=NO + + +# --- Settings ----------------------------------------------------- + +.INCLUDE : svpre.mk +.INCLUDE : settings.mk +.INCLUDE : sv.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+= "ixml2.lib" "crypt32.lib" "advapi32.lib" "xmlsec.lib" "xmlsec-mscrypto.lib" "xsec_xmlsec.lib" +.ELSE +SHARE_LIBS+= "-lxml2" "-lnss3" "-lnspr4" "-lxmlsec" "-lxmlsec-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/mscsfit/signer.cxx b/xmlsecurity/tools/standalone/mscsfit/signer.cxx new file mode 100644 index 000000000000..d47912b8e83c --- /dev/null +++ b/xmlsecurity/tools/standalone/mscsfit/signer.cxx @@ -0,0 +1,328 @@ +/** -- C++ Source File -- **/ +#include +#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 + +#include +#include +#include +#include +#include +#include +#include + +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 \n" , argv[0] ) ; + fprintf( stderr, "Or: \t%s < 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::createFromAscii( "local" ), OUString::createFromAscii( argv[3] ) ) ; + OSL_ENSURE( xManager.is() , + "ServicesManager - " + "Cannot get service manager" ) ; + + //Create signature template + Reference< XInterface > element = + xManager->createInstanceWithContext( OUString::createFromAscii( "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::createFromAscii( "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::createFromAscii("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::createFromAscii("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->setSecurityEnvironment( xSecEnv ) ; + + //Generate XML signature + Reference< XInterface > xmlsigner = + xManager->createInstanceWithContext( OUString::createFromAscii("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 , 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[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; +} + diff --git a/xmlsecurity/tools/standalone/mscsfit/util/makefile.mk b/xmlsecurity/tools/standalone/mscsfit/util/makefile.mk new file mode 100644 index 000000000000..a6ecf612ea56 --- /dev/null +++ b/xmlsecurity/tools/standalone/mscsfit/util/makefile.mk @@ -0,0 +1,216 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1.1.1 $ +# +# last change: $Author: mt $ $Date: 2004-07-12 13:15:25 $ +# +# The Contents of this file are made available subject to the terms of +# either of the following licenses +# +# - GNU Lesser General Public License Version 2.1 +# - Sun Industry Standards Source License Version 1.1 +# +# Sun Microsystems Inc., October, 2000 +# +# GNU Lesser General Public License Version 2.1 +# ============================================= +# Copyright 2000 by Sun Microsystems, Inc. +# 901 San Antonio Road, Palo Alto, CA 94303, USA +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License version 2.1, as published by the Free Software Foundation. +# +# This library 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 for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, +# MA 02111-1307 USA +# +# +# Sun Industry Standards Source License Version 1.1 +# ================================================= +# The contents of this file are subject to the Sun Industry Standards +# Source License Version 1.1 (the "License"); You may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at http://www.openoffice.org/license.html. +# +# Software provided under this License is provided on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, +# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, +# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. +# See the License for the specific provisions governing your rights and +# obligations concerning the Software. +# +# The Initial Developer of the Original Code is: Sun Microsystems, Inc. +# +# Copyright: 2000 by Sun Microsystems, Inc. +# +# All Rights Reserved. +# +# Contributor(s): _______________________________________ +# +# +# +#************************************************************************* +PRJ=..$/..$/..$/.. + +PRJNAME=xmlsecurity +TARGET=xmlsecurity-mscsfit-boot +TARGETTYPE=GUI + +VERSION=$(UPD) +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$(UPD)$(DLLPOSTFIX)$(DLLPOST) \ + $(DLLPRE)mcnttype$(DLLPOST) + +# $(DLLPRE)i18n$(UPD)$(DLLPOSTFIX)$(DLLPOST) \ +# $(DLLPRE)i18npool$(UPD)$(DLLPOSTFIX)$(DLLPOST) \ +# $(DLLPRE)tk$(UPD)$(DLLPOSTFIX)$(DLLPOST) \ +# $(DLLPRE)mcnttype$(DLLPOST) + +# Additional libraries +DLLPRE_NO= +REGISTERLIBS+= \ + $(DLLPRE_NO)shlibloader.uno$(DLLPOST) \ + $(DLLPRE_NO)dynamicloader.uno$(DLLPOST) \ + $(DLLPRE_NO)namingservice.uno$(DLLPOST) \ + $(DLLPRE_NO)servicemgr.uno$(DLLPOST) \ + $(DLLPRE)xsec_fw$(DLLPOST) \ + $(DLLPRE)xsec_xmlsec$(DLLPOST) + +# $(DLLPRE)implreg.uno$(DLLPOST) \ +# $(DLLPRE)nestedreg.uno$(DLLPOST) \ +# $(DLLPRE)simplereg.uno$(DLLPOST) \ + + +.IF "$(GUI)" == "UNX" +MY_DLLDIR=$(SOLARLIBDIR) +REGISTERLIBS+= \ + $(DLLPRE)dtransX11$(UPD)$(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 sandbox.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 new file mode 100644 index 000000000000..af2c5ec82e06 --- /dev/null +++ b/xmlsecurity/tools/standalone/mscsfit/verifier.cxx @@ -0,0 +1,319 @@ +/** -- C++ Source File -- **/ +#include +#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 +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +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 ; + FILE* dstFile = NULL ; + + if( argc !=3 && argc != 4 ) { + fprintf( stderr, "Usage: %s \n" , argv[0] ) ; + fprintf( stderr, "Or: \t%s < 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::createFromAscii( "local" ), OUString::createFromAscii( argv[2] ) ) ; + + //Create signature template + Reference< XInterface > element = + xManager->createInstanceWithContext( OUString::createFromAscii( "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::createFromAscii("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::createFromAscii("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::createFromAscii("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->setSecurityEnvironment( xSecEnv ) ; + + //Generate XML signature + Reference< XInterface > xmlsigner = + xManager->createInstanceWithContext( OUString::createFromAscii("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 + 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( 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 ; +} + diff --git a/xmlsecurity/tools/uno/AdapterNode.java b/xmlsecurity/tools/uno/AdapterNode.java new file mode 100644 index 000000000000..6653fc072b0d --- /dev/null +++ b/xmlsecurity/tools/uno/AdapterNode.java @@ -0,0 +1,199 @@ +/************************************************************************* + * + * $RCSfile: AdapterNode.java,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:24 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +package com.sun.star.xml.security.uno; + +import org.w3c.dom.Node; +import org.w3c.dom.Attr; +import org.w3c.dom.NamedNodeMap; + + +/* + * This class wraps a DOM node and returns the text we want to + * display in the tree. It also returns children, index values, + * and child counts. + */ +class AdapterNode +{ + private Node m_domNode; + static final int ELEMENT_TYPE = Node.ELEMENT_NODE; + + /* + * An array of names for DOM node-types + */ + static final String[] typeName = { + "none", + "Element", + "Attr", + "Text", + "CDATA", + "EntityRef", + "Entity", + "ProcInstr", + "Comment", + "Document", + "DocType", + "DocFragment", + "Notation", + }; + + protected Node getNode() + { + return m_domNode; + } + + /* + * Construct an Adapter node from a DOM node + */ + protected AdapterNode(org.w3c.dom.Node node) + { + m_domNode = node; + } + + /* + * Return children, index, and count values + */ + protected int index(AdapterNode child) + { + int count = childCount(); + for (int i=0; i=0 && index 0) + { + rc = false; + } + + return rc; + } + + public int getChildCount(Object parent) + { + AdapterNode node = (AdapterNode) parent; + return node.childCount(); + } + + public Object getChild(Object parent, int index) + { + AdapterNode node = (AdapterNode) parent; + return node.child(index); + } + + public int getIndexOfChild(Object parent, Object child) + { + AdapterNode node = (AdapterNode) parent; + return node.index((AdapterNode) child); + } + + public void valueForPathChanged(TreePath path, Object newValue) + { + /* + * Null. We won't be making changes in the GUI + * If we did, we would ensure the new value was really new, + * adjust the model, and then fire a TreeNodesChanged event. + */ + } + + public void addTreeModelListener(TreeModelListener listener) + { + if ( listener != null + && ! m_listenerList.contains( listener ) ) + { + m_listenerList.addElement( listener ); + } + } + + public void removeTreeModelListener(TreeModelListener listener) + { + if ( listener != null ) + { + m_listenerList.removeElement( listener ); + } + } + + public void fireTreeNodesChanged( TreeModelEvent e ) + { + Enumeration listeners = m_listenerList.elements(); + while ( listeners.hasMoreElements() ) + { + TreeModelListener listener = + (TreeModelListener) listeners.nextElement(); + listener.treeNodesChanged( e ); + } + } + + public void fireTreeNodesInserted( TreeModelEvent e ) + { + Enumeration listeners = m_listenerList.elements(); + while ( listeners.hasMoreElements() ) + { + TreeModelListener listener = + (TreeModelListener) listeners.nextElement(); + listener.treeNodesInserted( e ); + } + } + + public void fireTreeNodesRemoved( TreeModelEvent e ) + { + Enumeration listeners = m_listenerList.elements(); + while ( listeners.hasMoreElements() ) + { + TreeModelListener listener = + (TreeModelListener) listeners.nextElement(); + listener.treeNodesRemoved( e ); + } + } + + public void fireTreeStructureChanged( TreeModelEvent e ) + { + Enumeration listeners = m_listenerList.elements(); + while ( listeners.hasMoreElements() ) + { + TreeModelListener listener = + (TreeModelListener) listeners.nextElement(); + listener.treeStructureChanged( e ); + } + } +} + diff --git a/xmlsecurity/tools/uno/EncryptionEntity.java b/xmlsecurity/tools/uno/EncryptionEntity.java new file mode 100644 index 000000000000..3732b0c69095 --- /dev/null +++ b/xmlsecurity/tools/uno/EncryptionEntity.java @@ -0,0 +1,252 @@ +/************************************************************************* + * + * $RCSfile: EncryptionEntity.java,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:24 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +package com.sun.star.xml.security.uno; + +/* uno classes */ +import com.sun.star.uno.UnoRuntime; +import com.sun.star.lang.XMultiComponentFactory; +import com.sun.star.lang.XInitialization; +import com.sun.star.uno.XComponentContext; + +import com.sun.star.xml.crypto.*; +import com.sun.star.xml.crypto.sax.*; + +/* + * this class maintains the data for an encryption operation. + */ +class EncryptionEntity extends SecurityEntity +{ + private int m_nEncryptionElementCollectorId; + + EncryptionEntity( + XSecuritySAXEventKeeper xSAXEventKeeper, + boolean isExporting, + Object resultListener, + XXMLSecurityContext xXMLSecurityContext, + XXMLSignature xXMLSignature, + XXMLEncryption xXMLEncryption, + XMultiComponentFactory xRemoteServiceManager, + XComponentContext xRemoteContext) + { + super(xSAXEventKeeper, xXMLSecurityContext, xXMLSignature, + xXMLEncryption, xRemoteServiceManager, xRemoteContext); + + m_nEncryptionElementCollectorId = m_xSAXEventKeeper.addSecurityElementCollector( + ElementMarkPriority.PRI_AFTERMODIFY, + true); + + m_xSAXEventKeeper.setSecurityId(m_nEncryptionElementCollectorId, m_nSecurityId); + + if (isExporting) + { + try + { + /* + * creates a Encryptor. + */ + Object encryptor = m_xRemoteServiceManager.createInstanceWithContext( + TestTool.ENCRYPTOR_COMPONENT, m_xRemoteContext); + + m_xReferenceResolvedListener = + (XReferenceResolvedListener)UnoRuntime.queryInterface( + XReferenceResolvedListener.class, encryptor); + + /* + * initializes the Encryptor. + */ + XInitialization xInitialization = + (XInitialization)UnoRuntime.queryInterface( + XInitialization.class, m_xReferenceResolvedListener); + Object args[]=new Object[5]; + args[0] = new Integer(m_nSecurityId).toString(); + args[1] = m_xSAXEventKeeper; + args[2] = new Integer(m_nEncryptionElementCollectorId).toString(); + args[3] = m_xXMLSecurityContext; + args[4] = m_xXMLEncryption; + xInitialization.initialize(args); + + /* + * sets encryption result listener. + */ + XEncryptionResultBroadcaster m_xEncryptionResultBroadcaster = + (XEncryptionResultBroadcaster)UnoRuntime.queryInterface( + XEncryptionResultBroadcaster.class, m_xReferenceResolvedListener); + m_xEncryptionResultBroadcaster.addEncryptionResultListener( + (XEncryptionResultListener)UnoRuntime.queryInterface( + XEncryptionResultListener.class, resultListener)); + } + catch( com.sun.star.uno.Exception e) + { + e.printStackTrace(); + } + } + else + { + try{ + /* + * creates a Decryptor. + */ + Object decryptor = m_xRemoteServiceManager.createInstanceWithContext( + TestTool.DECRYPTOR_COMPONENT, m_xRemoteContext); + + m_xReferenceResolvedListener = + (XReferenceResolvedListener)UnoRuntime.queryInterface( + XReferenceResolvedListener.class, decryptor); + + /* + * initializes the Decryptor. + */ + XInitialization xInitialization = (XInitialization)UnoRuntime.queryInterface(XInitialization.class, m_xReferenceResolvedListener); + Object args[]=new Object[5]; + args[0] = new Integer(m_nSecurityId).toString(); + args[1] = m_xSAXEventKeeper; + args[2] = new Integer(m_nEncryptionElementCollectorId).toString(); + args[3] = m_xXMLSecurityContext; + args[4] = m_xXMLEncryption; + xInitialization.initialize(args); + + /* + * sets decryption result listener. + */ + XDecryptionResultBroadcaster m_xDecryptionResultBroadcaster = + (XDecryptionResultBroadcaster)UnoRuntime.queryInterface( + XDecryptionResultBroadcaster.class, m_xReferenceResolvedListener); + m_xDecryptionResultBroadcaster.addDecryptionResultListener( + (XDecryptionResultListener)UnoRuntime.queryInterface( + XDecryptionResultListener.class, resultListener)); + } + catch( com.sun.star.uno.Exception e) + { + e.printStackTrace(); + } + } + + /* + * creates a Blocker. + */ + int blockerId = m_xSAXEventKeeper.addBlocker(); + m_xSAXEventKeeper.setSecurityId(blockerId, m_nSecurityId); + + try + { + XBlockerMonitor xBlockerMonitor = (XBlockerMonitor)UnoRuntime.queryInterface( + XBlockerMonitor.class, m_xReferenceResolvedListener); + xBlockerMonitor.setBlockerId(blockerId); + } + catch( com.sun.star.uno.Exception e) + { + e.printStackTrace(); + } + + /* + * configures the resolve listener for the encryption template. + */ + XReferenceResolvedBroadcaster xReferenceResolvedBroadcaster = + (XReferenceResolvedBroadcaster)UnoRuntime.queryInterface( + XReferenceResolvedBroadcaster.class, m_xSAXEventKeeper); + xReferenceResolvedBroadcaster.addReferenceResolvedListener(m_nEncryptionElementCollectorId, m_xReferenceResolvedListener); + } + + /* + * add the reference to this encryption. + * + * 1. askes the SAXEventKeeper to add a ElementCollector to for the new + * referenced element; + * 2. configures this ElementCollector's security id; + * 3. tells the SAXEventKeeper which listener will receive the reference + * resolved notification. + * 4. notifies the SignatureCollector about the reference id. + */ + protected boolean setReference(boolean isExporting) + { + boolean rc = false; + + int referenceId = m_xSAXEventKeeper.addSecurityElementCollector( + isExporting? + (ElementMarkPriority.PRI_AFTERMODIFY):(ElementMarkPriority.PRI_BEFOREMODIFY), + true); + + m_xSAXEventKeeper.setSecurityId(referenceId, m_nSecurityId); + + XReferenceResolvedBroadcaster xReferenceResolvedBroadcaster = + (XReferenceResolvedBroadcaster)UnoRuntime.queryInterface( + XReferenceResolvedBroadcaster.class, m_xSAXEventKeeper); + xReferenceResolvedBroadcaster.addReferenceResolvedListener( + referenceId, m_xReferenceResolvedListener); + + try + { + XReferenceCollector xReferenceCollector = + (XReferenceCollector)UnoRuntime.queryInterface( + XReferenceCollector.class, m_xReferenceResolvedListener); + xReferenceCollector.setReferenceId(referenceId); + } + catch( com.sun.star.uno.Exception e) + { + e.printStackTrace(); + rc = false; + } + + return rc; + } +} + diff --git a/xmlsecurity/tools/uno/ParsingThread.java b/xmlsecurity/tools/uno/ParsingThread.java new file mode 100644 index 000000000000..699e7287a03e --- /dev/null +++ b/xmlsecurity/tools/uno/ParsingThread.java @@ -0,0 +1,282 @@ +/************************************************************************* + * + * $RCSfile: ParsingThread.java,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:24 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +package com.sun.star.xml.security.uno; + +import org.w3c.dom.Node; +import com.sun.star.xml.sax.XDocumentHandler; +import org.w3c.dom.Attr; +import org.w3c.dom.NamedNodeMap; + +/* + * this class is used to parse a document into SAX events + */ +class ParsingThread +{ + /* + * the Node which will be handled with in the next step + */ + private Node m_node; + + /* + * the event to be handled in the next step. + * true means endElement event, false otherwise. + */ + private boolean m_bIsEndEvent; + + /* + * the document handler which receives generated SAX events + */ + private XDocumentHandler m_xDocumentHandler; + + /* + * the TestTool which receives UI feedbacks + */ + private TestTool m_testTool; + + + ParsingThread(Node node, XDocumentHandler xDocumentHandler, TestTool testTool) + { + m_node = node; + m_xDocumentHandler = xDocumentHandler; + m_testTool = testTool; + + m_bIsEndEvent = false; + } + + /* + * changes the document handler. + */ + protected void setHandler(XDocumentHandler xDocumentHandler) + { + this.m_xDocumentHandler = xDocumentHandler; + } + + /* + * sends the next SAX event. + * when there is no further step, then false is returned, + * otherwise, true returned. + */ + protected boolean nextStep() + { + boolean rc = true; + + try + { + String message; + int type = m_node.getNodeType(); + if (!m_bIsEndEvent) + /* + * the next event is not a endElement event. + */ + { + switch (type) + { + case Node.DOCUMENT_NODE: /* startDocument */ + m_testTool.updatesCurrentSAXEventInformation("startDocument"); + m_xDocumentHandler.startDocument(); + m_testTool.updatesUIs(); + break; + case Node.ELEMENT_NODE: /* startElement */ + String nodeName = m_node.getNodeName(); + message = "startElement:"+nodeName; + NamedNodeMap attrs = m_node.getAttributes(); + + AttributeListHelper attributeListHelper = new AttributeListHelper(); + + int length = attrs.getLength(); + for (int i=0; i "+m_currentElement.toString()); + } + + if (m_testTool != null) + { + m_testTool.updatesUIs(); + } + } + + public void characters(String str) + { + Text newText = m_document.createTextNode(str); + m_currentElement.appendChild(newText); + if (m_testTool != null) + { + m_testTool.updatesUIs(); + } + } + + public void ignorableWhitespace(String str) + { + } + + public void processingInstruction(String aTarget, String aData) + { + ProcessingInstruction newPI + = m_document.createProcessingInstruction(aTarget, aData); + m_currentElement.appendChild(newPI); + if (m_testTool != null) + { + m_testTool.updatesUIs(); + } + } + + public void setDocumentLocator (com.sun.star.xml.sax.XLocator xLocator ) + throws com.sun.star.xml.sax.SAXException + { + } +} + diff --git a/xmlsecurity/tools/uno/SAXEventPrinter.java b/xmlsecurity/tools/uno/SAXEventPrinter.java new file mode 100644 index 000000000000..6a683b945774 --- /dev/null +++ b/xmlsecurity/tools/uno/SAXEventPrinter.java @@ -0,0 +1,354 @@ +/************************************************************************* + * + * $RCSfile: SAXEventPrinter.java,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:24 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +package com.sun.star.xml.security.uno; + +import org.w3c.dom.Node; +import org.w3c.dom.NamedNodeMap; +import org.w3c.dom.Attr; +import org.w3c.dom.NodeList; +import java.io.IOException; +import java.io.FileOutputStream; + +/* uno classes */ +import com.sun.star.xml.sax.XDocumentHandler; +import com.sun.star.xml.sax.XAttributeList; + +/* + * The SAXEventPrinter class is used to print out received + * SAX event stream. + */ +class SAXEventPrinter implements XDocumentHandler +{ + /* + * how many spaces as the indent of line + */ + private int m_nIndent; + + /* + * whether a NEW LINE character need to be appended to + * each line + */ + private boolean m_bIsFormatted; + + /* + * the output stream to write + */ + private FileOutputStream m_fileOutputStream; + + SAXEventPrinter(FileOutputStream fileOutputStream, boolean isFormatted) + { + m_nIndent = 0; + m_fileOutputStream = fileOutputStream; + m_bIsFormatted = isFormatted; + } + + protected static void outputIndent(int m_nIndent, FileOutputStream fileOutputStream) + throws IOException + { + for (int i=0; i".getBytes()); + + if (isFormatted) + { + fileOutputStream.write("\n".getBytes()); + } + + break; + + case Node.TEXT_NODE: + message = node.getNodeValue(); + if (message != null ) + { + if (isFormatted) + { + outputIndent(indent, fileOutputStream); + } + + fileOutputStream.write(node.getNodeValue().getBytes("UTF-8")); + + if (isFormatted) + { + fileOutputStream.write("\n".getBytes()); + } + } + break; + + case Node.PROCESSING_INSTRUCTION_NODE: + if (isFormatted) + { + outputIndent(indent, fileOutputStream); + } + + fileOutputStream.write("".getBytes()); + + if (isFormatted) + { + fileOutputStream.write("\n".getBytes()); + } + + break; + default: + break; + } + } + } + + /* + * XDocumentHandler + */ + public void startDocument () + { + } + + public void endDocument() + { + } + + public void startElement (String str, com.sun.star.xml.sax.XAttributeList xattribs) + { + try + { + String message; + + message = new String("<"+str); + if (xattribs !=null) + { + int length = xattribs.getLength(); + for (short i=0; i".getBytes()); + + if (m_bIsFormatted) + { + m_fileOutputStream.write("\n".getBytes()); + } + } + catch (IOException e) + { + e.printStackTrace(); + } + } + + public void characters(String str) + { + try + { + if (m_bIsFormatted) + { + outputIndent(m_nIndent, m_fileOutputStream); + } + + m_fileOutputStream.write(str.getBytes("UTF-8")); + + if (m_bIsFormatted) + { + m_fileOutputStream.write("\n".getBytes()); + } + } + catch (IOException e) + { + e.printStackTrace(); + } + } + + public void ignorableWhitespace(String str) + { + } + + public void processingInstruction(String aTarget, String aData) + { + try + { + if (m_bIsFormatted) + { + outputIndent(m_nIndent, m_fileOutputStream); + } + + m_fileOutputStream.write("".getBytes()); + + if (m_bIsFormatted) + { + m_fileOutputStream.write("\n".getBytes()); + } + } + catch (IOException e) + { + e.printStackTrace(); + } + } + + public void setDocumentLocator (com.sun.star.xml.sax.XLocator xLocator ) + throws com.sun.star.xml.sax.SAXException + { + } +} diff --git a/xmlsecurity/tools/uno/SecurityEntity.java b/xmlsecurity/tools/uno/SecurityEntity.java new file mode 100644 index 000000000000..f813b10cc87f --- /dev/null +++ b/xmlsecurity/tools/uno/SecurityEntity.java @@ -0,0 +1,236 @@ +/************************************************************************* + * + * $RCSfile: SecurityEntity.java,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:24 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +package com.sun.star.xml.security.uno; + +/* uno classes */ +import com.sun.star.uno.UnoRuntime; +import com.sun.star.lang.XMultiComponentFactory; +import com.sun.star.uno.XComponentContext; + +import com.sun.star.xml.crypto.*; +import com.sun.star.xml.crypto.sax.*; + +/* + * this class maintains the data for a security operation. + */ +class SecurityEntity +{ + /* + * the security id, which identifies this security entity + * uniquely. + */ + private static int m_nNextSecurityId = 1; + protected int m_nSecurityId; + + /* + * xml security related components + */ + protected XXMLSecurityContext m_xXMLSecurityContext; + protected XXMLSignature m_xXMLSignature; + protected XXMLEncryption m_xXMLEncryption; + protected XMultiComponentFactory m_xRemoteServiceManager; + protected XComponentContext m_xRemoteContext; + protected XReferenceResolvedListener m_xReferenceResolvedListener; + protected XSecuritySAXEventKeeper m_xSAXEventKeeper; + + /* + * the uri of the key material of this security entity + */ + private String m_keyURI; + + SecurityEntity( + XSecuritySAXEventKeeper xSAXEventKeeper, + XXMLSecurityContext xXMLSecurityContext, + XXMLSignature xXMLSignature, + XXMLEncryption xXMLEncryption, + XMultiComponentFactory xRemoteServiceManager, + XComponentContext xRemoteContext) + { + m_xSAXEventKeeper = xSAXEventKeeper; + m_xXMLSecurityContext = xXMLSecurityContext; + m_xXMLSignature = xXMLSignature; + m_xXMLEncryption = xXMLEncryption; + m_xRemoteServiceManager = xRemoteServiceManager; + m_xRemoteContext = xRemoteContext; + + m_nSecurityId = getNextSecurityId(); + m_keyURI = null; + } + +/************************************************************************************** + * private methods + **************************************************************************************/ + + /* + * generates a new security id. + */ + private static int getNextSecurityId() + { + int id = m_nNextSecurityId++; + return id; + } + +/************************************************************************************** + * protected methods + **************************************************************************************/ + + /* + * notifies the key collector about the key id, this key id + * is used to ask the SAXEventKeeper to release the bufferred + * key element. + * when the id is 0, that means there is no independant key + * element needed. + */ + protected void setKeyId(int id) + { + try + { + XKeyCollector xKeyCollector = + (XKeyCollector)UnoRuntime.queryInterface( + XKeyCollector.class, m_xReferenceResolvedListener); + xKeyCollector.setKeyId(id); + } + catch( com.sun.star.uno.Exception e) + { + e.printStackTrace(); + } + } + + /* + * set the key uri, which will be the value of the id attribute + * of the key element + */ + protected void setKeyURI(String uri) + { + m_keyURI = new String(uri); + } + + protected XReferenceResolvedListener getReferenceListener() + { + return m_xReferenceResolvedListener; + } + + protected int getSecurityId() + { + return m_nSecurityId; + } + + /* + * configures the key material to the security entity. + * + * if the uri is the key, then: + * 1. askes the SAXEventKeeper to add a ElementCollector to the key + * element; + * 2. notifies the key collector; + * 3. configures this ElementCollector's security id; + * 4. tells the SAXEventKeeper which listener will receive the reference + * resolved notification. + */ + protected boolean setKey(String uri, boolean isExporting) + { + boolean rc = false; + + if (m_keyURI != null && + m_keyURI.equals(uri)) + { + int referenceId = m_xSAXEventKeeper.addSecurityElementCollector( + isExporting? + (ElementMarkPriority.PRI_BEFOREMODIFY):(ElementMarkPriority.PRI_AFTERMODIFY), + false ); + + setKeyId(referenceId); + m_xSAXEventKeeper.setSecurityId(referenceId, m_nSecurityId); + + XReferenceResolvedBroadcaster xReferenceResolvedBroadcaster = + (XReferenceResolvedBroadcaster)UnoRuntime.queryInterface( + XReferenceResolvedBroadcaster.class, m_xSAXEventKeeper); + + xReferenceResolvedBroadcaster.addReferenceResolvedListener(referenceId, m_xReferenceResolvedListener); + + rc = true; + } + + return rc; + } + + /* + * ends this misstion, asks the security engine to clear up all + * resources. + */ + protected boolean endMission() + { + XMissionTaker xMissionTaker = + (XMissionTaker)UnoRuntime.queryInterface( + XMissionTaker.class, m_xReferenceResolvedListener); + + boolean rc = xMissionTaker.endMission(); + + m_xXMLSecurityContext = null; + m_xXMLSignature = null; + m_xXMLEncryption = null; + m_xReferenceResolvedListener = null; + m_xSAXEventKeeper = null; + + return rc; + } +} + diff --git a/xmlsecurity/tools/uno/SignatureEntity.java b/xmlsecurity/tools/uno/SignatureEntity.java new file mode 100644 index 000000000000..613d38bfd7dd --- /dev/null +++ b/xmlsecurity/tools/uno/SignatureEntity.java @@ -0,0 +1,322 @@ +/************************************************************************* + * + * $RCSfile: SignatureEntity.java,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:24 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +package com.sun.star.xml.security.uno; + +import java.util.Vector; + +/* uno classes */ +import com.sun.star.uno.UnoRuntime; +import com.sun.star.lang.XMultiComponentFactory; +import com.sun.star.lang.XInitialization; +import com.sun.star.uno.XComponentContext; + +import com.sun.star.xml.crypto.*; +import com.sun.star.xml.crypto.sax.*; + +/* + * this class maintains the data for a signature operation. + */ +class SignatureEntity extends SecurityEntity +{ + private Vector m_vReferenceIds; + private int m_nSignatureElementCollectorId; + + SignatureEntity( + XSecuritySAXEventKeeper xSAXEventKeeper, + boolean isExporting, + Object resultListener, + XXMLSecurityContext xXMLSecurityContext, + XXMLSignature xXMLSignature, + XXMLEncryption xXMLEncryption, + XMultiComponentFactory xRemoteServiceManager, + XComponentContext xRemoteContext) + { + super(xSAXEventKeeper, xXMLSecurityContext, xXMLSignature, + xXMLEncryption, xRemoteServiceManager, xRemoteContext); + + m_vReferenceIds = new Vector(); + + if (isExporting) + { + m_nSignatureElementCollectorId = m_xSAXEventKeeper.addSecurityElementCollector( + ElementMarkPriority.PRI_AFTERMODIFY, + true); + + m_xSAXEventKeeper.setSecurityId(m_nSignatureElementCollectorId, m_nSecurityId); + + try + { + /* + * creates a SignatureCreator. + */ + Object signatureCreator = m_xRemoteServiceManager.createInstanceWithContext( + TestTool.SIGNATURECREATOR_COMPONENT, m_xRemoteContext); + + m_xReferenceResolvedListener = + (XReferenceResolvedListener)UnoRuntime.queryInterface( + XReferenceResolvedListener.class, signatureCreator); + + /* + * initializes the SignatureCreator. + */ + XInitialization xInitialization = + (XInitialization)UnoRuntime.queryInterface( + XInitialization.class, m_xReferenceResolvedListener); + + Object args[]=new Object[5]; + args[0] = new Integer(m_nSecurityId).toString(); + args[1] = m_xSAXEventKeeper; + args[2] = new Integer(m_nSignatureElementCollectorId).toString(); + args[3] = m_xXMLSecurityContext; + args[4] = m_xXMLSignature; + xInitialization.initialize(args); + + /* + * creates a Blocker. + */ + int blockerId = m_xSAXEventKeeper.addBlocker(); + m_xSAXEventKeeper.setSecurityId(blockerId, m_nSecurityId); + + XBlockerMonitor xBlockerMonitor = (XBlockerMonitor)UnoRuntime.queryInterface( + XBlockerMonitor.class, m_xReferenceResolvedListener); + xBlockerMonitor.setBlockerId(blockerId); + + /* + * sets signature creation result listener. + */ + XSignatureCreationResultBroadcaster xSignatureCreationResultBroadcaster = + (XSignatureCreationResultBroadcaster)UnoRuntime.queryInterface( + XSignatureCreationResultBroadcaster.class, m_xReferenceResolvedListener); + xSignatureCreationResultBroadcaster.addSignatureCreationResultListener( + (XSignatureCreationResultListener)UnoRuntime.queryInterface( + XSignatureCreationResultListener.class, resultListener)); + } + catch( com.sun.star.uno.Exception e) + { + e.printStackTrace(); + } + + } + else + { + m_nSignatureElementCollectorId = m_xSAXEventKeeper.addSecurityElementCollector( + ElementMarkPriority.PRI_BEFOREMODIFY, false); + + m_xSAXEventKeeper.setSecurityId(m_nSignatureElementCollectorId, m_nSecurityId); + + try + { + /* + * creates a SignatureVerifier. + */ + Object signatureVerifier = m_xRemoteServiceManager.createInstanceWithContext( + TestTool.SIGNATUREVERIFIER_COMPONENT, m_xRemoteContext); + + m_xReferenceResolvedListener = + (XReferenceResolvedListener)UnoRuntime.queryInterface( + XReferenceResolvedListener.class, signatureVerifier); + + /* + * initializes the SignatureVerifier. + */ + XInitialization xInitialization = + (XInitialization)UnoRuntime.queryInterface( + XInitialization.class, m_xReferenceResolvedListener); + Object args[]=new Object[5]; + args[0] = new Integer(m_nSecurityId).toString(); + args[1] = m_xSAXEventKeeper; + args[2] = new Integer(m_nSignatureElementCollectorId).toString(); + args[3] = m_xXMLSecurityContext; + args[4] = m_xXMLSignature; + xInitialization.initialize(args); + + /* + * sets signature verify result listener. + */ + XSignatureVerifyResultBroadcaster xSignatureVerifyResultBroadcaster = + (XSignatureVerifyResultBroadcaster)UnoRuntime.queryInterface( + XSignatureVerifyResultBroadcaster.class, m_xReferenceResolvedListener); + xSignatureVerifyResultBroadcaster.addSignatureVerifyResultListener( + (XSignatureVerifyResultListener)UnoRuntime.queryInterface( + XSignatureVerifyResultListener.class, resultListener)); + } + catch( com.sun.star.uno.Exception e) + { + e.printStackTrace(); + } + } + + /* + * configures the resolve listener for the signature template. + */ + XReferenceResolvedBroadcaster xReferenceResolvedBroadcaster = + (XReferenceResolvedBroadcaster)UnoRuntime.queryInterface( + XReferenceResolvedBroadcaster.class, m_xSAXEventKeeper); + xReferenceResolvedBroadcaster.addReferenceResolvedListener( + m_nSignatureElementCollectorId, m_xReferenceResolvedListener); + } + +/************************************************************************************** + * private methods + **************************************************************************************/ + + /* + * checks whether this signature has a reference with + * the particular id. + */ + private boolean hasReference(String id) + { + boolean rc = false; + + int length = m_vReferenceIds.size(); + for (int i=0; i= 3) + { + if (argv[2].startsWith("-b")) + { + fileName = argv[2].substring(2); + hasBatch = true; + } + else + { + fileName = argv[2]; + hasFile = true; + } + } + + tt = new TestTool(); + tt.m_javaTokenFile = new String(argv[0]); + tt.m_nssTokenPath = new String(argv[1]); + tt.connectSO(null); + + /* Set up a GUI framework */ + JFrame myFrame = new JFrame("XML Security Components Tester"); + myFrame.addWindowListener( + new WindowAdapter() { + public void windowClosing(WindowEvent e) {System.exit(0);} + } + ); + + myFrame.setContentPane(tt.buildUI(screenSize.width, screenSize.height)); + myFrame.pack(); + int w = screenSize.width-30; + int h = screenSize.height-30; + myFrame.setLocation(screenSize.width/2 - w/2, + screenSize.height/2 - h/2); + myFrame.setSize(w, h); + myFrame.setVisible(true); + + if (hasFile) + { + tt.parseFile(new File(fileName)); + } + else if (hasBatch) + { + tt.runBatch(new File(fileName)); + } + } +} + diff --git a/xmlsecurity/tools/uno/UnsolvedReferenceTableModel.java b/xmlsecurity/tools/uno/UnsolvedReferenceTableModel.java new file mode 100644 index 000000000000..26892ecde553 --- /dev/null +++ b/xmlsecurity/tools/uno/UnsolvedReferenceTableModel.java @@ -0,0 +1,123 @@ +/************************************************************************* + * + * $RCSfile: UnsolvedReferenceTableModel.java,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:24 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +package com.sun.star.xml.security.uno; + +import javax.swing.table.AbstractTableModel; + +/* + * this class is used to maintain the unsolved reference + * table. + */ +class UnsolvedReferenceTableModel extends AbstractTableModel +{ + private String[] m_columnNames = {"id", + "refNum", + "EC's id"}; + + private TestTool m_testTool; + + UnsolvedReferenceTableModel(TestTool testTool) + { + m_testTool = testTool; + } + + public String getColumnName(int col) + { + return m_columnNames[col].toString(); + } + + public int getRowCount() + { + return m_testTool.getUnsolvedReferenceIds().size(); + } + + public int getColumnCount() + { + return m_columnNames.length; + } + + public Object getValueAt(int row, int col) + { + if (col == 0) + { + return (String)m_testTool.getUnsolvedReferenceIds().elementAt(row); + } + else if (col == 1) + { + return ((Integer)m_testTool.getUnsolvedReferenceRefNum().elementAt(row)).toString(); + } + else if (col == 2) + { + return ((Integer)m_testTool.getUnsolvedReferenceKeeperIds().elementAt(row)).toString(); + } + else + { + return null; + } + } + + public boolean isCellEditable(int row, int col) + { + return false; + } +} + diff --git a/xmlsecurity/tools/uno/XMLFileFilter.java b/xmlsecurity/tools/uno/XMLFileFilter.java new file mode 100644 index 000000000000..f492af6c9af0 --- /dev/null +++ b/xmlsecurity/tools/uno/XMLFileFilter.java @@ -0,0 +1,113 @@ +/************************************************************************* + * + * $RCSfile: XMLFileFilter.java,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:24 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +package com.sun.star.xml.security.uno; + +import java.io.File; +import javax.swing.filechooser.FileFilter; + +/* + * this class is used as a file filter for the XML file + * (*.xml) and the batch file (*.txt). + */ +class XMLFileFilter extends FileFilter +{ + public static String getExtension(File f) + { + String ext = null; + String s = f.getName(); + int i = s.lastIndexOf('.'); + + if (i > 0 && i < s.length() - 1) { + ext = s.substring(i+1).toLowerCase(); + } + + return ext; + } + + public boolean accept(File f) + { + boolean rc = false; + + if (f.isDirectory()) + { + rc = true; + } + else + { + String extension = getExtension(f); + if (extension != null) + { + if (extension.equals("xml") || extension.equals("txt")) + { + rc = true; + } + } + } + + return rc; + } + + public String getDescription() + { + return "XML and batch files (.xml,.txt)"; + } +} diff --git a/xmlsecurity/tools/uno/XMLSecurityFrameworkController.java b/xmlsecurity/tools/uno/XMLSecurityFrameworkController.java new file mode 100644 index 000000000000..f9014ae305ed --- /dev/null +++ b/xmlsecurity/tools/uno/XMLSecurityFrameworkController.java @@ -0,0 +1,1119 @@ +/************************************************************************* + * + * $RCSfile: XMLSecurityFrameworkController.java,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:24 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +package com.sun.star.xml.security.uno; + +import java.util.Stack; +import java.util.Vector; + +/* uno classes */ +import com.sun.star.uno.UnoRuntime; +import com.sun.star.lang.XMultiComponentFactory; +import com.sun.star.lang.XInitialization; +import com.sun.star.uno.XComponentContext; +import com.sun.star.xml.sax.XDocumentHandler; +import com.sun.star.xml.sax.XAttributeList; +import com.sun.star.xml.sax.SAXException; + +import com.sun.star.xml.crypto.*; +import com.sun.star.xml.crypto.sax.*; +import com.sun.star.xml.wrapper.*; + +/* + * the XMLSecurityFrameworkController class is used to controll the xml security framework. + */ +public class XMLSecurityFrameworkController + implements XDocumentHandler, XSignatureCreationResultListener, XSignatureVerifyResultListener, + XEncryptionResultListener, XDecryptionResultListener, XSAXEventKeeperStatusChangeListener +{ + /* + * UNO framework component + */ + private XMultiComponentFactory m_xRemoteServiceManager; + private XComponentContext m_xRemoteContext; + + /* + * xml security related UNO components + */ + private XSecuritySAXEventKeeper m_xSAXEventKeeper; + private XXMLDocumentWrapper m_xXMLDocumentWrapper; + private XDocumentHandler m_xOutputHandler; + private XXMLSecurityContext m_xXMLSecurityContext; + private XXMLSignature m_xXMLSignature; + private XXMLEncryption m_xXMLEncryption; + + /* + * used to reserve the current SAX ancestor path + */ + private Stack m_currentPath; + + /* + * maintains all SignatureEntities. + */ + private Vector m_signatureList; + + /* + * maintains all EncryptionEntities. + */ + private Vector m_encryptionList; + + /* + * maintains all unsolved reference Ids. + * These ids are strings which is the value of the id attribute + * of the referenced element. + */ + private Vector m_vUnsolvedReferenceIds; + + /* + * maintains all unsolved reference keeper ids. + * The keeper id is used to uniquely identify a bufferred element + * by the SAXEventKeeper. + */ + private Vector m_vUnsolvedReferencedKeeperIds; + + /* + * maintains the left time that each unsolved reference can be + * claimed. + */ + private Vector m_vUnsolvedReferenceRefNum; + + /* + * whether exporting or importing + */ + private boolean m_bIsExporting; + + /* + * whether java or c + */ + private boolean m_bIsJavaBased; + + /* + * whether the SAXEventKeeper is blocking + */ + private boolean m_bIsBlocking; + + /* + * whether it is collecting a bufferred element + */ + private boolean m_bIsInsideCollectedElement; + + /* + * whether a SAXEventKeeper is in the SAX chain + */ + private boolean m_bSAXEventKeeperIncluded; + + /* + * the ParsingThread used to parse the document + */ + private ParsingThread m_parsingThread; + + /* + * the next document handler that will receives SAX events + * from the parsing thread. + * if the SAXEventKeeper is on the SAX chain, then this + * variable will be the SAXEventKeeper, otherwise, this + * variable will be the xOutputHandler. + */ + private XDocumentHandler m_xExportHandler; + + /* + * the TestTool used to feedback information + */ + private TestTool m_testTool; + + /* + * for encryption target + */ + private boolean m_bIsEncryptionTarget; + private EncryptionEntity m_EncryptionForTarget; + + XMLSecurityFrameworkController( + TestTool testTool, + boolean bIsExporting, + boolean bIsJavaBased, + XDocumentHandler xOutputHandler, + ParsingThread parsingThread, + XXMLSecurityContext xXMLSecurityContext, + XXMLSignature xXMLSignature, + XXMLEncryption xXMLEncryption, + XMultiComponentFactory xRemoteServiceManager, + XComponentContext xRemoteContext) + { + m_bIsExporting = bIsExporting; + m_bIsJavaBased = bIsJavaBased; + + m_xOutputHandler = xOutputHandler; + m_xXMLSecurityContext = xXMLSecurityContext; + m_xXMLSignature = xXMLSignature; + m_xXMLEncryption = xXMLEncryption; + m_xRemoteServiceManager = xRemoteServiceManager; + m_xRemoteContext = xRemoteContext; + + m_testTool = testTool; + m_parsingThread = parsingThread; + + m_signatureList = new Vector(); + m_encryptionList = new Vector(); + + m_vUnsolvedReferenceIds = new Vector(); + m_vUnsolvedReferencedKeeperIds = new Vector(); + m_vUnsolvedReferenceRefNum = new Vector(); + + m_xXMLDocumentWrapper = null; + m_xSAXEventKeeper = null; + + m_bSAXEventKeeperIncluded = false; + m_bIsBlocking = false; + m_bIsInsideCollectedElement = false; + + m_bIsEncryptionTarget = false; + m_EncryptionForTarget = null; + + changeOutput(); + + m_currentPath = new Stack(); + + foundSecurityRelated(); + } + +/************************************************************************************** + * private methods + **************************************************************************************/ + + /* + * changes the output document handler. + */ + private void changeOutput() + { + if (m_bIsExporting) + { + m_parsingThread.setHandler(this); + + /* + * If the SAXEventKeeper is in the SAX chain, then redirects output + * to the SAXEventKeeper, otherwise, to the m_xOutputHandler + */ + if (m_bSAXEventKeeperIncluded) + { + m_xExportHandler = (XDocumentHandler)UnoRuntime.queryInterface( + XDocumentHandler.class, m_xSAXEventKeeper); + m_xSAXEventKeeper.setNextHandler(m_xOutputHandler); + + m_testTool.updatesSAXChainInformation("XMLExporter -> SAXEventKeeper -> SAXWriter"); + } + else + { + m_xExportHandler = m_xOutputHandler; + m_testTool.updatesSAXChainInformation("XMLExporter -> SAXWriter"); + } + } + else + { + if (m_bSAXEventKeeperIncluded) + { + m_parsingThread.setHandler( + (XDocumentHandler)UnoRuntime.queryInterface(XDocumentHandler.class, m_xSAXEventKeeper)); + m_xSAXEventKeeper.setNextHandler(this); + m_testTool.updatesSAXChainInformation("SAXParser -> SAXEventKeeper -> XMLImporter"); + } + else + { + m_parsingThread.setHandler(this); + m_testTool.updatesSAXChainInformation("SAXParser -> XMLImporter"); + } + m_xExportHandler = m_xOutputHandler; + } + } + + /* + * handles the situation when a security related element is found. + * if the SAXEventKeeper is not initialized, then creates a + * SAXEventKeeper. + * the return value represents whether the SAXEventKeeper is newly + * created. + */ + private boolean foundSecurityRelated() + { + if (m_xSAXEventKeeper == null) + { + m_testTool.showMessage("Message from : "+ + (m_bIsExporting?"XMLExporter":"XMLImporter")+ + "\n\nA security related content found, a SAXEventKeeper is created.\n "); + + m_bIsBlocking = false; + m_bIsInsideCollectedElement = false; + + try + { + /* + * creates an XMLDocumentWrapper component. + */ + Object xmlDocumentObj = null; + + if (m_bIsJavaBased) + { + xmlDocumentObj = m_xRemoteServiceManager.createInstanceWithContext( + TestTool.XMLDOCUMENTWRAPPER_COMPONENT_JAVA, m_xRemoteContext); + } + else + { + xmlDocumentObj = m_xRemoteServiceManager.createInstanceWithContext( + TestTool.XMLDOCUMENTWRAPPER_COMPONENT_C, m_xRemoteContext); + } + + m_xXMLDocumentWrapper = (XXMLDocumentWrapper)UnoRuntime.queryInterface( + XXMLDocumentWrapper.class, xmlDocumentObj); + + /* + * creates a SAXEventKeeper component. + */ + Object saxEventKeeperObj = m_xRemoteServiceManager.createInstanceWithContext( + TestTool.SAXEVENTKEEPER_COMPONENT, m_xRemoteContext); + + m_xSAXEventKeeper = + (XSecuritySAXEventKeeper)UnoRuntime.queryInterface( + XSecuritySAXEventKeeper.class, saxEventKeeperObj); + + /* + * initializes the SAXEventKeeper component with the XMLDocumentWrapper component. + */ + XInitialization xInitialization = + (XInitialization)UnoRuntime.queryInterface( + XInitialization.class, m_xSAXEventKeeper); + Object args[]=new Object[1]; + args[0] = m_xXMLDocumentWrapper; + xInitialization.initialize(args); + } + catch( com.sun.star.uno.Exception e) + { + e.printStackTrace(); + } + + /* + * configures the SAXEventKeeper's status change listener. + */ + XSAXEventKeeperStatusChangeBroadcaster xSaxEventKeeperStatusChangeBroadcaster = + (XSAXEventKeeperStatusChangeBroadcaster)UnoRuntime.queryInterface( + XSAXEventKeeperStatusChangeBroadcaster.class, m_xSAXEventKeeper); + xSaxEventKeeperStatusChangeBroadcaster.addXSAXEventKeeperStatusChangeListener(this); + } + + boolean rc = !m_bSAXEventKeeperIncluded; + + /* + * changes the export document handler. + */ + m_bSAXEventKeeperIncluded=true; + changeOutput(); + + return rc; + } + + /* + * finds key element or referenced element for a signature. + */ + private void findKeyOrReference(SecurityEntity signatureEntity, String uriStr, boolean isFindingKey) + { + int i=0; + + while (i0) + { + signatureEntity.addReferenceId(uriStr); + findKeyOrReference(signatureEntity, uriStr, false); + } + } + } + } + m_currentPath.push(signedInfo); + } + m_currentPath.push(localName); + } + else if(localName.equals("KeyValue") || + localName.equals("KeyName") || + localName.equals("X509Data") || + localName.equals("EncryptedKey")) + { + if (!m_currentPath.empty()) + { + Object keyInfo = m_currentPath.pop(); + + if (!m_currentPath.empty()) + { + Object objSorE = m_currentPath.peek(); + + if ((objSorE instanceof SignatureEntity) && keyInfo.toString().equals("KeyInfo")) + /* + * this element is the key element of a signature. + */ + { + SignatureEntity signatureEntity = (SignatureEntity)objSorE; + signatureEntity.setKeyId(0); + } + else if ((objSorE instanceof EncryptionEntity) && keyInfo.toString().equals("KeyInfo")) + /* + * this element is the key element of an encryption. + */ + { + EncryptionEntity theEncryption = (EncryptionEntity)objSorE; + theEncryption.setKeyId(0); + } + } + m_currentPath.push(keyInfo); + } + + m_currentPath.push(localName); + } + else if(localName.equals("RetrievalMethod")) + { + if (!m_currentPath.empty()) + { + Object keyInfo = m_currentPath.pop(); + + if (!m_currentPath.empty()) + { + Object objSorE = m_currentPath.peek(); + + if ((objSorE instanceof SignatureEntity) && keyInfo.toString().equals("KeyInfo")) + /* + * this element is the RetrievalMethod element in a signature, + * which will include the key uri of this signature. + */ + { + String uriStr = xattribs.getValueByName("URI"); + SignatureEntity signatureEntity = (SignatureEntity)objSorE; + + if (uriStr != null && uriStr.length()>0) + { + signatureEntity.setKeyURI(uriStr); + findKeyOrReference(signatureEntity,uriStr, true); + } + } + else if ((objSorE instanceof EncryptionEntity) && keyInfo.toString().equals("KeyInfo")) + /* + * this element is the RetrievalMethod element in an encryption, + * which will include the key uri of this encryption. + */ + { + String uriStr = xattribs.getValueByName("URI"); + EncryptionEntity theEncryption = (EncryptionEntity)objSorE; + + if (uriStr != null && uriStr.length()>0) + { + theEncryption.setKeyURI(uriStr); + findKeyOrReference(theEncryption, uriStr, true); + } + } + } + m_currentPath.push(keyInfo); + } + m_currentPath.push(localName); + } + else if (localName.equals("EncryptedData")) /* || localName.equals("EncryptedKey")) */ + /* + * this element is an Encryption element. + */ + { + EncryptionEntity theEncryption = new EncryptionEntity( + m_xSAXEventKeeper, + m_bIsExporting, + this, + m_xXMLSecurityContext, + m_xXMLSignature, + m_xXMLEncryption, + m_xRemoteServiceManager, + m_xRemoteContext); + + m_encryptionList.add(theEncryption); + + if (m_bIsExporting) + { + m_currentPath.push(theEncryption); + } + else + { + String uriStr = xattribs.getValueByName("keyURI"); + if (uriStr != null && uriStr.length()>0) + { + theEncryption.setKeyURI(uriStr); + findKeyOrReference(theEncryption,uriStr, true); + } + else + { + theEncryption.setKeyId(0); + } + + rc = true; + } + } + else + /* + * not a security related element. + */ + { + m_currentPath.push(localName); + } + + return rc; + } + + /* + * checks whether a startElement event is referenced by any security entity. + */ + private void checkReference(String localName, com.sun.star.xml.sax.XAttributeList xattribs, String id) + { + String refNumStr = xattribs.getValueByName("refNum"); + + if ( m_bIsEncryptionTarget ) + { + m_EncryptionForTarget.setReference(m_bIsExporting); + m_bIsEncryptionTarget = false; + } + + if (id != null && id.length()>0 ) + /* + * only if this element has id attribute, then it can be referenced by + * a security entity. + */ + { + /* + * if this element has an "refNum" attribute, then the value will be + * the max referencing number on this element, otherwise, set the max + * referencing number to 999. + */ + int refNum = 999; + + if (refNumStr != null && refNumStr.length()>0 ) + { + refNum = new Integer(refNumStr).intValue(); + } + + int length; + + /* + * searches the signature list to check whether any sigture has + * reference on this element. + */ + length = m_signatureList.size(); + for (int i=0; i0) + { + int keeperId; + + if (localName.equals("EncryptedKey")) + { + keeperId = m_xSAXEventKeeper.addSecurityElementCollector( + m_bIsExporting? + (ElementMarkPriority.PRI_BEFOREMODIFY):(ElementMarkPriority.PRI_AFTERMODIFY), + true); + } + else + { + keeperId = m_xSAXEventKeeper.addSecurityElementCollector( + m_bIsExporting? + (ElementMarkPriority.PRI_AFTERMODIFY):(ElementMarkPriority.PRI_BEFOREMODIFY), + false); + } + + m_vUnsolvedReferenceIds.add(id); + m_vUnsolvedReferencedKeeperIds.add(new Integer(keeperId)); + m_vUnsolvedReferenceRefNum.add(new Integer(refNum)); + } + } + } + + /* + * configures the output handler. + */ + private void setOutputHandler(XDocumentHandler handler) + { + m_xOutputHandler = handler; + changeOutput(); + } + + +/************************************************************************************** + * protected methods + **************************************************************************************/ + + /* + * methods used to transfer unsolved reference information. + */ + protected Vector getUnsolvedReferenceIds() + { + return m_vUnsolvedReferenceIds; + } + + protected Vector getUnsolvedReferenceKeeperIds() + { + return m_vUnsolvedReferencedKeeperIds; + } + + protected Vector getUnsolvedReferenceRefNum() + { + return m_vUnsolvedReferenceRefNum; + } + + protected String getBufferNodeTreeInformation() + { + if (m_xSAXEventKeeper != null) + { + return m_xSAXEventKeeper.printBufferNodeTree(); + } + else + { + return null; + } + } + + protected void getDocument(XDocumentHandler handler) + { + if (m_xXMLDocumentWrapper != null) + { + try + { + m_xXMLDocumentWrapper.getTree(handler); + } + catch(SAXException e) + { + e.printStackTrace(); + } + } + } + + protected void endMission() + { + while (m_signatureList.size()>0 || m_encryptionList.size()>0) + { + if (m_signatureList.size()>0) + { + SignatureEntity signatureEntity = (SignatureEntity)m_signatureList.elementAt(0); + m_signatureList.remove(0); + signatureEntity.endMission(); + } + else if (m_encryptionList.size()>0) + { + EncryptionEntity theEncryption = (EncryptionEntity)m_encryptionList.elementAt(0); + m_encryptionList.remove(0); + theEncryption.endMission(); + } + } + + while (m_vUnsolvedReferenceIds.size()>0) + { + int keeperId = ((Integer)m_vUnsolvedReferencedKeeperIds.elementAt(0)).intValue(); + m_xSAXEventKeeper.removeElementCollector(keeperId); + m_vUnsolvedReferenceIds.remove(0); + m_vUnsolvedReferencedKeeperIds.remove(0); + m_vUnsolvedReferenceRefNum.remove(0); + } + + m_xSAXEventKeeper.setNextHandler(null); + + XSAXEventKeeperStatusChangeBroadcaster xSaxEventKeeperStatusChangeBroadcaster = + (XSAXEventKeeperStatusChangeBroadcaster)UnoRuntime.queryInterface( + XSAXEventKeeperStatusChangeBroadcaster.class, m_xSAXEventKeeper); + xSaxEventKeeperStatusChangeBroadcaster.addXSAXEventKeeperStatusChangeListener(null); + + m_xSAXEventKeeper = null; + m_xXMLDocumentWrapper = null; + m_xOutputHandler = null; + m_xXMLSecurityContext = null; + m_xXMLSignature = null; + m_xXMLEncryption = null; + + m_xExportHandler = null; + m_parsingThread.setHandler(null); + } + +/************************************************************************************** + * public methods + **************************************************************************************/ + + /* + * XDocumentHandler + */ + public void startDocument() + { + try{ + m_xExportHandler.startDocument(); + } + catch( com.sun.star.xml.sax.SAXException e) + { + e.printStackTrace(); + } + + } + + public void endDocument() + { + try{ + m_xExportHandler.endDocument(); + } + catch( com.sun.star.xml.sax.SAXException e) + { + e.printStackTrace(); + } + } + + public void startElement (String str, com.sun.star.xml.sax.XAttributeList xattribs) + { + try{ + String idAttr = xattribs.getValueByName("id"); + if (idAttr == null) + { + idAttr = xattribs.getValueByName("Id"); + } + + boolean hasIdAttr = (idAttr != null && idAttr.length()>0 ); + boolean needResend = false; + + if (hasIdAttr || + (str.equals("Signature")||str.equals("EncryptedData")))/* || str.equals("EncryptedKey"))) */ + { + if (foundSecurityRelated() && !m_bIsExporting) + { + needResend = true; + } + } + + boolean suppressToNext = checkSecurityElement(str, xattribs); + + checkReference(str, xattribs, idAttr); + + if (needResend) + { + m_xSAXEventKeeper.setNextHandler(null); + + XDocumentHandler saxEventKeeperHandler = + (XDocumentHandler)UnoRuntime.queryInterface( + XDocumentHandler.class, m_xSAXEventKeeper); + saxEventKeeperHandler.startElement(str, xattribs); + m_xSAXEventKeeper.setNextHandler((XDocumentHandler)this); + } + + if (!suppressToNext) + { + m_xExportHandler.startElement(str, xattribs); + } + } + catch( com.sun.star.xml.sax.SAXException e) + { + e.printStackTrace(); + } + } + + public void endElement(String str) + { + if (!m_currentPath.empty()) + { + Object obj = m_currentPath.pop(); + + if (obj.toString().equals("SignedInfo")) + { + if (!m_currentPath.empty()) + { + Object objSignature = m_currentPath.peek(); + if (objSignature != null && objSignature instanceof SignatureEntity) + { + ((SignatureEntity)objSignature).setReferenceNumber(); + } + } + } + else if (obj instanceof EncryptionEntity) + { + m_bIsEncryptionTarget = true; + m_EncryptionForTarget = (EncryptionEntity)obj; + + } + } + + try{ + m_xExportHandler.endElement(str); + } + catch( com.sun.star.xml.sax.SAXException e) + { + e.printStackTrace(); + } + } + + public void characters(String str) + { + try{ + m_xExportHandler.characters(str); + } + catch( com.sun.star.xml.sax.SAXException e) + { + e.printStackTrace(); + } + } + + public void ignorableWhitespace(String str) + { + } + + public void processingInstruction(String aTarget, String aData) + { + try{ + m_xExportHandler.processingInstruction(aTarget, aData); + } + catch( com.sun.star.xml.sax.SAXException e) + { + e.printStackTrace(); + } + } + + public void setDocumentLocator (com.sun.star.xml.sax.XLocator xLocator ) + throws com.sun.star.xml.sax.SAXException + { + } + + + /* + * XSignatureCreationResultListener + */ + public void signatureCreated(int securityId, SignatureCreationResult creationResult) + { + String message = new String(); + message += "A Signature is created:"; + message += "\nSecurity Id = "+securityId; + message += "\nCreation result = "+((creationResult==SignatureCreationResult.CREATIONSUCCEED)?"Succeed":"Fail"); + + m_testTool.showMessage("Message from : SignatureCreator\n\n"+message+"\n "); + } + + /* + * XSignatureVerifyResultListener + */ + public void signatureVerified(int securityId, SignatureVerifyResult verifyResult) + { + String message = new String(); + message += "A Signature is verified:"; + message += "\nSecurity Id = "+securityId; + message += "\nVerify result = "+((verifyResult==SignatureVerifyResult.VERIFYSUCCEED)?"Succeed":"Fail"); + + m_testTool.showMessage("Message from : SignatureVerifier\n\n"+message+"\n "); + } + + /* + * XEncryptionResultListener + */ + public void encrypted(int securityId, EncryptionResult encryptionResult) + { + String message = new String(); + message += "An EncryptedData is encrypted:"; + message += "\nSecurity Id = "+securityId; + message += "\nEncrypt result = "+((encryptionResult==EncryptionResult.ENCRYPTIONSUCCEED)?"Succeed":"Fail"); + + m_testTool.showMessage("Message from : Encryptor\n\n"+message+"\n "); + } + + /* + * XDecryptionResultListener methods + */ + public void decrypted(int securityId, DecryptionResult decryptionResult) + { + String message = new String(); + message += "An EncryptedData is decrypted:"; + message += "\nSecurity Id = "+securityId; + message += "\nDecrypt result = "+((decryptionResult==DecryptionResult.DECRYPTIONSUCCEED)?"Succeed":"Fail"); + + m_testTool.showMessage("Message from : Decryptor\n\n"+message+"\n "); + } + + /* + * XSAXEventKeeperStatusChangeListener methods + */ + public void blockingStatusChanged(boolean isBlocking) + { + m_testTool.showMessage("Message from : SAXEventKeeper\n\n"+ + (isBlocking?"The SAX event stream is blocked.":"The SAX event stream is unblocked.")+ + "\n "); + + this.m_bIsBlocking = isBlocking; + } + + public void collectionStatusChanged(boolean isInsideCollectedElement) + { + m_testTool.showMessage("Message from : SAXEventKeeper\n\n"+ + (isInsideCollectedElement?"Begin to buffer data ...":"End of data bufferring.")+ + "\n "); + + /* + this.m_bIsInsideCollectedElement = isInsideCollectedElement; + + if ( !m_bIsInsideCollectedElement && !m_bIsBlocking) + { + m_bSAXEventKeeperIncluded = false; + } + else + { + m_bSAXEventKeeperIncluded = true; + } + changeOutput(); + */ + } + + public void bufferStatusChanged(boolean isBufferEmpty) + { + m_testTool.showMessage("Message from : SAXEventKeeper\n\n"+ + (isBufferEmpty?"All bufferred data are released, the SAXEventKeeper is destroyed.":"buffer data appears.")+ + "\n "); + /* + if (isBufferEmpty) + { + m_xXMLDocumentWrapper = null; + m_xSAXEventKeeper = null; + m_bSAXEventKeeperIncluded = false; + changeOutput(); + } + */ + } +} + diff --git a/xmlsecurity/tools/uno/XMLTreeCellRanderer.java b/xmlsecurity/tools/uno/XMLTreeCellRanderer.java new file mode 100644 index 000000000000..2c88aad382de --- /dev/null +++ b/xmlsecurity/tools/uno/XMLTreeCellRanderer.java @@ -0,0 +1,119 @@ +/************************************************************************* + * + * $RCSfile: XMLTreeCellRanderer.java,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:24 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +package com.sun.star.xml.security.uno; + +import javax.swing.tree.DefaultTreeCellRenderer; +import org.w3c.dom.Node; +import javax.swing.ImageIcon; +import java.awt.Component; +import javax.swing.JTree; + +/* + * a TreeCellRender which can show a graph on the current + * tree node. + */ +class XMLTreeCellRanderer extends DefaultTreeCellRenderer +{ + /* + * the icon for the current Node + */ + private ImageIcon m_currentIcon; + + /* + * the current Node + */ + private Node m_currentNode; + + XMLTreeCellRanderer(Node currentNode) + { + m_currentNode = currentNode; + m_currentIcon = new ImageIcon("current.gif"); + } + + public Component getTreeCellRendererComponent( + JTree tree, + Object value, + boolean sel, + boolean expanded, + boolean leaf, + int row, + boolean hasFocus) + { + super.getTreeCellRendererComponent( + tree, value, sel, + expanded, leaf, row, + hasFocus); + + if (((AdapterNode)value).getNode() == m_currentNode) + { + setIcon(m_currentIcon); + setToolTipText("This is the current element."); + } + else + { + setToolTipText(null); /* no tool tip */ + } + + return this; + } +} + diff --git a/xmlsecurity/tools/uno/current.gif b/xmlsecurity/tools/uno/current.gif new file mode 100644 index 000000000000..92b2a025f05e Binary files /dev/null and b/xmlsecurity/tools/uno/current.gif differ diff --git a/xmlsecurity/tools/uno/makefile.mk b/xmlsecurity/tools/uno/makefile.mk new file mode 100644 index 000000000000..595a3ebc8bb6 --- /dev/null +++ b/xmlsecurity/tools/uno/makefile.mk @@ -0,0 +1,83 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1.1.1 $ +# +# last change: $Author: mt $ $Date: 2004-07-12 13:15:24 $ +# +# The Contents of this file are made available subject to the terms of +# either of the following licenses +# +# - GNU Lesser General Public License Version 2.1 +# - Sun Industry Standards Source License Version 1.1 +# +# Sun Microsystems Inc., October, 2000 +# +# GNU Lesser General Public License Version 2.1 +# ============================================= +# Copyright 2000 by Sun Microsystems, Inc. +# 901 San Antonio Road, Palo Alto, CA 94303, USA +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License version 2.1, as published by the Free Software Foundation. +# +# This library 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 for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, +# MA 02111-1307 USA +# +# +# Sun Industry Standards Source License Version 1.1 +# ================================================= +# The contents of this file are subject to the Sun Industry Standards +# Source License Version 1.1 (the "License"); You may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at http://www.openoffice.org/license.html. +# +# Software provided under this License is provided on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, +# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, +# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. +# See the License for the specific provisions governing your rights and +# obligations concerning the Software. +# +# The Initial Developer of the Original Code is: Sun Microsystems, Inc. +# +# Copyright: 2000 by Sun Microsystems, Inc. +# +# All Rights Reserved. +# +# Contributor(s): _______________________________________ +# +# +# +#************************************************************************* + +PRJNAME = xmlsecurity +TARGET = xmlsecurity-uno +PACKAGE = com$/sun$/star$/xml$/security$/uno +PRJ = ..$/.. + +USE_JAVAVER:=TRUE + +# --- Settings ----------------------------------------------------- + +.INCLUDE : settings.mk +.INCLUDE : $(PRJ)$/util$/target.pmk + +JARFILES = java_uno.jar sandbox.jar jurt.jar unoil.jar ridl.jar juh.jar +JAVAFILES := $(shell +ls *.java) +JAVACLASSFILES= $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class) + +# --- Targets ------------------------------------------------------ + + +.INCLUDE : target.mk + diff --git a/xmlsecurity/util/exports_xsmscrypt.dxp b/xmlsecurity/util/exports_xsmscrypt.dxp new file mode 100644 index 000000000000..208cad179969 --- /dev/null +++ b/xmlsecurity/util/exports_xsmscrypt.dxp @@ -0,0 +1,8 @@ +component_getImplementationEnvironment +component_writeInfo +component_getFactory +?numericStringToBigInteger@@YA?AV?$Sequence@C@uno@star@sun@com@@VOUString@rtl@@@Z +?bigIntegerToNumericString@@YA?AVOUString@rtl@@V?$Sequence@C@uno@star@sun@com@@@Z +?getUnoTunnelId@SecurityEnvironment_MSCryptImpl@@SAABV?$Sequence@C@uno@star@sun@com@@XZ +?setNativeElement@XMLElementWrapper_XmlSecImpl@@QAEXQAU_xmlNode@@@Z +?getUnoTunnelImplementationId@XMLElementWrapper_XmlSecImpl@@SA?AV?$Sequence@C@uno@star@sun@com@@XZ diff --git a/xmlsecurity/util/exports_xsnss.dxp b/xmlsecurity/util/exports_xsnss.dxp new file mode 100644 index 000000000000..0986808b267b --- /dev/null +++ b/xmlsecurity/util/exports_xsnss.dxp @@ -0,0 +1,8 @@ +component_getImplementationEnvironment +component_writeInfo +component_getFactory +?bigIntegerToNumericString@@YA?AVOUString@rtl@@V?$Sequence@C@uno@star@sun@com@@@Z +?numericStringToBigInteger@@YA?AV?$Sequence@C@uno@star@sun@com@@VOUString@rtl@@@Z +?getUnoTunnelId@SecurityEnvironment_NssImpl@@SAABV?$Sequence@C@uno@star@sun@com@@XZ +?setNativeElement@XMLElementWrapper_XmlSecImpl@@QAEXQAU_xmlNode@@@Z +?getUnoTunnelImplementationId@XMLElementWrapper_XmlSecImpl@@SA?AV?$Sequence@C@uno@star@sun@com@@XZ diff --git a/xmlsecurity/util/makefile.mk b/xmlsecurity/util/makefile.mk new file mode 100644 index 000000000000..c0e586f5abc6 --- /dev/null +++ b/xmlsecurity/util/makefile.mk @@ -0,0 +1,194 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1.1.1 $ +# +# last change: $Author: mt $ $Date: 2004-07-12 13:15:31 $ +# +# The Contents of this file are made available subject to the terms of +# either of the following licenses +# +# - GNU Lesser General Public License Version 2.1 +# - Sun Industry Standards Source License Version 1.1 +# +# Sun Microsystems Inc., October, 2000 +# +# GNU Lesser General Public License Version 2.1 +# ============================================= +# Copyright 2000 by Sun Microsystems, Inc. +# 901 San Antonio Road, Palo Alto, CA 94303, USA +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License version 2.1, as published by the Free Software Foundation. +# +# This library 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 for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, +# MA 02111-1307 USA +# +# +# Sun Industry Standards Source License Version 1.1 +# ================================================= +# The contents of this file are subject to the Sun Industry Standards +# Source License Version 1.1 (the "License"); You may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at http://www.openoffice.org/license.html. +# +# Software provided under this License is provided on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, +# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, +# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. +# See the License for the specific provisions governing your rights and +# obligations concerning the Software. +# +# The Initial Developer of the Original Code is: Sun Microsystems, Inc. +# +# Copyright: 2000 by Sun Microsystems, Inc. +# +# All Rights Reserved. +# +# Contributor(s): _______________________________________ +# +# +# +#************************************************************************* + +PRJ=.. + +PRJNAME=xmlsecurity +TARGET=xmlsecurity + +# --- Settings ----------------------------------------------------- + +.INCLUDE : settings.mk +.INCLUDE : $(PRJ)$/util$/target.pmk + + +# --- Allgemein ---------------------------------------------------- +NO_BSYMBOLIC=TRUE +ENABLE_EXCEPTIONS=TRUE + +# --- Files -------------------------------------------------------- + +BMP_IN=$(PRJ)$/res + +# --- Shared-Library ----------------------------------------------- + +# +# The 1st shared library +# +SHL1NAME=xsec_fw +SHL1TARGET= $(SHL1NAME) +SHL1LIBS= $(SLB)$/fw.lib + +SHL1STDLIBS += \ + $(SALLIB) \ + $(CPPULIB) \ + $(CPPUHELPERLIB) + +SHL1IMPLIB = $(SHL1TARGET) +SHL1DEF = $(MISC)$/$(SHL1TARGET).def +DEF1NAME = $(SHL1TARGET) +DEF1EXPORTFILE = xsec_fw.dxp + +# +# The 2nd shared library +# +SHL2NAME=xsec_xmlsec +SHL2TARGET= $(SHL2NAME) +SHL2LIBS= \ + $(SLB)$/xs_comm.lib + +.IF "$(CRYPTO_ENGINE)" == "mscrypto" +SHL2LIBS += \ + $(SLB)$/xs_mscrypt.lib +.ELSE +SHL2LIBS += \ + $(SLB)$/xs_nss.lib +.ENDIF + +SHL2STDLIBS += \ + $(SALLIB) \ + $(CPPULIB) \ + $(CPPUHELPERLIB) \ + $(SVLLIB) \ + $(TOOLSLIB) \ + $(COMPHELPERLIB) \ + $(CPPUHELPERLIB) \ + $(XMLOFFLIB) + +.IF "$(GUI)"=="WNT" +.IF "$(CRYPTO_ENGINE)" == "mscrypto" +SHL2STDLIBS+= "ixml2.lib" "xmlsec.lib" "xmlsec-mscrypto.lib" "crypt32.lib" "advapi32.lib" +.ELSE +SHL2STDLIBS+= "ixml2.lib" "nss3.lib" "nspr4.lib" "plc4.lib" "xmlsec.lib" "xmlsec-nss.lib" "xpcom.lib" +.ENDIF +.ELSE +SHL2STDLIBS+= "-lxml2" "-lnss3" "-lnspr4" "-lplc4" "-lxmlsec" "-lxmlsec-nss" "-lxpcom" +.ENDIF + +SHL2IMPLIB = $(SHL2TARGET) +SHL2DEF = $(MISC)$/$(SHL2TARGET).def +DEF2NAME = $(SHL2TARGET) +.IF "$(CRYPTO_ENGINE)" == "mscrypto" +DEF2EXPORTFILE = exports_xsmscrypt.dxp +.ELSE +DEF2EXPORTFILE = exports_xsnss.dxp +.ENDIF + +SRSFILELIST= \ + $(SRS)$/dialogs.srs + +RESLIB1NAME=xmlsec +RESLIB1SRSFILES= $(SRSFILELIST) + +SHL4TARGET=$(TARGET) +SHL4LIBS=\ + $(SLB)$/helper.lib \ + $(SLB)$/dialogs.lib \ + $(SLB)$/component.lib +SHL4STDLIBS=\ + $(CPPULIB) \ + $(CPPUHELPERLIB) \ + $(COMPHELPERLIB) \ + $(UCBHELPERLIB) \ + $(UNOTOOLSLIB) \ + $(VCLLIB) \ + $(TOOLSLIB) \ + $(SVTOOLLIB) \ + $(SALLIB) \ + $(VOSLIB) \ + $(SOTLIB) \ + $(SVLIB) \ + $(SFXLIB) \ + $(XMLOFFLIB) \ + $(SVXLIB) + +.IF "$(GUI)"=="WNT" +SHL4STDLIBS+= "xmlsec.lib" "xsec_xmlsec.lib" +.ELSE +SHL4STDLIBS+= "-lxml2" "-lnss3" "-lnspr4" "-lxmlsec" "-lxmlsec-nss" "-lhelper" "-ldialogs" "-lxsec_xmlsec" +.ENDIF + + +SHL4VERSIONMAP = xmlsecurity.map +SHL4DEPN= +SHL4IMPLIB=i$(TARGET) +SHL4DEF=$(MISC)$/$(SHL4TARGET).def +DEF4NAME=$(SHL4TARGET) + +# --- Targets ---------------------------------------------------------- + +.INCLUDE : target.mk + +# --- Filter ----------------------------------------------------------- + +$(MISC)$/$(SHL3TARGET).flt: makefile.mk + +$(TYPE) $(SHL3TARGET).flt > $@ diff --git a/xmlsecurity/util/target.pmk b/xmlsecurity/util/target.pmk new file mode 100644 index 000000000000..cd44f80fc067 --- /dev/null +++ b/xmlsecurity/util/target.pmk @@ -0,0 +1,68 @@ + +#************************************************************************* +# +# $RCSfile: target.pmk,v $ +# +# $Revision: 1.1.1.1 $ +# +# last change: $Author: mt $ $Date: 2004-07-12 13:15:31 $ +# +# The Contents of this file are made available subject to the terms of +# either of the following licenses +# +# - GNU Lesser General Public License Version 2.1 +# - Sun Industry Standards Source License Version 1.1 +# +# Sun Microsystems Inc., October, 2000 +# +# GNU Lesser General Public License Version 2.1 +# ============================================= +# Copyright 2000 by Sun Microsystems, Inc. +# 901 San Antonio Road, Palo Alto, CA 94303, USA +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License version 2.1, as published by the Free Software Foundation. +# +# This library 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 for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, +# MA 02111-1307 USA +# +# +# Sun Industry Standards Source License Version 1.1 +# ================================================= +# The contents of this file are subject to the Sun Industry Standards +# Source License Version 1.1 (the "License"); You may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at http://www.openoffice.org/license.html. +# +# Software provided under this License is provided on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, +# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, +# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. +# See the License for the specific provisions governing your rights and +# obligations concerning the Software. +# +# The Initial Developer of the Original Code is: Sun Microsystems, Inc. +# +# Copyright: 2000 by Sun Microsystems, Inc. +# +# All Rights Reserved. +# +# Contributor(s): _______________________________________ +# +# +# +#************************************************************************* +.IF "$(GUI)" == "WNT" +CRYPTO_ENGINE = mscrypto +#CRYPTO_ENGINE = nss +.ELSE +CRYPTO_ENGINE = nss +.ENDIF diff --git a/xmlsecurity/util/xmlsecurity.map b/xmlsecurity/util/xmlsecurity.map new file mode 100644 index 000000000000..ac2c3750bfe0 --- /dev/null +++ b/xmlsecurity/util/xmlsecurity.map @@ -0,0 +1,8 @@ +UDK_3_0_0 { + global: + component_getImplementationEnvironment; + component_writeInfo; + component_getFactory; + local: + *; +}; diff --git a/xmlsecurity/util/xsec_fw.dxp b/xmlsecurity/util/xsec_fw.dxp new file mode 100644 index 000000000000..9630d7e06768 --- /dev/null +++ b/xmlsecurity/util/xsec_fw.dxp @@ -0,0 +1,3 @@ +component_getImplementationEnvironment +component_writeInfo +component_getFactory diff --git a/xmlsecurity/util/xsecctl.flt b/xmlsecurity/util/xsecctl.flt new file mode 100644 index 000000000000..3e2aa3dba0b7 --- /dev/null +++ b/xmlsecurity/util/xsecctl.flt @@ -0,0 +1,19 @@ +_CT? +??_5 +??_7 +??_8 +??_9 +??_C +??_E +??_F +??_G +??_H +??_I +__CT +_CTA +sXML_ +lcl +_Impl +WEP +LIBMAIN +LibMain diff --git a/xmlsecurity/workben/makefile.mk b/xmlsecurity/workben/makefile.mk new file mode 100644 index 000000000000..9cdebf08a559 --- /dev/null +++ b/xmlsecurity/workben/makefile.mk @@ -0,0 +1,116 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1.1.1 $ +# +# last change: $Author: mt $ $Date: 2004-07-12 13:15:31 $ +# +# The Contents of this file are made available subject to the terms of +# either of the following licenses +# +# - GNU Lesser General Public License Version 2.1 +# - Sun Industry Standards Source License Version 1.1 +# +# Sun Microsystems Inc., October, 2000 +# +# GNU Lesser General Public License Version 2.1 +# ============================================= +# Copyright 2000 by Sun Microsystems, Inc. +# 901 San Antonio Road, Palo Alto, CA 94303, USA +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License version 2.1, as published by the Free Software Foundation. +# +# This library 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 for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, +# MA 02111-1307 USA +# +# +# Sun Industry Standards Source License Version 1.1 +# ================================================= +# The contents of this file are subject to the Sun Industry Standards +# Source License Version 1.1 (the "License"); You may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at http://www.openoffice.org/license.html. +# +# Software provided under this License is provided on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, +# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, +# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. +# See the License for the specific provisions governing your rights and +# obligations concerning the Software. +# +# The Initial Developer of the Original Code is: Sun Microsystems, Inc. +# +# Copyright: 2000 by Sun Microsystems, Inc. +# +# All Rights Reserved. +# +# Contributor(s): _______________________________________ +# +# +# +#************************************************************************* + +PRJ=.. + +PRJNAME=SV +TARGET=signaturetest +LIBTARGET=NO +TARGETTYPE=GUI + +# --- Settings ----------------------------------------------------- + +.INCLUDE : svpre.mk +.INCLUDE : settings.mk +.INCLUDE : sv.mk +.INCLUDE : $(PRJ)$/util$/target.pmk + + +# --- Files -------------------------------------------------------- + +OBJFILES= $(OBJ)$/signaturetest.obj $(OBJ)$/storagehelper.obj +EXCEPTIONSFILES=$(OBJ)$/signaturetest.obj $(OBJ)$/storagehelper.obj + +APP1NOSAL= TRUE +APP1TARGET= $(TARGET) +APP1OBJS= $(OBJFILES) + +APP1STDLIBS= $(CPPULIB) \ + $(CPPUHELPERLIB) \ + $(COMPHELPERLIB) \ + $(UCBHELPERLIB) \ + $(UNOTOOLSLIB) \ + $(VCLLIB) \ + $(TOOLSLIB) \ + $(SVTOOLLIB) \ + $(SALLIB) \ + $(VOSLIB) \ + $(SOTLIB) \ + $(SVLIB) \ + $(SFXLIB) \ + $(XMLOFFLIB) \ + $(SVXLIB) + +.IF "$(GUI)"=="WNT" +APP1STDLIBS+= "ixml2.lib" "nss3.lib" "nspr4.lib" "xmlsec.lib" "helper.lib" "dialogs.lib" "xsec_xmlsec.lib" +.ELSE +APP1STDLIBS+= "-lxml2" "-lnss3" "-lnspr4" "-lxmlsec" "-lhelper" "-ldialogs" "-lxsec_xmlsec" +.ENDIF + + +# --- Targets ------------------------------------------------------ + +ALL : ALLTAR + +.INCLUDE : target.mk + + \ No newline at end of file diff --git a/xmlsecurity/workben/signaturetest.cxx b/xmlsecurity/workben/signaturetest.cxx new file mode 100644 index 000000000000..2d5719cb4877 --- /dev/null +++ b/xmlsecurity/workben/signaturetest.cxx @@ -0,0 +1,543 @@ +/************************************************************************* + * + * $RCSfile: signaturetest.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: mt $ $Date: 2004-07-12 13:15:31 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include + +#include +#include + +// Will be in comphelper if CWS MAV09 is integrated +#include + +#include + +#include +#include +#include + +#include + + +using namespace ::com::sun::star; +using namespace ::com::sun::star; + +void Main(); + +#define TEXTFIELDWIDTH 80 +#define TEXTFIELDSTARTX 10 + +#define EDITWIDTH 200 +#define EDITHEIGHT 20 + +#define FIXEDLINEHEIGHT 15 + +#define BUTTONWIDTH 50 +#define BUTTONHEIGHT 22 +#define BUTTONSPACE 20 + +#define LISTBOXHEIGHT 120 + +bool bStoreSignatureInStorage = false; + + +// ----------------------------------------------------------------------- + + SAL_IMPLEMENT_MAIN() +{ + uno::Reference< lang::XMultiServiceFactory > xMSF; + try + { + uno::Reference< uno::XComponentContext > xCtx( cppu::defaultBootstrap_InitialComponentContext() ); + if ( !xCtx.is() ) + { + DBG_ERROR( "Error creating initial component context!" ); + return -1; + } + + xMSF = uno::Reference< lang::XMultiServiceFactory >(xCtx->getServiceManager(), uno::UNO_QUERY ); + + if ( !xMSF.is() ) + { + DBG_ERROR( "No service manager!" ); + return -1; + } + + // Init USB + uno::Sequence< uno::Any > aArgs( 2 ); + aArgs[ 0 ] <<= rtl::OUString::createFromAscii( UCB_CONFIGURATION_KEY1_LOCAL ); + aArgs[ 1 ] <<= rtl::OUString::createFromAscii( UCB_CONFIGURATION_KEY2_OFFICE ); + sal_Bool bSuccess = ::ucb::ContentBroker::initialize( xMSF, aArgs ); + if ( !bSuccess ) + { + DBG_ERROR( "Error creating UCB!" ); + return -1; + } + + } + catch ( uno::Exception const & ) + { + DBG_ERROR( "Exception during creation of initial component context!" ); + return -1; + } + comphelper::setProcessServiceFactory( xMSF ); + + InitVCL( xMSF ); + ::Main(); + DeInitVCL(); + + return 0; +} + +// ----------------------------------------------------------------------- + +class MyWin : public WorkWindow +{ +private: + FixedLine maTokenLine; + CheckBox maCryptoCheckBox; + FixedText maFixedTextTokenName; + FileControl maEditTokenName; + FixedLine maTest1Line; + FixedText maFixedTextXMLFileName; + FileControl maEditXMLFileName; + FixedText maFixedTextBINFileName; + FileControl maEditBINFileName; + FixedText maFixedTextSIGFileName; + FileControl maEditSIGFileName; + PushButton maSignButton; + PushButton maVerifyButton; + FixedLine maTest2Line; + FixedText maFixedTextDOCFileName; + FileControl maEditDOCFileName; + PushButton maDigitalSignaturesButton; + FixedLine maHintLine; + FixedText maHintText; + + DECL_LINK( CryptoCheckBoxHdl, CheckBox* ); + DECL_LINK( SignButtonHdl, Button* ); + DECL_LINK( VerifyButtonHdl, Button* ); + DECL_LINK( DigitalSignaturesWithServiceHdl, Button* ); + DECL_LINK( DigitalSignaturesWithTokenHdl, Button* ); + DECL_LINK( StartVerifySignatureHdl, void* ); + +public: + MyWin( Window* pParent, WinBits nWinStyle ); + +}; + +// ----------------------------------------------------------------------- + +void Main() +{ + MyWin aMainWin( NULL, WB_APP | WB_STDWORK | WB_3DLOOK); + aMainWin.Show(); + + Application::Execute(); +} + +// ----------------------------------------------------------------------- + +MyWin::MyWin( Window* pParent, WinBits nWinStyle ) : + WorkWindow( pParent, nWinStyle ), + maTokenLine( this ), + maTest1Line( this ), + maTest2Line( this ), + maHintLine( this ), + maFixedTextXMLFileName( this ), + maEditXMLFileName( this, WB_BORDER ), + maFixedTextBINFileName( this ), + maEditBINFileName( this, WB_BORDER ), + maFixedTextSIGFileName( this ), + maEditSIGFileName( this, WB_BORDER ), + maFixedTextTokenName( this ), + maEditTokenName( this, WB_BORDER ), + maFixedTextDOCFileName( this ), + maEditDOCFileName( this, WB_BORDER ), + maSignButton( this ), + maVerifyButton( this ), + maDigitalSignaturesButton( this ), + maHintText( this, WB_WORDBREAK ), + maCryptoCheckBox( this ) + +{ + Size aOutputSize( 400, 600 ); + SetOutputSizePixel( aOutputSize ); + SetText( String( RTL_CONSTASCII_USTRINGPARAM( "XML Signature Test" ) ) ); + + long nY = 15; + + maTokenLine.SetPosSizePixel( TEXTFIELDSTARTX, nY, aOutputSize.Width()-2*TEXTFIELDSTARTX, FIXEDLINEHEIGHT ); + maTokenLine.SetText( String( RTL_CONSTASCII_USTRINGPARAM( "Crypto Settings" ) ) ); + maTokenLine.Show(); + + nY += EDITHEIGHT*3/2; + + maCryptoCheckBox.SetPosSizePixel( TEXTFIELDSTARTX, nY, aOutputSize.Width()-2*TEXTFIELDSTARTX, FIXEDLINEHEIGHT ); + maCryptoCheckBox.SetText( String( RTL_CONSTASCII_USTRINGPARAM( "Use Default Token" ) ) ); + maCryptoCheckBox.Check( TRUE ); + maEditTokenName.Disable(); + maFixedTextTokenName.Disable(); + maCryptoCheckBox.SetClickHdl( LINK( this, MyWin, CryptoCheckBoxHdl ) ); + + + maCryptoCheckBox.Show(); + + nY += EDITHEIGHT; + + maFixedTextTokenName.SetPosSizePixel( TEXTFIELDSTARTX, nY, TEXTFIELDWIDTH, EDITHEIGHT ); + maFixedTextTokenName.SetText( String( RTL_CONSTASCII_USTRINGPARAM( "Crypto Token:" ) ) ); + maFixedTextTokenName.Show(); + + maEditTokenName.SetPosSizePixel( TEXTFIELDSTARTX+TEXTFIELDWIDTH, nY, EDITWIDTH, EDITHEIGHT ); + maEditTokenName.Show(); + + nY += EDITHEIGHT*3; + + maTest1Line.SetPosSizePixel( TEXTFIELDSTARTX, nY, aOutputSize.Width()-2*TEXTFIELDSTARTX, FIXEDLINEHEIGHT ); + maTest1Line.SetText( String( RTL_CONSTASCII_USTRINGPARAM( "Test 1 - Simple Files" ) ) ); + maTest1Line.Show(); + + nY += EDITHEIGHT*3/2; + + maFixedTextXMLFileName.SetPosSizePixel( TEXTFIELDSTARTX, nY, TEXTFIELDWIDTH, EDITHEIGHT ); + maFixedTextXMLFileName.SetText( String( RTL_CONSTASCII_USTRINGPARAM( "XML File:" ) ) ); + maFixedTextXMLFileName.Show(); + + maEditXMLFileName.SetPosSizePixel( TEXTFIELDSTARTX+TEXTFIELDWIDTH, nY, EDITWIDTH, EDITHEIGHT ); + maEditXMLFileName.Show(); + + nY += EDITHEIGHT*3/2; + + maFixedTextBINFileName.SetPosSizePixel( TEXTFIELDSTARTX, nY, TEXTFIELDWIDTH, EDITHEIGHT ); + maFixedTextBINFileName.SetText( String( RTL_CONSTASCII_USTRINGPARAM( "Binary File:" ) ) ); + maFixedTextBINFileName.Show(); + + maEditBINFileName.SetPosSizePixel( TEXTFIELDSTARTX+TEXTFIELDWIDTH, nY, EDITWIDTH, EDITHEIGHT ); + maEditBINFileName.Show(); + + nY += EDITHEIGHT*3/2; + + maFixedTextSIGFileName.SetPosSizePixel( TEXTFIELDSTARTX, nY, TEXTFIELDWIDTH, EDITHEIGHT ); + maFixedTextSIGFileName.SetText( String( RTL_CONSTASCII_USTRINGPARAM( "Signature File:" ) ) ); + maFixedTextSIGFileName.Show(); + + maEditSIGFileName.SetPosSizePixel( TEXTFIELDSTARTX+TEXTFIELDWIDTH, nY, EDITWIDTH, EDITHEIGHT ); + maEditSIGFileName.Show(); + + nY += EDITHEIGHT*2; + + maSignButton.SetPosSizePixel( TEXTFIELDSTARTX, nY, BUTTONWIDTH, BUTTONHEIGHT ); + maSignButton.SetText( String( RTL_CONSTASCII_USTRINGPARAM( "Sign" ) ) ); + maSignButton.SetClickHdl( LINK( this, MyWin, SignButtonHdl ) ); + maSignButton.Show(); + + maVerifyButton.SetPosSizePixel( TEXTFIELDSTARTX+BUTTONWIDTH+BUTTONSPACE, nY, BUTTONWIDTH, BUTTONHEIGHT ); + maVerifyButton.SetText( String( RTL_CONSTASCII_USTRINGPARAM( "Verify" ) ) ); + maVerifyButton.SetClickHdl( LINK( this, MyWin, VerifyButtonHdl ) ); + maVerifyButton.Show(); + + nY += EDITHEIGHT*3; + + maTest2Line.SetPosSizePixel( TEXTFIELDSTARTX, nY, aOutputSize.Width()-2*TEXTFIELDSTARTX, FIXEDLINEHEIGHT ); + maTest2Line.SetText( String( RTL_CONSTASCII_USTRINGPARAM( "Test 2 - Office Document" ) ) ); + maTest2Line.Show(); + + nY += EDITHEIGHT*3/2; + + maFixedTextDOCFileName.SetPosSizePixel( TEXTFIELDSTARTX, nY, TEXTFIELDWIDTH, EDITHEIGHT ); + maFixedTextDOCFileName.SetText( String( RTL_CONSTASCII_USTRINGPARAM( "Office File:" ) ) ); + maFixedTextDOCFileName.Show(); + + maEditDOCFileName.SetPosSizePixel( TEXTFIELDSTARTX+TEXTFIELDWIDTH, nY, EDITWIDTH, EDITHEIGHT ); + maEditDOCFileName.Show(); + + nY += EDITHEIGHT*2; + + maDigitalSignaturesButton.SetPosSizePixel( TEXTFIELDSTARTX, nY, BUTTONWIDTH*2, BUTTONHEIGHT ); + maDigitalSignaturesButton.SetText( String( RTL_CONSTASCII_USTRINGPARAM( "Digital Signatures..." ) ) ); + maDigitalSignaturesButton.SetClickHdl( LINK( this, MyWin, DigitalSignaturesWithServiceHdl ) ); + maDigitalSignaturesButton.Show(); + + nY += EDITHEIGHT*3; + + maHintLine.SetPosSizePixel( TEXTFIELDSTARTX, nY, aOutputSize.Width()-2*TEXTFIELDSTARTX, FIXEDLINEHEIGHT ); + maHintLine.Show(); + + nY += EDITHEIGHT*2; + + maHintText.SetPosSizePixel( TEXTFIELDSTARTX, nY, aOutputSize.Width()-2*TEXTFIELDSTARTX, aOutputSize.Height()-nY ); + maHintText.SetText( String( RTL_CONSTASCII_USTRINGPARAM( "Hint: Copy crypto files from xmlsecurity/tools/cryptoken/nss and sample files from xmlsecurity/tools/examples to /nss.\nThis location will be used from the demo as the default location." ) ) ); + maHintText.Show(); + + // Help the user with some default values + ::rtl::OUString aTempDirURL; + ::osl::File::getTempDirURL( aTempDirURL ); + INetURLObject aURLObj( aTempDirURL ); + aURLObj.insertName( String( RTL_CONSTASCII_USTRINGPARAM( "nss" ) ), true ); + ::rtl::OUString aNSSFolder = aURLObj.getFSysPath( INetURLObject::FSYS_DETECT ); + String aDefaultXMLFileName( aNSSFolder ); + maEditXMLFileName.SetText( aNSSFolder + String( RTL_CONSTASCII_USTRINGPARAM( "demo-sample.xml" ) ) ); + maEditBINFileName.SetText( aNSSFolder + String( RTL_CONSTASCII_USTRINGPARAM( "demo-sample.gif" ) ) ); + maEditDOCFileName.SetText( aNSSFolder + String( RTL_CONSTASCII_USTRINGPARAM( "demo-sample.sxw" ) ) ); + maEditSIGFileName.SetText( aNSSFolder + String( RTL_CONSTASCII_USTRINGPARAM( "demo-result.xml" ) ) ); + maEditTokenName.SetText( aNSSFolder ); +} + +IMPL_LINK( MyWin, CryptoCheckBoxHdl, CheckBox*, EMPTYARG ) +{ + if ( maCryptoCheckBox.IsChecked() ) + { + maEditTokenName.Disable(); + maFixedTextTokenName.Disable(); + } + else + { + maEditTokenName.Enable(); + maFixedTextTokenName.Enable(); + } + return 1; +} + +IMPL_LINK( MyWin, SignButtonHdl, Button*, EMPTYARG ) +{ + String aXMLFileName = maEditXMLFileName.GetText(); + String aBINFileName = maEditBINFileName.GetText(); + String aSIGFileName = maEditSIGFileName.GetText(); + + String aTokenFileName; + if ( !maCryptoCheckBox.IsChecked() ) + aTokenFileName = maEditTokenName.GetText(); + + XMLSignatureHelper aSignatureHelper( comphelper::getProcessServiceFactory() ); + bool bInit = aSignatureHelper.Init( aTokenFileName ); + + if ( !bInit ) + { + ErrorBox( this, WB_OK, String( RTL_CONSTASCII_USTRINGPARAM( "Error initializing security context!" ) ) ).Execute(); + return 0; + } + + uno::Reference< ::com::sun::star::security::XCertificate > xCertToUse; + CertificateChooser aChooser( this, aSignatureHelper.GetSecurityEnvironment(), SignatureInformations() ); + if ( aChooser.Execute() ) + xCertToUse = aChooser.GetSelectedCertificate(); + + if ( !xCertToUse.is() ) + return 0; + + + aSignatureHelper.StartMission(); + + sal_Int32 nSecurityId = aSignatureHelper.GetNewSecurityId(); + + aSignatureHelper.SetX509Certificate( nSecurityId, xCertToUse->getIssuerName(), bigIntegerToNumericString( xCertToUse->getSerialNumber() ) ); + + aSignatureHelper.AddForSigning( nSecurityId, aXMLFileName, aXMLFileName, sal_False ); + aSignatureHelper.AddForSigning( nSecurityId, aBINFileName, aBINFileName, sal_True ); + + SvFileStream* pStream = new SvFileStream( aSIGFileName, STREAM_WRITE ); + SvLockBytesRef xLockBytes = new SvLockBytes( pStream, TRUE ); + uno::Reference< io::XOutputStream > xOutputStream = new utl::OOutputStreamHelper( xLockBytes ); + bool bDone = aSignatureHelper.CreateAndWriteSignatue( xOutputStream ); + + aSignatureHelper.EndMission(); + + if ( !bDone ) + { + ErrorBox( this, WB_OK, String( RTL_CONSTASCII_USTRINGPARAM( "Error creating Signature!" ) ) ).Execute(); + } + else + { + rtl::OUString aInfo( String( RTL_CONSTASCII_USTRINGPARAM( "Signature successfully created!\n\n" ) ) ); + // aInfo += getSignatureInformationmations( aSignatureHelper.getAllSignatureInformation(), aSignatureHelper.GetSecurityEnvironment() ); + + + InfoBox( this, aInfo ).Execute(); + } + + // Check for more detailed results... + + return 0; +} + +IMPL_LINK( MyWin, VerifyButtonHdl, Button*, EMPTYARG ) +{ + String aXMLFileName = maEditXMLFileName.GetText(); + String aBINFileName = maEditBINFileName.GetText(); + String aSIGFileName = maEditSIGFileName.GetText(); + + String aTokenFileName; + if ( !maCryptoCheckBox.IsChecked() ) + aTokenFileName = maEditTokenName.GetText(); + + XMLSignatureHelper aSignatureHelper( comphelper::getProcessServiceFactory() ); + bool bInit = aSignatureHelper.Init( aTokenFileName ); + + if ( !bInit ) + { + ErrorBox( this, WB_OK, String( RTL_CONSTASCII_USTRINGPARAM( "Error initializing security context!" ) ) ).Execute(); + return 0; + } + + aSignatureHelper.SetStartVerifySignatureHdl( LINK( this, MyWin, StartVerifySignatureHdl ) ); + + aSignatureHelper.StartMission(); + + SvFileStream* pStream = new SvFileStream( aSIGFileName, STREAM_READ ); + pStream->Seek( STREAM_SEEK_TO_END ); + ULONG nBytes = pStream->Tell(); + pStream->Seek( STREAM_SEEK_TO_BEGIN ); + SvLockBytesRef xLockBytes = new SvLockBytes( pStream, TRUE ); + uno::Reference< io::XInputStream > xInputStream = new utl::OInputStreamHelper( xLockBytes, nBytes ); + bool bDone = aSignatureHelper.ReadAndVerifySignatue( xInputStream ); + xInputStream->closeInput(); + + aSignatureHelper.EndMission(); + + if ( !bDone ) + ErrorBox( this, WB_OK, String( RTL_CONSTASCII_USTRINGPARAM( "Error in Signature!" ) ) ).Execute(); + else + InfoBox( this, String( RTL_CONSTASCII_USTRINGPARAM( "Signatures verified without any problems!" ) ) ).Execute(); + + return 0; +} + +IMPL_LINK( MyWin, StartVerifySignatureHdl, void*, EMPTYARG ) +{ + QueryBox aQueryBox( this, WB_YES_NO|WB_DEF_YES, String( RTL_CONSTASCII_USTRINGPARAM( "Found Signature - Verify?" ) ) ); + return ( aQueryBox.Execute() == RET_YES ) ? 1 : 0; +} + +IMPL_LINK( MyWin, DigitalSignaturesWithServiceHdl, Button*, EMPTYARG ) +{ + rtl::OUString aDocFileName = maEditDOCFileName.GetText(); + rtl::OUString aSigFileName; + + String aTokenFileName; + if ( !maCryptoCheckBox.IsChecked() ) + aTokenFileName = maEditTokenName.GetText(); + + uno::Reference < embed::XStorage > xStore = ::comphelper::OStorageHelper::GetStorageFromURL( + aDocFileName, embed::ElementModes::READWRITE, comphelper::getProcessServiceFactory() ); + + if ( !bStoreSignatureInStorage ) + { + aSigFileName = aDocFileName; + aSigFileName += String( RTL_CONSTASCII_USTRINGPARAM( ".signature" ) ); + } + + uno::Reference< security::XDocumentDigitalSignatures > xD( + comphelper::getProcessServiceFactory()->createInstance( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.security.DocumentDigitalSignatures" ) ) ), uno::UNO_QUERY ); + if ( xD.is() ) + xD->SignDocumentContent( xStore, aSigFileName, aTokenFileName ); + + + return 0; +} + +IMPL_LINK( MyWin, DigitalSignaturesWithTokenHdl, Button*, EMPTYARG ) +{ + String aDocFileName = maEditDOCFileName.GetText(); + String aTokenFileName = maEditTokenName.GetText(); + + DigitalSignaturesDialog aSignaturesDialog( this, comphelper::getProcessServiceFactory(), SignatureModeDocumentContent ); + + bool bInit = aSignaturesDialog.Init( aTokenFileName ); + if ( !bInit ) + { + ErrorBox( this, WB_OK, String( RTL_CONSTASCII_USTRINGPARAM( "Error initializing security context!" ) ) ).Execute(); + return 0; + } + + uno::Reference < embed::XStorage > xStore = ::comphelper::OStorageHelper::GetStorageFromURL( + aDocFileName, embed::ElementModes::READWRITE, comphelper::getProcessServiceFactory() ); + + aSignaturesDialog.SetStorage( xStore ); + + if ( !bStoreSignatureInStorage ) + { + rtl::OUString aSigFileName( aDocFileName ); + aSigFileName += String( RTL_CONSTASCII_USTRINGPARAM( ".signature" ) ); + aSignaturesDialog.SetSignatureFileName( aSigFileName ); + } + + aSignaturesDialog.Execute(); + + return 0; +} -- cgit v1.2.3