/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
if ( bCanUseSysCreds )
aDialog.SetUseSystemCredentials( rInfo.GetIsUseSystemCredentials() );
if (comphelper::LibreOfficeKit::isActive())
{ // Avoid the password dialog popup in the LOK case: it's not async and the "remember // password" checkbox would not work.
rInfo.SetResult(DialogMask::ButtonsCancel);
} else
{
rInfo.SetResult(aDialog.run() == RET_OK ? DialogMask::ButtonsOk :
DialogMask::ButtonsCancel);
}
rInfo.SetUserName(aDialog.GetName());
rInfo.SetPassword(aDialog.GetPassword());
rInfo.SetAccount(aDialog.GetAccount());
rInfo.SetIsRememberPassword(aDialog.IsSavePassword());
if ( bCanUseSysCreds )
rInfo.SetIsUseSystemCredentials( aDialog.IsUseSystemCredentials() );
}
LoginErrorInfo aInfo;
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.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 : OUString()); switch (aInfo.GetResult())
{ case DialogMask::ButtonsOk: if (xSupplyAuthentication.is())
{ if (xSupplyAuthentication->canSetUserName())
xSupplyAuthentication->setUserName(aInfo.GetUserName()); if (xSupplyAuthentication->canSetPassword())
xSupplyAuthentication->setPassword(aInfo.GetPassword());
if (ePreferredRememberMode != eAlternateRememberMode)
{ // user had the 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());
} elseif (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.isEmpty() ? rURL : rRequest.ServerName,
OUString(), // empty u/p -> sys creds
uno::Sequence< OUString >(),
xIH,
ePreferredRememberMode
== ucb::RememberAuthentication_PERSISTENT))
{
xSupplyAuthentication->setRememberPassword(
ucb::RememberAuthentication_NO);
}
} elseif (eAlternateRememberMode
== ucb::RememberAuthentication_SESSION)
{ if (!aPwContainerHelper.addRecord(
!rURL.isEmpty() ? rURL : rRequest.ServerName,
OUString(), // empty u/p -> sys creds
uno::Sequence< OUString >(),
xIH, false/* SESSION */))
{
xSupplyAuthentication->setRememberPassword(
ucb::RememberAuthentication_NO);
}
}
} // Empty user name can not be valid: elseif (!aInfo.GetUserName().isEmpty())
{
uno::Sequence< OUString >
aPassList(aInfo.GetAccount().isEmpty() ? 1 : 2); auto pPassList = aPassList.getArray();
pPassList[0] = aInfo.GetPassword(); if (!aInfo.GetAccount().isEmpty())
pPassList[1] = aInfo.GetAccount();
sal_uInt8 aKey[RTL_DIGEST_LENGTH_MD5]; // FIXME this is subject to the SHA1-bug tdf#114939 - but this // MasterPassword stuff is just stored in the UserInstallation, // so no interop concerns
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);
OUStringBuffer aBuffer; for (sal_uInt8 i : aKey)
{ // match PasswordContainer::DecodePasswords aMasterPasswd.copy(index * 2, 2).toUInt32(16));
aBuffer.append(OUString::number(i >> 4, 16) + OUString::number(i & 15, 16));
}
rInfo.SetPassword(aBuffer.makeStringAndClear());
}
// in case of master password a hash code is returned
executeMasterPasswordDialog(pParent, aInfo, nMode);
switch (aInfo.GetResult())
{ case DialogMask::ButtonsOk: if (xSupplyAuthentication.is())
{ if (xSupplyAuthentication->canSetPassword())
xSupplyAuthentication->setPassword(aInfo.GetPassword());
xSupplyAuthentication->select();
} break;
case DialogMask::ButtonsRetry: if (xRetry.is())
xRetry->select(); break;
default: if (xAbort.is())
xAbort->select(); break;
}
}
switch (aInfo.GetResult())
{ case DialogMask::ButtonsOk:
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() );
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.