Version 6.4.0.3, tag libreoffice-6.4.0.3
[LibreOffice.git] / uui / source / iahndl-authentication.cxx
blob4835a485dd2a44548ce32ab5148b892fbb81ea18
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <com/sun/star/task/DocumentPasswordRequest.hpp>
21 #include <com/sun/star/task/DocumentPasswordRequest2.hpp>
22 #include <com/sun/star/task/DocumentMSPasswordRequest.hpp>
23 #include <com/sun/star/task/DocumentMSPasswordRequest2.hpp>
24 #include <com/sun/star/task/MasterPasswordRequest.hpp>
25 #include <com/sun/star/task/XInteractionAbort.hpp>
26 #include <com/sun/star/task/XInteractionPassword.hpp>
27 #include <com/sun/star/task/XInteractionPassword2.hpp>
28 #include <com/sun/star/task/XInteractionRetry.hpp>
29 #include <com/sun/star/ucb/XInteractionAuthFallback.hpp>
30 #include <com/sun/star/ucb/XInteractionSupplyAuthentication2.hpp>
31 #include <com/sun/star/ucb/URLAuthenticationRequest.hpp>
33 #include <osl/diagnose.h>
34 #include <rtl/digest.h>
35 #include <unotools/resmgr.hxx>
36 #include <vcl/errcode.hxx>
37 #include <vcl/errinf.hxx>
38 #include <vcl/abstdlg.hxx>
39 #include <vcl/svapp.hxx>
40 #include <sal/log.hxx>
42 #include "authfallbackdlg.hxx"
43 #include <strings.hrc>
44 #include "getcontinuations.hxx"
45 #include "passwordcontainer.hxx"
46 #include "loginerr.hxx"
47 #include "logindlg.hxx"
48 #include "masterpasscrtdlg.hxx"
49 #include "masterpassworddlg.hxx"
50 #include "passworddlg.hxx"
52 #include "iahndl.hxx"
54 #include <memory>
56 using namespace com::sun::star;
58 namespace {
60 void
61 executeLoginDialog(
62 weld::Window* pParent,
63 LoginErrorInfo & rInfo,
64 OUString const & rRealm)
66 SolarMutexGuard aGuard;
68 bool bAccount = (rInfo.GetFlags() & LOGINERROR_FLAG_MODIFY_ACCOUNT) != 0;
69 bool bSavePassword = rInfo.GetCanRememberPassword();
70 bool bCanUseSysCreds = rInfo.GetCanUseSystemCredentials();
72 LoginFlags nFlags = LoginFlags::NONE;
73 if (rInfo.GetErrorText().isEmpty())
74 nFlags |= LoginFlags::NoErrorText;
75 if (!bAccount)
76 nFlags |= LoginFlags::NoAccount;
77 if (!(rInfo.GetFlags() & LOGINERROR_FLAG_MODIFY_USER_NAME))
78 nFlags |= LoginFlags::UsernameReadonly;
80 if (!bSavePassword)
81 nFlags |= LoginFlags::NoSavePassword;
83 if (!bCanUseSysCreds)
84 nFlags |= LoginFlags::NoUseSysCreds;
86 LoginDialog aDialog(pParent, nFlags, rInfo.GetServer(), rRealm);
87 if (!rInfo.GetErrorText().isEmpty())
88 aDialog.SetErrorText(rInfo.GetErrorText());
89 aDialog.SetName(rInfo.GetUserName());
90 if (bAccount)
91 aDialog.ClearAccount();
92 else
93 aDialog.ClearPassword();
94 aDialog.SetPassword(rInfo.GetPassword());
96 if (bSavePassword)
98 std::locale aLocale(Translate::Create("uui"));
99 aDialog.SetSavePasswordText(
100 Translate::get(rInfo.GetIsRememberPersistent()
101 ? RID_SAVE_PASSWORD
102 : RID_KEEP_PASSWORD,
103 aLocale));
105 aDialog.SetSavePassword(rInfo.GetIsRememberPassword());
108 if ( bCanUseSysCreds )
109 aDialog.SetUseSystemCredentials( rInfo.GetIsUseSystemCredentials() );
111 rInfo.SetResult(aDialog.run() == RET_OK ? DialogMask::ButtonsOk :
112 DialogMask::ButtonsCancel);
113 rInfo.SetUserName(aDialog.GetName());
114 rInfo.SetPassword(aDialog.GetPassword());
115 rInfo.SetAccount(aDialog.GetAccount());
116 rInfo.SetIsRememberPassword(aDialog.IsSavePassword());
118 if ( bCanUseSysCreds )
119 rInfo.SetIsUseSystemCredentials( aDialog.IsUseSystemCredentials() );
122 void getRememberModes(
123 uno::Sequence< ucb::RememberAuthentication > const & rRememberModes,
124 ucb::RememberAuthentication & rPreferredMode,
125 ucb::RememberAuthentication & rAlternateMode )
127 sal_Int32 nCount = rRememberModes.getLength();
128 OSL_ENSURE( (nCount > 0) && (nCount < 4),
129 "ucb::RememberAuthentication sequence size mismatch!" );
130 if ( nCount == 1 )
132 rPreferredMode = rAlternateMode = rRememberModes[ 0 ];
133 return;
135 else
137 bool bHasRememberModeSession = false;
138 bool bHasRememberModePersistent = false;
140 for (const auto& rRememberMode : rRememberModes)
142 switch ( rRememberMode )
144 case ucb::RememberAuthentication_NO:
145 break;
146 case ucb::RememberAuthentication_SESSION:
147 bHasRememberModeSession = true;
148 break;
149 case ucb::RememberAuthentication_PERSISTENT:
150 bHasRememberModePersistent = true;
151 break;
152 default:
153 SAL_WARN( "uui", "Unsupported RememberAuthentication value" << static_cast<sal_Int32>(rRememberMode) );
154 break;
158 if (bHasRememberModePersistent)
160 rPreferredMode = ucb::RememberAuthentication_PERSISTENT;
161 if (bHasRememberModeSession)
162 rAlternateMode = ucb::RememberAuthentication_SESSION;
163 else
164 rAlternateMode = ucb::RememberAuthentication_NO;
166 else
168 rPreferredMode = ucb::RememberAuthentication_SESSION;
169 rAlternateMode = ucb::RememberAuthentication_NO;
174 void
175 handleAuthenticationRequest_(
176 weld::Window * pParent,
177 uno::Reference< task::XInteractionHandler2 > const & xIH,
178 uno::Reference< uno::XComponentContext > const & xContext,
179 ucb::AuthenticationRequest const & rRequest,
180 uno::Sequence< uno::Reference< task::XInteractionContinuation > > const &
181 rContinuations,
182 const OUString & rURL)
184 uno::Reference< task::XInteractionRetry > xRetry;
185 uno::Reference< task::XInteractionAbort > xAbort;
186 uno::Reference< ucb::XInteractionSupplyAuthentication >
187 xSupplyAuthentication;
188 uno::Reference< ucb::XInteractionSupplyAuthentication2 >
189 xSupplyAuthentication2;
190 getContinuations(rContinuations, &xRetry, &xAbort, &xSupplyAuthentication);
191 if (xSupplyAuthentication.is())
192 xSupplyAuthentication2.set(xSupplyAuthentication, uno::UNO_QUERY);
195 // First, try to obtain credentials from password container service.
196 uui::PasswordContainerHelper aPwContainerHelper(xContext);
197 if (aPwContainerHelper.handleAuthenticationRequest(rRequest,
198 xSupplyAuthentication,
199 rURL,
200 xIH))
202 xSupplyAuthentication->select();
203 return;
207 // Second, try to obtain credentials from user via password dialog.
208 ucb::RememberAuthentication eDefaultRememberMode
209 = ucb::RememberAuthentication_SESSION;
210 ucb::RememberAuthentication ePreferredRememberMode
211 = eDefaultRememberMode;
212 ucb::RememberAuthentication eAlternateRememberMode
213 = ucb::RememberAuthentication_NO;
215 if (xSupplyAuthentication.is())
217 getRememberModes(
218 xSupplyAuthentication->getRememberPasswordModes(
219 eDefaultRememberMode),
220 ePreferredRememberMode,
221 eAlternateRememberMode);
224 bool bCanUseSystemCredentials;
225 sal_Bool bDefaultUseSystemCredentials;
226 if (xSupplyAuthentication2.is())
228 bCanUseSystemCredentials
229 = xSupplyAuthentication2->canUseSystemCredentials(
230 bDefaultUseSystemCredentials);
232 else
234 bCanUseSystemCredentials = false;
235 bDefaultUseSystemCredentials = false;
238 LoginErrorInfo aInfo;
239 aInfo.SetServer(rRequest.ServerName);
240 if (rRequest.HasAccount)
241 aInfo.SetAccount(rRequest.Account);
242 if (rRequest.HasUserName)
243 aInfo.SetUserName(rRequest.UserName);
244 if (rRequest.HasPassword)
245 aInfo.SetPassword(rRequest.Password);
246 aInfo.SetErrorText(rRequest.Diagnostic);
248 aInfo.SetCanRememberPassword(
249 ePreferredRememberMode != eAlternateRememberMode);
250 aInfo.SetIsRememberPassword(
251 ePreferredRememberMode == eDefaultRememberMode);
252 aInfo.SetIsRememberPersistent(
253 ePreferredRememberMode == ucb::RememberAuthentication_PERSISTENT);
255 aInfo.SetCanUseSystemCredentials(bCanUseSystemCredentials);
256 aInfo.SetIsUseSystemCredentials( bDefaultUseSystemCredentials );
257 aInfo.SetModifyAccount(rRequest.HasAccount
258 && xSupplyAuthentication.is()
259 && xSupplyAuthentication->canSetAccount());
260 aInfo.SetModifyUserName(rRequest.HasUserName
261 && xSupplyAuthentication.is()
262 && xSupplyAuthentication->canSetUserName());
263 executeLoginDialog(pParent,
264 aInfo,
265 rRequest.HasRealm ? rRequest.Realm : OUString());
266 switch (aInfo.GetResult())
268 case DialogMask::ButtonsOk:
269 if (xSupplyAuthentication.is())
271 if (xSupplyAuthentication->canSetUserName())
272 xSupplyAuthentication->setUserName(aInfo.GetUserName());
273 if (xSupplyAuthentication->canSetPassword())
274 xSupplyAuthentication->setPassword(aInfo.GetPassword());
276 if (ePreferredRememberMode != eAlternateRememberMode)
278 // user had the choice.
279 if (aInfo.GetIsRememberPassword())
280 xSupplyAuthentication->setRememberPassword(
281 ePreferredRememberMode);
282 else
283 xSupplyAuthentication->setRememberPassword(
284 eAlternateRememberMode);
286 else
288 // user had no choice.
289 xSupplyAuthentication->setRememberPassword(
290 ePreferredRememberMode);
293 if (rRequest.HasRealm)
295 if (xSupplyAuthentication->canSetRealm())
296 xSupplyAuthentication->setRealm(aInfo.GetAccount());
298 else if (xSupplyAuthentication->canSetAccount())
299 xSupplyAuthentication->setAccount(aInfo.GetAccount());
301 if ( xSupplyAuthentication2.is() && bCanUseSystemCredentials )
302 xSupplyAuthentication2->setUseSystemCredentials(
303 aInfo.GetIsUseSystemCredentials() );
305 xSupplyAuthentication->select();
309 // Third, store credentials in password container.
311 if ( aInfo.GetIsUseSystemCredentials() )
313 if (aInfo.GetIsRememberPassword())
315 if (!aPwContainerHelper.addRecord(
316 !rURL.isEmpty() ? rURL : rRequest.ServerName,
317 OUString(), // empty u/p -> sys creds
318 uno::Sequence< OUString >(),
319 xIH,
320 ePreferredRememberMode
321 == ucb::RememberAuthentication_PERSISTENT))
323 xSupplyAuthentication->setRememberPassword(
324 ucb::RememberAuthentication_NO);
327 else if (eAlternateRememberMode
328 == ucb::RememberAuthentication_SESSION)
330 if (!aPwContainerHelper.addRecord(
331 !rURL.isEmpty() ? rURL : rRequest.ServerName,
332 OUString(), // empty u/p -> sys creds
333 uno::Sequence< OUString >(),
334 xIH,
335 false /* SESSION */))
337 xSupplyAuthentication->setRememberPassword(
338 ucb::RememberAuthentication_NO);
342 // Empty user name can not be valid:
343 else if (!aInfo.GetUserName().isEmpty())
345 uno::Sequence< OUString >
346 aPassList(aInfo.GetAccount().isEmpty() ? 1 : 2);
347 aPassList[0] = aInfo.GetPassword();
348 if (!aInfo.GetAccount().isEmpty())
349 aPassList[1] = aInfo.GetAccount();
351 if (aInfo.GetIsRememberPassword())
353 if (!aPwContainerHelper.addRecord(
354 !rURL.isEmpty() ? rURL : rRequest.ServerName,
355 aInfo.GetUserName(),
356 aPassList,
357 xIH,
358 ePreferredRememberMode
359 == ucb::RememberAuthentication_PERSISTENT))
361 xSupplyAuthentication->setRememberPassword(
362 ucb::RememberAuthentication_NO);
365 else if (eAlternateRememberMode
366 == ucb::RememberAuthentication_SESSION)
368 if (!aPwContainerHelper.addRecord(
369 !rURL.isEmpty() ? rURL : rRequest.ServerName,
370 aInfo.GetUserName(),
371 aPassList,
372 xIH,
373 false /* SESSION */))
375 xSupplyAuthentication->setRememberPassword(
376 ucb::RememberAuthentication_NO);
380 break;
382 case DialogMask::ButtonsRetry:
383 if (xRetry.is())
384 xRetry->select();
385 break;
387 default:
388 if (xAbort.is())
389 xAbort->select();
390 break;
394 void
395 executeMasterPasswordDialog(
396 weld::Window* pParent,
397 LoginErrorInfo & rInfo,
398 task::PasswordRequestMode nMode)
400 OString aMaster;
402 SolarMutexGuard aGuard;
404 std::locale aResLocale(Translate::Create("uui"));
405 if( nMode == task::PasswordRequestMode_PASSWORD_CREATE )
407 MasterPasswordCreateDialog aDialog(pParent, aResLocale);
408 rInfo.SetResult(aDialog.run()
409 == RET_OK ? DialogMask::ButtonsOk : DialogMask::ButtonsCancel);
410 aMaster = OUStringToOString(
411 aDialog.GetMasterPassword(), RTL_TEXTENCODING_UTF8);
413 else
415 MasterPasswordDialog aDialog(pParent, nMode, aResLocale);
416 rInfo.SetResult(aDialog.run()
417 == RET_OK ? DialogMask::ButtonsOk : DialogMask::ButtonsCancel);
418 aMaster = OUStringToOString(
419 aDialog.GetMasterPassword(), RTL_TEXTENCODING_UTF8);
423 sal_uInt8 aKey[RTL_DIGEST_LENGTH_MD5];
424 // FIXME this is subject to the SHA1-bug tdf#114939 - but this
425 // MasterPassword stuff is just stored in the UserInstallation,
426 // so no interop concerns
427 rtl_digest_PBKDF2(aKey,
428 RTL_DIGEST_LENGTH_MD5,
429 reinterpret_cast< sal_uInt8 const * >(aMaster.getStr()),
430 aMaster.getLength(),
431 reinterpret_cast< sal_uInt8 const * >(
432 "3B5509ABA6BC42D9A3A1F3DAD49E56A51"),
434 1000);
436 OUStringBuffer aBuffer;
437 for (sal_uInt8 i : aKey)
439 aBuffer.append(static_cast< sal_Unicode >('a' + (i >> 4)));
440 aBuffer.append(static_cast< sal_Unicode >('a' + (i & 15)));
442 rInfo.SetPassword(aBuffer.makeStringAndClear());
445 void
446 handleMasterPasswordRequest_(
447 weld::Window * pParent,
448 task::PasswordRequestMode nMode,
449 uno::Sequence< uno::Reference< task::XInteractionContinuation > > const &
450 rContinuations)
452 uno::Reference< task::XInteractionRetry > xRetry;
453 uno::Reference< task::XInteractionAbort > xAbort;
454 uno::Reference< ucb::XInteractionSupplyAuthentication >
455 xSupplyAuthentication;
456 getContinuations(rContinuations, &xRetry, &xAbort, &xSupplyAuthentication);
457 LoginErrorInfo aInfo;
459 // in case of master password a hash code is returned
460 executeMasterPasswordDialog(pParent, aInfo, nMode);
462 switch (aInfo.GetResult())
464 case DialogMask::ButtonsOk:
465 if (xSupplyAuthentication.is())
467 if (xSupplyAuthentication->canSetPassword())
468 xSupplyAuthentication->setPassword(aInfo.GetPassword());
469 xSupplyAuthentication->select();
471 break;
473 case DialogMask::ButtonsRetry:
474 if (xRetry.is())
475 xRetry->select();
476 break;
478 default:
479 if (xAbort.is())
480 xAbort->select();
481 break;
485 void
486 executePasswordDialog(
487 weld::Window * pParent,
488 LoginErrorInfo & rInfo,
489 task::PasswordRequestMode nMode,
490 const OUString& aDocName,
491 sal_uInt16 nMaxPasswordLen,
492 bool bIsPasswordToModify,
493 bool bIsSimplePasswordRequest )
495 SolarMutexGuard aGuard;
497 std::locale aResLocale(Translate::Create("uui"));
498 if( nMode == task::PasswordRequestMode_PASSWORD_CREATE )
500 if (bIsSimplePasswordRequest)
502 std::unique_ptr<PasswordDialog> xDialog(new PasswordDialog(pParent, nMode,
503 aResLocale, aDocName, bIsPasswordToModify, bIsSimplePasswordRequest));
504 xDialog->SetMinLen(0);
506 rInfo.SetResult(xDialog->run() == RET_OK ? DialogMask::ButtonsOk : DialogMask::ButtonsCancel);
507 rInfo.SetPassword(xDialog->GetPassword());
509 else
511 VclAbstractDialogFactory * pFact = VclAbstractDialogFactory::Create();
512 ScopedVclPtr<AbstractPasswordToOpenModifyDialog> const pDialog(
513 pFact->CreatePasswordToOpenModifyDialog(pParent, nMaxPasswordLen, bIsPasswordToModify));
515 rInfo.SetResult( pDialog->Execute() == RET_OK ? DialogMask::ButtonsOk : DialogMask::ButtonsCancel );
516 rInfo.SetPassword( pDialog->GetPasswordToOpen() );
517 rInfo.SetPasswordToModify( pDialog->GetPasswordToModify() );
518 rInfo.SetRecommendToOpenReadonly( pDialog->IsRecommendToOpenReadonly() );
521 else // enter password or reenter password
523 std::unique_ptr<PasswordDialog> xDialog(new PasswordDialog(pParent, nMode,
524 aResLocale, aDocName, bIsPasswordToModify, bIsSimplePasswordRequest));
525 xDialog->SetMinLen(0);
527 rInfo.SetResult(xDialog->run() == RET_OK ? DialogMask::ButtonsOk : DialogMask::ButtonsCancel);
528 rInfo.SetPassword(bIsPasswordToModify ? OUString() : xDialog->GetPassword());
529 rInfo.SetPasswordToModify(bIsPasswordToModify ? xDialog->GetPassword() : OUString());
533 void
534 handlePasswordRequest_(
535 weld::Window * pParent,
536 task::PasswordRequestMode nMode,
537 uno::Sequence< uno::Reference< task::XInteractionContinuation > > const &
538 rContinuations,
539 const OUString& aDocumentName,
540 sal_uInt16 nMaxPasswordLen,
541 bool bIsPasswordToModify,
542 bool bIsSimplePasswordRequest = false )
544 uno::Reference< task::XInteractionRetry > xRetry;
545 uno::Reference< task::XInteractionAbort > xAbort;
546 uno::Reference< task::XInteractionPassword > xPassword;
547 uno::Reference< task::XInteractionPassword2 > xPassword2;
548 getContinuations(rContinuations, &xRetry, &xAbort, &xPassword2, &xPassword);
550 if ( xPassword2.is() && !xPassword.is() )
551 xPassword.set( xPassword2, uno::UNO_QUERY_THROW );
553 LoginErrorInfo aInfo;
555 executePasswordDialog( pParent, aInfo, nMode,
556 aDocumentName, nMaxPasswordLen, bIsPasswordToModify, bIsSimplePasswordRequest );
558 switch (aInfo.GetResult())
560 case DialogMask::ButtonsOk:
561 OSL_ENSURE( !bIsPasswordToModify || xPassword2.is(), "PasswordToModify is requested, but there is no Interaction!" );
562 if (xPassword.is())
564 if (xPassword2.is())
566 xPassword2->setPasswordToModify( aInfo.GetPasswordToModify() );
567 xPassword2->setRecommendReadOnly( aInfo.IsRecommendToOpenReadonly() );
570 xPassword->setPassword(aInfo.GetPassword());
571 xPassword->select();
573 break;
575 case DialogMask::ButtonsRetry:
576 if (xRetry.is())
577 xRetry->select();
578 break;
580 default:
581 if (xAbort.is())
582 xAbort->select();
583 break;
587 } // namespace
589 bool
590 UUIInteractionHelper::handleAuthenticationRequest(
591 uno::Reference< task::XInteractionRequest > const & rRequest)
593 uno::Any aAnyRequest(rRequest->getRequest());
594 uno::Reference<awt::XWindow> xParent = getParentXWindow();
596 ucb::URLAuthenticationRequest aURLAuthenticationRequest;
597 if (aAnyRequest >>= aURLAuthenticationRequest)
599 handleAuthenticationRequest_(Application::GetFrameWeld(xParent),
600 getInteractionHandler(),
601 m_xContext,
602 aURLAuthenticationRequest,
603 rRequest->getContinuations(),
604 aURLAuthenticationRequest.URL);
605 return true;
608 ucb::AuthenticationRequest aAuthenticationRequest;
609 if (aAnyRequest >>= aAuthenticationRequest)
611 handleAuthenticationRequest_(Application::GetFrameWeld(xParent),
612 getInteractionHandler(),
613 m_xContext,
614 aAuthenticationRequest,
615 rRequest->getContinuations(),
616 OUString());
617 return true;
619 return false;
622 bool
623 UUIInteractionHelper::handleMasterPasswordRequest(
624 uno::Reference< task::XInteractionRequest > const & rRequest)
626 uno::Any aAnyRequest(rRequest->getRequest());
628 task::MasterPasswordRequest aMasterPasswordRequest;
629 if (aAnyRequest >>= aMasterPasswordRequest)
631 uno::Reference<awt::XWindow> xParent = getParentXWindow();
633 handleMasterPasswordRequest_(Application::GetFrameWeld(xParent),
634 aMasterPasswordRequest.Mode,
635 rRequest->getContinuations());
636 return true;
638 return false;
641 bool
642 UUIInteractionHelper::handlePasswordRequest(
643 uno::Reference< task::XInteractionRequest > const & rRequest)
645 // parameters to be filled for the call to handlePasswordRequest_
646 uno::Reference<awt::XWindow> xParent = getParentXWindow();
647 task::PasswordRequestMode nMode = task::PasswordRequestMode_PASSWORD_ENTER;
648 uno::Sequence< uno::Reference< task::XInteractionContinuation > > const & rContinuations = rRequest->getContinuations();
649 OUString aDocumentName;
650 sal_uInt16 nMaxPasswordLen = 0; // any length
651 bool bIsPasswordToModify = false;
653 bool bDoHandleRequest = false;
655 uno::Any aAnyRequest(rRequest->getRequest());
659 task::DocumentPasswordRequest2 aDocumentPasswordRequest2;
660 if (aAnyRequest >>= aDocumentPasswordRequest2)
662 nMode = aDocumentPasswordRequest2.Mode;
663 aDocumentName = aDocumentPasswordRequest2.Name;
664 bIsPasswordToModify = aDocumentPasswordRequest2.IsRequestPasswordToModify;
666 bDoHandleRequest = true;
667 break; // do
670 task::DocumentPasswordRequest aDocumentPasswordRequest;
671 if (aAnyRequest >>= aDocumentPasswordRequest)
673 nMode = aDocumentPasswordRequest.Mode;
674 aDocumentName = aDocumentPasswordRequest.Name;
675 OSL_ENSURE( !bIsPasswordToModify, "bIsPasswordToModify should be false" );
677 bDoHandleRequest = true;
678 break; // do
681 task::DocumentMSPasswordRequest2 aDocumentMSPasswordRequest2;
682 if (aAnyRequest >>= aDocumentMSPasswordRequest2)
684 nMode = aDocumentMSPasswordRequest2.Mode;
685 aDocumentName = aDocumentMSPasswordRequest2.Name;
686 nMaxPasswordLen = 15;
687 bIsPasswordToModify = aDocumentMSPasswordRequest2.IsRequestPasswordToModify;
689 bDoHandleRequest = true;
690 break; // do
693 task::DocumentMSPasswordRequest aDocumentMSPasswordRequest;
694 if (aAnyRequest >>= aDocumentMSPasswordRequest)
696 nMode = aDocumentMSPasswordRequest.Mode;
697 aDocumentName = aDocumentMSPasswordRequest.Name;
698 nMaxPasswordLen = 15;
699 OSL_ENSURE( !bIsPasswordToModify, "bIsPasswordToModify should be false" );
701 bDoHandleRequest = true;
702 break; // do
705 while (false);
707 if (bDoHandleRequest)
709 handlePasswordRequest_( Application::GetFrameWeld(xParent), nMode, rContinuations,
710 aDocumentName, nMaxPasswordLen, bIsPasswordToModify );
711 return true;
714 task::PasswordRequest aPasswordRequest;
715 if( aAnyRequest >>= aPasswordRequest )
717 handlePasswordRequest_(Application::GetFrameWeld(xParent),
718 aPasswordRequest.Mode,
719 rRequest->getContinuations(),
720 OUString(),
721 0 /* sal_uInt16 nMaxPasswordLen */,
722 false /* bool bIsPasswordToModify */,
723 true /* bool bIsSimplePasswordRequest */ );
724 return true;
727 return false;
730 void
731 UUIInteractionHelper::handleAuthFallbackRequest( const OUString & instructions,
732 const OUString & url,
733 uno::Sequence< uno::Reference< task::XInteractionContinuation > > const & rContinuations )
735 uno::Reference<awt::XWindow> xParent = getParentXWindow();
736 AuthFallbackDlg dlg(Application::GetFrameWeld(xParent), instructions, url);
737 int retCode = dlg.run();
738 uno::Reference< task::XInteractionAbort > xAbort;
739 uno::Reference< ucb::XInteractionAuthFallback > xAuthFallback;
740 getContinuations(rContinuations, &xAbort, &xAuthFallback);
742 if( retCode == RET_OK && xAuthFallback.is( ) )
744 xAuthFallback->setCode(dlg.GetCode());
745 xAuthFallback->select( );
749 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */