10#define OUSTR_TO_STDSTR(s) std::string( OUStringToOString( s, RTL_TEXTENCODING_UTF8 ) )
11#define STD_TO_OUSTR( str ) OUString( str.c_str(), str.length( ), RTL_TEXTENCODING_UTF8 )
13#include <com/sun/star/task/XInteractionHandler.hpp>
14#include <com/sun/star/task/PasswordContainer.hpp>
15#include <com/sun/star/task/XPasswordContainer2.hpp>
31 uno::Reference< task::XInteractionHandler > xIH
32 =
m_xEnv->getInteractionHandler();
42 xIH->handle( xRequest );
45 = xRequest->getSelection();
47 if ( xSelection.is() )
50 uno::Reference< task::XInteractionAbort > xAbort(
51 xSelection.get(), uno::UNO_QUERY );
56 = xRequest->getAuthenticationSupplier();
71 std::string refreshToken;
72 const css::uno::Reference<css::ucb::XCommandEnvironment> xEnv =
getXEnv();
75 uno::Reference<task::XInteractionHandler> xIH = xEnv->getInteractionHandler();
77 if (rUsername.empty())
82 ucbhelper::SimpleAuthenticationRequest::EntityType::ENTITY_NA, OUString(),
83 ucbhelper::SimpleAuthenticationRequest::EntityType::ENTITY_MODIFY,
85 ucbhelper::SimpleAuthenticationRequest::EntityType::ENTITY_NA, OUString());
86 xIH->handle(xRequest);
89 = xRequest->getSelection();
94 uno::Reference<task::XInteractionAbort> xAbort(xSelection.get(),
99 = xRequest->getAuthenticationSupplier();
106 uno::Reference<uno::XComponentContext> xContext
107 = ::comphelper::getProcessComponentContext();
108 uno::Reference<task::XPasswordContainer2> xMasterPasswd
109 = task::PasswordContainer::create(xContext);
110 if (xMasterPasswd->hasMasterPassword())
112 xMasterPasswd->authorizateWithMasterPassword(xIH);
114 if (xMasterPasswd->isPersistentStoringAllowed())
118 if (aRec.UserList.hasElements() && aRec.UserList[0].Passwords.hasElements())
126 const std::string& refreshToken)
128 if (refreshToken.empty())
130 if (password == refreshToken)
132 const css::uno::Reference<css::ucb::XCommandEnvironment> xEnv =
getXEnv();
135 uno::Reference<task::XInteractionHandler> xIH = xEnv->getInteractionHandler();
136 uno::Reference<uno::XComponentContext> xContext
137 = ::comphelper::getProcessComponentContext();
138 uno::Reference<task::XPasswordContainer2> xMasterPasswd
139 = task::PasswordContainer::create(xContext);
140 uno::Sequence<OUString> aPasswd{
STD_TO_OUSTR(refreshToken) };
141 if (xMasterPasswd->isPersistentStoringAllowed())
143 if (xMasterPasswd->hasMasterPassword())
145 xMasterPasswd->authorizateWithMasterPassword(xIH);
170 OUString url_oustr( url, strlen( url ), RTL_TEXTENCODING_UTF8 );
171 const css::uno::Reference<
172 css::ucb::XCommandEnvironment> xEnv =
getXEnv( );
176 uno::Reference< task::XInteractionHandler > xIH
177 = xEnv->getInteractionHandler();
183 "Open the following link in your browser and "
184 "paste the code from the URL you have been redirected to in the "
185 "box below. For example:\n"
186 "http://localhost/LibreOffice?code=YOUR_CODE",
189 xIH->handle( xRequest );
192 = xRequest->getSelection();
194 if ( xSelection.is() )
198 xAuthFallback = xRequest->getAuthFallbackInter( );
199 if ( xAuthFallback.is() )
201 OUString
code = xAuthFallback->getCode( );
#define OUSTR_TO_STDSTR(s)
#define STD_TO_OUSTR(str)
bool authenticationQuery(std::string &username, std::string &password) override
bool storeRefreshToken(const std::string &username, const std::string &password, const std::string &refreshToken)
static css::uno::WeakReference< css::ucb::XCommandEnvironment > sm_xEnv
const css::uno::Reference< css::ucb::XCommandEnvironment > & m_xEnv
static void setXEnv(const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
static char * copyWebAuthCodeFallback(const char *url, const char *, const char *)
std::string getRefreshToken(std::string &username)
static css::uno::Reference< css::ucb::XCommandEnvironment > getXEnv()