1*859212d1SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*859212d1SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*859212d1SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*859212d1SAndrew Rist * distributed with this work for additional information 6*859212d1SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*859212d1SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*859212d1SAndrew Rist * "License"); you may not use this file except in compliance 9*859212d1SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*859212d1SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*859212d1SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*859212d1SAndrew Rist * software distributed under the License is distributed on an 15*859212d1SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*859212d1SAndrew Rist * KIND, either express or implied. See the License for the 17*859212d1SAndrew Rist * specific language governing permissions and limitations 18*859212d1SAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*859212d1SAndrew Rist *************************************************************/ 21*859212d1SAndrew Rist 22*859212d1SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #include "cppuhelper/factory.hxx" 25cdf0e10cSrcweir 26cdf0e10cSrcweir #include "com/sun/star/lang/XMultiServiceFactory.hpp" 27cdf0e10cSrcweir #include "com/sun/star/task/NoMasterException.hpp" 28cdf0e10cSrcweir #include "com/sun/star/task/XInteractionHandler.hpp" 29cdf0e10cSrcweir #include "com/sun/star/task/XMasterPasswordHandling.hpp" 30cdf0e10cSrcweir #include "com/sun/star/task/XPasswordContainer.hpp" 31cdf0e10cSrcweir #include "com/sun/star/task/XUrlContainer.hpp" 32cdf0e10cSrcweir #include "com/sun/star/ucb/AuthenticationRequest.hpp" 33cdf0e10cSrcweir #include "com/sun/star/ucb/URLAuthenticationRequest.hpp" 34cdf0e10cSrcweir #include "com/sun/star/ucb/XInteractionSupplyAuthentication.hpp" 35cdf0e10cSrcweir #include "com/sun/star/ucb/XInteractionSupplyAuthentication2.hpp" 36cdf0e10cSrcweir 37cdf0e10cSrcweir #include "passwordcontainer.hxx" 38cdf0e10cSrcweir 39cdf0e10cSrcweir using namespace com::sun::star; 40cdf0e10cSrcweir 41cdf0e10cSrcweir namespace { 42cdf0e10cSrcweir 43cdf0e10cSrcweir //========================================================================= 44cdf0e10cSrcweir bool fillContinuation( 45cdf0e10cSrcweir bool bUseSystemCredentials, 46cdf0e10cSrcweir const ucb::AuthenticationRequest & rRequest, 47cdf0e10cSrcweir const task::UrlRecord & aRec, 48cdf0e10cSrcweir const uno::Reference< ucb::XInteractionSupplyAuthentication > & 49cdf0e10cSrcweir xSupplyAuthentication, 50cdf0e10cSrcweir const uno::Reference< ucb::XInteractionSupplyAuthentication2 > & 51cdf0e10cSrcweir xSupplyAuthentication2, 52cdf0e10cSrcweir bool bCanUseSystemCredentials, 53cdf0e10cSrcweir bool bCheckForEqualPasswords ) 54cdf0e10cSrcweir { 55cdf0e10cSrcweir if ( bUseSystemCredentials ) 56cdf0e10cSrcweir { 57cdf0e10cSrcweir // "use system creds" record found. 58cdf0e10cSrcweir // Wants client that we use it? 59cdf0e10cSrcweir if ( xSupplyAuthentication2.is() && bCanUseSystemCredentials ) 60cdf0e10cSrcweir { 61cdf0e10cSrcweir xSupplyAuthentication2->setUseSystemCredentials( sal_True ); 62cdf0e10cSrcweir return true; 63cdf0e10cSrcweir } 64cdf0e10cSrcweir return false; 65cdf0e10cSrcweir } 66cdf0e10cSrcweir else if (aRec.UserList.getLength() != 0) 67cdf0e10cSrcweir { 68cdf0e10cSrcweir if (aRec.UserList[0].Passwords.getLength() == 0) 69cdf0e10cSrcweir { 70cdf0e10cSrcweir // Password sequence can be empty, for instance if master 71cdf0e10cSrcweir // password was not given (e.g. master pw dialog canceled) 72cdf0e10cSrcweir // pw container does not throw NoMasterException in this case. 73cdf0e10cSrcweir // bug??? 74cdf0e10cSrcweir return false; 75cdf0e10cSrcweir } 76cdf0e10cSrcweir 77cdf0e10cSrcweir // "user/pass" record found. 78cdf0e10cSrcweir if (!bCheckForEqualPasswords || !rRequest.HasPassword 79cdf0e10cSrcweir || rRequest.Password != aRec.UserList[0].Passwords[0]) // failed login attempt? 80cdf0e10cSrcweir { 81cdf0e10cSrcweir if (xSupplyAuthentication->canSetUserName()) 82cdf0e10cSrcweir xSupplyAuthentication-> 83cdf0e10cSrcweir setUserName(aRec.UserList[0].UserName.getStr()); 84cdf0e10cSrcweir 85cdf0e10cSrcweir if (xSupplyAuthentication->canSetPassword()) 86cdf0e10cSrcweir xSupplyAuthentication-> 87cdf0e10cSrcweir setPassword(aRec.UserList[0].Passwords[0].getStr()); 88cdf0e10cSrcweir if (aRec.UserList[0].Passwords.getLength() > 1) 89cdf0e10cSrcweir { 90cdf0e10cSrcweir if (rRequest.HasRealm) 91cdf0e10cSrcweir { 92cdf0e10cSrcweir if (xSupplyAuthentication->canSetRealm()) 93cdf0e10cSrcweir xSupplyAuthentication-> 94cdf0e10cSrcweir setRealm(aRec.UserList[0].Passwords[1]. 95cdf0e10cSrcweir getStr()); 96cdf0e10cSrcweir } 97cdf0e10cSrcweir else if (xSupplyAuthentication->canSetAccount()) 98cdf0e10cSrcweir xSupplyAuthentication-> 99cdf0e10cSrcweir setAccount(aRec.UserList[0].Passwords[1]. 100cdf0e10cSrcweir getStr()); 101cdf0e10cSrcweir } 102cdf0e10cSrcweir 103cdf0e10cSrcweir if ( xSupplyAuthentication2.is() && bCanUseSystemCredentials ) 104cdf0e10cSrcweir xSupplyAuthentication2->setUseSystemCredentials( sal_False ); 105cdf0e10cSrcweir 106cdf0e10cSrcweir return true; 107cdf0e10cSrcweir } 108cdf0e10cSrcweir } 109cdf0e10cSrcweir return false; 110cdf0e10cSrcweir } 111cdf0e10cSrcweir 112cdf0e10cSrcweir } // namespace 113cdf0e10cSrcweir 114cdf0e10cSrcweir namespace uui { 115cdf0e10cSrcweir 116cdf0e10cSrcweir //========================================================================= 117cdf0e10cSrcweir PasswordContainerHelper::PasswordContainerHelper( 118cdf0e10cSrcweir uno::Reference< lang::XMultiServiceFactory > const & xServiceFactory ) 119cdf0e10cSrcweir { 120cdf0e10cSrcweir OSL_ENSURE(xServiceFactory.is(), "no service factory given!"); 121cdf0e10cSrcweir if (xServiceFactory.is()) 122cdf0e10cSrcweir try 123cdf0e10cSrcweir { 124cdf0e10cSrcweir m_xPasswordContainer 125cdf0e10cSrcweir = uno::Reference< task::XPasswordContainer >( 126cdf0e10cSrcweir xServiceFactory-> 127cdf0e10cSrcweir createInstance( 128cdf0e10cSrcweir rtl::OUString( 129cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM( 130cdf0e10cSrcweir "com.sun.star.task.PasswordContainer"))), 131cdf0e10cSrcweir uno::UNO_QUERY); 132cdf0e10cSrcweir } 133cdf0e10cSrcweir catch (uno::Exception const &) 134cdf0e10cSrcweir {} 135cdf0e10cSrcweir OSL_ENSURE(m_xPasswordContainer.is(), 136cdf0e10cSrcweir "unable to instanciate password container service"); 137cdf0e10cSrcweir } 138cdf0e10cSrcweir 139cdf0e10cSrcweir //========================================================================= 140cdf0e10cSrcweir bool PasswordContainerHelper::handleAuthenticationRequest( 141cdf0e10cSrcweir ucb::AuthenticationRequest const & rRequest, 142cdf0e10cSrcweir uno::Reference< ucb::XInteractionSupplyAuthentication > const & 143cdf0e10cSrcweir xSupplyAuthentication, 144cdf0e10cSrcweir rtl::OUString const & rURL, 145cdf0e10cSrcweir uno::Reference< task::XInteractionHandler > const & xIH ) 146cdf0e10cSrcweir SAL_THROW((uno::RuntimeException)) 147cdf0e10cSrcweir { 148cdf0e10cSrcweir // Is continuation even a XInteractionSupplyAuthentication2, which 149cdf0e10cSrcweir // is derived from XInteractionSupplyAuthentication? 150cdf0e10cSrcweir uno::Reference< ucb::XInteractionSupplyAuthentication2 > 151cdf0e10cSrcweir xSupplyAuthentication2(xSupplyAuthentication, uno::UNO_QUERY); 152cdf0e10cSrcweir 153cdf0e10cSrcweir sal_Bool bCanUseSystemCredentials = sal_False; 154cdf0e10cSrcweir if (xSupplyAuthentication2.is()) 155cdf0e10cSrcweir { 156cdf0e10cSrcweir sal_Bool bDefaultUseSystemCredentials; 157cdf0e10cSrcweir bCanUseSystemCredentials 158cdf0e10cSrcweir = xSupplyAuthentication2->canUseSystemCredentials( 159cdf0e10cSrcweir bDefaultUseSystemCredentials ); 160cdf0e10cSrcweir } 161cdf0e10cSrcweir 162cdf0e10cSrcweir uno::Reference< task::XPasswordContainer > xContainer( 163cdf0e10cSrcweir m_xPasswordContainer ); 164cdf0e10cSrcweir uno::Reference< task::XUrlContainer > xUrlContainer( 165cdf0e10cSrcweir m_xPasswordContainer, uno::UNO_QUERY ); 166cdf0e10cSrcweir OSL_ENSURE( xUrlContainer.is(), "Got no XUrlContainer!" ); 167cdf0e10cSrcweir 168cdf0e10cSrcweir if ( !xContainer.is() || !xUrlContainer.is() ) 169cdf0e10cSrcweir return false; 170cdf0e10cSrcweir 171cdf0e10cSrcweir if ( bCanUseSystemCredentials ) 172cdf0e10cSrcweir { 173cdf0e10cSrcweir // Runtime / Persistent info avail for current auth request? 174cdf0e10cSrcweir 175cdf0e10cSrcweir rtl::OUString aResult = xUrlContainer->findUrl( 176cdf0e10cSrcweir rURL.getLength() ? rURL : rRequest.ServerName ); 177cdf0e10cSrcweir if ( aResult.getLength() > 0 ) 178cdf0e10cSrcweir { 179cdf0e10cSrcweir if ( fillContinuation( true, 180cdf0e10cSrcweir rRequest, 181cdf0e10cSrcweir task::UrlRecord(), 182cdf0e10cSrcweir xSupplyAuthentication, 183cdf0e10cSrcweir xSupplyAuthentication2, 184cdf0e10cSrcweir bCanUseSystemCredentials, 185cdf0e10cSrcweir false ) ) 186cdf0e10cSrcweir { 187cdf0e10cSrcweir return true; 188cdf0e10cSrcweir } 189cdf0e10cSrcweir } 190cdf0e10cSrcweir } 191cdf0e10cSrcweir 192cdf0e10cSrcweir // xContainer works with userName passwdSequences pairs: 193cdf0e10cSrcweir if (rRequest.HasUserName && rRequest.HasPassword) 194cdf0e10cSrcweir { 195cdf0e10cSrcweir try 196cdf0e10cSrcweir { 197cdf0e10cSrcweir if (rRequest.UserName.getLength() == 0) 198cdf0e10cSrcweir { 199cdf0e10cSrcweir task::UrlRecord aRec; 200cdf0e10cSrcweir if ( rURL.getLength() ) 201cdf0e10cSrcweir aRec = xContainer->find(rURL, xIH); 202cdf0e10cSrcweir 203cdf0e10cSrcweir if ( aRec.UserList.getLength() == 0 ) 204cdf0e10cSrcweir { 205cdf0e10cSrcweir // compat: try server name. 206cdf0e10cSrcweir aRec = xContainer->find(rRequest.ServerName, xIH); 207cdf0e10cSrcweir } 208cdf0e10cSrcweir 209cdf0e10cSrcweir if ( fillContinuation( false, 210cdf0e10cSrcweir rRequest, 211cdf0e10cSrcweir aRec, 212cdf0e10cSrcweir xSupplyAuthentication, 213cdf0e10cSrcweir xSupplyAuthentication2, 214cdf0e10cSrcweir bCanUseSystemCredentials, 215cdf0e10cSrcweir false ) ) 216cdf0e10cSrcweir { 217cdf0e10cSrcweir return true; 218cdf0e10cSrcweir } 219cdf0e10cSrcweir } 220cdf0e10cSrcweir else 221cdf0e10cSrcweir { 222cdf0e10cSrcweir task::UrlRecord aRec; 223cdf0e10cSrcweir if ( rURL.getLength() ) 224cdf0e10cSrcweir aRec = xContainer->findForName( 225cdf0e10cSrcweir rURL, rRequest.UserName, xIH); 226cdf0e10cSrcweir 227cdf0e10cSrcweir if ( aRec.UserList.getLength() == 0 ) 228cdf0e10cSrcweir { 229cdf0e10cSrcweir // compat: try server name. 230cdf0e10cSrcweir aRec = xContainer->findForName( 231cdf0e10cSrcweir rRequest.ServerName, rRequest.UserName, xIH); 232cdf0e10cSrcweir } 233cdf0e10cSrcweir 234cdf0e10cSrcweir if ( fillContinuation( false, 235cdf0e10cSrcweir rRequest, 236cdf0e10cSrcweir aRec, 237cdf0e10cSrcweir xSupplyAuthentication, 238cdf0e10cSrcweir xSupplyAuthentication2, 239cdf0e10cSrcweir bCanUseSystemCredentials, 240cdf0e10cSrcweir true ) ) 241cdf0e10cSrcweir { 242cdf0e10cSrcweir return true; 243cdf0e10cSrcweir } 244cdf0e10cSrcweir } 245cdf0e10cSrcweir } 246cdf0e10cSrcweir catch (task::NoMasterException const &) 247cdf0e10cSrcweir {} // user did not enter master password 248cdf0e10cSrcweir } 249cdf0e10cSrcweir return false; 250cdf0e10cSrcweir } 251cdf0e10cSrcweir 252cdf0e10cSrcweir //========================================================================= 253cdf0e10cSrcweir bool PasswordContainerHelper::addRecord( 254cdf0e10cSrcweir rtl::OUString const & rURL, 255cdf0e10cSrcweir rtl::OUString const & rUsername, 256cdf0e10cSrcweir uno::Sequence< rtl::OUString > const & rPasswords, 257cdf0e10cSrcweir uno::Reference< task::XInteractionHandler > const & xIH, 258cdf0e10cSrcweir bool bPersist ) 259cdf0e10cSrcweir SAL_THROW((uno::RuntimeException)) 260cdf0e10cSrcweir { 261cdf0e10cSrcweir try 262cdf0e10cSrcweir { 263cdf0e10cSrcweir if ( rUsername.getLength() ) 264cdf0e10cSrcweir { 265cdf0e10cSrcweir OSL_ENSURE( m_xPasswordContainer.is(), 266cdf0e10cSrcweir "Got no XPasswordContainer!" ); 267cdf0e10cSrcweir if ( !m_xPasswordContainer.is() ) 268cdf0e10cSrcweir return false; 269cdf0e10cSrcweir 270cdf0e10cSrcweir if ( bPersist ) 271cdf0e10cSrcweir { 272cdf0e10cSrcweir uno::Reference< task::XMasterPasswordHandling > xMPH( 273cdf0e10cSrcweir m_xPasswordContainer, uno::UNO_QUERY_THROW ); 274cdf0e10cSrcweir 275cdf0e10cSrcweir // If persistent storing of passwords is not yet 276cdf0e10cSrcweir // allowed, enable it. 277cdf0e10cSrcweir if ( !xMPH->isPersistentStoringAllowed() ) 278cdf0e10cSrcweir xMPH->allowPersistentStoring( sal_True ); 279cdf0e10cSrcweir 280cdf0e10cSrcweir m_xPasswordContainer->addPersistent( rURL, 281cdf0e10cSrcweir rUsername, 282cdf0e10cSrcweir rPasswords, 283cdf0e10cSrcweir xIH ); 284cdf0e10cSrcweir } 285cdf0e10cSrcweir else 286cdf0e10cSrcweir m_xPasswordContainer->add( rURL, 287cdf0e10cSrcweir rUsername, 288cdf0e10cSrcweir rPasswords, 289cdf0e10cSrcweir xIH ); 290cdf0e10cSrcweir } 291cdf0e10cSrcweir else 292cdf0e10cSrcweir { 293cdf0e10cSrcweir uno::Reference< task::XUrlContainer > 294cdf0e10cSrcweir xContainer( m_xPasswordContainer, uno::UNO_QUERY ); 295cdf0e10cSrcweir OSL_ENSURE( xContainer.is(), "Got no XUrlContainer!" ); 296cdf0e10cSrcweir if ( !xContainer.is() ) 297cdf0e10cSrcweir return false; 298cdf0e10cSrcweir 299cdf0e10cSrcweir xContainer->addUrl( rURL, bPersist ); 300cdf0e10cSrcweir } 301cdf0e10cSrcweir } 302cdf0e10cSrcweir catch ( task::NoMasterException const & ) 303cdf0e10cSrcweir { 304cdf0e10cSrcweir // user did not enter master password 305cdf0e10cSrcweir return false; 306cdf0e10cSrcweir } 307cdf0e10cSrcweir return true; 308cdf0e10cSrcweir } 309cdf0e10cSrcweir 310cdf0e10cSrcweir //========================================================================= 311cdf0e10cSrcweir //========================================================================= 312cdf0e10cSrcweir //========================================================================= 313cdf0e10cSrcweir 314cdf0e10cSrcweir PasswordContainerInteractionHandler::PasswordContainerInteractionHandler( 315cdf0e10cSrcweir const uno::Reference< lang::XMultiServiceFactory >& xSMgr ) 316cdf0e10cSrcweir : m_aPwContainerHelper( xSMgr ) 317cdf0e10cSrcweir { 318cdf0e10cSrcweir } 319cdf0e10cSrcweir 320cdf0e10cSrcweir //========================================================================= 321cdf0e10cSrcweir // virtual 322cdf0e10cSrcweir PasswordContainerInteractionHandler::~PasswordContainerInteractionHandler() 323cdf0e10cSrcweir { 324cdf0e10cSrcweir } 325cdf0e10cSrcweir 326cdf0e10cSrcweir //========================================================================= 327cdf0e10cSrcweir // 328cdf0e10cSrcweir // XServiceInfo methods. 329cdf0e10cSrcweir // 330cdf0e10cSrcweir //========================================================================= 331cdf0e10cSrcweir 332cdf0e10cSrcweir // virtual 333cdf0e10cSrcweir ::rtl::OUString SAL_CALL 334cdf0e10cSrcweir PasswordContainerInteractionHandler::getImplementationName() 335cdf0e10cSrcweir throw ( uno::RuntimeException ) 336cdf0e10cSrcweir { 337cdf0e10cSrcweir return getImplementationName_Static(); 338cdf0e10cSrcweir } 339cdf0e10cSrcweir 340cdf0e10cSrcweir //========================================================================= 341cdf0e10cSrcweir // virtual 342cdf0e10cSrcweir sal_Bool SAL_CALL 343cdf0e10cSrcweir PasswordContainerInteractionHandler::supportsService( 344cdf0e10cSrcweir const ::rtl::OUString& ServiceName ) 345cdf0e10cSrcweir throw ( uno::RuntimeException ) 346cdf0e10cSrcweir { 347cdf0e10cSrcweir uno::Sequence< rtl::OUString > aSNL = getSupportedServiceNames(); 348cdf0e10cSrcweir const rtl::OUString * pArray = aSNL.getConstArray(); 349cdf0e10cSrcweir for ( sal_Int32 i = 0; i < aSNL.getLength(); i++ ) 350cdf0e10cSrcweir { 351cdf0e10cSrcweir if ( pArray[ i ] == ServiceName ) 352cdf0e10cSrcweir return sal_True; 353cdf0e10cSrcweir } 354cdf0e10cSrcweir return sal_False; 355cdf0e10cSrcweir } 356cdf0e10cSrcweir 357cdf0e10cSrcweir //========================================================================= 358cdf0e10cSrcweir // virtual 359cdf0e10cSrcweir uno::Sequence< ::rtl::OUString > SAL_CALL 360cdf0e10cSrcweir PasswordContainerInteractionHandler::getSupportedServiceNames() 361cdf0e10cSrcweir throw ( uno::RuntimeException ) 362cdf0e10cSrcweir { 363cdf0e10cSrcweir return getSupportedServiceNames_Static(); 364cdf0e10cSrcweir } 365cdf0e10cSrcweir 366cdf0e10cSrcweir //========================================================================= 367cdf0e10cSrcweir // static 368cdf0e10cSrcweir rtl::OUString 369cdf0e10cSrcweir PasswordContainerInteractionHandler::getImplementationName_Static() 370cdf0e10cSrcweir { 371cdf0e10cSrcweir return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( 372cdf0e10cSrcweir "com.sun.star.comp.uui.PasswordContainerInteractionHandler" ) ); 373cdf0e10cSrcweir } 374cdf0e10cSrcweir 375cdf0e10cSrcweir //========================================================================= 376cdf0e10cSrcweir // static 377cdf0e10cSrcweir uno::Sequence< rtl::OUString > 378cdf0e10cSrcweir PasswordContainerInteractionHandler::getSupportedServiceNames_Static() 379cdf0e10cSrcweir { 380cdf0e10cSrcweir uno::Sequence< rtl::OUString > aSNS( 1 ); 381cdf0e10cSrcweir aSNS.getArray()[ 0 ] 382cdf0e10cSrcweir = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( 383cdf0e10cSrcweir "com.sun.star.task.PasswordContainerInteractionHandler" ) ); 384cdf0e10cSrcweir return aSNS; 385cdf0e10cSrcweir } 386cdf0e10cSrcweir 387cdf0e10cSrcweir //========================================================================= 388cdf0e10cSrcweir // 389cdf0e10cSrcweir // XInteractionHandler methods. 390cdf0e10cSrcweir // 391cdf0e10cSrcweir //========================================================================= 392cdf0e10cSrcweir 393cdf0e10cSrcweir // virtual 394cdf0e10cSrcweir void SAL_CALL 395cdf0e10cSrcweir PasswordContainerInteractionHandler::handle( 396cdf0e10cSrcweir const uno::Reference< task::XInteractionRequest >& rRequest ) 397cdf0e10cSrcweir throw ( uno::RuntimeException ) 398cdf0e10cSrcweir { 399cdf0e10cSrcweir if ( !rRequest.is() ) 400cdf0e10cSrcweir return; 401cdf0e10cSrcweir 402cdf0e10cSrcweir uno::Any aAnyRequest( rRequest->getRequest() ); 403cdf0e10cSrcweir 404cdf0e10cSrcweir ucb::AuthenticationRequest aAuthenticationRequest; 405cdf0e10cSrcweir if ( !( aAnyRequest >>= aAuthenticationRequest ) ) 406cdf0e10cSrcweir return; 407cdf0e10cSrcweir 408cdf0e10cSrcweir rtl::OUString aURL; 409cdf0e10cSrcweir ucb::URLAuthenticationRequest aURLAuthenticationRequest; 410cdf0e10cSrcweir if ( aAnyRequest >>= aURLAuthenticationRequest ) 411cdf0e10cSrcweir aURL = aURLAuthenticationRequest.URL; 412cdf0e10cSrcweir 413cdf0e10cSrcweir uno::Sequence< uno::Reference< task::XInteractionContinuation > > 414cdf0e10cSrcweir rContinuations = rRequest->getContinuations(); 415cdf0e10cSrcweir 416cdf0e10cSrcweir uno::Reference< ucb::XInteractionSupplyAuthentication > 417cdf0e10cSrcweir xSupplyAuthentication; 418cdf0e10cSrcweir 419cdf0e10cSrcweir for ( sal_Int32 i = 0; i < rContinuations.getLength(); ++i ) 420cdf0e10cSrcweir { 421cdf0e10cSrcweir xSupplyAuthentication 422cdf0e10cSrcweir = uno::Reference< ucb::XInteractionSupplyAuthentication >( 423cdf0e10cSrcweir rContinuations[i], uno::UNO_QUERY ); 424cdf0e10cSrcweir if( xSupplyAuthentication.is() ) 425cdf0e10cSrcweir break; 426cdf0e10cSrcweir } 427cdf0e10cSrcweir 428cdf0e10cSrcweir if ( !xSupplyAuthentication.is() ) 429cdf0e10cSrcweir return; 430cdf0e10cSrcweir 431cdf0e10cSrcweir // Try to obatin credentials from password container. 432cdf0e10cSrcweir if ( m_aPwContainerHelper. 433cdf0e10cSrcweir handleAuthenticationRequest( aAuthenticationRequest, 434cdf0e10cSrcweir xSupplyAuthentication, 435cdf0e10cSrcweir aURL, 436cdf0e10cSrcweir // @@@ FIXME: this not able to 437cdf0e10cSrcweir // handle master pw request! 438cdf0e10cSrcweir // master pw request is never 439cdf0e10cSrcweir // solvable without UI! 440cdf0e10cSrcweir this ) ) 441cdf0e10cSrcweir { 442cdf0e10cSrcweir // successfully handled 443cdf0e10cSrcweir xSupplyAuthentication->select(); 444cdf0e10cSrcweir } 445cdf0e10cSrcweir } 446cdf0e10cSrcweir 447cdf0e10cSrcweir //========================================================================= 448cdf0e10cSrcweir // 449cdf0e10cSrcweir // Service factory implementation. 450cdf0e10cSrcweir // 451cdf0e10cSrcweir //========================================================================= 452cdf0e10cSrcweir 453cdf0e10cSrcweir static uno::Reference< uno::XInterface > SAL_CALL 454cdf0e10cSrcweir PasswordContainerInteractionHandler_CreateInstance( 455cdf0e10cSrcweir const uno::Reference< lang::XMultiServiceFactory> & rSMgr ) 456cdf0e10cSrcweir throw( uno::Exception ) 457cdf0e10cSrcweir { 458cdf0e10cSrcweir lang::XServiceInfo * pX = static_cast< lang::XServiceInfo * >( 459cdf0e10cSrcweir new PasswordContainerInteractionHandler( rSMgr ) ); 460cdf0e10cSrcweir return uno::Reference< uno::XInterface >::query( pX ); 461cdf0e10cSrcweir } 462cdf0e10cSrcweir 463cdf0e10cSrcweir //========================================================================= 464cdf0e10cSrcweir // static 465cdf0e10cSrcweir uno::Reference< lang::XSingleServiceFactory > 466cdf0e10cSrcweir PasswordContainerInteractionHandler::createServiceFactory( 467cdf0e10cSrcweir const uno::Reference< lang::XMultiServiceFactory >& rxServiceMgr ) 468cdf0e10cSrcweir { 469cdf0e10cSrcweir return uno::Reference< lang::XSingleServiceFactory >( 470cdf0e10cSrcweir cppu::createOneInstanceFactory( 471cdf0e10cSrcweir rxServiceMgr, 472cdf0e10cSrcweir PasswordContainerInteractionHandler::getImplementationName_Static(), 473cdf0e10cSrcweir PasswordContainerInteractionHandler_CreateInstance, 474cdf0e10cSrcweir PasswordContainerInteractionHandler::getSupportedServiceNames_Static() ) ); 475cdf0e10cSrcweir } 476cdf0e10cSrcweir 477cdf0e10cSrcweir } // namespace uui 478