1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_ucbhelper.hxx"
30 #include <com/sun/star/task/XMasterPasswordHandling.hpp>
31 #include <com/sun/star/ucb/URLAuthenticationRequest.hpp>
32 #include <ucbhelper/simpleauthenticationrequest.hxx>
34 using namespace com::sun::star
;
35 using namespace ucbhelper
;
37 //=========================================================================
38 SimpleAuthenticationRequest::SimpleAuthenticationRequest(
39 const rtl::OUString
& rURL
,
40 const rtl::OUString
& rServerName
,
41 const rtl::OUString
& rRealm
,
42 const rtl::OUString
& rUserName
,
43 const rtl::OUString
& rPassword
,
44 const rtl::OUString
& rAccount
)
47 ucb::URLAuthenticationRequest aRequest
;
48 // aRequest.Message = // OUString
49 // aRequest.Context = // XInterface
50 aRequest
.Classification
= task::InteractionClassification_ERROR
;
51 aRequest
.ServerName
= rServerName
;
52 // aRequest.Diagnostic = // OUString
53 aRequest
.HasRealm
= ( rRealm
.getLength() > 0 );
54 if ( aRequest
.HasRealm
)
55 aRequest
.Realm
= rRealm
;
56 aRequest
.HasUserName
= sal_True
;
57 aRequest
.UserName
= rUserName
;
58 aRequest
.HasPassword
= sal_True
;
59 aRequest
.Password
= rPassword
;
60 aRequest
.HasAccount
= ( rAccount
.getLength() > 0 );
61 if ( aRequest
.HasAccount
)
62 aRequest
.Account
= rAccount
;
73 //=========================================================================
74 SimpleAuthenticationRequest::SimpleAuthenticationRequest(
75 const rtl::OUString
& rURL
,
76 const rtl::OUString
& rServerName
,
77 const rtl::OUString
& rRealm
,
78 const rtl::OUString
& rUserName
,
79 const rtl::OUString
& rPassword
,
80 const rtl::OUString
& rAccount
,
81 sal_Bool bAllowPersistentStoring
,
82 sal_Bool bAllowUseSystemCredentials
)
86 ucb::URLAuthenticationRequest aRequest
;
87 // aRequest.Message = // OUString
88 // aRequest.Context = // XInterface
89 aRequest
.Classification
= task::InteractionClassification_ERROR
;
90 aRequest
.ServerName
= rServerName
;
91 // aRequest.Diagnostic = // OUString
92 aRequest
.HasRealm
= ( rRealm
.getLength() > 0 );
93 if ( aRequest
.HasRealm
)
94 aRequest
.Realm
= rRealm
;
95 aRequest
.HasUserName
= sal_True
;
96 aRequest
.UserName
= rUserName
;
97 aRequest
.HasPassword
= sal_True
;
98 aRequest
.Password
= rPassword
;
99 aRequest
.HasAccount
= ( rAccount
.getLength() > 0 );
100 if ( aRequest
.HasAccount
)
101 aRequest
.Account
= rAccount
;
109 bAllowPersistentStoring
,
110 bAllowUseSystemCredentials
);
113 //=========================================================================
114 SimpleAuthenticationRequest::SimpleAuthenticationRequest(
115 const rtl::OUString
& rURL
,
116 const rtl::OUString
& rServerName
,
117 EntityType eRealmType
,
118 const rtl::OUString
& rRealm
,
119 EntityType eUserNameType
,
120 const rtl::OUString
& rUserName
,
121 EntityType ePasswordType
,
122 const rtl::OUString
& rPassword
,
123 EntityType eAccountType
,
124 const rtl::OUString
& rAccount
)
127 ucb::URLAuthenticationRequest aRequest
;
128 // aRequest.Message = // OUString
129 // aRequest.Context = // XInterface
130 aRequest
.Classification
= task::InteractionClassification_ERROR
;
131 aRequest
.ServerName
= rServerName
;
132 // aRequest.Diagnostic = // OUString
133 aRequest
.HasRealm
= eRealmType
!= ENTITY_NA
;
134 if ( aRequest
.HasRealm
)
135 aRequest
.Realm
= rRealm
;
136 aRequest
.HasUserName
= eUserNameType
!= ENTITY_NA
;
137 if ( aRequest
.HasUserName
)
138 aRequest
.UserName
= rUserName
;
139 aRequest
.HasPassword
= ePasswordType
!= ENTITY_NA
;
140 if ( aRequest
.HasPassword
)
141 aRequest
.Password
= rPassword
;
142 aRequest
.HasAccount
= eAccountType
!= ENTITY_NA
;
143 if ( aRequest
.HasAccount
)
144 aRequest
.Account
= rAccount
;
148 eRealmType
== ENTITY_MODIFY
,
149 eUserNameType
== ENTITY_MODIFY
,
150 ePasswordType
== ENTITY_MODIFY
,
151 eAccountType
== ENTITY_MODIFY
,
156 //=========================================================================
157 SimpleAuthenticationRequest::SimpleAuthenticationRequest(
158 const rtl::OUString
& rURL
,
159 const rtl::OUString
& rServerName
,
160 EntityType eRealmType
,
161 const rtl::OUString
& rRealm
,
162 EntityType eUserNameType
,
163 const rtl::OUString
& rUserName
,
164 EntityType ePasswordType
,
165 const rtl::OUString
& rPassword
,
166 EntityType eAccountType
,
167 const rtl::OUString
& rAccount
,
168 sal_Bool bAllowPersistentStoring
,
169 sal_Bool bAllowUseSystemCredentials
)
172 ucb::URLAuthenticationRequest aRequest
;
173 // aRequest.Message = // OUString
174 // aRequest.Context = // XInterface
175 aRequest
.Classification
= task::InteractionClassification_ERROR
;
176 aRequest
.ServerName
= rServerName
;
177 // aRequest.Diagnostic = // OUString
178 aRequest
.HasRealm
= eRealmType
!= ENTITY_NA
;
179 if ( aRequest
.HasRealm
)
180 aRequest
.Realm
= rRealm
;
181 aRequest
.HasUserName
= eUserNameType
!= ENTITY_NA
;
182 if ( aRequest
.HasUserName
)
183 aRequest
.UserName
= rUserName
;
184 aRequest
.HasPassword
= ePasswordType
!= ENTITY_NA
;
185 if ( aRequest
.HasPassword
)
186 aRequest
.Password
= rPassword
;
187 aRequest
.HasAccount
= eAccountType
!= ENTITY_NA
;
188 if ( aRequest
.HasAccount
)
189 aRequest
.Account
= rAccount
;
193 eRealmType
== ENTITY_MODIFY
,
194 eUserNameType
== ENTITY_MODIFY
,
195 ePasswordType
== ENTITY_MODIFY
,
196 eAccountType
== ENTITY_MODIFY
,
197 bAllowPersistentStoring
,
198 bAllowUseSystemCredentials
);
201 //=========================================================================
202 void SimpleAuthenticationRequest::initialize(
203 const ucb::URLAuthenticationRequest
& rRequest
,
204 sal_Bool bCanSetRealm
,
205 sal_Bool bCanSetUserName
,
206 sal_Bool bCanSetPassword
,
207 sal_Bool bCanSetAccount
,
208 sal_Bool bAllowPersistentStoring
,
209 sal_Bool bAllowUseSystemCredentials
)
211 setRequest( uno::makeAny( rRequest
) );
213 // Fill continuations...
214 uno::Sequence
< ucb::RememberAuthentication
> aRememberModes(
215 bAllowPersistentStoring
? 3 : 2 );
216 aRememberModes
[ 0 ] = ucb::RememberAuthentication_NO
;
217 aRememberModes
[ 1 ] = ucb::RememberAuthentication_SESSION
;
218 if (bAllowPersistentStoring
)
219 aRememberModes
[ 2 ] = ucb::RememberAuthentication_PERSISTENT
;
222 = new InteractionSupplyAuthentication(
228 aRememberModes
, // rRememberPasswordModes
229 ucb::RememberAuthentication_SESSION
, // eDefaultRememberPasswordMode
230 aRememberModes
, // rRememberAccountModes
231 ucb::RememberAuthentication_SESSION
, // eDefaultRememberAccountMode
232 bAllowUseSystemCredentials
, // bCanUseSystemCredentials,
233 false // bDefaultUseSystemCredentials
237 uno::Reference
< task::XInteractionContinuation
> > aContinuations( 3 );
238 aContinuations
[ 0 ] = new InteractionAbort( this );
239 aContinuations
[ 1 ] = new InteractionRetry( this );
240 aContinuations
[ 2 ] = m_xAuthSupplier
.get();
242 setContinuations( aContinuations
);