diff options
author | Noel Grandin <noel@peralex.com> | 2012-10-31 14:58:31 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2012-11-05 16:43:14 +0100 |
commit | 1dedb15b17a8e8bf04f248809ef48db663034254 (patch) | |
tree | e8fc086787fb7506046b8a7756a24b76e2f4bde3 /package/source | |
parent | 4c49af256a456af48f0b29262c0b23aa1f6a9cd5 (diff) |
fdo#46808, Adapt xml::crypto::SEInitializer UNO service to new style
Also create an NSSInitializer service IDL and split it's interfaces
out from SEInitializer.
It looks like this was the intention all along, but someone
took a shortcut.
Change-Id: I53ac1cb5d38b78b6718fe22c9666eae1f194a3b7
Diffstat (limited to 'package/source')
-rw-r--r-- | package/source/zipapi/XUnbufferedStream.cxx | 8 | ||||
-rw-r--r-- | package/source/zipapi/XUnbufferedStream.hxx | 4 | ||||
-rw-r--r-- | package/source/zipapi/ZipFile.cxx | 49 | ||||
-rw-r--r-- | package/source/zipapi/ZipOutputStream.cxx | 8 | ||||
-rw-r--r-- | package/source/zippackage/ZipPackage.cxx | 6 | ||||
-rw-r--r-- | package/source/zippackage/ZipPackageStream.cxx | 2 | ||||
-rw-r--r-- | package/source/zippackage/zipfileaccess.cxx | 14 |
7 files changed, 44 insertions, 47 deletions
diff --git a/package/source/zipapi/XUnbufferedStream.cxx b/package/source/zipapi/XUnbufferedStream.cxx index 559e72feabdd..37599c3678f1 100644 --- a/package/source/zipapi/XUnbufferedStream.cxx +++ b/package/source/zipapi/XUnbufferedStream.cxx @@ -41,7 +41,7 @@ using com::sun::star::packages::zip::ZipIOException; using ::rtl::OUString; XUnbufferedStream::XUnbufferedStream( - const uno::Reference< lang::XMultiServiceFactory >& xFactory, + const uno::Reference< uno::XComponentContext >& xContext, SotMutexHolderRef aMutexHolder, ZipEntry & rEntry, Reference < XInputStream > xNewZipStream, @@ -87,7 +87,7 @@ XUnbufferedStream::XUnbufferedStream( if ( bMustDecrypt ) { - m_xCipherContext = ZipFile::StaticGetCipher( xFactory, rData, false ); + m_xCipherContext = ZipFile::StaticGetCipher( xContext, rData, false ); mnBlockSize = ( rData->m_nEncAlg == xml::crypto::CipherID::AES_CBC_W3C_PADDING ? 16 : 1 ); } @@ -111,7 +111,7 @@ XUnbufferedStream::XUnbufferedStream( // allows to read package raw stream XUnbufferedStream::XUnbufferedStream( - const uno::Reference< lang::XMultiServiceFactory >& /*xFactory*/, + const uno::Reference< uno::XComponentContext >& /*xContext*/, const Reference < XInputStream >& xRawStream, const ::rtl::Reference< EncryptionData >& rData ) : maMutexHolder( new SotMutexHolder ) @@ -148,7 +148,7 @@ XUnbufferedStream::XUnbufferedStream( mnZipEnd = mnZipCurrent + mnZipSize; // the raw data will not be decrypted, no need for the cipher - // m_xCipherContext = ZipFile::StaticGetCipher( xFactory, rData, false ); + // m_xCipherContext = ZipFile::StaticGetCipher( xContext, rData, false ); } XUnbufferedStream::~XUnbufferedStream() diff --git a/package/source/zipapi/XUnbufferedStream.hxx b/package/source/zipapi/XUnbufferedStream.hxx index 3f68b326d55e..4bfa35c49a05 100644 --- a/package/source/zipapi/XUnbufferedStream.hxx +++ b/package/source/zipapi/XUnbufferedStream.hxx @@ -61,7 +61,7 @@ protected: public: XUnbufferedStream( - const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xFactory, + const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& xContext, SotMutexHolderRef aMutexHolder, ZipEntry & rEntry, com::sun::star::uno::Reference < com::sun::star::io::XInputStream > xNewZipStream, @@ -73,7 +73,7 @@ public: // allows to read package raw stream XUnbufferedStream( - const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xFactory, + const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& xContext, const com::sun::star::uno::Reference < com::sun::star::io::XInputStream >& xRawStream, const ::rtl::Reference< EncryptionData >& rData ); diff --git a/package/source/zipapi/ZipFile.cxx b/package/source/zipapi/ZipFile.cxx index 83984d68a170..0da4c337ef60 100644 --- a/package/source/zipapi/ZipFile.cxx +++ b/package/source/zipapi/ZipFile.cxx @@ -27,6 +27,7 @@ #include <com/sun/star/xml/crypto/XDigestContextSupplier.hpp> #include <com/sun/star/xml/crypto/CipherID.hpp> #include <com/sun/star/xml/crypto/DigestID.hpp> +#include <com/sun/star/xml/crypto/NSSInitializer.hpp> #include <comphelper/storagehelper.hxx> #include <comphelper/processfactory.hxx> @@ -62,13 +63,13 @@ using ZipUtils::Inflater; /** This class is used to read entries from a zip file */ -ZipFile::ZipFile( uno::Reference < XInputStream > &xInput, const uno::Reference < XMultiServiceFactory > &xNewFactory, sal_Bool bInitialise ) +ZipFile::ZipFile( uno::Reference < XInputStream > &xInput, const uno::Reference < XComponentContext > & rxContext, sal_Bool bInitialise ) throw(IOException, ZipException, RuntimeException) : aGrabber(xInput) , aInflater (sal_True) , xStream(xInput) , xSeek(xInput, UNO_QUERY) -, m_xFactory ( xNewFactory ) +, m_xContext ( rxContext ) , bRecoveryMode( sal_False ) { if (bInitialise) @@ -83,13 +84,13 @@ ZipFile::ZipFile( uno::Reference < XInputStream > &xInput, const uno::Reference -ZipFile::ZipFile( uno::Reference < XInputStream > &xInput, const uno::Reference < XMultiServiceFactory > &xNewFactory, sal_Bool bInitialise, sal_Bool bForceRecovery, uno::Reference < XProgressHandler > xProgress ) +ZipFile::ZipFile( uno::Reference < XInputStream > &xInput, const uno::Reference < XComponentContext > & rxContext, sal_Bool bInitialise, sal_Bool bForceRecovery, uno::Reference < XProgressHandler > xProgress ) throw(IOException, ZipException, RuntimeException) : aGrabber(xInput) , aInflater (sal_True) , xStream(xInput) , xSeek(xInput, UNO_QUERY) -, m_xFactory ( xNewFactory ) +, m_xContext ( rxContext ) , xProgressHandler( xProgress ) , bRecoveryMode( bForceRecovery ) { @@ -121,18 +122,16 @@ void ZipFile::setInputStream ( uno::Reference < XInputStream > xNewStream ) aGrabber.setInputStream ( xStream ); } -uno::Reference< xml::crypto::XDigestContext > ZipFile::StaticGetDigestContextForChecksum( const uno::Reference< lang::XMultiServiceFactory >& xArgFactory, const ::rtl::Reference< EncryptionData >& xEncryptionData ) +uno::Reference< xml::crypto::XDigestContext > ZipFile::StaticGetDigestContextForChecksum( const uno::Reference< uno::XComponentContext >& xArgContext, const ::rtl::Reference< EncryptionData >& xEncryptionData ) { uno::Reference< xml::crypto::XDigestContext > xDigestContext; if ( xEncryptionData->m_nCheckAlg == xml::crypto::DigestID::SHA256_1K ) { - uno::Reference< lang::XMultiServiceFactory > xFactory = xArgFactory; - if ( !xFactory.is() ) - xFactory.set( comphelper::getProcessServiceFactory(), uno::UNO_SET_THROW ); + uno::Reference< uno::XComponentContext > xContext = xArgContext; + if ( !xContext.is() ) + xContext = comphelper::getProcessComponentContext(); - uno::Reference< xml::crypto::XDigestContextSupplier > xDigestContextSupplier( - xFactory->createInstance("com.sun.star.xml.crypto.NSSInitializer"), - uno::UNO_QUERY_THROW ); + uno::Reference< xml::crypto::XNSSInitializer > xDigestContextSupplier = xml::crypto::NSSInitializer::create( xContext ); xDigestContext.set( xDigestContextSupplier->getDigestContext( xEncryptionData->m_nCheckAlg, uno::Sequence< beans::NamedValue >() ), uno::UNO_SET_THROW ); } @@ -142,7 +141,7 @@ uno::Reference< xml::crypto::XDigestContext > ZipFile::StaticGetDigestContextFor return xDigestContext; } -uno::Reference< xml::crypto::XCipherContext > ZipFile::StaticGetCipher( const uno::Reference< lang::XMultiServiceFactory >& xArgFactory, const ::rtl::Reference< EncryptionData >& xEncryptionData, bool bEncrypt ) +uno::Reference< xml::crypto::XCipherContext > ZipFile::StaticGetCipher( const uno::Reference< uno::XComponentContext >& xArgContext, const ::rtl::Reference< EncryptionData >& xEncryptionData, bool bEncrypt ) { uno::Reference< xml::crypto::XCipherContext > xResult; @@ -169,13 +168,11 @@ uno::Reference< xml::crypto::XCipherContext > ZipFile::StaticGetCipher( const un if ( xEncryptionData->m_nEncAlg == xml::crypto::CipherID::AES_CBC_W3C_PADDING ) { - uno::Reference< lang::XMultiServiceFactory > xFactory = xArgFactory; - if ( !xFactory.is() ) - xFactory.set( comphelper::getProcessServiceFactory(), uno::UNO_SET_THROW ); + uno::Reference< uno::XComponentContext > xContext = xArgContext; + if ( !xContext.is() ) + xContext = comphelper::getProcessComponentContext(); - uno::Reference< xml::crypto::XCipherContextSupplier > xCipherContextSupplier( - xFactory->createInstance("com.sun.star.xml.crypto.NSSInitializer"), - uno::UNO_QUERY_THROW ); + uno::Reference< xml::crypto::XNSSInitializer > xCipherContextSupplier = xml::crypto::NSSInitializer::create( xContext ); xResult = xCipherContextSupplier->getCipherContext( xEncryptionData->m_nEncAlg, aDerivedKey, xEncryptionData->m_aInitVector, bEncrypt, uno::Sequence< beans::NamedValue >() ); } @@ -381,7 +378,7 @@ sal_Bool ZipFile::StaticFillData ( ::rtl::Reference< BaseEncryptionData > & rDa return bOk; } -uno::Reference< XInputStream > ZipFile::StaticGetDataFromRawStream( const uno::Reference< lang::XMultiServiceFactory >& xFactory, +uno::Reference< XInputStream > ZipFile::StaticGetDataFromRawStream( const uno::Reference< uno::XComponentContext >& rxContext, const uno::Reference< XInputStream >& xStream, const ::rtl::Reference< EncryptionData > &rData ) throw ( packages::WrongPasswordException, ZipIOException, RuntimeException ) @@ -417,11 +414,11 @@ uno::Reference< XInputStream > ZipFile::StaticGetDataFromRawStream( const uno::R xStream->readBytes( aReadBuffer, nSize ); - if ( !StaticHasValidPassword( xFactory, aReadBuffer, rData ) ) + if ( !StaticHasValidPassword( rxContext, aReadBuffer, rData ) ) throw packages::WrongPasswordException(OSL_LOG_PREFIX, uno::Reference< uno::XInterface >() ); } - return new XUnbufferedStream( xFactory, xStream, rData ); + return new XUnbufferedStream( rxContext, xStream, rData ); } #if 0 @@ -439,14 +436,14 @@ void CheckSequence( const uno::Sequence< sal_Int8 >& aSequence ) } #endif -sal_Bool ZipFile::StaticHasValidPassword( const uno::Reference< lang::XMultiServiceFactory >& xFactory, const Sequence< sal_Int8 > &aReadBuffer, const ::rtl::Reference< EncryptionData > &rData ) +sal_Bool ZipFile::StaticHasValidPassword( const uno::Reference< uno::XComponentContext >& rxContext, const Sequence< sal_Int8 > &aReadBuffer, const ::rtl::Reference< EncryptionData > &rData ) { if ( !rData.is() || !rData->m_aKey.getLength() ) return sal_False; sal_Bool bRet = sal_False; - uno::Reference< xml::crypto::XCipherContext > xCipher( StaticGetCipher( xFactory, rData, false ), uno::UNO_SET_THROW ); + uno::Reference< xml::crypto::XCipherContext > xCipher( StaticGetCipher( rxContext, rData, false ), uno::UNO_SET_THROW ); uno::Sequence< sal_Int8 > aDecryptBuffer; uno::Sequence< sal_Int8 > aDecryptBuffer2; @@ -472,7 +469,7 @@ sal_Bool ZipFile::StaticHasValidPassword( const uno::Reference< lang::XMultiServ aDecryptBuffer.realloc( n_ConstDigestLength ); uno::Sequence< sal_Int8 > aDigestSeq; - uno::Reference< xml::crypto::XDigestContext > xDigestContext( StaticGetDigestContextForChecksum( xFactory, rData ), uno::UNO_SET_THROW ); + uno::Reference< xml::crypto::XDigestContext > xDigestContext( StaticGetDigestContextForChecksum( rxContext, rData ), uno::UNO_SET_THROW ); xDigestContext->updateDigest( aDecryptBuffer ); aDigestSeq = xDigestContext->finalizeDigestAndDispose(); @@ -510,7 +507,7 @@ sal_Bool ZipFile::hasValidPassword ( ZipEntry & rEntry, const ::rtl::Reference< xStream->readBytes( aReadBuffer, nSize ); - bRet = StaticHasValidPassword( m_xFactory, aReadBuffer, rData ); + bRet = StaticHasValidPassword( m_xContext, aReadBuffer, rData ); } return bRet; @@ -526,7 +523,7 @@ uno::Reference< XInputStream > ZipFile::createUnbufferedStream( { ::osl::MutexGuard aGuard( m_aMutex ); - return new XUnbufferedStream ( m_xFactory, aMutexHolder, rEntry, xStream, rData, nStreamMode, bIsEncrypted, aMediaType, bRecoveryMode ); + return new XUnbufferedStream ( m_xContext, aMutexHolder, rEntry, xStream, rData, nStreamMode, bIsEncrypted, aMediaType, bRecoveryMode ); } diff --git a/package/source/zipapi/ZipOutputStream.cxx b/package/source/zipapi/ZipOutputStream.cxx index df5c70ffbf67..f24881dfbb7a 100644 --- a/package/source/zipapi/ZipOutputStream.cxx +++ b/package/source/zipapi/ZipOutputStream.cxx @@ -40,9 +40,9 @@ using namespace com::sun::star::packages::zip::ZipConstants; /** This class is used to write Zip files */ -ZipOutputStream::ZipOutputStream( const uno::Reference< lang::XMultiServiceFactory >& xFactory, +ZipOutputStream::ZipOutputStream( const uno::Reference< uno::XComponentContext >& rxContext, const uno::Reference < XOutputStream > &xOStream ) -: m_xFactory( xFactory ) +: m_xContext( rxContext ) , xStream(xOStream) , m_aDeflateBuffer(n_ConstBufferSize) , aDeflater(DEFAULT_COMPRESSION, sal_True) @@ -96,8 +96,8 @@ void SAL_CALL ZipOutputStream::putNextEntry( ZipEntry& rEntry, { bEncryptCurrentEntry = sal_True; - m_xCipherContext = ZipFile::StaticGetCipher( m_xFactory, pStream->GetEncryptionData(), true ); - m_xDigestContext = ZipFile::StaticGetDigestContextForChecksum( m_xFactory, pStream->GetEncryptionData() ); + m_xCipherContext = ZipFile::StaticGetCipher( m_xContext, pStream->GetEncryptionData(), true ); + m_xDigestContext = ZipFile::StaticGetDigestContextForChecksum( m_xContext, pStream->GetEncryptionData() ); mnDigested = 0; rEntry.nFlag |= 1 << 4; m_pCurrentStream = pStream; diff --git a/package/source/zippackage/ZipPackage.cxx b/package/source/zippackage/ZipPackage.cxx index b6b853d7bac2..f24774755a9e 100644 --- a/package/source/zippackage/ZipPackage.cxx +++ b/package/source/zippackage/ZipPackage.cxx @@ -753,7 +753,7 @@ void SAL_CALL ZipPackage::initialize( const uno::Sequence< Any >& aArguments ) { try { - m_pZipFile = new ZipFile ( m_xContentStream, m_xFactory, sal_True, m_bForceRecovery, xProgressHandler ); + m_pZipFile = new ZipFile ( m_xContentStream, comphelper::getComponentContext(m_xFactory), sal_True, m_bForceRecovery, xProgressHandler ); getZipFileContents(); } catch ( IOException & ) @@ -1108,7 +1108,7 @@ void ZipPackage::ConnectTo( const uno::Reference< io::XInputStream >& xInStream if ( m_pZipFile ) m_pZipFile->setInputStream( m_xContentStream ); else - m_pZipFile = new ZipFile ( m_xContentStream, m_xFactory, sal_False ); + m_pZipFile = new ZipFile ( m_xContentStream, comphelper::getComponentContext(m_xFactory), sal_False ); } //-------------------------------------------------------- @@ -1157,7 +1157,7 @@ uno::Reference< io::XInputStream > ZipPackage::writeTempFile() } // Hand it to the ZipOutputStream: - ZipOutputStream aZipOut( m_xFactory, xTempOut ); + ZipOutputStream aZipOut( comphelper::getComponentContext(m_xFactory), xTempOut ); aZipOut.setMethod( DEFLATED ); aZipOut.setLevel( DEFAULT_COMPRESSION ); diff --git a/package/source/zippackage/ZipPackageStream.cxx b/package/source/zippackage/ZipPackageStream.cxx index 7352b8c3d3e0..88afb2a3366a 100644 --- a/package/source/zippackage/ZipPackageStream.cxx +++ b/package/source/zippackage/ZipPackageStream.cxx @@ -564,7 +564,7 @@ uno::Reference< io::XInputStream > SAL_CALL ZipPackageStream::getDataStream() return xResult; } else if ( m_nStreamMode == PACKAGE_STREAM_RAW ) - return ZipFile::StaticGetDataFromRawStream( m_xFactory, GetOwnSeekStream(), GetEncryptionData() ); + return ZipFile::StaticGetDataFromRawStream( comphelper::getComponentContext(m_xFactory), GetOwnSeekStream(), GetEncryptionData() ); else if ( GetOwnSeekStream().is() ) { return new WrapStreamForShare( GetOwnSeekStream(), rZipPackage.GetSharedMutexRef() ); diff --git a/package/source/zippackage/zipfileaccess.cxx b/package/source/zippackage/zipfileaccess.cxx index 0ee088f6ffda..09a6e89d7fca 100644 --- a/package/source/zippackage/zipfileaccess.cxx +++ b/package/source/zippackage/zipfileaccess.cxx @@ -38,14 +38,14 @@ using namespace ::com::sun::star; // ---------------------------------------------------------------- -OZipFileAccess::OZipFileAccess( const uno::Reference< lang::XMultiServiceFactory >& xFactory ) +OZipFileAccess::OZipFileAccess( const uno::Reference< uno::XComponentContext >& rxContext ) : m_aMutexHolder( new SotMutexHolder ) -, m_xFactory( xFactory ) +, m_xContext( rxContext ) , m_pZipFile( NULL ) , m_pListenersContainer( NULL ) , m_bDisposed( sal_False ) { - if ( !xFactory.is() ) + if ( !rxContext.is() ) throw uno::RuntimeException(OSL_LOG_PREFIX, uno::Reference< uno::XInterface >() ); } @@ -188,7 +188,7 @@ void SAL_CALL OZipFileAccess::initialize( const uno::Sequence< uno::Any >& aArgu ::ucbhelper::Content aContent( aParamURL, uno::Reference< ::com::sun::star::ucb::XCommandEnvironment >(), - comphelper::getComponentContext( m_xFactory ) ); + m_xContext ); uno::Reference < io::XActiveDataSink > xSink = new ZipPackageSink; if ( aContent.openStream ( xSink ) ) { @@ -221,7 +221,7 @@ void SAL_CALL OZipFileAccess::initialize( const uno::Sequence< uno::Any >& aArgu // TODO: in case xSeekable is implemented on separated XStream implementation a wrapper is required m_pZipFile = new ZipFile( m_xContentStream, - m_xFactory, + m_xContext, sal_True ); } @@ -450,9 +450,9 @@ OUString SAL_CALL OZipFileAccess::impl_staticGetImplementationName() //------------------------------------------------------------------------- uno::Reference< uno::XInterface > SAL_CALL OZipFileAccess::impl_staticCreateSelfInstance( - const uno::Reference< lang::XMultiServiceFactory >& xServiceManager ) + const uno::Reference< lang::XMultiServiceFactory >& rxMSF ) { - return uno::Reference< uno::XInterface >( *new OZipFileAccess( xServiceManager ) ); + return uno::Reference< uno::XInterface >( *new OZipFileAccess( comphelper::getComponentContext(rxMSF) ) ); } //------------------------------------------------------------------------- |