Kaydet (Commit) 9a4ece8a authored tarafından Malte Timmermann's avatar Malte Timmermann

component...

üst f8ceb18d
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
* *
* $RCSfile: digitalsignaturesdialog.hxx,v $ * $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 * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
...@@ -67,6 +67,7 @@ ...@@ -67,6 +67,7 @@
#include <vcl/button.hxx> #include <vcl/button.hxx>
#include <svx/simptabl.hxx> #include <svx/simptabl.hxx>
#include <xmlsecurity/documentsignaturehelper.hxx>
#include <xmlsecurity/xmlsignaturehelper.hxx> #include <xmlsecurity/xmlsignaturehelper.hxx>
#ifndef _STLP_VECTOR #ifndef _STLP_VECTOR
...@@ -89,16 +90,6 @@ namespace cssu = com::sun::star::uno; ...@@ -89,16 +90,6 @@ namespace cssu = com::sun::star::uno;
class HeaderBar; 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 class DigitalSignaturesDialog : public ModalDialog
{ {
private: private:
...@@ -108,6 +99,7 @@ private: ...@@ -108,6 +99,7 @@ private:
css::uno::Reference < css::embed::XStorage > mxStore; css::uno::Reference < css::embed::XStorage > mxStore;
SignatureInformations aCurrentSignatureInformations; SignatureInformations aCurrentSignatureInformations;
bool mbVerifySignatures; bool mbVerifySignatures;
bool mbSignaturesChanged;
DocumentSignatureMode meSignatureMode; DocumentSignatureMode meSignatureMode;
// HACK, until sig in storage works // HACK, until sig in storage works
...@@ -139,7 +131,7 @@ private: ...@@ -139,7 +131,7 @@ private:
void ImplShowSignaturesDetails(); void ImplShowSignaturesDetails();
public: 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(); ~DigitalSignaturesDialog();
// Initialize the dialog and the security environment, returns TRUE on success // Initialize the dialog and the security environment, returns TRUE on success
...@@ -151,11 +143,11 @@ public: ...@@ -151,11 +143,11 @@ public:
// HACK: Set a signature file name, use this until sig in storage works! // HACK: Set a signature file name, use this until sig in storage works!
void SetSignatureFileName( const rtl::OUString& rName ) { maSigFileName = rName; } void SetSignatureFileName( const rtl::OUString& rName ) { maSigFileName = rName; }
// Execute the dialog... // Execute the dialog...
short Execute(); short Execute();
static SignatureStreamHelper OpenSignatureStream( css::uno::Reference < css::embed::XStorage >& rxStore, sal_Int32 nOpenMode, DocumentSignatureMode eDocSigMode ); // Did signatures change?
static std::vector< rtl::OUString > CreateElementList( css::uno::Reference < css::embed::XStorage >& rxStore, const ::rtl::OUString rRootStorageName, DocumentSignatureMode eMode ); sal_Bool SignaturesChanged() const { return mbSignaturesChanged; }
}; };
#endif // _XMLSECURITY_DIGITALSIGNATURESDIALOG_HXX #endif // _XMLSECURITY_DIGITALSIGNATURESDIALOG_HXX
......
/*************************************************************************
*
* $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
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
* *
* $RCSfile: xmlsignaturehelper.hxx,v $ * $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 * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
...@@ -182,7 +182,7 @@ public: ...@@ -182,7 +182,7 @@ public:
// Argument for the Link is a uno::Reference< xml::sax::XAttributeList >* // Argument for the Link is a uno::Reference< xml::sax::XAttributeList >*
// Return 1 to verify, 0 to skip. // Return 1 to verify, 0 to skip.
// Default will verify all. // Default handler will verify all.
void SetStartVerifySignatureHdl( const Link& rLink ); void SetStartVerifySignatureHdl( const Link& rLink );
// Get the security environment // Get the security environment
...@@ -199,9 +199,9 @@ public: ...@@ -199,9 +199,9 @@ public:
void SetDateTime( sal_Int32 nSecurityId, const rtl::OUString& ouDate, const rtl::OUString& ouTime); 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 ); 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 CreateAndWriteSignature( 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 CreateAndWriteSignature( 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 ReadAndVerifySignature( const com::sun::star::uno::Reference< com::sun::star::io::XInputStream >& xInputStream );
// MT: ??? I think only for adding/removing, not for new signatures... // 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 // MM: Yes, but if you want to insert a new signature into an existing signature file, those function
......
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
* *
* $RCSfile: documentdigitalsignatures.cxx,v $ * $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 * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
...@@ -66,6 +66,10 @@ ...@@ -66,6 +66,10 @@
#ifndef _COM_SUN_STAR_EMBED_XSTORAGE_HPP_ #ifndef _COM_SUN_STAR_EMBED_XSTORAGE_HPP_
#include <com/sun/star/embed/XStorage.hpp> #include <com/sun/star/embed/XStorage.hpp>
#endif #endif
#ifndef _COM_SUN_STAR_EMBED_ELEMENTMODES_HPP_
#include <com/sun/star/embed/ElementModes.hpp>
#endif
using namespace ::com::sun::star; using namespace ::com::sun::star;
...@@ -77,28 +81,99 @@ DocumentDigitalSignatures::DocumentDigitalSignatures( const com::sun::star::uno: ...@@ -77,28 +81,99 @@ DocumentDigitalSignatures::DocumentDigitalSignatures( const com::sun::star::uno:
mxMSF = rxMSF; 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!" ); DBG_ASSERT( bInit, "Error initializing security context!" );
if ( bInit ) if ( bInit )
{ {
aSignaturesDialog.SetStorage( rxStorage ); aSignaturesDialog.SetStorage( rxStorage );
aSignaturesDialog.SetSignatureFileName( rStorageName );
aSignaturesDialog.Execute(); 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; ::com::sun::star::uno::Sequence< ::com::sun::star::security::DocumentSignaturesInformation > aInfos;
return aInfos; return aInfos;
} }
rtl::OUString DocumentDigitalSignatures::GetImplementationName() throw (uno::RuntimeException) rtl::OUString DocumentDigitalSignatures::GetImplementationName() throw (uno::RuntimeException)
...@@ -106,7 +181,7 @@ rtl::OUString DocumentDigitalSignatures::GetImplementationName() throw (uno::Run ...@@ -106,7 +181,7 @@ rtl::OUString DocumentDigitalSignatures::GetImplementationName() throw (uno::Run
return rtl::OUString ( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.security.DocumentDigitalSignatures" ) ); 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); uno::Sequence < rtl::OUString > aRet(1);
rtl::OUString* pArray = aRet.getArray(); rtl::OUString* pArray = aRet.getArray();
...@@ -115,9 +190,8 @@ uno::Sequence< rtl::OUString > SAL_CALL DocumentDigitalSignatures::GetSupportedS ...@@ -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 ) const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& rSMgr) throw ( com::sun::star::uno::Exception )
{ {
return (cppu::OWeakObject*) new DocumentDigitalSignatures( rSMgr ); return (cppu::OWeakObject*) new DocumentDigitalSignatures( rSMgr );
} }
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
* *
* $RCSfile: documentdigitalsignatures.hxx,v $ * $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 * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
...@@ -65,6 +65,7 @@ ...@@ -65,6 +65,7 @@
#include <cppuhelper/implbase1.hxx> #include <cppuhelper/implbase1.hxx>
#include <com/sun/star/security/XDocumentDigitalSignatures.hpp> #include <com/sun/star/security/XDocumentDigitalSignatures.hpp>
#include <xmlsecurity/documentsignaturehelper.hxx>
class DocumentDigitalSignatures : public cppu::WeakImplHelper1 class DocumentDigitalSignatures : public cppu::WeakImplHelper1
...@@ -75,6 +76,9 @@ class DocumentDigitalSignatures : public cppu::WeakImplHelper1 ...@@ -75,6 +76,9 @@ class DocumentDigitalSignatures : public cppu::WeakImplHelper1
private: private:
com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > mxMSF; 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: public:
DocumentDigitalSignatures( const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory> rxMSF ); DocumentDigitalSignatures( const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory> rxMSF );
...@@ -83,8 +87,15 @@ public: ...@@ -83,8 +87,15 @@ public:
static ::com::sun::star::uno::Sequence < ::rtl::OUString > GetSupportedServiceNames() throw (com::sun::star::uno::RuntimeException); static ::com::sun::star::uno::Sequence < ::rtl::OUString > GetSupportedServiceNames() throw (com::sun::star::uno::RuntimeException);
// XDocumentDigitalSignatures // 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); sal_Bool SAL_CALL SignDocumentContent( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& rxStorage ) 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::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);
}; };
......
/*************************************************************************
*
* $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;
}
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
# #
# $RCSfile: makefile.mk,v $ # $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 # The Contents of this file are made available subject to the terms of
# either of the following licenses # either of the following licenses
...@@ -77,6 +77,7 @@ ENABLE_EXCEPTIONS=TRUE ...@@ -77,6 +77,7 @@ ENABLE_EXCEPTIONS=TRUE
# --- Files -------------------------------------------------------- # --- Files --------------------------------------------------------
SLOFILES= \ SLOFILES= \
$(SLO)$/documentsignaturehelper.obj \
$(SLO)$/xmlsignaturehelper.obj \ $(SLO)$/xmlsignaturehelper.obj \
$(SLO)$/xmlsignaturehelper2.obj \ $(SLO)$/xmlsignaturehelper2.obj \
$(SLO)$/xsecctl.obj \ $(SLO)$/xsecctl.obj \
......
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
* *
* $RCSfile: xmlsignaturehelper.cxx,v $ * $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 * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
...@@ -230,7 +230,7 @@ void XMLSignatureHelper::ExportSignature( ...@@ -230,7 +230,7 @@ void XMLSignatureHelper::ExportSignature(
mpXSecController->exportSignature(xDocumentHandler, signatureInfo); 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; mbError = false;
...@@ -250,7 +250,7 @@ bool XMLSignatureHelper::CreateAndWriteSignatue( const uno::Reference< xml::sax: ...@@ -250,7 +250,7 @@ bool XMLSignatureHelper::CreateAndWriteSignatue( const uno::Reference< xml::sax:
/* /*
* write signatures * write signatures
*/ */
if ( !mpXSecController->WriteSignatue( xDocumentHandler ) ) if ( !mpXSecController->WriteSignature( xDocumentHandler ) )
{ {
mbError = true; mbError = true;
} }
...@@ -263,19 +263,19 @@ bool XMLSignatureHelper::CreateAndWriteSignatue( const uno::Reference< xml::sax: ...@@ -263,19 +263,19 @@ bool XMLSignatureHelper::CreateAndWriteSignatue( const uno::Reference< xml::sax:
return !mbError; 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 uno::Reference<xml::sax::XDocumentHandler> xDocHandler
= CreateDocumentHandlerWithHeader(xOutputStream); = CreateDocumentHandlerWithHeader(xOutputStream);
bool rc = CreateAndWriteSignatue( xDocHandler ); bool rc = CreateAndWriteSignature( xDocHandler );
CloseDocumentHandler(xDocHandler); CloseDocumentHandler(xDocHandler);
return rc; 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; mbError = false;
......
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
* *
* $RCSfile: xsecctl.hxx,v $ * $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 * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
...@@ -510,7 +510,7 @@ public: ...@@ -510,7 +510,7 @@ public:
const rtl::OUString& ouDate, const rtl::OUString& ouDate,
const rtl::OUString& ouTime); const rtl::OUString& ouTime);
bool WriteSignatue( bool WriteSignature(
const com::sun::star::uno::Reference< const com::sun::star::uno::Reference<
com::sun::star::xml::sax::XDocumentHandler >& xDocumentHandler ); com::sun::star::xml::sax::XDocumentHandler >& xDocumentHandler );
......
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
* *
* $RCSfile: xsecsign.cxx,v $ * $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 * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
...@@ -319,7 +319,7 @@ void XSecController::setDateTime( ...@@ -319,7 +319,7 @@ void XSecController::setDateTime(
} }
} }
bool XSecController::WriteSignatue( bool XSecController::WriteSignature(
const cssu::Reference<cssxs::XDocumentHandler>& xDocumentHandler ) const cssu::Reference<cssxs::XDocumentHandler>& xDocumentHandler )
{ {
bool rc = false; bool rc = false;
......
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
# #
# $RCSfile: makefile.mk,v $ # $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 # The Contents of this file are made available subject to the terms of
# either of the following licenses # either of the following licenses
...@@ -177,7 +177,11 @@ SHL4STDLIBS=\ ...@@ -177,7 +177,11 @@ SHL4STDLIBS=\
.IF "$(GUI)"=="WNT" .IF "$(GUI)"=="WNT"
SHL4STDLIBS+= "xmlsec.lib" "xsec_xmlsec.lib" SHL4STDLIBS+= "xmlsec.lib" "xsec_xmlsec.lib"
.ELSE .ELSE
<<<<<<< makefile.mk
SHL4STDLIBS+= "-lxmlsec" "-lxsec_xmlsec"
=======
SHL4STDLIBS+= "-lxmlsec" "-lxsec_xmlsec" SHL4STDLIBS+= "-lxmlsec" "-lxsec_xmlsec"
>>>>>>> 1.2
.ENDIF .ENDIF
......
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
# #
# $RCSfile: makefile.mk,v $ # $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 # The Contents of this file are made available subject to the terms of
# either of the following licenses # either of the following licenses
...@@ -101,7 +101,8 @@ APP1STDLIBS= $(CPPULIB) \ ...@@ -101,7 +101,8 @@ APP1STDLIBS= $(CPPULIB) \
$(SVXLIB) $(SVXLIB)
.IF "$(GUI)"=="WNT" .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 .ELSE
APP1STDLIBS+= "-lxml2" "-lnss3" "-lnspr4" "-lxmlsec" "-lhelper" "-ldialogs" "-lxsec_xmlsec" APP1STDLIBS+= "-lxml2" "-lnss3" "-lnspr4" "-lxmlsec" "-lhelper" "-ldialogs" "-lxsec_xmlsec"
.ENDIF .ENDIF
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment