summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ucb/source/ucp/webdav/webdavcontent.cxx283
-rw-r--r--uui/source/iahndl.cxx286
-rw-r--r--uui/source/iahndl.hxx17
-rw-r--r--uui/source/makefile.mk3
-rw-r--r--uui/source/passwordcontainer.cxx473
-rw-r--r--uui/source/passwordcontainer.hxx200
-rw-r--r--uui/source/services.cxx74
7 files changed, 813 insertions, 523 deletions
diff --git a/ucb/source/ucp/webdav/webdavcontent.cxx b/ucb/source/ucp/webdav/webdavcontent.cxx
index ae6623ff4492..7adaa88585b3 100644
--- a/ucb/source/ucp/webdav/webdavcontent.cxx
+++ b/ucb/source/ucp/webdav/webdavcontent.cxx
@@ -36,13 +36,16 @@
**************************************************************************
*************************************************************************/
-#include <osl/diagnose.h>
+#include <osl/diagnose.h>
#include "osl/doublecheckedlocking.h"
#include <rtl/uri.hxx>
#include <rtl/ustrbuf.hxx>
-#include "com/sun/star/task/XPasswordContainer.hpp"
-#include "com/sun/star/task/NoMasterException.hpp"
+#include <ucbhelper/contentidentifier.hxx>
+#include <ucbhelper/propertyvalueset.hxx>
+#include <ucbhelper/simpleinteractionrequest.hxx>
+#include <ucbhelper/cancelcommandexecution.hxx>
+
#include <com/sun/star/beans/PropertyAttribute.hpp>
#include <com/sun/star/beans/PropertySetInfoChange.hpp>
#include <com/sun/star/beans/PropertySetInfoChangeEvent.hpp>
@@ -50,7 +53,8 @@
#include <com/sun/star/io/XActiveDataSink.hpp>
#include <com/sun/star/io/XOutputStream.hpp>
#include <com/sun/star/lang/IllegalAccessException.hpp>
-#include "com/sun/star/ucb/AuthenticationRequest.hpp"
+#include <com/sun/star/task/PasswordContainerInteractionHandler.hpp>
+#include <com/sun/star/ucb/CommandEnvironment.hpp>
#include <com/sun/star/ucb/CommandFailedException.hpp>
#include <com/sun/star/ucb/ContentInfoAttribute.hpp>
#include <com/sun/star/ucb/InsertCommandArgument.hpp>
@@ -64,24 +68,22 @@
#include <com/sun/star/ucb/InteractiveNetworkReadException.hpp>
#include <com/sun/star/ucb/InteractiveNetworkResolveNameException.hpp>
#include <com/sun/star/ucb/InteractiveNetworkWriteException.hpp>
+#include <com/sun/star/ucb/MissingInputStreamException.hpp>
+#include <com/sun/star/ucb/MissingPropertiesException.hpp>
#include <com/sun/star/ucb/NameClash.hpp>
#include <com/sun/star/ucb/NameClashException.hpp>
#include <com/sun/star/ucb/OpenCommandArgument2.hpp>
#include <com/sun/star/ucb/OpenMode.hpp>
#include <com/sun/star/ucb/PostCommandArgument2.hpp>
#include <com/sun/star/ucb/TransferInfo.hpp>
-#include <com/sun/star/ucb/XCommandInfo.hpp>
-#include <com/sun/star/ucb/XPersistentPropertySet.hpp>
-#include <com/sun/star/ucb/MissingInputStreamException.hpp>
-#include <com/sun/star/ucb/MissingPropertiesException.hpp>
#include <com/sun/star/ucb/UnsupportedCommandException.hpp>
#include <com/sun/star/ucb/UnsupportedDataSinkException.hpp>
#include <com/sun/star/ucb/UnsupportedNameClashException.hpp>
#include <com/sun/star/ucb/UnsupportedOpenModeException.hpp>
-#include <ucbhelper/contentidentifier.hxx>
-#include <ucbhelper/propertyvalueset.hxx>
-#include <ucbhelper/simpleinteractionrequest.hxx>
-#include <ucbhelper/cancelcommandexecution.hxx>
+#include <com/sun/star/ucb/XCommandInfo.hpp>
+#include <com/sun/star/ucb/XPersistentPropertySet.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+
#include "webdavcontent.hxx"
#include "webdavprovider.hxx"
#include "webdavresultset.hxx"
@@ -95,230 +97,6 @@ using namespace webdav_ucp;
//=========================================================================
//=========================================================================
//
-// CommandEnvironment_Impl Implementation.
-//
-//=========================================================================
-//=========================================================================
-
-class CommandEnvironment_Impl : public cppu::OWeakObject,
- public ucb::XCommandEnvironment,
- public task::XInteractionHandler
-{
-public:
-
- CommandEnvironment_Impl(
- const uno::Reference< lang::XMultiServiceFactory >& xSMgr )
- : m_xSMgr( xSMgr )
- {
- }
-
- // XInterface
- XINTERFACE_DECL()
-
- // XCommandEnvironment
- virtual uno::Reference< task::XInteractionHandler > SAL_CALL
- getInteractionHandler( )
- throw (uno::RuntimeException)
- {
- return this;
- }
-
- virtual uno::Reference< ucb::XProgressHandler > SAL_CALL
- getProgressHandler( )
- throw (uno::RuntimeException)
- {
- return 0;
- }
-
- // XInteractionHandler
- virtual void SAL_CALL
- handle( const uno::Reference< task::XInteractionRequest >& Request )
- throw (uno::RuntimeException);
-
-private:
- void
- handleAuthenticationRequest(
- ucb::AuthenticationRequest const&,
- uno::Sequence< uno::Reference< task::XInteractionContinuation > > const&)
- SAL_THROW((uno::RuntimeException))
- {
- }
-
- uno::Reference< lang::XMultiServiceFactory > m_xSMgr;
-};
-
-//=========================================================================
-void SAL_CALL CommandEnvironment_Impl::acquire()
- throw()
-{
- OWeakObject::acquire();
-}
-
-//=========================================================================
-void SAL_CALL CommandEnvironment_Impl::release()
- throw()
-{
- OWeakObject::release();
-}
-
-//=========================================================================
-uno::Any SAL_CALL CommandEnvironment_Impl::queryInterface(
- const uno::Type & rType )
- throw( uno::RuntimeException )
-{
- uno::Any aRet = cppu::queryInterface(
- rType,
- static_cast< ucb::XCommandEnvironment * >( this ),
- static_cast< task::XInteractionHandler * >( this ) );
- return aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType );
-}
-
-//=========================================================================
-void SAL_CALL CommandEnvironment_Impl::handle(
- const uno::Reference< task::XInteractionRequest >& rIRequest )
- throw (uno::RuntimeException)
-{
- if (!rIRequest.is())
- return;
-
- uno::Any aAnyRequest(rIRequest->getRequest());
-
- ucb::AuthenticationRequest rRequest;
- if (!(aAnyRequest >>= rRequest))
- return;
-
- uno::Sequence< uno::Reference< task::XInteractionContinuation > >
- rContinuations = rIRequest->getContinuations();
-
- uno::Reference< ucb::XInteractionSupplyAuthentication >
- xSupplyAuthentication;
-
- for (sal_Int32 i = 0; i < rContinuations.getLength(); ++i)
- {
- xSupplyAuthentication
- = uno::Reference< ucb::XInteractionSupplyAuthentication >(
- rContinuations[i], uno::UNO_QUERY );
- if( xSupplyAuthentication.is() )
- break;
- }
-
- if (!xSupplyAuthentication.is())
- return;
-
- ucb::RememberAuthentication eDefault;
- uno::Sequence< ucb::RememberAuthentication > aModes(
- xSupplyAuthentication->getRememberPasswordModes(eDefault));
- bool bRememberPersistent = false;
- for (sal_Int32 i = 0; i < aModes.getLength(); ++i)
- {
- if (aModes[i] == ucb::RememberAuthentication_PERSISTENT)
- {
- bRememberPersistent = true;
- break;
- }
- }
-
- uno::Reference< task::XPasswordContainer > xContainer;
- try
- {
- xContainer
- = uno::Reference< task::XPasswordContainer >(
- m_xSMgr->createInstance(
- rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
- "com.sun.star.task.PasswordContainer"))),
- uno::UNO_QUERY);
- }
- catch (uno::Exception const &)
- {
- }
-
- // xContainer works with userName passwdSequences pairs:
- if (xContainer.is() && rRequest.HasUserName && rRequest.HasPassword )
- {
- try
- {
- if (rRequest.UserName.getLength() == 0)
- {
- task::UrlRecord
- aRec(xContainer->find(rRequest.ServerName, this));
- if (aRec.UserList.getLength() != 0)
- {
- if (xSupplyAuthentication->canSetUserName())
- xSupplyAuthentication->
- setUserName(aRec.UserList[0].UserName.getStr());
- if (xSupplyAuthentication->canSetPassword())
- {
- OSL_ENSURE(aRec.UserList[0].Passwords.getLength() != 0,
- "empty password list");
- xSupplyAuthentication->
- setPassword(aRec.UserList[0].Passwords[0].getStr());
- }
- if (aRec.UserList[0].Passwords.getLength() > 1)
- {
- if (rRequest.HasRealm)
- {
- if (xSupplyAuthentication->canSetRealm())
- xSupplyAuthentication->
- setRealm(aRec.UserList[0].Passwords[1].
- getStr());
- }
- else if (xSupplyAuthentication->canSetAccount())
- xSupplyAuthentication->
- setAccount(aRec.UserList[0].Passwords[1].
- getStr());
- }
- xSupplyAuthentication->select();
- return;
- }
- }
- else
- {
- task::UrlRecord
- aRec(xContainer->findForName(rRequest.ServerName,
- rRequest.UserName,
- this));
- if (aRec.UserList.getLength() != 0)
- {
- OSL_ENSURE(aRec.UserList[0].Passwords.getLength() != 0,
- "empty password list");
- if (!rRequest.HasPassword
- || rRequest.Password != aRec.UserList[0].Passwords[0])
- {
- if (xSupplyAuthentication->canSetUserName())
- xSupplyAuthentication->
- setUserName(aRec.UserList[0].UserName.getStr());
- if (xSupplyAuthentication->canSetPassword())
- xSupplyAuthentication->
- setPassword(aRec.UserList[0].Passwords[0].
- getStr());
- if (aRec.UserList[0].Passwords.getLength() > 1)
- {
- if (rRequest.HasRealm)
- {
- if (xSupplyAuthentication->canSetRealm())
- xSupplyAuthentication->
- setRealm(aRec.UserList[0].Passwords[1].
- getStr());
- }
- else if (xSupplyAuthentication->canSetAccount())
- xSupplyAuthentication->
- setAccount(aRec.UserList[0].Passwords[1].
- getStr());
- }
- xSupplyAuthentication->select();
- return;
- }
- }
- }
- }
- catch (task::NoMasterException const &)
- {} // user did not enter master password
- }
-}
-
-//=========================================================================
-//=========================================================================
-//
// Content Implementation.
//
//=========================================================================
@@ -425,9 +203,28 @@ uno::Any SAL_CALL Content::queryInterface( const uno::Type & rType )
{
try
{
- return isFolder( new CommandEnvironment_Impl(m_xSMgr) )
- ? aRet
- : uno::Any();
+ uno::Reference< beans::XPropertySet > const xProps(
+ m_xSMgr, uno::UNO_QUERY_THROW );
+ uno::Reference< uno::XComponentContext > xCtx;
+ xCtx.set( xProps->getPropertyValue(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ) ) ),
+ uno::UNO_QUERY_THROW );
+
+ uno::Reference< task::XInteractionHandler > xIH(
+ task::PasswordContainerInteractionHandler::create( xCtx ) );
+
+ // Supply a command env to isFolder() that contains an interaction
+ // handler that uses the password container service to obtain
+ // credentials without displaying a password gui.
+
+ uno::Reference< ucb::XCommandEnvironment > xCmdEnv(
+ ucb::CommandEnvironment::create(
+ xCtx,
+ xIH,
+ uno::Reference< ucb::XProgressHandler >() ) );
+
+ return isFolder( xCmdEnv ) ? aRet : uno::Any();
}
catch ( uno::RuntimeException const & )
{
@@ -609,9 +406,11 @@ uno::Any SAL_CALL Content::execute(
ucb::CommandAbortedException,
uno::RuntimeException )
{
- OSL_TRACE( "Content::execute: start %s",
+ OSL_TRACE( ">>>>> Content::execute: start: command: %s, env: %s",
rtl::OUStringToOString( aCommand.Name,
- RTL_TEXTENCODING_UTF8 ).getStr() );
+ RTL_TEXTENCODING_UTF8 ).getStr(),
+ Environment.is() ? "present" : "missing" );
+
uno::Any aRet;
if ( aCommand.Name.equalsAsciiL(
@@ -856,7 +655,7 @@ uno::Any SAL_CALL Content::execute(
// Unreachable
}
- OSL_TRACE( "Content::execute: end %s",
+ OSL_TRACE( "<<<<< Content::execute: end: command: %s",
rtl::OUStringToOString( aCommand.Name,
RTL_TEXTENCODING_UTF8 ).getStr() );
diff --git a/uui/source/iahndl.cxx b/uui/source/iahndl.cxx
index 29f380b2a7a0..e64ac960d08e 100644
--- a/uui/source/iahndl.cxx
+++ b/uui/source/iahndl.cxx
@@ -67,7 +67,6 @@
#include "com/sun/star/task/ErrorCodeIOException.hpp"
#include "com/sun/star/task/ErrorCodeRequest.hpp"
#include "com/sun/star/task/MasterPasswordRequest.hpp"
-#include "com/sun/star/task/NoMasterException.hpp"
#include "com/sun/star/task/DocumentMacroConfirmationRequest.hpp"
#include "com/sun/star/task/DocumentMacroConfirmationRequest2.hpp"
#include "com/sun/star/task/XInteractionAbort.hpp"
@@ -76,8 +75,6 @@
#include "com/sun/star/task/XInteractionPassword.hpp"
#include "com/sun/star/task/XInteractionRequest.hpp"
#include "com/sun/star/task/XInteractionRetry.hpp"
-#include "com/sun/star/task/XPasswordContainer.hpp"
-#include "com/sun/star/task/XUrlContainer.hpp"
#include "com/sun/star/task/XInteractionAskLater.hpp"
#include "com/sun/star/ucb/AuthenticationRequest.hpp"
#include "com/sun/star/ucb/URLAuthenticationRequest.hpp"
@@ -141,6 +138,7 @@
#include "trylater.hxx"
#include "lockfailed.hxx"
#include "loginerr.hxx"
+#include "passwordcontainer.hxx"
#include <comphelper/processfactory.hxx>
#include <svtools/zforlist.hxx>
@@ -1619,38 +1617,6 @@ rtl::OUString UUIInteractionHelper::getContextProperty() SAL_THROW(())
return rtl::OUString();
}
-bool
-UUIInteractionHelper::initPasswordContainer(
- star::uno::Reference< star::task::XPasswordContainer > * pContainer,
- star::uno::Reference< star::task::XUrlContainer > * pUrlContainer)
- const SAL_THROW(())
-{
- OSL_ENSURE(pContainer, "specification violation");
- if (!pContainer->is() && m_xServiceFactory.is())
- try
- {
- *pContainer
- = star::uno::Reference< star::task::XPasswordContainer >(
- m_xServiceFactory->
- createInstance(
- rtl::OUString(
- RTL_CONSTASCII_USTRINGPARAM(
- "com.sun.star.task.PasswordContainer"))),
- star::uno::UNO_QUERY);
-
- if ( pContainer->is() )
- {
- *pUrlContainer = star::uno::Reference< star::task::XUrlContainer >( *pContainer, UNO_QUERY );
- OSL_ENSURE( pUrlContainer->is(), "Got no XUrlContainer!" );
- }
- }
- catch (star::uno::Exception const &)
- {}
- OSL_ENSURE(pContainer->is(), "unexpected situation");
- return pContainer->is() && pUrlContainer->is();
-}
-
-
String GetContentPart( const String& _rRawString )
{
// search over some parts to find a string
@@ -2218,6 +2184,7 @@ UUIInteractionHelper::executeMessageBox(
return aResult;
}
+
star::uno::Reference< star::task::XInteractionHandler >
UUIInteractionHelper::getInteractionHandler() const
SAL_THROW((star::uno::RuntimeException))
@@ -2245,80 +2212,6 @@ UUIInteractionHelper::getInteractionHandler() const
return xIH;
}
-namespace
-{
-bool fillContinuation(
- bool bUseSystemCredentials,
- const star::ucb::AuthenticationRequest & rRequest,
- const star::task::UrlRecord & aRec,
- const star::uno::Reference< star::ucb::XInteractionSupplyAuthentication > &
- xSupplyAuthentication,
- const star::uno::Reference< star::ucb::XInteractionSupplyAuthentication2 > &
- xSupplyAuthentication2,
- bool bCanUseSystemCredentials,
- bool bCheckForEqualPasswords )
-{
- if ( bUseSystemCredentials )
- {
- // "use system creds" record found.
- // Wants client that we use it?
- if ( xSupplyAuthentication2.is() &&
- bCanUseSystemCredentials )
- {
- xSupplyAuthentication2->setUseSystemCredentials( sal_True );
- return true;
- }
- return false;
- }
- else if (aRec.UserList.getLength() != 0)
- {
- if (aRec.UserList[0].Passwords.getLength() == 0)
- {
- // Password sequence can be empty, for instance if master
- // password was not given (e.g. master pw dialog canceled)
- // pw container does not throw NoMasterException in this case.
- // bug???
- return false;
- }
-
- // "user/pass" record found.
- if (!bCheckForEqualPasswords || !rRequest.HasPassword
- || rRequest.Password != aRec.UserList[0].Passwords[0]) // failed login attempt?
- {
- if (xSupplyAuthentication->canSetUserName())
- xSupplyAuthentication->
- setUserName(aRec.UserList[0].UserName.getStr());
-
- if (xSupplyAuthentication->canSetPassword())
- xSupplyAuthentication->
- setPassword(aRec.UserList[0].Passwords[0].getStr());
- if (aRec.UserList[0].Passwords.getLength() > 1)
- {
- if (rRequest.HasRealm)
- {
- if (xSupplyAuthentication->canSetRealm())
- xSupplyAuthentication->
- setRealm(aRec.UserList[0].Passwords[1].
- getStr());
- }
- else if (xSupplyAuthentication->canSetAccount())
- xSupplyAuthentication->
- setAccount(aRec.UserList[0].Passwords[1].
- getStr());
- }
-
- if ( xSupplyAuthentication2.is() &&
- bCanUseSystemCredentials )
- xSupplyAuthentication2->setUseSystemCredentials( sal_False );
-
- return true;
- }
- }
- return false;
-}
-
-}
-
void
UUIInteractionHelper::handleAuthenticationRequest(
star::ucb::AuthenticationRequest const & rRequest,
@@ -2328,8 +2221,6 @@ UUIInteractionHelper::handleAuthenticationRequest(
const rtl::OUString & rURL)
SAL_THROW((star::uno::RuntimeException))
{
- star::uno::Reference< star::task::XInteractionHandler > xIH;
-
star::uno::Reference< star::task::XInteractionRetry > xRetry;
star::uno::Reference< star::task::XInteractionAbort > xAbort;
star::uno::Reference< star::ucb::XInteractionSupplyAuthentication >
@@ -2339,7 +2230,25 @@ UUIInteractionHelper::handleAuthenticationRequest(
getContinuations(
rContinuations,
0, 0, &xRetry, &xAbort,
- &xSupplyAuthentication, &xSupplyAuthentication2, 0, 0, 0 );
+ &xSupplyAuthentication, &xSupplyAuthentication2, 0, 0, 0);
+
+ star::uno::Reference< star::task::XInteractionHandler > xIH(
+ getInteractionHandler());
+
+ //////////////////////////
+ // First, try to obatin credentials from password container service.
+ uui::PasswordContainerHelper aPwContainerHelper(m_xServiceFactory);
+ if (aPwContainerHelper.handleAuthenticationRequest(rRequest,
+ xSupplyAuthentication,
+ rURL,
+ xIH))
+ {
+ xSupplyAuthentication->select();
+ return;
+ }
+
+ //////////////////////////
+ // Second, try to obtain credentials from user via password dialog.
bool bRemember;
bool bRememberPersistent;
if (xSupplyAuthentication.is())
@@ -2367,8 +2276,8 @@ UUIInteractionHelper::handleAuthenticationRequest(
if (xSupplyAuthentication2.is())
{
bCanUseSystemCredentials
- = xSupplyAuthentication2->canUseSystemCredentials(
- bDefaultUseSystemCredentials );
+ = xSupplyAuthentication2->canUseSystemCredentials(
+ bDefaultUseSystemCredentials);
}
else
{
@@ -2376,96 +2285,6 @@ UUIInteractionHelper::handleAuthenticationRequest(
bDefaultUseSystemCredentials = sal_False;
}
- com::sun::star::uno::Reference< com::sun::star::task::XPasswordContainer >
- xContainer;
- com::sun::star::uno::Reference< com::sun::star::task::XUrlContainer >
- xUrlContainer;
-
- if ( bCanUseSystemCredentials && initPasswordContainer( &xContainer, &xUrlContainer ) )
- {
- // Runtime / Persistent info avail for current auth request?
-
- rtl::OUString aResult = xUrlContainer->findUrl(
- rURL.getLength() ? rURL : rRequest.ServerName );
- if ( aResult.getLength() > 0 )
- {
- if ( fillContinuation( true,
- rRequest,
- star::task::UrlRecord(),
- xSupplyAuthentication,
- xSupplyAuthentication2,
- bCanUseSystemCredentials,
- false ) )
- {
- xSupplyAuthentication->select();
- return;
- }
- }
- }
-
- // xContainer works with userName passwdSequences pairs:
- if (rRequest.HasUserName
- && rRequest.HasPassword
- && initPasswordContainer(&xContainer, &xUrlContainer))
- {
- xIH = getInteractionHandler();
- try
- {
- if (rRequest.UserName.getLength() == 0)
- {
- star::task::UrlRecord aRec;
- if ( rURL.getLength() )
- aRec = xContainer->find(rURL, xIH);
-
- if ( aRec.UserList.getLength() == 0 )
- {
- // compat: try server name.
- aRec = xContainer->find(rRequest.ServerName, xIH);
- }
-
- if ( fillContinuation( false,
- rRequest,
- aRec,
- xSupplyAuthentication,
- xSupplyAuthentication2,
- bCanUseSystemCredentials,
- false ) )
- {
- xSupplyAuthentication->select();
- return;
- }
- }
- else
- {
- star::task::UrlRecord aRec;
- if ( rURL.getLength() )
- aRec = xContainer->findForName(
- rURL, rRequest.UserName, xIH);
-
- if ( aRec.UserList.getLength() == 0 )
- {
- // compat: try server name.
- aRec = xContainer->findForName(
- rRequest.ServerName, rRequest.UserName, xIH);
- }
-
- if ( fillContinuation( false,
- rRequest,
- aRec,
- xSupplyAuthentication,
- xSupplyAuthentication2,
- bCanUseSystemCredentials,
- true ) )
- {
- xSupplyAuthentication->select();
- return;
- }
- }
- }
- catch (star::task::NoMasterException const &)
- {} // user did not enter master password
- }
-
LoginErrorInfo aInfo;
aInfo.SetTitle(rRequest.ServerName);
aInfo.SetServer(rRequest.ServerName);
@@ -2478,7 +2297,7 @@ UUIInteractionHelper::handleAuthenticationRequest(
aInfo.SetErrorText(rRequest.Diagnostic);
aInfo.SetPersistentPassword(bRememberPersistent);
aInfo.SetSavePassword(bRemember);
- aInfo.SetCanUseSystemCredentials( bCanUseSystemCredentials );
+ aInfo.SetCanUseSystemCredentials(bCanUseSystemCredentials);
aInfo.SetIsUseSystemCredentials( bDefaultUseSystemCredentials );
aInfo.SetModifyAccount(rRequest.HasAccount
&& xSupplyAuthentication.is()
@@ -2519,48 +2338,39 @@ UUIInteractionHelper::handleAuthenticationRequest(
xSupplyAuthentication->select();
}
+ //////////////////////////
+ // Third, store credentials in password container.
+
if ( aInfo.GetIsUseSystemCredentials() )
{
if (aInfo.GetIsSavePassword())
{
- if ( initPasswordContainer(&xContainer, &xUrlContainer) )
- xUrlContainer->addUrl(
- rURL.getLength() ? rURL : rRequest.ServerName,
- bRememberPersistent );
+ aPwContainerHelper.addRecord(
+ rURL.getLength() ? rURL : rRequest.ServerName,
+ rtl::OUString(), // empty u/p -> sys creds
+ uno::Sequence< rtl::OUString >(),
+ xIH,
+ bRememberPersistent);
}
}
- else if (aInfo.GetUserName().Len() != 0 // Empty user name can not be valid:
- && initPasswordContainer(&xContainer, &xUrlContainer))
+ // Empty user name can not be valid:
+ else if (aInfo.GetUserName().Len() != 0)
{
- try
+ if (aInfo.GetIsSavePassword())
{
- if (aInfo.GetIsSavePassword())
- {
- star::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 (!xIH.is())
- xIH = getInteractionHandler();
-
- if (bRememberPersistent)
- xContainer->addPersistent(
- rURL.getLength() ? rURL : rRequest.ServerName,
- aInfo.GetUserName(),
- aPassList,
- xIH);
- else
- xContainer->add(
- rURL.getLength() ? rURL : rRequest.ServerName,
- aInfo.GetUserName(),
- aPassList,
- xIH);
- }
+ star::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);
}
- catch (star::task::NoMasterException const &)
- {} // user did not enter master password
}
break;
diff --git a/uui/source/iahndl.hxx b/uui/source/iahndl.hxx
index bea53e436c6d..5693a5cf149b 100644
--- a/uui/source/iahndl.hxx
+++ b/uui/source/iahndl.hxx
@@ -45,14 +45,12 @@
#include "com/sun/star/task/PasswordRequestMode.hpp"
#include "com/sun/star/task/FutureDocumentVersionProductUpdateRequest.hpp"
#include "com/sun/star/security/DocumentSignatureInformation.hpp"
+#include "com/sun/star/security/XCertificate.hpp"
+#include "com/sun/star/xml/crypto/XSecurityEnvironment.hpp"
#include "tools/solar.h"
#include "tools/errcode.hxx"
#include "vcl/wintypes.hxx"
#include "fltdlg.hxx"
-#include <com/sun/star/security/XCertificate.hpp>
-#ifndef _COM_SUN_STAR_XML_CRYPTO_XXSECURITYENVIRONMENT_HPP_
-#include <com/sun/star/xml/crypto/XSecurityEnvironment.hpp>
-#endif
class Window;
class LoginErrorInfo;
@@ -99,8 +97,6 @@ namespace com { namespace sun { namespace star {
class XInteractionContinuation;
class XInteractionHandler;
class XInteractionRequest;
- class XPasswordContainer;
- class XUrlContainer;
}
namespace ucb {
class AuthenticationRequest;
@@ -181,15 +177,6 @@ private:
rtl::OUString getContextProperty() SAL_THROW(());
- bool
- initPasswordContainer(com::sun::star::uno::Reference<
- com::sun::star::task::XPasswordContainer > *
- pContainer,
- com::sun::star::uno::Reference<
- com::sun::star::task::XUrlContainer > *
- pUrlContainer)
- const SAL_THROW(());
-
com::sun::star::uno::Reference< com::sun::star::task::XInteractionHandler >
getInteractionHandler() const
SAL_THROW((com::sun::star::uno::RuntimeException));
diff --git a/uui/source/makefile.mk b/uui/source/makefile.mk
index 95b998ffd36d..5c70719cd91c 100644
--- a/uui/source/makefile.mk
+++ b/uui/source/makefile.mk
@@ -56,7 +56,8 @@ SLOFILES = \
$(SLO)$/alreadyopen.obj\
$(SLO)$/lockfailed.obj\
$(SLO)$/trylater.obj\
- $(SLO)$/newerverwarn.obj
+ $(SLO)$/newerverwarn.obj\
+ $(SLO)$/passwordcontainer.obj
SRS1NAME=$(TARGET)
SRC1FILES = \
diff --git a/uui/source/passwordcontainer.cxx b/uui/source/passwordcontainer.cxx
new file mode 100644
index 000000000000..4802f92af88b
--- /dev/null
+++ b/uui/source/passwordcontainer.cxx
@@ -0,0 +1,473 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: $
+ * $Revision: $
+ *
+ * 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 "cppuhelper/factory.hxx"
+
+#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/XPasswordContainer.hpp"
+#include "com/sun/star/task/XUrlContainer.hpp"
+#include "com/sun/star/ucb/AuthenticationRequest.hpp"
+#include "com/sun/star/ucb/URLAuthenticationRequest.hpp"
+#include "com/sun/star/ucb/XInteractionSupplyAuthentication.hpp"
+#include "com/sun/star/ucb/XInteractionSupplyAuthentication2.hpp"
+
+#include "passwordcontainer.hxx"
+
+using namespace com::sun::star;
+
+namespace {
+
+//=========================================================================
+bool fillContinuation(
+ bool bUseSystemCredentials,
+ const ucb::AuthenticationRequest & rRequest,
+ const task::UrlRecord & aRec,
+ const uno::Reference< ucb::XInteractionSupplyAuthentication > &
+ xSupplyAuthentication,
+ const uno::Reference< ucb::XInteractionSupplyAuthentication2 > &
+ xSupplyAuthentication2,
+ bool bCanUseSystemCredentials,
+ bool bCheckForEqualPasswords )
+{
+ if ( bUseSystemCredentials )
+ {
+ // "use system creds" record found.
+ // Wants client that we use it?
+ if ( xSupplyAuthentication2.is() && bCanUseSystemCredentials )
+ {
+ xSupplyAuthentication2->setUseSystemCredentials( sal_True );
+ return true;
+ }
+ return false;
+ }
+ else if (aRec.UserList.getLength() != 0)
+ {
+ if (aRec.UserList[0].Passwords.getLength() == 0)
+ {
+ // Password sequence can be empty, for instance if master
+ // password was not given (e.g. master pw dialog canceled)
+ // pw container does not throw NoMasterException in this case.
+ // bug???
+ return false;
+ }
+
+ // "user/pass" record found.
+ if (!bCheckForEqualPasswords || !rRequest.HasPassword
+ || rRequest.Password != aRec.UserList[0].Passwords[0]) // failed login attempt?
+ {
+ if (xSupplyAuthentication->canSetUserName())
+ xSupplyAuthentication->
+ setUserName(aRec.UserList[0].UserName.getStr());
+
+ if (xSupplyAuthentication->canSetPassword())
+ xSupplyAuthentication->
+ setPassword(aRec.UserList[0].Passwords[0].getStr());
+ if (aRec.UserList[0].Passwords.getLength() > 1)
+ {
+ if (rRequest.HasRealm)
+ {
+ if (xSupplyAuthentication->canSetRealm())
+ xSupplyAuthentication->
+ setRealm(aRec.UserList[0].Passwords[1].
+ getStr());
+ }
+ else if (xSupplyAuthentication->canSetAccount())
+ xSupplyAuthentication->
+ setAccount(aRec.UserList[0].Passwords[1].
+ getStr());
+ }
+
+ if ( xSupplyAuthentication2.is() && bCanUseSystemCredentials )
+ xSupplyAuthentication2->setUseSystemCredentials( sal_False );
+
+ return true;
+ }
+ }
+ return false;
+}
+
+} // namespace
+
+namespace uui {
+
+//=========================================================================
+PasswordContainerHelper::PasswordContainerHelper(
+ uno::Reference< lang::XMultiServiceFactory > const & xServiceFactory )
+{
+ OSL_ENSURE(xServiceFactory.is(), "no service factory given!");
+ if (xServiceFactory.is())
+ try
+ {
+ m_xPasswordContainer
+ = uno::Reference< task::XPasswordContainer >(
+ xServiceFactory->
+ createInstance(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "com.sun.star.task.PasswordContainer"))),
+ uno::UNO_QUERY);
+ }
+ catch (uno::Exception const &)
+ {}
+ OSL_ENSURE(m_xPasswordContainer.is(),
+ "unable to instanciate password container service");
+}
+
+//=========================================================================
+bool PasswordContainerHelper::handleAuthenticationRequest(
+ ucb::AuthenticationRequest const & rRequest,
+ uno::Reference< ucb::XInteractionSupplyAuthentication > const &
+ xSupplyAuthentication,
+ rtl::OUString const & rURL,
+ uno::Reference< task::XInteractionHandler > const & xIH )
+ SAL_THROW((uno::RuntimeException))
+{
+ // Is continuation even a XInteractionSupplyAuthentication2, which
+ // is derived from XInteractionSupplyAuthentication?
+ uno::Reference< ucb::XInteractionSupplyAuthentication2 >
+ xSupplyAuthentication2(xSupplyAuthentication, uno::UNO_QUERY);
+
+ sal_Bool bCanUseSystemCredentials = sal_False;
+ if (xSupplyAuthentication2.is())
+ {
+ sal_Bool bDefaultUseSystemCredentials;
+ bCanUseSystemCredentials
+ = xSupplyAuthentication2->canUseSystemCredentials(
+ bDefaultUseSystemCredentials );
+ }
+
+ uno::Reference< task::XPasswordContainer > xContainer(
+ m_xPasswordContainer );
+ uno::Reference< task::XUrlContainer > xUrlContainer(
+ m_xPasswordContainer, uno::UNO_QUERY );
+ OSL_ENSURE( xUrlContainer.is(), "Got no XUrlContainer!" );
+
+ if ( !xContainer.is() || !xUrlContainer.is() )
+ return false;
+
+ if ( bCanUseSystemCredentials )
+ {
+ // Runtime / Persistent info avail for current auth request?
+
+ rtl::OUString aResult = xUrlContainer->findUrl(
+ rURL.getLength() ? rURL : rRequest.ServerName );
+ if ( aResult.getLength() > 0 )
+ {
+ if ( fillContinuation( true,
+ rRequest,
+ task::UrlRecord(),
+ xSupplyAuthentication,
+ xSupplyAuthentication2,
+ bCanUseSystemCredentials,
+ false ) )
+ {
+ return true;
+ }
+ }
+ }
+
+ // xContainer works with userName passwdSequences pairs:
+ if (rRequest.HasUserName && rRequest.HasPassword)
+ {
+ try
+ {
+ if (rRequest.UserName.getLength() == 0)
+ {
+ task::UrlRecord aRec;
+ if ( rURL.getLength() )
+ aRec = xContainer->find(rURL, xIH);
+
+ if ( aRec.UserList.getLength() == 0 )
+ {
+ // compat: try server name.
+ aRec = xContainer->find(rRequest.ServerName, xIH);
+ }
+
+ if ( fillContinuation( false,
+ rRequest,
+ aRec,
+ xSupplyAuthentication,
+ xSupplyAuthentication2,
+ bCanUseSystemCredentials,
+ false ) )
+ {
+ return true;
+ }
+ }
+ else
+ {
+ task::UrlRecord aRec;
+ if ( rURL.getLength() )
+ aRec = xContainer->findForName(
+ rURL, rRequest.UserName, xIH);
+
+ if ( aRec.UserList.getLength() == 0 )
+ {
+ // compat: try server name.
+ aRec = xContainer->findForName(
+ rRequest.ServerName, rRequest.UserName, xIH);
+ }
+
+ if ( fillContinuation( false,
+ rRequest,
+ aRec,
+ xSupplyAuthentication,
+ xSupplyAuthentication2,
+ bCanUseSystemCredentials,
+ true ) )
+ {
+ return true;
+ }
+ }
+ }
+ catch (task::NoMasterException const &)
+ {} // user did not enter master password
+ }
+ return false;
+}
+
+//=========================================================================
+bool PasswordContainerHelper::addRecord(
+ rtl::OUString const & rURL,
+ rtl::OUString const & rUsername,
+ uno::Sequence< rtl::OUString > const & rPasswords,
+ uno::Reference< task::XInteractionHandler > const & xIH,
+ bool bPersist )
+ SAL_THROW((uno::RuntimeException))
+{
+ try
+ {
+ if ( rUsername.getLength() )
+ {
+ OSL_ENSURE( m_xPasswordContainer.is(),
+ "Got no XPasswordContainer!" );
+ if ( !m_xPasswordContainer.is() )
+ return false;
+
+ if ( bPersist )
+ m_xPasswordContainer->addPersistent( rURL,
+ rUsername,
+ rPasswords,
+ xIH );
+ else
+ m_xPasswordContainer->add( rURL,
+ rUsername,
+ rPasswords,
+ xIH );
+ }
+ else
+ {
+ uno::Reference< task::XUrlContainer >
+ xContainer( m_xPasswordContainer, uno::UNO_QUERY );
+ OSL_ENSURE( xContainer.is(), "Got no XUrlContainer!" );
+ if ( !xContainer.is() )
+ return false;
+
+ xContainer->addUrl( rURL, bPersist );
+ }
+ }
+ catch ( task::NoMasterException const & )
+ {
+ // user did not enter master password
+ return false;
+ }
+ return true;
+}
+
+//=========================================================================
+//=========================================================================
+//=========================================================================
+
+PasswordContainerInteractionHandler::PasswordContainerInteractionHandler(
+ const uno::Reference< lang::XMultiServiceFactory >& xSMgr )
+: m_aPwContainerHelper( xSMgr )
+{
+}
+
+//=========================================================================
+// virtual
+PasswordContainerInteractionHandler::~PasswordContainerInteractionHandler()
+{
+}
+
+//=========================================================================
+//
+// XServiceInfo methods.
+//
+//=========================================================================
+
+// virtual
+::rtl::OUString SAL_CALL
+PasswordContainerInteractionHandler::getImplementationName()
+ throw ( uno::RuntimeException )
+{
+ return getImplementationName_Static();
+}
+
+//=========================================================================
+// virtual
+sal_Bool SAL_CALL
+PasswordContainerInteractionHandler::supportsService(
+ const ::rtl::OUString& ServiceName )
+ throw ( uno::RuntimeException )
+{
+ uno::Sequence< rtl::OUString > aSNL = getSupportedServiceNames();
+ const rtl::OUString * pArray = aSNL.getConstArray();
+ for ( sal_Int32 i = 0; i < aSNL.getLength(); i++ )
+ {
+ if ( pArray[ i ] == ServiceName )
+ return sal_True;
+ }
+ return sal_False;
+}
+
+//=========================================================================
+// virtual
+uno::Sequence< ::rtl::OUString > SAL_CALL
+PasswordContainerInteractionHandler::getSupportedServiceNames()
+ throw ( uno::RuntimeException )
+{
+ return getSupportedServiceNames_Static();
+}
+
+//=========================================================================
+// static
+rtl::OUString
+PasswordContainerInteractionHandler::getImplementationName_Static()
+{
+ return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
+ "com.sun.star.comp.uui.PasswordContainerInteractionHandler" ) );
+}
+
+//=========================================================================
+// static
+uno::Sequence< rtl::OUString >
+PasswordContainerInteractionHandler::getSupportedServiceNames_Static()
+{
+ uno::Sequence< rtl::OUString > aSNS( 1 );
+ aSNS.getArray()[ 0 ]
+ = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
+ "com.sun.star.task.PasswordContainerInteractionHandler" ) );
+ return aSNS;
+}
+
+//=========================================================================
+//
+// XInteractionHandler methods.
+//
+//=========================================================================
+
+// virtual
+void SAL_CALL
+PasswordContainerInteractionHandler::handle(
+ const uno::Reference< task::XInteractionRequest >& rRequest )
+ throw ( uno::RuntimeException )
+{
+ if ( !rRequest.is() )
+ return;
+
+ uno::Any aAnyRequest( rRequest->getRequest() );
+
+ ucb::AuthenticationRequest aAuthenticationRequest;
+ if ( !( aAnyRequest >>= aAuthenticationRequest ) )
+ return;
+
+ rtl::OUString aURL;
+ ucb::URLAuthenticationRequest aURLAuthenticationRequest;
+ if ( aAnyRequest >>= aURLAuthenticationRequest )
+ aURL = aURLAuthenticationRequest.URL;
+
+ uno::Sequence< uno::Reference< task::XInteractionContinuation > >
+ rContinuations = rRequest->getContinuations();
+
+ uno::Reference< ucb::XInteractionSupplyAuthentication >
+ xSupplyAuthentication;
+
+ for ( sal_Int32 i = 0; i < rContinuations.getLength(); ++i )
+ {
+ xSupplyAuthentication
+ = uno::Reference< ucb::XInteractionSupplyAuthentication >(
+ rContinuations[i], uno::UNO_QUERY );
+ if( xSupplyAuthentication.is() )
+ break;
+ }
+
+ if ( !xSupplyAuthentication.is() )
+ return;
+
+ // Try to obatin credentials from password container.
+ if ( m_aPwContainerHelper.
+ handleAuthenticationRequest( aAuthenticationRequest,
+ xSupplyAuthentication,
+ aURL,
+ // @@@ FIXME: this not able to
+ // handle master pw request!
+ // master pw request is never
+ // solvabe without UI!
+ this ) )
+ {
+ // successfully handled
+ xSupplyAuthentication->select();
+ }
+}
+
+//=========================================================================
+//
+// Service factory implementation.
+//
+//=========================================================================
+
+static uno::Reference< uno::XInterface > SAL_CALL
+PasswordContainerInteractionHandler_CreateInstance(
+ const uno::Reference< lang::XMultiServiceFactory> & rSMgr )
+ throw( uno::Exception )
+{
+ lang::XServiceInfo * pX = static_cast< lang::XServiceInfo * >(
+ new PasswordContainerInteractionHandler( rSMgr ) );
+ return uno::Reference< uno::XInterface >::query( pX );
+}
+
+//=========================================================================
+// static
+uno::Reference< lang::XSingleServiceFactory >
+PasswordContainerInteractionHandler::createServiceFactory(
+ const uno::Reference< lang::XMultiServiceFactory >& rxServiceMgr )
+{
+ return uno::Reference< lang::XSingleServiceFactory >(
+ cppu::createOneInstanceFactory(
+ rxServiceMgr,
+ PasswordContainerInteractionHandler::getImplementationName_Static(),
+ PasswordContainerInteractionHandler_CreateInstance,
+ PasswordContainerInteractionHandler::getSupportedServiceNames_Static() ) );
+}
+
+} // namespace uui
diff --git a/uui/source/passwordcontainer.hxx b/uui/source/passwordcontainer.hxx
new file mode 100644
index 000000000000..c08ef7016635
--- /dev/null
+++ b/uui/source/passwordcontainer.hxx
@@ -0,0 +1,200 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: $
+ * $Revision: $
+ *
+ * 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 INCLUDED_UUI_PASSWORDCONTAINER_HXX
+#define INCLUDED_UUI_PASSWORDCONTAINER_HXX
+
+#include "cppuhelper/implbase2.hxx"
+
+#include "com/sun/star/lang/XServiceInfo.hpp"
+#include "com/sun/star/lang/XSingleServiceFactory.hpp"
+#include "com/sun/star/task/XInteractionHandler.hpp"
+#include "com/sun/star/task/XPasswordContainer.hpp"
+
+namespace com {
+ namespace sun {
+ namespace star {
+ namespace lang {
+ class XMultiServiceFactory;
+ }
+ namespace ucb {
+ class AuthenticationRequest;
+ class XInteractionSupplyAuthentication;
+} } } }
+
+namespace uui {
+
+// ============================================================================
+
+/** Passwordcontainer UNO service (com.sun.star.task.PasswordContainer) helper.
+ */
+class PasswordContainerHelper
+{
+public:
+ PasswordContainerHelper(
+ com::sun::star::uno::Reference<
+ com::sun::star::lang::XMultiServiceFactory > const &
+ xServiceFactory );
+
+ // ------------------------------------------------------------------------
+
+ /** This member function tries to handle an authentication interaction
+ request by looking up credentials for the given URL in the password
+ container service.
+
+ In case of success the given interaction continuation
+ (XInteractionSupplyAuthentication) is filled with the credentials found
+ in the password container.
+
+ Please note the the continuation gets not "selected" by this
+ implementation. "Selecting" the continuation is up to the caller (e.g.
+ an implementation of XInteractionHandler::handle) of this function.
+
+ @param rRequest
+ The authentication request.
+
+ @param xSupplyAuthentication
+ The "supply authentication" interaction continuation.
+
+ @param rURL
+ The URL to lookup credentials for.
+
+ @param xIH
+ The interaction handler to use, for example if a master password is
+ needed to access the password container.
+
+ @return
+ True, if the authentication request was handled successfully.
+ False, otherwise.
+ */
+ bool handleAuthenticationRequest(
+ com::sun::star::ucb::AuthenticationRequest const & rRequest,
+ com::sun::star::uno::Reference<
+ com::sun::star::ucb::XInteractionSupplyAuthentication > const &
+ xSupplyAuthentication,
+ rtl::OUString const & rURL,
+ com::sun::star::uno::Reference<
+ com::sun::star::task::XInteractionHandler > const & xIH )
+ SAL_THROW( (com::sun::star::uno::RuntimeException) );
+
+ /** This member function adds credentials for the given URL to the password
+ container.
+
+ @param rURL
+ The URL the credentials are valid for. rURL must not be empty.
+
+ @param rUsername
+ The user name.
+
+ @param rPasswords
+ This list of passwords.
+
+ @param xIH
+ The interaction handler to use, for example if a master password is
+ needed to access the password container.
+
+ @param bPersist
+ True, the record will get stored persistently; restored upon
+ password container initialization
+ False, the record will be stored until password container instance
+ gets destroyed.
+
+ @return
+ True, if the record was added successfully.
+ False, otherwise.
+
+ */
+ bool addRecord( rtl::OUString const & rURL,
+ rtl::OUString const & rUsername,
+ com::sun::star::uno::Sequence< rtl::OUString > const &
+ rPasswords,
+ com::sun::star::uno::Reference<
+ com::sun::star::task::XInteractionHandler > const & xIH,
+ bool bPersist )
+ SAL_THROW( (com::sun::star::uno::RuntimeException) );
+
+ // ------------------------------------------------------------------------
+
+private:
+ com::sun::star::uno::Reference<
+ com::sun::star::task::XPasswordContainer > m_xPasswordContainer;
+};
+
+// ============================================================================
+
+class PasswordContainerInteractionHandler :
+ public cppu::WeakImplHelper2< com::sun::star::lang::XServiceInfo,
+ com::sun::star::task::XInteractionHandler >
+{
+public:
+ PasswordContainerInteractionHandler(
+ const com::sun::star::uno::Reference<
+ com::sun::star::lang::XMultiServiceFactory >& rXSMgr );
+ virtual ~PasswordContainerInteractionHandler();
+
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName()
+ throw ( com::sun::star::uno::RuntimeException );
+
+ virtual sal_Bool SAL_CALL
+ supportsService( const ::rtl::OUString& ServiceName )
+ throw ( com::sun::star::uno::RuntimeException );
+
+ virtual com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL
+ getSupportedServiceNames()
+ throw ( com::sun::star::uno::RuntimeException );
+
+ // XInteractionHandler
+ virtual void SAL_CALL
+ handle( const ::com::sun::star::uno::Reference<
+ ::com::sun::star::task::XInteractionRequest >& Request )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ // Non-UNO interfaces
+ static rtl::OUString
+ getImplementationName_Static();
+
+ static com::sun::star::uno::Sequence< rtl::OUString >
+ getSupportedServiceNames_Static();
+
+ static com::sun::star::uno::Reference<
+ com::sun::star::lang::XSingleServiceFactory >
+ createServiceFactory( const com::sun::star::uno::Reference<
+ com::sun::star::lang::XMultiServiceFactory > & rxServiceMgr );
+
+private:
+ //com::sun::star::uno::Reference<
+ // com::sun::star::lang::XMultiServiceFactory > m_xSMgr;
+ PasswordContainerHelper m_aPwContainerHelper;
+};
+
+} // namespace uui
+
+#endif
diff --git a/uui/source/services.cxx b/uui/source/services.cxx
index 824c3f895b7d..92669fe0d9d1 100644
--- a/uui/source/services.cxx
+++ b/uui/source/services.cxx
@@ -37,6 +37,7 @@
#include "interactionhandler.hxx"
#include "requeststringresolver.hxx"
+#include "passwordcontainer.hxx"
using namespace rtl;
using namespace com::sun::star::uno;
@@ -46,18 +47,18 @@ using namespace com::sun::star::registry;
namespace {
sal_Bool writeInfo( void * pRegistryKey,
- const char * pImplementationName,
+ const OUString & rImplementationName,
Sequence< OUString > const & rServiceNames )
{
OUString aKeyName( OUString::createFromAscii( "/" ) );
- aKeyName += OUString::createFromAscii( pImplementationName );
+ aKeyName += rImplementationName;
aKeyName += OUString::createFromAscii( "/UNO/SERVICES" );
Reference< XRegistryKey > xKey;
try
{
- xKey = static_cast< XRegistryKey * >(
- pRegistryKey )->createKey( aKeyName );
+ xKey = static_cast< XRegistryKey * >(
+ pRegistryKey )->createKey( aKeyName );
}
catch ( InvalidRegistryException const & )
{
@@ -65,21 +66,21 @@ sal_Bool writeInfo( void * pRegistryKey,
if ( !xKey.is() )
{
- return sal_False;
+ return sal_False;
}
sal_Bool bSuccess = sal_True;
for ( sal_Int32 n = 0; n < rServiceNames.getLength(); ++n )
{
- try
- {
- xKey->createKey( rServiceNames[ n ] );
- }
- catch ( InvalidRegistryException const & )
- {
- bSuccess = sal_False;
- break;
- }
+ try
+ {
+ xKey->createKey( rServiceNames[ n ] );
+ }
+ catch ( InvalidRegistryException const & )
+ {
+ bSuccess = sal_False;
+ break;
+ }
}
return bSuccess;
}
@@ -114,16 +115,26 @@ extern "C" sal_Bool SAL_CALL component_writeInfo(void *, void * pRegistryKey)
//////////////////////////////////////////////////////////////////////
writeInfo( pRegistryKey,
- UUIInteractionHandler::m_aImplementationName,
- UUIInteractionHandler::getSupportedServiceNames_static() ) &&
+ OUString::createFromAscii(
+ UUIInteractionHandler::m_aImplementationName ),
+ UUIInteractionHandler::getSupportedServiceNames_static() ) &&
//////////////////////////////////////////////////////////////////////
// UUI Interaction Request String Resolver.
//////////////////////////////////////////////////////////////////////
writeInfo( pRegistryKey,
- UUIInteractionRequestStringResolver::m_aImplementationName,
- UUIInteractionRequestStringResolver::getSupportedServiceNames_static() );
+ OUString::createFromAscii(
+ UUIInteractionRequestStringResolver::m_aImplementationName ),
+ UUIInteractionRequestStringResolver::getSupportedServiceNames_static() ) &&
+
+ //////////////////////////////////////////////////////////////////////
+ // UUI Password Container Interaction Handler.
+ //////////////////////////////////////////////////////////////////////
+
+ writeInfo( pRegistryKey,
+ uui::PasswordContainerInteractionHandler::getImplementationName_Static(),
+ uui::PasswordContainerInteractionHandler::getSupportedServiceNames_Static() );
}
//============================================================================
@@ -142,7 +153,7 @@ extern "C" void * SAL_CALL component_getFactory(sal_Char const * pImplName,
void * pRet = 0;
Reference< XMultiServiceFactory > xSMgr(
- reinterpret_cast< XMultiServiceFactory * >( pServiceManager ) );
+ reinterpret_cast< XMultiServiceFactory * >( pServiceManager ) );
Reference< XSingleServiceFactory > xFactory;
//////////////////////////////////////////////////////////////////////
@@ -153,10 +164,9 @@ extern "C" void * SAL_CALL component_getFactory(sal_Char const * pImplName,
UUIInteractionHandler::m_aImplementationName)
== 0)
{
- xFactory =
+ xFactory =
cppu::createSingleFactory(
- static_cast< XMultiServiceFactory * >(
- pServiceManager),
+ static_cast< XMultiServiceFactory * >(pServiceManager),
OUString::createFromAscii(
UUIInteractionHandler::m_aImplementationName),
&UUIInteractionHandler::createInstance,
@@ -171,10 +181,9 @@ extern "C" void * SAL_CALL component_getFactory(sal_Char const * pImplName,
UUIInteractionRequestStringResolver::m_aImplementationName)
== 0)
{
- xFactory =
+ xFactory =
cppu::createSingleFactory(
- static_cast< XMultiServiceFactory * >(
- pServiceManager),
+ static_cast< XMultiServiceFactory * >(pServiceManager),
OUString::createFromAscii(
UUIInteractionRequestStringResolver::m_aImplementationName),
&UUIInteractionRequestStringResolver::createInstance,
@@ -182,11 +191,22 @@ extern "C" void * SAL_CALL component_getFactory(sal_Char const * pImplName,
}
//////////////////////////////////////////////////////////////////////
+ // UUI Password Container Interaction Handler.
+ //////////////////////////////////////////////////////////////////////
+
+ else if ( uui::PasswordContainerInteractionHandler::getImplementationName_Static().
+ compareToAscii( pImplName ) == 0 )
+ {
+ xFactory =
+ uui::PasswordContainerInteractionHandler::createServiceFactory( xSMgr );
+ }
+
+ //////////////////////////////////////////////////////////////////////
if ( xFactory.is() )
{
- xFactory->acquire();
- pRet = xFactory.get();
+ xFactory->acquire();
+ pRet = xFactory.get();
}
return pRet;