summaryrefslogtreecommitdiff
path: root/package/source/zipapi
diff options
context:
space:
mode:
authorMartin Gallwey <mtg@openoffice.org>2001-11-15 19:20:40 +0000
committerMartin Gallwey <mtg@openoffice.org>2001-11-15 19:20:40 +0000
commite40e075973890c7ba9ca44071d777391ecaa091d (patch)
tree2de365368fa0344a1098833c3b3e011783969d2d /package/source/zipapi
parent614bfb6cddf45885e93450c9794726e78e91c53f (diff)
#94679#, #92268# support XTypeProvider and Encrypted data headers
Diffstat (limited to 'package/source/zipapi')
-rw-r--r--package/source/zipapi/XFileStream.cxx66
-rw-r--r--package/source/zipapi/XFileStream.hxx35
2 files changed, 50 insertions, 51 deletions
diff --git a/package/source/zipapi/XFileStream.cxx b/package/source/zipapi/XFileStream.cxx
index 00f616782d83..1c1a49aa4eb0 100644
--- a/package/source/zipapi/XFileStream.cxx
+++ b/package/source/zipapi/XFileStream.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: XFileStream.cxx,v $
*
- * $Revision: 1.5 $
+ * $Revision: 1.6 $
*
- * last change: $Author: mtg $ $Date: 2001-10-31 11:32:54 $
+ * last change: $Author: mtg $ $Date: 2001-11-15 20:18:31 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -76,6 +76,12 @@
#ifndef _ZIP_FILE_HXX
#include <ZipFile.hxx>
#endif
+#ifndef _ENCRYPTED_DATA_HEADER_HXX_
+#include <EncryptedDataHeader.hxx>
+#endif
+#ifndef _COM_SUN_STAR_IO_XOUTPUTSTREAM_HPP_
+#include <com/sun/star/io/XOutputStream.hpp>
+#endif
using namespace com::sun::star::packages::zip::ZipConstants;
using namespace com::sun::star::io;
@@ -87,7 +93,8 @@ XFileStream::XFileStream( ZipEntry & rEntry,
com::sun::star::uno::Reference < com::sun::star::io::XInputStream > xNewZipStream,
com::sun::star::uno::Reference < com::sun::star::io::XInputStream > xNewTempStream,
const vos::ORef < EncryptionData > &rData,
- sal_Bool bNewRawStream )
+ sal_Bool bNewRawStream,
+ sal_Bool bIsEncrypted )
: maEntry ( rEntry )
, mxData ( rData )
, mbRawStream ( bNewRawStream )
@@ -111,8 +118,32 @@ XFileStream::XFileStream( ZipEntry & rEntry,
mnZipSize = maEntry.nSize;
mnZipEnd = maEntry.nMethod == DEFLATED ? maEntry.nOffset + maEntry.nCompressedSize : maEntry.nOffset + maEntry.nSize;
}
- if ( !rData.isEmpty() && rData->aSalt.getLength() )
- ZipFile::StaticGetCipher ( rData, maCipher );
+
+ if ( bIsEncrypted )
+ {
+ sal_Bool bHaveEncryptData = ( !rData.isEmpty() && rData->aSalt.getLength() && rData->aInitVector.getLength() && rData->nIterationCount != 0 ) ? sal_True : sal_False;
+
+ // if we have all the encrypted data, and want a raw stream, then prepend it to the stream, otherwise
+ // make a cipher so we can decrypt it
+ if ( bHaveEncryptData )
+ {
+ if ( !bNewRawStream )
+ ZipFile::StaticGetCipher ( rData, maCipher );
+ else
+ {
+ // Put in the EncryptedDataHeader
+ Sequence < sal_Int8 > aEncryptedDataHeader ( n_ConstHeaderSize +
+ rData->aInitVector.getLength() +
+ rData->aSalt.getLength() +
+ rData->aDigest.getLength() );
+ sal_Int8 * pHeader = aEncryptedDataHeader.getArray();
+ ZipFile::StaticFillHeader ( rData, rEntry.nSize, pHeader );
+ mxTempOut->writeBytes ( aEncryptedDataHeader );
+ mnZipSize += mxTempSeek->getPosition();
+ mxTempSeek->seek ( 0 );
+ }
+ }
+ }
}
XFileStream::~XFileStream()
@@ -121,31 +152,6 @@ XFileStream::~XFileStream()
rtl_cipher_destroy ( maCipher );
}
-Any SAL_CALL XFileStream::queryInterface( const Type& rType )
- throw(RuntimeException)
-{
- return ::cppu::queryInterface ( rType ,
- // OWeakObject interfaces
- reinterpret_cast< XInterface* > ( this ) ,
- static_cast< XWeak* > ( this ) ,
- // my interfaces
- static_cast< XInputStream* > ( this ) ,
- static_cast< XSeekable* > ( this ) );
-
-}
-
-void SAL_CALL XFileStream::acquire(void)
- throw()
-{
- OWeakObject::acquire();
-}
-
-void SAL_CALL XFileStream::release(void)
- throw()
-{
- OWeakObject::release();
-}
-
void XFileStream::fill( sal_Int64 nUntil)
{
sal_Int32 nRead;
diff --git a/package/source/zipapi/XFileStream.hxx b/package/source/zipapi/XFileStream.hxx
index 1dc04f9083ed..a210e6a34395 100644
--- a/package/source/zipapi/XFileStream.hxx
+++ b/package/source/zipapi/XFileStream.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: XFileStream.hxx,v $
*
- * $Revision: 1.3 $
+ * $Revision: 1.4 $
*
- * last change: $Author: mtg $ $Date: 2001-09-14 14:55:03 $
+ * last change: $Author: mtg $ $Date: 2001-11-15 20:20:40 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -61,9 +61,6 @@
#ifndef _XFILE_STREAM_HXX
#define _XFILE_STREAM_HXX
-#ifndef _COM_SUN_STAR_IO_XOUTPUTSTREAM_HPP_
-#include <com/sun/star/io/XOutputStream.hpp>
-#endif
#ifndef _COM_SUN_STAR_LANG_ILLEGALARGUMENTEXCEPTION_HPP_
#include <com/sun/star/lang/IllegalArgumentException.hpp>
#endif
@@ -73,11 +70,8 @@
#ifndef _COM_SUN_STAR_IO_XINPUTSTREAM_HPP_
#include <com/sun/star/io/XInputStream.hpp>
#endif
-#ifndef _COM_SUN_STAR_IO_XOUTPUTSTREAM_HPP_
-#include <com/sun/star/io/XOutputStream.hpp>
-#endif
-#ifndef _CPPUHELPER_WEAK_HXX_
-#include <cppuhelper/weak.hxx>
+#ifndef _CPPUHELPER_IMPLBASE2_HXX_
+#include <cppuhelper/implbase2.hxx>
#endif
#ifndef _VOS_REF_H_
#include <vos/ref.hxx>
@@ -89,11 +83,16 @@
#include <ZipEntry.hxx>
#endif
+namespace com { namespace sun { namespace star {
+ namespace io { class XOutputStream; }
+} } }
class EncryptionData;
typedef void* rtlCipher;
-class XFileStream : public com::sun::star::io::XInputStream,
- public com::sun::star::io::XSeekable,
- public cppu::OWeakObject
+class XFileStream : public cppu::WeakImplHelper2
+<
+ com::sun::star::io::XInputStream,
+ com::sun::star::io::XSeekable
+>
{
protected:
com::sun::star::uno::Reference < com::sun::star::io::XInputStream > mxZipStream;
@@ -115,16 +114,10 @@ public:
com::sun::star::uno::Reference < com::sun::star::io::XInputStream > xNewZipStream,
com::sun::star::uno::Reference < com::sun::star::io::XInputStream > xNewTempStream,
const vos::ORef < EncryptionData > &rData,
- sal_Bool bRawStream );
+ sal_Bool bRawStream,
+ sal_Bool bIsEncrypted );
virtual ~XFileStream();
- // XInterface
- virtual com::sun::star::uno::Any SAL_CALL queryInterface( const com::sun::star::uno::Type& rType )
- throw(com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL acquire()
- throw();
- virtual void SAL_CALL release()
- throw();
// XInputStream
virtual sal_Int32 SAL_CALL readBytes( ::com::sun::star::uno::Sequence< sal_Int8 >& aData, sal_Int32 nBytesToRead )
throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);