summaryrefslogtreecommitdiff
path: root/dbaccess
diff options
context:
space:
mode:
authorThomas Lange [tl] <tl@openoffice.org>2010-04-28 10:17:23 +0200
committerThomas Lange [tl] <tl@openoffice.org>2010-04-28 10:17:23 +0200
commitfbe48b903ecfc57f778478d5f04ba5f4d0dd7936 (patch)
treed8af7e0148702df0c282265e603159804fb17c67 /dbaccess
parent49282fd36431c820b0d3af625ed5455834ebd1e3 (diff)
parentccc5686417ffc7aff8e81eb629b6a98eebfed477 (diff)
cws tl79: merge
Diffstat (limited to 'dbaccess')
-rwxr-xr-x[-rw-r--r--]dbaccess/source/core/dataaccess/datasource.cxx37
-rwxr-xr-xdbaccess/source/inc/OAuthenticationContinuation.hxx82
-rwxr-xr-x[-rw-r--r--]dbaccess/source/ui/dlg/DbAdminImpl.cxx80
-rwxr-xr-x[-rw-r--r--]dbaccess/source/ui/uno/dbinteraction.cxx3
4 files changed, 151 insertions, 51 deletions
diff --git a/dbaccess/source/core/dataaccess/datasource.cxx b/dbaccess/source/core/dataaccess/datasource.cxx
index b5cf356c2115..835f5398efc7 100644..100755
--- a/dbaccess/source/core/dataaccess/datasource.cxx
+++ b/dbaccess/source/core/dataaccess/datasource.cxx
@@ -38,6 +38,7 @@
#include "connection.hxx"
#include "SharedConnection.hxx"
#include "databasedocument.hxx"
+#include "OAuthenticationContinuation.hxx"
/** === begin UNO includes === **/
@@ -206,40 +207,10 @@ void SAL_CALL FlushNotificationAdapter::disposing( const EventObject& Source ) t
impl_dispose( false );
}
-//============================================================
-//= OAuthenticationContinuation
-//============================================================
-class OAuthenticationContinuation : public OInteraction< XInteractionSupplyAuthentication >
-{
- sal_Bool m_bRemberPassword : 1; // remember the password for this session ?
-
- ::rtl::OUString m_sUser; // the user
- ::rtl::OUString m_sPassword; // the user's password
-
-public:
- OAuthenticationContinuation();
-
- sal_Bool SAL_CALL canSetRealm( ) throw(RuntimeException);
- void SAL_CALL setRealm( const ::rtl::OUString& Realm ) throw(RuntimeException);
- sal_Bool SAL_CALL canSetUserName( ) throw(RuntimeException);
- void SAL_CALL setUserName( const ::rtl::OUString& UserName ) throw(RuntimeException);
- sal_Bool SAL_CALL canSetPassword( ) throw(RuntimeException);
- void SAL_CALL setPassword( const ::rtl::OUString& Password ) throw(RuntimeException);
- Sequence< RememberAuthentication > SAL_CALL getRememberPasswordModes( RememberAuthentication& Default ) throw(RuntimeException);
- void SAL_CALL setRememberPassword( RememberAuthentication Remember ) throw(RuntimeException);
- sal_Bool SAL_CALL canSetAccount( ) throw(RuntimeException);
- void SAL_CALL setAccount( const ::rtl::OUString& Account ) throw(RuntimeException);
- Sequence< RememberAuthentication > SAL_CALL getRememberAccountModes( RememberAuthentication& Default ) throw(RuntimeException);
- void SAL_CALL setRememberAccount( RememberAuthentication Remember ) throw(RuntimeException);
-
- ::rtl::OUString getUser() const { return m_sUser; }
- ::rtl::OUString getPassword() const { return m_sPassword; }
- sal_Bool getRememberPassword() const { return m_bRemberPassword; }
-};
-
//--------------------------------------------------------------------------
OAuthenticationContinuation::OAuthenticationContinuation()
- :m_bRemberPassword(sal_True) // TODO: a meaningfull default
+ :m_bRemberPassword(sal_True), // TODO: a meaningfull default
+ m_bCanSetUserName(sal_True)
{
}
@@ -260,7 +231,7 @@ sal_Bool SAL_CALL OAuthenticationContinuation::canSetUserName( ) throw(RuntimeE
{
// we alwas allow this, even if the database document is read-only. In this case,
// it's simply that the user cannot store the new user name.
- return sal_True;
+ return m_bCanSetUserName;
}
//--------------------------------------------------------------------------
diff --git a/dbaccess/source/inc/OAuthenticationContinuation.hxx b/dbaccess/source/inc/OAuthenticationContinuation.hxx
new file mode 100755
index 000000000000..d025ff343462
--- /dev/null
+++ b/dbaccess/source/inc/OAuthenticationContinuation.hxx
@@ -0,0 +1,82 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef _DBACCESS_OAUTHENTICATIONCONTINUATION_HXX_
+#define _DBACCESS_OAUTHENTICATIONCONTINUATION_HXX_
+
+#include "dbadllapi.hxx"
+
+#include <com/sun/star/ucb/XInteractionSupplyAuthentication.hpp>
+#include <com/sun/star/ucb/RememberAuthentication.hpp>
+#include <com/sun/star/uno/Sequence.hxx>
+
+#include <tools/string.hxx>
+#include <comphelper/interaction.hxx>
+
+
+//........................................................................
+namespace dbaccess
+{
+//........................................................................
+
+class OOO_DLLPUBLIC_DBA OAuthenticationContinuation :
+ public comphelper::OInteraction< com::sun::star::ucb::XInteractionSupplyAuthentication >
+{
+ sal_Bool m_bRemberPassword : 1; // remember the password for this session ?
+
+ sal_Bool m_bCanSetUserName;
+ ::rtl::OUString m_sUser; // the user
+ ::rtl::OUString m_sPassword; // the user's password
+
+public:
+ OAuthenticationContinuation();
+
+ sal_Bool SAL_CALL canSetRealm( ) throw(com::sun::star::uno::RuntimeException);
+ void SAL_CALL setRealm( const ::rtl::OUString& Realm ) throw(com::sun::star::uno::RuntimeException);
+ sal_Bool SAL_CALL canSetUserName( ) throw(com::sun::star::uno::RuntimeException);
+ void SAL_CALL setUserName( const ::rtl::OUString& UserName ) throw(com::sun::star::uno::RuntimeException);
+ sal_Bool SAL_CALL canSetPassword( ) throw(com::sun::star::uno::RuntimeException);
+ void SAL_CALL setPassword( const ::rtl::OUString& Password ) throw(com::sun::star::uno::RuntimeException);
+ com::sun::star::uno::Sequence< com::sun::star::ucb::RememberAuthentication > SAL_CALL getRememberPasswordModes( com::sun::star::ucb::RememberAuthentication& Default ) throw(com::sun::star::uno::RuntimeException);
+ void SAL_CALL setRememberPassword( com::sun::star::ucb::RememberAuthentication Remember ) throw(com::sun::star::uno::RuntimeException);
+ sal_Bool SAL_CALL canSetAccount( ) throw(com::sun::star::uno::RuntimeException);
+ void SAL_CALL setAccount( const ::rtl::OUString& Account ) throw(com::sun::star::uno::RuntimeException);
+ com::sun::star::uno::Sequence< com::sun::star::ucb::RememberAuthentication > SAL_CALL getRememberAccountModes( com::sun::star::ucb::RememberAuthentication& Default ) throw(com::sun::star::uno::RuntimeException);
+ void SAL_CALL setRememberAccount( com::sun::star::ucb::RememberAuthentication Remember ) throw(com::sun::star::uno::RuntimeException);
+
+ void setCanChangeUserName( sal_Bool bVal ) { m_bCanSetUserName = bVal; }
+ ::rtl::OUString getUser() const { return m_sUser; }
+ ::rtl::OUString getPassword() const { return m_sPassword; }
+ sal_Bool getRememberPassword() const { return m_bRemberPassword; }
+};
+
+//........................................................................
+} // namespace dbaccess
+//........................................................................
+
+#endif // _DBACCESS_OAUTHENTICATIONCONTINUATION_HXX_
+
diff --git a/dbaccess/source/ui/dlg/DbAdminImpl.cxx b/dbaccess/source/ui/dlg/DbAdminImpl.cxx
index a4e06a640bff..5e38c7419936 100644..100755
--- a/dbaccess/source/ui/dlg/DbAdminImpl.cxx
+++ b/dbaccess/source/ui/dlg/DbAdminImpl.cxx
@@ -42,6 +42,7 @@
#include "optionalboolitem.hxx"
#include "propertysetitem.hxx"
#include "stringlistitem.hxx"
+#include "OAuthenticationContinuation.hxx"
/** === begin UNO includes === **/
#include <com/sun/star/beans/PropertyAttribute.hpp>
@@ -49,23 +50,32 @@
#include <com/sun/star/sdb/SQLContext.hpp>
#include <com/sun/star/sdbc/XDriver.hpp>
#include <com/sun/star/sdbc/XDriverAccess.hpp>
+#include <com/sun/star/task/XInteractionHandler.hpp>
+#include <com/sun/star/task/XInteractionRequest.hpp>
+#include <com/sun/star/ucb/XInteractionSupplyAuthentication2.hpp>
+#include <com/sun/star/ucb/AuthenticationRequest.hpp>
/** === end UNO includes === **/
+#include <comphelper/interaction.hxx>
#include <comphelper/property.hxx>
#include <comphelper/sequence.hxx>
+#include <comphelper/guarding.hxx>
#include <connectivity/DriversConfig.hxx>
#include <connectivity/dbexception.hxx>
#include <osl/file.hxx>
#include <svl/eitem.hxx>
#include <svl/intitem.hxx>
#include <svl/itempool.hxx>
-#include <svtools/logindlg.hxx>
#include <svl/poolitem.hxx>
#include <svl/stritem.hxx>
+#include <tools/urlobj.hxx>
+#include <tools/diagnose_ex.h>
#include <typelib/typedescription.hxx>
+#include <vcl/svapp.hxx>
#include <vcl/msgbox.hxx>
#include <vcl/stdtext.hxx>
#include <vcl/waitobj.hxx>
+#include <vos/mutex.hxx>
#include <algorithm>
#include <functional>
@@ -76,6 +86,8 @@ namespace dbaui
using namespace ::dbtools;
using namespace com::sun::star::uno;
using namespace com::sun::star;
+using namespace com::sun::star::ucb;
+using namespace com::sun::star::task;
using namespace com::sun::star::sdbc;
using namespace com::sun::star::sdb;
using namespace com::sun::star::lang;
@@ -251,35 +263,73 @@ sal_Bool ODbDataSourceAdministrationHelper::getCurrentSettings(Sequence< Propert
{
SFX_ITEMSET_GET(*m_pItemSetHelper->getOutputSet(), pName, SfxStringItem, DSID_NAME, sal_True);
- ::svt::LoginDialog aDlg(m_pParent,
- LF_NO_PATH | LF_NO_ACCOUNT | LF_NO_ERRORTEXT | LF_USERNAME_READONLY,
- String(), NULL);
+ Reference< XModel > xModel( getDataSourceOrModel( m_xDatasource ), UNO_QUERY_THROW );
+ ::comphelper::NamedValueCollection aArgs( xModel->getArgs() );
+ Reference< XInteractionHandler > xHandler( aArgs.getOrDefault( "InteractionHandler", Reference< XInteractionHandler >() ) );
- aDlg.SetName(pUser ? pUser->GetValue() : String());
- aDlg.ClearPassword(); // this will give the password field the focus
+ if ( !xHandler.is() )
+ {
+ // instantiate the default SDB interaction handler
+ xHandler = Reference< XInteractionHandler >( m_xORB->createInstance( SERVICE_SDB_INTERACTION_HANDLER ), UNO_QUERY );
+ if ( !xHandler.is() )
+ ShowServiceNotAvailableError(m_pParent->GetParent(), String(SERVICE_SDB_INTERACTION_HANDLER), sal_True);
+ }
String sName = pName ? pName->GetValue() : String();
String sLoginRequest(ModuleRes(STR_ENTER_CONNECTION_PASSWORD));
::rtl::OUString sTemp = sName;
sName = ::dbaui::getStrippedDatabaseName(NULL,sTemp);
if ( sName.Len() )
- sLoginRequest.SearchAndReplaceAscii("$name$", sName);
+ sLoginRequest.SearchAndReplaceAscii("$name$", sName);
else
{
sLoginRequest.SearchAndReplaceAscii("\"$name$\"", String());
sLoginRequest.SearchAndReplaceAscii("$name$", String()); // just to be sure that in other languages the string will be deleted
}
- aDlg.SetLoginRequestText(sLoginRequest);
-
- aDlg.SetSavePasswordText(ModuleRes(STR_REMEMBERPASSWORD_SESSION));
- aDlg.SetSavePassword(sal_True);
- sal_Int32 nResult = aDlg.Execute();
- if (nResult != RET_OK)
+ // the request
+ AuthenticationRequest aRequest;
+ aRequest.ServerName = sName;
+ aRequest.Diagnostic = sLoginRequest;
+ aRequest.HasRealm = aRequest.HasAccount = sal_False;
+ // aRequest.Realm
+ aRequest.HasUserName = pUser != 0;
+ aRequest.UserName = pUser ? pUser->GetValue() : ::rtl::OUString();
+ aRequest.HasPassword = sal_True;
+ //aRequest.Password
+ aRequest.HasAccount = sal_False;
+ // aRequest.Account
+
+ comphelper::OInteractionRequest* pRequest = new comphelper::OInteractionRequest(makeAny(aRequest));
+ uno::Reference< XInteractionRequest > xRequest(pRequest);
+
+ // build an interaction request
+ // two continuations (Ok and Cancel)
+ ::rtl::Reference< comphelper::OInteractionAbort > pAbort = new comphelper::OInteractionAbort;
+ ::rtl::Reference< dbaccess::OAuthenticationContinuation > pAuthenticate = new dbaccess::OAuthenticationContinuation;
+ pAuthenticate->setCanChangeUserName( sal_False );
+ pAuthenticate->setRememberPassword( RememberAuthentication_SESSION );
+
+ // some knittings
+ pRequest->addContinuation(pAbort.get());
+ pRequest->addContinuation(pAuthenticate.get());
+
+ // handle the request
+ try
+ {
+ ::vos::OGuard aSolarGuard(Application::GetSolarMutex());
+ // release the mutex when calling the handler, it may need to lock the SolarMutex
+ xHandler->handle(xRequest);
+ }
+ catch(Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ if (!pAuthenticate->wasSelected())
return sal_False;
- sPassword = aDlg.GetPassword();
- if (aDlg.IsSavePassword())
+ sPassword = pAuthenticate->getPassword();
+ if (pAuthenticate->getRememberPassword())
m_pItemSetHelper->getWriteOutputSet()->Put(SfxStringItem(DSID_PASSWORD, sPassword));
}
diff --git a/dbaccess/source/ui/uno/dbinteraction.cxx b/dbaccess/source/ui/uno/dbinteraction.cxx
index 0707f49d522b..39ac0e40e7cc 100644..100755
--- a/dbaccess/source/ui/uno/dbinteraction.cxx
+++ b/dbaccess/source/ui/uno/dbinteraction.cxx
@@ -67,9 +67,6 @@
#ifndef _COM_SUN_STAR_SDB_XINTERACTIONDOCUMENTSAVE_HPP_
#include <com/sun/star/sdb/XInteractionDocumentSave.hpp>
#endif
-#ifndef _SVTOOLS_LOGINDLG_HXX_
-#include <svtools/logindlg.hxx>
-#endif
#ifndef SFX_QUERYSAVEDOCUMENT_HXX
#include <sfx2/QuerySaveDocument.hxx>
#endif