21#include <com/sun/star/task/XInteractionAbort.hpp>
22#include <com/sun/star/ucb/XWebDAVCommandEnvironment.hpp>
30#include <com/sun/star/lang/IllegalArgumentException.hpp>
31#include <com/sun/star/io/IOException.hpp>
42int DAVAuthListener_Impl::authenticate(
43 const OUString & inRealm,
44 const OUString & inHostName,
45 OUString & inoutUserName,
46 OUString & outPassWord,
47 bool bCanUseSystemCredentials,
48 bool bUsePreviousCredentials )
52 uno::Reference< task::XInteractionHandler > xIH
53 =
m_xEnv->getInteractionHandler();
61 if ( inoutUserName.isEmpty() && bUsePreviousCredentials )
64 if ( outPassWord.isEmpty() && bUsePreviousCredentials )
69 m_aURL, inHostName, inRealm, inoutUserName,
71 bCanUseSystemCredentials );
72 xIH->handle( xRequest );
75 = xRequest->getSelection();
77 if ( xSelection.is() )
80 uno::Reference< task::XInteractionAbort > xAbort(
81 xSelection.get(), uno::UNO_QUERY );
86 = xRequest->getAuthenticationSupplier();
88 bool bUseSystemCredentials =
false;
90 if ( bCanUseSystemCredentials )
92 = xSupp->getUseSystemCredentials();
94 if ( bUseSystemCredentials )
98 inoutUserName.clear();
103 inoutUserName = xSupp->getUserName();
104 outPassWord = xSupp->getPassword();
127 uno::Reference< uno::XComponentContext > xContext,
131 m_xSessionFactory(
std::move( xSessionFactory )),
139 m_aPath( rOther.m_aPath ),
140 m_aFlags( rOther.m_aFlags ),
141 m_xSession( rOther.m_xSession ),
142 m_xSessionFactory( rOther.m_xSessionFactory ),
144 m_aRedirectURIs( rOther.m_aRedirectURIs )
165 const uno::Reference< ucb::XCommandEnvironment > & xEnv )
180 ucb::WebDAVHTTPMethod_OPTIONS,
202 const std::vector< OUString > & rPropertyNames,
203 std::vector< DAVResource > & rResources,
204 const uno::Reference< ucb::XCommandEnvironment > & xEnv )
219 ucb::WebDAVHTTPMethod_PROPFIND,
244 std::vector< DAVResourceInfo > & rResInfo,
245 const uno::Reference< ucb::XCommandEnvironment > & xEnv )
259 ucb::WebDAVHTTPMethod_PROPFIND,
282 const std::vector< ProppatchValue >& rValues,
283 const uno::Reference< ucb::XCommandEnvironment >& xEnv )
297 ucb::WebDAVHTTPMethod_PROPPATCH,
319 const std::vector< OUString > & rHeaderNames,
321 const uno::Reference< ucb::XCommandEnvironment >& xEnv )
335 ucb::WebDAVHTTPMethod_HEAD,
358 const uno::Reference< ucb::XCommandEnvironment > & xEnv )
362 uno::Reference< io::XInputStream >
xStream;
373 ucb::WebDAVHTTPMethod_GET,
397 uno::Reference< io::XOutputStream > & rStream,
398 const uno::Reference< ucb::XCommandEnvironment > & xEnv )
412 ucb::WebDAVHTTPMethod_GET,
434 const std::vector< OUString > & rHeaderNames,
436 const uno::Reference< ucb::XCommandEnvironment > & xEnv )
440 uno::Reference< io::XInputStream >
xStream;
451 ucb::WebDAVHTTPMethod_GET,
479 const std::vector< OUString > & rHeaderNames,
481 const uno::Reference< ucb::XCommandEnvironment > & xEnv )
494 ucb::WebDAVHTTPMethod_GET,
518 uno::Reference< io::XOutputStream > & rStream,
519 const std::vector< OUString > & rHeaderNames,
521 const uno::Reference< ucb::XCommandEnvironment > & xEnv )
535 ucb::WebDAVHTTPMethod_GET,
563 osl::Guard<osl::Mutex>
const g(
m_aMutex);
576 void resetInputStream(
const uno::Reference< io::XInputStream > & rStream )
580 uno::Reference< io::XSeekable > xSeekable(
581 rStream, uno::UNO_QUERY );
582 if ( xSeekable.is() )
584 xSeekable->seek( 0 );
588 catch ( lang::IllegalArgumentException
const & )
591 catch ( io::IOException
const & )
602 const uno::Reference< io::XInputStream > & rStream,
603 const uno::Reference< ucb::XCommandEnvironment > & xEnv )
608 uno::Reference< io::XInputStream > xSeekableStream
617 resetInputStream( xSeekableStream );
625 ucb::WebDAVHTTPMethod_PUT,
647 const OUString & rContentType,
648 const OUString & rReferer,
649 const uno::Reference< io::XInputStream > & rInputStream,
650 const uno::Reference< ucb::XCommandEnvironment >& xEnv )
655 uno::Reference< io::XInputStream > xSeekableStream
659 uno::Reference< io::XInputStream >
xStream;
666 resetInputStream( xSeekableStream );
675 ucb::WebDAVHTTPMethod_POST,
708 const OUString & rContentType,
709 const OUString & rReferer,
710 const uno::Reference< io::XInputStream > & rInputStream,
711 uno::Reference< io::XOutputStream > & rOutputStream,
712 const uno::Reference< ucb::XCommandEnvironment >& xEnv )
717 uno::Reference< io::XInputStream > xSeekableStream
727 resetInputStream( xSeekableStream );
736 ucb::WebDAVHTTPMethod_POST,
758 GET( rOutputStream, xEnv );
768 const uno::Reference< ucb::XCommandEnvironment > & xEnv )
782 ucb::WebDAVHTTPMethod_MKCOL,
803 const OUString & rSourcePath,
804 const OUString & rDestinationURI,
806 const uno::Reference< ucb::XCommandEnvironment > & xEnv )
820 ucb::WebDAVHTTPMethod_COPY,
843 const OUString & rSourcePath,
844 const OUString & rDestinationURI,
846 const uno::Reference< ucb::XCommandEnvironment > & xEnv )
860 ucb::WebDAVHTTPMethod_MOVE,
883 const uno::Reference< ucb::XCommandEnvironment > & xEnv )
897 ucb::WebDAVHTTPMethod_DELETE,
920 const uno::Reference< ucb::XCommandEnvironment > & xEnv )
934 ucb::WebDAVHTTPMethod_LOCK,
955 const uno::Reference< ucb::XCommandEnvironment > & xEnv )
969 ucb::WebDAVHTTPMethod_UNLOCK,
990 osl::Guard< osl::Mutex > aGuard(
m_aMutex );
996 osl::Guard< osl::Mutex > aGuard(
m_aMutex );
1005 osl::Guard< osl::Mutex > aGuard(
m_aMutex );
1012 if ( aPath.isEmpty() )
1016 if ( aURI.
GetHost().isEmpty() )
1046 "DAVResourceAccess::getRequestURI - Not initialized!");
1058 const uno::Reference< ucb::XCommandEnvironment > & xEnv,
1059 const OUString & rURI,
1060 ucb::WebDAVHTTPMethod eMethod,
1066 uno::Reference< ucb::XWebDAVCommandEnvironment > xDAVEnv(
1067 xEnv, uno::UNO_QUERY );
1069 if ( !xDAVEnv.is() )
1072 uno::Sequence< beans::StringPair > aRequestHeaders
1073 = xDAVEnv->getUserRequestHeaders( rURI, eMethod );
1075 for ( sal_Int32
n = 0;
n < aRequestHeaders.getLength(); ++
n )
1077 rRequestHeaders.push_back(
1079 aRequestHeaders[
n ].Second ) );
1085 ::std::u16string_view
const rRedirectURL)
1087 osl::Guard< osl::Mutex > aGuard(
m_aMutex );
1089 CurlUri const aUri( rRedirectURL );
1101 [&aUri](
const CurlUri& rUri) { return aUri == rUri; });
1107 osl::Guard< osl::Mutex > aGuard(
m_aMutex );
1150 if ( errorCount < 3 )
constexpr size_t g_nRedirectLimit
Reference< XComponentContext > m_xContext
OUString GetRelativeReference() const
OUString const & GetHost() const
OUString const & GetURI() const
const css::uno::Reference< css::ucb::XCommandEnvironment > m_xEnv
const OUString & getData() const
const ExceptionCode & getError() const
sal_uInt16 getStatus() const
void GET0(DAVRequestHeaders &rRequestHeaders, const std::vector< OUString > &rHeaderNames, DAVResource &rResource, const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
used as HEAD substitute when HEAD is not implemented on server
css::uno::Reference< css::uno::XComponentContext > m_xContext
const OUString & getRequestURI() const
void setFlags(const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue > &rFlags)
DAVResourceAccess()=default
void PUT(const css::uno::Reference< css::io::XInputStream > &rStream, const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
void PROPFIND(const Depth nDepth, const std::vector< OUString > &rPropertyNames, std::vector< DAVResource > &rResources, const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
css::uno::Reference< css::io::XInputStream > POST(const OUString &rContentType, const OUString &rReferer, const css::uno::Reference< css::io::XInputStream > &rInputStream, const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
DAVResourceAccess & operator=(const DAVResourceAccess &rOther)
bool detectRedirectCycle(::std::u16string_view rRedirectURL)
void MKCOL(const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
void HEAD(const std::vector< OUString > &rHeaderNames, DAVResource &rResource, const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
void DESTROY(const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
std::vector< CurlUri > m_aRedirectURIs
bool handleException(DAVException const &e, int errorCount)
void MOVE(const OUString &rSourcePath, const OUString &rDestinationURI, bool bOverwrite, const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
void PROPPATCH(const std::vector< ProppatchValue > &rValues, const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
rtl::Reference< DAVSession > m_xSession
::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue > m_aFlags
void UNLOCK(const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
void setURL(const OUString &rNewURL)
void OPTIONS(DAVOptions &rOptions, const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
void LOCK(css::ucb::Lock &inLock, const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
void COPY(const OUString &rSourcePath, const OUString &rDestinationURI, bool bOverwrite, const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
static void getUserRequestHeaders(const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv, const OUString &rURI, css::ucb::WebDAVHTTPMethod eMethod, DAVRequestHeaders &rRequestHeaders)
css::uno::Reference< css::io::XInputStream > GET(const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
rtl::Reference< DAVSessionFactory > m_xSessionFactory
const sal_uInt16 SC_BAD_GATEWAY
const sal_uInt16 SC_GATEWAY_TIMEOUT
const sal_uInt16 SC_SERVICE_UNAVAILABLE
const sal_uInt16 SC_INSUFFICIENT_STORAGE
const sal_uInt16 SC_BAD_REQUEST
std::vector< DAVRequestHeader > DAVRequestHeaders
std::pair< OUString, OUString > DAVRequestHeader