-
Notifications
You must be signed in to change notification settings - Fork 3
/
brokerXml.hh
328 lines (265 loc) · 9.78 KB
/
brokerXml.hh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
/*********************************************************
* Copyright (C) 2008 VMware, Inc. All rights reserved.
*
* This file is part of VMware View Open Client.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation version 2.1 and no later version.
*
* This program is released with an additional exemption that
* compiling, linking, and/or using the OpenSSL libraries with this
* program is allowed.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the Lesser GNU General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
*********************************************************/
/*
* brokerXml.hh --
*
* Handlers for the specific Broker XML API requests.
*/
#ifndef BROKER_XML_HH
#define BROKER_XML_HH
#if defined(_WIN32) && !defined(__MINGW32__)
#include <atlbase.h>
#endif
#include <boost/function.hpp>
#include <libxml/tree.h>
#include <vector>
#include "baseXml.hh"
namespace cdk {
class BrokerXml
: public BaseXml
{
public:
enum AuthType {
AUTH_NONE = 0,
AUTH_DISCLAIMER,
AUTH_SECURID_PASSCODE,
AUTH_SECURID_NEXTTOKENCODE,
AUTH_SECURID_PINCHANGE,
AUTH_SECURID_WAIT,
AUTH_WINDOWS_PASSWORD,
AUTH_WINDOWS_PASSWORD_EXPIRED,
AUTH_CERT_AUTH
};
enum OfflineState {
OFFLINE_CHECKED_IN,
OFFLINE_CHECKED_OUT,
OFFLINE_CHECKING_IN,
OFFLINE_CHECKING_OUT,
OFFLINE_BACKGROUND_CHECKING_IN,
OFFLINE_ROLLING_BACK,
OFFLINE_NONE
};
struct AuthInfo
{
Util::string name;
Util::string title;
Util::string text;
std::vector<Param> params;
bool Parse(xmlNode *parentNode, Util::AbortSlot onAbort);
AuthType GetAuthType() const;
Util::string GetDisclaimer() const;
Util::string GetUsername(bool *readOnly = NULL) const;
std::vector<Util::string> GetDomains() const
{ return GetParam("domain"); }
Util::string GetError() const;
private:
std::vector<Util::string> GetParam(const Util::string name,
bool *readOnly = NULL) const;
};
struct Configuration
{
AuthInfo authInfo;
bool Parse(xmlNode *parentNode, Util::AbortSlot onAbort);
};
struct AuthResult
{
AuthInfo authInfo;
bool logoutOnCertRemoval;
AuthResult() : logoutOnCertRemoval(false) { }
bool Parse(xmlNode *parentNode, Util::AbortSlot onAbort);
};
struct Tunnel
{
// Tunnel Connect
Util::string connectionId;
int statusPort;
Util::string server1;
Util::string server2;
int generation;
// Direct Connect
bool bypassTunnel;
Tunnel();
bool Parse(xmlNode *parentNode, Util::AbortSlot onAbort);
};
typedef std::pair<Util::string, Util::string> Preference;
struct UserPreferences
{
std::vector<Preference> preferences;
bool Parse(xmlNode *parentNode, Util::AbortSlot onAbort);
};
struct Desktop
{
Util::string id;
Util::string name;
Util::string type;
Util::string state;
bool offlineEnabled;
bool endpointEnabled;
OfflineState offlineState;
bool checkedOutByOther;
Util::string sessionId;
bool resetAllowed;
bool resetAllowedOnSession;
bool inMaintenance;
UserPreferences userPreferences;
std::vector<Util::string> protocols;
int defaultProtocol;
bool expired;
uint64 progressWorkDoneSoFar;
uint64 progressTotalWork;
bool checkedOutHereAndDisabled;
Desktop();
virtual ~Desktop() {}
virtual bool Parse(xmlNode *parentNode, Util::AbortSlot onAbort);
};
typedef std::vector<Desktop> DesktopList;
struct EntitledDesktops
{
DesktopList desktops;
virtual ~EntitledDesktops() {}
bool Parse(xmlNode *parentNode, Util::AbortSlot onAbort);
};
struct Listener
{
Util::string address;
int port;
bool Parse(xmlNode *parentNode, Util::string &name,
Util::AbortSlot onAbort);
};
// Maps listener names to listener objects.
typedef std::map<Util::string, Listener> ListenerMap;
struct DesktopConnection
{
ListenerMap listeners;
Util::string id;
Util::string address;
int port;
Util::string channelTicket;
Util::string protocol;
Util::string username;
Util::string password;
Util::string domainName;
Util::string token;
bool enableUSB;
bool enableMMR;
DesktopConnection();
bool Parse(xmlNode *parentNode, Util::AbortSlot onAbort);
};
typedef boost::function2<void, Result&, Configuration&> ConfigurationSlot;
typedef boost::function1<void, Result&> LocaleSlot;
typedef boost::function2<void, Result&, AuthResult&> AuthenticationSlot;
typedef boost::function2<void, Result&, Tunnel&> TunnelConnectionSlot;
typedef boost::function2<void, Result&, EntitledDesktops&> DesktopsSlot;
typedef boost::function2<void, Result&, UserPreferences&> PreferencesSlot;
typedef boost::function3<void, Result&, Util::string,
UserPreferences&> DesktopPreferencesSlot;
typedef boost::function2<void, Result&,
DesktopConnection&> DesktopConnectionSlot;
typedef boost::function1<void, Result&> LogoutSlot;
typedef boost::function1<void, Result&> KillSessionSlot;
typedef boost::function1<void, Result&> ResetDesktopSlot;
typedef boost::function1<void, Result&> RollbackSlot;
struct DoneSlots {
ConfigurationSlot configuration;
LocaleSlot locale;
AuthenticationSlot authentication;
TunnelConnectionSlot tunnelConnection;
DesktopsSlot desktops;
PreferencesSlot preferences;
DesktopPreferencesSlot desktopPreferences;
DesktopConnectionSlot desktopConnection;
LogoutSlot logout;
KillSessionSlot killSession;
ResetDesktopSlot reset;
RollbackSlot rollback;
};
struct RequestState
: public BaseXml::RequestState
{
DoneSlots onDone;
};
BrokerXml(Util::string hostname, int port, bool secure,
const Util::string &sslCAPath = "");
virtual ~BrokerXml();
void GetConfiguration(Util::AbortSlot onAbort, ConfigurationSlot onDone);
void SetLocale(Util::string locale, Util::AbortSlot onAbort,
LocaleSlot onDone);
void SubmitAuthentication(AuthInfo &auth, Util::AbortSlot onAbort,
AuthenticationSlot onDone);
void PasswordAuthentication(Util::string username,
Util::string password,
Util::string domain,
Util::AbortSlot onAbort,
AuthenticationSlot onDone);
void SecurIDUsernamePasscode(Util::string username, Util::string passcode,
Util::AbortSlot onAbort,
AuthenticationSlot onDone);
void SecurIDNextTokencode(Util::string tokencode, Util::AbortSlot onAbort,
AuthenticationSlot onDone);
void SecurIDPins(Util::string pin1, Util::string pin2,
Util::AbortSlot onAbort, AuthenticationSlot onDone);
void AcceptDisclaimer(Util::AbortSlot onAbort, AuthenticationSlot onDone);
void ChangePassword(Util::string oldPassword, Util::string newPassword,
Util::string confirm, Util::AbortSlot onAbort,
AuthenticationSlot onDone);
void SubmitCertAuth(bool accept,
const char *pin,
const Util::string &reader,
Util::AbortSlot onAbort,
AuthenticationSlot onDone);
void GetTunnelConnection(Util::AbortSlot onAbort,
TunnelConnectionSlot onDone);
void GetDesktops(std::vector<Util::string> protocols,
Util::AbortSlot onAbort, DesktopsSlot onDone);
void GetUserGlobalPreferences(Util::AbortSlot onAbort,
PreferencesSlot onDone);
void SetUserGlobalPreferences(UserPreferences &preferences,
Util::AbortSlot onAbort,
PreferencesSlot onDone);
void SetUserDesktopPreferences(Util::string desktopId,
UserPreferences &preferences,
Util::AbortSlot onAbort,
DesktopPreferencesSlot onDone);
void GetDesktopConnection(Util::string desktopId,
Util::AbortSlot onAbort,
DesktopConnectionSlot onDone,
const Util::ClientInfoMap &info,
const Util::string &protocol);
void Logout(Util::AbortSlot onAbort, LogoutSlot onDone);
void KillSession(Util::string sessionId,
Util::AbortSlot onAbort,
KillSessionSlot onDone);
void ResetDesktop(Util::string desktopId,
Util::AbortSlot onAbort,
ResetDesktopSlot onDone);
void Rollback(Util::string sessionId,
Util::AbortSlot onAbort,
RollbackSlot onDone);
protected:
virtual bool ResponseDispatch(xmlNode *operationNode,
BaseXml::RequestState &state,
Result &result);
};
} // namespace cdk
#endif // BROKER_XML_HH