summaryrefslogtreecommitdiff
path: root/ucb/source/ucp/cmis/auth_provider.cxx
diff options
context:
space:
mode:
authorMihai Varga <mihai.mv13@gmail.com>2014-07-31 12:07:56 +0300
committerMiklos Vajna <vmiklos@collabora.co.uk>2014-12-15 11:23:27 +0100
commit30298bc388f3e7c5b180904a8ad4f671e7b8b52b (patch)
tree414f0b4c3eaad03231c7bd9db9c4bf9c94929243 /ucb/source/ucp/cmis/auth_provider.cxx
parenta3b93ed6d8adc562687cbe419a1006660926164b (diff)
OneDrive authfallback request is now issued
Change-Id: I9ee1f087322d80cbdf8ca369fccb6b6b0336062e
Diffstat (limited to 'ucb/source/ucp/cmis/auth_provider.cxx')
-rw-r--r--ucb/source/ucp/cmis/auth_provider.cxx48
1 files changed, 48 insertions, 0 deletions
diff --git a/ucb/source/ucp/cmis/auth_provider.cxx b/ucb/source/ucp/cmis/auth_provider.cxx
index bd00986a18b0..63e742f84282 100644
--- a/ucb/source/ucp/cmis/auth_provider.cxx
+++ b/ucb/source/ucp/cmis/auth_provider.cxx
@@ -13,6 +13,7 @@
#include <com/sun/star/task/XInteractionHandler.hpp>
#include <ucbhelper/simpleauthenticationrequest.hxx>
+#include <ucbhelper/authenticationfallback.hxx>
#include "auth_provider.hxx"
@@ -21,6 +22,8 @@ using namespace std;
namespace cmis
{
+ com::sun::star::uno::Reference< com::sun::star::ucb::XCommandEnvironment>
+ AuthProvider::sm_xEnv;
bool AuthProvider::authenticationQuery( string& username, string& password )
{
if ( m_xEnv.is() )
@@ -62,6 +65,51 @@ namespace cmis
}
return false;
}
+
+ char* AuthProvider::onedriveAuthCodeFallback( const char* url,
+ const char* /*username*/,
+ const char* /*password*/ )
+ {
+ OUString instructions = "Please open the following link in your browser and\n"
+ "paste the code from the URL you have been redirected to\n"
+ "in the box bellow. For example:\n"
+ "https://login.live.com/oauth20_desktop.srf?code=YOUR_CODE&lc=1033";
+ OUString url_oustr( url, strlen( url ), RTL_TEXTENCODING_UTF8 );
+ const com::sun::star::uno::Reference<
+ com::sun::star::ucb::XCommandEnvironment> xEnv = getXEnv( );
+
+ if ( xEnv.is() )
+ {
+ uno::Reference< task::XInteractionHandler > xIH
+ = xEnv->getInteractionHandler();
+
+ if ( xIH.is() )
+ {
+ rtl::Reference< ucbhelper::AuthenticationFallbackRequest > xRequest
+ = new ucbhelper::AuthenticationFallbackRequest (
+ instructions, url_oustr );
+
+ xIH->handle( xRequest.get() );
+
+ rtl::Reference< ucbhelper::InteractionContinuation > xSelection
+ = xRequest->getSelection();
+
+ if ( xSelection.is() )
+ {
+ // Handler handled the request.
+ const rtl::Reference< ucbhelper::InteractionAuthFallback >&
+ xAuthFallback = xRequest->getAuthFallbackInter( );
+ if ( xAuthFallback.is() )
+ {
+ OUString code = xAuthFallback->getCode( );
+ return strdup( OUSTR_TO_STDSTR( code ).c_str( ) );
+ }
+ }
+ }
+ }
+
+ return strdup( "" );
+ }
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */