summaryrefslogtreecommitdiff
path: root/uui
diff options
context:
space:
mode:
authorobo <obo@openoffice.org>2010-06-18 13:31:23 +0200
committerobo <obo@openoffice.org>2010-06-18 13:31:23 +0200
commit1049a5b33e6c2b40c4557bc6932956cc2431b03f (patch)
treed89910dcff61363f801790d9a6541275baaebf7e /uui
parent9827d16734c9e1984a0fd7aab43209df07d992ff (diff)
parent86307827b3b671154a44b552e2f8a8bb94791442 (diff)
CWS-TOOLING: integrate CWS tl79
Diffstat (limited to 'uui')
-rwxr-xr-xuui/source/iahndl-authentication.cxx1502
-rwxr-xr-xuui/source/ids.hrc30
-rwxr-xr-x[-rw-r--r--]uui/source/logindlg.cxx164
-rwxr-xr-x[-rw-r--r--]uui/source/logindlg.hrc30
-rwxr-xr-x[-rw-r--r--]uui/source/logindlg.hxx50
-rwxr-xr-x[-rw-r--r--]uui/source/logindlg.src188
-rwxr-xr-xuui/source/loginerr.hxx2
7 files changed, 967 insertions, 999 deletions
diff --git a/uui/source/iahndl-authentication.cxx b/uui/source/iahndl-authentication.cxx
index deea16ccad98..91aa3fed73a6 100755
--- a/uui/source/iahndl-authentication.cxx
+++ b/uui/source/iahndl-authentication.cxx
@@ -1,751 +1,751 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-#include "com/sun/star/task/DocumentPasswordRequest.hpp"
-#include "com/sun/star/task/DocumentPasswordRequest2.hpp"
-#include "com/sun/star/task/DocumentMSPasswordRequest.hpp"
-#include "com/sun/star/task/DocumentMSPasswordRequest2.hpp"
-#include "com/sun/star/task/MasterPasswordRequest.hpp"
-#include "com/sun/star/task/XInteractionAbort.hpp"
-#include "com/sun/star/task/XInteractionPassword.hpp"
-#include "com/sun/star/task/XInteractionPassword2.hpp"
-#include "com/sun/star/task/XInteractionRetry.hpp"
-#include "com/sun/star/ucb/XInteractionSupplyAuthentication2.hpp"
-#include "com/sun/star/ucb/URLAuthenticationRequest.hpp"
-
-#include "osl/diagnose.h"
-#include "rtl/digest.h"
-#include "vos/mutex.hxx"
-#include "tools/errcode.hxx"
-#include "vcl/msgbox.hxx"
-#include "vcl/abstdlg.hxx"
-#include "vcl/svapp.hxx"
-
-#include "ids.hrc"
-#include "getcontinuations.hxx"
-#include "passwordcontainer.hxx"
-#include "loginerr.hxx"
-#include "logindlg.hxx"
-#include "masterpasscrtdlg.hxx"
-#include "masterpassworddlg.hxx"
-#include "passcrtdlg.hxx"
-#include "passworddlg.hxx"
-
-#include "iahndl.hxx"
-
-using namespace com::sun::star;
-
-namespace {
-
-void
-executeLoginDialog(
- Window * pParent,
- LoginErrorInfo & rInfo,
- rtl::OUString const & rRealm)
- SAL_THROW((uno::RuntimeException))
-{
- try
- {
- vos::OGuard aGuard(Application::GetSolarMutex());
-
- bool bAccount = (rInfo.GetFlags() & LOGINERROR_FLAG_MODIFY_ACCOUNT) != 0;
- bool bSavePassword = rInfo.GetCanRememberPassword();
- bool bCanUseSysCreds = rInfo.GetCanUseSystemCredentials();
-
- sal_uInt16 nFlags = 0;
- if (rInfo.GetPath().Len() == 0)
- nFlags |= LF_NO_PATH;
- if (rInfo.GetErrorText().Len() == 0)
- nFlags |= LF_NO_ERRORTEXT;
- if (!bAccount)
- nFlags |= LF_NO_ACCOUNT;
- if (!(rInfo.GetFlags() & LOGINERROR_FLAG_MODIFY_USER_NAME))
- nFlags |= LF_USERNAME_READONLY;
-
- if (!bSavePassword)
- nFlags |= LF_NO_SAVEPASSWORD;
-
- if (!bCanUseSysCreds)
- nFlags |= LF_NO_USESYSCREDS;
-
- std::auto_ptr< ResMgr > xManager( ResMgr::CreateResMgr(CREATEVERSIONRESMGR_NAME(uui)));
- UniString aRealm(rRealm);
- std::auto_ptr< LoginDialog > xDialog(
- new LoginDialog( pParent, nFlags, rInfo.GetServer(), &aRealm, xManager.get()));
- if (rInfo.GetErrorText().Len() != 0)
- xDialog->SetErrorText(rInfo.GetErrorText());
- xDialog->SetName(rInfo.GetUserName());
- if (bAccount)
- xDialog->ClearAccount();
- else
- xDialog->ClearPassword();
- xDialog->SetPassword(rInfo.GetPassword());
-
- if (bSavePassword)
- {
- xDialog->SetSavePasswordText(
- ResId(rInfo.GetIsRememberPersistent()
- ? RID_SAVE_PASSWORD
- : RID_KEEP_PASSWORD,
- *xManager.get()));
-
- xDialog->SetSavePassword(rInfo.GetIsRememberPassword());
- }
-
- if ( bCanUseSysCreds )
- xDialog->SetUseSystemCredentials( rInfo.GetIsUseSystemCredentials() );
-
- rInfo.SetResult(xDialog->Execute() == RET_OK ? ERRCODE_BUTTON_OK :
- ERRCODE_BUTTON_CANCEL);
- rInfo.SetUserName(xDialog->GetName());
- rInfo.SetPassword(xDialog->GetPassword());
- rInfo.SetAccount(xDialog->GetAccount());
- rInfo.SetIsRememberPassword(xDialog->IsSavePassword());
-
- if ( bCanUseSysCreds )
- rInfo.SetIsUseSystemCredentials( xDialog->IsUseSystemCredentials() );
- }
- catch (std::bad_alloc const &)
- {
- throw uno::RuntimeException(
- rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("out of memory")),
- uno::Reference< uno::XInterface >());
- }
-}
-
-void getRememberModes(
- uno::Sequence< ucb::RememberAuthentication > const & rRememberModes,
- ucb::RememberAuthentication & rPreferredMode,
- ucb::RememberAuthentication & rAlternateMode )
-{
- sal_Int32 nCount = rRememberModes.getLength();
- OSL_ENSURE( (nCount > 0) && (nCount < 4),
- "ucb::RememberAuthentication sequence size mismatch!" );
- if ( nCount == 1 )
- {
- rPreferredMode = rAlternateMode = rRememberModes[ 0 ];
- return;
- }
- else
- {
- //bool bHasRememberModeNo = false;
- bool bHasRememberModeSession = false;
- bool bHasRememberModePersistent = false;
-
- for (sal_Int32 i = 0; i < nCount; ++i)
- {
- switch ( rRememberModes[i] )
- {
- case ucb::RememberAuthentication_NO:
- //bHasRememberModeNo = true;
- break;
- case ucb::RememberAuthentication_SESSION:
- bHasRememberModeSession = true;
- break;
- case ucb::RememberAuthentication_PERSISTENT:
- bHasRememberModePersistent = true;
- break;
- default:
- OSL_TRACE( "Unsupported RememberAuthentication value" );
- break;
- }
- }
-
- if (bHasRememberModePersistent)
- {
- rPreferredMode = ucb::RememberAuthentication_PERSISTENT;
- if (bHasRememberModeSession)
- rAlternateMode = ucb::RememberAuthentication_SESSION;
- else
- rAlternateMode = ucb::RememberAuthentication_NO;
- }
- else
- {
- rPreferredMode = ucb::RememberAuthentication_SESSION;
- rAlternateMode = ucb::RememberAuthentication_NO;
- }
- }
-}
-
-void
-handleAuthenticationRequest_(
- Window * pParent,
- uno::Reference< task::XInteractionHandler > const & xIH,
- uno::Reference< lang::XMultiServiceFactory > const & xServiceFactory,
- ucb::AuthenticationRequest const & rRequest,
- uno::Sequence< uno::Reference< task::XInteractionContinuation > > const &
- rContinuations,
- const rtl::OUString & rURL)
- SAL_THROW((uno::RuntimeException))
-{
- uno::Reference< task::XInteractionRetry > xRetry;
- uno::Reference< task::XInteractionAbort > xAbort;
- uno::Reference< ucb::XInteractionSupplyAuthentication >
- xSupplyAuthentication;
- uno::Reference< ucb::XInteractionSupplyAuthentication2 >
- xSupplyAuthentication2;
- getContinuations(rContinuations, &xRetry, &xAbort, &xSupplyAuthentication);
- if (xSupplyAuthentication.is())
- xSupplyAuthentication2.set(xSupplyAuthentication, uno::UNO_QUERY);
-
- //////////////////////////
- // First, try to obtain credentials from password container service.
- uui::PasswordContainerHelper aPwContainerHelper(xServiceFactory);
- if (aPwContainerHelper.handleAuthenticationRequest(rRequest,
- xSupplyAuthentication,
- rURL,
- xIH))
- {
- xSupplyAuthentication->select();
- return;
- }
-
- //////////////////////////
- // Second, try to obtain credentials from user via password dialog.
- ucb::RememberAuthentication eDefaultRememberMode
- = ucb::RememberAuthentication_SESSION;
- ucb::RememberAuthentication ePreferredRememberMode
- = eDefaultRememberMode;
- ucb::RememberAuthentication eAlternateRememberMode
- = ucb::RememberAuthentication_NO;
-
- if (xSupplyAuthentication.is())
- {
- getRememberModes(
- xSupplyAuthentication->getRememberPasswordModes(
- eDefaultRememberMode),
- ePreferredRememberMode,
- eAlternateRememberMode);
- }
-
- sal_Bool bCanUseSystemCredentials;
- sal_Bool bDefaultUseSystemCredentials;
- if (xSupplyAuthentication2.is())
- {
- bCanUseSystemCredentials
- = xSupplyAuthentication2->canUseSystemCredentials(
- bDefaultUseSystemCredentials);
- }
- else
- {
- bCanUseSystemCredentials = sal_False;
- bDefaultUseSystemCredentials = sal_False;
- }
-
- LoginErrorInfo aInfo;
- aInfo.SetTitle(rRequest.ServerName);
- aInfo.SetServer(rRequest.ServerName);
- if (rRequest.HasAccount)
- aInfo.SetAccount(rRequest.Account);
- if (rRequest.HasUserName)
- aInfo.SetUserName(rRequest.UserName);
- if (rRequest.HasPassword)
- aInfo.SetPassword(rRequest.Password);
- aInfo.SetErrorText(rRequest.Diagnostic);
-
- aInfo.SetCanRememberPassword(
- ePreferredRememberMode != eAlternateRememberMode);
- aInfo.SetIsRememberPassword(
- eDefaultRememberMode != ucb::RememberAuthentication_NO);
- aInfo.SetIsRememberPersistent(
- ePreferredRememberMode == ucb::RememberAuthentication_PERSISTENT);
-
- aInfo.SetCanUseSystemCredentials(bCanUseSystemCredentials);
- aInfo.SetIsUseSystemCredentials( bDefaultUseSystemCredentials );
- aInfo.SetModifyAccount(rRequest.HasAccount
- && xSupplyAuthentication.is()
- && xSupplyAuthentication->canSetAccount());
- aInfo.SetModifyUserName(rRequest.HasUserName
- && xSupplyAuthentication.is()
- && xSupplyAuthentication->canSetUserName());
- executeLoginDialog(pParent,
- aInfo,
- rRequest.HasRealm ? rRequest.Realm : rtl::OUString());
- switch (aInfo.GetResult())
- {
- case ERRCODE_BUTTON_OK:
- if (xSupplyAuthentication.is())
- {
- if (xSupplyAuthentication->canSetUserName())
- xSupplyAuthentication->setUserName(aInfo.GetUserName());
- if (xSupplyAuthentication->canSetPassword())
- xSupplyAuthentication->setPassword(aInfo.GetPassword());
-
- if (ePreferredRememberMode != eAlternateRememberMode)
- {
- // user had te choice.
- if (aInfo.GetIsRememberPassword())
- xSupplyAuthentication->setRememberPassword(
- ePreferredRememberMode);
- else
- xSupplyAuthentication->setRememberPassword(
- eAlternateRememberMode);
- }
- else
- {
- // user had no choice.
- xSupplyAuthentication->setRememberPassword(
- ePreferredRememberMode);
- }
-
- if (rRequest.HasRealm)
- {
- if (xSupplyAuthentication->canSetRealm())
- xSupplyAuthentication->setRealm(aInfo.GetAccount());
- }
- else if (xSupplyAuthentication->canSetAccount())
- xSupplyAuthentication->setAccount(aInfo.GetAccount());
-
- if ( xSupplyAuthentication2.is() && bCanUseSystemCredentials )
- xSupplyAuthentication2->setUseSystemCredentials(
- aInfo.GetIsUseSystemCredentials() );
-
- xSupplyAuthentication->select();
- }
-
- //////////////////////////
- // Third, store credentials in password container.
-
- if ( aInfo.GetIsUseSystemCredentials() )
- {
- if (aInfo.GetIsRememberPassword())
- {
- if (!aPwContainerHelper.addRecord(
- rURL.getLength() ? rURL : rRequest.ServerName,
- rtl::OUString(), // empty u/p -> sys creds
- uno::Sequence< rtl::OUString >(),
- xIH,
- ePreferredRememberMode
- == ucb::RememberAuthentication_PERSISTENT))
- {
- xSupplyAuthentication->setRememberPassword(
- ucb::RememberAuthentication_NO);
- }
- }
- else if (eAlternateRememberMode
- == ucb::RememberAuthentication_SESSION)
- {
- if (!aPwContainerHelper.addRecord(
- rURL.getLength() ? rURL : rRequest.ServerName,
- rtl::OUString(), // empty u/p -> sys creds
- uno::Sequence< rtl::OUString >(),
- xIH,
- false /* SESSION */))
- {
- xSupplyAuthentication->setRememberPassword(
- ucb::RememberAuthentication_NO);
- }
- }
- }
- // Empty user name can not be valid:
- else if (aInfo.GetUserName().Len() != 0)
- {
- uno::Sequence< rtl::OUString >
- aPassList(aInfo.GetAccount().Len() == 0 ? 1 : 2);
- aPassList[0] = aInfo.GetPassword();
- if (aInfo.GetAccount().Len() != 0)
- aPassList[1] = aInfo.GetAccount();
-
- if (aInfo.GetIsRememberPassword())
- {
- if (!aPwContainerHelper.addRecord(
- rURL.getLength() ? rURL : rRequest.ServerName,
- aInfo.GetUserName(),
- aPassList,
- xIH,
- ePreferredRememberMode
- == ucb::RememberAuthentication_PERSISTENT))
- {
- xSupplyAuthentication->setRememberPassword(
- ucb::RememberAuthentication_NO);
- }
- }
- else if (eAlternateRememberMode
- == ucb::RememberAuthentication_SESSION)
- {
- if (!aPwContainerHelper.addRecord(
- rURL.getLength() ? rURL : rRequest.ServerName,
- aInfo.GetUserName(),
- aPassList,
- xIH,
- false /* SESSION */))
- {
- xSupplyAuthentication->setRememberPassword(
- ucb::RememberAuthentication_NO);
- }
- }
- }
- break;
-
- case ERRCODE_BUTTON_RETRY:
- if (xRetry.is())
- xRetry->select();
- break;
-
- default:
- if (xAbort.is())
- xAbort->select();
- break;
- }
-}
-
-void
-executeMasterPasswordDialog(
- Window * pParent,
- LoginErrorInfo & rInfo,
- task::PasswordRequestMode nMode)
- SAL_THROW((uno::RuntimeException))
-{
- rtl::OString aMaster;
- try
- {
- vos::OGuard aGuard(Application::GetSolarMutex());
-
- std::auto_ptr< ResMgr > xManager(
- ResMgr::CreateResMgr(CREATEVERSIONRESMGR_NAME(uui)));
- if( nMode == task::PasswordRequestMode_PASSWORD_CREATE )
- {
- std::auto_ptr< MasterPasswordCreateDialog > xDialog(
- new MasterPasswordCreateDialog(pParent, xManager.get()));
- rInfo.SetResult(xDialog->Execute()
- == RET_OK ? ERRCODE_BUTTON_OK : ERRCODE_BUTTON_CANCEL);
- aMaster = rtl::OUStringToOString(
- xDialog->GetMasterPassword(), RTL_TEXTENCODING_UTF8);
- }
- else
- {
- std::auto_ptr< MasterPasswordDialog > xDialog(
- new MasterPasswordDialog(pParent, nMode, xManager.get()));
- rInfo.SetResult(xDialog->Execute()
- == RET_OK ? ERRCODE_BUTTON_OK : ERRCODE_BUTTON_CANCEL);
- aMaster = rtl::OUStringToOString(
- xDialog->GetMasterPassword(), RTL_TEXTENCODING_UTF8);
- }
- }
- catch (std::bad_alloc const &)
- {
- throw uno::RuntimeException(
- rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("out of memory")),
- uno::Reference< uno::XInterface >());
- }
-
- sal_uInt8 aKey[RTL_DIGEST_LENGTH_MD5];
- rtl_digest_PBKDF2(aKey,
- RTL_DIGEST_LENGTH_MD5,
- reinterpret_cast< sal_uInt8 const * >(aMaster.getStr()),
- aMaster.getLength(),
- reinterpret_cast< sal_uInt8 const * >(
- "3B5509ABA6BC42D9A3A1F3DAD49E56A51"),
- 32,
- 1000);
-
- rtl::OUStringBuffer aBuffer;
- for (int i = 0; i < RTL_DIGEST_LENGTH_MD5; ++i)
- {
- aBuffer.append(static_cast< sal_Unicode >('a' + (aKey[i] >> 4)));
- aBuffer.append(static_cast< sal_Unicode >('a' + (aKey[i] & 15)));
- }
- rInfo.SetPassword(aBuffer.makeStringAndClear());
-}
-
-void
-handleMasterPasswordRequest_(
- Window * pParent,
- task::PasswordRequestMode nMode,
- uno::Sequence< uno::Reference< task::XInteractionContinuation > > const &
- rContinuations)
- SAL_THROW((uno::RuntimeException))
-{
- uno::Reference< task::XInteractionRetry > xRetry;
- uno::Reference< task::XInteractionAbort > xAbort;
- uno::Reference< ucb::XInteractionSupplyAuthentication >
- xSupplyAuthentication;
- getContinuations(rContinuations, &xRetry, &xAbort, &xSupplyAuthentication);
- LoginErrorInfo aInfo;
-
- // in case of master password a hash code is returned
- executeMasterPasswordDialog(pParent, aInfo, nMode);
-
- switch (aInfo.GetResult())
- {
- case ERRCODE_BUTTON_OK:
- if (xSupplyAuthentication.is())
- {
- if (xSupplyAuthentication->canSetPassword())
- xSupplyAuthentication->setPassword(aInfo.GetPassword());
- xSupplyAuthentication->select();
- }
- break;
-
- case ERRCODE_BUTTON_RETRY:
- if (xRetry.is())
- xRetry->select();
- break;
-
- default:
- if (xAbort.is())
- xAbort->select();
- break;
- }
-}
-
-void
-executePasswordDialog(
- Window * pParent,
- LoginErrorInfo & rInfo,
- task::PasswordRequestMode nMode,
- ::rtl::OUString aDocName,
- bool bMSCryptoMode,
- bool bIsPasswordToModify )
- SAL_THROW((uno::RuntimeException))
-{
- try
- {
- vos::OGuard aGuard(Application::GetSolarMutex());
-
- std::auto_ptr< ResMgr > xManager(
- ResMgr::CreateResMgr(CREATEVERSIONRESMGR_NAME(uui)));
- if( nMode == task::PasswordRequestMode_PASSWORD_CREATE )
- {
- const sal_uInt16 nMaxPasswdLen = bMSCryptoMode ? 15 : 0; // 0 -> allow any length
-
- VclAbstractDialogFactory * pFact = VclAbstractDialogFactory::Create();
- AbstractPasswordToOpenModifyDialog *pTmp = pFact->CreatePasswordToOpenModifyDialog( pParent, 0, nMaxPasswdLen, bIsPasswordToModify );
- std::auto_ptr< AbstractPasswordToOpenModifyDialog > pDialog( pTmp );
-
- rInfo.SetResult( pDialog->Execute() == RET_OK ? ERRCODE_BUTTON_OK : ERRCODE_BUTTON_CANCEL );
- rInfo.SetPassword( pDialog->GetPasswordToOpen() );
- rInfo.SetPasswordToModify( pDialog->GetPasswordToModify() );
- rInfo.SetRecommendToOpenReadonly( pDialog->IsRecommendToOpenReadonly() );
- }
- else
- {
- std::auto_ptr< PasswordDialog > pDialog(
- new PasswordDialog( pParent, nMode, xManager.get(), aDocName, bIsPasswordToModify ) );
-
- rInfo.SetResult( pDialog->Execute() == RET_OK ? ERRCODE_BUTTON_OK : ERRCODE_BUTTON_CANCEL );
- rInfo.SetPassword( bIsPasswordToModify ? String() : pDialog->GetPassword() );
- rInfo.SetPasswordToModify( bIsPasswordToModify ? pDialog->GetPassword() : String() );
- }
- }
- catch (std::bad_alloc const &)
- {
- throw uno::RuntimeException(
- rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("out of memory")),
- uno::Reference< uno::XInterface>());
- }
-}
-
-void
-handlePasswordRequest_(
- Window * pParent,
- task::PasswordRequestMode nMode,
- uno::Sequence< uno::Reference< task::XInteractionContinuation > > const &
- rContinuations,
- ::rtl::OUString aDocumentName,
- bool bMSCryptoMode,
- bool bIsPasswordToModify )
- SAL_THROW((uno::RuntimeException))
-{
- uno::Reference< task::XInteractionRetry > xRetry;
- uno::Reference< task::XInteractionAbort > xAbort;
- uno::Reference< task::XInteractionPassword > xPassword;
- uno::Reference< task::XInteractionPassword2 > xPassword2;
- getContinuations(rContinuations, &xRetry, &xAbort, &xPassword2, &xPassword);
-
- if ( xPassword2.is() && !xPassword.is() )
- xPassword.set( xPassword2, uno::UNO_QUERY_THROW );
-
- LoginErrorInfo aInfo;
-
- executePasswordDialog( pParent, aInfo, nMode,
- aDocumentName, bMSCryptoMode, bIsPasswordToModify );
-
- switch (aInfo.GetResult())
- {
- case ERRCODE_BUTTON_OK:
- OSL_ENSURE( !bIsPasswordToModify || xPassword2.is(), "PasswordToModify is requested, but there is no Interaction!" );
- if (xPassword.is())
- {
- if (xPassword2.is())
- {
- xPassword2->setPasswordToModify( aInfo.GetPasswordToModify() );
- xPassword2->setRecommendReadOnly( aInfo.IsRecommendToOpenReadonly() );
- }
-
- xPassword->setPassword(aInfo.GetPassword());
- xPassword->select();
- }
- break;
-
- case ERRCODE_BUTTON_RETRY:
- if (xRetry.is())
- xRetry->select();
- break;
-
- default:
- if (xAbort.is())
- xAbort->select();
- break;
- }
-}
-
-} // namespace
-
-bool
-UUIInteractionHelper::handleAuthenticationRequest(
- uno::Reference< task::XInteractionRequest > const & rRequest)
- SAL_THROW((uno::RuntimeException))
-{
- uno::Any aAnyRequest(rRequest->getRequest());
-
- ucb::URLAuthenticationRequest aURLAuthenticationRequest;
- if (aAnyRequest >>= aURLAuthenticationRequest)
- {
- handleAuthenticationRequest_(getParentProperty(),
- getInteractionHandler(),
- m_xServiceFactory,
- aURLAuthenticationRequest,
- rRequest->getContinuations(),
- aURLAuthenticationRequest.URL);
- return true;
- }
-
- ucb::AuthenticationRequest aAuthenticationRequest;
- if (aAnyRequest >>= aAuthenticationRequest)
- {
- handleAuthenticationRequest_(getParentProperty(),
- getInteractionHandler(),
- m_xServiceFactory,
- aAuthenticationRequest,
- rRequest->getContinuations(),
- rtl::OUString());
- return true;
- }
- return false;
-}
-
-bool
-UUIInteractionHelper::handleMasterPasswordRequest(
- uno::Reference< task::XInteractionRequest > const & rRequest)
- SAL_THROW((uno::RuntimeException))
-{
- uno::Any aAnyRequest(rRequest->getRequest());
-
- task::MasterPasswordRequest aMasterPasswordRequest;
- if (aAnyRequest >>= aMasterPasswordRequest)
- {
- handleMasterPasswordRequest_(getParentProperty(),
- aMasterPasswordRequest.Mode,
- rRequest->getContinuations());
- return true;
- }
- return false;
-}
-
-bool
-UUIInteractionHelper::handlePasswordRequest(
- uno::Reference< task::XInteractionRequest > const & rRequest)
- SAL_THROW((uno::RuntimeException))
-{
- // parameters to be filled for the call to handlePasswordRequest_
- Window * pParent = getParentProperty();
- task::PasswordRequestMode nMode = task::PasswordRequestMode_PASSWORD_ENTER;
- uno::Sequence< uno::Reference< task::XInteractionContinuation > > const & rContinuations = rRequest->getContinuations();
- ::rtl::OUString aDocumentName;
- bool bMSCryptoMode = false;
- bool bIsPasswordToModify = false;
-
- bool bDoHandleRequest = false;
-
- uno::Any aAnyRequest(rRequest->getRequest());
-
- task::DocumentPasswordRequest2 aDocumentPasswordRequest2;
- if (!bDoHandleRequest && (aAnyRequest >>= aDocumentPasswordRequest2))
- {
- nMode = aDocumentPasswordRequest2.Mode;
- aDocumentName = aDocumentPasswordRequest2.Name;
- OSL_ENSURE( bMSCryptoMode == false, "bMSCryptoMode should be false" );
- bIsPasswordToModify = aDocumentPasswordRequest2.IsRequestPasswordToModify;
-
- bDoHandleRequest = true;
- }
-
- task::DocumentPasswordRequest aDocumentPasswordRequest;
- if (!bDoHandleRequest && (aAnyRequest >>= aDocumentPasswordRequest))
- {
- nMode = aDocumentPasswordRequest.Mode;
- aDocumentName = aDocumentPasswordRequest.Name;
- OSL_ENSURE( bMSCryptoMode == false, "bMSCryptoMode should be false" );
- OSL_ENSURE( bIsPasswordToModify == false, "bIsPasswordToModify should be false" );
-
- bDoHandleRequest = true;
- }
-
- task::DocumentMSPasswordRequest2 aDocumentMSPasswordRequest2;
- if (!bDoHandleRequest && (aAnyRequest >>= aDocumentMSPasswordRequest2))
- {
- nMode = aDocumentMSPasswordRequest2.Mode;
- aDocumentName = aDocumentMSPasswordRequest2.Name;
- bMSCryptoMode = true;
- bIsPasswordToModify = aDocumentMSPasswordRequest2.IsRequestPasswordToModify;
-
- bDoHandleRequest = true;
- }
-
- task::DocumentMSPasswordRequest aDocumentMSPasswordRequest;
- if (!bDoHandleRequest && (aAnyRequest >>= aDocumentMSPasswordRequest))
- {
- nMode = aDocumentMSPasswordRequest.Mode;
- aDocumentName = aDocumentMSPasswordRequest.Name;
- bMSCryptoMode = true;
- OSL_ENSURE( bIsPasswordToModify == false, "bIsPasswordToModify should be false" );
-
- bDoHandleRequest = true;
- }
-
- if (bDoHandleRequest)
- {
- handlePasswordRequest_( pParent, nMode, rContinuations,
- aDocumentName, bMSCryptoMode, bIsPasswordToModify );
- return true;
- }
-
- task::PasswordRequest aPasswordRequest;
- if( aAnyRequest >>= aPasswordRequest )
- {
- handlePasswordRequest_(getParentProperty(),
- aPasswordRequest.Mode,
- rRequest->getContinuations(),
- rtl::OUString(),
- false /* bool bMSCryptoMode */);
- return true;
- }
-
- return false;
-}
-
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "com/sun/star/task/DocumentPasswordRequest.hpp"
+#include "com/sun/star/task/DocumentPasswordRequest2.hpp"
+#include "com/sun/star/task/DocumentMSPasswordRequest.hpp"
+#include "com/sun/star/task/DocumentMSPasswordRequest2.hpp"
+#include "com/sun/star/task/MasterPasswordRequest.hpp"
+#include "com/sun/star/task/XInteractionAbort.hpp"
+#include "com/sun/star/task/XInteractionPassword.hpp"
+#include "com/sun/star/task/XInteractionPassword2.hpp"
+#include "com/sun/star/task/XInteractionRetry.hpp"
+#include "com/sun/star/ucb/XInteractionSupplyAuthentication2.hpp"
+#include "com/sun/star/ucb/URLAuthenticationRequest.hpp"
+
+#include "osl/diagnose.h"
+#include "rtl/digest.h"
+#include "vos/mutex.hxx"
+#include "tools/errcode.hxx"
+#include "vcl/msgbox.hxx"
+#include "vcl/abstdlg.hxx"
+#include "vcl/svapp.hxx"
+
+#include "ids.hrc"
+#include "getcontinuations.hxx"
+#include "passwordcontainer.hxx"
+#include "loginerr.hxx"
+#include "logindlg.hxx"
+#include "masterpasscrtdlg.hxx"
+#include "masterpassworddlg.hxx"
+#include "passcrtdlg.hxx"
+#include "passworddlg.hxx"
+
+#include "iahndl.hxx"
+
+using namespace com::sun::star;
+
+namespace {
+
+void
+executeLoginDialog(
+ Window * pParent,
+ LoginErrorInfo & rInfo,
+ rtl::OUString const & rRealm)
+ SAL_THROW((uno::RuntimeException))
+{
+ try
+ {
+ vos::OGuard aGuard(Application::GetSolarMutex());
+
+ bool bAccount = (rInfo.GetFlags() & LOGINERROR_FLAG_MODIFY_ACCOUNT) != 0;
+ bool bSavePassword = rInfo.GetCanRememberPassword();
+ bool bCanUseSysCreds = rInfo.GetCanUseSystemCredentials();
+
+ sal_uInt16 nFlags = 0;
+ if (rInfo.GetPath().Len() == 0)
+ nFlags |= LF_NO_PATH;
+ if (rInfo.GetErrorText().Len() == 0)
+ nFlags |= LF_NO_ERRORTEXT;
+ if (!bAccount)
+ nFlags |= LF_NO_ACCOUNT;
+ if (!(rInfo.GetFlags() & LOGINERROR_FLAG_MODIFY_USER_NAME))
+ nFlags |= LF_USERNAME_READONLY;
+
+ if (!bSavePassword)
+ nFlags |= LF_NO_SAVEPASSWORD;
+
+ if (!bCanUseSysCreds)
+ nFlags |= LF_NO_USESYSCREDS;
+
+ std::auto_ptr< ResMgr > xManager( ResMgr::CreateResMgr(CREATEVERSIONRESMGR_NAME(uui)));
+ UniString aRealm(rRealm);
+ std::auto_ptr< LoginDialog > xDialog(
+ new LoginDialog( pParent, nFlags, rInfo.GetServer(), &aRealm, xManager.get()));
+ if (rInfo.GetErrorText().Len() != 0)
+ xDialog->SetErrorText(rInfo.GetErrorText());
+ xDialog->SetName(rInfo.GetUserName());
+ if (bAccount)
+ xDialog->ClearAccount();
+ else
+ xDialog->ClearPassword();
+ xDialog->SetPassword(rInfo.GetPassword());
+
+ if (bSavePassword)
+ {
+ xDialog->SetSavePasswordText(
+ ResId(rInfo.GetIsRememberPersistent()
+ ? RID_SAVE_PASSWORD
+ : RID_KEEP_PASSWORD,
+ *xManager.get()));
+
+ xDialog->SetSavePassword(rInfo.GetIsRememberPassword());
+ }
+
+ if ( bCanUseSysCreds )
+ xDialog->SetUseSystemCredentials( rInfo.GetIsUseSystemCredentials() );
+
+ rInfo.SetResult(xDialog->Execute() == RET_OK ? ERRCODE_BUTTON_OK :
+ ERRCODE_BUTTON_CANCEL);
+ rInfo.SetUserName(xDialog->GetName());
+ rInfo.SetPassword(xDialog->GetPassword());
+ rInfo.SetAccount(xDialog->GetAccount());
+ rInfo.SetIsRememberPassword(xDialog->IsSavePassword());
+
+ if ( bCanUseSysCreds )
+ rInfo.SetIsUseSystemCredentials( xDialog->IsUseSystemCredentials() );
+ }
+ catch (std::bad_alloc const &)
+ {
+ throw uno::RuntimeException(
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("out of memory")),
+ uno::Reference< uno::XInterface >());
+ }
+}
+
+void getRememberModes(
+ uno::Sequence< ucb::RememberAuthentication > const & rRememberModes,
+ ucb::RememberAuthentication & rPreferredMode,
+ ucb::RememberAuthentication & rAlternateMode )
+{
+ sal_Int32 nCount = rRememberModes.getLength();
+ OSL_ENSURE( (nCount > 0) && (nCount < 4),
+ "ucb::RememberAuthentication sequence size mismatch!" );
+ if ( nCount == 1 )
+ {
+ rPreferredMode = rAlternateMode = rRememberModes[ 0 ];
+ return;
+ }
+ else
+ {
+ //bool bHasRememberModeNo = false;
+ bool bHasRememberModeSession = false;
+ bool bHasRememberModePersistent = false;
+
+ for (sal_Int32 i = 0; i < nCount; ++i)
+ {
+ switch ( rRememberModes[i] )
+ {
+ case ucb::RememberAuthentication_NO:
+ //bHasRememberModeNo = true;
+ break;
+ case ucb::RememberAuthentication_SESSION:
+ bHasRememberModeSession = true;
+ break;
+ case ucb::RememberAuthentication_PERSISTENT:
+ bHasRememberModePersistent = true;
+ break;
+ default:
+ OSL_TRACE( "Unsupported RememberAuthentication value" );
+ break;
+ }
+ }
+
+ if (bHasRememberModePersistent)
+ {
+ rPreferredMode = ucb::RememberAuthentication_PERSISTENT;
+ if (bHasRememberModeSession)
+ rAlternateMode = ucb::RememberAuthentication_SESSION;
+ else
+ rAlternateMode = ucb::RememberAuthentication_NO;
+ }
+ else
+ {
+ rPreferredMode = ucb::RememberAuthentication_SESSION;
+ rAlternateMode = ucb::RememberAuthentication_NO;
+ }
+ }
+}
+
+void
+handleAuthenticationRequest_(
+ Window * pParent,
+ uno::Reference< task::XInteractionHandler > const & xIH,
+ uno::Reference< lang::XMultiServiceFactory > const & xServiceFactory,
+ ucb::AuthenticationRequest const & rRequest,
+ uno::Sequence< uno::Reference< task::XInteractionContinuation > > const &
+ rContinuations,
+ const rtl::OUString & rURL)
+ SAL_THROW((uno::RuntimeException))
+{
+ uno::Reference< task::XInteractionRetry > xRetry;
+ uno::Reference< task::XInteractionAbort > xAbort;
+ uno::Reference< ucb::XInteractionSupplyAuthentication >
+ xSupplyAuthentication;
+ uno::Reference< ucb::XInteractionSupplyAuthentication2 >
+ xSupplyAuthentication2;
+ getContinuations(rContinuations, &xRetry, &xAbort, &xSupplyAuthentication);
+ if (xSupplyAuthentication.is())
+ xSupplyAuthentication2.set(xSupplyAuthentication, uno::UNO_QUERY);
+
+ //////////////////////////
+ // First, try to obtain credentials from password container service.
+ uui::PasswordContainerHelper aPwContainerHelper(xServiceFactory);
+ if (aPwContainerHelper.handleAuthenticationRequest(rRequest,
+ xSupplyAuthentication,
+ rURL,
+ xIH))
+ {
+ xSupplyAuthentication->select();
+ return;
+ }
+
+ //////////////////////////
+ // Second, try to obtain credentials from user via password dialog.
+ ucb::RememberAuthentication eDefaultRememberMode
+ = ucb::RememberAuthentication_SESSION;
+ ucb::RememberAuthentication ePreferredRememberMode
+ = eDefaultRememberMode;
+ ucb::RememberAuthentication eAlternateRememberMode
+ = ucb::RememberAuthentication_NO;
+
+ if (xSupplyAuthentication.is())
+ {
+ getRememberModes(
+ xSupplyAuthentication->getRememberPasswordModes(
+ eDefaultRememberMode),
+ ePreferredRememberMode,
+ eAlternateRememberMode);
+ }
+
+ sal_Bool bCanUseSystemCredentials;
+ sal_Bool bDefaultUseSystemCredentials;
+ if (xSupplyAuthentication2.is())
+ {
+ bCanUseSystemCredentials
+ = xSupplyAuthentication2->canUseSystemCredentials(
+ bDefaultUseSystemCredentials);
+ }
+ else
+ {
+ bCanUseSystemCredentials = sal_False;
+ bDefaultUseSystemCredentials = sal_False;
+ }
+
+ LoginErrorInfo aInfo;
+ aInfo.SetTitle(rRequest.ServerName);
+ aInfo.SetServer(rRequest.ServerName);
+ if (rRequest.HasAccount)
+ aInfo.SetAccount(rRequest.Account);
+ if (rRequest.HasUserName)
+ aInfo.SetUserName(rRequest.UserName);
+ if (rRequest.HasPassword)
+ aInfo.SetPassword(rRequest.Password);
+ aInfo.SetErrorText(rRequest.Diagnostic);
+
+ aInfo.SetCanRememberPassword(
+ ePreferredRememberMode != eAlternateRememberMode);
+ aInfo.SetIsRememberPassword(
+ eDefaultRememberMode != ucb::RememberAuthentication_NO);
+ aInfo.SetIsRememberPersistent(
+ ePreferredRememberMode == ucb::RememberAuthentication_PERSISTENT);
+
+ aInfo.SetCanUseSystemCredentials(bCanUseSystemCredentials);
+ aInfo.SetIsUseSystemCredentials( bDefaultUseSystemCredentials );
+ aInfo.SetModifyAccount(rRequest.HasAccount
+ && xSupplyAuthentication.is()
+ && xSupplyAuthentication->canSetAccount());
+ aInfo.SetModifyUserName(rRequest.HasUserName
+ && xSupplyAuthentication.is()
+ && xSupplyAuthentication->canSetUserName());
+ executeLoginDialog(pParent,
+ aInfo,
+ rRequest.HasRealm ? rRequest.Realm : rtl::OUString());
+ switch (aInfo.GetResult())
+ {
+ case ERRCODE_BUTTON_OK:
+ if (xSupplyAuthentication.is())
+ {
+ if (xSupplyAuthentication->canSetUserName())
+ xSupplyAuthentication->setUserName(aInfo.GetUserName());
+ if (xSupplyAuthentication->canSetPassword())
+ xSupplyAuthentication->setPassword(aInfo.GetPassword());
+
+ if (ePreferredRememberMode != eAlternateRememberMode)
+ {
+ // user had te choice.
+ if (aInfo.GetIsRememberPassword())
+ xSupplyAuthentication->setRememberPassword(
+ ePreferredRememberMode);
+ else
+ xSupplyAuthentication->setRememberPassword(
+ eAlternateRememberMode);
+ }
+ else
+ {
+ // user had no choice.
+ xSupplyAuthentication->setRememberPassword(
+ ePreferredRememberMode);
+ }
+
+ if (rRequest.HasRealm)
+ {
+ if (xSupplyAuthentication->canSetRealm())
+ xSupplyAuthentication->setRealm(aInfo.GetAccount());
+ }
+ else if (xSupplyAuthentication->canSetAccount())
+ xSupplyAuthentication->setAccount(aInfo.GetAccount());
+
+ if ( xSupplyAuthentication2.is() && bCanUseSystemCredentials )
+ xSupplyAuthentication2->setUseSystemCredentials(
+ aInfo.GetIsUseSystemCredentials() );
+
+ xSupplyAuthentication->select();
+ }
+
+ //////////////////////////
+ // Third, store credentials in password container.
+
+ if ( aInfo.GetIsUseSystemCredentials() )
+ {
+ if (aInfo.GetIsRememberPassword())
+ {
+ if (!aPwContainerHelper.addRecord(
+ rURL.getLength() ? rURL : rRequest.ServerName,
+ rtl::OUString(), // empty u/p -> sys creds
+ uno::Sequence< rtl::OUString >(),
+ xIH,
+ ePreferredRememberMode
+ == ucb::RememberAuthentication_PERSISTENT))
+ {
+ xSupplyAuthentication->setRememberPassword(
+ ucb::RememberAuthentication_NO);
+ }
+ }
+ else if (eAlternateRememberMode
+ == ucb::RememberAuthentication_SESSION)
+ {
+ if (!aPwContainerHelper.addRecord(
+ rURL.getLength() ? rURL : rRequest.ServerName,
+ rtl::OUString(), // empty u/p -> sys creds
+ uno::Sequence< rtl::OUString >(),
+ xIH,
+ false /* SESSION */))
+ {
+ xSupplyAuthentication->setRememberPassword(
+ ucb::RememberAuthentication_NO);
+ }
+ }
+ }
+ // Empty user name can not be valid:
+ else if (aInfo.GetUserName().Len() != 0)
+ {
+ uno::Sequence< rtl::OUString >
+ aPassList(aInfo.GetAccount().Len() == 0 ? 1 : 2);
+ aPassList[0] = aInfo.GetPassword();
+ if (aInfo.GetAccount().Len() != 0)
+ aPassList[1] = aInfo.GetAccount();
+
+ if (aInfo.GetIsRememberPassword())
+ {
+ if (!aPwContainerHelper.addRecord(
+ rURL.getLength() ? rURL : rRequest.ServerName,
+ aInfo.GetUserName(),
+ aPassList,
+ xIH,
+ ePreferredRememberMode
+ == ucb::RememberAuthentication_PERSISTENT))
+ {
+ xSupplyAuthentication->setRememberPassword(
+ ucb::RememberAuthentication_NO);
+ }
+ }
+ else if (eAlternateRememberMode
+ == ucb::RememberAuthentication_SESSION)
+ {
+ if (!aPwContainerHelper.addRecord(
+ rURL.getLength() ? rURL : rRequest.ServerName,
+ aInfo.GetUserName(),
+ aPassList,
+ xIH,
+ false /* SESSION */))
+ {
+ xSupplyAuthentication->setRememberPassword(
+ ucb::RememberAuthentication_NO);
+ }
+ }
+ }
+ break;
+
+ case ERRCODE_BUTTON_RETRY:
+ if (xRetry.is())
+ xRetry->select();
+ break;
+
+ default:
+ if (xAbort.is())
+ xAbort->select();
+ break;
+ }
+}
+
+void
+executeMasterPasswordDialog(
+ Window * pParent,
+ LoginErrorInfo & rInfo,
+ task::PasswordRequestMode nMode)
+ SAL_THROW((uno::RuntimeException))
+{
+ rtl::OString aMaster;
+ try
+ {
+ vos::OGuard aGuard(Application::GetSolarMutex());
+
+ std::auto_ptr< ResMgr > xManager(
+ ResMgr::CreateResMgr(CREATEVERSIONRESMGR_NAME(uui)));
+ if( nMode == task::PasswordRequestMode_PASSWORD_CREATE )
+ {
+ std::auto_ptr< MasterPasswordCreateDialog > xDialog(
+ new MasterPasswordCreateDialog(pParent, xManager.get()));
+ rInfo.SetResult(xDialog->Execute()
+ == RET_OK ? ERRCODE_BUTTON_OK : ERRCODE_BUTTON_CANCEL);
+ aMaster = rtl::OUStringToOString(
+ xDialog->GetMasterPassword(), RTL_TEXTENCODING_UTF8);
+ }
+ else
+ {
+ std::auto_ptr< MasterPasswordDialog > xDialog(
+ new MasterPasswordDialog(pParent, nMode, xManager.get()));
+ rInfo.SetResult(xDialog->Execute()
+ == RET_OK ? ERRCODE_BUTTON_OK : ERRCODE_BUTTON_CANCEL);
+ aMaster = rtl::OUStringToOString(
+ xDialog->GetMasterPassword(), RTL_TEXTENCODING_UTF8);
+ }
+ }
+ catch (std::bad_alloc const &)
+ {
+ throw uno::RuntimeException(
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("out of memory")),
+ uno::Reference< uno::XInterface >());
+ }
+
+ sal_uInt8 aKey[RTL_DIGEST_LENGTH_MD5];
+ rtl_digest_PBKDF2(aKey,
+ RTL_DIGEST_LENGTH_MD5,
+ reinterpret_cast< sal_uInt8 const * >(aMaster.getStr()),
+ aMaster.getLength(),
+ reinterpret_cast< sal_uInt8 const * >(
+ "3B5509ABA6BC42D9A3A1F3DAD49E56A51"),
+ 32,
+ 1000);
+
+ rtl::OUStringBuffer aBuffer;
+ for (int i = 0; i < RTL_DIGEST_LENGTH_MD5; ++i)
+ {
+ aBuffer.append(static_cast< sal_Unicode >('a' + (aKey[i] >> 4)));
+ aBuffer.append(static_cast< sal_Unicode >('a' + (aKey[i] & 15)));
+ }
+ rInfo.SetPassword(aBuffer.makeStringAndClear());
+}
+
+void
+handleMasterPasswordRequest_(
+ Window * pParent,
+ task::PasswordRequestMode nMode,
+ uno::Sequence< uno::Reference< task::XInteractionContinuation > > const &
+ rContinuations)
+ SAL_THROW((uno::RuntimeException))
+{
+ uno::Reference< task::XInteractionRetry > xRetry;
+ uno::Reference< task::XInteractionAbort > xAbort;
+ uno::Reference< ucb::XInteractionSupplyAuthentication >
+ xSupplyAuthentication;
+ getContinuations(rContinuations, &xRetry, &xAbort, &xSupplyAuthentication);
+ LoginErrorInfo aInfo;
+
+ // in case of master password a hash code is returned
+ executeMasterPasswordDialog(pParent, aInfo, nMode);
+
+ switch (aInfo.GetResult())
+ {
+ case ERRCODE_BUTTON_OK:
+ if (xSupplyAuthentication.is())
+ {
+ if (xSupplyAuthentication->canSetPassword())
+ xSupplyAuthentication->setPassword(aInfo.GetPassword());
+ xSupplyAuthentication->select();
+ }
+ break;
+
+ case ERRCODE_BUTTON_RETRY:
+ if (xRetry.is())
+ xRetry->select();
+ break;
+
+ default:
+ if (xAbort.is())
+ xAbort->select();
+ break;
+ }
+}
+
+void
+executePasswordDialog(
+ Window * pParent,
+ LoginErrorInfo & rInfo,
+ task::PasswordRequestMode nMode,
+ ::rtl::OUString aDocName,
+ bool bMSCryptoMode,
+ bool bIsPasswordToModify )
+ SAL_THROW((uno::RuntimeException))
+{
+ try
+ {
+ vos::OGuard aGuard(Application::GetSolarMutex());
+
+ std::auto_ptr< ResMgr > xManager(
+ ResMgr::CreateResMgr(CREATEVERSIONRESMGR_NAME(uui)));
+ if( nMode == task::PasswordRequestMode_PASSWORD_CREATE )
+ {
+ const sal_uInt16 nMaxPasswdLen = bMSCryptoMode ? 15 : 0; // 0 -> allow any length
+
+ VclAbstractDialogFactory * pFact = VclAbstractDialogFactory::Create();
+ AbstractPasswordToOpenModifyDialog *pTmp = pFact->CreatePasswordToOpenModifyDialog( pParent, 0, nMaxPasswdLen, bIsPasswordToModify );
+ std::auto_ptr< AbstractPasswordToOpenModifyDialog > pDialog( pTmp );
+
+ rInfo.SetResult( pDialog->Execute() == RET_OK ? ERRCODE_BUTTON_OK : ERRCODE_BUTTON_CANCEL );
+ rInfo.SetPassword( pDialog->GetPasswordToOpen() );
+ rInfo.SetPasswordToModify( pDialog->GetPasswordToModify() );
+ rInfo.SetRecommendToOpenReadonly( pDialog->IsRecommendToOpenReadonly() );
+ }
+ else
+ {
+ std::auto_ptr< PasswordDialog > pDialog(
+ new PasswordDialog( pParent, nMode, xManager.get(), aDocName, bIsPasswordToModify ) );
+
+ rInfo.SetResult( pDialog->Execute() == RET_OK ? ERRCODE_BUTTON_OK : ERRCODE_BUTTON_CANCEL );
+ rInfo.SetPassword( bIsPasswordToModify ? String() : pDialog->GetPassword() );
+ rInfo.SetPasswordToModify( bIsPasswordToModify ? pDialog->GetPassword() : String() );
+ }
+ }
+ catch (std::bad_alloc const &)
+ {
+ throw uno::RuntimeException(
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("out of memory")),
+ uno::Reference< uno::XInterface>());
+ }
+}
+
+void
+handlePasswordRequest_(
+ Window * pParent,
+ task::PasswordRequestMode nMode,
+ uno::Sequence< uno::Reference< task::XInteractionContinuation > > const &
+ rContinuations,
+ ::rtl::OUString aDocumentName,
+ bool bMSCryptoMode,
+ bool bIsPasswordToModify )
+ SAL_THROW((uno::RuntimeException))
+{
+ uno::Reference< task::XInteractionRetry > xRetry;
+ uno::Reference< task::XInteractionAbort > xAbort;
+ uno::Reference< task::XInteractionPassword > xPassword;
+ uno::Reference< task::XInteractionPassword2 > xPassword2;
+ getContinuations(rContinuations, &xRetry, &xAbort, &xPassword2, &xPassword);
+
+ if ( xPassword2.is() && !xPassword.is() )
+ xPassword.set( xPassword2, uno::UNO_QUERY_THROW );
+
+ LoginErrorInfo aInfo;
+
+ executePasswordDialog( pParent, aInfo, nMode,
+ aDocumentName, bMSCryptoMode, bIsPasswordToModify );
+
+ switch (aInfo.GetResult())
+ {
+ case ERRCODE_BUTTON_OK:
+ OSL_ENSURE( !bIsPasswordToModify || xPassword2.is(), "PasswordToModify is requested, but there is no Interaction!" );
+ if (xPassword.is())
+ {
+ if (xPassword2.is())
+ {
+ xPassword2->setPasswordToModify( aInfo.GetPasswordToModify() );
+ xPassword2->setRecommendReadOnly( aInfo.IsRecommendToOpenReadonly() );
+ }
+
+ xPassword->setPassword(aInfo.GetPassword());
+ xPassword->select();
+ }
+ break;
+
+ case ERRCODE_BUTTON_RETRY:
+ if (xRetry.is())
+ xRetry->select();
+ break;
+
+ default:
+ if (xAbort.is())
+ xAbort->select();
+ break;
+ }
+}
+
+} // namespace
+
+bool
+UUIInteractionHelper::handleAuthenticationRequest(
+ uno::Reference< task::XInteractionRequest > const & rRequest)
+ SAL_THROW((uno::RuntimeException))
+{
+ uno::Any aAnyRequest(rRequest->getRequest());
+
+ ucb::URLAuthenticationRequest aURLAuthenticationRequest;
+ if (aAnyRequest >>= aURLAuthenticationRequest)
+ {
+ handleAuthenticationRequest_(getParentProperty(),
+ getInteractionHandler(),
+ m_xServiceFactory,
+ aURLAuthenticationRequest,
+ rRequest->getContinuations(),
+ aURLAuthenticationRequest.URL);
+ return true;
+ }
+
+ ucb::AuthenticationRequest aAuthenticationRequest;
+ if (aAnyRequest >>= aAuthenticationRequest)
+ {
+ handleAuthenticationRequest_(getParentProperty(),
+ getInteractionHandler(),
+ m_xServiceFactory,
+ aAuthenticationRequest,
+ rRequest->getContinuations(),
+ rtl::OUString());
+ return true;
+ }
+ return false;
+}
+
+bool
+UUIInteractionHelper::handleMasterPasswordRequest(
+ uno::Reference< task::XInteractionRequest > const & rRequest)
+ SAL_THROW((uno::RuntimeException))
+{
+ uno::Any aAnyRequest(rRequest->getRequest());
+
+ task::MasterPasswordRequest aMasterPasswordRequest;
+ if (aAnyRequest >>= aMasterPasswordRequest)
+ {
+ handleMasterPasswordRequest_(getParentProperty(),
+ aMasterPasswordRequest.Mode,
+ rRequest->getContinuations());
+ return true;
+ }
+ return false;
+}
+
+bool
+UUIInteractionHelper::handlePasswordRequest(
+ uno::Reference< task::XInteractionRequest > const & rRequest)
+ SAL_THROW((uno::RuntimeException))
+{
+ // parameters to be filled for the call to handlePasswordRequest_
+ Window * pParent = getParentProperty();
+ task::PasswordRequestMode nMode = task::PasswordRequestMode_PASSWORD_ENTER;
+ uno::Sequence< uno::Reference< task::XInteractionContinuation > > const & rContinuations = rRequest->getContinuations();
+ ::rtl::OUString aDocumentName;
+ bool bMSCryptoMode = false;
+ bool bIsPasswordToModify = false;
+
+ bool bDoHandleRequest = false;
+
+ uno::Any aAnyRequest(rRequest->getRequest());
+
+ task::DocumentPasswordRequest2 aDocumentPasswordRequest2;
+ if (!bDoHandleRequest && (aAnyRequest >>= aDocumentPasswordRequest2))
+ {
+ nMode = aDocumentPasswordRequest2.Mode;
+ aDocumentName = aDocumentPasswordRequest2.Name;
+ OSL_ENSURE( bMSCryptoMode == false, "bMSCryptoMode should be false" );
+ bIsPasswordToModify = aDocumentPasswordRequest2.IsRequestPasswordToModify;
+
+ bDoHandleRequest = true;
+ }
+
+ task::DocumentPasswordRequest aDocumentPasswordRequest;
+ if (!bDoHandleRequest && (aAnyRequest >>= aDocumentPasswordRequest))
+ {
+ nMode = aDocumentPasswordRequest.Mode;
+ aDocumentName = aDocumentPasswordRequest.Name;
+ OSL_ENSURE( bMSCryptoMode == false, "bMSCryptoMode should be false" );
+ OSL_ENSURE( bIsPasswordToModify == false, "bIsPasswordToModify should be false" );
+
+ bDoHandleRequest = true;
+ }
+
+ task::DocumentMSPasswordRequest2 aDocumentMSPasswordRequest2;
+ if (!bDoHandleRequest && (aAnyRequest >>= aDocumentMSPasswordRequest2))
+ {
+ nMode = aDocumentMSPasswordRequest2.Mode;
+ aDocumentName = aDocumentMSPasswordRequest2.Name;
+ bMSCryptoMode = true;
+ bIsPasswordToModify = aDocumentMSPasswordRequest2.IsRequestPasswordToModify;
+
+ bDoHandleRequest = true;
+ }
+
+ task::DocumentMSPasswordRequest aDocumentMSPasswordRequest;
+ if (!bDoHandleRequest && (aAnyRequest >>= aDocumentMSPasswordRequest))
+ {
+ nMode = aDocumentMSPasswordRequest.Mode;
+ aDocumentName = aDocumentMSPasswordRequest.Name;
+ bMSCryptoMode = true;
+ OSL_ENSURE( bIsPasswordToModify == false, "bIsPasswordToModify should be false" );
+
+ bDoHandleRequest = true;
+ }
+
+ if (bDoHandleRequest)
+ {
+ handlePasswordRequest_( pParent, nMode, rContinuations,
+ aDocumentName, bMSCryptoMode, bIsPasswordToModify );
+ return true;
+ }
+
+ task::PasswordRequest aPasswordRequest;
+ if( aAnyRequest >>= aPasswordRequest )
+ {
+ handlePasswordRequest_(getParentProperty(),
+ aPasswordRequest.Mode,
+ rRequest->getContinuations(),
+ rtl::OUString(),
+ false /* bool bMSCryptoMode */);
+ return true;
+ }
+
+ return false;
+}
+
diff --git a/uui/source/ids.hrc b/uui/source/ids.hrc
index 6a6f38385013..796186fd5140 100755
--- a/uui/source/ids.hrc
+++ b/uui/source/ids.hrc
@@ -170,17 +170,25 @@
#define ERRCODE_UUI_SSLWARN_INVALID_1 (ERRCODE_AREA_UUI_UNKNOWNAUTH + SSLWARN_TYPE_INVALID + 1)
#define TITLE_UUI_SSLWARN_INVALID (ERRCODE_AREA_UUI_UNKNOWNAUTH + SSLWARN_TYPE_INVALID + 3)
-#define HID_DLG_LOGIN (HID_UUI_START + 0)
-#define HID_DLG_COOKIES (HID_UUI_START + 1)
-#define HID_DLG_MASTERPASSWORD_UUI (HID_UUI_START + 2)
-#define HID_DLG_MASTERPASSWORD_CRT (HID_UUI_START + 3)
-#define HID_DLG_FILTER_SELECT (HID_UUI_START + 4)
-#define HID_DLG_PASSWORD_UUI (HID_UUI_START + 5)
-#define HID_DLG_PASSWORD_CRT (HID_UUI_START + 6)
-#define HID_DLG_UNKNOWNAUTH_UUI (HID_UUI_START + 7)
-#define HID_DLG_SSLWARN_UUI (HID_UUI_START + 8)
-#define HID_XMLSECDLG_MACROWARN (HID_UUI_START + 9)
-#define HID_DLG_NEWERVERSIONWARNING (HID_UUI_START +10)
+#define HID_DLG_LOGIN (HID_UUI_START + 0)
+#define HID_DLG_COOKIES (HID_UUI_START + 1)
+#define HID_DLG_MASTERPASSWORD_UUI (HID_UUI_START + 2)
+#define HID_DLG_MASTERPASSWORD_CRT (HID_UUI_START + 3)
+#define HID_DLG_FILTER_SELECT (HID_UUI_START + 4)
+#define HID_DLG_PASSWORD_UUI (HID_UUI_START + 5)
+#define HID_DLG_PASSWORD_CRT (HID_UUI_START + 6)
+#define HID_DLG_UNKNOWNAUTH_UUI (HID_UUI_START + 7)
+#define HID_DLG_SSLWARN_UUI (HID_UUI_START + 8)
+#define HID_XMLSECDLG_MACROWARN (HID_UUI_START + 9)
+#define HID_DLG_NEWERVERSIONWARNING (HID_UUI_START +10)
+
+#define HID_LOGIN_DLG_PATH (HID_UUI_START +11)
+#define HID_LOGIN_DLG_BROWSE (HID_UUI_START +12)
+#define HID_LOGIN_DLG_USER_NAME (HID_UUI_START +13)
+#define HID_LOGIN_DLG_PASSWORD (HID_UUI_START +14)
+#define HID_LOGIN_DLG_ACCOUNT (HID_UUI_START +15)
+#define HID_LOGIN_DLG_REMEMBER_PASSWORD (HID_UUI_START +16)
+#define HID_LOGIN_DLG_USE_SYSTEM_CREDENTIALS (HID_UUI_START +17)
// HID_UUI_END (aka HID_CHAOS_NEW_DATABASE) is reserved in
// sfx2/util/hidother.src
diff --git a/uui/source/logindlg.cxx b/uui/source/logindlg.cxx
index 53ea243c9577..d7ded58b5dde 100644..100755
--- a/uui/source/logindlg.cxx
+++ b/uui/source/logindlg.cxx
@@ -47,12 +47,20 @@
//............................................................................
//............................................................................
+static void lcl_Move( Window &rWin, long nOffset )
+{
+ Point aTmp( rWin.GetPosPixel() );
+ aTmp.Y() -= nOffset;
+ rWin.SetPosPixel( aTmp );
+}
+
+
void LoginDialog::HideControls_Impl( USHORT nFlags )
{
- FASTBOOL bPathHide = FALSE;
- FASTBOOL bErrorHide = FALSE;
- FASTBOOL bAccountHide = FALSE;
- FASTBOOL bUseSysCredsHide = FALSE;
+ bool bPathHide = FALSE;
+ bool bErrorHide = FALSE;
+ bool bAccountHide = FALSE;
+ bool bUseSysCredsHide = FALSE;
if ( ( nFlags & LF_NO_PATH ) == LF_NO_PATH )
{
@@ -63,9 +71,8 @@ void LoginDialog::HideControls_Impl( USHORT nFlags )
}
else if ( ( nFlags & LF_PATH_READONLY ) == LF_PATH_READONLY )
{
- aPathED.Hide();
- aPathInfo.Show();
- aPathBtn.Hide();
+ aPathED.Enable( FALSE );
+ aPathBtn.Enable( FALSE );
}
if ( ( nFlags & LF_NO_USERNAME ) == LF_NO_USERNAME )
@@ -75,8 +82,7 @@ void LoginDialog::HideControls_Impl( USHORT nFlags )
}
else if ( ( nFlags & LF_USERNAME_READONLY ) == LF_USERNAME_READONLY )
{
- aNameED.Hide();
- aNameInfo.Show();
+ aNameED.Enable( FALSE );
}
if ( ( nFlags & LF_NO_PASSWORD ) == LF_NO_PASSWORD )
@@ -91,7 +97,8 @@ void LoginDialog::HideControls_Impl( USHORT nFlags )
if ( ( nFlags & LF_NO_ERRORTEXT ) == LF_NO_ERRORTEXT )
{
aErrorInfo.Hide();
- aErrorGB.Hide();
+ aErrorFT.Hide();
+ aLogin1FL.Hide();
bErrorHide = TRUE;
}
@@ -110,53 +117,26 @@ void LoginDialog::HideControls_Impl( USHORT nFlags )
if ( bErrorHide )
{
- long nOffset = aLoginGB.GetPosPixel().Y() -
- aErrorGB.GetPosPixel().Y();
- Point aNewPnt = aRequestInfo.GetPosPixel();
- aNewPnt.Y() -= nOffset;
- aRequestInfo.SetPosPixel( aNewPnt );
- aNewPnt = aPathFT.GetPosPixel();
- aNewPnt.Y() -= nOffset;
- aPathFT.SetPosPixel( aNewPnt );
- aNewPnt = aPathED.GetPosPixel();
- aNewPnt.Y() -= nOffset;
- aPathED.SetPosPixel( aNewPnt );
- aNewPnt = aPathInfo.GetPosPixel();
- aNewPnt.Y() -= nOffset;
- aPathInfo.SetPosPixel( aNewPnt );
- aNewPnt = aPathBtn.GetPosPixel();
- aNewPnt.Y() -= nOffset;
- aPathBtn.SetPosPixel( aNewPnt );
- aNewPnt = aNameFT.GetPosPixel();
- aNewPnt.Y() -= nOffset;
- aNameFT.SetPosPixel( aNewPnt );
- aNewPnt = aNameED.GetPosPixel();
- aNewPnt.Y() -= nOffset;
- aNameED.SetPosPixel( aNewPnt );
- aNewPnt = aNameInfo.GetPosPixel();
- aNewPnt.Y() -= nOffset;
- aNameInfo.SetPosPixel( aNewPnt );
- aNewPnt = aPasswordFT.GetPosPixel();
- aNewPnt.Y() -= nOffset;
- aPasswordFT.SetPosPixel( aNewPnt );
- aNewPnt = aPasswordED.GetPosPixel();
- aNewPnt.Y() -= nOffset;
- aPasswordED.SetPosPixel( aNewPnt );
- aNewPnt = aAccountFT.GetPosPixel();
- aNewPnt.Y() -= nOffset;
- aAccountFT.SetPosPixel( aNewPnt );
- aNewPnt = aAccountED.GetPosPixel();
- aNewPnt.Y() -= nOffset;
- aAccountED.SetPosPixel( aNewPnt );
- aNewPnt = aSavePasswdBtn.GetPosPixel();
- aNewPnt.Y() -= nOffset;
- aSavePasswdBtn.SetPosPixel( aNewPnt );
- aNewPnt = aUseSysCredsCB.GetPosPixel();
- aNewPnt.Y() -= nOffset;
- aUseSysCredsCB.SetPosPixel( aNewPnt );
- aNewPnt = aLoginGB.GetPosPixel();
- aNewPnt.Y() -= nOffset;
- aLoginGB.SetPosPixel( aNewPnt );
+ long nOffset = aRequestInfo.GetPosPixel().Y() -
+ aErrorFT.GetPosPixel().Y();
+ lcl_Move( aRequestInfo, nOffset );
+ lcl_Move( aLogin2FL, nOffset );
+ lcl_Move( aPathFT, nOffset );
+ lcl_Move( aPathED, nOffset );
+ lcl_Move( aPathBtn, nOffset );
+ lcl_Move( aNameFT, nOffset );
+ lcl_Move( aNameED, nOffset );
+ lcl_Move( aPasswordFT, nOffset );
+ lcl_Move( aPasswordED, nOffset );
+ lcl_Move( aAccountFT, nOffset );
+ lcl_Move( aAccountED, nOffset );
+ lcl_Move( aSavePasswdBtn, nOffset );
+ lcl_Move( aUseSysCredsCB, nOffset );
+ lcl_Move( aButtonsFL, nOffset );
+ lcl_Move( aOKBtn, nOffset );
+ lcl_Move( aCancelBtn, nOffset );
+ lcl_Move( aHelpBtn, nOffset );
+
Size aNewSiz = GetSizePixel();
aNewSiz.Height() -= nOffset;
SetSizePixel( aNewSiz );
@@ -166,24 +146,19 @@ void LoginDialog::HideControls_Impl( USHORT nFlags )
{
long nOffset = aNameED.GetPosPixel().Y() -
aPathED.GetPosPixel().Y();
+ lcl_Move( aNameFT, nOffset );
+ lcl_Move( aNameED, nOffset );
+ lcl_Move( aPasswordFT, nOffset );
+ lcl_Move( aPasswordED, nOffset );
+ lcl_Move( aAccountFT, nOffset );
+ lcl_Move( aAccountED, nOffset );
+ lcl_Move( aSavePasswdBtn, nOffset );
+ lcl_Move( aUseSysCredsCB, nOffset );
+ lcl_Move( aButtonsFL, nOffset );
+ lcl_Move( aOKBtn, nOffset );
+ lcl_Move( aCancelBtn, nOffset );
+ lcl_Move( aHelpBtn, nOffset );
- Point aTmpPnt1 = aNameFT.GetPosPixel();
- Point aTmpPnt2 = aPasswordFT.GetPosPixel();
- aNameFT.SetPosPixel( aPathFT.GetPosPixel() );
- aPasswordFT.SetPosPixel( aTmpPnt1 );
- aAccountFT.SetPosPixel( aTmpPnt2 );
- aTmpPnt1 = aNameED.GetPosPixel();
- aTmpPnt2 = aPasswordED.GetPosPixel();
- aNameED.SetPosPixel( aPathED.GetPosPixel() );
- aPasswordED.SetPosPixel( aTmpPnt1 );
- aAccountED.SetPosPixel( aTmpPnt2 );
- aNameInfo.SetPosPixel( aPathInfo.GetPosPixel() );
- aTmpPnt1 = aSavePasswdBtn.GetPosPixel();
- aTmpPnt1.Y() -= nOffset;
- aSavePasswdBtn.SetPosPixel( aTmpPnt1 );
- aTmpPnt1 = aUseSysCredsCB.GetPosPixel();
- aTmpPnt1.Y() -= nOffset;
- aUseSysCredsCB.SetPosPixel( aTmpPnt1 );
Size aNewSz = GetSizePixel();
aNewSz.Height() -= nOffset;
SetSizePixel( aNewSz );
@@ -191,14 +166,15 @@ void LoginDialog::HideControls_Impl( USHORT nFlags )
if ( bAccountHide )
{
- long nOffset = aAccountED.GetPosPixel().Y() - aPasswordED.GetPosPixel().Y();
-
- Point aTmpPnt = aSavePasswdBtn.GetPosPixel();
- aTmpPnt.Y() -= nOffset;
- aSavePasswdBtn.SetPosPixel( aTmpPnt );
- aTmpPnt = aUseSysCredsCB.GetPosPixel();
- aTmpPnt.Y() -= nOffset;
- aUseSysCredsCB.SetPosPixel( aTmpPnt );
+ long nOffset = aAccountED.GetPosPixel().Y() -
+ aPasswordED.GetPosPixel().Y();
+ lcl_Move( aSavePasswdBtn, nOffset );
+ lcl_Move( aUseSysCredsCB, nOffset );
+ lcl_Move( aButtonsFL, nOffset );
+ lcl_Move( aOKBtn, nOffset );
+ lcl_Move( aCancelBtn, nOffset );
+ lcl_Move( aHelpBtn, nOffset );
+
Size aNewSz = GetSizePixel();
aNewSz.Height() -= nOffset;
SetSizePixel( aNewSz );
@@ -208,6 +184,10 @@ void LoginDialog::HideControls_Impl( USHORT nFlags )
{
long nOffset = aUseSysCredsCB.GetPosPixel().Y() -
aSavePasswdBtn.GetPosPixel().Y();
+ lcl_Move( aButtonsFL, nOffset );
+ lcl_Move( aOKBtn, nOffset );
+ lcl_Move( aCancelBtn, nOffset );
+ lcl_Move( aHelpBtn, nOffset );
Size aNewSz = GetSizePixel();
aNewSz.Height() -= nOffset;
@@ -219,15 +199,13 @@ void LoginDialog::HideControls_Impl( USHORT nFlags )
void LoginDialog::EnableUseSysCredsControls_Impl( BOOL bUseSysCredsEnabled )
{
aErrorInfo.Enable( !bUseSysCredsEnabled );
- aErrorGB.Enable( !bUseSysCredsEnabled );
+ aErrorFT.Enable( !bUseSysCredsEnabled );
aRequestInfo.Enable( !bUseSysCredsEnabled );
aPathFT.Enable( !bUseSysCredsEnabled );
aPathED.Enable( !bUseSysCredsEnabled );
- aPathInfo.Enable( !bUseSysCredsEnabled );
aPathBtn.Enable( !bUseSysCredsEnabled );
aNameFT.Enable( !bUseSysCredsEnabled );
aNameED.Enable( !bUseSysCredsEnabled );
- aNameInfo.Enable( !bUseSysCredsEnabled );
aPasswordFT.Enable( !bUseSysCredsEnabled );
aPasswordED.Enable( !bUseSysCredsEnabled );
aAccountFT.Enable( !bUseSysCredsEnabled );
@@ -282,23 +260,23 @@ LoginDialog::LoginDialog
ModalDialog( pParent, ResId( DLG_UUI_LOGIN, *pResMgr ) ),
- aErrorInfo ( this, ResId( INFO_LOGIN_ERROR, *pResMgr ) ),
- aErrorGB ( this, ResId( GB_LOGIN_ERROR, *pResMgr ) ),
- aRequestInfo ( this, ResId( INFO_LOGIN_REQUEST, *pResMgr ) ),
+ aErrorFT ( this, ResId( FT_LOGIN_ERROR, *pResMgr ) ),
+ aErrorInfo ( this, ResId( FT_INFO_LOGIN_ERROR, *pResMgr ) ),
+ aLogin1FL ( this, ResId( FL_LOGIN_1, *pResMgr ) ),
+ aRequestInfo ( this, ResId( FT_INFO_LOGIN_REQUEST, *pResMgr ) ),
+ aLogin2FL ( this, ResId( FL_LOGIN_2, *pResMgr ) ),
aPathFT ( this, ResId( FT_LOGIN_PATH, *pResMgr ) ),
aPathED ( this, ResId( ED_LOGIN_PATH, *pResMgr ) ),
- aPathInfo ( this, ResId( INFO_LOGIN_PATH, *pResMgr ) ),
aPathBtn ( this, ResId( BTN_LOGIN_PATH, *pResMgr ) ),
aNameFT ( this, ResId( FT_LOGIN_USERNAME, *pResMgr ) ),
aNameED ( this, ResId( ED_LOGIN_USERNAME, *pResMgr ) ),
- aNameInfo ( this, ResId( INFO_LOGIN_USERNAME, *pResMgr ) ),
aPasswordFT ( this, ResId( FT_LOGIN_PASSWORD, *pResMgr ) ),
aPasswordED ( this, ResId( ED_LOGIN_PASSWORD, *pResMgr ) ),
aAccountFT ( this, ResId( FT_LOGIN_ACCOUNT, *pResMgr ) ),
aAccountED ( this, ResId( ED_LOGIN_ACCOUNT, *pResMgr ) ),
aSavePasswdBtn ( this, ResId( CB_LOGIN_SAVEPASSWORD, *pResMgr ) ),
aUseSysCredsCB ( this, ResId( CB_LOGIN_USESYSCREDS, *pResMgr ) ),
- aLoginGB ( this, ResId( GB_LOGIN_LOGIN, *pResMgr ) ),
+ aButtonsFL ( this, ResId( FL_BUTTONS, *pResMgr ) ),
aOKBtn ( this, ResId( BTN_LOGIN_OK, *pResMgr ) ),
aCancelBtn ( this, ResId( BTN_LOGIN_CANCEL, *pResMgr ) ),
aHelpBtn ( this, ResId( BTN_LOGIN_HELP, *pResMgr ) )
@@ -333,10 +311,8 @@ LoginDialog::LoginDialog
// -----------------------------------------------------------------------
-void LoginDialog::SetName( const String& rNewName )
+LoginDialog::~LoginDialog()
{
- aNameED.SetText( rNewName );
- aNameInfo.SetText( rNewName );
}
// -----------------------------------------------------------------------
diff --git a/uui/source/logindlg.hrc b/uui/source/logindlg.hrc
index 68162fb620cd..b541740bd768 100644..100755
--- a/uui/source/logindlg.hrc
+++ b/uui/source/logindlg.hrc
@@ -30,24 +30,24 @@
//============================================================================
-#define INFO_LOGIN_ERROR 10
-#define GB_LOGIN_ERROR 11
+#define FT_INFO_LOGIN_ERROR 10
+#define FT_LOGIN_ERROR 11
-#define INFO_LOGIN_REQUEST 20
+#define FT_INFO_LOGIN_REQUEST 20
#define FT_LOGIN_PATH 21
#define ED_LOGIN_PATH 22
-#define INFO_LOGIN_PATH 23
-#define BTN_LOGIN_PATH 24
-#define FT_LOGIN_USERNAME 25
-#define ED_LOGIN_USERNAME 26
-#define INFO_LOGIN_USERNAME 27
-#define FT_LOGIN_PASSWORD 28
-#define ED_LOGIN_PASSWORD 29
-#define FT_LOGIN_ACCOUNT 30
-#define ED_LOGIN_ACCOUNT 31
-#define CB_LOGIN_SAVEPASSWORD 32
-#define GB_LOGIN_LOGIN 33
-#define CB_LOGIN_USESYSCREDS 34
+#define BTN_LOGIN_PATH 23
+#define FT_LOGIN_USERNAME 24
+#define ED_LOGIN_USERNAME 25
+#define FT_LOGIN_PASSWORD 26
+#define ED_LOGIN_PASSWORD 27
+#define FT_LOGIN_ACCOUNT 28
+#define ED_LOGIN_ACCOUNT 29
+#define CB_LOGIN_SAVEPASSWORD 30
+#define CB_LOGIN_USESYSCREDS 31
+#define FL_LOGIN_1 32
+#define FL_LOGIN_2 33
+#define FL_BUTTONS 34
#define BTN_LOGIN_OK 50
#define BTN_LOGIN_CANCEL 51
diff --git a/uui/source/logindlg.hxx b/uui/source/logindlg.hxx
index 0a4637d89251..05ba8e8d55d4 100644..100755
--- a/uui/source/logindlg.hxx
+++ b/uui/source/logindlg.hxx
@@ -53,23 +53,23 @@
//============================================================================
class LoginDialog : public ModalDialog
{
+ FixedText aErrorFT;
FixedInfo aErrorInfo;
- FixedLine aErrorGB;
+ FixedLine aLogin1FL;
FixedInfo aRequestInfo;
+ FixedLine aLogin2FL;
FixedText aPathFT;
Edit aPathED;
- FixedInfo aPathInfo;
PushButton aPathBtn;
FixedText aNameFT;
Edit aNameED;
- FixedInfo aNameInfo;
FixedText aPasswordFT;
Edit aPasswordED;
FixedText aAccountFT;
Edit aAccountED;
CheckBox aSavePasswdBtn;
CheckBox aUseSysCredsCB;
- FixedLine aLoginGB;
+ FixedLine aButtonsFL;
OKButton aOKBtn;
CancelButton aCancelBtn;
HelpButton aHelpBtn;
@@ -85,36 +85,30 @@ public:
LoginDialog( Window* pParent, USHORT nFlags,
const String& rServer, const String* pRealm,
ResMgr * pResMgr );
+ virtual ~LoginDialog();
- String GetPath() const { return aPathED.GetText(); }
- void SetPath( const String& rNewPath )
- { aPathED.SetText( rNewPath );
- aPathInfo.SetText( rNewPath );}
- String GetName() const { return aNameED.GetText(); }
- void SetName( const String& rNewName );
- String GetPassword() const { return aPasswordED.GetText(); }
- void SetPassword( const String& rNew )
- { aPasswordED.SetText( rNew ); }
- String GetAccount() const { return aAccountED.GetText(); }
- void SetAccount( const String& rNew )
- { aAccountED.SetText( rNew ); }
- BOOL IsSavePassword() const
- { return aSavePasswdBtn.IsChecked(); }
- void SetSavePassword( BOOL bSave )
- { aSavePasswdBtn.Check( bSave ); }
- void SetSavePasswordText( const String& rTxt )
- { aSavePasswdBtn.SetText( rTxt ); }
- BOOL IsUseSystemCredentials() const
- { return aUseSysCredsCB.IsChecked(); }
+ String GetPath() const { return aPathED.GetText(); }
+ void SetPath( const String& rNewPath ) { aPathED.SetText( rNewPath ); }
+ String GetName() const { return aNameED.GetText(); }
+ void SetName( const String& rNewName ) { aNameED.SetText( rNewName ); }
+ String GetPassword() const { return aPasswordED.GetText(); }
+ void SetPassword( const String& rNew ) { aPasswordED.SetText( rNew ); }
+ String GetAccount() const { return aAccountED.GetText(); }
+ void SetAccount( const String& rNew ) { aAccountED.SetText( rNew ); }
+ BOOL IsSavePassword() const { return aSavePasswdBtn.IsChecked(); }
+ void SetSavePassword( BOOL bSave ) { aSavePasswdBtn.Check( bSave ); }
+ void SetSavePasswordText( const String& rTxt ) { aSavePasswdBtn.SetText( rTxt ); }
+ BOOL IsUseSystemCredentials() const { return aUseSysCredsCB.IsChecked(); }
void SetUseSystemCredentials( BOOL bUse );
- void SetErrorText( const String& rTxt )
- { aErrorInfo.SetText( rTxt ); }
- void SetLoginRequestText( const String& rTxt )
- { aRequestInfo.SetText( rTxt ); }
+ void SetErrorText( const String& rTxt ) { aErrorInfo.SetText( rTxt ); }
+ void SetLoginRequestText( const String& rTxt ) { aRequestInfo.SetText( rTxt ); }
void ClearPassword();
void ClearAccount();
};
+// -----------------------------------------------------------------------
+
+
//............................................................................
//............................................................................
diff --git a/uui/source/logindlg.src b/uui/source/logindlg.src
index ce998f4945be..bf6a97c3b0ff 100644..100755
--- a/uui/source/logindlg.src
+++ b/uui/source/logindlg.src
@@ -16,7 +16,7 @@
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
+ *(a copy is included in the LICENSE file that accompanied this code).
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
@@ -42,166 +42,156 @@ ModalDialog DLG_UUI_LOGIN
Moveable = TRUE ;
OutputSize = TRUE ;
SVLook = TRUE ;
- Size = MAP_APPFONT ( 265 , 170 ) ;
- FixedText INFO_LOGIN_ERROR
+ Size = MAP_APPFONT( 177 , 247 ) ;
+ Text [ en-US ] = "Authentication Required" ;
+
+ FixedText FT_LOGIN_ERROR
{
- Pos = MAP_APPFONT ( 12 , 14 ) ;
- Size = MAP_APPFONT ( 185 , 18 ) ;
+ Pos = MAP_APPFONT( 6 , 6 ) ;
+ Size = MAP_APPFONT( 165 , 8 ) ;
+ Text [ en-US ] = "Message from server:" ;
+ };
+
+ FixedText FT_INFO_LOGIN_ERROR
+ {
+ Pos = MAP_APPFONT( 6 , 14 ) ;
+ Size = MAP_APPFONT( 165 , 3*8 ) ;
WordBreak = TRUE ;
};
- FixedLine GB_LOGIN_ERROR
+
+ FixedLine FL_LOGIN_1
{
- Pos = MAP_APPFONT ( 6 , 3 ) ;
- Size = MAP_APPFONT ( 197 , 8 ) ;
- Text [ en-US ] = "Message from server" ;
+ Pos = MAP_APPFONT( 6 , 41 ) ;
+ Size = MAP_APPFONT( 165 , 8 ) ;
};
- FixedText INFO_LOGIN_REQUEST
+
+ FixedText FT_INFO_LOGIN_REQUEST
{
- Pos = MAP_APPFONT ( 12 , 55 ) ;
- Size = MAP_APPFONT ( 185 , 18 ) ;
+ Pos = MAP_APPFONT( 6 , 52 ) ;
+ Size = MAP_APPFONT( 165 , 2*8 ) ;
WordBreak = TRUE ;
- Text [ en-US ] = "Enter the user name and password for %1 here." ;
+ Text [ en-US ] = "Enter user name and password for: \n%1" ;
};
+
+ String STR_LOGIN_REALM
+ {
+ Text [ en-US ] = "Enter user name and password for: \n\"%2\" on %1" ;
+ };
+
+ FixedLine FL_LOGIN_2
+ {
+ Pos = MAP_APPFONT( 6 , 71 ) ;
+ Size = MAP_APPFONT( 165 , 8 ) ;
+ };
+
FixedText FT_LOGIN_PATH
{
- Pos = MAP_APPFONT ( 12 , 77 ) ;
- Size = MAP_APPFONT ( 57 , 10 ) ;
+ Pos = MAP_APPFONT( 6 , 84 ) ;
+ Size = MAP_APPFONT( 112 , 8 ) ;
Text [ en-US ] = "~Path" ;
};
+
Edit ED_LOGIN_PATH
{
+ HelpId = HID_LOGIN_DLG_PATH;
Border = TRUE ;
- Pos = MAP_APPFONT ( 72 , 76 ) ;
- Size = MAP_APPFONT ( 108 , 12 ) ;
- };
- FixedText INFO_LOGIN_PATH
- {
- Hide = TRUE ;
- Pos = MAP_APPFONT ( 72 , 77 ) ;
- Size = MAP_APPFONT ( 125 , 10 ) ;
+ Pos = MAP_APPFONT( 6 , 95 ) ;
+ Size = MAP_APPFONT( 112 , 12 ) ;
};
PushButton BTN_LOGIN_PATH
{
- Pos = MAP_APPFONT ( 183 , 75 ) ;
- Size = MAP_APPFONT ( 14 , 14 ) ;
- Text = "~..." ;
+ HelpId = HID_LOGIN_DLG_BROWSE;
+ Pos = MAP_APPFONT( 121 , 94 ) ;
+ Size = MAP_APPFONT( 50 , 14 ) ;
+ Text = "~Browse..." ;
};
+
FixedText FT_LOGIN_USERNAME
{
- Pos = MAP_APPFONT ( 12 , 92 ) ;
- Size = MAP_APPFONT ( 57 , 10 ) ;
+ Pos = MAP_APPFONT( 6 , 110 ) ;
+ Size = MAP_APPFONT( 165 , 8 ) ;
Text [ en-US ] = "~User name" ;
};
+
Edit ED_LOGIN_USERNAME
{
+ HelpId = HID_LOGIN_DLG_USER_NAME;
Border = TRUE ;
- Pos = MAP_APPFONT ( 72 , 91 ) ;
- Size = MAP_APPFONT ( 125 , 12 ) ;
- };
- FixedText INFO_LOGIN_USERNAME
- {
- Hide = TRUE ;
- Pos = MAP_APPFONT ( 72 , 92 ) ;
- Size = MAP_APPFONT ( 125 , 10 ) ;
+ Pos = MAP_APPFONT( 6 , 121 ) ;
+ Size = MAP_APPFONT( 165 , 12 ) ;
};
+
FixedText FT_LOGIN_PASSWORD
{
- Pos = MAP_APPFONT ( 12 , 107 ) ;
- Size = MAP_APPFONT ( 57 , 10 ) ;
+ Pos = MAP_APPFONT( 6 , 136 ) ;
+ Size = MAP_APPFONT( 165 , 8 ) ;
Text [ en-US ] = "Pass~word" ;
};
+
Edit ED_LOGIN_PASSWORD
{
+ HelpId = HID_LOGIN_DLG_PASSWORD;
Border = TRUE ;
- Pos = MAP_APPFONT ( 72 , 106 ) ;
- Size = MAP_APPFONT ( 125 , 12 ) ;
+ Pos = MAP_APPFONT( 6 , 147 ) ;
+ Size = MAP_APPFONT( 165 , 12 ) ;
PassWord = TRUE ;
};
+
FixedText FT_LOGIN_ACCOUNT
{
- Pos = MAP_APPFONT ( 12 , 122 ) ;
- Size = MAP_APPFONT ( 57 , 10 ) ;
+ Pos = MAP_APPFONT( 6 , 162 ) ;
+ Size = MAP_APPFONT( 165 , 8 ) ;
Text [ en-US ] = "A~ccount";
};
+
Edit ED_LOGIN_ACCOUNT
{
+ HelpId = HID_LOGIN_DLG_ACCOUNT;
Border = TRUE ;
- Pos = MAP_APPFONT ( 72 , 121 ) ;
- Size = MAP_APPFONT ( 125 , 12 ) ;
+ Pos = MAP_APPFONT( 6 , 173 ) ;
+ Size = MAP_APPFONT( 165 , 12 ) ;
PassWord = TRUE ;
};
+
CheckBox CB_LOGIN_SAVEPASSWORD
{
- Pos = MAP_APPFONT ( 12 , 136 ) ;
- Size = MAP_APPFONT ( 185 , 10 ) ;
- Text [ en-US ] = "~Save password" ;
+ HelpId = HID_LOGIN_DLG_REMEMBER_PASSWORD;
+ Pos = MAP_APPFONT( 6 , 190 ) ;
+ Size = MAP_APPFONT( 165 , 10 ) ;
+ Text [ en-US ] = "~Remember password" ;
};
+
CheckBox CB_LOGIN_USESYSCREDS
{
- Pos = MAP_APPFONT ( 12 , 148 ) ;
- Size = MAP_APPFONT ( 185 , 10 ) ;
- Text [ en-US ] = "~Use System Credentials" ;
+ HelpId = HID_LOGIN_DLG_USE_SYSTEM_CREDENTIALS;
+ Pos = MAP_APPFONT( 6 , 203 ) ;
+ Size = MAP_APPFONT( 165 , 10 ) ;
+ Text [ en-US ] = "~Use system credentials" ;
};
- FixedLine GB_LOGIN_LOGIN
+
+ FixedLine FL_BUTTONS
{
- Pos = MAP_APPFONT ( 7 , 44 ) ;
- Size = MAP_APPFONT ( 197 , 8 ) ;
- Text [ en-US ] = "Log in" ;
+ Pos = MAP_APPFONT( 0 , 216 ) ;
+ Size = MAP_APPFONT( 177 , 8 ) ;
};
+
OKButton BTN_LOGIN_OK
{
- Pos = MAP_APPFONT ( 209 , 6 ) ;
- Size = MAP_APPFONT ( 50 , 14 ) ;
+ Pos = MAP_APPFONT( 6 , 227 ) ;
+ Size = MAP_APPFONT( 50 , 14 ) ;
DefButton = TRUE ;
};
+
CancelButton BTN_LOGIN_CANCEL
{
- Pos = MAP_APPFONT ( 209 , 23 ) ;
- Size = MAP_APPFONT ( 50 , 14 ) ;
+ Pos = MAP_APPFONT( 66 , 227 ) ;
+ Size = MAP_APPFONT( 50 , 14 ) ;
};
+
HelpButton BTN_LOGIN_HELP
{
- Pos = MAP_APPFONT ( 209 , 43 ) ;
- Size = MAP_APPFONT ( 50 , 14 ) ;
- };
- String STR_LOGIN_REALM
- {
- Text [ en-US ] = "Please enter user name and password for \"%2\" on %1 here." ;
+ Pos = MAP_APPFONT( 121 , 227 ) ;
+ Size = MAP_APPFONT( 50 , 14 ) ;
};
- Text [ en-US ] = "User Name and Password Required" ;
};
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/uui/source/loginerr.hxx b/uui/source/loginerr.hxx
index 73d61bea359f..ec1317dbd805 100755
--- a/uui/source/loginerr.hxx
+++ b/uui/source/loginerr.hxx
@@ -81,7 +81,7 @@ public:
{ return ( m_nFlags & LOGINERROR_FLAG_IS_USE_SYSCREDS ) ==
LOGINERROR_FLAG_IS_USE_SYSCREDS; }
BYTE GetFlags() const { return m_nFlags; }
- USHORT GetResult() const { return m_nRet; }
+ USHORT GetResult() const { return m_nRet; }
void SetTitle( const String& aTitle )
{ m_aTitle = aTitle; }