aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/lluserauth.h
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:44:46 -0500
committerJacek Antonelli2008-08-15 23:44:46 -0500
commit38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4 (patch)
treeadca584755d22ca041a2dbfc35d4eca01f70b32c /linden/indra/newview/lluserauth.h
parentREADME.txt (diff)
downloadmeta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.zip
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.gz
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.bz2
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.xz
Second Life viewer sources 1.13.2.12
Diffstat (limited to '')
-rw-r--r--linden/indra/newview/lluserauth.h135
1 files changed, 135 insertions, 0 deletions
diff --git a/linden/indra/newview/lluserauth.h b/linden/indra/newview/lluserauth.h
new file mode 100644
index 0000000..d50f5b4
--- /dev/null
+++ b/linden/indra/newview/lluserauth.h
@@ -0,0 +1,135 @@
1/**
2 * @file lluserauth.h
3 * @brief LLUserAuth class header file
4 *
5 * Copyright (c) 2003-2007, Linden Research, Inc.
6 *
7 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement
10 * ("Other License"), formally executed by you and Linden Lab. Terms of
11 * the GPL can be found in doc/GPL-license.txt in this distribution, or
12 * online at http://secondlife.com/developers/opensource/gplv2
13 *
14 * There are special exceptions to the terms and conditions of the GPL as
15 * it is applied to this Source Code. View the full text of the exception
16 * in the file doc/FLOSS-exception.txt in this software distribution, or
17 * online at http://secondlife.com/developers/opensource/flossexception
18 *
19 * By copying, modifying or distributing this software, you acknowledge
20 * that you have read and understood your obligations described above,
21 * and agree to abide by those obligations.
22 *
23 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
24 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
25 * COMPLETENESS OR PERFORMANCE.
26 */
27
28#ifndef LLUSERAUTH_H
29#define LLUSERAUTH_H
30
31#include <string>
32#include <vector>
33#include <map>
34
35class LLXMLRPCTransaction;
36
37//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
38// Class LLUserAuth
39//
40// This class encapsulates the authentication and initialization from
41// the login server. Construct an instance of this object, and call
42// the authenticate() method, and call authResponse() until it returns
43// a non-negative value. If that method returns E_OK, you can start
44// asking for responses via the getResponse() method. Here is some
45// sample code that gets the session id if login was successful:
46//
47// auth.authenticate(...);
48// while((auth.authResponse() < 0)) {sleep(1);}
49// LLUUID session_id;
50// if(0 == strcmp(auth.getResponse("login"), "true"))
51// {
52// const char* session_id_str = auth.getResponse("session-id");
53// if(session_id_str) session_id.set(session_id_str);
54// }
55//
56// Format for responses as maintained in login.cgi:
57// login = 'true' | 'false'
58// reason = [ 'data' | -- insufficient or poorly formatted data
59// 'ban' | -- user is banned
60// 'update' | -- viewer requires update
61// 'optional' | -- optional viewer update
62// 'key' | -- mismatched first/last/passwd
63// message = human readable message for client
64// session-id = auth key
65//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
66
67class LLUserAuth
68{
69public:
70 LLUserAuth();
71 ~LLUserAuth();
72
73 // These codes map to the curl return codes...
74 typedef enum {
75 E_NO_RESPONSE_YET = -2,
76 E_DOWNLOADING = -1,
77 E_OK = 0,
78 E_COULDNT_RESOLVE_HOST,
79 E_SSL_PEER_CERTIFICATE,
80 E_SSL_CACERT,
81 E_SSL_CONNECT_ERROR,
82 E_UNHANDLED_ERROR,
83 E_LAST // never use!
84 } UserAuthcode;
85
86 // used for holding options
87 typedef std::map<std::string, std::string> response_t;
88 typedef std::vector<response_t> options_t;
89
90 void authenticate(
91 const char* auth_uri,
92 const char* auth_method,
93 const char* firstname,
94 const char* lastname,
95 const char* passwd,
96 const char* start,
97 BOOL skip_optional_update,
98 BOOL accept_tos,
99 BOOL accept_critical_message,
100 const LLUUID& viewer_digest,
101 BOOL last_exec_froze,
102 const std::vector<const char*>& requested_options,
103 const std::string& hashed_mac,
104 const std::string& hashed_volume_serial);
105
106 UserAuthcode authResponse();
107
108 std::string errorMessage() const { return mErrorMessage; }
109
110 // function to get a direct reponse from the login api by
111 // name. returns NULL if the named response was not found.
112 const char* getResponse(const char* name) const;
113 BOOL getOptions(const char* name, options_t& options) const;
114
115 F64 getLastTransferRateBPS() const { return mLastTransferRateBPS; }
116
117private:
118 LLXMLRPCTransaction* mTransaction;
119
120 UserAuthcode mAuthResponse;
121 std::string mErrorMessage;
122
123 // dealing with the XML
124 typedef std::map<std::string, options_t> all_options_t;
125 response_t mResponses;
126 all_options_t mOptions;
127
128 UserAuthcode parseResponse();
129
130 F64 mLastTransferRateBPS; // bits per second, only valid after a big transfer like inventory
131};
132
133extern LLUserAuth *gUserAuthp;
134
135#endif /* LLUSERAUTH_H */