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 #include <sal/config.h> 27cdf0e10cSrcweir #include <rtl/uuid.h> 28cdf0e10cSrcweir #include "xmlencryption_nssimpl.hxx" 29cdf0e10cSrcweir 30cdf0e10cSrcweir #ifndef _XMLDOCUMENTWRAPPER_XMLSECIMPL_HXX_ 31cdf0e10cSrcweir #include "xmldocumentwrapper_xmlsecimpl.hxx" 32cdf0e10cSrcweir #endif 33cdf0e10cSrcweir 34cdf0e10cSrcweir #ifndef _XMLELEMENTWRAPPER_XMLSECIMPL_HXX_ 35cdf0e10cSrcweir #include "xmlelementwrapper_xmlsecimpl.hxx" 36cdf0e10cSrcweir #endif 37cdf0e10cSrcweir 38cdf0e10cSrcweir #ifndef _SECURITYENVIRONMENT_NSSIMPL_HXX_ 39cdf0e10cSrcweir #include "securityenvironment_nssimpl.hxx" 40cdf0e10cSrcweir #endif 41cdf0e10cSrcweir #include "errorcallback.hxx" 42cdf0e10cSrcweir 43cdf0e10cSrcweir #include <sal/types.h> 44cdf0e10cSrcweir //For reasons that escape me, this is what xmlsec does when size_t is not 4 45cdf0e10cSrcweir #if SAL_TYPES_SIZEOFPOINTER != 4 46cdf0e10cSrcweir # define XMLSEC_NO_SIZE_T 47cdf0e10cSrcweir #endif 48cdf0e10cSrcweir #include "xmlsec/xmlsec.h" 49cdf0e10cSrcweir #include "xmlsec/xmltree.h" 50cdf0e10cSrcweir #include "xmlsec/xmlenc.h" 51cdf0e10cSrcweir #include "xmlsec/crypto.h" 52cdf0e10cSrcweir 53cdf0e10cSrcweir #ifdef UNX 54cdf0e10cSrcweir #define stricmp strcasecmp 55cdf0e10cSrcweir #endif 56cdf0e10cSrcweir 57cdf0e10cSrcweir using namespace ::com::sun::star::uno ; 58cdf0e10cSrcweir using namespace ::com::sun::star::lang ; 59cdf0e10cSrcweir using ::com::sun::star::lang::XMultiServiceFactory ; 60cdf0e10cSrcweir using ::com::sun::star::lang::XSingleServiceFactory ; 61cdf0e10cSrcweir using ::rtl::OUString ; 62cdf0e10cSrcweir 63cdf0e10cSrcweir using ::com::sun::star::xml::wrapper::XXMLElementWrapper ; 64cdf0e10cSrcweir using ::com::sun::star::xml::wrapper::XXMLDocumentWrapper ; 65cdf0e10cSrcweir using ::com::sun::star::xml::crypto::XSecurityEnvironment ; 66cdf0e10cSrcweir using ::com::sun::star::xml::crypto::XXMLEncryption ; 67cdf0e10cSrcweir using ::com::sun::star::xml::crypto::XXMLEncryptionTemplate ; 68cdf0e10cSrcweir using ::com::sun::star::xml::crypto::XXMLSecurityContext ; 69cdf0e10cSrcweir using ::com::sun::star::xml::crypto::XSecurityEnvironment ; 70cdf0e10cSrcweir using ::com::sun::star::xml::crypto::XMLEncryptionException ; 71cdf0e10cSrcweir 72cdf0e10cSrcweir XMLEncryption_NssImpl :: XMLEncryption_NssImpl( const Reference< XMultiServiceFactory >& aFactory ) : m_xServiceManager( aFactory ) { 73cdf0e10cSrcweir } 74cdf0e10cSrcweir 75cdf0e10cSrcweir XMLEncryption_NssImpl :: ~XMLEncryption_NssImpl() { 76cdf0e10cSrcweir } 77cdf0e10cSrcweir 78cdf0e10cSrcweir /* XXMLEncryption */ 79cdf0e10cSrcweir Reference< XXMLEncryptionTemplate > 80cdf0e10cSrcweir SAL_CALL XMLEncryption_NssImpl :: encrypt( 81cdf0e10cSrcweir const Reference< XXMLEncryptionTemplate >& aTemplate , 82cdf0e10cSrcweir const Reference< XSecurityEnvironment >& aEnvironment 83cdf0e10cSrcweir ) throw( com::sun::star::xml::crypto::XMLEncryptionException, 84cdf0e10cSrcweir com::sun::star::uno::SecurityException ) 85cdf0e10cSrcweir { 86cdf0e10cSrcweir xmlSecKeysMngrPtr pMngr = NULL ; 87cdf0e10cSrcweir xmlSecEncCtxPtr pEncCtx = NULL ; 88cdf0e10cSrcweir xmlNodePtr pEncryptedData = NULL ; 89cdf0e10cSrcweir xmlNodePtr pContent = NULL ; 90cdf0e10cSrcweir 91cdf0e10cSrcweir if( !aTemplate.is() ) 92cdf0e10cSrcweir throw RuntimeException() ; 93cdf0e10cSrcweir 94cdf0e10cSrcweir if( !aEnvironment.is() ) 95cdf0e10cSrcweir throw RuntimeException() ; 96cdf0e10cSrcweir 97cdf0e10cSrcweir //Get Keys Manager 98cdf0e10cSrcweir Reference< XUnoTunnel > xSecTunnel( aEnvironment , UNO_QUERY ) ; 99cdf0e10cSrcweir if( !xSecTunnel.is() ) { 100cdf0e10cSrcweir throw RuntimeException() ; 101cdf0e10cSrcweir } 102cdf0e10cSrcweir 103cdf0e10cSrcweir #if 0 104cdf0e10cSrcweir XMLSecurityContext_NssImpl* pSecCtxt = ( XMLSecurityContext_NssImpl* )xSecTunnel->getSomething( XMLSecurityContext_NssImpl::getUnoTunnelId() ) ; 105cdf0e10cSrcweir if( pSecCtxt == NULL ) 106cdf0e10cSrcweir throw RuntimeException() ; 107cdf0e10cSrcweir #endif 108cdf0e10cSrcweir 109cdf0e10cSrcweir SecurityEnvironment_NssImpl* pSecEnv = 110cdf0e10cSrcweir reinterpret_cast<SecurityEnvironment_NssImpl*>( 111cdf0e10cSrcweir sal::static_int_cast<sal_uIntPtr>(xSecTunnel->getSomething( SecurityEnvironment_NssImpl::getUnoTunnelId() ))) ; 112cdf0e10cSrcweir if( pSecEnv == NULL ) 113cdf0e10cSrcweir throw RuntimeException() ; 114cdf0e10cSrcweir 115cdf0e10cSrcweir //Get the encryption template 116cdf0e10cSrcweir Reference< XXMLElementWrapper > xTemplate = aTemplate->getTemplate() ; 117cdf0e10cSrcweir if( !xTemplate.is() ) { 118cdf0e10cSrcweir throw RuntimeException() ; 119cdf0e10cSrcweir } 120cdf0e10cSrcweir 121cdf0e10cSrcweir Reference< XUnoTunnel > xTplTunnel( xTemplate , UNO_QUERY ) ; 122cdf0e10cSrcweir if( !xTplTunnel.is() ) { 123cdf0e10cSrcweir throw RuntimeException() ; 124cdf0e10cSrcweir } 125cdf0e10cSrcweir 126cdf0e10cSrcweir XMLElementWrapper_XmlSecImpl* pTemplate = 127cdf0e10cSrcweir reinterpret_cast<XMLElementWrapper_XmlSecImpl*>( 128cdf0e10cSrcweir sal::static_int_cast<sal_uIntPtr>( 129cdf0e10cSrcweir xTplTunnel->getSomething( XMLElementWrapper_XmlSecImpl::getUnoTunnelImplementationId() ))); 130cdf0e10cSrcweir if( pTemplate == NULL ) { 131cdf0e10cSrcweir throw RuntimeException() ; 132cdf0e10cSrcweir } 133cdf0e10cSrcweir 134cdf0e10cSrcweir //MM : Get the element to be encrypted 135cdf0e10cSrcweir Reference< XXMLElementWrapper > xTarget = aTemplate->getTarget() ; 136cdf0e10cSrcweir if( !xTarget.is() ) { 137cdf0e10cSrcweir throw XMLEncryptionException() ; 138cdf0e10cSrcweir } 139cdf0e10cSrcweir 140cdf0e10cSrcweir Reference< XUnoTunnel > xTgtTunnel( xTarget , UNO_QUERY ) ; 141cdf0e10cSrcweir if( !xTgtTunnel.is() ) { 142cdf0e10cSrcweir throw XMLEncryptionException() ; 143cdf0e10cSrcweir } 144cdf0e10cSrcweir 145cdf0e10cSrcweir XMLElementWrapper_XmlSecImpl* pTarget = 146cdf0e10cSrcweir reinterpret_cast<XMLElementWrapper_XmlSecImpl*>( 147cdf0e10cSrcweir sal::static_int_cast<sal_uIntPtr>( 148cdf0e10cSrcweir xTgtTunnel->getSomething( XMLElementWrapper_XmlSecImpl::getUnoTunnelImplementationId() ))); 149cdf0e10cSrcweir if( pTarget == NULL ) { 150cdf0e10cSrcweir throw RuntimeException() ; 151cdf0e10cSrcweir } 152cdf0e10cSrcweir 153cdf0e10cSrcweir pContent = pTarget->getNativeElement() ; 154cdf0e10cSrcweir //MM : end 155cdf0e10cSrcweir 156cdf0e10cSrcweir if( pContent == NULL ) { 157cdf0e10cSrcweir throw XMLEncryptionException() ; 158cdf0e10cSrcweir } 159cdf0e10cSrcweir 160cdf0e10cSrcweir /* MM : remove the following 2 lines 161cdf0e10cSrcweir xmlUnlinkNode(pContent); 162cdf0e10cSrcweir xmlAddNextSibling(pEncryptedData, pContent); 163cdf0e10cSrcweir */ 164cdf0e10cSrcweir 165cdf0e10cSrcweir //remember the position of the element to be signed 166cdf0e10cSrcweir sal_Bool isParentRef = sal_True; 167cdf0e10cSrcweir xmlNodePtr pParent = pEncryptedData->parent; 168cdf0e10cSrcweir xmlNodePtr referenceNode; 169cdf0e10cSrcweir 170cdf0e10cSrcweir if (pEncryptedData == pParent->children) 171cdf0e10cSrcweir { 172cdf0e10cSrcweir referenceNode = pParent; 173cdf0e10cSrcweir } 174cdf0e10cSrcweir else 175cdf0e10cSrcweir { 176cdf0e10cSrcweir referenceNode = pEncryptedData->prev; 177cdf0e10cSrcweir isParentRef = sal_False; 178cdf0e10cSrcweir } 179cdf0e10cSrcweir 180cdf0e10cSrcweir setErrorRecorder( ); 181cdf0e10cSrcweir 182cdf0e10cSrcweir pMngr = pSecEnv->createKeysManager() ; //i39448 183cdf0e10cSrcweir if( !pMngr ) { 184cdf0e10cSrcweir throw RuntimeException() ; 185cdf0e10cSrcweir } 186cdf0e10cSrcweir 187cdf0e10cSrcweir //Create Encryption context 188cdf0e10cSrcweir pEncCtx = xmlSecEncCtxCreate( pMngr ) ; 189cdf0e10cSrcweir if( pEncCtx == NULL ) 190cdf0e10cSrcweir { 191cdf0e10cSrcweir pSecEnv->destroyKeysManager( pMngr ) ; //i39448 192cdf0e10cSrcweir //throw XMLEncryptionException() ; 193cdf0e10cSrcweir clearErrorRecorder(); 194cdf0e10cSrcweir return aTemplate; 195cdf0e10cSrcweir } 196cdf0e10cSrcweir 197cdf0e10cSrcweir pEncryptedData = pTemplate->getNativeElement() ; 198cdf0e10cSrcweir 199cdf0e10cSrcweir //Find the element to be encrypted. 200cdf0e10cSrcweir /* MM : remove the old method to get the target element 201cdf0e10cSrcweir //This element is wrapped in the CipherValue sub-element. 202cdf0e10cSrcweir xmlNodePtr pCipherData = pEncryptedData->children; 203cdf0e10cSrcweir while (pCipherData != NULL && stricmp((const char *)(pCipherData->name), "CipherData")) 204cdf0e10cSrcweir { 205cdf0e10cSrcweir pCipherData = pCipherData->next; 206cdf0e10cSrcweir } 207cdf0e10cSrcweir 208cdf0e10cSrcweir if( pCipherData == NULL ) { 209cdf0e10cSrcweir xmlSecEncCtxDestroy( pEncCtx ) ; 210cdf0e10cSrcweir throw XMLEncryptionException() ; 211cdf0e10cSrcweir } 212cdf0e10cSrcweir 213cdf0e10cSrcweir xmlNodePtr pCipherValue = pCipherData->children; 214cdf0e10cSrcweir while (pCipherValue != NULL && stricmp((const char *)(pCipherValue->name), "CipherValue")) 215cdf0e10cSrcweir { 216cdf0e10cSrcweir pCipherValue = pCipherValue->next; 217cdf0e10cSrcweir } 218cdf0e10cSrcweir 219cdf0e10cSrcweir if( pCipherValue == NULL ) { 220cdf0e10cSrcweir xmlSecEncCtxDestroy( pEncCtx ) ; 221cdf0e10cSrcweir throw XMLEncryptionException() ; 222cdf0e10cSrcweir } 223cdf0e10cSrcweir 224cdf0e10cSrcweir pContent = pCipherValue->children; 225cdf0e10cSrcweir */ 226cdf0e10cSrcweir 227cdf0e10cSrcweir //Encrypt the template 228cdf0e10cSrcweir if( xmlSecEncCtxXmlEncrypt( pEncCtx , pEncryptedData , pContent ) < 0 ) 229cdf0e10cSrcweir { 230cdf0e10cSrcweir xmlSecEncCtxDestroy( pEncCtx ) ; 231cdf0e10cSrcweir pSecEnv->destroyKeysManager( pMngr ) ; //i39448 232cdf0e10cSrcweir 233cdf0e10cSrcweir //throw XMLEncryptionException() ; 234cdf0e10cSrcweir clearErrorRecorder(); 235cdf0e10cSrcweir return aTemplate; 236cdf0e10cSrcweir } 237cdf0e10cSrcweir 238cdf0e10cSrcweir xmlSecEncCtxDestroy( pEncCtx ) ; 239cdf0e10cSrcweir pSecEnv->destroyKeysManager( pMngr ) ; //i39448 240cdf0e10cSrcweir 241cdf0e10cSrcweir //get the new EncryptedData element 242cdf0e10cSrcweir if (isParentRef) 243cdf0e10cSrcweir { 244cdf0e10cSrcweir pTemplate->setNativeElement(referenceNode->children) ; 245cdf0e10cSrcweir } 246cdf0e10cSrcweir else 247cdf0e10cSrcweir { 248cdf0e10cSrcweir pTemplate->setNativeElement(referenceNode->next); 249cdf0e10cSrcweir } 250cdf0e10cSrcweir 251cdf0e10cSrcweir return aTemplate ; 252cdf0e10cSrcweir } 253cdf0e10cSrcweir 254cdf0e10cSrcweir /* XXMLEncryption */ 255cdf0e10cSrcweir Reference< XXMLEncryptionTemplate > 256cdf0e10cSrcweir SAL_CALL XMLEncryption_NssImpl :: decrypt( 257cdf0e10cSrcweir const Reference< XXMLEncryptionTemplate >& aTemplate , 258cdf0e10cSrcweir const Reference< XXMLSecurityContext >& aSecurityCtx 259cdf0e10cSrcweir ) throw( com::sun::star::xml::crypto::XMLEncryptionException , 260cdf0e10cSrcweir com::sun::star::uno::SecurityException) { 261cdf0e10cSrcweir xmlSecKeysMngrPtr pMngr = NULL ; 262cdf0e10cSrcweir xmlSecEncCtxPtr pEncCtx = NULL ; 263cdf0e10cSrcweir xmlNodePtr pEncryptedData = NULL ; 264cdf0e10cSrcweir 265cdf0e10cSrcweir if( !aTemplate.is() ) 266cdf0e10cSrcweir throw RuntimeException() ; 267cdf0e10cSrcweir 268cdf0e10cSrcweir if( !aSecurityCtx.is() ) 269cdf0e10cSrcweir throw RuntimeException() ; 270cdf0e10cSrcweir 271cdf0e10cSrcweir //Get the encryption template 272cdf0e10cSrcweir Reference< XXMLElementWrapper > xTemplate = aTemplate->getTemplate() ; 273cdf0e10cSrcweir if( !xTemplate.is() ) { 274cdf0e10cSrcweir throw RuntimeException() ; 275cdf0e10cSrcweir } 276cdf0e10cSrcweir 277cdf0e10cSrcweir Reference< XUnoTunnel > xTplTunnel( xTemplate , UNO_QUERY ) ; 278cdf0e10cSrcweir if( !xTplTunnel.is() ) { 279cdf0e10cSrcweir throw RuntimeException() ; 280cdf0e10cSrcweir } 281cdf0e10cSrcweir 282cdf0e10cSrcweir XMLElementWrapper_XmlSecImpl* pTemplate = 283cdf0e10cSrcweir reinterpret_cast<XMLElementWrapper_XmlSecImpl*>( 284cdf0e10cSrcweir sal::static_int_cast<sal_uIntPtr>( 285cdf0e10cSrcweir xTplTunnel->getSomething( XMLElementWrapper_XmlSecImpl::getUnoTunnelImplementationId() ))); 286cdf0e10cSrcweir if( pTemplate == NULL ) { 287cdf0e10cSrcweir throw RuntimeException() ; 288cdf0e10cSrcweir } 289cdf0e10cSrcweir 290cdf0e10cSrcweir pEncryptedData = pTemplate->getNativeElement() ; 291cdf0e10cSrcweir 292cdf0e10cSrcweir //remember the position of the element to be signed 293cdf0e10cSrcweir sal_Bool isParentRef = sal_True; 294cdf0e10cSrcweir xmlNodePtr pParent = pEncryptedData->parent; 295cdf0e10cSrcweir xmlNodePtr referenceNode; 296cdf0e10cSrcweir 297cdf0e10cSrcweir if (pEncryptedData == pParent->children) 298cdf0e10cSrcweir { 299cdf0e10cSrcweir referenceNode = pParent; 300cdf0e10cSrcweir } 301cdf0e10cSrcweir else 302cdf0e10cSrcweir { 303cdf0e10cSrcweir referenceNode = pEncryptedData->prev; 304cdf0e10cSrcweir isParentRef = sal_False; 305cdf0e10cSrcweir } 306cdf0e10cSrcweir 307cdf0e10cSrcweir setErrorRecorder( ); 308cdf0e10cSrcweir 309cdf0e10cSrcweir sal_Int32 nSecurityEnvironment = aSecurityCtx->getSecurityEnvironmentNumber(); 310cdf0e10cSrcweir sal_Int32 i; 311cdf0e10cSrcweir 312cdf0e10cSrcweir for (i=0; i<nSecurityEnvironment; ++i) 313cdf0e10cSrcweir { 314cdf0e10cSrcweir Reference< XSecurityEnvironment > aEnvironment = aSecurityCtx->getSecurityEnvironmentByIndex(i); 315cdf0e10cSrcweir 316cdf0e10cSrcweir //Get Keys Manager 317cdf0e10cSrcweir Reference< XUnoTunnel > xSecTunnel( aEnvironment , UNO_QUERY ) ; 318cdf0e10cSrcweir if( !aEnvironment.is() ) { 319cdf0e10cSrcweir throw RuntimeException() ; 320cdf0e10cSrcweir } 321cdf0e10cSrcweir 322cdf0e10cSrcweir SecurityEnvironment_NssImpl* pSecEnv = 323cdf0e10cSrcweir reinterpret_cast<SecurityEnvironment_NssImpl*>( 324cdf0e10cSrcweir sal::static_int_cast<sal_uIntPtr>( 325cdf0e10cSrcweir xSecTunnel->getSomething( SecurityEnvironment_NssImpl::getUnoTunnelId() ))); 326cdf0e10cSrcweir if( pSecEnv == NULL ) 327cdf0e10cSrcweir throw RuntimeException() ; 328cdf0e10cSrcweir 329cdf0e10cSrcweir pMngr = pSecEnv->createKeysManager() ; //i39448 330cdf0e10cSrcweir if( !pMngr ) { 331cdf0e10cSrcweir throw RuntimeException() ; 332cdf0e10cSrcweir } 333cdf0e10cSrcweir 334cdf0e10cSrcweir //Create Encryption context 335cdf0e10cSrcweir pEncCtx = xmlSecEncCtxCreate( pMngr ) ; 336cdf0e10cSrcweir if( pEncCtx == NULL ) 337cdf0e10cSrcweir { 338cdf0e10cSrcweir pSecEnv->destroyKeysManager( pMngr ) ; //i39448 339cdf0e10cSrcweir //throw XMLEncryptionException() ; 340cdf0e10cSrcweir clearErrorRecorder(); 341cdf0e10cSrcweir return aTemplate; 342cdf0e10cSrcweir } 343cdf0e10cSrcweir 344cdf0e10cSrcweir //Decrypt the template 345cdf0e10cSrcweir if(!( xmlSecEncCtxDecrypt( pEncCtx , pEncryptedData ) < 0 || pEncCtx->result == NULL )) 346cdf0e10cSrcweir { 347cdf0e10cSrcweir //The decryption succeeds 348cdf0e10cSrcweir 349cdf0e10cSrcweir //Destroy the encryption context 350cdf0e10cSrcweir xmlSecEncCtxDestroy( pEncCtx ) ; 351cdf0e10cSrcweir pSecEnv->destroyKeysManager( pMngr ) ; //i39448 352cdf0e10cSrcweir 353cdf0e10cSrcweir //get the decrypted element 354cdf0e10cSrcweir XMLElementWrapper_XmlSecImpl * ret = new XMLElementWrapper_XmlSecImpl(isParentRef? 355cdf0e10cSrcweir (referenceNode->children):(referenceNode->next)); 356cdf0e10cSrcweir 357cdf0e10cSrcweir //return ret; 358cdf0e10cSrcweir aTemplate->setTemplate(ret); 359cdf0e10cSrcweir break; 360cdf0e10cSrcweir } 361cdf0e10cSrcweir else 362cdf0e10cSrcweir { 363cdf0e10cSrcweir //The decryption fails, continue with the next security environment 364cdf0e10cSrcweir xmlSecEncCtxDestroy( pEncCtx ) ; 365cdf0e10cSrcweir pSecEnv->destroyKeysManager( pMngr ) ; //i39448 366cdf0e10cSrcweir } 367cdf0e10cSrcweir } 368cdf0e10cSrcweir 369cdf0e10cSrcweir clearErrorRecorder(); 370cdf0e10cSrcweir return aTemplate; 371cdf0e10cSrcweir } 372cdf0e10cSrcweir 373cdf0e10cSrcweir /* XInitialization */ 374cdf0e10cSrcweir void SAL_CALL XMLEncryption_NssImpl :: initialize( const Sequence< Any >& /*aArguments*/ ) throw( Exception, RuntimeException ) { 375cdf0e10cSrcweir // TBD 376cdf0e10cSrcweir } ; 377cdf0e10cSrcweir 378cdf0e10cSrcweir /* XServiceInfo */ 379cdf0e10cSrcweir OUString SAL_CALL XMLEncryption_NssImpl :: getImplementationName() throw( RuntimeException ) { 380cdf0e10cSrcweir return impl_getImplementationName() ; 381cdf0e10cSrcweir } 382cdf0e10cSrcweir 383cdf0e10cSrcweir /* XServiceInfo */ 384cdf0e10cSrcweir sal_Bool SAL_CALL XMLEncryption_NssImpl :: supportsService( const OUString& serviceName) throw( RuntimeException ) { 385cdf0e10cSrcweir Sequence< OUString > seqServiceNames = getSupportedServiceNames() ; 386cdf0e10cSrcweir const OUString* pArray = seqServiceNames.getConstArray() ; 387cdf0e10cSrcweir for( sal_Int32 i = 0 ; i < seqServiceNames.getLength() ; i ++ ) { 388cdf0e10cSrcweir if( *( pArray + i ) == serviceName ) 389cdf0e10cSrcweir return sal_True ; 390cdf0e10cSrcweir } 391cdf0e10cSrcweir return sal_False ; 392cdf0e10cSrcweir } 393cdf0e10cSrcweir 394cdf0e10cSrcweir /* XServiceInfo */ 395cdf0e10cSrcweir Sequence< OUString > SAL_CALL XMLEncryption_NssImpl :: getSupportedServiceNames() throw( RuntimeException ) { 396cdf0e10cSrcweir return impl_getSupportedServiceNames() ; 397cdf0e10cSrcweir } 398cdf0e10cSrcweir 399cdf0e10cSrcweir //Helper for XServiceInfo 400cdf0e10cSrcweir Sequence< OUString > XMLEncryption_NssImpl :: impl_getSupportedServiceNames() { 401cdf0e10cSrcweir ::osl::Guard< ::osl::Mutex > aGuard( ::osl::Mutex::getGlobalMutex() ) ; 402cdf0e10cSrcweir Sequence< OUString > seqServiceNames( 1 ) ; 403cdf0e10cSrcweir seqServiceNames.getArray()[0] = OUString::createFromAscii( "com.sun.star.xml.crypto.XMLEncryption" ) ; 404cdf0e10cSrcweir return seqServiceNames ; 405cdf0e10cSrcweir } 406cdf0e10cSrcweir 407cdf0e10cSrcweir OUString XMLEncryption_NssImpl :: impl_getImplementationName() throw( RuntimeException ) { 408cdf0e10cSrcweir return OUString::createFromAscii( "com.sun.star.xml.security.bridge.xmlsec.XMLEncryption_NssImpl" ) ; 409cdf0e10cSrcweir } 410cdf0e10cSrcweir 411cdf0e10cSrcweir //Helper for registry 412cdf0e10cSrcweir Reference< XInterface > SAL_CALL XMLEncryption_NssImpl :: impl_createInstance( const Reference< XMultiServiceFactory >& aServiceManager ) throw( RuntimeException ) { 413cdf0e10cSrcweir return Reference< XInterface >( *new XMLEncryption_NssImpl( aServiceManager ) ) ; 414cdf0e10cSrcweir } 415cdf0e10cSrcweir 416cdf0e10cSrcweir Reference< XSingleServiceFactory > XMLEncryption_NssImpl :: impl_createFactory( const Reference< XMultiServiceFactory >& aServiceManager ) { 417cdf0e10cSrcweir //Reference< XSingleServiceFactory > xFactory ; 418cdf0e10cSrcweir //xFactory = ::cppu::createSingleFactory( aServiceManager , impl_getImplementationName , impl_createInstance , impl_getSupportedServiceNames ) ; 419cdf0e10cSrcweir //return xFactory ; 420cdf0e10cSrcweir return ::cppu::createSingleFactory( aServiceManager , impl_getImplementationName() , impl_createInstance , impl_getSupportedServiceNames() ) ; 421cdf0e10cSrcweir } 422cdf0e10cSrcweir 423