1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 #define OUSTR_TO_STDSTR(s) string( OUStringToOString( s, RTL_TEXTENCODING_UTF8 ).getStr() )
11 #define STD_TO_OUSTR( str ) OUString( str.c_str(), str.length( ), RTL_TEXTENCODING_UTF8 )
13 #include <com/sun/star/task/XInteractionHandler.hpp>
15 #include <ucbhelper/simpleauthenticationrequest.hxx>
17 #include "auth_provider.hxx"
19 using namespace com::sun::star
;
24 bool AuthProvider::authenticationQuery( string
& username
, string
& password
)
28 uno::Reference
< task::XInteractionHandler
> xIH
29 = m_xEnv
->getInteractionHandler();
33 rtl::Reference
< ucbhelper::SimpleAuthenticationRequest
> xRequest
34 = new ucbhelper::SimpleAuthenticationRequest(
35 m_sUrl
, m_sBindingUrl
, OUString(),
36 STD_TO_OUSTR( username
),
37 STD_TO_OUSTR( password
),
38 OUString(), true, false );
39 xIH
->handle( xRequest
.get() );
41 rtl::Reference
< ucbhelper::InteractionContinuation
> xSelection
42 = xRequest
->getSelection();
44 if ( xSelection
.is() )
46 // Handler handled the request.
47 uno::Reference
< task::XInteractionAbort
> xAbort(
48 xSelection
.get(), uno::UNO_QUERY
);
52 ucbhelper::InteractionSupplyAuthentication
> & xSupp
53 = xRequest
->getAuthenticationSupplier();
55 username
= OUSTR_TO_STDSTR( xSupp
->getUserName() );
56 password
= OUSTR_TO_STDSTR( xSupp
->getPassword() );
67 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */