1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 "comphelper/processfactory.hxx"
22 #include "com/sun/star/task/DocumentPasswordRequest.hpp"
23 #include "com/sun/star/task/DocumentPasswordRequest2.hpp"
24 #include "com/sun/star/task/DocumentMSPasswordRequest.hpp"
25 #include "com/sun/star/task/DocumentMSPasswordRequest2.hpp"
26 #include "com/sun/star/task/MasterPasswordRequest.hpp"
27 #include "com/sun/star/task/XInteractionAbort.hpp"
28 #include "com/sun/star/task/XInteractionPassword.hpp"
29 #include "com/sun/star/task/XInteractionPassword2.hpp"
30 #include "com/sun/star/task/XInteractionRetry.hpp"
31 #include "com/sun/star/ucb/XInteractionSupplyAuthentication2.hpp"
32 #include "com/sun/star/ucb/URLAuthenticationRequest.hpp"
34 #include "osl/diagnose.h"
35 #include "rtl/digest.h"
36 #include "osl/mutex.hxx"
37 #include "tools/errcode.hxx"
38 #include "vcl/msgbox.hxx"
39 #include "vcl/abstdlg.hxx"
40 #include "vcl/svapp.hxx"
43 #include "getcontinuations.hxx"
44 #include "passwordcontainer.hxx"
45 #include "loginerr.hxx"
46 #include "logindlg.hxx"
47 #include "masterpasscrtdlg.hxx"
48 #include "masterpassworddlg.hxx"
49 #include "passworddlg.hxx"
53 #include <boost/scoped_ptr.hpp>
55 using namespace com::sun::star
;
62 LoginErrorInfo
& rInfo
,
63 rtl::OUString
const & rRealm
)
64 SAL_THROW((uno::RuntimeException
))
68 SolarMutexGuard aGuard
;
70 bool bAccount
= (rInfo
.GetFlags() & LOGINERROR_FLAG_MODIFY_ACCOUNT
) != 0;
71 bool bSavePassword
= rInfo
.GetCanRememberPassword();
72 bool bCanUseSysCreds
= rInfo
.GetCanUseSystemCredentials();
74 sal_uInt16 nFlags
= 0;
75 if (rInfo
.GetPath().Len() == 0)
77 if (rInfo
.GetErrorText().Len() == 0)
78 nFlags
|= LF_NO_ERRORTEXT
;
80 nFlags
|= LF_NO_ACCOUNT
;
81 if (!(rInfo
.GetFlags() & LOGINERROR_FLAG_MODIFY_USER_NAME
))
82 nFlags
|= LF_USERNAME_READONLY
;
85 nFlags
|= LF_NO_SAVEPASSWORD
;
88 nFlags
|= LF_NO_USESYSCREDS
;
90 boost::scoped_ptr
< ResMgr
> xManager(ResMgr::CreateResMgr("uui"));
91 boost::scoped_ptr
< LoginDialog
> xDialog(
92 new LoginDialog( pParent
, nFlags
, rInfo
.GetServer(), rRealm
, xManager
.get()));
93 if (rInfo
.GetErrorText().Len() != 0)
94 xDialog
->SetErrorText(rInfo
.GetErrorText());
95 xDialog
->SetName(rInfo
.GetUserName());
97 xDialog
->ClearAccount();
99 xDialog
->ClearPassword();
100 xDialog
->SetPassword(rInfo
.GetPassword());
104 xDialog
->SetSavePasswordText(
105 ResId(rInfo
.GetIsRememberPersistent()
110 xDialog
->SetSavePassword(rInfo
.GetIsRememberPassword());
113 if ( bCanUseSysCreds
)
114 xDialog
->SetUseSystemCredentials( rInfo
.GetIsUseSystemCredentials() );
116 rInfo
.SetResult(xDialog
->Execute() == RET_OK
? ERRCODE_BUTTON_OK
:
117 ERRCODE_BUTTON_CANCEL
);
118 rInfo
.SetUserName(xDialog
->GetName());
119 rInfo
.SetPassword(xDialog
->GetPassword());
120 rInfo
.SetAccount(xDialog
->GetAccount());
121 rInfo
.SetIsRememberPassword(xDialog
->IsSavePassword());
123 if ( bCanUseSysCreds
)
124 rInfo
.SetIsUseSystemCredentials( xDialog
->IsUseSystemCredentials() );
126 catch (std::bad_alloc
const &)
128 throw uno::RuntimeException(
129 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("out of memory")),
130 uno::Reference
< uno::XInterface
>());
134 void getRememberModes(
135 uno::Sequence
< ucb::RememberAuthentication
> const & rRememberModes
,
136 ucb::RememberAuthentication
& rPreferredMode
,
137 ucb::RememberAuthentication
& rAlternateMode
)
139 sal_Int32 nCount
= rRememberModes
.getLength();
140 OSL_ENSURE( (nCount
> 0) && (nCount
< 4),
141 "ucb::RememberAuthentication sequence size mismatch!" );
144 rPreferredMode
= rAlternateMode
= rRememberModes
[ 0 ];
149 bool bHasRememberModeSession
= false;
150 bool bHasRememberModePersistent
= false;
152 for (sal_Int32 i
= 0; i
< nCount
; ++i
)
154 switch ( rRememberModes
[i
] )
156 case ucb::RememberAuthentication_NO
:
158 case ucb::RememberAuthentication_SESSION
:
159 bHasRememberModeSession
= true;
161 case ucb::RememberAuthentication_PERSISTENT
:
162 bHasRememberModePersistent
= true;
165 OSL_TRACE( "Unsupported RememberAuthentication value" );
170 if (bHasRememberModePersistent
)
172 rPreferredMode
= ucb::RememberAuthentication_PERSISTENT
;
173 if (bHasRememberModeSession
)
174 rAlternateMode
= ucb::RememberAuthentication_SESSION
;
176 rAlternateMode
= ucb::RememberAuthentication_NO
;
180 rPreferredMode
= ucb::RememberAuthentication_SESSION
;
181 rAlternateMode
= ucb::RememberAuthentication_NO
;
187 handleAuthenticationRequest_(
189 uno::Reference
< task::XInteractionHandler2
> const & xIH
,
190 uno::Reference
< lang::XMultiServiceFactory
> const & xServiceFactory
,
191 ucb::AuthenticationRequest
const & rRequest
,
192 uno::Sequence
< uno::Reference
< task::XInteractionContinuation
> > const &
194 const rtl::OUString
& rURL
)
195 SAL_THROW((uno::RuntimeException
))
197 uno::Reference
< task::XInteractionRetry
> xRetry
;
198 uno::Reference
< task::XInteractionAbort
> xAbort
;
199 uno::Reference
< ucb::XInteractionSupplyAuthentication
>
200 xSupplyAuthentication
;
201 uno::Reference
< ucb::XInteractionSupplyAuthentication2
>
202 xSupplyAuthentication2
;
203 getContinuations(rContinuations
, &xRetry
, &xAbort
, &xSupplyAuthentication
);
204 if (xSupplyAuthentication
.is())
205 xSupplyAuthentication2
.set(xSupplyAuthentication
, uno::UNO_QUERY
);
207 //////////////////////////
208 // First, try to obtain credentials from password container service.
209 uui::PasswordContainerHelper
aPwContainerHelper(comphelper::getComponentContext(xServiceFactory
));
210 if (aPwContainerHelper
.handleAuthenticationRequest(rRequest
,
211 xSupplyAuthentication
,
215 xSupplyAuthentication
->select();
219 //////////////////////////
220 // Second, try to obtain credentials from user via password dialog.
221 ucb::RememberAuthentication eDefaultRememberMode
222 = ucb::RememberAuthentication_SESSION
;
223 ucb::RememberAuthentication ePreferredRememberMode
224 = eDefaultRememberMode
;
225 ucb::RememberAuthentication eAlternateRememberMode
226 = ucb::RememberAuthentication_NO
;
228 if (xSupplyAuthentication
.is())
231 xSupplyAuthentication
->getRememberPasswordModes(
232 eDefaultRememberMode
),
233 ePreferredRememberMode
,
234 eAlternateRememberMode
);
237 sal_Bool bCanUseSystemCredentials
;
238 sal_Bool bDefaultUseSystemCredentials
;
239 if (xSupplyAuthentication2
.is())
241 bCanUseSystemCredentials
242 = xSupplyAuthentication2
->canUseSystemCredentials(
243 bDefaultUseSystemCredentials
);
247 bCanUseSystemCredentials
= sal_False
;
248 bDefaultUseSystemCredentials
= sal_False
;
251 LoginErrorInfo aInfo
;
252 aInfo
.SetTitle(rRequest
.ServerName
);
253 aInfo
.SetServer(rRequest
.ServerName
);
254 if (rRequest
.HasAccount
)
255 aInfo
.SetAccount(rRequest
.Account
);
256 if (rRequest
.HasUserName
)
257 aInfo
.SetUserName(rRequest
.UserName
);
258 if (rRequest
.HasPassword
)
259 aInfo
.SetPassword(rRequest
.Password
);
260 aInfo
.SetErrorText(rRequest
.Diagnostic
);
262 aInfo
.SetCanRememberPassword(
263 ePreferredRememberMode
!= eAlternateRememberMode
);
264 aInfo
.SetIsRememberPassword(
265 ePreferredRememberMode
== eDefaultRememberMode
);
266 aInfo
.SetIsRememberPersistent(
267 ePreferredRememberMode
== ucb::RememberAuthentication_PERSISTENT
);
269 aInfo
.SetCanUseSystemCredentials(bCanUseSystemCredentials
);
270 aInfo
.SetIsUseSystemCredentials( bDefaultUseSystemCredentials
);
271 aInfo
.SetModifyAccount(rRequest
.HasAccount
272 && xSupplyAuthentication
.is()
273 && xSupplyAuthentication
->canSetAccount());
274 aInfo
.SetModifyUserName(rRequest
.HasUserName
275 && xSupplyAuthentication
.is()
276 && xSupplyAuthentication
->canSetUserName());
277 executeLoginDialog(pParent
,
279 rRequest
.HasRealm
? rRequest
.Realm
: rtl::OUString());
280 switch (aInfo
.GetResult())
282 case ERRCODE_BUTTON_OK
:
283 if (xSupplyAuthentication
.is())
285 if (xSupplyAuthentication
->canSetUserName())
286 xSupplyAuthentication
->setUserName(aInfo
.GetUserName());
287 if (xSupplyAuthentication
->canSetPassword())
288 xSupplyAuthentication
->setPassword(aInfo
.GetPassword());
290 if (ePreferredRememberMode
!= eAlternateRememberMode
)
292 // user had the choice.
293 if (aInfo
.GetIsRememberPassword())
294 xSupplyAuthentication
->setRememberPassword(
295 ePreferredRememberMode
);
297 xSupplyAuthentication
->setRememberPassword(
298 eAlternateRememberMode
);
302 // user had no choice.
303 xSupplyAuthentication
->setRememberPassword(
304 ePreferredRememberMode
);
307 if (rRequest
.HasRealm
)
309 if (xSupplyAuthentication
->canSetRealm())
310 xSupplyAuthentication
->setRealm(aInfo
.GetAccount());
312 else if (xSupplyAuthentication
->canSetAccount())
313 xSupplyAuthentication
->setAccount(aInfo
.GetAccount());
315 if ( xSupplyAuthentication2
.is() && bCanUseSystemCredentials
)
316 xSupplyAuthentication2
->setUseSystemCredentials(
317 aInfo
.GetIsUseSystemCredentials() );
319 xSupplyAuthentication
->select();
322 //////////////////////////
323 // Third, store credentials in password container.
325 if ( aInfo
.GetIsUseSystemCredentials() )
327 if (aInfo
.GetIsRememberPassword())
329 if (!aPwContainerHelper
.addRecord(
330 !rURL
.isEmpty() ? rURL
: rRequest
.ServerName
,
331 rtl::OUString(), // empty u/p -> sys creds
332 uno::Sequence
< rtl::OUString
>(),
334 ePreferredRememberMode
335 == ucb::RememberAuthentication_PERSISTENT
))
337 xSupplyAuthentication
->setRememberPassword(
338 ucb::RememberAuthentication_NO
);
341 else if (eAlternateRememberMode
342 == ucb::RememberAuthentication_SESSION
)
344 if (!aPwContainerHelper
.addRecord(
345 !rURL
.isEmpty() ? rURL
: rRequest
.ServerName
,
346 rtl::OUString(), // empty u/p -> sys creds
347 uno::Sequence
< rtl::OUString
>(),
349 false /* SESSION */))
351 xSupplyAuthentication
->setRememberPassword(
352 ucb::RememberAuthentication_NO
);
356 // Empty user name can not be valid:
357 else if (aInfo
.GetUserName().Len() != 0)
359 uno::Sequence
< rtl::OUString
>
360 aPassList(aInfo
.GetAccount().Len() == 0 ? 1 : 2);
361 aPassList
[0] = aInfo
.GetPassword();
362 if (aInfo
.GetAccount().Len() != 0)
363 aPassList
[1] = aInfo
.GetAccount();
365 if (aInfo
.GetIsRememberPassword())
367 if (!aPwContainerHelper
.addRecord(
368 !rURL
.isEmpty() ? rURL
: rRequest
.ServerName
,
372 ePreferredRememberMode
373 == ucb::RememberAuthentication_PERSISTENT
))
375 xSupplyAuthentication
->setRememberPassword(
376 ucb::RememberAuthentication_NO
);
379 else if (eAlternateRememberMode
380 == ucb::RememberAuthentication_SESSION
)
382 if (!aPwContainerHelper
.addRecord(
383 !rURL
.isEmpty() ? rURL
: rRequest
.ServerName
,
387 false /* SESSION */))
389 xSupplyAuthentication
->setRememberPassword(
390 ucb::RememberAuthentication_NO
);
396 case ERRCODE_BUTTON_RETRY
:
409 executeMasterPasswordDialog(
411 LoginErrorInfo
& rInfo
,
412 task::PasswordRequestMode nMode
)
413 SAL_THROW((uno::RuntimeException
))
415 rtl::OString aMaster
;
418 SolarMutexGuard aGuard
;
420 boost::scoped_ptr
< ResMgr
> xManager(ResMgr::CreateResMgr("uui"));
421 if( nMode
== task::PasswordRequestMode_PASSWORD_CREATE
)
423 boost::scoped_ptr
< MasterPasswordCreateDialog
> xDialog(
424 new MasterPasswordCreateDialog(pParent
, xManager
.get()));
425 rInfo
.SetResult(xDialog
->Execute()
426 == RET_OK
? ERRCODE_BUTTON_OK
: ERRCODE_BUTTON_CANCEL
);
427 aMaster
= rtl::OUStringToOString(
428 xDialog
->GetMasterPassword(), RTL_TEXTENCODING_UTF8
);
432 boost::scoped_ptr
< MasterPasswordDialog
> xDialog(
433 new MasterPasswordDialog(pParent
, nMode
, xManager
.get()));
434 rInfo
.SetResult(xDialog
->Execute()
435 == RET_OK
? ERRCODE_BUTTON_OK
: ERRCODE_BUTTON_CANCEL
);
436 aMaster
= rtl::OUStringToOString(
437 xDialog
->GetMasterPassword(), RTL_TEXTENCODING_UTF8
);
440 catch (std::bad_alloc
const &)
442 throw uno::RuntimeException(
443 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("out of memory")),
444 uno::Reference
< uno::XInterface
>());
447 sal_uInt8 aKey
[RTL_DIGEST_LENGTH_MD5
];
448 rtl_digest_PBKDF2(aKey
,
449 RTL_DIGEST_LENGTH_MD5
,
450 reinterpret_cast< sal_uInt8
const * >(aMaster
.getStr()),
452 reinterpret_cast< sal_uInt8
const * >(
453 "3B5509ABA6BC42D9A3A1F3DAD49E56A51"),
457 rtl::OUStringBuffer aBuffer
;
458 for (int i
= 0; i
< RTL_DIGEST_LENGTH_MD5
; ++i
)
460 aBuffer
.append(static_cast< sal_Unicode
>('a' + (aKey
[i
] >> 4)));
461 aBuffer
.append(static_cast< sal_Unicode
>('a' + (aKey
[i
] & 15)));
463 rInfo
.SetPassword(aBuffer
.makeStringAndClear());
467 handleMasterPasswordRequest_(
469 task::PasswordRequestMode nMode
,
470 uno::Sequence
< uno::Reference
< task::XInteractionContinuation
> > const &
472 SAL_THROW((uno::RuntimeException
))
474 uno::Reference
< task::XInteractionRetry
> xRetry
;
475 uno::Reference
< task::XInteractionAbort
> xAbort
;
476 uno::Reference
< ucb::XInteractionSupplyAuthentication
>
477 xSupplyAuthentication
;
478 getContinuations(rContinuations
, &xRetry
, &xAbort
, &xSupplyAuthentication
);
479 LoginErrorInfo aInfo
;
481 // in case of master password a hash code is returned
482 executeMasterPasswordDialog(pParent
, aInfo
, nMode
);
484 switch (aInfo
.GetResult())
486 case ERRCODE_BUTTON_OK
:
487 if (xSupplyAuthentication
.is())
489 if (xSupplyAuthentication
->canSetPassword())
490 xSupplyAuthentication
->setPassword(aInfo
.GetPassword());
491 xSupplyAuthentication
->select();
495 case ERRCODE_BUTTON_RETRY
:
508 executePasswordDialog(
510 LoginErrorInfo
& rInfo
,
511 task::PasswordRequestMode nMode
,
512 ::rtl::OUString aDocName
,
514 bool bIsPasswordToModify
,
515 bool bIsSimplePasswordRequest
)
516 SAL_THROW((uno::RuntimeException
))
520 SolarMutexGuard aGuard
;
522 boost::scoped_ptr
< ResMgr
> xManager(ResMgr::CreateResMgr("uui"));
523 if( nMode
== task::PasswordRequestMode_PASSWORD_CREATE
)
525 if (bIsSimplePasswordRequest
)
527 boost::scoped_ptr
< PasswordDialog
> pDialog(
528 new PasswordDialog( pParent
, nMode
, xManager
.get(), aDocName
,
529 bIsPasswordToModify
, bIsSimplePasswordRequest
) );
530 pDialog
->SetMinLen(0);
532 rInfo
.SetResult( pDialog
->Execute() == RET_OK
? ERRCODE_BUTTON_OK
: ERRCODE_BUTTON_CANCEL
);
533 rInfo
.SetPassword( pDialog
->GetPassword() );
537 const sal_uInt16 nMaxPasswdLen
= bMSCryptoMode
? 15 : 0; // 0 -> allow any length
539 VclAbstractDialogFactory
* pFact
= VclAbstractDialogFactory::Create();
540 AbstractPasswordToOpenModifyDialog
*pTmp
= pFact
->CreatePasswordToOpenModifyDialog( pParent
, 0, nMaxPasswdLen
, bIsPasswordToModify
);
541 boost::scoped_ptr
< AbstractPasswordToOpenModifyDialog
> pDialog( pTmp
);
543 rInfo
.SetResult( pDialog
->Execute() == RET_OK
? ERRCODE_BUTTON_OK
: ERRCODE_BUTTON_CANCEL
);
544 rInfo
.SetPassword( pDialog
->GetPasswordToOpen() );
545 rInfo
.SetPasswordToModify( pDialog
->GetPasswordToModify() );
546 rInfo
.SetRecommendToOpenReadonly( pDialog
->IsRecommendToOpenReadonly() );
549 else // enter password or reenter password
551 boost::scoped_ptr
< PasswordDialog
> pDialog(
552 new PasswordDialog( pParent
, nMode
, xManager
.get(), aDocName
,
553 bIsPasswordToModify
, bIsSimplePasswordRequest
) );
554 pDialog
->SetMinLen(0);
556 rInfo
.SetResult( pDialog
->Execute() == RET_OK
? ERRCODE_BUTTON_OK
: ERRCODE_BUTTON_CANCEL
);
557 rInfo
.SetPassword( bIsPasswordToModify
? String() : pDialog
->GetPassword() );
558 rInfo
.SetPasswordToModify( bIsPasswordToModify
? pDialog
->GetPassword() : String() );
561 catch (std::bad_alloc
const &)
563 throw uno::RuntimeException(
564 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("out of memory")),
565 uno::Reference
< uno::XInterface
>());
570 handlePasswordRequest_(
572 task::PasswordRequestMode nMode
,
573 uno::Sequence
< uno::Reference
< task::XInteractionContinuation
> > const &
575 ::rtl::OUString aDocumentName
,
577 bool bIsPasswordToModify
,
578 bool bIsSimplePasswordRequest
= false )
579 SAL_THROW((uno::RuntimeException
))
581 uno::Reference
< task::XInteractionRetry
> xRetry
;
582 uno::Reference
< task::XInteractionAbort
> xAbort
;
583 uno::Reference
< task::XInteractionPassword
> xPassword
;
584 uno::Reference
< task::XInteractionPassword2
> xPassword2
;
585 getContinuations(rContinuations
, &xRetry
, &xAbort
, &xPassword2
, &xPassword
);
587 if ( xPassword2
.is() && !xPassword
.is() )
588 xPassword
.set( xPassword2
, uno::UNO_QUERY_THROW
);
590 LoginErrorInfo aInfo
;
592 executePasswordDialog( pParent
, aInfo
, nMode
,
593 aDocumentName
, bMSCryptoMode
, bIsPasswordToModify
, bIsSimplePasswordRequest
);
595 switch (aInfo
.GetResult())
597 case ERRCODE_BUTTON_OK
:
598 OSL_ENSURE( !bIsPasswordToModify
|| xPassword2
.is(), "PasswordToModify is requested, but there is no Interaction!" );
603 xPassword2
->setPasswordToModify( aInfo
.GetPasswordToModify() );
604 xPassword2
->setRecommendReadOnly( aInfo
.IsRecommendToOpenReadonly() );
607 xPassword
->setPassword(aInfo
.GetPassword());
612 case ERRCODE_BUTTON_RETRY
:
627 UUIInteractionHelper::handleAuthenticationRequest(
628 uno::Reference
< task::XInteractionRequest
> const & rRequest
)
629 SAL_THROW((uno::RuntimeException
))
631 uno::Any
aAnyRequest(rRequest
->getRequest());
633 ucb::URLAuthenticationRequest aURLAuthenticationRequest
;
634 if (aAnyRequest
>>= aURLAuthenticationRequest
)
636 handleAuthenticationRequest_(getParentProperty(),
637 getInteractionHandler(),
639 aURLAuthenticationRequest
,
640 rRequest
->getContinuations(),
641 aURLAuthenticationRequest
.URL
);
645 ucb::AuthenticationRequest aAuthenticationRequest
;
646 if (aAnyRequest
>>= aAuthenticationRequest
)
648 handleAuthenticationRequest_(getParentProperty(),
649 getInteractionHandler(),
651 aAuthenticationRequest
,
652 rRequest
->getContinuations(),
660 UUIInteractionHelper::handleMasterPasswordRequest(
661 uno::Reference
< task::XInteractionRequest
> const & rRequest
)
662 SAL_THROW((uno::RuntimeException
))
664 uno::Any
aAnyRequest(rRequest
->getRequest());
666 task::MasterPasswordRequest aMasterPasswordRequest
;
667 if (aAnyRequest
>>= aMasterPasswordRequest
)
669 handleMasterPasswordRequest_(getParentProperty(),
670 aMasterPasswordRequest
.Mode
,
671 rRequest
->getContinuations());
678 UUIInteractionHelper::handlePasswordRequest(
679 uno::Reference
< task::XInteractionRequest
> const & rRequest
)
680 SAL_THROW((uno::RuntimeException
))
682 // parameters to be filled for the call to handlePasswordRequest_
683 Window
* pParent
= getParentProperty();
684 task::PasswordRequestMode nMode
= task::PasswordRequestMode_PASSWORD_ENTER
;
685 uno::Sequence
< uno::Reference
< task::XInteractionContinuation
> > const & rContinuations
= rRequest
->getContinuations();
686 ::rtl::OUString aDocumentName
;
687 bool bMSCryptoMode
= false;
688 bool bIsPasswordToModify
= false;
690 bool bDoHandleRequest
= false;
692 uno::Any
aAnyRequest(rRequest
->getRequest());
694 task::DocumentPasswordRequest2 aDocumentPasswordRequest2
;
695 if (!bDoHandleRequest
&& (aAnyRequest
>>= aDocumentPasswordRequest2
))
697 nMode
= aDocumentPasswordRequest2
.Mode
;
698 aDocumentName
= aDocumentPasswordRequest2
.Name
;
699 OSL_ENSURE( bMSCryptoMode
== false, "bMSCryptoMode should be false" );
700 bIsPasswordToModify
= aDocumentPasswordRequest2
.IsRequestPasswordToModify
;
702 bDoHandleRequest
= true;
705 task::DocumentPasswordRequest aDocumentPasswordRequest
;
706 if (!bDoHandleRequest
&& (aAnyRequest
>>= aDocumentPasswordRequest
))
708 nMode
= aDocumentPasswordRequest
.Mode
;
709 aDocumentName
= aDocumentPasswordRequest
.Name
;
710 OSL_ENSURE( bMSCryptoMode
== false, "bMSCryptoMode should be false" );
711 OSL_ENSURE( bIsPasswordToModify
== false, "bIsPasswordToModify should be false" );
713 bDoHandleRequest
= true;
716 task::DocumentMSPasswordRequest2 aDocumentMSPasswordRequest2
;
717 if (!bDoHandleRequest
&& (aAnyRequest
>>= aDocumentMSPasswordRequest2
))
719 nMode
= aDocumentMSPasswordRequest2
.Mode
;
720 aDocumentName
= aDocumentMSPasswordRequest2
.Name
;
721 bMSCryptoMode
= true;
722 bIsPasswordToModify
= aDocumentMSPasswordRequest2
.IsRequestPasswordToModify
;
724 bDoHandleRequest
= true;
727 task::DocumentMSPasswordRequest aDocumentMSPasswordRequest
;
728 if (!bDoHandleRequest
&& (aAnyRequest
>>= aDocumentMSPasswordRequest
))
730 nMode
= aDocumentMSPasswordRequest
.Mode
;
731 aDocumentName
= aDocumentMSPasswordRequest
.Name
;
732 bMSCryptoMode
= true;
733 OSL_ENSURE( bIsPasswordToModify
== false, "bIsPasswordToModify should be false" );
735 bDoHandleRequest
= true;
738 if (bDoHandleRequest
)
740 handlePasswordRequest_( pParent
, nMode
, rContinuations
,
741 aDocumentName
, bMSCryptoMode
, bIsPasswordToModify
);
745 task::PasswordRequest aPasswordRequest
;
746 if( aAnyRequest
>>= aPasswordRequest
)
748 handlePasswordRequest_(getParentProperty(),
749 aPasswordRequest
.Mode
,
750 rRequest
->getContinuations(),
752 false /* bool bMSCryptoMode */,
753 false /* bool bIsPasswordToModify */,
754 true /* bool bIsSimplePasswordRequest */ );
761 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */