1*06b3ce53SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*06b3ce53SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*06b3ce53SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*06b3ce53SAndrew Rist * distributed with this work for additional information 6*06b3ce53SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*06b3ce53SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*06b3ce53SAndrew Rist * "License"); you may not use this file except in compliance 9*06b3ce53SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*06b3ce53SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*06b3ce53SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*06b3ce53SAndrew Rist * software distributed under the License is distributed on an 15*06b3ce53SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*06b3ce53SAndrew Rist * KIND, either express or implied. See the License for the 17*06b3ce53SAndrew Rist * specific language governing permissions and limitations 18*06b3ce53SAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*06b3ce53SAndrew Rist *************************************************************/ 21*06b3ce53SAndrew Rist 22*06b3ce53SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_xmlsecurity.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <sal/config.h> 28cdf0e10cSrcweir #include <rtl/uuid.h> 29cdf0e10cSrcweir #include "xmlencryption_mscryptimpl.hxx" 30cdf0e10cSrcweir 31cdf0e10cSrcweir #ifndef _XMLDOCUMENTWRAPPER_XMLSECIMPL_HXX_ 32cdf0e10cSrcweir #include "xmldocumentwrapper_xmlsecimpl.hxx" 33cdf0e10cSrcweir #endif 34cdf0e10cSrcweir 35cdf0e10cSrcweir #ifndef _XMLELEMENTWRAPPER_XMLSECIMPL_HXX_ 36cdf0e10cSrcweir #include "xmlelementwrapper_xmlsecimpl.hxx" 37cdf0e10cSrcweir #endif 38cdf0e10cSrcweir 39cdf0e10cSrcweir #ifndef _SECURITYENVIRONMENT_MSCRYPTIMPL_HXX_ 40cdf0e10cSrcweir #include "securityenvironment_mscryptimpl.hxx" 41cdf0e10cSrcweir #endif 42cdf0e10cSrcweir #include "errorcallback.hxx" 43cdf0e10cSrcweir 44cdf0e10cSrcweir #include "xmlsec/xmlsec.h" 45cdf0e10cSrcweir #include "xmlsec/xmltree.h" 46cdf0e10cSrcweir #include "xmlsec/xmlenc.h" 47cdf0e10cSrcweir #include "xmlsec/crypto.h" 48cdf0e10cSrcweir 49cdf0e10cSrcweir #ifdef UNX 50cdf0e10cSrcweir #define stricmp strcasecmp 51cdf0e10cSrcweir #endif 52cdf0e10cSrcweir 53cdf0e10cSrcweir using namespace ::com::sun::star::uno ; 54cdf0e10cSrcweir using namespace ::com::sun::star::lang ; 55cdf0e10cSrcweir using ::com::sun::star::lang::XMultiServiceFactory ; 56cdf0e10cSrcweir using ::com::sun::star::lang::XSingleServiceFactory ; 57cdf0e10cSrcweir using ::rtl::OUString ; 58cdf0e10cSrcweir 59cdf0e10cSrcweir using ::com::sun::star::xml::wrapper::XXMLElementWrapper ; 60cdf0e10cSrcweir using ::com::sun::star::xml::wrapper::XXMLDocumentWrapper ; 61cdf0e10cSrcweir using ::com::sun::star::xml::crypto::XSecurityEnvironment ; 62cdf0e10cSrcweir using ::com::sun::star::xml::crypto::XXMLEncryption ; 63cdf0e10cSrcweir using ::com::sun::star::xml::crypto::XXMLEncryptionTemplate ; 64cdf0e10cSrcweir using ::com::sun::star::xml::crypto::XXMLSecurityContext ; 65cdf0e10cSrcweir using ::com::sun::star::xml::crypto::XMLEncryptionException ; 66cdf0e10cSrcweir 67cdf0e10cSrcweir XMLEncryption_MSCryptImpl :: XMLEncryption_MSCryptImpl( const Reference< XMultiServiceFactory >& aFactory ) : m_xServiceManager( aFactory ) { 68cdf0e10cSrcweir } 69cdf0e10cSrcweir 70cdf0e10cSrcweir XMLEncryption_MSCryptImpl :: ~XMLEncryption_MSCryptImpl() { 71cdf0e10cSrcweir } 72cdf0e10cSrcweir 73cdf0e10cSrcweir /* XXMLEncryption */ 74cdf0e10cSrcweir Reference< XXMLEncryptionTemplate > 75cdf0e10cSrcweir SAL_CALL XMLEncryption_MSCryptImpl :: encrypt( 76cdf0e10cSrcweir const Reference< XXMLEncryptionTemplate >& aTemplate , 77cdf0e10cSrcweir const Reference< XSecurityEnvironment >& aEnvironment 78cdf0e10cSrcweir ) throw( com::sun::star::xml::crypto::XMLEncryptionException, 79cdf0e10cSrcweir com::sun::star::uno::SecurityException ) 80cdf0e10cSrcweir { 81cdf0e10cSrcweir xmlSecKeysMngrPtr pMngr = NULL ; 82cdf0e10cSrcweir xmlSecEncCtxPtr pEncCtx = NULL ; 83cdf0e10cSrcweir xmlNodePtr pEncryptedData = NULL ; 84cdf0e10cSrcweir xmlNodePtr pContent = NULL ; 85cdf0e10cSrcweir 86cdf0e10cSrcweir if( !aTemplate.is() ) 87cdf0e10cSrcweir throw RuntimeException() ; 88cdf0e10cSrcweir 89cdf0e10cSrcweir if( !aEnvironment.is() ) 90cdf0e10cSrcweir throw RuntimeException() ; 91cdf0e10cSrcweir 92cdf0e10cSrcweir //Get Keys Manager 93cdf0e10cSrcweir Reference< XUnoTunnel > xSecTunnel( aEnvironment , UNO_QUERY ) ; 94cdf0e10cSrcweir if( !xSecTunnel.is() ) { 95cdf0e10cSrcweir throw RuntimeException() ; 96cdf0e10cSrcweir } 97cdf0e10cSrcweir 98cdf0e10cSrcweir SecurityEnvironment_MSCryptImpl* pSecEnv = ( SecurityEnvironment_MSCryptImpl* )xSecTunnel->getSomething( SecurityEnvironment_MSCryptImpl::getUnoTunnelId() ) ; 99cdf0e10cSrcweir if( pSecEnv == NULL ) 100cdf0e10cSrcweir throw RuntimeException() ; 101cdf0e10cSrcweir 102cdf0e10cSrcweir //Get the encryption template 103cdf0e10cSrcweir Reference< XXMLElementWrapper > xTemplate = aTemplate->getTemplate() ; 104cdf0e10cSrcweir if( !xTemplate.is() ) { 105cdf0e10cSrcweir throw RuntimeException() ; 106cdf0e10cSrcweir } 107cdf0e10cSrcweir 108cdf0e10cSrcweir Reference< XUnoTunnel > xTplTunnel( xTemplate , UNO_QUERY ) ; 109cdf0e10cSrcweir if( !xTplTunnel.is() ) { 110cdf0e10cSrcweir throw RuntimeException() ; 111cdf0e10cSrcweir } 112cdf0e10cSrcweir 113cdf0e10cSrcweir XMLElementWrapper_XmlSecImpl* pTemplate = ( XMLElementWrapper_XmlSecImpl* )xTplTunnel->getSomething( XMLElementWrapper_XmlSecImpl::getUnoTunnelImplementationId() ) ; 114cdf0e10cSrcweir if( pTemplate == NULL ) { 115cdf0e10cSrcweir throw RuntimeException() ; 116cdf0e10cSrcweir } 117cdf0e10cSrcweir 118cdf0e10cSrcweir pEncryptedData = pTemplate->getNativeElement() ; 119cdf0e10cSrcweir 120cdf0e10cSrcweir //Find the element to be encrypted. 121cdf0e10cSrcweir //This element is wrapped in the CipherValue sub-element. 122cdf0e10cSrcweir xmlNodePtr pCipherData = pEncryptedData->children; 123cdf0e10cSrcweir while (pCipherData != NULL && stricmp((const char *)(pCipherData->name), "CipherData")) 124cdf0e10cSrcweir { 125cdf0e10cSrcweir pCipherData = pCipherData->next; 126cdf0e10cSrcweir } 127cdf0e10cSrcweir 128cdf0e10cSrcweir if( pCipherData == NULL ) { 129cdf0e10cSrcweir throw XMLEncryptionException() ; 130cdf0e10cSrcweir } 131cdf0e10cSrcweir 132cdf0e10cSrcweir xmlNodePtr pCipherValue = pCipherData->children; 133cdf0e10cSrcweir while (pCipherValue != NULL && stricmp((const char *)(pCipherValue->name), "CipherValue")) 134cdf0e10cSrcweir { 135cdf0e10cSrcweir pCipherValue = pCipherValue->next; 136cdf0e10cSrcweir } 137cdf0e10cSrcweir 138cdf0e10cSrcweir if( pCipherValue == NULL ) { 139cdf0e10cSrcweir throw XMLEncryptionException() ; 140cdf0e10cSrcweir } 141cdf0e10cSrcweir 142cdf0e10cSrcweir pContent = pCipherValue->children; 143cdf0e10cSrcweir 144cdf0e10cSrcweir if( pContent == NULL ) { 145cdf0e10cSrcweir throw XMLEncryptionException() ; 146cdf0e10cSrcweir } 147cdf0e10cSrcweir 148cdf0e10cSrcweir xmlUnlinkNode(pContent); 149cdf0e10cSrcweir xmlAddNextSibling(pEncryptedData, pContent); 150cdf0e10cSrcweir 151cdf0e10cSrcweir //remember the position of the element to be signed 152cdf0e10cSrcweir sal_Bool isParentRef = sal_True; 153cdf0e10cSrcweir xmlNodePtr pParent = pEncryptedData->parent; 154cdf0e10cSrcweir xmlNodePtr referenceNode; 155cdf0e10cSrcweir 156cdf0e10cSrcweir if (pEncryptedData == pParent->children) 157cdf0e10cSrcweir { 158cdf0e10cSrcweir referenceNode = pParent; 159cdf0e10cSrcweir } 160cdf0e10cSrcweir else 161cdf0e10cSrcweir { 162cdf0e10cSrcweir referenceNode = pEncryptedData->prev; 163cdf0e10cSrcweir isParentRef = sal_False; 164cdf0e10cSrcweir } 165cdf0e10cSrcweir 166cdf0e10cSrcweir setErrorRecorder( ); 167cdf0e10cSrcweir 168cdf0e10cSrcweir pMngr = pSecEnv->createKeysManager() ; //i39448 169cdf0e10cSrcweir if( !pMngr ) { 170cdf0e10cSrcweir throw RuntimeException() ; 171cdf0e10cSrcweir } 172cdf0e10cSrcweir 173cdf0e10cSrcweir //Create Encryption context 174cdf0e10cSrcweir pEncCtx = xmlSecEncCtxCreate( pMngr ) ; 175cdf0e10cSrcweir if( pEncCtx == NULL ) 176cdf0e10cSrcweir { 177cdf0e10cSrcweir pSecEnv->destroyKeysManager( pMngr ) ; //i39448 178cdf0e10cSrcweir //throw XMLEncryptionException() ; 179cdf0e10cSrcweir clearErrorRecorder(); 180cdf0e10cSrcweir return aTemplate; 181cdf0e10cSrcweir } 182cdf0e10cSrcweir 183cdf0e10cSrcweir //Encrypt the template 184cdf0e10cSrcweir if( xmlSecEncCtxXmlEncrypt( pEncCtx , pEncryptedData , pContent ) < 0 ) { 185cdf0e10cSrcweir aTemplate->setStatus(::com::sun::star::xml::crypto::SecurityOperationStatus_UNKNOWN); 186cdf0e10cSrcweir xmlSecEncCtxDestroy( pEncCtx ) ; 187cdf0e10cSrcweir pSecEnv->destroyKeysManager( pMngr ) ; //i39448 188cdf0e10cSrcweir clearErrorRecorder(); 189cdf0e10cSrcweir return aTemplate; 190cdf0e10cSrcweir } 191cdf0e10cSrcweir aTemplate->setStatus(::com::sun::star::xml::crypto::SecurityOperationStatus_OPERATION_SUCCEEDED); 192cdf0e10cSrcweir xmlSecEncCtxDestroy( pEncCtx ) ; 193cdf0e10cSrcweir pSecEnv->destroyKeysManager( pMngr ) ; //i39448 194cdf0e10cSrcweir 195cdf0e10cSrcweir //get the new EncryptedData element 196cdf0e10cSrcweir if (isParentRef) 197cdf0e10cSrcweir { 198cdf0e10cSrcweir pTemplate->setNativeElement(referenceNode->children) ; 199cdf0e10cSrcweir } 200cdf0e10cSrcweir else 201cdf0e10cSrcweir { 202cdf0e10cSrcweir pTemplate->setNativeElement(referenceNode->next); 203cdf0e10cSrcweir } 204cdf0e10cSrcweir 205cdf0e10cSrcweir clearErrorRecorder(); 206cdf0e10cSrcweir return aTemplate ; 207cdf0e10cSrcweir } 208cdf0e10cSrcweir 209cdf0e10cSrcweir /* XXMLEncryption */ 210cdf0e10cSrcweir Reference< XXMLEncryptionTemplate > SAL_CALL 211cdf0e10cSrcweir XMLEncryption_MSCryptImpl :: decrypt( 212cdf0e10cSrcweir const Reference< XXMLEncryptionTemplate >& aTemplate , 213cdf0e10cSrcweir const Reference< XXMLSecurityContext >& aSecurityCtx 214cdf0e10cSrcweir ) throw( com::sun::star::xml::crypto::XMLEncryptionException , 215cdf0e10cSrcweir com::sun::star::uno::SecurityException) { 216cdf0e10cSrcweir xmlSecKeysMngrPtr pMngr = NULL ; 217cdf0e10cSrcweir xmlSecEncCtxPtr pEncCtx = NULL ; 218cdf0e10cSrcweir xmlNodePtr pEncryptedData = NULL ; 219cdf0e10cSrcweir 220cdf0e10cSrcweir if( !aTemplate.is() ) 221cdf0e10cSrcweir throw RuntimeException() ; 222cdf0e10cSrcweir 223cdf0e10cSrcweir if( !aSecurityCtx.is() ) 224cdf0e10cSrcweir throw RuntimeException() ; 225cdf0e10cSrcweir 226cdf0e10cSrcweir //Get Keys Manager 227cdf0e10cSrcweir Reference< XSecurityEnvironment > xSecEnv 228cdf0e10cSrcweir = aSecurityCtx->getSecurityEnvironmentByIndex( 229cdf0e10cSrcweir aSecurityCtx->getDefaultSecurityEnvironmentIndex()); 230cdf0e10cSrcweir Reference< XUnoTunnel > xSecTunnel( xSecEnv , UNO_QUERY ) ; 231cdf0e10cSrcweir if( !xSecTunnel.is() ) { 232cdf0e10cSrcweir throw RuntimeException() ; 233cdf0e10cSrcweir } 234cdf0e10cSrcweir 235cdf0e10cSrcweir SecurityEnvironment_MSCryptImpl* pSecEnv = ( SecurityEnvironment_MSCryptImpl* )xSecTunnel->getSomething( SecurityEnvironment_MSCryptImpl::getUnoTunnelId() ) ; 236cdf0e10cSrcweir if( pSecEnv == NULL ) 237cdf0e10cSrcweir throw RuntimeException() ; 238cdf0e10cSrcweir 239cdf0e10cSrcweir //Get the encryption template 240cdf0e10cSrcweir Reference< XXMLElementWrapper > xTemplate = aTemplate->getTemplate() ; 241cdf0e10cSrcweir if( !xTemplate.is() ) { 242cdf0e10cSrcweir throw RuntimeException() ; 243cdf0e10cSrcweir } 244cdf0e10cSrcweir 245cdf0e10cSrcweir Reference< XUnoTunnel > xTplTunnel( xTemplate , UNO_QUERY ) ; 246cdf0e10cSrcweir if( !xTplTunnel.is() ) { 247cdf0e10cSrcweir throw RuntimeException() ; 248cdf0e10cSrcweir } 249cdf0e10cSrcweir 250cdf0e10cSrcweir XMLElementWrapper_XmlSecImpl* pTemplate = ( XMLElementWrapper_XmlSecImpl* )xTplTunnel->getSomething( XMLElementWrapper_XmlSecImpl::getUnoTunnelImplementationId() ) ; 251cdf0e10cSrcweir if( pTemplate == NULL ) { 252cdf0e10cSrcweir throw RuntimeException() ; 253cdf0e10cSrcweir } 254cdf0e10cSrcweir 255cdf0e10cSrcweir pEncryptedData = pTemplate->getNativeElement() ; 256cdf0e10cSrcweir 257cdf0e10cSrcweir //remember the position of the element to be signed 258cdf0e10cSrcweir sal_Bool isParentRef = sal_True; 259cdf0e10cSrcweir xmlNodePtr pParent = pEncryptedData->parent; 260cdf0e10cSrcweir xmlNodePtr referenceNode; 261cdf0e10cSrcweir 262cdf0e10cSrcweir if (pEncryptedData == pParent->children) 263cdf0e10cSrcweir { 264cdf0e10cSrcweir referenceNode = pParent; 265cdf0e10cSrcweir } 266cdf0e10cSrcweir else 267cdf0e10cSrcweir { 268cdf0e10cSrcweir referenceNode = pEncryptedData->prev; 269cdf0e10cSrcweir isParentRef = sal_False; 270cdf0e10cSrcweir } 271cdf0e10cSrcweir 272cdf0e10cSrcweir setErrorRecorder( ); 273cdf0e10cSrcweir 274cdf0e10cSrcweir pMngr = pSecEnv->createKeysManager() ; //i39448 275cdf0e10cSrcweir if( !pMngr ) { 276cdf0e10cSrcweir throw RuntimeException() ; 277cdf0e10cSrcweir } 278cdf0e10cSrcweir 279cdf0e10cSrcweir //Create Encryption context 280cdf0e10cSrcweir pEncCtx = xmlSecEncCtxCreate( pMngr ) ; 281cdf0e10cSrcweir if( pEncCtx == NULL ) 282cdf0e10cSrcweir { 283cdf0e10cSrcweir pSecEnv->destroyKeysManager( pMngr ) ; //i39448 284cdf0e10cSrcweir //throw XMLEncryptionException() ; 285cdf0e10cSrcweir clearErrorRecorder(); 286cdf0e10cSrcweir return aTemplate; 287cdf0e10cSrcweir } 288cdf0e10cSrcweir 289cdf0e10cSrcweir //Decrypt the template 290cdf0e10cSrcweir if( xmlSecEncCtxDecrypt( pEncCtx , pEncryptedData ) < 0 || pEncCtx->result == NULL ) { 291cdf0e10cSrcweir aTemplate->setStatus(::com::sun::star::xml::crypto::SecurityOperationStatus_UNKNOWN); 292cdf0e10cSrcweir xmlSecEncCtxDestroy( pEncCtx ) ; 293cdf0e10cSrcweir pSecEnv->destroyKeysManager( pMngr ) ; //i39448 294cdf0e10cSrcweir 295cdf0e10cSrcweir //throw XMLEncryptionException() ; 296cdf0e10cSrcweir clearErrorRecorder(); 297cdf0e10cSrcweir return aTemplate; 298cdf0e10cSrcweir } 299cdf0e10cSrcweir aTemplate->setStatus(::com::sun::star::xml::crypto::SecurityOperationStatus_OPERATION_SUCCEEDED); 300cdf0e10cSrcweir /*---------------------------------------- 301cdf0e10cSrcweir if( pEncCtx->resultReplaced != 0 ) { 302cdf0e10cSrcweir pContent = pEncryptedData ; 303cdf0e10cSrcweir 304cdf0e10cSrcweir Reference< XUnoTunnel > xTunnel( ret , UNO_QUERY ) ; 305cdf0e10cSrcweir if( !xTunnel.is() ) { 306cdf0e10cSrcweir xmlSecEncCtxDestroy( pEncCtx ) ; 307cdf0e10cSrcweir throw RuntimeException() ; 308cdf0e10cSrcweir } 309cdf0e10cSrcweir XMLElementWrapper_XmlSecImpl* pNode = ( XMLElementWrapper_XmlSecImpl* )xTunnel->getSomething( XMLElementWrapper_XmlSecImpl::getUnoTunnelImplementationId() ) ; 310cdf0e10cSrcweir if( pNode == NULL ) { 311cdf0e10cSrcweir xmlSecEncCtxDestroy( pEncCtx ) ; 312cdf0e10cSrcweir throw RuntimeException() ; 313cdf0e10cSrcweir } 314cdf0e10cSrcweir 315cdf0e10cSrcweir pNode->setNativeElement( pContent ) ; 316cdf0e10cSrcweir } else { 317cdf0e10cSrcweir xmlSecEncCtxDestroy( pEncCtx ) ; 318cdf0e10cSrcweir throw RuntimeException() ; 319cdf0e10cSrcweir } 320cdf0e10cSrcweir ----------------------------------------*/ 321cdf0e10cSrcweir 322cdf0e10cSrcweir //Destroy the encryption context 323cdf0e10cSrcweir xmlSecEncCtxDestroy( pEncCtx ) ; 324cdf0e10cSrcweir pSecEnv->destroyKeysManager( pMngr ) ; //i39448 325cdf0e10cSrcweir 326cdf0e10cSrcweir //get the decrypted element 327cdf0e10cSrcweir XMLElementWrapper_XmlSecImpl * ret = new XMLElementWrapper_XmlSecImpl(isParentRef? 328cdf0e10cSrcweir (referenceNode->children):(referenceNode->next)); 329cdf0e10cSrcweir 330cdf0e10cSrcweir //return ret; 331cdf0e10cSrcweir aTemplate->setTemplate(ret); 332cdf0e10cSrcweir 333cdf0e10cSrcweir clearErrorRecorder(); 334cdf0e10cSrcweir return aTemplate; 335cdf0e10cSrcweir } 336cdf0e10cSrcweir 337cdf0e10cSrcweir /* XInitialization */ 338cdf0e10cSrcweir void SAL_CALL XMLEncryption_MSCryptImpl :: initialize( const Sequence< Any >& /*aArguments*/ ) throw( Exception, RuntimeException ) { 339cdf0e10cSrcweir // TBD 340cdf0e10cSrcweir } ; 341cdf0e10cSrcweir 342cdf0e10cSrcweir /* XServiceInfo */ 343cdf0e10cSrcweir OUString SAL_CALL XMLEncryption_MSCryptImpl :: getImplementationName() throw( RuntimeException ) { 344cdf0e10cSrcweir return impl_getImplementationName() ; 345cdf0e10cSrcweir } 346cdf0e10cSrcweir 347cdf0e10cSrcweir /* XServiceInfo */ 348cdf0e10cSrcweir sal_Bool SAL_CALL XMLEncryption_MSCryptImpl :: supportsService( const OUString& serviceName) throw( RuntimeException ) { 349cdf0e10cSrcweir Sequence< OUString > seqServiceNames = getSupportedServiceNames() ; 350cdf0e10cSrcweir const OUString* pArray = seqServiceNames.getConstArray() ; 351cdf0e10cSrcweir for( sal_Int32 i = 0 ; i < seqServiceNames.getLength() ; i ++ ) { 352cdf0e10cSrcweir if( *( pArray + i ) == serviceName ) 353cdf0e10cSrcweir return sal_True ; 354cdf0e10cSrcweir } 355cdf0e10cSrcweir return sal_False ; 356cdf0e10cSrcweir } 357cdf0e10cSrcweir 358cdf0e10cSrcweir /* XServiceInfo */ 359cdf0e10cSrcweir Sequence< OUString > SAL_CALL XMLEncryption_MSCryptImpl :: getSupportedServiceNames() throw( RuntimeException ) { 360cdf0e10cSrcweir return impl_getSupportedServiceNames() ; 361cdf0e10cSrcweir } 362cdf0e10cSrcweir 363cdf0e10cSrcweir //Helper for XServiceInfo 364cdf0e10cSrcweir Sequence< OUString > XMLEncryption_MSCryptImpl :: impl_getSupportedServiceNames() { 365cdf0e10cSrcweir ::osl::Guard< ::osl::Mutex > aGuard( ::osl::Mutex::getGlobalMutex() ) ; 366cdf0e10cSrcweir Sequence< OUString > seqServiceNames( 1 ) ; 367cdf0e10cSrcweir seqServiceNames.getArray()[0] = OUString::createFromAscii( "com.sun.star.xml.crypto.XMLEncryption" ) ; 368cdf0e10cSrcweir return seqServiceNames ; 369cdf0e10cSrcweir } 370cdf0e10cSrcweir 371cdf0e10cSrcweir OUString XMLEncryption_MSCryptImpl :: impl_getImplementationName() throw( RuntimeException ) { 372cdf0e10cSrcweir return OUString::createFromAscii( "com.sun.star.xml.security.bridge.xmlsec.XMLEncryption_MSCryptImpl" ) ; 373cdf0e10cSrcweir } 374cdf0e10cSrcweir 375cdf0e10cSrcweir //Helper for registry 376cdf0e10cSrcweir Reference< XInterface > SAL_CALL XMLEncryption_MSCryptImpl :: impl_createInstance( const Reference< XMultiServiceFactory >& aServiceManager ) throw( RuntimeException ) { 377cdf0e10cSrcweir return Reference< XInterface >( *new XMLEncryption_MSCryptImpl( aServiceManager ) ) ; 378cdf0e10cSrcweir } 379cdf0e10cSrcweir 380cdf0e10cSrcweir Reference< XSingleServiceFactory > XMLEncryption_MSCryptImpl :: impl_createFactory( const Reference< XMultiServiceFactory >& aServiceManager ) { 381cdf0e10cSrcweir //Reference< XSingleServiceFactory > xFactory ; 382cdf0e10cSrcweir //xFactory = ::cppu::createSingleFactory( aServiceManager , impl_getImplementationName , impl_createInstance , impl_getSupportedServiceNames ) ; 383cdf0e10cSrcweir //return xFactory ; 384cdf0e10cSrcweir return ::cppu::createSingleFactory( aServiceManager , impl_getImplementationName() , impl_createInstance , impl_getSupportedServiceNames() ) ; 385cdf0e10cSrcweir } 386cdf0e10cSrcweir 387