fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / ucbhelper / source / provider / simpleauthenticationrequest.cxx
blobad6c9cd8a8c4062be3ba53fa3b1af27e91fadcf2
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 const OUString & rAccount,
35 bool bAllowPersistentStoring,
36 bool bAllowUseSystemCredentials,
37 bool bAllowSessionStoring )
40 // Fill request...
41 ucb::URLAuthenticationRequest aRequest;
42 // aRequest.Message = // OUString
43 // aRequest.Context = // XInterface
44 aRequest.Classification = task::InteractionClassification_ERROR;
45 aRequest.ServerName = rServerName;
46 // aRequest.Diagnostic = // OUString
47 aRequest.HasRealm = !rRealm.isEmpty();
48 if ( aRequest.HasRealm )
49 aRequest.Realm = rRealm;
50 aRequest.HasUserName = sal_True;
51 aRequest.UserName = rUserName;
52 aRequest.HasPassword = sal_True;
53 aRequest.Password = rPassword;
54 aRequest.HasAccount = !rAccount.isEmpty();
55 if ( aRequest.HasAccount )
56 aRequest.Account = rAccount;
57 aRequest.URL = rURL;
59 initialize(aRequest,
60 false,
61 true,
62 true,
63 aRequest.HasAccount,
64 bAllowPersistentStoring,
65 bAllowUseSystemCredentials,
66 bAllowSessionStoring );
70 SimpleAuthenticationRequest::SimpleAuthenticationRequest(
71 const OUString & rURL,
72 const OUString & rServerName,
73 EntityType eRealmType,
74 const OUString & rRealm,
75 EntityType eUserNameType,
76 const OUString & rUserName,
77 EntityType ePasswordType,
78 const OUString & rPassword,
79 EntityType eAccountType,
80 const OUString & rAccount )
82 // Fill request...
83 ucb::URLAuthenticationRequest aRequest;
84 // aRequest.Message = // OUString
85 // aRequest.Context = // XInterface
86 aRequest.Classification = task::InteractionClassification_ERROR;
87 aRequest.ServerName = rServerName;
88 // aRequest.Diagnostic = // OUString
89 aRequest.HasRealm = eRealmType != ENTITY_NA;
90 if ( aRequest.HasRealm )
91 aRequest.Realm = rRealm;
92 aRequest.HasUserName = eUserNameType != ENTITY_NA;
93 if ( aRequest.HasUserName )
94 aRequest.UserName = rUserName;
95 aRequest.HasPassword = ePasswordType != ENTITY_NA;
96 if ( aRequest.HasPassword )
97 aRequest.Password = rPassword;
98 aRequest.HasAccount = eAccountType != ENTITY_NA;
99 if ( aRequest.HasAccount )
100 aRequest.Account = rAccount;
101 aRequest.URL = rURL;
103 initialize(aRequest,
104 eRealmType == ENTITY_MODIFY,
105 eUserNameType == ENTITY_MODIFY,
106 ePasswordType == ENTITY_MODIFY,
107 eAccountType == ENTITY_MODIFY,
108 true,
109 false );
113 void SimpleAuthenticationRequest::initialize(
114 const ucb::URLAuthenticationRequest & rRequest,
115 bool bCanSetRealm,
116 bool bCanSetUserName,
117 bool bCanSetPassword,
118 bool bCanSetAccount,
119 bool bAllowPersistentStoring,
120 bool bAllowUseSystemCredentials,
121 bool bAllowSessionStoring )
123 setRequest( uno::makeAny( rRequest ) );
125 // Fill continuations...
126 unsigned int nSize = 1;
127 unsigned int nPos = 0;
129 if( bAllowSessionStoring )
130 nSize++;
132 if( bAllowPersistentStoring )
133 nSize++;
135 uno::Sequence< ucb::RememberAuthentication > aRememberModes( nSize );
136 aRememberModes[ nPos++ ] = ucb::RememberAuthentication_NO;
138 if( bAllowSessionStoring )
139 aRememberModes[ nPos++ ] = ucb::RememberAuthentication_SESSION;
141 if ( bAllowPersistentStoring )
142 aRememberModes[ nPos++ ] = ucb::RememberAuthentication_PERSISTENT;
144 m_xAuthSupplier
145 = new InteractionSupplyAuthentication(
146 this,
147 bCanSetRealm,
148 bCanSetUserName,
149 bCanSetPassword,
150 bCanSetAccount,
151 aRememberModes, // rRememberPasswordModes
152 ucb::RememberAuthentication_SESSION, // eDefaultRememberPasswordMode
153 aRememberModes, // rRememberAccountModes
154 ucb::RememberAuthentication_SESSION, // eDefaultRememberAccountMode
155 bAllowUseSystemCredentials, // bCanUseSystemCredentials,
156 false // bDefaultUseSystemCredentials
159 uno::Sequence<
160 uno::Reference< task::XInteractionContinuation > > aContinuations( 3 );
161 aContinuations[ 0 ] = new InteractionAbort( this );
162 aContinuations[ 1 ] = new InteractionRetry( this );
163 aContinuations[ 2 ] = m_xAuthSupplier.get();
165 setContinuations( aContinuations );
168 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */