summaryrefslogtreecommitdiff
path: root/uui
diff options
context:
space:
mode:
authorPhilipp Lohmann [pl] <Philipp.Lohmann@Sun.COM>2010-06-08 15:27:40 +0200
committerPhilipp Lohmann [pl] <Philipp.Lohmann@Sun.COM>2010-06-08 15:27:40 +0200
commit0de7a6bf8e3896a656f93191ba74ead580bc0332 (patch)
treeaeeb66df51e05ca62902fb11a37d3f26f3bef26c /uui
parentf215bbf0f03ee9dfe59436d7c153f071c9f59642 (diff)
parent44ada130c3857b167e954b63c7a5490268b72c5b (diff)
rebase to DEV300_m80
Diffstat (limited to 'uui')
-rw-r--r--uui/source/iahndl-authentication.cxx247
-rw-r--r--uui/source/loginerr.hxx99
-rw-r--r--uui/source/passwordcontainer.cxx15
-rw-r--r--uui/util/exports.map10
-rw-r--r--uui/util/makefile.mk2
5 files changed, 246 insertions, 127 deletions
diff --git a/uui/source/iahndl-authentication.cxx b/uui/source/iahndl-authentication.cxx
index fbc57156e0..f5599595fe 100644
--- a/uui/source/iahndl-authentication.cxx
+++ b/uui/source/iahndl-authentication.cxx
@@ -1,7 +1,7 @@
/*************************************************************************
*
* 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
@@ -67,10 +67,9 @@ 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.GetCanRememberPassword();
bool bCanUseSysCreds = rInfo.GetCanUseSystemCredentials();
sal_uInt16 nFlags = 0;
@@ -109,12 +108,13 @@ executeLoginDialog(
if (bSavePassword)
{
- xDialog->
- SetSavePasswordText(ResId(rInfo.GetIsPersistentPassword() ?
- RID_SAVE_PASSWORD :
- RID_KEEP_PASSWORD,
- *xManager.get()));
- xDialog->SetSavePassword(rInfo.GetIsSavePassword());
+ xDialog->SetSavePasswordText(
+ ResId(rInfo.GetIsRememberPersistent()
+ ? RID_SAVE_PASSWORD
+ : RID_KEEP_PASSWORD,
+ *xManager.get()));
+
+ xDialog->SetSavePassword(rInfo.GetIsRememberPassword());
}
if ( bCanUseSysCreds )
@@ -126,7 +126,7 @@ executeLoginDialog(
rInfo.SetUserName(xDialog->GetName());
rInfo.SetPassword(xDialog->GetPassword());
rInfo.SetAccount(xDialog->GetAccount());
- rInfo.SetSavePassword(xDialog->IsSavePassword());
+ rInfo.SetIsRememberPassword(xDialog->IsSavePassword());
if ( bCanUseSysCreds )
rInfo.SetIsUseSystemCredentials( xDialog->IsUseSystemCredentials() );
@@ -139,6 +139,60 @@ executeLoginDialog(
}
}
+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,
@@ -161,7 +215,7 @@ handleAuthenticationRequest_(
xSupplyAuthentication2.set(xSupplyAuthentication, uno::UNO_QUERY);
//////////////////////////
- // First, try to obatin credentials from password container service.
+ // First, try to obtain credentials from password container service.
uui::PasswordContainerHelper aPwContainerHelper(xServiceFactory);
if (aPwContainerHelper.handleAuthenticationRequest(rRequest,
xSupplyAuthentication,
@@ -174,26 +228,20 @@ handleAuthenticationRequest_(
//////////////////////////
// Second, try to obtain credentials from user via password dialog.
- bool bRemember;
- bool bRememberPersistent;
+ ucb::RememberAuthentication eDefaultRememberMode
+ = ucb::RememberAuthentication_SESSION;
+ ucb::RememberAuthentication ePreferredRememberMode
+ = eDefaultRememberMode;
+ ucb::RememberAuthentication eAlternateRememberMode
+ = ucb::RememberAuthentication_NO;
+
if (xSupplyAuthentication.is())
{
- ucb::RememberAuthentication eDefault;
- uno::Sequence< ucb::RememberAuthentication >
- aModes(xSupplyAuthentication->getRememberPasswordModes(eDefault));
- bRemember = eDefault != ucb::RememberAuthentication_NO;
- bRememberPersistent = false;
- for (sal_Int32 i = 0; i < aModes.getLength(); ++i)
- if (aModes[i] == ucb::RememberAuthentication_PERSISTENT)
- {
- bRememberPersistent = true;
- break;
- }
- }
- else
- {
- bRemember = false;
- bRememberPersistent = false;
+ getRememberModes(
+ xSupplyAuthentication->getRememberPasswordModes(
+ eDefaultRememberMode),
+ ePreferredRememberMode,
+ eAlternateRememberMode);
}
sal_Bool bCanUseSystemCredentials;
@@ -220,8 +268,14 @@ handleAuthenticationRequest_(
if (rRequest.HasPassword)
aInfo.SetPassword(rRequest.Password);
aInfo.SetErrorText(rRequest.Diagnostic);
- aInfo.SetPersistentPassword(bRememberPersistent);
- aInfo.SetSavePassword(bRemember);
+
+ 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
@@ -242,13 +296,24 @@ handleAuthenticationRequest_(
xSupplyAuthentication->setUserName(aInfo.GetUserName());
if (xSupplyAuthentication->canSetPassword())
xSupplyAuthentication->setPassword(aInfo.GetPassword());
- xSupplyAuthentication->
- setRememberPassword(
- aInfo.GetIsSavePassword() ?
- bRememberPersistent ?
- ucb::RememberAuthentication_PERSISTENT :
- ucb::RememberAuthentication_SESSION :
- ucb::RememberAuthentication_NO);
+
+ 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())
@@ -267,38 +332,76 @@ handleAuthenticationRequest_(
//////////////////////////
// Third, store credentials in password container.
- if ( aInfo.GetIsUseSystemCredentials() )
- {
- if (aInfo.GetIsSavePassword())
- {
- aPwContainerHelper.addRecord(
- rURL.getLength() ? rURL : rRequest.ServerName,
- rtl::OUString(), // empty u/p -> sys creds
- uno::Sequence< rtl::OUString >(),
- xIH,
- bRememberPersistent);
- }
- }
- // Empty user name can not be valid:
- else if (aInfo.GetUserName().Len() != 0)
- {
- if (aInfo.GetIsSavePassword())
- {
- uno::Sequence< rtl::OUString >
- aPassList(aInfo.GetAccount().Len() == 0 ? 1 : 2);
- aPassList[0] = aInfo.GetPassword();
- if (aInfo.GetAccount().Len() != 0)
- aPassList[1] = aInfo.GetAccount();
-
- aPwContainerHelper.addRecord(
- rURL.getLength() ? rURL : rRequest.ServerName,
- aInfo.GetUserName(),
- aPassList,
- xIH,
- bRememberPersistent);
- }
- }
- break;
+ 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())
diff --git a/uui/source/loginerr.hxx b/uui/source/loginerr.hxx
index 1d5451529e..39e5b81caf 100644
--- a/uui/source/loginerr.hxx
+++ b/uui/source/loginerr.hxx
@@ -1,7 +1,7 @@
/*************************************************************************
*
* 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
@@ -32,12 +32,13 @@
//=========================================================================
-#define LOGINERROR_FLAG_SET_SAVE_PASSWORD 1
-#define LOGINERROR_FLAG_MODIFY_ACCOUNT 2
-#define LOGINERROR_FLAG_MODIFY_USER_NAME 4
-#define LOGINERROR_FLAG_PERSISTENT_PASSWORD 8
-#define LOGINERROR_FLAG_CAN_USE_SYSCREDS 16
-#define LOGINERROR_FLAG_IS_USE_SYSCREDS 32
+#define LOGINERROR_FLAG_MODIFY_ACCOUNT 1
+#define LOGINERROR_FLAG_MODIFY_USER_NAME 2
+#define LOGINERROR_FLAG_CAN_REMEMBER_PASSWORD 4
+#define LOGINERROR_FLAG_IS_REMEMBER_PASSWORD 8
+#define LOGINERROR_FLAG_CAN_USE_SYSCREDS 16
+#define LOGINERROR_FLAG_IS_USE_SYSCREDS 32
+#define LOGINERROR_FLAG_REMEMBER_PERSISTENT 64
class LoginErrorInfo
{
@@ -56,71 +57,85 @@ public:
LoginErrorInfo()
: _nFlags( LOGINERROR_FLAG_MODIFY_USER_NAME ),
_nRet( ERRCODE_BUTTON_CANCEL )
- {
- }
-
- const String& GetTitle() const { return _aTitle; }
- const String& GetServer() const { return _aServer; }
- const String& GetAccount() const { return _aAccount; }
- const String& GetUserName() const { return _aUserName; }
- const String& GetPassword() const { return _aPassword; }
- const String& GetPath() const { return _aPath; }
- const String& GetErrorText() const { return _aErrorText; }
- BOOL GetIsPersistentPassword() const
- { return ( _nFlags & LOGINERROR_FLAG_PERSISTENT_PASSWORD ); }
- BOOL GetIsSavePassword() const
- { return ( _nFlags & LOGINERROR_FLAG_SET_SAVE_PASSWORD ); }
+ {}
+
+ const String& GetTitle() const { return _aTitle; }
+ const String& GetServer() const { return _aServer; }
+ const String& GetAccount() const { return _aAccount; }
+ const String& GetUserName() const { return _aUserName; }
+ const String& GetPassword() const { return _aPassword; }
+ const String& GetPath() const { return _aPath; }
+ const String& GetErrorText() const { return _aErrorText; }
+
+ BOOL GetCanRememberPassword() const
+ { return ( _nFlags & LOGINERROR_FLAG_CAN_REMEMBER_PASSWORD ); }
+ BOOL GetIsRememberPersistent() const
+ { return ( _nFlags & LOGINERROR_FLAG_REMEMBER_PERSISTENT ); }
+ BOOL GetIsRememberPassword() const
+ { return ( _nFlags & LOGINERROR_FLAG_IS_REMEMBER_PASSWORD ); }
+
BOOL GetCanUseSystemCredentials() const
{ return ( _nFlags & LOGINERROR_FLAG_CAN_USE_SYSCREDS ); }
BOOL GetIsUseSystemCredentials() const
{ return ( _nFlags & LOGINERROR_FLAG_IS_USE_SYSCREDS ) ==
LOGINERROR_FLAG_IS_USE_SYSCREDS; }
- BYTE GetFlags() const { return _nFlags; }
- USHORT GetResult() const { return _nRet; }
+ BYTE GetFlags() const { return _nFlags; }
+ USHORT GetResult() const { return _nRet; }
- void SetTitle( const String& aTitle )
+ void SetTitle( const String& aTitle )
{ _aTitle = aTitle; }
- void SetServer( const String& aServer )
+ void SetServer( const String& aServer )
{ _aServer = aServer; }
- void SetAccount( const String& aAccount )
+ void SetAccount( const String& aAccount )
{ _aAccount = aAccount; }
- void SetUserName( const String& aUserName )
+ void SetUserName( const String& aUserName )
{ _aUserName = aUserName; }
- void SetPassword( const String& aPassword )
+ void SetPassword( const String& aPassword )
{ _aPassword = aPassword; }
- void SetPath( const String& aPath )
+ void SetPath( const String& aPath )
{ _aPath = aPath; }
- void SetErrorText( const String& aErrorText )
+ void SetErrorText( const String& aErrorText )
{ _aErrorText = aErrorText; }
void SetFlags( BYTE nFlags )
{ _nFlags = nFlags; }
- inline void SetSavePassword( BOOL bSet );
- inline void SetPersistentPassword( BOOL bSet );
+
+ inline void SetCanRememberPassword( BOOL bSet );
+ inline void SetIsRememberPassword( BOOL bSet );
+ inline void SetIsRememberPersistent( BOOL bSet );
+
inline void SetCanUseSystemCredentials( BOOL bSet );
inline void SetIsUseSystemCredentials( BOOL bSet );
- inline void SetModifyAccount( BOOL bSet );
- inline void SetModifyUserName( BOOL bSet );
+ inline void SetModifyAccount( BOOL bSet );
+ inline void SetModifyUserName( BOOL bSet );
void SetResult( USHORT nRet )
{ _nRet = nRet; }
};
-inline void LoginErrorInfo::SetSavePassword( BOOL bSet )
+inline void LoginErrorInfo::SetCanRememberPassword( BOOL bSet )
+{
+ if ( bSet )
+ _nFlags |= LOGINERROR_FLAG_CAN_REMEMBER_PASSWORD;
+ else
+ _nFlags &= ~LOGINERROR_FLAG_CAN_REMEMBER_PASSWORD;
+}
+
+inline void LoginErrorInfo::SetIsRememberPassword( BOOL bSet )
{
if ( bSet )
- _nFlags |= LOGINERROR_FLAG_SET_SAVE_PASSWORD;
+ _nFlags |= LOGINERROR_FLAG_IS_REMEMBER_PASSWORD;
else
- _nFlags &= ~LOGINERROR_FLAG_SET_SAVE_PASSWORD;
+ _nFlags &= ~LOGINERROR_FLAG_IS_REMEMBER_PASSWORD;
}
-inline void LoginErrorInfo::SetPersistentPassword( BOOL bSet )
+inline void LoginErrorInfo::SetIsRememberPersistent( BOOL bSet )
{
if ( bSet )
- _nFlags |= LOGINERROR_FLAG_PERSISTENT_PASSWORD;
+ _nFlags |= LOGINERROR_FLAG_REMEMBER_PERSISTENT;
else
- _nFlags &= ~LOGINERROR_FLAG_PERSISTENT_PASSWORD;
+ _nFlags &= ~LOGINERROR_FLAG_REMEMBER_PERSISTENT;
}
-inline void LoginErrorInfo::SetCanUseSystemCredentials( BOOL bSet )
+inline void LoginErrorInfo::SetCanUseSystemCredentials( BOOL bSet )
{
if ( bSet )
_nFlags |= LOGINERROR_FLAG_CAN_USE_SYSCREDS;
@@ -128,7 +143,7 @@ inline void LoginErrorInfo::SetCanUseSystemCredentials( BOOL bSet )
_nFlags &= ~LOGINERROR_FLAG_CAN_USE_SYSCREDS;
}
-inline void LoginErrorInfo::SetIsUseSystemCredentials( BOOL bSet )
+inline void LoginErrorInfo::SetIsUseSystemCredentials( BOOL bSet )
{
if ( bSet )
_nFlags |= LOGINERROR_FLAG_IS_USE_SYSCREDS;
diff --git a/uui/source/passwordcontainer.cxx b/uui/source/passwordcontainer.cxx
index c9448bcf24..0a056289c2 100644
--- a/uui/source/passwordcontainer.cxx
+++ b/uui/source/passwordcontainer.cxx
@@ -1,7 +1,7 @@
/*************************************************************************
*
* 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
@@ -30,6 +30,7 @@
#include "com/sun/star/lang/XMultiServiceFactory.hpp"
#include "com/sun/star/task/NoMasterException.hpp"
#include "com/sun/star/task/XInteractionHandler.hpp"
+#include "com/sun/star/task/XMasterPasswordHandling.hpp"
#include "com/sun/star/task/XPasswordContainer.hpp"
#include "com/sun/star/task/XUrlContainer.hpp"
#include "com/sun/star/ucb/AuthenticationRequest.hpp"
@@ -271,10 +272,20 @@ bool PasswordContainerHelper::addRecord(
return false;
if ( bPersist )
+ {
+ uno::Reference< task::XMasterPasswordHandling > xMPH(
+ m_xPasswordContainer, uno::UNO_QUERY_THROW );
+
+ // If persistent storing of passwords is not yet
+ // allowed, enable it.
+ if ( !xMPH->isPersistentStoringAllowed() )
+ xMPH->allowPersistentStoring( sal_True );
+
m_xPasswordContainer->addPersistent( rURL,
rUsername,
rPasswords,
xIH );
+ }
else
m_xPasswordContainer->add( rURL,
rUsername,
@@ -429,7 +440,7 @@ PasswordContainerInteractionHandler::handle(
// @@@ FIXME: this not able to
// handle master pw request!
// master pw request is never
- // solvabe without UI!
+ // solvable without UI!
this ) )
{
// successfully handled
diff --git a/uui/util/exports.map b/uui/util/exports.map
deleted file mode 100644
index ba501f9ae0..0000000000
--- a/uui/util/exports.map
+++ /dev/null
@@ -1,10 +0,0 @@
-UDK_3_0_0 {
- global:
- GetVersionInfo;
- component_getImplementationEnvironment;
- component_getFactory;
- component_writeInfo;
-
- local:
- *;
-};
diff --git a/uui/util/makefile.mk b/uui/util/makefile.mk
index 78d726d0ee..163a7bb550 100644
--- a/uui/util/makefile.mk
+++ b/uui/util/makefile.mk
@@ -38,7 +38,7 @@ NO_BSYMBOLIC = true
SHL1TARGET = $(TARGET)$(DLLPOSTFIX)
SHL1IMPLIB = i$(TARGET)
-SHL1VERSIONMAP = exports.map
+SHL1VERSIONMAP = $(SOLARENV)/src/component.map
SHL1DEF = $(MISC)$/$(SHL1TARGET).def
DEF1NAME = $(SHL1TARGET)