tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / ucbhelper / source / provider / simpleauthenticationrequest.cxx
blob972864d9aab62349b532277b3e554f483983c780
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/ucb/URLAuthenticationRequest.hpp>
21 #include <ucbhelper/simpleauthenticationrequest.hxx>
23 using namespace com::sun::star;
24 using namespace ucbhelper;
27 SimpleAuthenticationRequest::SimpleAuthenticationRequest(
28 const OUString & rURL,
29 const OUString & rServerName,
30 const OUString & rRealm,
31 const OUString & rUserName,
32 const OUString & rPassword,
33 bool bAllowUseSystemCredentials,
34 bool bAllowSessionStoring )
37 // Fill request...
38 ucb::URLAuthenticationRequest aRequest;
39 // aRequest.Message = // OUString
40 // aRequest.Context = // XInterface
41 aRequest.Classification = task::InteractionClassification_ERROR;
42 aRequest.ServerName = rServerName;
43 // aRequest.Diagnostic = // OUString
44 aRequest.HasRealm = !rRealm.isEmpty();
45 if ( aRequest.HasRealm )
46 aRequest.Realm = rRealm;
47 aRequest.HasUserName = true;
48 aRequest.UserName = rUserName;
49 aRequest.HasPassword = true;
50 aRequest.Password = rPassword;
51 aRequest.HasAccount = false;
52 aRequest.URL = rURL;
54 initialize(aRequest,
55 false,
56 true,
57 true,
58 aRequest.HasAccount,
59 bAllowUseSystemCredentials,
60 bAllowSessionStoring );
64 SimpleAuthenticationRequest::SimpleAuthenticationRequest(
65 const OUString & rURL,
66 const OUString & rServerName,
67 EntityType eRealmType,
68 const OUString & rRealm,
69 EntityType eUserNameType,
70 const OUString & rUserName,
71 EntityType ePasswordType,
72 const OUString & rPassword)
74 // Fill request...
75 ucb::URLAuthenticationRequest aRequest;
76 // aRequest.Message = // OUString
77 // aRequest.Context = // XInterface
78 aRequest.Classification = task::InteractionClassification_ERROR;
79 aRequest.ServerName = rServerName;
80 // aRequest.Diagnostic = // OUString
81 aRequest.HasRealm = eRealmType != ENTITY_NA;
82 if ( aRequest.HasRealm )
83 aRequest.Realm = rRealm;
84 aRequest.HasUserName = eUserNameType != ENTITY_NA;
85 if ( aRequest.HasUserName )
86 aRequest.UserName = rUserName;
87 aRequest.HasPassword = ePasswordType != ENTITY_NA;
88 if ( aRequest.HasPassword )
89 aRequest.Password = rPassword;
90 aRequest.HasAccount = false;
91 aRequest.URL = rURL;
93 initialize(aRequest,
94 eRealmType == ENTITY_MODIFY,
95 eUserNameType == ENTITY_MODIFY,
96 ePasswordType == ENTITY_MODIFY,
97 false,
98 false,
99 true );
103 void SimpleAuthenticationRequest::initialize(
104 const ucb::URLAuthenticationRequest & rRequest,
105 bool bCanSetRealm,
106 bool bCanSetUserName,
107 bool bCanSetPassword,
108 bool bCanSetAccount,
109 bool bAllowUseSystemCredentials,
110 bool bAllowSessionStoring )
112 setRequest( uno::Any( rRequest ) );
114 // Fill continuations...
115 unsigned int nSize = 2;
117 if( bAllowSessionStoring )
118 nSize++;
120 uno::Sequence< ucb::RememberAuthentication > aRememberModes( nSize );
121 auto it = aRememberModes.getArray();
122 *it++ = ucb::RememberAuthentication_NO;
124 if( bAllowSessionStoring )
125 *it++ = ucb::RememberAuthentication_SESSION;
127 *it = ucb::RememberAuthentication_PERSISTENT;
129 m_xAuthSupplier
130 = new InteractionSupplyAuthentication(
131 this,
132 bCanSetRealm,
133 bCanSetUserName,
134 bCanSetPassword,
135 bCanSetAccount,
136 aRememberModes, // rRememberPasswordModes
137 ucb::RememberAuthentication_SESSION, // eDefaultRememberPasswordMode
138 aRememberModes, // rRememberAccountModes
139 ucb::RememberAuthentication_SESSION, // eDefaultRememberAccountMode
140 bAllowUseSystemCredentials // bCanUseSystemCredentials,
143 setContinuations(
144 { new InteractionAbort(this), new InteractionRetry(this), m_xAuthSupplier });
147 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */