diff options
author | Kai Sommerfeld <kso@openoffice.org> | 2002-09-03 12:06:53 +0000 |
---|---|---|
committer | Kai Sommerfeld <kso@openoffice.org> | 2002-09-03 12:06:53 +0000 |
commit | 734962718c3c721337c51b9dca32f04bfbdff93f (patch) | |
tree | 546723d40af3e61bdba60e0f440ad5d19636889c /ucb | |
parent | cb1d3ad3126ce403b629010267a9cba787336f58 (diff) |
#102871# - Supply username+password from previous try with authentication
request (to make password container service work correctly).
Diffstat (limited to 'ucb')
-rw-r--r-- | ucb/source/ucp/webdav/NeonSession.cxx | 61 | ||||
-rw-r--r-- | ucb/source/ucp/webdav/NeonSession.hxx | 30 |
2 files changed, 73 insertions, 18 deletions
diff --git a/ucb/source/ucp/webdav/NeonSession.cxx b/ucb/source/ucp/webdav/NeonSession.cxx index bb20cea4345d..0a155d5b39a0 100644 --- a/ucb/source/ucp/webdav/NeonSession.cxx +++ b/ucb/source/ucp/webdav/NeonSession.cxx @@ -2,9 +2,9 @@ * * $RCSfile: NeonSession.cxx,v $ * - * $Revision: 1.21 $ + * $Revision: 1.22 $ * - * last change: $Author: kso $ $Date: 2002-08-29 09:00:13 $ + * last change: $Author: kso $ $Date: 2002-09-03 13:06:53 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -232,12 +232,21 @@ extern "C" void NeonSession_ResponseBlockWriter( void * inUserData, } } -extern "C" int NeonAuth( void * inUserData, - const char * inRealm, - int attempt, - char * inoutUserName, - char * inoutPassWord ) +extern "C" int NeonSession_NeonAuth( void * inUserData, + const char * inRealm, + int attempt, + char * inoutUserName, + char * inoutPassWord ) { +#if 0 + // Give'em only a limited mumber of retries.. + if ( attempt > 9 ) + { + // abort + return -1; + } +#endif + NeonSession * theSession = static_cast< NeonSession * >( inUserData ); if ( !theSession->getServerAuthListener() ) { @@ -253,6 +262,14 @@ extern "C" int NeonAuth( void * inUserData, // (last checked: 0.22.0). rtl::OUString::createFromAscii( inoutPassWord ) ); */ + // #102871# - Supply username and password from previous try. Password + // container service depends on this! + if ( theUserName.getLength() == 0 ) + theUserName = theSession->getUserName(); + + if ( thePassWord.getLength() == 0 ) + thePassWord = theSession->getPassWord(); + int theRetVal = theSession->getServerAuthListener()->authenticate( rtl::OUString::createFromAscii( inRealm ), theSession->getHostName(), @@ -265,6 +282,10 @@ extern "C" int NeonAuth( void * inUserData, strcpy( inoutPassWord, rtl::OUStringToOString( thePassWord, RTL_TEXTENCODING_UTF8 ) ); + // #102871# - Remember username and password. + theSession->setUserName( theUserName ); + theSession->setPassWord( thePassWord ); + return theRetVal; } @@ -433,8 +454,12 @@ void NeonSession::setServerAuthListener( DAVAuthListener * inDAVAuthListener ) // Calling ne_set_server_auth more than once sometimes crashes Neon! if ( m_pListener == 0 ) { - m_pListener = inDAVAuthListener; - ne_set_server_auth( m_pHttpSession, NeonAuth, this ); + osl::Guard< osl::Mutex > theGuard( m_aMutex ); + if ( m_pListener == 0 ) + { + m_pListener = inDAVAuthListener; + ne_set_server_auth( m_pHttpSession, NeonSession_NeonAuth, this ); + } } } @@ -445,6 +470,20 @@ void NeonSession::setProxyAuthListener( DAVAuthListener * inDAVAuthListener ) } // ------------------------------------------------------------------- +void NeonSession::setUserName( const rtl::OUString & rUserName ) +{ + osl::Guard< osl::Mutex > theGuard( m_aMutex ); + m_aPrevUserName = rUserName; +} + +// ------------------------------------------------------------------- +void NeonSession::setPassWord( const rtl::OUString & rPassWord ) +{ + osl::Guard< osl::Mutex > theGuard( m_aMutex ); + m_aPrevPassWord = rPassWord; +} + +// ------------------------------------------------------------------- // OPTIONS // ------------------------------------------------------------------- void NeonSession::OPTIONS( const rtl::OUString & inPath, @@ -964,7 +1003,9 @@ void NeonSession::HandleError( int nError ) switch ( nError ) { case NE_OK: - break; + // Cleanup. + m_aPrevUserName = m_aPrevPassWord = rtl::OUString(); + return; case NE_ERROR: // Generic error { diff --git a/ucb/source/ucp/webdav/NeonSession.hxx b/ucb/source/ucp/webdav/NeonSession.hxx index 3a62b6509efe..46f39521b41d 100644 --- a/ucb/source/ucp/webdav/NeonSession.hxx +++ b/ucb/source/ucp/webdav/NeonSession.hxx @@ -2,9 +2,9 @@ * * $RCSfile: NeonSession.hxx,v $ * - * $Revision: 1.13 $ + * $Revision: 1.14 $ * - * last change: $Author: kso $ $Date: 2002-08-29 09:00:13 $ + * last change: $Author: kso $ $Date: 2002-09-03 13:06:53 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -110,6 +110,14 @@ class NeonSession : public DAVSession com::sun::star::uno::Reference< com::sun::star::ucb::XCommandEnvironment > m_xEnv; + // @@@ This should really be per-request data. A NeonSession + // instance can handle multiple requests at a time!!! + // Username/password entered during last request. Cleared, if + // request was processed successfully. Kept as long as request + // returns with an error. + rtl::OUString m_aPrevUserName; + rtl::OUString m_aPrevPassWord; + protected: virtual ~NeonSession(); @@ -125,12 +133,6 @@ class NeonSession : public DAVSession virtual void setServerAuthListener(DAVAuthListener * inDAVAuthListener); virtual void setProxyAuthListener(DAVAuthListener * inDAVAuthListener); - virtual void OPTIONS( const ::rtl::OUString & inPath, - DAVCapabilities & outCapabilities, - const com::sun::star::uno::Reference< - com::sun::star::ucb::XCommandEnvironment >& inEnv ) - throw ( DAVException ); - DAVAuthListener * getServerAuthListener() const { return m_pListener; } @@ -142,6 +144,18 @@ class NeonSession : public DAVSession const void * getRequestData() const { return m_pRequestData; } + const rtl::OUString & getUserName() const { return m_aPrevUserName; } + const rtl::OUString & getPassWord() const { return m_aPrevPassWord; } + + void setUserName( const rtl::OUString & rUserName ); + void setPassWord( const rtl::OUString & rPassWord ); + + virtual void OPTIONS( const ::rtl::OUString & inPath, + DAVCapabilities & outCapabilities, + const com::sun::star::uno::Reference< + com::sun::star::ucb::XCommandEnvironment >& inEnv ) + throw ( DAVException ); + // allprop & named virtual void PROPFIND( const ::rtl::OUString & inPath, const Depth inDepth, |