Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * Version: MPL 1.1 / GPLv3+ / LGPLv3+
4 : *
5 : * The contents of this file are subject to the Mozilla Public License Version
6 : * 1.1 (the "License"); you may not use this file except in compliance with
7 : * the License or as specified alternatively below. You may obtain a copy of
8 : * the License at http://www.mozilla.org/MPL/
9 : *
10 : * Software distributed under the License is distributed on an "AS IS" basis,
11 : * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 : * for the specific language governing rights and limitations under the
13 : * License.
14 : *
15 : * Major Contributor(s):
16 : * [ Copyright (C) 2011 SUSE <cbosdonnat@suse.com> (initial developer) ]
17 : *
18 : * All Rights Reserved.
19 : *
20 : * For minor contributions see the git repository.
21 : *
22 : * Alternatively, the contents of this file may be used under the terms of
23 : * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
24 : * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
25 : * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
26 : * instead of those above.
27 : */
28 :
29 : #define OUSTR_TO_STDSTR(s) string( rtl::OUStringToOString( s, RTL_TEXTENCODING_UTF8 ).getStr() )
30 : #define STD_TO_OUSTR( str ) rtl::OUString( str.c_str(), str.length( ), RTL_TEXTENCODING_UTF8 )
31 :
32 : #include <com/sun/star/task/XInteractionHandler.hpp>
33 :
34 : #include <ucbhelper/simpleauthenticationrequest.hxx>
35 :
36 : #include "auth_provider.hxx"
37 :
38 : using namespace com::sun::star;
39 : using namespace std;
40 :
41 : namespace cmis
42 : {
43 0 : bool AuthProvider::authenticationQuery( string& username, string& password )
44 : {
45 0 : if ( m_xEnv.is() )
46 : {
47 : uno::Reference< task::XInteractionHandler > xIH
48 0 : = m_xEnv->getInteractionHandler();
49 :
50 0 : if ( xIH.is() )
51 : {
52 : rtl::Reference< ucbhelper::SimpleAuthenticationRequest > xRequest
53 : = new ucbhelper::SimpleAuthenticationRequest(
54 : m_sUrl, m_sBindingUrl, ::rtl::OUString(),
55 0 : STD_TO_OUSTR( username ),
56 0 : STD_TO_OUSTR( password ),
57 0 : ::rtl::OUString(), true, false );
58 0 : xIH->handle( xRequest.get() );
59 :
60 : rtl::Reference< ucbhelper::InteractionContinuation > xSelection
61 0 : = xRequest->getSelection();
62 :
63 0 : if ( xSelection.is() )
64 : {
65 : // Handler handled the request.
66 : uno::Reference< task::XInteractionAbort > xAbort(
67 0 : xSelection.get(), uno::UNO_QUERY );
68 0 : if ( !xAbort.is() )
69 : {
70 : const rtl::Reference<
71 : ucbhelper::InteractionSupplyAuthentication > & xSupp
72 0 : = xRequest->getAuthenticationSupplier();
73 :
74 0 : username = OUSTR_TO_STDSTR( xSupp->getUserName() );
75 0 : password = OUSTR_TO_STDSTR( xSupp->getPassword() );
76 :
77 0 : return true;
78 0 : }
79 0 : }
80 0 : }
81 : }
82 0 : return false;
83 : }
84 0 : }
85 :
86 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|