summaryrefslogtreecommitdiff
path: root/xmlsecurity
diff options
context:
space:
mode:
Diffstat (limited to 'xmlsecurity')
-rw-r--r--xmlsecurity/inc/xmlsecurity/digitalsignaturesdialog.hxx26
-rw-r--r--xmlsecurity/inc/xmlsecurity/documentsignaturehelper.hxx120
-rw-r--r--xmlsecurity/inc/xmlsecurity/xmlsignaturehelper.hxx12
-rw-r--r--xmlsecurity/source/component/documentdigitalsignatures.cxx96
-rw-r--r--xmlsecurity/source/component/documentdigitalsignatures.hxx19
-rw-r--r--xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx205
-rw-r--r--xmlsecurity/source/helper/documentsignaturehelper.cxx235
-rw-r--r--xmlsecurity/source/helper/makefile.mk5
-rw-r--r--xmlsecurity/source/helper/xmlsignaturehelper.cxx14
-rw-r--r--xmlsecurity/source/helper/xsecctl.hxx6
-rw-r--r--xmlsecurity/source/helper/xsecsign.cxx6
-rw-r--r--xmlsecurity/util/makefile.mk8
-rw-r--r--xmlsecurity/workben/makefile.mk7
-rw-r--r--xmlsecurity/workben/signaturetest.cxx162
14 files changed, 622 insertions, 299 deletions
diff --git a/xmlsecurity/inc/xmlsecurity/digitalsignaturesdialog.hxx b/xmlsecurity/inc/xmlsecurity/digitalsignaturesdialog.hxx
index 6b5827141611..85b2d87d4f2e 100644
--- a/xmlsecurity/inc/xmlsecurity/digitalsignaturesdialog.hxx
+++ b/xmlsecurity/inc/xmlsecurity/digitalsignaturesdialog.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: digitalsignaturesdialog.hxx,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: mt $ $Date: 2004-07-13 11:01:59 $
+ * last change: $Author: mt $ $Date: 2004-07-14 11:05:44 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -67,6 +67,7 @@
#include <vcl/button.hxx>
#include <svx/simptabl.hxx>
+#include <xmlsecurity/documentsignaturehelper.hxx>
#include <xmlsecurity/xmlsignaturehelper.hxx>
#ifndef _STLP_VECTOR
@@ -89,16 +90,6 @@ namespace cssu = com::sun::star::uno;
class HeaderBar;
-enum DocumentSignatureMode { SignatureModeDocumentContent, SignatureModeMacros, SignatureModePackage };
-
-struct SignatureStreamHelper
-{
- cssu::Reference < css::embed::XStorage > xSignatureStorage;
- cssu::Reference < css::io::XStream > xSignatureStream;
-
- void Dispose();
-};
-
class DigitalSignaturesDialog : public ModalDialog
{
private:
@@ -108,6 +99,7 @@ private:
css::uno::Reference < css::embed::XStorage > mxStore;
SignatureInformations aCurrentSignatureInformations;
bool mbVerifySignatures;
+ bool mbSignaturesChanged;
DocumentSignatureMode meSignatureMode;
// HACK, until sig in storage works
@@ -139,7 +131,7 @@ private:
void ImplShowSignaturesDetails();
public:
- DigitalSignaturesDialog( Window* pParent, cssu::Reference< css::lang::XMultiServiceFactory >& rxMSF, DocumentSignatureMode eMode );
+ DigitalSignaturesDialog( Window* pParent, cssu::Reference< css::lang::XMultiServiceFactory >& rxMSF, DocumentSignatureMode eMode, sal_Bool bReadOnly );
~DigitalSignaturesDialog();
// Initialize the dialog and the security environment, returns TRUE on success
@@ -151,11 +143,11 @@ public:
// 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();
+ // Execute the dialog...
+ short Execute();
- static SignatureStreamHelper OpenSignatureStream( css::uno::Reference < css::embed::XStorage >& rxStore, sal_Int32 nOpenMode, DocumentSignatureMode eDocSigMode );
- static std::vector< rtl::OUString > CreateElementList( css::uno::Reference < css::embed::XStorage >& rxStore, const ::rtl::OUString rRootStorageName, DocumentSignatureMode eMode );
+ // Did signatures change?
+ sal_Bool SignaturesChanged() const { return mbSignaturesChanged; }
};
#endif // _XMLSECURITY_DIGITALSIGNATURESDIALOG_HXX
diff --git a/xmlsecurity/inc/xmlsecurity/documentsignaturehelper.hxx b/xmlsecurity/inc/xmlsecurity/documentsignaturehelper.hxx
new file mode 100644
index 000000000000..9d452bf32d28
--- /dev/null
+++ b/xmlsecurity/inc/xmlsecurity/documentsignaturehelper.hxx
@@ -0,0 +1,120 @@
+/*************************************************************************
+ *
+ * $RCSfile: documentsignaturehelper.hxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: mt $ $Date: 2004-07-14 11:06:05 $
+ *
+ * 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_DOCUMENTSIGNATUREHELPER_HXX
+#define _XMLSECURITY_DOCUMENTSIGNATUREHELPER_HXX
+
+#ifndef _COM_SUN_STAR_UNO_REFERENCE_H_
+#include <com/sun/star/uno/Reference.h>
+#endif
+
+#ifndef _RTL_USTRING_HXX_
+#include <rtl/ustring.hxx>
+#endif
+
+
+#ifndef _STLP_VECTOR
+#include <vector>
+#endif
+
+
+namespace com {
+namespace sun {
+namespace star {
+namespace io {
+ class XStream; }
+namespace embed {
+ class XStorage; }
+}}}
+
+namespace css = com::sun::star;
+
+
+/**********************************************************
+ DocumentSignatureHelper
+
+ Helper class for signing and verifieng document signatures
+
+ Functions:
+ 1. help to create a list of content to be signed/verified
+
+ **********************************************************/
+
+enum DocumentSignatureMode { SignatureModeDocumentContent, SignatureModeMacros, SignatureModePackage };
+
+struct SignatureStreamHelper
+{
+ css::uno::Reference < css::embed::XStorage > xSignatureStorage;
+ css::uno::Reference < css::io::XStream > xSignatureStream;
+
+ void Clear();
+};
+
+
+class DocumentSignatureHelper
+{
+public:
+
+ static SignatureStreamHelper OpenSignatureStream( const css::uno::Reference < css::embed::XStorage >& rxStore, sal_Int32 nOpenMode, DocumentSignatureMode eDocSigMode );
+ static std::vector< rtl::OUString > CreateElementList( const css::uno::Reference < css::embed::XStorage >& rxStore, const ::rtl::OUString rRootStorageName, DocumentSignatureMode eMode );
+};
+
+#endif // _XMLSECURITY_XMLSIGNATUREHELPER_HXX
diff --git a/xmlsecurity/inc/xmlsecurity/xmlsignaturehelper.hxx b/xmlsecurity/inc/xmlsecurity/xmlsignaturehelper.hxx
index 63130f9a5baa..c726fd27c18a 100644
--- a/xmlsecurity/inc/xmlsecurity/xmlsignaturehelper.hxx
+++ b/xmlsecurity/inc/xmlsecurity/xmlsignaturehelper.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: xmlsignaturehelper.hxx,v $
*
- * $Revision: 1.1.1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: mt $ $Date: 2004-07-12 13:15:20 $
+ * last change: $Author: mt $ $Date: 2004-07-14 11:05:44 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -182,7 +182,7 @@ public:
// Argument for the Link is a uno::Reference< xml::sax::XAttributeList >*
// Return 1 to verify, 0 to skip.
- // Default will verify all.
+ // Default handler will verify all.
void SetStartVerifySignatureHdl( const Link& rLink );
// Get the security environment
@@ -199,9 +199,9 @@ public:
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 );
+ bool CreateAndWriteSignature( const com::sun::star::uno::Reference< com::sun::star::xml::sax::XDocumentHandler >& xDocumentHandler );
+ bool CreateAndWriteSignature( const com::sun::star::uno::Reference< com::sun::star::io::XOutputStream >& xOutputStream );
+ bool ReadAndVerifySignature( 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
diff --git a/xmlsecurity/source/component/documentdigitalsignatures.cxx b/xmlsecurity/source/component/documentdigitalsignatures.cxx
index d000b23a33bd..1b0efa72f835 100644
--- a/xmlsecurity/source/component/documentdigitalsignatures.cxx
+++ b/xmlsecurity/source/component/documentdigitalsignatures.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: documentdigitalsignatures.cxx,v $
*
- * $Revision: 1.1.1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: mt $ $Date: 2004-07-12 13:15:24 $
+ * last change: $Author: mt $ $Date: 2004-07-14 11:05:44 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -66,6 +66,10 @@
#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
+
using namespace ::com::sun::star;
@@ -77,28 +81,99 @@ DocumentDigitalSignatures::DocumentDigitalSignatures( const com::sun::star::uno:
mxMSF = rxMSF;
}
+sal_Bool DocumentDigitalSignatures::SignDocumentContent( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& rxStorage ) throw (::com::sun::star::uno::RuntimeException)
+{
+ return ImplViewSignatures( rxStorage, SignatureModeDocumentContent, false );
+}
+
+::com::sun::star::uno::Sequence< ::com::sun::star::security::DocumentSignaturesInformation > DocumentDigitalSignatures::VerifyDocumentContentSignatures( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& rxStorage ) throw (::com::sun::star::uno::RuntimeException)
+{
+ return ImplVerifySignatures( rxStorage, SignatureModeDocumentContent );
+}
+
+void DocumentDigitalSignatures::ShowDocumentContentSignatures( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& rxStorage ) throw (::com::sun::star::uno::RuntimeException)
+{
+ ImplViewSignatures( rxStorage, SignatureModeDocumentContent, true );
+}
+
+sal_Bool DocumentDigitalSignatures::SignScriptingContent( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& rxStorage ) throw (::com::sun::star::uno::RuntimeException)
+{
+ return ImplViewSignatures( rxStorage, SignatureModeMacros, false );
+}
+
+::com::sun::star::uno::Sequence< ::com::sun::star::security::DocumentSignaturesInformation > DocumentDigitalSignatures::VerifyScriptingContentSignatures( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& rxStorage ) throw (::com::sun::star::uno::RuntimeException)
+{
+ return ImplVerifySignatures( rxStorage, SignatureModeMacros );
+}
+
+void DocumentDigitalSignatures::ShowScriptingContentSignatures( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& rxStorage ) throw (::com::sun::star::uno::RuntimeException)
+{
+ ImplViewSignatures( rxStorage, SignatureModeMacros, true );
+}
+
+sal_Bool DocumentDigitalSignatures::SignPackage( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& rxStorage ) throw (::com::sun::star::uno::RuntimeException)
+{
+ return ImplViewSignatures( rxStorage, SignatureModePackage, false );
+}
+
+::com::sun::star::uno::Sequence< ::com::sun::star::security::DocumentSignaturesInformation > DocumentDigitalSignatures::VerifyPackageSignatures( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& rxStorage ) throw (::com::sun::star::uno::RuntimeException)
+{
+ return ImplVerifySignatures( rxStorage, SignatureModePackage );
+}
-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)
+void DocumentDigitalSignatures::ShowPackageSignatures( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& rxStorage ) throw (::com::sun::star::uno::RuntimeException)
{
- DigitalSignaturesDialog aSignaturesDialog( NULL, mxMSF, SignatureModeDocumentContent );
+ ImplViewSignatures( rxStorage, SignatureModePackage, true );
+}
- bool bInit = aSignaturesDialog.Init( rTokenName );
+sal_Bool DocumentDigitalSignatures::ImplViewSignatures( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& rxStorage, DocumentSignatureMode eMode, bool bReadOnly ) throw (::com::sun::star::uno::RuntimeException)
+{
+ DigitalSignaturesDialog aSignaturesDialog( NULL, mxMSF, eMode, bReadOnly );
+ bool bInit = aSignaturesDialog.Init( rtl::OUString() );
DBG_ASSERT( bInit, "Error initializing security context!" );
if ( bInit )
{
aSignaturesDialog.SetStorage( rxStorage );
- aSignaturesDialog.SetSignatureFileName( rStorageName );
aSignaturesDialog.Execute();
}
- return 0;
+ return aSignaturesDialog.SignaturesChanged();
}
-::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 > DocumentDigitalSignatures::ImplVerifySignatures( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& rxStorage, DocumentSignatureMode eMode ) throw (::com::sun::star::uno::RuntimeException)
{
+ std::vector< rtl::OUString > aElementsToBeVerified = DocumentSignatureHelper::CreateElementList( rxStorage, ::rtl::OUString(), eMode );
+
+ XMLSignatureHelper aSignatureHelper( mxMSF );
+ aSignatureHelper.Init( rtl::OUString() );
+ aSignatureHelper.SetStorage( rxStorage );
+
+ aSignatureHelper.StartMission();
+
+ SignatureStreamHelper aStreamHelper = DocumentSignatureHelper::OpenSignatureStream( rxStorage, embed::ElementModes::READ, eMode );
+ if ( aStreamHelper.xSignatureStream.is() )
+ {
+ uno::Reference< io::XInputStream > xInputStream( aStreamHelper.xSignatureStream, uno::UNO_QUERY );
+ bool bVerifyOK = aSignatureHelper.ReadAndVerifySignature( xInputStream );
+
+ if ( bVerifyOK )
+ {
+ // SignatureInformations aInformations = aSignatureHelper.GetSignatureInformations();
+ // ...
+ }
+ }
+
+ aStreamHelper.Clear();
+
+ aSignatureHelper.EndMission();
+
+ // MT: LATER...
+ // = aHelper.GetSignatureInformations();
+
::com::sun::star::uno::Sequence< ::com::sun::star::security::DocumentSignaturesInformation > aInfos;
return aInfos;
+
}
rtl::OUString DocumentDigitalSignatures::GetImplementationName() throw (uno::RuntimeException)
@@ -106,7 +181,7 @@ rtl::OUString DocumentDigitalSignatures::GetImplementationName() throw (uno::Run
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 > DocumentDigitalSignatures::GetSupportedServiceNames() throw (cssu::RuntimeException)
{
uno::Sequence < rtl::OUString > aRet(1);
rtl::OUString* pArray = aRet.getArray();
@@ -115,9 +190,8 @@ uno::Sequence< rtl::OUString > SAL_CALL DocumentDigitalSignatures::GetSupportedS
}
-com::sun::star::uno::Reference< com::sun::star::uno::XInterface > SAL_CALL DocumentDigitalSignatures_CreateInstance(
+com::sun::star::uno::Reference< com::sun::star::uno::XInterface > 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
index 50d10ad85084..96f874129b91 100644
--- a/xmlsecurity/source/component/documentdigitalsignatures.hxx
+++ b/xmlsecurity/source/component/documentdigitalsignatures.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: documentdigitalsignatures.hxx,v $
*
- * $Revision: 1.1.1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: mt $ $Date: 2004-07-12 13:15:24 $
+ * last change: $Author: mt $ $Date: 2004-07-14 11:05:45 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -65,6 +65,7 @@
#include <cppuhelper/implbase1.hxx>
#include <com/sun/star/security/XDocumentDigitalSignatures.hpp>
+#include <xmlsecurity/documentsignaturehelper.hxx>
class DocumentDigitalSignatures : public cppu::WeakImplHelper1
@@ -75,6 +76,9 @@ class DocumentDigitalSignatures : public cppu::WeakImplHelper1
private:
com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > mxMSF;
+ sal_Bool ImplViewSignatures( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& rxStorage, DocumentSignatureMode eMode, bool bReadOnly ) throw (::com::sun::star::uno::RuntimeException);
+ com::sun::star::uno::Sequence< ::com::sun::star::security::DocumentSignaturesInformation > ImplVerifySignatures( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& rxStorage, DocumentSignatureMode eMode ) throw (::com::sun::star::uno::RuntimeException);
+
public:
DocumentDigitalSignatures( const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory> rxMSF );
@@ -83,8 +87,15 @@ public:
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);
+ sal_Bool SAL_CALL SignDocumentContent( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& rxStorage ) throw (::com::sun::star::uno::RuntimeException);
+ com::sun::star::uno::Sequence< ::com::sun::star::security::DocumentSignaturesInformation > SAL_CALL VerifyDocumentContentSignatures( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& rxStorage ) throw (::com::sun::star::uno::RuntimeException);
+ void SAL_CALL ShowDocumentContentSignatures( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& Storage ) throw (::com::sun::star::uno::RuntimeException);
+ sal_Bool SAL_CALL SignScriptingContent( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& rxStorage ) throw (::com::sun::star::uno::RuntimeException);
+ com::sun::star::uno::Sequence< ::com::sun::star::security::DocumentSignaturesInformation > SAL_CALL VerifyScriptingContentSignatures( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& rxStorage ) throw (::com::sun::star::uno::RuntimeException);
+ void SAL_CALL ShowScriptingContentSignatures( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& Storage ) throw (::com::sun::star::uno::RuntimeException);
+ sal_Bool SAL_CALL SignPackage( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& rxStorage ) throw (::com::sun::star::uno::RuntimeException);
+ com::sun::star::uno::Sequence< ::com::sun::star::security::DocumentSignaturesInformation > SAL_CALL VerifyPackageSignatures( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& rxStorage ) throw (::com::sun::star::uno::RuntimeException);
+ void SAL_CALL ShowPackageSignatures( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& Storage ) throw (::com::sun::star::uno::RuntimeException);
};
diff --git a/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx b/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx
index bcabfa2b04c6..c1a617c82fab 100644
--- a/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx
+++ b/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: digitalsignaturesdialog.cxx,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: mt $ $Date: 2004-07-13 11:02:46 $
+ * last change: $Author: mt $ $Date: 2004-07-14 11:05:45 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -90,7 +90,7 @@ using namespace ::com::sun::star::security;
using namespace ::com::sun::star;
using namespace ::com::sun::star;
-DigitalSignaturesDialog::DigitalSignaturesDialog( Window* pParent, uno::Reference< lang::XMultiServiceFactory >& rxMSF, DocumentSignatureMode eMode )
+DigitalSignaturesDialog::DigitalSignaturesDialog( Window* pParent, uno::Reference< lang::XMultiServiceFactory >& rxMSF, DocumentSignatureMode eMode, sal_Bool bReadOnly )
:ModalDialog ( pParent, XMLSEC_RES( RID_XMLSECDLG_DIGSIG ) )
,maSignatureHelper ( rxMSF )
,meSignatureMode ( eMode )
@@ -112,6 +112,7 @@ DigitalSignaturesDialog::DigitalSignaturesDialog( Window* pParent, uno::Referenc
FreeResource();
mbVerifySignatures = true;
+ mbSignaturesChanged = false;
maSignaturesLB.SetSelectHdl( LINK( this, DigitalSignaturesDialog, SignatureHighlightHdl ) );
maSignaturesLB.SetDoubleClickHdl( LINK( this, DigitalSignaturesDialog, SignatureSelectHdl ) );
@@ -120,6 +121,8 @@ DigitalSignaturesDialog::DigitalSignaturesDialog( Window* pParent, uno::Referenc
maViewBtn.Disable();
maAddBtn.SetClickHdl( LINK( this, DigitalSignaturesDialog, AddButtonHdl ) );
+ if ( bReadOnly )
+ maAddBtn.Disable();
maRemoveBtn.SetClickHdl( LINK( this, DigitalSignaturesDialog, RemoveButtonHdl ) );
maRemoveBtn.Disable();
@@ -176,9 +179,11 @@ short DigitalSignaturesDialog::Execute()
IMPL_LINK( DigitalSignaturesDialog, SignatureHighlightHdl, void*, EMPTYARG )
{
- bool bSel = maSignaturesLB.FirstSelected() != 0;
+ bool bSel = maSignaturesLB.FirstSelected() ? true : false;
maViewBtn.Enable( bSel );
- maRemoveBtn.Enable( bSel );
+ if ( maAddBtn.IsEnabled() ) // not read only
+ maRemoveBtn.Enable( bSel );
+
return 0;
}
@@ -212,7 +217,7 @@ IMPL_LINK( DigitalSignaturesDialog, AddButtonHdl, Button*, EMPTYARG )
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 );
+ std::vector< rtl::OUString > aElements = DocumentSignatureHelper::CreateElementList( mxStore, rtl::OUString(), meSignatureMode );
::rtl::OUString aXMLExt( RTL_CONSTASCII_USTRINGPARAM( "XML" ) );
sal_Int32 nElements = aElements.size();
@@ -229,7 +234,7 @@ IMPL_LINK( DigitalSignaturesDialog, AddButtonHdl, Button*, EMPTYARG )
maSignatureHelper.AddForSigning( nSecurityId, aElements[n], aElements[n], bBinaryMode );
}
- SignatureStreamHelper aStreamHelper = OpenSignatureStream( mxStore, embed::ElementModes::WRITE|embed::ElementModes::TRUNCATE, meSignatureMode );
+ SignatureStreamHelper aStreamHelper = DocumentSignatureHelper::OpenSignatureStream( mxStore, embed::ElementModes::WRITE|embed::ElementModes::TRUNCATE, meSignatureMode );
uno::Reference< io::XOutputStream > xOutputStream( aStreamHelper.xSignatureStream, uno::UNO_QUERY );
uno::Reference< com::sun::star::xml::sax::XDocumentHandler> xDocumentHandler = maSignatureHelper.CreateDocumentHandlerWithHeader( xOutputStream );
@@ -239,28 +244,31 @@ IMPL_LINK( DigitalSignaturesDialog, AddButtonHdl, Button*, EMPTYARG )
maSignatureHelper.ExportSignature( xDocumentHandler, aCurrentSignatureInformations[n]);
// Create a new one...
- bool bDone = maSignatureHelper.CreateAndWriteSignatue( xDocumentHandler );
+ bool bDone = maSignatureHelper.CreateAndWriteSignature( xDocumentHandler );
// That's it...
maSignatureHelper.CloseDocumentHandler( xDocumentHandler);
- uno::Reference< embed::XTransactedObject > xTrans( aStreamHelper.xSignatureStorage, uno::UNO_QUERY );
- xTrans->commit();
-
- uno::Reference< embed::XTransactedObject > xTrans2( mxStore, uno::UNO_QUERY );
- xTrans2->commit();
-
- aStreamHelper.Dispose();
-
maSignatureHelper.EndMission();
if ( bDone )
{
+ uno::Reference< embed::XTransactedObject > xTrans( aStreamHelper.xSignatureStorage, uno::UNO_QUERY );
+ xTrans->commit();
+
+ uno::Reference< embed::XTransactedObject > xTrans2( mxStore, uno::UNO_QUERY );
+ xTrans2->commit();
+
+ aStreamHelper.Clear();
+
+ mbSignaturesChanged = true;
+
// Can't simply remember current information, need parsing for getting full information :(
ImplGetSignatureInformations();
ImplFillSignaturesBox();
}
+ aStreamHelper.Clear();
}
}
catch (NoPasswordException&)
@@ -278,7 +286,7 @@ IMPL_LINK( DigitalSignaturesDialog, RemoveButtonHdl, Button*, EMPTYARG )
aCurrentSignatureInformations.erase( aCurrentSignatureInformations.begin()+nSelected );
// Export all other signatures...
- SignatureStreamHelper aStreamHelper = OpenSignatureStream( mxStore, embed::ElementModes::WRITE|embed::ElementModes::TRUNCATE, meSignatureMode );
+ SignatureStreamHelper aStreamHelper = DocumentSignatureHelper::OpenSignatureStream( mxStore, embed::ElementModes::WRITE|embed::ElementModes::TRUNCATE, meSignatureMode );
uno::Reference< io::XOutputStream > xOutputStream( aStreamHelper.xSignatureStream, uno::UNO_QUERY );
uno::Reference< com::sun::star::xml::sax::XDocumentHandler> xDocumentHandler = maSignatureHelper.CreateDocumentHandlerWithHeader( xOutputStream );
@@ -294,7 +302,9 @@ IMPL_LINK( DigitalSignaturesDialog, RemoveButtonHdl, Button*, EMPTYARG )
uno::Reference< embed::XTransactedObject > xTrans2( mxStore, uno::UNO_QUERY );
xTrans2->commit();
- aStreamHelper.Dispose();
+ mbSignaturesChanged = true;
+
+ aStreamHelper.Clear();
ImplFillSignaturesBox();
}
@@ -358,17 +368,17 @@ void DigitalSignaturesDialog::ImplGetSignatureInformations()
maSignatureHelper.StartMission();
- SignatureStreamHelper aStreamHelper = OpenSignatureStream( mxStore, embed::ElementModes::READ, meSignatureMode );
+ SignatureStreamHelper aStreamHelper = DocumentSignatureHelper::OpenSignatureStream( mxStore, embed::ElementModes::READ, meSignatureMode );
if ( aStreamHelper.xSignatureStream.is() )
{
uno::Reference< io::XInputStream > xInputStream( aStreamHelper.xSignatureStream, uno::UNO_QUERY );
- bool bVerifyOK = maSignatureHelper.ReadAndVerifySignatue( xInputStream );
+ bool bVerifyOK = maSignatureHelper.ReadAndVerifySignature( xInputStream );
if ( bVerifyOK )
aCurrentSignatureInformations = maSignatureHelper.GetSignatureInformations();
}
- aStreamHelper.Dispose();
+ aStreamHelper.Clear();
maSignatureHelper.EndMission();
@@ -394,156 +404,3 @@ void DigitalSignaturesDialog::ImplShowSignaturesDetails()
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;
-}
-
-SignatureStreamHelper DigitalSignaturesDialog::OpenSignatureStream( uno::Reference < embed::XStorage >& rxStore, sal_Int32 nOpenMode, DocumentSignatureMode eDocSigMode )
-{
- sal_Int32 nSubStorageOpenMode = embed::ElementModes::READ;
- if ( nOpenMode & embed::ElementModes::WRITE )
- nSubStorageOpenMode = embed::ElementModes::WRITE;
-
- SignatureStreamHelper aHelper;
-
- try
- {
- ::rtl::OUString aSIGStoreName( RTL_CONSTASCII_USTRINGPARAM( "META-INF" ) );
- aHelper.xSignatureStorage = rxStore->openStorageElement( aSIGStoreName, nSubStorageOpenMode );
- if ( aHelper.xSignatureStorage.is() )
- {
- ::rtl::OUString aSIGStreamName;
- if ( eDocSigMode == SignatureModeDocumentContent )
- aSIGStreamName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DocumentSignatures.xml" ) );
- else if ( eDocSigMode == SignatureModeMacros )
- aSIGStreamName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MacroSignatures.xml" ) );
- else
- aSIGStreamName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PackageSignatures.xml" ) );
-
- aHelper.xSignatureStream = aHelper.xSignatureStorage->openStreamElement( aSIGStreamName, nOpenMode );
- }
- }
- catch( com::sun::star::io::IOException& )
- {
- // Doesn't have to exist...
- DBG_ASSERT( nOpenMode == embed::ElementModes::READ, "Error creating signature stream..." );
- }
-
- return aHelper;
-}
-
-void SignatureStreamHelper::Dispose()
-{
- if ( xSignatureStorage.is() )
- {
- try
- {
- uno::Reference< lang::XComponent > xComp( xSignatureStorage, uno::UNO_QUERY );
- xComp->dispose();
- }
- catch ( lang::DisposedException )
- {
- }
- }
-
- if ( xSignatureStream.is() )
- {
- try
- {
- uno::Reference< lang::XComponent > xComp( xSignatureStream, uno::UNO_QUERY );
- xComp->dispose();
- }
- catch ( lang::DisposedException )
- {
- }
- }
-} \ No newline at end of file
diff --git a/xmlsecurity/source/helper/documentsignaturehelper.cxx b/xmlsecurity/source/helper/documentsignaturehelper.cxx
new file mode 100644
index 000000000000..931162e7fcb0
--- /dev/null
+++ b/xmlsecurity/source/helper/documentsignaturehelper.cxx
@@ -0,0 +1,235 @@
+/*************************************************************************
+ *
+ * $RCSfile: documentsignaturehelper.cxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: mt $ $Date: 2004-07-14 11:06:31 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <xmlsecurity/documentsignaturehelper.hxx>
+
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/lang/DisposedException.hpp>
+
+#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 <tools/debug.hxx>
+
+using namespace ::com::sun::star;
+
+
+void ImplFillElementList( std::vector< rtl::OUString >& rList, const 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 > DocumentSignatureHelper::CreateElementList( const 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;
+}
+
+SignatureStreamHelper DocumentSignatureHelper::OpenSignatureStream( const uno::Reference < embed::XStorage >& rxStore, sal_Int32 nOpenMode, DocumentSignatureMode eDocSigMode )
+{
+ sal_Int32 nSubStorageOpenMode = embed::ElementModes::READ;
+ if ( nOpenMode & embed::ElementModes::WRITE )
+ nSubStorageOpenMode = embed::ElementModes::WRITE;
+
+ SignatureStreamHelper aHelper;
+
+ try
+ {
+ ::rtl::OUString aSIGStoreName( RTL_CONSTASCII_USTRINGPARAM( "META-INF" ) );
+ aHelper.xSignatureStorage = rxStore->openStorageElement( aSIGStoreName, nSubStorageOpenMode );
+ if ( aHelper.xSignatureStorage.is() )
+ {
+ ::rtl::OUString aSIGStreamName;
+ if ( eDocSigMode == SignatureModeDocumentContent )
+ aSIGStreamName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DocumentSignatures.xml" ) );
+ else if ( eDocSigMode == SignatureModeMacros )
+ aSIGStreamName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MacroSignatures.xml" ) );
+ else
+ aSIGStreamName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PackageSignatures.xml" ) );
+
+ aHelper.xSignatureStream = aHelper.xSignatureStorage->openStreamElement( aSIGStreamName, nOpenMode );
+ }
+ }
+ catch( com::sun::star::io::IOException& )
+ {
+ // Doesn't have to exist...
+ DBG_ASSERT( nOpenMode == embed::ElementModes::READ, "Error creating signature stream..." );
+ }
+
+ return aHelper;
+}
+
+void SignatureStreamHelper::Clear()
+{
+ // MT: bug in storage implementation, shouldn't be necessary
+ if ( xSignatureStorage.is() )
+ {
+ try
+ {
+ uno::Reference< lang::XComponent > xComp( xSignatureStorage, uno::UNO_QUERY );
+ xComp->dispose();
+ }
+ catch ( lang::DisposedException )
+ {
+ }
+ }
+
+ if ( xSignatureStream.is() )
+ {
+ try
+ {
+ uno::Reference< lang::XComponent > xComp( xSignatureStream, uno::UNO_QUERY );
+ xComp->dispose();
+ }
+ catch ( lang::DisposedException )
+ {
+ }
+ }
+
+ xSignatureStream = NULL;
+ xSignatureStorage = NULL;
+}
diff --git a/xmlsecurity/source/helper/makefile.mk b/xmlsecurity/source/helper/makefile.mk
index 0d5fec4a5bdb..b896d18927d2 100644
--- a/xmlsecurity/source/helper/makefile.mk
+++ b/xmlsecurity/source/helper/makefile.mk
@@ -2,9 +2,9 @@
#
# $RCSfile: makefile.mk,v $
#
-# $Revision: 1.1.1.1 $
+# $Revision: 1.2 $
#
-# last change: $Author: mt $ $Date: 2004-07-12 13:15:22 $
+# last change: $Author: mt $ $Date: 2004-07-14 11:05:46 $
#
# The Contents of this file are made available subject to the terms of
# either of the following licenses
@@ -77,6 +77,7 @@ ENABLE_EXCEPTIONS=TRUE
# --- Files --------------------------------------------------------
SLOFILES= \
+ $(SLO)$/documentsignaturehelper.obj \
$(SLO)$/xmlsignaturehelper.obj \
$(SLO)$/xmlsignaturehelper2.obj \
$(SLO)$/xsecctl.obj \
diff --git a/xmlsecurity/source/helper/xmlsignaturehelper.cxx b/xmlsecurity/source/helper/xmlsignaturehelper.cxx
index ffca2ddb6c78..3b3a4befe741 100644
--- a/xmlsecurity/source/helper/xmlsignaturehelper.cxx
+++ b/xmlsecurity/source/helper/xmlsignaturehelper.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: xmlsignaturehelper.cxx,v $
*
- * $Revision: 1.1.1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: mt $ $Date: 2004-07-12 13:15:22 $
+ * last change: $Author: mt $ $Date: 2004-07-14 11:05:46 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -230,7 +230,7 @@ void XMLSignatureHelper::ExportSignature(
mpXSecController->exportSignature(xDocumentHandler, signatureInfo);
}
-bool XMLSignatureHelper::CreateAndWriteSignatue( const uno::Reference< xml::sax::XDocumentHandler >& xDocumentHandler )
+bool XMLSignatureHelper::CreateAndWriteSignature( const uno::Reference< xml::sax::XDocumentHandler >& xDocumentHandler )
{
mbError = false;
@@ -250,7 +250,7 @@ bool XMLSignatureHelper::CreateAndWriteSignatue( const uno::Reference< xml::sax:
/*
* write signatures
*/
- if ( !mpXSecController->WriteSignatue( xDocumentHandler ) )
+ if ( !mpXSecController->WriteSignature( xDocumentHandler ) )
{
mbError = true;
}
@@ -263,19 +263,19 @@ bool XMLSignatureHelper::CreateAndWriteSignatue( const uno::Reference< xml::sax:
return !mbError;
}
-bool XMLSignatureHelper::CreateAndWriteSignatue( const com::sun::star::uno::Reference< com::sun::star::io::XOutputStream >& xOutputStream )
+bool XMLSignatureHelper::CreateAndWriteSignature( const com::sun::star::uno::Reference< com::sun::star::io::XOutputStream >& xOutputStream )
{
uno::Reference<xml::sax::XDocumentHandler> xDocHandler
= CreateDocumentHandlerWithHeader(xOutputStream);
- bool rc = CreateAndWriteSignatue( xDocHandler );
+ bool rc = CreateAndWriteSignature( xDocHandler );
CloseDocumentHandler(xDocHandler);
return rc;
}
-bool XMLSignatureHelper::ReadAndVerifySignatue( const com::sun::star::uno::Reference< com::sun::star::io::XInputStream >& xInputStream )
+bool XMLSignatureHelper::ReadAndVerifySignature( const com::sun::star::uno::Reference< com::sun::star::io::XInputStream >& xInputStream )
{
mbError = false;
diff --git a/xmlsecurity/source/helper/xsecctl.hxx b/xmlsecurity/source/helper/xsecctl.hxx
index 7d3a939f93af..7e2cc53f38cc 100644
--- a/xmlsecurity/source/helper/xsecctl.hxx
+++ b/xmlsecurity/source/helper/xsecctl.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: xsecctl.hxx,v $
*
- * $Revision: 1.1.1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: mt $ $Date: 2004-07-12 13:15:22 $
+ * last change: $Author: mt $ $Date: 2004-07-14 11:05:46 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -510,7 +510,7 @@ public:
const rtl::OUString& ouDate,
const rtl::OUString& ouTime);
- bool WriteSignatue(
+ bool WriteSignature(
const com::sun::star::uno::Reference<
com::sun::star::xml::sax::XDocumentHandler >& xDocumentHandler );
diff --git a/xmlsecurity/source/helper/xsecsign.cxx b/xmlsecurity/source/helper/xsecsign.cxx
index 8b5bfaa1653e..50603a155ab6 100644
--- a/xmlsecurity/source/helper/xsecsign.cxx
+++ b/xmlsecurity/source/helper/xsecsign.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: xsecsign.cxx,v $
*
- * $Revision: 1.1.1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: mt $ $Date: 2004-07-12 13:15:22 $
+ * last change: $Author: mt $ $Date: 2004-07-14 11:05:46 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -319,7 +319,7 @@ void XSecController::setDateTime(
}
}
-bool XSecController::WriteSignatue(
+bool XSecController::WriteSignature(
const cssu::Reference<cssxs::XDocumentHandler>& xDocumentHandler )
{
bool rc = false;
diff --git a/xmlsecurity/util/makefile.mk b/xmlsecurity/util/makefile.mk
index d2dd3b6fd210..8af5a1ffb6a1 100644
--- a/xmlsecurity/util/makefile.mk
+++ b/xmlsecurity/util/makefile.mk
@@ -2,9 +2,9 @@
#
# $RCSfile: makefile.mk,v $
#
-# $Revision: 1.3 $
+# $Revision: 1.4 $
#
-# last change: $Author: mmi $ $Date: 2004-07-14 10:44:22 $
+# last change: $Author: mt $ $Date: 2004-07-14 11:05:46 $
#
# The Contents of this file are made available subject to the terms of
# either of the following licenses
@@ -177,7 +177,11 @@ SHL4STDLIBS=\
.IF "$(GUI)"=="WNT"
SHL4STDLIBS+= "xmlsec.lib" "xsec_xmlsec.lib"
.ELSE
+<<<<<<< makefile.mk
+SHL4STDLIBS+= "-lxmlsec" "-lxsec_xmlsec"
+=======
SHL4STDLIBS+= "-lxmlsec" "-lxsec_xmlsec"
+>>>>>>> 1.2
.ENDIF
diff --git a/xmlsecurity/workben/makefile.mk b/xmlsecurity/workben/makefile.mk
index 9cdebf08a559..db7abe2f8150 100644
--- a/xmlsecurity/workben/makefile.mk
+++ b/xmlsecurity/workben/makefile.mk
@@ -2,9 +2,9 @@
#
# $RCSfile: makefile.mk,v $
#
-# $Revision: 1.1.1.1 $
+# $Revision: 1.2 $
#
-# last change: $Author: mt $ $Date: 2004-07-12 13:15:31 $
+# last change: $Author: mt $ $Date: 2004-07-14 11:05:47 $
#
# The Contents of this file are made available subject to the terms of
# either of the following licenses
@@ -101,7 +101,8 @@ APP1STDLIBS= $(CPPULIB) \
$(SVXLIB)
.IF "$(GUI)"=="WNT"
-APP1STDLIBS+= "ixml2.lib" "nss3.lib" "nspr4.lib" "xmlsec.lib" "helper.lib" "dialogs.lib" "xsec_xmlsec.lib"
+#APP1STDLIBS+= "xmlsec.lib" "helper.lib" "dialogs.lib" "xsec_xmlsec.lib"
+APP1STDLIBS+= "xsec_xmlsec.lib"
.ELSE
APP1STDLIBS+= "-lxml2" "-lnss3" "-lnspr4" "-lxmlsec" "-lhelper" "-ldialogs" "-lxsec_xmlsec"
.ENDIF
diff --git a/xmlsecurity/workben/signaturetest.cxx b/xmlsecurity/workben/signaturetest.cxx
index 2d5719cb4877..be0d061f87bc 100644
--- a/xmlsecurity/workben/signaturetest.cxx
+++ b/xmlsecurity/workben/signaturetest.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: signaturetest.cxx,v $
*
- * $Revision: 1.1.1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: mt $ $Date: 2004-07-12 13:15:31 $
+ * last change: $Author: mt $ $Date: 2004-07-14 11:05:47 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -113,7 +113,7 @@ void Main();
#define LISTBOXHEIGHT 120
-bool bStoreSignatureInStorage = false;
+// #define TEST_IMPLEMENTATION_DIRECTLY
// -----------------------------------------------------------------------
@@ -186,6 +186,7 @@ private:
FixedText maFixedTextDOCFileName;
FileControl maEditDOCFileName;
PushButton maDigitalSignaturesButton;
+ PushButton maVerifyDigitalSignaturesButton;
FixedLine maHintLine;
FixedText maHintText;
@@ -193,6 +194,7 @@ private:
DECL_LINK( SignButtonHdl, Button* );
DECL_LINK( VerifyButtonHdl, Button* );
DECL_LINK( DigitalSignaturesWithServiceHdl, Button* );
+ DECL_LINK( VerifyDigitalSignaturesHdl, Button* );
DECL_LINK( DigitalSignaturesWithTokenHdl, Button* );
DECL_LINK( StartVerifySignatureHdl, void* );
@@ -232,11 +234,16 @@ MyWin::MyWin( Window* pParent, WinBits nWinStyle ) :
maSignButton( this ),
maVerifyButton( this ),
maDigitalSignaturesButton( this ),
+ maVerifyDigitalSignaturesButton( this ),
maHintText( this, WB_WORDBREAK ),
maCryptoCheckBox( this )
{
+#ifdef TEST_IMPLEMENTATION_DIRECTLY
Size aOutputSize( 400, 600 );
+#else
+ Size aOutputSize( 400, 400 );
+#endif
SetOutputSizePixel( aOutputSize );
SetText( String( RTL_CONSTASCII_USTRINGPARAM( "XML Signature Test" ) ) );
@@ -249,13 +256,11 @@ MyWin::MyWin( Window* pParent, WinBits nWinStyle ) :
nY += EDITHEIGHT*3/2;
maCryptoCheckBox.SetPosSizePixel( TEXTFIELDSTARTX, nY, aOutputSize.Width()-2*TEXTFIELDSTARTX, FIXEDLINEHEIGHT );
- maCryptoCheckBox.SetText( String( RTL_CONSTASCII_USTRINGPARAM( "Use Default Token" ) ) );
+ maCryptoCheckBox.SetText( String( RTL_CONSTASCII_USTRINGPARAM( "Use Default Token (NSS option only)" ) ) );
maCryptoCheckBox.Check( TRUE );
maEditTokenName.Disable();
maFixedTextTokenName.Disable();
maCryptoCheckBox.SetClickHdl( LINK( this, MyWin, CryptoCheckBoxHdl ) );
-
-
maCryptoCheckBox.Show();
nY += EDITHEIGHT;
@@ -269,8 +274,10 @@ MyWin::MyWin( Window* pParent, WinBits nWinStyle ) :
nY += EDITHEIGHT*3;
+#ifdef TEST_IMPLEMENTATION_DIRECTLY
+
maTest1Line.SetPosSizePixel( TEXTFIELDSTARTX, nY, aOutputSize.Width()-2*TEXTFIELDSTARTX, FIXEDLINEHEIGHT );
- maTest1Line.SetText( String( RTL_CONSTASCII_USTRINGPARAM( "Test 1 - Simple Files" ) ) );
+ maTest1Line.SetText( String( RTL_CONSTASCII_USTRINGPARAM( "Test simple files" ) ) );
maTest1Line.Show();
nY += EDITHEIGHT*3/2;
@@ -314,12 +321,15 @@ MyWin::MyWin( Window* pParent, WinBits nWinStyle ) :
nY += EDITHEIGHT*3;
+#endif // TEST_IMPLEMENTATION_DIRECTLY
+
maTest2Line.SetPosSizePixel( TEXTFIELDSTARTX, nY, aOutputSize.Width()-2*TEXTFIELDSTARTX, FIXEDLINEHEIGHT );
- maTest2Line.SetText( String( RTL_CONSTASCII_USTRINGPARAM( "Test 2 - Office Document" ) ) );
+ maTest2Line.SetText( String( RTL_CONSTASCII_USTRINGPARAM( "Test Office Document" ) ) );
maTest2Line.Show();
nY += EDITHEIGHT*3/2;
+
maFixedTextDOCFileName.SetPosSizePixel( TEXTFIELDSTARTX, nY, TEXTFIELDWIDTH, EDITHEIGHT );
maFixedTextDOCFileName.SetText( String( RTL_CONSTASCII_USTRINGPARAM( "Office File:" ) ) );
maFixedTextDOCFileName.Show();
@@ -334,7 +344,12 @@ MyWin::MyWin( Window* pParent, WinBits nWinStyle ) :
maDigitalSignaturesButton.SetClickHdl( LINK( this, MyWin, DigitalSignaturesWithServiceHdl ) );
maDigitalSignaturesButton.Show();
- nY += EDITHEIGHT*3;
+ maVerifyDigitalSignaturesButton.SetPosSizePixel( TEXTFIELDSTARTX+BUTTONWIDTH*2+BUTTONSPACE, nY, BUTTONWIDTH*2, BUTTONHEIGHT );
+ maVerifyDigitalSignaturesButton.SetText( String( RTL_CONSTASCII_USTRINGPARAM( "Verify Signatures" ) ) );
+ maVerifyDigitalSignaturesButton.SetClickHdl( LINK( this, MyWin, VerifyDigitalSignaturesHdl ) );
+ maVerifyDigitalSignaturesButton.Show();
+
+ nY += EDITHEIGHT*2;
maHintLine.SetPosSizePixel( TEXTFIELDSTARTX, nY, aOutputSize.Width()-2*TEXTFIELDSTARTX, FIXEDLINEHEIGHT );
maHintLine.Show();
@@ -357,6 +372,13 @@ MyWin::MyWin( Window* pParent, WinBits nWinStyle ) :
maEditDOCFileName.SetText( aNSSFolder + String( RTL_CONSTASCII_USTRINGPARAM( "demo-sample.sxw" ) ) );
maEditSIGFileName.SetText( aNSSFolder + String( RTL_CONSTASCII_USTRINGPARAM( "demo-result.xml" ) ) );
maEditTokenName.SetText( aNSSFolder );
+
+#ifdef WNT
+ maEditTokenName.SetText( String() );
+ maEditTokenName.Disable();
+ maCryptoCheckBox.Disable();
+#endif
+
}
IMPL_LINK( MyWin, CryptoCheckBoxHdl, CheckBox*, EMPTYARG )
@@ -374,6 +396,67 @@ IMPL_LINK( MyWin, CryptoCheckBoxHdl, CheckBox*, EMPTYARG )
return 1;
}
+IMPL_LINK( MyWin, DigitalSignaturesWithServiceHdl, Button*, EMPTYARG )
+{
+ rtl::OUString aDocFileName = maEditDOCFileName.GetText();
+ uno::Reference < embed::XStorage > xStore = ::comphelper::OStorageHelper::GetStorageFromURL(
+ aDocFileName, embed::ElementModes::READWRITE, comphelper::getProcessServiceFactory() );
+
+ uno::Reference< security::XDocumentDigitalSignatures > xD(
+ comphelper::getProcessServiceFactory()->createInstance( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.security.DocumentDigitalSignatures" ) ) ), uno::UNO_QUERY );
+ if ( xD.is() )
+ xD->SignDocumentContent( xStore );
+
+
+ return 0;
+}
+
+IMPL_LINK( MyWin, VerifyDigitalSignaturesHdl, Button*, EMPTYARG )
+{
+ rtl::OUString aDocFileName = maEditDOCFileName.GetText();
+ uno::Reference < embed::XStorage > xStore = ::comphelper::OStorageHelper::GetStorageFromURL(
+ aDocFileName, embed::ElementModes::READWRITE, comphelper::getProcessServiceFactory() );
+
+ uno::Reference< security::XDocumentDigitalSignatures > xD(
+ comphelper::getProcessServiceFactory()->createInstance( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.security.DocumentDigitalSignatures" ) ) ), uno::UNO_QUERY );
+ if ( xD.is() )
+ {
+ com::sun::star::uno::Sequence< ::com::sun::star::security::DocumentSignaturesInformation > aInfos = xD->VerifyDocumentContentSignatures( xStore );
+ // ...
+
+ }
+
+
+ return 0;
+}
+
+
+#ifdef TEST_IMPLEMENTATION_DIRECTLY
+
+IMPL_LINK( MyWin, DigitalSignaturesWithTokenHdl, Button*, EMPTYARG )
+{
+ String aDocFileName = maEditDOCFileName.GetText();
+ String aTokenFileName = maEditTokenName.GetText();
+
+ DigitalSignaturesDialog aSignaturesDialog( this, comphelper::getProcessServiceFactory(), SignatureModeDocumentContent, false );
+
+ bool bInit = aSignaturesDialog.Init( aTokenFileName );
+ if ( !bInit )
+ {
+ ErrorBox( this, WB_OK, String( RTL_CONSTASCII_USTRINGPARAM( "Error initializing security context!" ) ) ).Execute();
+ return 0;
+ }
+
+ uno::Reference < embed::XStorage > xStore = ::comphelper::OStorageHelper::GetStorageFromURL(
+ aDocFileName, embed::ElementModes::READWRITE, comphelper::getProcessServiceFactory() );
+
+ aSignaturesDialog.SetStorage( xStore );
+
+ aSignaturesDialog.Execute();
+
+ return 0;
+}
+
IMPL_LINK( MyWin, SignButtonHdl, Button*, EMPTYARG )
{
String aXMLFileName = maEditXMLFileName.GetText();
@@ -414,7 +497,7 @@ IMPL_LINK( MyWin, SignButtonHdl, Button*, EMPTYARG )
SvFileStream* pStream = new SvFileStream( aSIGFileName, STREAM_WRITE );
SvLockBytesRef xLockBytes = new SvLockBytes( pStream, TRUE );
uno::Reference< io::XOutputStream > xOutputStream = new utl::OOutputStreamHelper( xLockBytes );
- bool bDone = aSignatureHelper.CreateAndWriteSignatue( xOutputStream );
+ bool bDone = aSignatureHelper.CreateAndWriteSignature( xOutputStream );
aSignatureHelper.EndMission();
@@ -465,7 +548,7 @@ IMPL_LINK( MyWin, VerifyButtonHdl, Button*, EMPTYARG )
pStream->Seek( STREAM_SEEK_TO_BEGIN );
SvLockBytesRef xLockBytes = new SvLockBytes( pStream, TRUE );
uno::Reference< io::XInputStream > xInputStream = new utl::OInputStreamHelper( xLockBytes, nBytes );
- bool bDone = aSignatureHelper.ReadAndVerifySignatue( xInputStream );
+ bool bDone = aSignatureHelper.ReadAndVerifySignature( xInputStream );
xInputStream->closeInput();
aSignatureHelper.EndMission();
@@ -484,60 +567,5 @@ IMPL_LINK( MyWin, StartVerifySignatureHdl, void*, EMPTYARG )
return ( aQueryBox.Execute() == RET_YES ) ? 1 : 0;
}
-IMPL_LINK( MyWin, DigitalSignaturesWithServiceHdl, Button*, EMPTYARG )
-{
- rtl::OUString aDocFileName = maEditDOCFileName.GetText();
- rtl::OUString aSigFileName;
-
- String aTokenFileName;
- if ( !maCryptoCheckBox.IsChecked() )
- aTokenFileName = maEditTokenName.GetText();
-
- uno::Reference < embed::XStorage > xStore = ::comphelper::OStorageHelper::GetStorageFromURL(
- aDocFileName, embed::ElementModes::READWRITE, comphelper::getProcessServiceFactory() );
-
- if ( !bStoreSignatureInStorage )
- {
- aSigFileName = aDocFileName;
- aSigFileName += String( RTL_CONSTASCII_USTRINGPARAM( ".signature" ) );
- }
-
- uno::Reference< security::XDocumentDigitalSignatures > xD(
- comphelper::getProcessServiceFactory()->createInstance( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.security.DocumentDigitalSignatures" ) ) ), uno::UNO_QUERY );
- if ( xD.is() )
- xD->SignDocumentContent( xStore, aSigFileName, aTokenFileName );
-
-
- return 0;
-}
-
-IMPL_LINK( MyWin, DigitalSignaturesWithTokenHdl, Button*, EMPTYARG )
-{
- String aDocFileName = maEditDOCFileName.GetText();
- String aTokenFileName = maEditTokenName.GetText();
-
- DigitalSignaturesDialog aSignaturesDialog( this, comphelper::getProcessServiceFactory(), SignatureModeDocumentContent );
-
- bool bInit = aSignaturesDialog.Init( aTokenFileName );
- if ( !bInit )
- {
- ErrorBox( this, WB_OK, String( RTL_CONSTASCII_USTRINGPARAM( "Error initializing security context!" ) ) ).Execute();
- return 0;
- }
-
- uno::Reference < embed::XStorage > xStore = ::comphelper::OStorageHelper::GetStorageFromURL(
- aDocFileName, embed::ElementModes::READWRITE, comphelper::getProcessServiceFactory() );
-
- aSignaturesDialog.SetStorage( xStore );
-
- if ( !bStoreSignatureInStorage )
- {
- rtl::OUString aSigFileName( aDocFileName );
- aSigFileName += String( RTL_CONSTASCII_USTRINGPARAM( ".signature" ) );
- aSignaturesDialog.SetSignatureFileName( aSigFileName );
- }
- aSignaturesDialog.Execute();
-
- return 0;
-}
+#endif // #ifdef TEST_IMPLEMENTATION_DIRECTLY