summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--xmlsecurity/inc/xmlsecurity/certificatechooser.hxx126
-rw-r--r--xmlsecurity/inc/xmlsecurity/certificateviewer.hxx185
-rw-r--r--xmlsecurity/inc/xmlsecurity/digitalsignaturesdialog.hxx152
-rw-r--r--xmlsecurity/inc/xmlsecurity/sigstruct.hxx120
-rw-r--r--xmlsecurity/inc/xmlsecurity/stbcontrl.hxx91
-rw-r--r--xmlsecurity/inc/xmlsecurity/xmlsignaturehelper.hxx214
-rw-r--r--xmlsecurity/prj/build.lst10
-rw-r--r--xmlsecurity/prj/d.lst4
-rw-r--r--xmlsecurity/source/component/documentdigitalsignatures.cxx123
-rw-r--r--xmlsecurity/source/component/documentdigitalsignatures.hxx94
-rw-r--r--xmlsecurity/source/component/makefile.mk86
-rw-r--r--xmlsecurity/source/component/registerservices.cxx135
-rw-r--r--xmlsecurity/source/dialogs/certificatechooser.cxx216
-rw-r--r--xmlsecurity/source/dialogs/certificatechooser.src125
-rw-r--r--xmlsecurity/source/dialogs/certificateviewer.cxx397
-rw-r--r--xmlsecurity/source/dialogs/certificateviewer.src334
-rw-r--r--xmlsecurity/source/dialogs/dialogs.hrc263
-rw-r--r--xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx545
-rw-r--r--xmlsecurity/source/dialogs/digitalsignaturesdialog.src159
-rw-r--r--xmlsecurity/source/dialogs/makefile.mk100
-rw-r--r--xmlsecurity/source/dialogs/resourcemanager.cxx190
-rw-r--r--xmlsecurity/source/dialogs/resourcemanager.hxx96
-rw-r--r--xmlsecurity/source/dialogs/stbcontrl.cxx232
-rw-r--r--xmlsecurity/source/framework/buffernode.cxx1313
-rw-r--r--xmlsecurity/source/framework/buffernode.hxx175
-rw-r--r--xmlsecurity/source/framework/decryptorimpl.cxx288
-rw-r--r--xmlsecurity/source/framework/decryptorimpl.hxx176
-rw-r--r--xmlsecurity/source/framework/elementcollector.cxx330
-rw-r--r--xmlsecurity/source/framework/elementcollector.hxx147
-rw-r--r--xmlsecurity/source/framework/elementmark.cxx136
-rw-r--r--xmlsecurity/source/framework/elementmark.hxx123
-rw-r--r--xmlsecurity/source/framework/encryptionengine.cxx254
-rw-r--r--xmlsecurity/source/framework/encryptionengine.hxx157
-rw-r--r--xmlsecurity/source/framework/encryptorimpl.cxx328
-rw-r--r--xmlsecurity/source/framework/encryptorimpl.hxx190
-rw-r--r--xmlsecurity/source/framework/makefile.mk98
-rw-r--r--xmlsecurity/source/framework/saxeventkeeperimpl.cxx1503
-rw-r--r--xmlsecurity/source/framework/saxeventkeeperimpl.hxx423
-rw-r--r--xmlsecurity/source/framework/securityengine.cxx122
-rw-r--r--xmlsecurity/source/framework/securityengine.hxx225
-rw-r--r--xmlsecurity/source/framework/signaturecreatorimpl.cxx343
-rw-r--r--xmlsecurity/source/framework/signaturecreatorimpl.hxx189
-rw-r--r--xmlsecurity/source/framework/signatureengine.cxx306
-rw-r--r--xmlsecurity/source/framework/signatureengine.hxx199
-rw-r--r--xmlsecurity/source/framework/signatureverifierimpl.cxx288
-rw-r--r--xmlsecurity/source/framework/signatureverifierimpl.hxx175
-rw-r--r--xmlsecurity/source/framework/xmlencryptiontemplateimpl.cxx164
-rw-r--r--xmlsecurity/source/framework/xmlencryptiontemplateimpl.hxx168
-rw-r--r--xmlsecurity/source/framework/xmlsignaturetemplateimpl.cxx193
-rw-r--r--xmlsecurity/source/framework/xmlsignaturetemplateimpl.hxx177
-rw-r--r--xmlsecurity/source/framework/xsec_framework.cxx284
-rw-r--r--xmlsecurity/source/helper/makefile.mk90
-rw-r--r--xmlsecurity/source/helper/xmlsignaturehelper.cxx424
-rw-r--r--xmlsecurity/source/helper/xmlsignaturehelper2.cxx242
-rw-r--r--xmlsecurity/source/helper/xmlsignaturehelper2.hxx164
-rw-r--r--xmlsecurity/source/helper/xsecctl.cxx1359
-rw-r--r--xmlsecurity/source/helper/xsecctl.hxx580
-rw-r--r--xmlsecurity/source/helper/xsecparser.cxx353
-rw-r--r--xmlsecurity/source/helper/xsecparser.hxx199
-rw-r--r--xmlsecurity/source/helper/xsecsign.cxx394
-rw-r--r--xmlsecurity/source/helper/xsecverify.cxx349
-rw-r--r--xmlsecurity/source/xmlsec/certificateextension_xmlsecimpl.cxx134
-rw-r--r--xmlsecurity/source/xmlsec/certificateextension_xmlsecimpl.hxx119
-rw-r--r--xmlsecurity/source/xmlsec/makefile.mk94
-rw-r--r--xmlsecurity/source/xmlsec/mscrypt/makefile.mk102
-rw-r--r--xmlsecurity/source/xmlsec/mscrypt/securityenvironment_mscryptimpl.cxx1028
-rw-r--r--xmlsecurity/source/xmlsec/mscrypt/securityenvironment_mscryptimpl.hxx235
-rw-r--r--xmlsecurity/source/xmlsec/mscrypt/seinitializer_mscryptimpl.cxx269
-rw-r--r--xmlsecurity/source/xmlsec/mscrypt/seinitializer_mscryptimpl.hxx152
-rw-r--r--xmlsecurity/source/xmlsec/mscrypt/x509certificate_mscryptimpl.cxx392
-rw-r--r--xmlsecurity/source/xmlsec/mscrypt/x509certificate_mscryptimpl.hxx147
-rw-r--r--xmlsecurity/source/xmlsec/mscrypt/xmlencryption_mscryptimpl.cxx403
-rw-r--r--xmlsecurity/source/xmlsec/mscrypt/xmlencryption_mscryptimpl.hxx165
-rw-r--r--xmlsecurity/source/xmlsec/mscrypt/xmlsecuritycontext_mscryptimpl.cxx331
-rw-r--r--xmlsecurity/source/xmlsec/mscrypt/xmlsecuritycontext_mscryptimpl.hxx174
-rw-r--r--xmlsecurity/source/xmlsec/mscrypt/xmlsignature_mscryptimpl.cxx336
-rw-r--r--xmlsecurity/source/xmlsec/mscrypt/xmlsignature_mscryptimpl.hxx165
-rw-r--r--xmlsecurity/source/xmlsec/mscrypt/xsec_mscrypt.cxx198
-rw-r--r--xmlsecurity/source/xmlsec/nss/makefile.mk158
-rw-r--r--xmlsecurity/source/xmlsec/nss/securityenvironment_nssimpl.cxx832
-rw-r--r--xmlsecurity/source/xmlsec/nss/securityenvironment_nssimpl.hxx210
-rw-r--r--xmlsecurity/source/xmlsec/nss/seinitializer_nssimpl.cxx390
-rw-r--r--xmlsecurity/source/xmlsec/nss/seinitializer_nssimpl.hxx152
-rw-r--r--xmlsecurity/source/xmlsec/nss/x509certificate_nssimpl.cxx360
-rw-r--r--xmlsecurity/source/xmlsec/nss/x509certificate_nssimpl.hxx146
-rw-r--r--xmlsecurity/source/xmlsec/nss/xmlencryption_nssimpl.cxx429
-rw-r--r--xmlsecurity/source/xmlsec/nss/xmlencryption_nssimpl.hxx165
-rw-r--r--xmlsecurity/source/xmlsec/nss/xmlsecuritycontext_nssimpl.cxx290
-rw-r--r--xmlsecurity/source/xmlsec/nss/xmlsecuritycontext_nssimpl.hxx174
-rw-r--r--xmlsecurity/source/xmlsec/nss/xmlsignature_nssimpl.cxx336
-rw-r--r--xmlsecurity/source/xmlsec/nss/xmlsignature_nssimpl.hxx165
-rw-r--r--xmlsecurity/source/xmlsec/nss/xsec_nss.cxx199
-rw-r--r--xmlsecurity/source/xmlsec/saxhelper.cxx465
-rw-r--r--xmlsecurity/source/xmlsec/saxhelper.hxx123
-rw-r--r--xmlsecurity/source/xmlsec/xmldocumentwrapper_xmlsecimpl.cxx1187
-rw-r--r--xmlsecurity/source/xmlsec/xmldocumentwrapper_xmlsecimpl.hxx328
-rw-r--r--xmlsecurity/source/xmlsec/xmlelementwrapper_xmlsecimpl.cxx221
-rw-r--r--xmlsecurity/source/xmlsec/xmlelementwrapper_xmlsecimpl.hxx152
-rw-r--r--xmlsecurity/source/xmlsec/xmlstreamio.cxx244
-rw-r--r--xmlsecurity/source/xmlsec/xmlstreamio.hxx83
-rw-r--r--xmlsecurity/source/xmlsec/xsec_xmlsec.cxx201
-rw-r--r--xmlsecurity/tools/demo/makefile.mk151
-rw-r--r--xmlsecurity/tools/demo/multisigdemo.cxx353
-rw-r--r--xmlsecurity/tools/demo/signdemo.cxx223
-rw-r--r--xmlsecurity/tools/demo/util.cxx215
-rw-r--r--xmlsecurity/tools/demo/util.hxx87
-rw-r--r--xmlsecurity/tools/demo/verifydemo.cxx180
-rw-r--r--xmlsecurity/tools/examples/demo-sample.gifbin0 -> 94 bytes
-rw-r--r--xmlsecurity/tools/examples/demo-sample.sxwbin0 -> 19891 bytes
-rw-r--r--xmlsecurity/tools/examples/demo-sample.xml3
-rw-r--r--xmlsecurity/tools/examples/enc-1.xml31
-rw-r--r--xmlsecurity/tools/examples/enc-2.xml58
-rw-r--r--xmlsecurity/tools/examples/eval_export.txt7
-rw-r--r--xmlsecurity/tools/examples/eval_import.txt14
-rw-r--r--xmlsecurity/tools/examples/evaluate_win.bat142
-rw-r--r--xmlsecurity/tools/examples/s-in-e-1.xml53
-rw-r--r--xmlsecurity/tools/examples/s-in-e-2.xml53
-rw-r--r--xmlsecurity/tools/examples/sign-0.xml27
-rw-r--r--xmlsecurity/tools/examples/sign-1.xml29
-rw-r--r--xmlsecurity/tools/examples/sign-2.xml33
-rw-r--r--xmlsecurity/tools/examples/sign-3.xml41
-rw-r--r--xmlsecurity/tools/examples/sign-4.xml57
-rw-r--r--xmlsecurity/tools/examples/sign-5.xml89
-rw-r--r--xmlsecurity/tools/examples/uno_win.bat24
-rw-r--r--xmlsecurity/tools/examples/warmup.xml27
-rw-r--r--xmlsecurity/tools/standalone/csfit/certmngr.cxx201
-rw-r--r--xmlsecurity/tools/standalone/csfit/decrypter.cxx303
-rw-r--r--xmlsecurity/tools/standalone/csfit/encrypter.cxx340
-rw-r--r--xmlsecurity/tools/standalone/csfit/helper.cxx297
-rw-r--r--xmlsecurity/tools/standalone/csfit/helper.hxx275
-rw-r--r--xmlsecurity/tools/standalone/csfit/makefile.mk187
-rw-r--r--xmlsecurity/tools/standalone/csfit/signer.cxx388
-rw-r--r--xmlsecurity/tools/standalone/csfit/util/makefile.mk216
-rw-r--r--xmlsecurity/tools/standalone/csfit/verifier.cxx371
-rw-r--r--xmlsecurity/tools/standalone/mscsfit/certmngr.cxx140
-rw-r--r--xmlsecurity/tools/standalone/mscsfit/decrypter.cxx243
-rw-r--r--xmlsecurity/tools/standalone/mscsfit/encrypter.cxx294
-rw-r--r--xmlsecurity/tools/standalone/mscsfit/helper.cxx217
-rw-r--r--xmlsecurity/tools/standalone/mscsfit/helper.hxx204
-rw-r--r--xmlsecurity/tools/standalone/mscsfit/makefile.mk184
-rw-r--r--xmlsecurity/tools/standalone/mscsfit/signer.cxx328
-rw-r--r--xmlsecurity/tools/standalone/mscsfit/util/makefile.mk216
-rw-r--r--xmlsecurity/tools/standalone/mscsfit/verifier.cxx319
-rw-r--r--xmlsecurity/tools/uno/AdapterNode.java199
-rw-r--r--xmlsecurity/tools/uno/AttributeListHelper.java182
-rw-r--r--xmlsecurity/tools/uno/DomToTreeModelAdapter.java200
-rw-r--r--xmlsecurity/tools/uno/EncryptionEntity.java252
-rw-r--r--xmlsecurity/tools/uno/ParsingThread.java282
-rw-r--r--xmlsecurity/tools/uno/SAXEventCollector.java229
-rw-r--r--xmlsecurity/tools/uno/SAXEventPrinter.java354
-rw-r--r--xmlsecurity/tools/uno/SecurityEntity.java236
-rw-r--r--xmlsecurity/tools/uno/SignatureEntity.java322
-rw-r--r--xmlsecurity/tools/uno/TestTool.java1426
-rw-r--r--xmlsecurity/tools/uno/UnsolvedReferenceTableModel.java123
-rw-r--r--xmlsecurity/tools/uno/XMLFileFilter.java113
-rw-r--r--xmlsecurity/tools/uno/XMLSecurityFrameworkController.java1119
-rw-r--r--xmlsecurity/tools/uno/XMLTreeCellRanderer.java119
-rw-r--r--xmlsecurity/tools/uno/current.gifbin0 -> 94 bytes
-rw-r--r--xmlsecurity/tools/uno/makefile.mk83
-rw-r--r--xmlsecurity/util/exports_xsmscrypt.dxp8
-rw-r--r--xmlsecurity/util/exports_xsnss.dxp8
-rw-r--r--xmlsecurity/util/makefile.mk194
-rw-r--r--xmlsecurity/util/target.pmk68
-rw-r--r--xmlsecurity/util/xmlsecurity.map8
-rw-r--r--xmlsecurity/util/xsec_fw.dxp3
-rw-r--r--xmlsecurity/util/xsecctl.flt19
-rw-r--r--xmlsecurity/workben/makefile.mk116
-rw-r--r--xmlsecurity/workben/signaturetest.cxx543
168 files changed, 40905 insertions, 0 deletions
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 <vcl/dialog.hxx>
+#include <vcl/fixed.hxx>
+#include <vcl/button.hxx>
+#include <svx/simptabl.hxx>
+
+namespace com {
+namespace sun {
+namespace star {
+namespace security {
+ class XCertificate; }
+namespace xml { namespace crypto {
+ class XSecurityEnvironment; }}
+}}}
+
+#include <com/sun/star/uno/Sequence.hxx>
+
+#ifndef _SIGSTRUCT_HXX
+#include <xmlsecurity/sigstruct.hxx>
+#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 <vcl/fixed.hxx>
+#include <vcl/button.hxx>
+#include <vcl/lstbox.hxx>
+#include <vcl/tabdlg.hxx>
+#include <vcl/tabctrl.hxx>
+#include <vcl/tabpage.hxx>
+#include <svtools/stdctrl.hxx>
+#include <svx/simptabl.hxx>
+#include <svtools/svmedit.hxx>
+
+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 <vcl/dialog.hxx>
+#include <vcl/fixed.hxx>
+#include <vcl/button.hxx>
+#include <svx/simptabl.hxx>
+
+#include <xmlsecurity/xmlsignaturehelper.hxx>
+
+#ifndef _STLP_VECTOR
+#include <vector>
+#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 <rtl/ustring.hxx>
+
+#ifndef INCLUDED_VECTOR
+#include <vector>
+#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 <sfx2/stbitem.hxx>
+
+
+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 <vector>
+#endif
+
+#include <tools/link.hxx>
+
+#include <rtl/ustring.hxx>
+
+#include <xmlsecurity/sigstruct.hxx>
+
+#include <com/sun/star/xml/sax/XDocumentHandler.hpp>
+#include <com/sun/star/xml/crypto/XUriBinding.hpp>
+#include <com/sun/star/xml/crypto/XSEInitializer.hpp>
+#include <com/sun/star/xml/crypto/sax/XSecurityController.hpp>
+#include <com/sun/star/xml/crypto/sax/XSignatureCreationResultListener.hpp>
+#include <com/sun/star/xml/crypto/sax/XSignatureVerifyResultListener.hpp>
+
+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<XMLSignatureCreationResult> XMLSignatureCreationResults;
+typedef ::std::vector<XMLSignatureVerifyResult> 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 <documentdigitalsignatures.hxx>
+#include <xmlsecurity/digitalsignaturesdialog.hxx>
+
+#ifndef _COM_SUN_STAR_EMBED_XSTORAGE_HPP_
+#include <com/sun/star/embed/XStorage.hpp>
+#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 <cppuhelper/implbase1.hxx>
+
+#include <com/sun/star/security/XDocumentDigitalSignatures.hpp>
+
+
+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 <tools/debug.hxx>
+
+#ifndef _COM_SUN_STAR_LANG_XSINGLESERVICEFACTORY_HPP_
+#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+#endif
+
+#include <cppuhelper/factory.hxx>
+
+
+#include <documentdigitalsignatures.hxx>
+
+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 <xmlsecurity/certificatechooser.hxx>
+#include <xmlsecurity/certificateviewer.hxx>
+
+#ifndef _COM_SUN_STAR_XML_CRYPTO_XSECURITYENVIRONMENT_HPP_
+#include <com/sun/star/xml/crypto/XSecurityEnvironment.hpp>
+#endif
+
+#ifndef _COMPHELPER_SEQUENCE_HXX_
+#include <comphelper/sequence.hxx>
+#endif
+
+// MM : added for password exception
+#include <vcl/msgbox.hxx>
+#include <com/sun/star/security/NoPasswordException.hpp>
+using namespace ::com::sun::star::security;
+
+// Only for bigIntegerToNumericString
+#include <xmlsecurity/xmlsignaturehelper.hxx>
+
+#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 <xmlsecurity/certificateviewer.hxx>
+
+// Only for bigIntegerToNumericString
+#include <xmlsecurity/xmlsignaturehelper.hxx>
+
+
+#ifndef _COM_SUN_STAR_SECURITY_XCERTIFICATE_HPP_
+#include <com/sun/star/security/XCertificate.hpp>
+#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 <svtools/controldims.hrc>
+
+
+#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 <xmlsecurity/digitalsignaturesdialog.hxx>
+#include <xmlsecurity/certificatechooser.hxx>
+#include <xmlsecurity/certificateviewer.hxx>
+
+#ifndef _COM_SUN_STAR_EMBED_XSTORAGE_HPP_
+#include <com/sun/star/embed/XStorage.hpp>
+#endif
+#ifndef _COM_SUN_STAR_EMBED_ELEMENTMODES_HPP_
+#include <com/sun/star/embed/ElementModes.hpp>
+#endif
+#include <com/sun/star/embed/XTransactedObject.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/lang/XComponent.hpp>
+
+// Only needed until sig is in storage:
+#include <unotools/streamhelper.hxx>
+
+/*-
+ * deleted by AF. base64.h is a mozilla nss file, this file should not depend
+ * on nss/nspr.
+ */
+//#include <external/base64.h>
+
+#if OSL_DEBUG_LEVEL > 1
+#include <vcl/msgbox.hxx>
+#endif
+
+#include <tools/intn.hxx>
+
+#include "dialogs.hrc"
+#include "resourcemanager.hxx"
+
+// MM : added for password exception
+#include <com/sun/star/security/NoPasswordException.hpp>
+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<com::sun::star::xml::crypto::XSecurityEnvironment> 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<com::sun::star::xml::crypto::XSecurityEnvironment> 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 <vcl/svapp.hxx>
+#include <svtools/solar.hrc>
+
+
+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 <tools/resmgr.hxx>
+#endif
+#ifndef _TOOLS_INTN_HXX
+#include <tools/intn.hxx>
+#endif
+#ifndef _DATETIME_HXX
+#include <tools/datetime.hxx>
+#endif
+#ifndef _COM_SUN_STAR_UTIL_DATETIME_HPP_
+#include <com/sun/star/util/DateTime.hpp>
+#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 <tools/shl.hxx>
+#endif
+#ifndef _STATUS_HXX //autogen
+#include <vcl/status.hxx>
+#endif
+#ifndef _MENU_HXX //autogen
+#include <vcl/menu.hxx>
+#endif
+#ifndef _SV_IMAGE_HXX
+#include <vcl/image.hxx>
+#endif
+//#ifndef _SFXITEMPOOL_HXX
+//#include <svtools/itempool.hxx>
+//#endif
+#ifndef _SFXAPP_HXX
+#include <sfx2/app.hxx>
+#endif
+#ifndef _SFXMODULE_HXX
+#include <sfx2/module.hxx>
+#endif
+#ifndef _SFXDISPATCH_HXX //autogen
+#include <sfx2/dispatch.hxx>
+#endif
+#ifndef _SFX_OBJSH_HXX //autogen
+#include <sfx2/objsh.hxx>
+#endif
+
+#include <svtools/eitem.hxx>
+
+
+#include <xmlsecurity/stbcontrl.hxx>
+
+#define PAINT_OFFSET 5
+
+//#include "sizeitem.hxx"
+//#include "dialmgr.hxx"
+//#include "dlgutil.hxx"
+//#include "stbctrls.h"
+
+//#include "dialogs.hrc"
+
+/*#ifndef _UNOTOOLS_LOCALEDATAWRAPPER_HXX
+#include <unotools/localedatawrapper.hxx>
+#endif
+#ifndef _UNOTOOLS_PROCESSFACTORY_HXX
+#include <comphelper/processfactory.hxx>
+#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 <com/sun/star/xml/crypto/sax/ConstOfSecurityId.hpp>
+#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 <com/sun/star/lang/XServiceInfo.hpp>
+#endif
+#ifndef _COM_SUN_STAR_XML_WRAPPER_XXMLELEMENTWRAPPER_HPP_
+#include <com/sun/star/xml/wrapper/XXMLElementWrapper.hpp>
+#endif
+
+#ifndef INCLUDED_VECTOR
+#include <vector>
+#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 <com/sun/star/xml/crypto/XXMLEncryptionTemplate.hpp>
+#endif
+#ifndef _COM_SUN_STAR_XML_WRAPPER_XXMLELEMENTWRAPPER_HPP_
+#include <com/sun/star/xml/wrapper/XXMLElementWrapper.hpp>
+#endif
+#ifndef _COM_SUN_STAR_XML_CRYPTO_SAX_DECRYPTIONRESULT_HPP_
+#include <com/sun/star/xml/crypto/sax/DecryptionResult.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#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 <com/sun/star/xml/crypto/sax/XDecryptionResultBroadcaster.hpp>
+#endif
+#ifndef _COM_SUN_STAR_XML_CRYPTO_SAX_XDECRYPTIONRESULTLISTENER_HPP_
+#include <com/sun/star/xml/crypto/sax/XDecryptionResultListener.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XINITIALIZATION_HPP_
+#include <com/sun/star/lang/XInitialization.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#endif
+#ifndef _CPPUHELPER_IMPLBASE3_HXX_
+#include <cppuhelper/implbase3.hxx>
+#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 <com/sun/star/xml/crypto/sax/ConstOfSecurityId.hpp>
+#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 <com/sun/star/xml/crypto/sax/XReferenceResolvedListener.hpp>
+#endif
+#ifndef _COM_SUN_STAR_XML_CRYPTO_SAX_ELEMENTMARKPRIORITY_HPP_
+#include <com/sun/star/xml/crypto/sax/ElementMarkPriority.hpp>
+#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 <com/sun/star/lang/XServiceInfo.hpp>
+#endif
+#ifndef _COM_SUN_STAR_XML_CRYPTO_SAX_ELEMENTMARKTYPE_HPP_
+#include <com/sun/star/xml/crypto/sax/ElementMarkType.hpp>
+#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 <com/sun/star/xml/crypto/XXMLEncryptionTemplate.hpp>
+#endif
+#ifndef _COM_SUN_STAR_XML_WRAPPER_XXMLELEMENTWRAPPER_HPP_
+#include <com/sun/star/xml/wrapper/XXMLElementWrapper.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#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 <com/sun/star/xml/crypto/sax/XReferenceResolvedListener.hpp>
+#endif
+#ifndef _COM_SUN_STAR_XML_CRYPTO_SAX_XREFERENCERESOLVEDBROADCASTER_HPP_
+#include <com/sun/star/xml/crypto/sax/XReferenceResolvedBroadcaster.hpp>
+#endif
+#ifndef _COM_SUN_STAR_XML_CRYPTO_SAX_XBLOCKERMONITOR_HPP_
+#include <com/sun/star/xml/crypto/sax/XBlockerMonitor.hpp>
+#endif
+#ifndef _COM_SUN_STAR_XML_CRYPTO_SAX_XKEYCOLLECTOR_HPP_
+#include <com/sun/star/xml/crypto/sax/XKeyCollector.hpp>
+#endif
+#ifndef _COM_SUN_STAR_XML_CRYPTO_SAX_XMISSIONTAKER_HPP_
+#include <com/sun/star/xml/crypto/sax/XMissionTaker.hpp>
+#endif
+#ifndef _COM_SUN_STAR_XML_CRYPTO_SAX_XSAXEVENTKEEPER_HPP_
+#include <com/sun/star/xml/crypto/sax/XSAXEventKeeper.hpp>
+#endif
+#ifndef _COM_SUN_STAR_XML_CRYPTO_XXMLSECURITYCONTEXT_HPP_
+#include <com/sun/star/xml/crypto/XXMLSecurityContext.hpp>
+#endif
+#ifndef _COM_SUN_STAR_XML_CRYPTO_XXMLENCRYPTION_HPP_
+#include <com/sun/star/xml/crypto/XXMLEncryption.hpp>
+#endif
+
+#ifndef _CPPUHELPER_IMPLBASE1_HXX_
+#include <cppuhelper/implbase1.hxx>
+#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 <com/sun/star/xml/crypto/XXMLEncryptionTemplate.hpp>
+#endif
+#ifndef _COM_SUN_STAR_XML_WRAPPER_XXMLELEMENTWRAPPER_HPP_
+#include <com/sun/star/xml/wrapper/XXMLElementWrapper.hpp>
+#endif
+#ifndef _COM_SUN_STAR_XML_CRYPTO_SAX_ENCRYPTIONRESULT_HPP_
+#include <com/sun/star/xml/crypto/sax/EncryptionResult.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#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 <com/sun/star/xml/crypto/sax/XEncryptionResultBroadcaster.hpp>
+#endif
+#ifndef _COM_SUN_STAR_XML_CRYPTO_SAX_XENCRYPTIONRESULTLISTENER_HPP_
+#include <com/sun/star/xml/crypto/sax/XEncryptionResultListener.hpp>
+#endif
+#ifndef _COM_SUN_STAR_XML_CRYPTO_SAX_XSIGNATURECOLLECTOR_HPP_
+#include <com/sun/star/xml/crypto/sax/XReferenceCollector.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XINITIALIZATION_HPP_
+#include <com/sun/star/lang/XInitialization.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#endif
+#ifndef _CPPUHELPER_IMPLBASE4_HXX_
+#include <cppuhelper/implbase4.hxx>
+#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 <com/sun/star/lang/XMultiServiceFactory.hpp>
+#endif
+#ifndef _COM_SUN_STAR_XML_SAX_XDOCUMENTHANDLER_HPP_
+#include <com/sun/star/xml/sax/XDocumentHandler.hpp>
+#endif
+#ifndef _COM_SUN_STAR_XML_CRYPTO_SAX_CONSTOFSECURITYID_HPP_
+#include <com/sun/star/xml/crypto/sax/ConstOfSecurityId.hpp>
+#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; i<nIndent; ++i )
+ {
+ rc += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( " " ));
+ }
+
+ if (pBufferNode == m_pCurrentBufferNode)
+ {
+ rc += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "[%]" ));
+ }
+
+ if (pBufferNode == m_pCurrentBlockingBufferNode)
+ {
+ rc += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "[B]" ));
+ }
+
+ rc += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( " " ));
+ rc += m_xXMLDocument->getNodeName(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; i<nLength; ++i )
+ {
+ aAttributes[i].sName = xAttribs->getNameByIndex((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 <com/sun/star/xml/crypto/sax/XSecuritySAXEventKeeper.hpp>
+#endif
+#ifndef _COM_SUN_STAR_XML_CRYPTO_SAX_XREFERENCERESOLVEDBROADCASTER_HPP_
+#include <com/sun/star/xml/crypto/sax/XReferenceResolvedBroadcaster.hpp>
+#endif
+#ifndef _COM_SUN_STAR_XML_CRYPTO_SAX_XSAXEVENTKEEPERSTATUSCHANGEBROADCASTER_HPP_
+#include <com/sun/star/xml/crypto/sax/XSAXEventKeeperStatusChangeBroadcaster.hpp>
+#endif
+#ifndef _COM_SUN_STAR_XML_CRYPTO_SAX_XSAXEVENTKEEPERSTATUSCHANGELISTENER_HPP_
+#include <com/sun/star/xml/crypto/sax/XSAXEventKeeperStatusChangeListener.hpp>
+#endif
+#ifndef _COM_SUN_STAR_XML_CSAX_XCOMPRESSEDDOCUMENTHANDLER_HPP_
+#include <com/sun/star/xml/csax/XCompressedDocumentHandler.hpp>
+#endif
+#ifndef _COM_SUN_STAR_XML_WRAPPER_XXMLDOCUMENTWRAPPER_HPP_
+#include <com/sun/star/xml/wrapper/XXMLDocumentWrapper.hpp>
+#endif
+#ifndef _COM_SUN_STAR_XML_SAX_XDOCUMENTHANDLER_HPP_
+#include <com/sun/star/xml/sax/XDocumentHandler.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XINITIALIZATION_HPP_
+#include <com/sun/star/lang/XInitialization.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#endif
+#ifndef _CPPUHELPER_IMPLBASE6_HXX_
+#include <cppuhelper/implbase6.hxx>
+#endif
+
+#include "buffernode.hxx"
+#include "elementmark.hxx"
+#include "elementcollector.hxx"
+
+#ifndef INCLUDED_VECTOR
+#include <vector>
+#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 <com/sun/star/lang/XMultiServiceFactory.hpp>
+#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 <com/sun/star/xml/crypto/sax/XReferenceResolvedListener.hpp>
+#endif
+#ifndef _COM_SUN_STAR_XML_CRYPTO_SAX_XREFERENCERESOLVEDBROADCASTER_HPP_
+#include <com/sun/star/xml/crypto/sax/XReferenceResolvedBroadcaster.hpp>
+#endif
+#ifndef _COM_SUN_STAR_XML_CRYPTO_SAX_XKEYCOLLECTOR_HPP_
+#include <com/sun/star/xml/crypto/sax/XKeyCollector.hpp>
+#endif
+#ifndef _COM_SUN_STAR_XML_CRYPTO_SAX_XMISSIONTAKER_HPP_
+#include <com/sun/star/xml/crypto/sax/XMissionTaker.hpp>
+#endif
+#ifndef _COM_SUN_STAR_XML_CRYPTO_SAX_XSAXEVENTKEEPER_HPP_
+#include <com/sun/star/xml/crypto/sax/XSAXEventKeeper.hpp>
+#endif
+#ifndef _COM_SUN_STAR_XML_CRYPTO_XXMLSECURITYCONTEXT_HPP_
+#include <com/sun/star/xml/crypto/XXMLSecurityContext.hpp>
+#endif
+#ifndef _COM_SUN_STAR_XML_CRYPTO_XXMLSIGNATURE_HPP_
+#include <com/sun/star/xml/crypto/XXMLSignature.hpp>
+#endif
+
+#ifndef _CPPUHELPER_IMPLBASE3_HXX_
+#include <cppuhelper/implbase3.hxx>
+#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 <com/sun/star/xml/crypto/XXMLSignatureTemplate.hpp>
+#endif
+#ifndef _COM_SUN_STAR_XML_WRAPPER_XXMLELEMENTWRAPPER_HPP_
+#include <com/sun/star/xml/wrapper/XXMLElementWrapper.hpp>
+#endif
+#ifndef _COM_SUN_STAR_XML_CRYPTO_SAX_SIGNATURECREATIONRESULT_HPP_
+#include <com/sun/star/xml/crypto/sax/SignatureCreationResult.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#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 <com/sun/star/xml/crypto/sax/XBlockerMonitor.hpp>
+#endif
+#ifndef _COM_SUN_STAR_XML_CRYPTO_SAX_XSIGNATURECREATIONRESULTLISTENER_HPP_
+#include <com/sun/star/xml/crypto/sax/XSignatureCreationResultListener.hpp>
+#endif
+#ifndef _COM_SUN_STAR_XML_CRYPTO_SAX_XSIGNATURECREATIONRESULTBROADCASTER_HPP_
+#include <com/sun/star/xml/crypto/sax/XSignatureCreationResultBroadcaster.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XINITIALIZATION_HPP_
+#include <com/sun/star/lang/XInitialization.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#endif
+#ifndef _CPPUHELPER_IMPLBASE4_HXX_
+#include <cppuhelper/implbase4.hxx>
+#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 <com/sun/star/xml/crypto/XXMLSignatureTemplate.hpp>
+#endif
+#ifndef _COM_SUN_STAR_XML_WRAPPER_XXMLELEMENTWRAPPER_HPP_
+#include <com/sun/star/xml/wrapper/XXMLElementWrapper.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#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<size; ++i)
+ {
+ if (m_vUris[i] == uri)
+ {
+ xInputStream = m_vXInputStreams[i];
+ break;
+ }
+ }
+
+ return xInputStream;
+}
+
diff --git a/xmlsecurity/source/framework/signatureengine.hxx b/xmlsecurity/source/framework/signatureengine.hxx
new file mode 100644
index 000000000000..e349faec6a9a
--- /dev/null
+++ b/xmlsecurity/source/framework/signatureengine.hxx
@@ -0,0 +1,199 @@
+/*************************************************************************
+ *
+ * $RCSfile: signatureengine.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 _SIGNATUREENGINE_HXX
+#define _SIGNATUREENGINE_HXX
+
+#ifndef _COM_SUN_STAR_XML_CRYPTO_SAX_XREFERENCERESOLVEDLISTENER_HPP_
+#include <com/sun/star/xml/crypto/sax/XReferenceResolvedListener.hpp>
+#endif
+#ifndef _COM_SUN_STAR_XML_CRYPTO_SAX_XREFERENCERESOLVEDBROADCASTER_HPP_
+#include <com/sun/star/xml/crypto/sax/XReferenceResolvedBroadcaster.hpp>
+#endif
+#ifndef _COM_SUN_STAR_XML_CRYPTO_SAX_XSIGNATURECOLLECTOR_HPP_
+#include <com/sun/star/xml/crypto/sax/XReferenceCollector.hpp>
+#endif
+#ifndef _COM_SUN_STAR_XML_CRYPTO_SAX_XKEYCOLLECTOR_HPP_
+#include <com/sun/star/xml/crypto/sax/XKeyCollector.hpp>
+#endif
+#ifndef _COM_SUN_STAR_XML_CRYPTO_SAX_XMISSIONTAKER_HPP_
+#include <com/sun/star/xml/crypto/sax/XMissionTaker.hpp>
+#endif
+#ifndef _COM_SUN_STAR_XML_CRYPTO_SAX_XSAXEVENTKEEPER_HPP_
+#include <com/sun/star/xml/crypto/sax/XSAXEventKeeper.hpp>
+#endif
+#ifndef _COM_SUN_STAR_XML_CRYPTO_XXMLSECURITYCONTEXT_HPP_
+#include <com/sun/star/xml/crypto/XXMLSecurityContext.hpp>
+#endif
+#ifndef _COM_SUN_STAR_XML_CRYPTO_XXMLSIGNATURE_HPP_
+#include <com/sun/star/xml/crypto/XXMLSignature.hpp>
+#endif
+#ifndef _COM_SUN_STAR_XML_CRYPTO_XURIBINDING_HPP_
+#include <com/sun/star/xml/crypto/XUriBinding.hpp>
+#endif
+#ifndef _COM_SUN_STAR_IO_XINPUTSTREAM_HPP_
+#include <com/sun/star/io/XInputStream.hpp>
+#endif
+
+#ifndef _CPPUHELPER_IMPLBASE2_HXX_
+#include <cppuhelper/implbase2.hxx>
+#endif
+
+#include "securityengine.hxx"
+
+#ifndef INCLUDED_VECTOR
+#include <vector>
+#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 <com/sun/star/xml/crypto/XXMLSignatureTemplate.hpp>
+#endif
+#ifndef _COM_SUN_STAR_XML_WRAPPER_XXMLELEMENTWRAPPER_HPP_
+#include <com/sun/star/xml/wrapper/XXMLElementWrapper.hpp>
+#endif
+#ifndef _COM_SUN_STAR_XML_CRYPTO_SAX_SIGNATUREVERIFYRESULT_HPP_
+#include <com/sun/star/xml/crypto/sax/SignatureVerifyResult.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#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 <com/sun/star/xml/crypto/sax/XSignatureVerifyResultListener.hpp>
+#endif
+#ifndef _COM_SUN_STAR_XML_CRYPTO_SAX_XSIGNATUREVERIFYRESULTBROADCASTER_HPP_
+#include <com/sun/star/xml/crypto/sax/XSignatureVerifyResultBroadcaster.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XINITIALIZATION_HPP_
+#include <com/sun/star/lang/XInitialization.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#endif
+#ifndef _CPPUHELPER_IMPLBASE3_HXX_
+#include <cppuhelper/implbase3.hxx>
+#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 <sal/config.h>
+#endif
+
+#ifndef _RTL_UUID_H_
+#include <rtl/uuid.h>
+#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 <sal/config.h>
+#endif
+
+#ifndef _RTL_USTRING_HXX_
+#include <rtl/ustring.hxx>
+#endif
+
+#ifndef _CPPUHELPER_FACTORY_HXX_
+#include <cppuhelper/factory.hxx>
+#endif
+
+#ifndef _CPPUHELPER_IMPLBASE3_HXX_
+#include <cppuhelper/implbase3.hxx>
+#endif
+
+#ifndef _COM_SUN_STAR_UNO_EXCEPTION_HPP_
+#include <com/sun/star/uno/Exception.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_UNO_REFERENCE_HPP_
+#include <com/sun/star/uno/Reference.hxx>
+#endif
+
+#ifndef _COM_SUN_STAR_LANG_XSINGLESERVICEFACTORY_HPP_
+#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_LANG_XSECVICEINFO_HPP_
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_LANG_XINITIALIZATION_HPP_
+#include <com/sun/star/lang/XInitialization.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_LANG_XUNOTUNNEL_HPP_
+#include <com/sun/star/lang/XUnoTunnel.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_XML_CRYPTO_XXMLENCRYPTIONTEMPLATE_HPP_
+#include <com/sun/star/xml/crypto/XXMLEncryptionTemplate.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_XML_WRAPPER_XXMLELEMENTWRAPPER_HPP_
+#include <com/sun/star/xml/wrapper/XXMLElementWrapper.hpp>
+#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 <sal/config.h>
+#endif
+
+#ifndef _RTL_USTRING_HXX_
+#include <rtl/ustring.hxx>
+#endif
+
+#ifndef _RTL_UUID_H_
+#include <rtl/uuid.h>
+#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<length; i++)
+ {
+ aTargets[i] = targets[i];
+ }
+
+ return aTargets;
+}
+
+void SAL_CALL XMLSignatureTemplateImpl::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)
+{
+ 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 <sal/config.h>
+#endif
+
+#ifndef _RTL_USTRING_HXX_
+#include <rtl/ustring.hxx>
+#endif
+
+#ifndef _CPPUHELPER_FACTORY_HXX_
+#include <cppuhelper/factory.hxx>
+#endif
+
+#ifndef _CPPUHELPER_IMPLBASE3_HXX_
+#include <cppuhelper/implbase3.hxx>
+#endif
+
+#ifndef _COM_SUN_STAR_UNO_EXCEPTION_HPP_
+#include <com/sun/star/uno/Exception.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_UNO_REFERENCE_HPP_
+#include <com/sun/star/uno/Reference.hxx>
+#endif
+
+#ifndef _COM_SUN_STAR_LANG_XSINGLESERVICEFACTORY_HPP_
+#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_LANG_XSECVICEINFO_HPP_
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_LANG_XINITIALIZATION_HPP_
+#include <com/sun/star/lang/XInitialization.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_XML_CRYPTO_XXMLSIGNATURETEMPLATE_HPP_
+#include <com/sun/star/xml/crypto/XXMLSignatureTemplate.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_XML_WRAPPER_XXMLELEMENTWRAPPER_HPP_
+#include <com/sun/star/xml/wrapper/XXMLElementWrapper.hpp>
+#endif
+
+#ifndef __SGI_STL_VECTOR
+#include <vector>
+#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 <stdio.h>
+
+#include <osl/mutex.hxx>
+#include <osl/thread.h>
+#include <cppuhelper/factory.hxx>
+
+#ifndef _COM_SUN_STAR_LANG_XSINGLESERVICEFACTORY_HPP_
+#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+#endif
+
+#include <decryptorimpl.hxx>
+#include <encryptorimpl.hxx>
+#include <signaturecreatorimpl.hxx>
+#include <signatureverifierimpl.hxx>
+#include <saxeventkeeperimpl.hxx>
+#include <xmlencryptiontemplateimpl.hxx>
+#include <xmlsignaturetemplateimpl.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"
+{
+//==================================================================================================
+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 <xmlsecurity/xmlsignaturehelper.hxx>
+#include <xsecctl.hxx>
+
+#include <xmlsignaturehelper2.hxx>
+
+#include <tools/stream.hxx>
+#include <tools/debug.hxx>
+
+#include <xmloff/attrlist.hxx>
+
+#include <com/sun/star/io/XOutputStream.hpp>
+#include <com/sun/star/io/XInputStream.hpp>
+#include <com/sun/star/io/XActiveDataSource.hpp>
+
+/* 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<xml::sax::XDocumentHandler> 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<xml::sax::XDocumentHandler>
+ 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<xml::sax::XDocumentHandler>& 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<xml::sax::XDocumentHandler> 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 <xmlsecurity/xmlsignaturehelper.hxx>
+#include <xmlsignaturehelper2.hxx>
+
+#include <unotools/streamhelper.hxx>
+
+#include <com/sun/star/embed/XStorage.hpp>
+#include <com/sun/star/embed/ElementModes.hpp>
+
+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 <tools/link.hxx>
+#include <rtl/ustring.hxx>
+
+#include <cppuhelper/implbase1.hxx>
+#include <cppuhelper/implbase3.hxx>
+
+#include <com/sun/star/xml/sax/XDocumentHandler.hpp>
+#include <com/sun/star/xml/crypto/sax/XSignatureCreationResultListener.hpp>
+#include <com/sun/star/xml/crypto/sax/XSignatureVerifyResultListener.hpp>
+
+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 <xsecctl.hxx>
+
+#ifndef _TOOLS_DEBUG_HXX //autogen wg. DBG_ASSERT
+#include <tools/debug.hxx>
+#endif
+
+#include <com/sun/star/xml/crypto/sax/ElementMarkPriority.hpp>
+#include <com/sun/star/xml/crypto/sax/XReferenceResolvedBroadcaster.hpp>
+#include <com/sun/star/xml/crypto/sax/XMissionTaker.hpp>
+#include <com/sun/star/xml/crypto/sax/XReferenceCollector.hpp>
+#include <com/sun/star/xml/crypto/sax/XSAXEventKeeperStatusChangeBroadcaster.hpp>
+#include <com/sun/star/xml/crypto/sax/SignatureVerifyResult.hpp>
+#include <com/sun/star/xml/crypto/sax/SignatureCreationResult.hpp>
+
+#include <xmloff/attrlist.hxx>
+
+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<size; ++i)
+ {
+ if (m_vInternalSignatureInformations[i].signatureInfor.nSecurityId == nSecurityId)
+ {
+ return i;
+ }
+ }
+
+ return -1;
+}
+
+void XSecController::createXSecComponent( )
+/****** XSecController/createXSecComponent ************************************
+ *
+ * NAME
+ * bResult = createXSecComponent -- creates xml security components
+ *
+ * SYNOPSIS
+ * createXSecComponent( );
+ *
+ * FUNCTION
+ * Creates xml security components, including:
+ * 1. an xml signature bridge component ( Java based or C based)
+ * 2. an XMLDocumentWrapper component ( Java based or C based)
+ * 3. a SAXEventKeeper component
+ *
+ * INPUTS
+ * empty
+ *
+ * RESULT
+ * empty
+ *
+ * HISTORY
+ * 05.01.2004 - implemented
+ *
+ * AUTHOR
+ * Michael Mi
+ * Email: michael.mi@sun.com
+ ******************************************************************************/
+{
+ rtl::OUString sSAXEventKeeper(rtl::OUString::createFromAscii( SAXEVENTKEEPER_COMPONENT ));
+ rtl::OUString sXMLSignature(rtl::OUString::createFromAscii( XMLSIGNATURE_COMPONENT ));
+ rtl::OUString sXMLDocument(rtl::OUString::createFromAscii( XMLDOCUMENTWRAPPER_COMPONENT ));
+
+ /*
+ * marks all security components are not available.
+ */
+ m_nStatusOfSecurityComponents = FAILTOINITIALIZED;
+ m_xXMLSignature = NULL;
+ m_xXMLDocumentWrapper = NULL;
+ m_xSAXEventKeeper = NULL;
+
+ m_xXMLSignature = cssu::Reference< cssxc::XXMLSignature >(
+ 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 <cssu::Any> arg(1);
+ arg[0] = cssu::makeAny(m_xXMLDocumentWrapper);
+ xInitialization->initialize(arg);
+
+ cssu::Reference<cssxc::sax::XSAXEventKeeperStatusChangeBroadcaster>
+ 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<cssu::Any> 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<cssu::Any> 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<cssl::XMultiServiceFactory>& 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<size; ++i)
+ {
+ if ( m_nStatusOfSecurityComponents == INITIALIZED )
+ /*
+ * ResolvedListener only exist when the security components are created.
+ */
+ {
+ cssu::Reference< cssxc::sax::XMissionTaker > 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<cssxc::sax::XSAXEventKeeperStatusChangeBroadcaster>
+ 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<cssxs::XDocumentHandler>& 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; j<refNum; ++j)
+ {
+ const SignatureReferenceInformation& refInfor = vReferenceInfors[j];
+
+ pAttributeList = new SvXMLAttributeList();
+ if ( refInfor.nType != 1 )
+ /*
+ * stream reference
+ */
+ {
+ pAttributeList->AddAttribute(
+ 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<sigNum; ++i)
+ {
+ SignatureInformation si = m_vInternalSignatureInformations[i].signatureInfor;
+ vInfors.push_back(si);
+ }
+
+ return vInfors;
+}
+
+/*
+ * XSecurityController
+ *
+ * no methods
+ */
+
+/*
+ * XFastPropertySet
+ */
+/*
+void SAL_CALL XSecController::setFastPropertyValue(
+ sal_Int32 nHandle,
+ const cssu::Any& aValue )
+ throw ( cssb::UnknownPropertyException,
+ cssb::PropertyVetoException,
+ cssl::IllegalArgumentException,
+ cssl::WrappedTargetException,
+ cssu::RuntimeException)
+{
+ sal_Int32 nIndex = getFastPropertyIndex(nHandle);
+ if (nIndex == -1)
+ {
+ m_vFastPropertyIndexs.push_back( nHandle );
+ m_vFastPropertyValues.push_back( aValue );
+ }
+ else
+ {
+ m_vFastPropertyValues[nIndex] = aValue;
+ }
+}
+
+cssu::Any SAL_CALL XSecController::getFastPropertyValue(
+ sal_Int32 nHandle )
+ throw (
+ cssb::UnknownPropertyException,
+ cssl::WrappedTargetException,
+ cssu::RuntimeException)
+{
+ cssu::Any aValue;
+
+ sal_Int32 nIndex = getFastPropertyIndex(nHandle);
+ if (nIndex != -1)
+ {
+ aValue = m_vFastPropertyValues[nIndex];
+ }
+
+ return aValue;
+}
+*/
+
+/*
+ * XSAXEventKeeperStatusChangeListener
+ */
+
+void SAL_CALL XSecController::blockingStatusChanged( sal_Bool isBlocking )
+ throw (cssu::RuntimeException)
+{
+ /*
+ showMessageBox( rtl::OUString::createFromAscii((isBlocking?
+ "Blocking Status => 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 <xmlsecurity/sigstruct.hxx>
+
+#include <com/sun/star/xml/sax/XParser.hpp>
+#include <com/sun/star/lang/XInitialization.hpp>
+#include <com/sun/star/xml/sax/XDocumentHandler.hpp>
+#include <com/sun/star/xml/sax/XAttributeList.hpp>
+#include <com/sun/star/xml/crypto/XXMLSignature.hpp>
+#include <com/sun/star/xml/crypto/XSEInitializer.hpp>
+#include <com/sun/star/xml/crypto/sax/XSecurityController.hpp>
+#include <com/sun/star/xml/crypto/sax/XElementStackKeeper.hpp>
+#include <com/sun/star/xml/crypto/sax/XSecuritySAXEventKeeper.hpp>
+#include <com/sun/star/xml/crypto/sax/XReferenceResolvedListener.hpp>
+#include <com/sun/star/xml/crypto/sax/XSAXEventKeeperStatusChangeListener.hpp>
+#include <com/sun/star/xml/crypto/sax/XSignatureCreationResultListener.hpp>
+#include <com/sun/star/xml/crypto/sax/XSignatureVerifyResultListener.hpp>
+#include <com/sun/star/xml/wrapper/XXMLDocumentWrapper.hpp>
+#include <com/sun/star/beans/XFastPropertySet.hpp>
+#include <com/sun/star/io/XOutputStream.hpp>
+#include <com/sun/star/io/XInputStream.hpp>
+
+#include <cppuhelper/implbase4.hxx>
+
+#ifndef INCLUDED_VECTOR
+#include <vector>
+#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<XInterface> 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:
+ * <A>
+ * <B/>
+ * <C>
+ * <D>
+ * <E/>
+ * </D>
+ * </C>
+ * </A>
+ *
+ * If we consider the SAX event section from startElement(<A>) to
+ * startElement(<D>), then the key SAX events are:
+ *
+ * startElement(<A>), startElement(<C>), startElement(<D>)
+ *
+ * The startElement(<B>) and endElement(<B>) is ignored, because
+ * they are unimportant for the tree structure in this section.
+ *
+ * If we consider the SAX event section from startElement(<D>) to
+ * endElement(<A>), the key SAX events are:
+ *
+ * startElement(<D>), endElement(<D>), endElement(<C>),
+ * endElement(<A>).
+ */
+ 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 <tools/debug.hxx>
+#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)))
+ {