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/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <com/sun/star/task/XMasterPasswordHandling.hpp>
21 #include <com/sun/star/ucb/URLAuthenticationRequest.hpp>
22 #include <ucbhelper/simpleauthenticationrequest.hxx>
24 using namespace com::sun::star
;
25 using namespace ucbhelper
;
28 SimpleAuthenticationRequest::SimpleAuthenticationRequest(
29 const OUString
& rURL
,
30 const OUString
& rServerName
,
31 const OUString
& rRealm
,
32 const OUString
& rUserName
,
33 const OUString
& rPassword
,
34 bool bAllowUseSystemCredentials
,
35 bool bAllowSessionStoring
)
39 ucb::URLAuthenticationRequest aRequest
;
40 // aRequest.Message = // OUString
41 // aRequest.Context = // XInterface
42 aRequest
.Classification
= task::InteractionClassification_ERROR
;
43 aRequest
.ServerName
= rServerName
;
44 // aRequest.Diagnostic = // OUString
45 aRequest
.HasRealm
= !rRealm
.isEmpty();
46 if ( aRequest
.HasRealm
)
47 aRequest
.Realm
= rRealm
;
48 aRequest
.HasUserName
= true;
49 aRequest
.UserName
= rUserName
;
50 aRequest
.HasPassword
= true;
51 aRequest
.Password
= rPassword
;
52 aRequest
.HasAccount
= false;
60 bAllowUseSystemCredentials
,
61 bAllowSessionStoring
);
65 SimpleAuthenticationRequest::SimpleAuthenticationRequest(
66 const OUString
& rURL
,
67 const OUString
& rServerName
,
68 EntityType eRealmType
,
69 const OUString
& rRealm
,
70 EntityType eUserNameType
,
71 const OUString
& rUserName
,
72 EntityType ePasswordType
,
73 const OUString
& rPassword
)
76 ucb::URLAuthenticationRequest aRequest
;
77 // aRequest.Message = // OUString
78 // aRequest.Context = // XInterface
79 aRequest
.Classification
= task::InteractionClassification_ERROR
;
80 aRequest
.ServerName
= rServerName
;
81 // aRequest.Diagnostic = // OUString
82 aRequest
.HasRealm
= eRealmType
!= ENTITY_NA
;
83 if ( aRequest
.HasRealm
)
84 aRequest
.Realm
= rRealm
;
85 aRequest
.HasUserName
= eUserNameType
!= ENTITY_NA
;
86 if ( aRequest
.HasUserName
)
87 aRequest
.UserName
= rUserName
;
88 aRequest
.HasPassword
= ePasswordType
!= ENTITY_NA
;
89 if ( aRequest
.HasPassword
)
90 aRequest
.Password
= rPassword
;
91 aRequest
.HasAccount
= false;
95 eRealmType
== ENTITY_MODIFY
,
96 eUserNameType
== ENTITY_MODIFY
,
97 ePasswordType
== ENTITY_MODIFY
,
104 void SimpleAuthenticationRequest::initialize(
105 const ucb::URLAuthenticationRequest
& rRequest
,
107 bool bCanSetUserName
,
108 bool bCanSetPassword
,
110 bool bAllowUseSystemCredentials
,
111 bool bAllowSessionStoring
)
113 setRequest( uno::makeAny( rRequest
) );
115 // Fill continuations...
116 unsigned int nSize
= 1;
117 unsigned int nPos
= 0;
119 if( bAllowSessionStoring
)
124 uno::Sequence
< ucb::RememberAuthentication
> aRememberModes( nSize
);
125 aRememberModes
[ nPos
++ ] = ucb::RememberAuthentication_NO
;
127 if( bAllowSessionStoring
)
128 aRememberModes
[ nPos
++ ] = ucb::RememberAuthentication_SESSION
;
130 aRememberModes
[ nPos
++ ] = ucb::RememberAuthentication_PERSISTENT
;
133 = new InteractionSupplyAuthentication(
139 aRememberModes
, // rRememberPasswordModes
140 ucb::RememberAuthentication_SESSION
, // eDefaultRememberPasswordMode
141 aRememberModes
, // rRememberAccountModes
142 ucb::RememberAuthentication_SESSION
, // eDefaultRememberAccountMode
143 bAllowUseSystemCredentials
// bCanUseSystemCredentials,
147 uno::Reference
< task::XInteractionContinuation
> > aContinuations( 3 );
148 aContinuations
[ 0 ] = new InteractionAbort( this );
149 aContinuations
[ 1 ] = new InteractionRetry( this );
150 aContinuations
[ 2 ] = m_xAuthSupplier
.get();
152 setContinuations( aContinuations
);
155 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */