LibreOffice Module ucbhelper (master) 1
simpleauthenticationrequest.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#include <com/sun/star/ucb/URLAuthenticationRequest.hpp>
22
23using namespace com::sun::star;
24using namespace ucbhelper;
25
26
27SimpleAuthenticationRequest::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 )
35{
36
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;
53
54 initialize(aRequest,
55 false,
56 true,
57 true,
58 aRequest.HasAccount,
59 bAllowUseSystemCredentials,
60 bAllowSessionStoring );
61}
62
63
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)
73{
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;
92
93 initialize(aRequest,
94 eRealmType == ENTITY_MODIFY,
95 eUserNameType == ENTITY_MODIFY,
96 ePasswordType == ENTITY_MODIFY,
97 false,
98 false,
99 true );
100}
101
102
104 const ucb::URLAuthenticationRequest & rRequest,
105 bool bCanSetRealm,
106 bool bCanSetUserName,
107 bool bCanSetPassword,
108 bool bCanSetAccount,
109 bool bAllowUseSystemCredentials,
110 bool bAllowSessionStoring )
111{
112 setRequest( uno::Any( rRequest ) );
113
114 // Fill continuations...
115 unsigned int nSize = 2;
116
117 if( bAllowSessionStoring )
118 nSize++;
119
120 uno::Sequence< ucb::RememberAuthentication > aRememberModes( nSize );
121 auto it = aRememberModes.getArray();
122 *it++ = ucb::RememberAuthentication_NO;
123
124 if( bAllowSessionStoring )
125 *it++ = ucb::RememberAuthentication_SESSION;
126
127 *it = ucb::RememberAuthentication_PERSISTENT;
128
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,
141 );
142
144 { new InteractionAbort(this), new InteractionRetry(this), m_xAuthSupplier });
145}
146
147/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
This class implements a standard interaction continuation, namely the interface XInteractionAbort.
void setRequest(const css::uno::Any &rRequest)
void setContinuations(const css::uno::Sequence< css::uno::Reference< css::task::XInteractionContinuation > > &rContinuations)
This method sets the continuations for the request.
This class implements a standard interaction continuation, namely the interface XInteractionRetry.
This class implements a standard interaction continuation, namely the interface XInteractionSupplyAut...
void initialize(const css::ucb::URLAuthenticationRequest &rRequest, bool bCanSetRealm, bool bCanSetUserName, bool bCanSetPassword, bool bCanSetAccount, bool bAllowUseSystemCredentials, bool bAllowSessionStoring)
SimpleAuthenticationRequest(const OUString &rURL, const OUString &rServerName, const OUString &rRealm, const OUString &rUserName, const OUString &rPassword, bool bAllowUseSystemCredentials, bool bAllowSessionStoring=true)
Constructor.
EntityType
Specification whether some entity (realm, username, password, account) is either not applicable at al...
rtl::Reference< ucbhelper::InteractionSupplyAuthentication > m_xAuthSupplier