diff options
Diffstat (limited to 'xmlsecurity/source/xmlsec/mscrypt/seinitializer_mscryptimpl.cxx')
-rw-r--r-- | xmlsecurity/source/xmlsec/mscrypt/seinitializer_mscryptimpl.cxx | 74 |
1 files changed, 20 insertions, 54 deletions
diff --git a/xmlsecurity/source/xmlsec/mscrypt/seinitializer_mscryptimpl.cxx b/xmlsecurity/source/xmlsec/mscrypt/seinitializer_mscryptimpl.cxx index 36ea2903ae1b..af584e2f1602 100644 --- a/xmlsecurity/source/xmlsec/mscrypt/seinitializer_mscryptimpl.cxx +++ b/xmlsecurity/source/xmlsec/mscrypt/seinitializer_mscryptimpl.cxx @@ -24,19 +24,17 @@ #include "xmlsecurity/xmlsec-wrapper.h" #include "xmlsec/mscrypto/app.h" +#include "com/sun/star/xml/crypto/SecurityEnvironment.hpp" +#include "com/sun/star/xml/crypto/XMLSecurityContext.hpp" +#include "comphelper/processfactory.hxx" namespace cssu = com::sun::star::uno; namespace cssl = com::sun::star::lang; namespace cssxc = com::sun::star::xml::crypto; -#define SERVICE_NAME "com.sun.star.xml.crypto.SEInitializer" -#define IMPLEMENTATION_NAME "com.sun.star.xml.security.bridge.xmlsec.SEInitializer_MSCryptImpl" -#define SECURITY_ENVIRONMENT "com.sun.star.xml.crypto.SecurityEnvironment" -#define SECURITY_CONTEXT "com.sun.star.xml.crypto.XMLSecurityContext" - SEInitializer_MSCryptImpl::SEInitializer_MSCryptImpl( - const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > &rxMSF) - :mxMSF( rxMSF ) + const cssu::Reference< cssu::XComponentContext > &rxContext) + :mxContext( rxContext ) { } @@ -74,33 +72,11 @@ cssu::Reference< cssxc::XXMLSecurityContext > SAL_CALL try { /* Build Security Environment */ - const OUString sSecyrutyEnvironment ( RTL_CONSTASCII_USTRINGPARAM( SECURITY_ENVIRONMENT ) ); - cssu::Reference< cssxc::XSecurityEnvironment > xSecEnv( mxMSF->createInstance ( sSecyrutyEnvironment ), cssu::UNO_QUERY ); - if( !xSecEnv.is() ) - { - if( n_hStoreHandle != NULL ) - { - CertCloseStore( n_hStoreHandle, CERT_CLOSE_STORE_FORCE_FLAG ) ; - } - - xmlSecMSCryptoAppShutdown() ; - return NULL; - } + cssu::Reference< cssxc::XSecurityEnvironment > xSecEnv = cssxc::SecurityEnvironment::create( mxContext ); /* Setup key slot and certDb */ - cssu::Reference< cssl::XUnoTunnel > xEnvTunnel( xSecEnv , cssu::UNO_QUERY ) ; - if( !xEnvTunnel.is() ) - { - if( n_hStoreHandle != NULL ) - { - CertCloseStore( n_hStoreHandle, CERT_CLOSE_STORE_FORCE_FLAG ) ; - } - - xmlSecMSCryptoAppShutdown() ; - return NULL; - } - - SecurityEnvironment_MSCryptImpl* pSecEnv = ( SecurityEnvironment_MSCryptImpl* )xEnvTunnel->getSomething( SecurityEnvironment_MSCryptImpl::getUnoTunnelId() ) ; + cssu::Reference< cssl::XUnoTunnel > xSecEnvTunnel( xSecEnv, cssu::UNO_QUERY_THROW ); + SecurityEnvironment_MSCryptImpl* pSecEnv = ( SecurityEnvironment_MSCryptImpl* )xSecEnvTunnel->getSomething( SecurityEnvironment_MSCryptImpl::getUnoTunnelId() ) ; if( pSecEnv == NULL ) { if( n_hStoreHandle != NULL ) @@ -123,18 +99,7 @@ cssu::Reference< cssxc::XXMLSecurityContext > SAL_CALL } /* Build XML Security Context */ - const OUString sSecyrutyContext ( RTL_CONSTASCII_USTRINGPARAM( SECURITY_CONTEXT ) ); - cssu::Reference< cssxc::XXMLSecurityContext > xSecCtx( mxMSF->createInstance ( sSecyrutyContext ), cssu::UNO_QUERY ); - if( !xSecCtx.is() ) - { - if( n_hStoreHandle != NULL ) - { - CertCloseStore( n_hStoreHandle, CERT_CLOSE_STORE_FORCE_FLAG ) ; - } - - xmlSecMSCryptoAppShutdown() ; - return NULL; - } + cssu::Reference< cssxc::XXMLSecurityContext > xSecCtx = cssxc::XMLSecurityContext::create( mxContext ); xSecCtx->setDefaultSecurityEnvironmentIndex(xSecCtx->addSecurityEnvironment( xSecEnv )) ; return xSecCtx; @@ -181,46 +146,47 @@ void SAL_CALL SEInitializer_MSCryptImpl::freeSecurityContext( const cssu::Refere xmlSecMSCryptoAppShutdown() ; } -OUString SEInitializer_MSCryptImpl_getImplementationName () +OUString SEInitializer_MSCryptImpl_getImplementationName() throw (cssu::RuntimeException) { - return OUString ( RTL_CONSTASCII_USTRINGPARAM ( IMPLEMENTATION_NAME ) ); + return OUString( "com.sun.star.xml.security.bridge.xmlsec.SEInitializer_MSCryptImpl" ); } -sal_Bool SAL_CALL SEInitializer_MSCryptImpl_supportsService( const OUString& ServiceName ) +sal_Bool SAL_CALL SEInitializer_MSCryptImpl_supportsService( const OUString& rServiceName ) throw (cssu::RuntimeException) { - return ServiceName == SERVICE_NAME; + return rServiceName == "com.sun.star.xml.crypto.SEInitializer"; } -cssu::Sequence< OUString > SAL_CALL SEInitializer_MSCryptImpl_getSupportedServiceNames( ) +cssu::Sequence< OUString > SAL_CALL SEInitializer_MSCryptImpl_getSupportedServiceNames() throw (cssu::RuntimeException) { cssu::Sequence < OUString > aRet(1); OUString* pArray = aRet.getArray(); - pArray[0] = OUString ( RTL_CONSTASCII_USTRINGPARAM ( SERVICE_NAME ) ); + pArray[0] = OUString( "com.sun.star.xml.crypto.SEInitializer" ); return aRet; } -#undef SERVICE_NAME cssu::Reference< cssu::XInterface > SAL_CALL SEInitializer_MSCryptImpl_createInstance( const cssu::Reference< cssl::XMultiServiceFactory > & rSMgr) throw( cssu::Exception ) { - return (cppu::OWeakObject*) new SEInitializer_MSCryptImpl(rSMgr); + return (cppu::OWeakObject*) new SEInitializer_MSCryptImpl( comphelper::getComponentContext(rSMgr) ); } /* XServiceInfo */ -OUString SAL_CALL SEInitializer_MSCryptImpl::getImplementationName( ) +OUString SAL_CALL SEInitializer_MSCryptImpl::getImplementationName() throw (cssu::RuntimeException) { return SEInitializer_MSCryptImpl_getImplementationName(); } + sal_Bool SAL_CALL SEInitializer_MSCryptImpl::supportsService( const OUString& rServiceName ) throw (cssu::RuntimeException) { return SEInitializer_MSCryptImpl_supportsService( rServiceName ); } -cssu::Sequence< OUString > SAL_CALL SEInitializer_MSCryptImpl::getSupportedServiceNames( ) + +cssu::Sequence< OUString > SAL_CALL SEInitializer_MSCryptImpl::getSupportedServiceNames() throw (cssu::RuntimeException) { return SEInitializer_MSCryptImpl_getSupportedServiceNames(); |