summaryrefslogtreecommitdiff
path: root/uui/source/iahndl-authentication.cxx
diff options
context:
space:
mode:
authorThomas Lange [tl] <tl@openoffice.org>2010-03-04 16:14:56 +0100
committerThomas Lange [tl] <tl@openoffice.org>2010-03-04 16:14:56 +0100
commit8a44a90d32ee4dd2e9b3813e485ed4c0fe30cb12 (patch)
treebb1f963b7a09fc30242079c7368cbeb6a9996501 /uui/source/iahndl-authentication.cxx
parent5f4789aa21fb16982d4e744d6eb1f2198f36154e (diff)
#i109634# password to open/modify dialog
Diffstat (limited to 'uui/source/iahndl-authentication.cxx')
-rwxr-xr-xuui/source/iahndl-authentication.cxx92
1 files changed, 54 insertions, 38 deletions
diff --git a/uui/source/iahndl-authentication.cxx b/uui/source/iahndl-authentication.cxx
index 18c8d94b573a..e910d27d1132 100755
--- a/uui/source/iahndl-authentication.cxx
+++ b/uui/source/iahndl-authentication.cxx
@@ -31,6 +31,7 @@
#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"
@@ -43,6 +44,7 @@
#include "vos/mutex.hxx"
#include "tools/errcode.hxx"
#include "vcl/msgbox.hxx"
+#include "vcl/abstdlg.hxx"
#include "vcl/svapp.hxx"
#include "ids.hrc"
@@ -72,10 +74,8 @@ executeLoginDialog(
{
vos::OGuard aGuard(Application::GetSolarMutex());
- bool bAccount = (rInfo.GetFlags() & LOGINERROR_FLAG_MODIFY_ACCOUNT)
- != 0;
- bool bSavePassword = rInfo.GetIsPersistentPassword()
- || rInfo.GetIsSavePassword();
+ bool bAccount = (rInfo.GetFlags() & LOGINERROR_FLAG_MODIFY_ACCOUNT) != 0;
+ bool bSavePassword = rInfo.GetIsPersistentPassword() || rInfo.GetIsSavePassword();
bool bCanUseSysCreds = rInfo.GetCanUseSystemCredentials();
sal_uInt16 nFlags = 0;
@@ -94,15 +94,10 @@ executeLoginDialog(
if (!bCanUseSysCreds)
nFlags |= LF_NO_USESYSCREDS;
- std::auto_ptr< ResMgr > xManager(
- ResMgr::CreateResMgr(CREATEVERSIONRESMGR_NAME(uui)));
+ 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()));
+ new LoginDialog( pParent, nFlags, rInfo.GetServer(), &aRealm, xManager.get()));
if (rInfo.GetErrorText().Len() != 0)
xDialog->SetErrorText(rInfo.GetErrorText());
xDialog->SetName(rInfo.GetUserName());
@@ -114,17 +109,14 @@ executeLoginDialog(
if (bSavePassword)
{
- xDialog->
- SetSavePasswordText(ResId(rInfo.GetIsPersistentPassword() ?
- RID_SAVE_PASSWORD :
- RID_KEEP_PASSWORD,
- *xManager.get()));
+ sal_uInt32 nResId = rInfo.GetIsPersistentPassword() ?
+ RID_SAVE_PASSWORD : RID_KEEP_PASSWORD;
+ xDialog->SetSavePasswordText( ResId( nResId, *xManager.get()) );
xDialog->SetSavePassword(rInfo.GetIsSavePassword());
}
if ( bCanUseSysCreds )
- xDialog->SetUseSystemCredentials(
- rInfo.GetIsUseSystemCredentials() );
+ xDialog->SetUseSystemCredentials( rInfo.GetIsUseSystemCredentials() );
rInfo.SetResult(xDialog->Execute() == RET_OK ? ERRCODE_BUTTON_OK :
ERRCODE_BUTTON_CANCEL);
@@ -423,7 +415,8 @@ executePasswordDialog(
LoginErrorInfo & rInfo,
task::PasswordRequestMode nMode,
::rtl::OUString aDocName,
- bool bMSCryptoMode)
+ bool bMSCryptoMode,
+ bool bIsPasswordToModify )
SAL_THROW((uno::RuntimeException))
{
try
@@ -434,23 +427,25 @@ executePasswordDialog(
ResMgr::CreateResMgr(CREATEVERSIONRESMGR_NAME(uui)));
if( nMode == task::PasswordRequestMode_PASSWORD_CREATE )
{
- std::auto_ptr< PasswordCreateDialog > xDialog(
- new PasswordCreateDialog(pParent,
- xManager.get(),
- bMSCryptoMode));
+ const sal_uInt16 nMaxPasswdLen = bMSCryptoMode ? 15 : 0; // 0 -> allow any length
- rInfo.SetResult(xDialog->Execute()
- == RET_OK ? ERRCODE_BUTTON_OK : ERRCODE_BUTTON_CANCEL);
- rInfo.SetPassword( xDialog->GetPassword() );
+ VclAbstractDialogFactory * pFact = VclAbstractDialogFactory::Create();
+ std::auto_ptr< AbstractPasswordToOpenModifyDialog > pDialog(
+ pFact->CreatePasswordToOpenModifyDialog( pParent, 0, nMaxPasswdLen ) );
+
+ rInfo.SetResult( pDialog->Execute() == RET_OK ? ERRCODE_BUTTON_OK : ERRCODE_BUTTON_CANCEL );
+ rInfo.SetPasswordToOpen( pDialog->GetPasswordToOpen() );
+ rInfo.SetPasswordToModify( pDialog->GetPasswordToModify() );
+ rInfo.SetRecommendToOpenReadonly( pDialog->IsRecommendToOpenReadonly() );
}
else
{
- std::auto_ptr< PasswordDialog > xDialog(
- new PasswordDialog(pParent, nMode, xManager.get(), aDocName));
+ std::auto_ptr< PasswordDialog > pDialog(
+ new PasswordDialog( pParent, nMode, xManager.get(), aDocName, bIsPasswordToModify ) );
- rInfo.SetResult(xDialog->Execute()
- == RET_OK ? ERRCODE_BUTTON_OK : ERRCODE_BUTTON_CANCEL);
- rInfo.SetPassword( xDialog->GetPassword() );
+ rInfo.SetResult( pDialog->Execute() == RET_OK ? ERRCODE_BUTTON_OK : ERRCODE_BUTTON_CANCEL );
+ rInfo.SetPasswordToOpen( bIsPasswordToModify ? String() : pDialog->GetPassword() );
+ rInfo.SetPasswordToModify( bIsPasswordToModify ? pDialog->GetPassword() : String() );
}
}
catch (std::bad_alloc const &)
@@ -468,7 +463,8 @@ handlePasswordRequest_(
uno::Sequence< uno::Reference< task::XInteractionContinuation > > const &
rContinuations,
::rtl::OUString aDocumentName,
- bool bMSCryptoMode )
+ bool bMSCryptoMode,
+ bool bIsPasswordToModify )
SAL_THROW((uno::RuntimeException))
{
uno::Reference< task::XInteractionRetry > xRetry;
@@ -477,11 +473,8 @@ handlePasswordRequest_(
getContinuations(rContinuations, &xRetry, &xAbort, &xPassword);
LoginErrorInfo aInfo;
- executePasswordDialog(pParent,
- aInfo,
- nMode,
- aDocumentName,
- bMSCryptoMode);
+ executePasswordDialog( pParent, aInfo, nMode,
+ aDocumentName, bMSCryptoMode, bIsPasswordToModify );
switch (aInfo.GetResult())
{
@@ -575,6 +568,17 @@ UUIInteractionHelper::handlePasswordRequest(
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))
{
@@ -586,6 +590,17 @@ UUIInteractionHelper::handlePasswordRequest(
bDoHandleRequest = true;
}
+ task::DocumentMSPasswordRequest2 aDocumentMSPasswordRequest2;
+ if (!bDoHandleRequest && (aAnyRequest >>= aDocumentMSPasswordRequest2))
+ {
+ nMode = aDocumentMSPasswordRequest2.Mode;
+ aDocumentName = aDocumentMSPasswordRequest2.Name;
+ bMSCryptoMode = true;
+ bIsPasswordToModify = aDocumentPasswordRequest2.IsRequestPasswordToModify;
+
+ bDoHandleRequest = true;
+ }
+
task::DocumentMSPasswordRequest aDocumentMSPasswordRequest;
if (!bDoHandleRequest && (aAnyRequest >>= aDocumentMSPasswordRequest))
{
@@ -599,7 +614,8 @@ UUIInteractionHelper::handlePasswordRequest(
if (bDoHandleRequest)
{
- handlePasswordRequest_( pParent, nMode, rContinuations, aDocumentName, bMSCryptoMode );
+ handlePasswordRequest_( pParent, nMode, rContinuations,
+ aDocumentName, bMSCryptoMode, bIsPasswordToModify );
return true;
}