fdo#46808, Convert XMultiServiceFactory in xmlsecurity module

Change-Id: Ia134170d07f33c2649b2a2620f40bc7b45ec7e16
This commit is contained in:
Noel Grandin 2013-06-05 11:32:31 +02:00
parent 27c6434fcc
commit a4196fc3cf
15 changed files with 96 additions and 82 deletions

View File

@ -19,6 +19,7 @@ $(eval $(call gb_Library_set_include,xsec_fw,\
$(eval $(call gb_Library_use_sdk_api,xsec_fw)) $(eval $(call gb_Library_use_sdk_api,xsec_fw))
$(eval $(call gb_Library_use_libraries,xsec_fw,\ $(eval $(call gb_Library_use_libraries,xsec_fw,\
comphelper \
cppu \ cppu \
cppuhelper \ cppuhelper \
sal \ sal \

View File

@ -22,7 +22,9 @@
#include <com/sun/star/xml/crypto/XXMLEncryptionTemplate.hpp> #include <com/sun/star/xml/crypto/XXMLEncryptionTemplate.hpp>
#include <com/sun/star/xml/wrapper/XXMLElementWrapper.hpp> #include <com/sun/star/xml/wrapper/XXMLElementWrapper.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <comphelper/processfactory.hxx>
using namespace com::sun::star::uno;
namespace cssu = com::sun::star::uno; namespace cssu = com::sun::star::uno;
namespace cssl = com::sun::star::lang; namespace cssl = com::sun::star::lang;
namespace cssxc = com::sun::star::xml::crypto; namespace cssxc = com::sun::star::xml::crypto;
@ -31,9 +33,8 @@ namespace cssxw = com::sun::star::xml::wrapper;
#define SERVICE_NAME "com.sun.star.xml.crypto.sax.Decryptor" #define SERVICE_NAME "com.sun.star.xml.crypto.sax.Decryptor"
#define IMPLEMENTATION_NAME "com.sun.star.xml.security.framework.DecryptorImpl" #define IMPLEMENTATION_NAME "com.sun.star.xml.security.framework.DecryptorImpl"
DecryptorImpl::DecryptorImpl( const cssu::Reference< cssl::XMultiServiceFactory >& rxMSF) DecryptorImpl::DecryptorImpl(const Reference< XComponentContext > & xContext) : DecryptorImpl_Base(xContext)
{ {
mxMSF = rxMSF;
} }
DecryptorImpl::~DecryptorImpl() DecryptorImpl::~DecryptorImpl()
@ -198,10 +199,10 @@ cssu::Sequence< OUString > SAL_CALL DecryptorImpl_getSupportedServiceNames( )
} }
#undef SERVICE_NAME #undef SERVICE_NAME
cssu::Reference< cssu::XInterface > SAL_CALL DecryptorImpl_createInstance( const cssu::Reference< cssl::XMultiServiceFactory >& rSMgr) cssu::Reference< cssu::XInterface > SAL_CALL DecryptorImpl_createInstance( const cssu::Reference< cssl::XMultiServiceFactory >& xMSF)
throw( cssu::Exception ) throw( cssu::Exception )
{ {
return (cppu::OWeakObject*) new DecryptorImpl(rSMgr); return (cppu::OWeakObject*) new DecryptorImpl( comphelper::getComponentContext( xMSF ) );
} }
/* XServiceInfo */ /* XServiceInfo */

View File

@ -29,13 +29,14 @@
#include "encryptionengine.hxx" #include "encryptionengine.hxx"
class DecryptorImpl : public cppu::ImplInheritanceHelper3 typedef cppu::ImplInheritanceHelper3
< <
EncryptionEngine, EncryptionEngine,
com::sun::star::xml::crypto::sax::XDecryptionResultBroadcaster, com::sun::star::xml::crypto::sax::XDecryptionResultBroadcaster,
com::sun::star::lang::XInitialization, com::sun::star::lang::XInitialization,
com::sun::star::lang::XServiceInfo com::sun::star::lang::XServiceInfo
> > DecryptorImpl_Base;
class DecryptorImpl : public DecryptorImpl_Base
/****** DecryptorImpl.hxx/CLASS DecryptorImpl ********************************* /****** DecryptorImpl.hxx/CLASS DecryptorImpl *********************************
* *
* NAME * NAME
@ -63,8 +64,7 @@ private:
throw (com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException); throw (com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException);
public: public:
explicit DecryptorImpl( const com::sun::star::uno::Reference< explicit DecryptorImpl(const com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > & xContext);
com::sun::star::lang::XMultiServiceFactory >& rxMSF);
virtual ~DecryptorImpl(); virtual ~DecryptorImpl();
/* XDecryptionResultBroadcaster */ /* XDecryptionResultBroadcaster */

View File

@ -23,14 +23,14 @@
#include <com/sun/star/xml/wrapper/XXMLElementWrapper.hpp> #include <com/sun/star/xml/wrapper/XXMLElementWrapper.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp>
namespace cssu = com::sun::star::uno; using namespace com::sun::star::uno;
namespace cssxc = com::sun::star::xml::crypto; namespace cssxc = com::sun::star::xml::crypto;
namespace cssxw = com::sun::star::xml::wrapper; namespace cssxw = com::sun::star::xml::wrapper;
#define ENCRYPTION_TEMPLATE "com.sun.star.xml.crypto.XMLEncryptionTemplate" #define ENCRYPTION_TEMPLATE "com.sun.star.xml.crypto.XMLEncryptionTemplate"
EncryptionEngine::EncryptionEngine( ) EncryptionEngine::EncryptionEngine( const Reference<XComponentContext> & xContext)
:m_nIdOfBlocker(-1) :m_xContext(xContext), m_nIdOfBlocker(-1)
{ {
} }
@ -82,7 +82,7 @@ bool EncryptionEngine::checkReady() const
} }
void EncryptionEngine::tryToPerform( ) void EncryptionEngine::tryToPerform( )
throw (cssu::Exception, cssu::RuntimeException) throw (Exception, RuntimeException)
/****** EncryptionEngine/tryToPerform **************************************** /****** EncryptionEngine/tryToPerform ****************************************
* *
* NAME * NAME
@ -113,12 +113,12 @@ void EncryptionEngine::tryToPerform( )
if (checkReady()) if (checkReady())
{ {
const OUString sEncryptionTemplate ( ENCRYPTION_TEMPLATE ); const OUString sEncryptionTemplate ( ENCRYPTION_TEMPLATE );
cssu::Reference < cssxc::XXMLEncryptionTemplate > xEncryptionTemplate( Reference < cssxc::XXMLEncryptionTemplate > xEncryptionTemplate(
mxMSF->createInstance( sEncryptionTemplate ), cssu::UNO_QUERY ); m_xContext->getServiceManager()->createInstanceWithContext( sEncryptionTemplate, m_xContext ), UNO_QUERY );
OSL_ASSERT( xEncryptionTemplate.is() ); OSL_ASSERT( xEncryptionTemplate.is() );
cssu::Reference< cssxw::XXMLElementWrapper > xXMLElement Reference< cssxw::XXMLElementWrapper > xXMLElement
= m_xSAXEventKeeper->getElement( m_nIdOfTemplateEC ); = m_xSAXEventKeeper->getElement( m_nIdOfTemplateEC );
xEncryptionTemplate->setTemplate(xXMLElement); xEncryptionTemplate->setTemplate(xXMLElement);
@ -162,12 +162,12 @@ void EncryptionEngine::clearUp( ) const
* Email: michael.mi@sun.com * Email: michael.mi@sun.com
******************************************************************************/ ******************************************************************************/
{ {
cssu::Reference < cssxc::sax::XReferenceResolvedBroadcaster > Reference < cssxc::sax::XReferenceResolvedBroadcaster >
xReferenceResolvedBroadcaster( m_xSAXEventKeeper, cssu::UNO_QUERY ); xReferenceResolvedBroadcaster( m_xSAXEventKeeper, UNO_QUERY );
xReferenceResolvedBroadcaster->removeReferenceResolvedListener( xReferenceResolvedBroadcaster->removeReferenceResolvedListener(
m_nIdOfTemplateEC, m_nIdOfTemplateEC,
(const cssu::Reference < cssxc::sax::XReferenceResolvedListener >)((SecurityEngine *)this)); (const Reference < cssxc::sax::XReferenceResolvedListener >)((SecurityEngine *)this));
m_xSAXEventKeeper->removeElementCollector(m_nIdOfTemplateEC); m_xSAXEventKeeper->removeElementCollector(m_nIdOfTemplateEC);

View File

@ -50,6 +50,10 @@ class EncryptionEngine : public cppu::ImplInheritanceHelper1
* Email: michael.mi@sun.com * Email: michael.mi@sun.com
******************************************************************************/ ******************************************************************************/
{ {
private:
com::sun::star::uno::Reference<
com::sun::star::uno::XComponentContext > m_xContext;
protected: protected:
/* /*
* the Encryption bridge component, which performs encrypt and decrypt * the Encryption bridge component, which performs encrypt and decrypt
@ -64,7 +68,7 @@ protected:
sal_Int32 m_nIdOfBlocker; sal_Int32 m_nIdOfBlocker;
protected: protected:
EncryptionEngine( ); EncryptionEngine( const com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > & xContext );
virtual ~EncryptionEngine(){}; virtual ~EncryptionEngine(){};
virtual void tryToPerform( ) virtual void tryToPerform( )

View File

@ -22,8 +22,9 @@
#include <com/sun/star/xml/crypto/XXMLEncryptionTemplate.hpp> #include <com/sun/star/xml/crypto/XXMLEncryptionTemplate.hpp>
#include <com/sun/star/xml/wrapper/XXMLElementWrapper.hpp> #include <com/sun/star/xml/wrapper/XXMLElementWrapper.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <comphelper/processfactory.hxx>
namespace cssu = com::sun::star::uno; using namespace com::sun::star::uno;
namespace cssl = com::sun::star::lang; namespace cssl = com::sun::star::lang;
namespace cssxc = com::sun::star::xml::crypto; namespace cssxc = com::sun::star::xml::crypto;
namespace cssxw = com::sun::star::xml::wrapper; namespace cssxw = com::sun::star::xml::wrapper;
@ -31,10 +32,9 @@ namespace cssxw = com::sun::star::xml::wrapper;
#define SERVICE_NAME "com.sun.star.xml.crypto.sax.Encryptor" #define SERVICE_NAME "com.sun.star.xml.crypto.sax.Encryptor"
#define IMPLEMENTATION_NAME "com.sun.star.xml.security.framework.EncryptorImpl" #define IMPLEMENTATION_NAME "com.sun.star.xml.security.framework.EncryptorImpl"
EncryptorImpl::EncryptorImpl( const cssu::Reference< cssl::XMultiServiceFactory >& rxMSF) EncryptorImpl::EncryptorImpl(const Reference<XComponentContext> & xContext) : EncryptorImpl(xContext)
{ {
m_nReferenceId = -1; m_nReferenceId = -1;
mxMSF = rxMSF;
} }
EncryptorImpl::~EncryptorImpl() EncryptorImpl::~EncryptorImpl()
@ -79,7 +79,7 @@ bool EncryptorImpl::checkReady() const
} }
void EncryptorImpl::notifyResultListener() const void EncryptorImpl::notifyResultListener() const
throw (cssu::Exception, cssu::RuntimeException) throw (Exception, RuntimeException)
/****** DecryptorImpl/notifyResultListener *********************************** /****** DecryptorImpl/notifyResultListener ***********************************
* *
* NAME * NAME
@ -103,16 +103,16 @@ void EncryptorImpl::notifyResultListener() const
* Email: michael.mi@sun.com * Email: michael.mi@sun.com
******************************************************************************/ ******************************************************************************/
{ {
cssu::Reference< cssxc::sax::XEncryptionResultListener > Reference< cssxc::sax::XEncryptionResultListener >
xEncryptionResultListener ( m_xResultListener , cssu::UNO_QUERY ) ; xEncryptionResultListener ( m_xResultListener , UNO_QUERY ) ;
xEncryptionResultListener->encrypted( m_nSecurityId, m_nStatus ); xEncryptionResultListener->encrypted( m_nSecurityId, m_nStatus );
} }
void EncryptorImpl::startEngine( const cssu::Reference< void EncryptorImpl::startEngine( const Reference<
cssxc::XXMLEncryptionTemplate >& cssxc::XXMLEncryptionTemplate >&
xEncryptionTemplate) xEncryptionTemplate)
throw (cssu::Exception, cssu::RuntimeException) throw (Exception, RuntimeException)
/****** EncryptorImpl/startEngine ******************************************** /****** EncryptorImpl/startEngine ********************************************
* *
* NAME * NAME
@ -137,9 +137,9 @@ void EncryptorImpl::startEngine( const cssu::Reference<
* Email: michael.mi@sun.com * Email: michael.mi@sun.com
******************************************************************************/ ******************************************************************************/
{ {
cssu::Reference < cssxc::XXMLEncryptionTemplate > xResultTemplate; Reference < cssxc::XXMLEncryptionTemplate > xResultTemplate;
cssu::Reference< cssxw::XXMLElementWrapper > Reference< cssxw::XXMLElementWrapper >
xXMLElement = m_xSAXEventKeeper->getElement( m_nReferenceId ); xXMLElement = m_xSAXEventKeeper->getElement( m_nReferenceId );
xEncryptionTemplate->setTarget(xXMLElement); xEncryptionTemplate->setTarget(xXMLElement);
@ -149,14 +149,14 @@ void EncryptorImpl::startEngine( const cssu::Reference<
xEncryptionTemplate, m_xSecurityEnvironment); xEncryptionTemplate, m_xSecurityEnvironment);
m_nStatus = xResultTemplate->getStatus(); m_nStatus = xResultTemplate->getStatus();
} }
catch( cssu::Exception& ) catch( Exception& )
{ {
m_nStatus = cssxc::SecurityOperationStatus_RUNTIMEERROR_FAILED; m_nStatus = cssxc::SecurityOperationStatus_RUNTIMEERROR_FAILED;
} }
if (m_nStatus == cssxc::SecurityOperationStatus_OPERATION_SUCCEEDED) if (m_nStatus == cssxc::SecurityOperationStatus_OPERATION_SUCCEEDED)
{ {
cssu::Reference < cssxw::XXMLElementWrapper > xResultEncryption Reference < cssxw::XXMLElementWrapper > xResultEncryption
= xResultTemplate->getTemplate(); = xResultTemplate->getTemplate();
m_xSAXEventKeeper->setElement(m_nIdOfTemplateEC, xResultEncryption); m_xSAXEventKeeper->setElement(m_nIdOfTemplateEC, xResultEncryption);
m_xSAXEventKeeper->setElement(m_nReferenceId, NULL); m_xSAXEventKeeper->setElement(m_nReferenceId, NULL);
@ -165,7 +165,7 @@ void EncryptorImpl::startEngine( const cssu::Reference<
/* XReferenceCollector */ /* XReferenceCollector */
void SAL_CALL EncryptorImpl::setReferenceCount(sal_Int32) void SAL_CALL EncryptorImpl::setReferenceCount(sal_Int32)
throw (cssu::Exception, cssu::RuntimeException) throw (Exception, RuntimeException)
{ {
/* /*
* dummp method, because there is only one reference in * dummp method, because there is only one reference in
@ -175,27 +175,27 @@ void SAL_CALL EncryptorImpl::setReferenceCount(sal_Int32)
} }
void SAL_CALL EncryptorImpl::setReferenceId( sal_Int32 id ) void SAL_CALL EncryptorImpl::setReferenceId( sal_Int32 id )
throw (cssu::Exception, cssu::RuntimeException) throw (Exception, RuntimeException)
{ {
m_nReferenceId = id; m_nReferenceId = id;
} }
/* XEncryptionResultBroadcaster */ /* XEncryptionResultBroadcaster */
void SAL_CALL EncryptorImpl::addEncryptionResultListener( const cssu::Reference< cssxc::sax::XEncryptionResultListener >& listener ) void SAL_CALL EncryptorImpl::addEncryptionResultListener( const Reference< cssxc::sax::XEncryptionResultListener >& listener )
throw (cssu::Exception, cssu::RuntimeException) throw (Exception, RuntimeException)
{ {
m_xResultListener = listener; m_xResultListener = listener;
tryToPerform(); tryToPerform();
} }
void SAL_CALL EncryptorImpl::removeEncryptionResultListener( const cssu::Reference< cssxc::sax::XEncryptionResultListener >&) void SAL_CALL EncryptorImpl::removeEncryptionResultListener( const Reference< cssxc::sax::XEncryptionResultListener >&)
throw (cssu::RuntimeException) throw (RuntimeException)
{ {
} }
/* XInitialization */ /* XInitialization */
void SAL_CALL EncryptorImpl::initialize( const cssu::Sequence< cssu::Any >& aArguments ) void SAL_CALL EncryptorImpl::initialize( const Sequence< Any >& aArguments )
throw (cssu::Exception, cssu::RuntimeException) throw (Exception, RuntimeException)
{ {
OSL_ASSERT(aArguments.getLength() == 5); OSL_ASSERT(aArguments.getLength() == 5);
@ -212,47 +212,47 @@ void SAL_CALL EncryptorImpl::initialize( const cssu::Sequence< cssu::Any >& aArg
OUString EncryptorImpl_getImplementationName () OUString EncryptorImpl_getImplementationName ()
throw (cssu::RuntimeException) throw (RuntimeException)
{ {
return OUString ( IMPLEMENTATION_NAME ); return OUString ( IMPLEMENTATION_NAME );
} }
sal_Bool SAL_CALL EncryptorImpl_supportsService( const OUString& ServiceName ) sal_Bool SAL_CALL EncryptorImpl_supportsService( const OUString& ServiceName )
throw (cssu::RuntimeException) throw (RuntimeException)
{ {
return ServiceName == SERVICE_NAME; return ServiceName == SERVICE_NAME;
} }
cssu::Sequence< OUString > SAL_CALL EncryptorImpl_getSupportedServiceNames( ) Sequence< OUString > SAL_CALL EncryptorImpl_getSupportedServiceNames( )
throw (cssu::RuntimeException) throw (RuntimeException)
{ {
cssu::Sequence < OUString > aRet(1); Sequence < OUString > aRet(1);
OUString* pArray = aRet.getArray(); OUString* pArray = aRet.getArray();
pArray[0] = OUString ( SERVICE_NAME ); pArray[0] = OUString ( SERVICE_NAME );
return aRet; return aRet;
} }
#undef SERVICE_NAME #undef SERVICE_NAME
cssu::Reference< cssu::XInterface > SAL_CALL EncryptorImpl_createInstance( Reference< XInterface > SAL_CALL EncryptorImpl_createInstance(
const cssu::Reference< cssl::XMultiServiceFactory >& rSMgr) const Reference< cssl::XMultiServiceFactory >& xMSF)
throw( cssu::Exception ) throw( Exception )
{ {
return (cppu::OWeakObject*) new EncryptorImpl(rSMgr); return (cppu::OWeakObject*) new EncryptorImpl( comphelper::getComponentContext( xMSF ) );
} }
/* XServiceInfo */ /* XServiceInfo */
OUString SAL_CALL EncryptorImpl::getImplementationName( ) OUString SAL_CALL EncryptorImpl::getImplementationName( )
throw (cssu::RuntimeException) throw (RuntimeException)
{ {
return EncryptorImpl_getImplementationName(); return EncryptorImpl_getImplementationName();
} }
sal_Bool SAL_CALL EncryptorImpl::supportsService( const OUString& rServiceName ) sal_Bool SAL_CALL EncryptorImpl::supportsService( const OUString& rServiceName )
throw (cssu::RuntimeException) throw (RuntimeException)
{ {
return EncryptorImpl_supportsService( rServiceName ); return EncryptorImpl_supportsService( rServiceName );
} }
cssu::Sequence< OUString > SAL_CALL EncryptorImpl::getSupportedServiceNames( ) Sequence< OUString > SAL_CALL EncryptorImpl::getSupportedServiceNames( )
throw (cssu::RuntimeException) throw (RuntimeException)
{ {
return EncryptorImpl_getSupportedServiceNames(); return EncryptorImpl_getSupportedServiceNames();
} }

View File

@ -30,14 +30,16 @@
#include "encryptionengine.hxx" #include "encryptionengine.hxx"
class EncryptorImpl : public cppu::ImplInheritanceHelper4 typedef cppu::ImplInheritanceHelper4
< <
EncryptionEngine, EncryptionEngine,
com::sun::star::xml::crypto::sax::XEncryptionResultBroadcaster, com::sun::star::xml::crypto::sax::XEncryptionResultBroadcaster,
com::sun::star::xml::crypto::sax::XReferenceCollector, com::sun::star::xml::crypto::sax::XReferenceCollector,
com::sun::star::lang::XInitialization, com::sun::star::lang::XInitialization,
com::sun::star::lang::XServiceInfo com::sun::star::lang::XServiceInfo
> > EncryptorImpl_Base;
class EncryptorImpl : public EncryptorImpl_Base
/****** EncryptorImpl.hxx/CLASS EncryptorImpl ********************************* /****** EncryptorImpl.hxx/CLASS EncryptorImpl *********************************
* *
* NAME * NAME
@ -70,8 +72,7 @@ private:
throw (com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException); throw (com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException);
public: public:
explicit EncryptorImpl( const com::sun::star::uno::Reference< explicit EncryptorImpl(const com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > & xContext);
com::sun::star::lang::XMultiServiceFactory >& rxMSF);
virtual ~EncryptorImpl(); virtual ~EncryptorImpl();
/* XEncryptionResultBroadcaster */ /* XEncryptionResultBroadcaster */

View File

@ -24,9 +24,8 @@
namespace cssu = com::sun::star::uno; namespace cssu = com::sun::star::uno;
namespace cssl = com::sun::star::lang; namespace cssl = com::sun::star::lang;
SecurityEngine::SecurityEngine( const cssu::Reference< cssl::XMultiServiceFactory >& rxMSF ) SecurityEngine::SecurityEngine()
:mxMSF( rxMSF ), :m_nIdOfTemplateEC(-1),
m_nIdOfTemplateEC(-1),
m_nNumOfResolvedReferences(0), m_nNumOfResolvedReferences(0),
m_nIdOfKeyEC(-1), m_nIdOfKeyEC(-1),
m_bMissionDone(false), m_bMissionDone(false),

View File

@ -50,8 +50,6 @@ class SecurityEngine : public cppu::WeakImplHelper3
******************************************************************************/ ******************************************************************************/
{ {
protected: protected:
com::sun::star::uno::Reference<
com::sun::star::lang::XMultiServiceFactory > mxMSF;
/* /*
* A SAXEventKeeper internally maintians all resources that a security * A SAXEventKeeper internally maintians all resources that a security
@ -106,8 +104,7 @@ protected:
m_xResultListener; m_xResultListener;
protected: protected:
explicit SecurityEngine( const com::sun::star::uno::Reference< explicit SecurityEngine();
com::sun::star::lang::XMultiServiceFactory >& rxMSF = NULL );
virtual ~SecurityEngine() {}; virtual ~SecurityEngine() {};
/* /*

View File

@ -22,7 +22,9 @@
#include <com/sun/star/xml/crypto/XXMLSignatureTemplate.hpp> #include <com/sun/star/xml/crypto/XXMLSignatureTemplate.hpp>
#include <com/sun/star/xml/wrapper/XXMLElementWrapper.hpp> #include <com/sun/star/xml/wrapper/XXMLElementWrapper.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <comphelper/processfactory.hxx>
using namespace com::sun::star::uno;
namespace cssu = com::sun::star::uno; namespace cssu = com::sun::star::uno;
namespace cssl = com::sun::star::lang; namespace cssl = com::sun::star::lang;
namespace cssxc = com::sun::star::xml::crypto; namespace cssxc = com::sun::star::xml::crypto;
@ -31,10 +33,9 @@ namespace cssxw = com::sun::star::xml::wrapper;
#define SERVICE_NAME "com.sun.star.xml.crypto.sax.SignatureCreator" #define SERVICE_NAME "com.sun.star.xml.crypto.sax.SignatureCreator"
#define IMPLEMENTATION_NAME "com.sun.star.xml.security.framework.SignatureCreatorImpl" #define IMPLEMENTATION_NAME "com.sun.star.xml.security.framework.SignatureCreatorImpl"
SignatureCreatorImpl::SignatureCreatorImpl( const cssu::Reference< cssl::XMultiServiceFactory >& rxMSF ) SignatureCreatorImpl::SignatureCreatorImpl( const Reference<XComponentContext> & xContext )
:m_nIdOfBlocker(-1) : SignatureCreatorImpl_Base(xContext), m_nIdOfBlocker(-1)
{ {
mxMSF = rxMSF;
} }
SignatureCreatorImpl::~SignatureCreatorImpl( ) SignatureCreatorImpl::~SignatureCreatorImpl( )
@ -247,10 +248,10 @@ cssu::Sequence< OUString > SAL_CALL SignatureCreatorImpl_getSupportedServiceName
#undef SERVICE_NAME #undef SERVICE_NAME
cssu::Reference< cssu::XInterface > SAL_CALL SignatureCreatorImpl_createInstance( cssu::Reference< cssu::XInterface > SAL_CALL SignatureCreatorImpl_createInstance(
const cssu::Reference< cssl::XMultiServiceFactory >& rSMgr) const cssu::Reference< cssl::XMultiServiceFactory >& xMSF )
throw( cssu::Exception ) throw( cssu::Exception )
{ {
return (cppu::OWeakObject*) new SignatureCreatorImpl( rSMgr ); return (cppu::OWeakObject*) new SignatureCreatorImpl( comphelper::getComponentContext( xMSF ) );
} }
/* XServiceInfo */ /* XServiceInfo */

View File

@ -30,14 +30,16 @@
#include "signatureengine.hxx" #include "signatureengine.hxx"
class SignatureCreatorImpl : public cppu::ImplInheritanceHelper4 typedef cppu::ImplInheritanceHelper4
< <
SignatureEngine, SignatureEngine,
com::sun::star::xml::crypto::sax::XBlockerMonitor, com::sun::star::xml::crypto::sax::XBlockerMonitor,
com::sun::star::xml::crypto::sax::XSignatureCreationResultBroadcaster, com::sun::star::xml::crypto::sax::XSignatureCreationResultBroadcaster,
com::sun::star::lang::XInitialization, com::sun::star::lang::XInitialization,
com::sun::star::lang::XServiceInfo com::sun::star::lang::XServiceInfo
> > SignatureCreatorImpl_Base;
class SignatureCreatorImpl : public SignatureCreatorImpl_Base
/****** SignatureCreatorImpl.hxx/CLASS SignatureCreatorImpl ******************* /****** SignatureCreatorImpl.hxx/CLASS SignatureCreatorImpl *******************
* *
* NAME * NAME
@ -71,8 +73,7 @@ private:
throw (com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException); throw (com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException);
public: public:
explicit SignatureCreatorImpl( const com::sun::star::uno::Reference< explicit SignatureCreatorImpl( const com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > & xContext );
com::sun::star::lang::XMultiServiceFactory >& rxMSF);
virtual ~SignatureCreatorImpl(); virtual ~SignatureCreatorImpl();
/* XBlockerMonitor */ /* XBlockerMonitor */

View File

@ -23,6 +23,7 @@
#include <com/sun/star/xml/wrapper/XXMLElementWrapper.hpp> #include <com/sun/star/xml/wrapper/XXMLElementWrapper.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp>
using namespace com::sun::star::uno;
namespace cssu = com::sun::star::uno; namespace cssu = com::sun::star::uno;
namespace cssl = com::sun::star::lang; namespace cssl = com::sun::star::lang;
namespace cssxc = com::sun::star::xml::crypto; namespace cssxc = com::sun::star::xml::crypto;
@ -30,8 +31,8 @@ namespace cssxw = com::sun::star::xml::wrapper;
#define SIGNATURE_TEMPLATE "com.sun.star.xml.crypto.XMLSignatureTemplate" #define SIGNATURE_TEMPLATE "com.sun.star.xml.crypto.XMLSignatureTemplate"
SignatureEngine::SignatureEngine( ) SignatureEngine::SignatureEngine( const Reference<XComponentContext> & xContext)
:m_nTotalReferenceNumber(-1) : m_xContext(xContext), m_nTotalReferenceNumber(-1)
{ {
} }
@ -115,7 +116,7 @@ void SignatureEngine::tryToPerform( )
{ {
const OUString ouSignatureTemplate ( SIGNATURE_TEMPLATE ); const OUString ouSignatureTemplate ( SIGNATURE_TEMPLATE );
cssu::Reference < cssxc::XXMLSignatureTemplate > cssu::Reference < cssxc::XXMLSignatureTemplate >
xSignatureTemplate( mxMSF->createInstance( ouSignatureTemplate ), cssu::UNO_QUERY ); xSignatureTemplate( m_xContext->getServiceManager()->createInstanceWithContext( ouSignatureTemplate, m_xContext ), cssu::UNO_QUERY );
OSL_ASSERT( xSignatureTemplate.is() ); OSL_ASSERT( xSignatureTemplate.is() );

View File

@ -30,6 +30,7 @@
#include <com/sun/star/xml/crypto/XXMLSignature.hpp> #include <com/sun/star/xml/crypto/XXMLSignature.hpp>
#include <com/sun/star/xml/crypto/XUriBinding.hpp> #include <com/sun/star/xml/crypto/XUriBinding.hpp>
#include <com/sun/star/io/XInputStream.hpp> #include <com/sun/star/io/XInputStream.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
#include <cppuhelper/implbase2.hxx> #include <cppuhelper/implbase2.hxx>
@ -56,6 +57,9 @@ class SignatureEngine : public cppu::ImplInheritanceHelper2
* Email: michael.mi@sun.com * Email: michael.mi@sun.com
******************************************************************************/ ******************************************************************************/
{ {
private:
com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > m_xContext;
protected: protected:
/* /*
@ -87,7 +91,7 @@ protected:
com::sun::star::io::XInputStream > > m_vXInputStreams; com::sun::star::io::XInputStream > > m_vXInputStreams;
protected: protected:
SignatureEngine( ); SignatureEngine( const com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > & xContext);
virtual ~SignatureEngine() {}; virtual ~SignatureEngine() {};
virtual void tryToPerform( ) virtual void tryToPerform( )

View File

@ -22,6 +22,7 @@
#include <com/sun/star/xml/crypto/XXMLSignatureTemplate.hpp> #include <com/sun/star/xml/crypto/XXMLSignatureTemplate.hpp>
#include <com/sun/star/xml/wrapper/XXMLElementWrapper.hpp> #include <com/sun/star/xml/wrapper/XXMLElementWrapper.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <comphelper/processfactory.hxx>
namespace cssu = com::sun::star::uno; namespace cssu = com::sun::star::uno;
namespace cssl = com::sun::star::lang; namespace cssl = com::sun::star::lang;
@ -30,9 +31,9 @@ namespace cssxc = com::sun::star::xml::crypto;
#define SERVICE_NAME "com.sun.star.xml.crypto.sax.SignatureVerifier" #define SERVICE_NAME "com.sun.star.xml.crypto.sax.SignatureVerifier"
#define IMPLEMENTATION_NAME "com.sun.star.xml.security.framework.SignatureVerifierImpl" #define IMPLEMENTATION_NAME "com.sun.star.xml.security.framework.SignatureVerifierImpl"
SignatureVerifierImpl::SignatureVerifierImpl( const cssu::Reference< cssl::XMultiServiceFactory >& rxMSF) SignatureVerifierImpl::SignatureVerifierImpl( const cssu::Reference< css::uno::XComponentContext >& xContext)
: SignatureVerifierImpl_Base(xContext)
{ {
mxMSF = rxMSF;
} }
SignatureVerifierImpl::~SignatureVerifierImpl() SignatureVerifierImpl::~SignatureVerifierImpl()
@ -196,7 +197,7 @@ cssu::Reference< cssu::XInterface > SAL_CALL SignatureVerifierImpl_createInstanc
const cssu::Reference< cssl::XMultiServiceFactory >& rSMgr) const cssu::Reference< cssl::XMultiServiceFactory >& rSMgr)
throw( cssu::Exception ) throw( cssu::Exception )
{ {
return (cppu::OWeakObject*) new SignatureVerifierImpl(rSMgr); return (cppu::OWeakObject*) new SignatureVerifierImpl( comphelper::getComponentContext(rSMgr) );
} }
/* XServiceInfo */ /* XServiceInfo */

View File

@ -25,17 +25,20 @@
#include <com/sun/star/xml/crypto/XXMLSecurityContext.hpp> #include <com/sun/star/xml/crypto/XXMLSecurityContext.hpp>
#include <com/sun/star/lang/XInitialization.hpp> #include <com/sun/star/lang/XInitialization.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
#include <cppuhelper/implbase3.hxx> #include <cppuhelper/implbase3.hxx>
#include "signatureengine.hxx" #include "signatureengine.hxx"
class SignatureVerifierImpl : public cppu::ImplInheritanceHelper3 typedef cppu::ImplInheritanceHelper3
< <
SignatureEngine, SignatureEngine,
com::sun::star::xml::crypto::sax::XSignatureVerifyResultBroadcaster, com::sun::star::xml::crypto::sax::XSignatureVerifyResultBroadcaster,
com::sun::star::lang::XInitialization, com::sun::star::lang::XInitialization,
com::sun::star::lang::XServiceInfo com::sun::star::lang::XServiceInfo
> > SignatureVerifierImpl_Base;
class SignatureVerifierImpl : public SignatureVerifierImpl_Base
/****** SignatureVerifier.hxx/CLASS SignatureVerifierImpl ********************* /****** SignatureVerifier.hxx/CLASS SignatureVerifierImpl *********************
* *
* NAME * NAME
@ -64,7 +67,7 @@ private:
public: public:
explicit SignatureVerifierImpl( const com::sun::star::uno::Reference< explicit SignatureVerifierImpl( const com::sun::star::uno::Reference<
com::sun::star::lang::XMultiServiceFactory >& rxMSF); com::sun::star::uno::XComponentContext >& rxContext);
virtual ~SignatureVerifierImpl(); virtual ~SignatureVerifierImpl();
/* XSignatureVerifyResultBroadcaster */ /* XSignatureVerifyResultBroadcaster */