summaryrefslogtreecommitdiff
path: root/comphelper/inc
diff options
context:
space:
mode:
authorIvo Hinkelmann <ihi@openoffice.org>2010-11-30 17:00:37 +0100
committerIvo Hinkelmann <ihi@openoffice.org>2010-11-30 17:00:37 +0100
commita5509a421f2f3d43aad1ba5d32e6c7bf1c015b3b (patch)
tree2b149629e818baec741e85a72159851e99a32832 /comphelper/inc
parent65df21598fe975ffefd8f8e6951f8d3b331c2b29 (diff)
parent8cbc2d0363811781f5de45b3a11b3614feec4a9a (diff)
CWS-TOOLING: integrate CWS pl08
Notes
split repo tag: libs-gui_ooo/DEV300_m95
Diffstat (limited to 'comphelper/inc')
-rw-r--r--comphelper/inc/comphelper/docpasswordhelper.hxx63
-rw-r--r--comphelper/inc/comphelper/mediadescriptor.hxx1
-rw-r--r--comphelper/inc/comphelper/storagehelper.hxx11
3 files changed, 69 insertions, 6 deletions
diff --git a/comphelper/inc/comphelper/docpasswordhelper.hxx b/comphelper/inc/comphelper/docpasswordhelper.hxx
index dbbb68372a07..7e9f06318a26 100644
--- a/comphelper/inc/comphelper/docpasswordhelper.hxx
+++ b/comphelper/inc/comphelper/docpasswordhelper.hxx
@@ -28,6 +28,7 @@
#ifndef COMPHELPER_DOCPASSWORDHELPR_HXX
#define COMPHELPER_DOCPASSWORDHELPR_HXX
+#include <com/sun/star/beans/NamedValue.hpp>
#include "comphelper/comphelperdllapi.h"
#include <vector>
#include "comphelper/docpasswordrequest.hxx"
@@ -53,7 +54,7 @@ enum DocPasswordVerifierResult
/** Base class for a password verifier used by the DocPasswordHelper class
below.
- Users have to implement the virtual function and pass an instance of the
+ Users have to implement the virtual functions and pass an instance of the
verifier to one of the password request functions.
*/
class COMPHELPER_DLLPUBLIC IDocPasswordVerifier
@@ -63,6 +64,14 @@ public:
/** Will be called everytime a password needs to be verified.
+ @param rPassword
+ The password to be verified
+
+ @param o_rEncryptionData
+ Output parameter, that is filled with the EncryptionData generated
+ from the password. The data is filled only if the validation was
+ successful.
+
@return The result of the verification.
- DocPasswordVerifierResult_OK, if and only if the passed password
is valid and can be used to process the related document.
@@ -72,7 +81,23 @@ public:
occured while password verification. The password request loop
will be aborted.
*/
- virtual DocPasswordVerifierResult verifyPassword( const ::rtl::OUString& rPassword ) = 0;
+ virtual DocPasswordVerifierResult verifyPassword( const ::rtl::OUString& rPassword, ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue >& o_rEncryptionData ) = 0;
+
+ /** Will be called everytime an encryption data needs to be verified.
+
+ @param rEncryptionData
+ The data will be validated
+
+ @return The result of the verification.
+ - DocPasswordVerifierResult_OK, if and only if the passed encryption data
+ is valid and can be used to process the related document.
+ - DocPasswordVerifierResult_WRONG_PASSWORD, if the encryption data is
+ wrong.
+ - DocPasswordVerifierResult_ABORT, if an unrecoverable error
+ occured while data verification. The password request loop
+ will be aborted.
+ */
+ virtual DocPasswordVerifierResult verifyEncryptionData( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue >& o_rEncryptionData ) = 0;
};
@@ -195,6 +220,35 @@ public:
// ------------------------------------------------------------------------
+ /** This helper function generates a random sequence of bytes of
+ requested length.
+ */
+
+ static ::com::sun::star::uno::Sequence< sal_Int8 > GenerateRandomByteSequence(
+ sal_Int32 nLength );
+
+ // ------------------------------------------------------------------------
+
+ /** This helper function generates a byte sequence representing the
+ key digest value used by MSCodec_Std97 codec.
+ */
+
+ static ::com::sun::star::uno::Sequence< sal_Int8 > GenerateStd97Key(
+ const ::rtl::OUString& aPassword,
+ const ::com::sun::star::uno::Sequence< sal_Int8 >& aDocId );
+
+ // ------------------------------------------------------------------------
+
+ /** This helper function generates a byte sequence representing the
+ key digest value used by MSCodec_Std97 codec.
+ */
+
+ static ::com::sun::star::uno::Sequence< sal_Int8 > GenerateStd97Key(
+ const sal_uInt16 pPassData[16],
+ const ::com::sun::star::uno::Sequence< sal_Int8 >& aDocId );
+
+ // ------------------------------------------------------------------------
+
/** This helper function tries to request and verify a password to load a
protected document.
@@ -248,8 +302,9 @@ public:
passed password verifier. If empty, no valid password has been
found, or the user has chossen to cancel password input.
*/
- static ::rtl::OUString requestAndVerifyDocPassword(
+ static ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue > requestAndVerifyDocPassword(
IDocPasswordVerifier& rVerifier,
+ const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue >& rMediaEncData,
const ::rtl::OUString& rMediaPassword,
const ::com::sun::star::uno::Reference<
::com::sun::star::task::XInteractionHandler >& rxInteractHandler,
@@ -300,7 +355,7 @@ public:
passed password verifier. If empty, no valid password has been
found, or the user has chossen to cancel password input.
*/
- static ::rtl::OUString requestAndVerifyDocPassword(
+ static ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue > requestAndVerifyDocPassword(
IDocPasswordVerifier& rVerifier,
MediaDescriptor& rMediaDesc,
DocPasswordRequestType eRequestType,
diff --git a/comphelper/inc/comphelper/mediadescriptor.hxx b/comphelper/inc/comphelper/mediadescriptor.hxx
index 7d2333045390..01fa8059b284 100644
--- a/comphelper/inc/comphelper/mediadescriptor.hxx
+++ b/comphelper/inc/comphelper/mediadescriptor.hxx
@@ -78,6 +78,7 @@ class COMPHELPER_DLLPUBLIC MediaDescriptor : public SequenceAsHashMap
static const ::rtl::OUString& PROP_DEEPDETECTION();
static const ::rtl::OUString& PROP_DETECTSERVICE();
static const ::rtl::OUString& PROP_DOCUMENTSERVICE();
+ static const ::rtl::OUString& PROP_ENCRYPTIONDATA();
static const ::rtl::OUString& PROP_EXTENSION();
static const ::rtl::OUString& PROP_FILENAME();
static const ::rtl::OUString& PROP_FILTERNAME();
diff --git a/comphelper/inc/comphelper/storagehelper.hxx b/comphelper/inc/comphelper/storagehelper.hxx
index b7e5704c4d68..9d44b42e9514 100644
--- a/comphelper/inc/comphelper/storagehelper.hxx
+++ b/comphelper/inc/comphelper/storagehelper.hxx
@@ -33,6 +33,7 @@
#include <com/sun/star/lang/XSingleServiceFactory.hpp>
#include <com/sun/star/embed/XStorage.hpp>
#include <com/sun/star/embed/ElementModes.hpp>
+#include <com/sun/star/beans/NamedValue.hpp>
#include <com/sun/star/io/XInputStream.hpp>
#include <com/sun/star/io/XOutputStream.hpp>
#include <com/sun/star/io/XStream.hpp>
@@ -43,6 +44,9 @@
#define ZIP_STORAGE_FORMAT_STRING ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ZipFormat" ) )
#define OFOPXML_STORAGE_FORMAT_STRING ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "OFOPXMLFormat" ) )
+#define PACKAGE_ENCRYPTIONDATA_SHA1UTF8 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PackageSHA1UTF8EncryptionKey" ) )
+#define PACKAGE_ENCRYPTIONDATA_SHA1MS1252 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PackageSHA1MS1252EncryptionKey" ) )
+
namespace comphelper {
class COMPHELPER_DLLPUBLIC OStorageHelper
@@ -112,9 +116,9 @@ public:
= ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >() )
throw ( ::com::sun::star::uno::Exception );
- static void SetCommonStoragePassword(
+ static void SetCommonStorageEncryptionData(
const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage,
- const ::rtl::OUString& aPass )
+ const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue >& aEncryptionData )
throw ( ::com::sun::star::uno::Exception );
// the following method supports only storages of OOo formats
@@ -159,6 +163,9 @@ public:
sal_Bool bRepairStorage = sal_False )
throw ( ::com::sun::star::uno::Exception );
+ static ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue >
+ CreatePackageEncryptionData( const ::rtl::OUString& aPassword );
+
static sal_Bool IsValidZipEntryFileName( const ::rtl::OUString& aName, sal_Bool bSlashAllowed );
static sal_Bool IsValidZipEntryFileName( const sal_Unicode *pChar, sal_Int32 nLength, sal_Bool bSlashAllowed );