diff options
Diffstat (limited to '')
-rw-r--r-- | Common/OpenSim.Framework/UserProfileManager.cs | 299 |
1 files changed, 0 insertions, 299 deletions
diff --git a/Common/OpenSim.Framework/UserProfileManager.cs b/Common/OpenSim.Framework/UserProfileManager.cs deleted file mode 100644 index a4dac05..0000000 --- a/Common/OpenSim.Framework/UserProfileManager.cs +++ /dev/null | |||
@@ -1,299 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSim Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | * | ||
27 | */ | ||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Collections; | ||
31 | using System.Text; | ||
32 | using System.Text.RegularExpressions; | ||
33 | using System.Xml; | ||
34 | using libsecondlife; | ||
35 | using Nwc.XmlRpc; | ||
36 | using OpenSim.Framework.Sims; | ||
37 | using OpenSim.Framework.Inventory; | ||
38 | using OpenSim.Framework.Utilities; | ||
39 | |||
40 | namespace OpenSim.Framework.User | ||
41 | { | ||
42 | public class UserProfileManager : UserProfileManagerBase | ||
43 | { | ||
44 | public string GridURL; | ||
45 | public string GridSendKey; | ||
46 | public string GridRecvKey; | ||
47 | public string DefaultStartupMsg; | ||
48 | |||
49 | public UserProfileManager() | ||
50 | { | ||
51 | |||
52 | } | ||
53 | |||
54 | public void SetKeys(string sendKey, string recvKey, string url, string message) | ||
55 | { | ||
56 | GridRecvKey = recvKey; | ||
57 | GridSendKey = sendKey; | ||
58 | GridURL = url; | ||
59 | DefaultStartupMsg = message; | ||
60 | } | ||
61 | |||
62 | public virtual string ParseXMLRPC(string requestBody) | ||
63 | { | ||
64 | |||
65 | XmlRpcRequest request = (XmlRpcRequest)(new XmlRpcRequestDeserializer()).Deserialize(requestBody); | ||
66 | |||
67 | switch (request.MethodName) | ||
68 | { | ||
69 | case "login_to_simulator": | ||
70 | XmlRpcResponse response = XmlRpcLoginMethod(request); | ||
71 | |||
72 | return (Regex.Replace(XmlRpcResponseSerializer.Singleton.Serialize(response), "utf-16", "utf-8")); | ||
73 | } | ||
74 | |||
75 | return ""; | ||
76 | } | ||
77 | |||
78 | public string RestDeleteUserSessionMethod( string request, string path, string param ) | ||
79 | { | ||
80 | LLUUID sessionid = new LLUUID(param); // get usersessions/sessionid | ||
81 | foreach (libsecondlife.LLUUID UUID in UserProfiles.Keys) | ||
82 | { | ||
83 | if ( UserProfiles[UUID].CurrentSessionID == sessionid) | ||
84 | { | ||
85 | UserProfiles[UUID].CurrentSessionID = null; | ||
86 | UserProfiles[UUID].CurrentSecureSessionID = null; | ||
87 | UserProfiles[UUID].Circuits.Clear(); | ||
88 | } | ||
89 | } | ||
90 | |||
91 | return "OK"; | ||
92 | } | ||
93 | |||
94 | public XmlRpcResponse XmlRpcLoginMethod(XmlRpcRequest request) | ||
95 | { | ||
96 | XmlRpcResponse response = new XmlRpcResponse(); | ||
97 | Hashtable requestData = (Hashtable)request.Params[0]; | ||
98 | |||
99 | bool GoodXML = (requestData.Contains("first") && requestData.Contains("last") && requestData.Contains("passwd")); | ||
100 | bool GoodLogin = false; | ||
101 | string firstname = ""; | ||
102 | string lastname = ""; | ||
103 | string passwd = ""; | ||
104 | |||
105 | if (GoodXML) | ||
106 | { | ||
107 | firstname = (string)requestData["first"]; | ||
108 | lastname = (string)requestData["last"]; | ||
109 | passwd = (string)requestData["passwd"]; | ||
110 | GoodLogin = AuthenticateUser(firstname, lastname, passwd); | ||
111 | } | ||
112 | |||
113 | |||
114 | if (!(GoodXML && GoodLogin)) | ||
115 | { | ||
116 | response = CreateErrorConnectingToGridResponse(); | ||
117 | } | ||
118 | else | ||
119 | { | ||
120 | UserProfile TheUser = GetProfileByName(firstname, lastname); | ||
121 | //we need to sort out how sessions are logged out , currently the sim tells the gridserver | ||
122 | //but if as this suggests the userserver handles it then please have the sim telling the userserver instead | ||
123 | //as it really makes things messy for sandbox mode | ||
124 | //if (!((TheUser.CurrentSessionID == null) && (TheUser.CurrentSecureSessionID == null))) | ||
125 | // { | ||
126 | // response = CreateAlreadyLoggedInResponse(); | ||
127 | // } | ||
128 | //else | ||
129 | //{ | ||
130 | try | ||
131 | { | ||
132 | Hashtable responseData = new Hashtable(); | ||
133 | |||
134 | LLUUID AgentID = TheUser.UUID; | ||
135 | TheUser.InitSessionData(); | ||
136 | |||
137 | //for loading data from a grid server, make any changes in CustomiseResponse() (or create a sub class of this and override that method) | ||
138 | //SimProfile SimInfo = new SimProfile(); | ||
139 | //SimInfo = SimInfo.LoadFromGrid(TheUser.homeregionhandle, GridURL, GridSendKey, GridRecvKey); | ||
140 | |||
141 | |||
142 | Hashtable GlobalT = new Hashtable(); | ||
143 | GlobalT["sun_texture_id"] = "cce0f112-878f-4586-a2e2-a8f104bba271"; | ||
144 | GlobalT["cloud_texture_id"] = "fc4b9f0b-d008-45c6-96a4-01dd947ac621"; | ||
145 | GlobalT["moon_texture_id"] = "fc4b9f0b-d008-45c6-96a4-01dd947ac621"; | ||
146 | ArrayList GlobalTextures = new ArrayList(); | ||
147 | GlobalTextures.Add(GlobalT); | ||
148 | |||
149 | Hashtable LoginFlagsHash = new Hashtable(); | ||
150 | LoginFlagsHash["daylight_savings"] = "N"; | ||
151 | LoginFlagsHash["stipend_since_login"] = "N"; | ||
152 | LoginFlagsHash["gendered"] = "Y"; | ||
153 | LoginFlagsHash["ever_logged_in"] = "Y"; | ||
154 | ArrayList LoginFlags = new ArrayList(); | ||
155 | LoginFlags.Add(LoginFlagsHash); | ||
156 | |||
157 | Hashtable uiconfig = new Hashtable(); | ||
158 | uiconfig["allow_first_life"] = "Y"; | ||
159 | ArrayList ui_config = new ArrayList(); | ||
160 | ui_config.Add(uiconfig); | ||
161 | |||
162 | Hashtable ClassifiedCategoriesHash = new Hashtable(); | ||
163 | ClassifiedCategoriesHash["category_name"] = "bla bla"; | ||
164 | ClassifiedCategoriesHash["category_id"] = (Int32)1; | ||
165 | ArrayList ClassifiedCategories = new ArrayList(); | ||
166 | ClassifiedCategories.Add(ClassifiedCategoriesHash); | ||
167 | |||
168 | ArrayList AgentInventory = new ArrayList(); | ||
169 | Console.WriteLine("adding inventory to response"); | ||
170 | Hashtable TempHash; | ||
171 | foreach (InventoryFolder InvFolder in TheUser.Inventory.InventoryFolders.Values) | ||
172 | { | ||
173 | TempHash = new Hashtable(); | ||
174 | Console.WriteLine("adding folder " + InvFolder.FolderName + ", ID: " + InvFolder.FolderID.ToStringHyphenated() + " with parent: " + InvFolder.ParentID.ToStringHyphenated()); | ||
175 | TempHash["name"] = InvFolder.FolderName; | ||
176 | TempHash["parent_id"] = InvFolder.ParentID.ToStringHyphenated(); | ||
177 | TempHash["version"] = (Int32)InvFolder.Version; | ||
178 | TempHash["type_default"] = (Int32)InvFolder.DefaultType; | ||
179 | TempHash["folder_id"] = InvFolder.FolderID.ToStringHyphenated(); | ||
180 | AgentInventory.Add(TempHash); | ||
181 | } | ||
182 | |||
183 | Hashtable InventoryRootHash = new Hashtable(); | ||
184 | InventoryRootHash["folder_id"] = TheUser.Inventory.InventoryRoot.FolderID.ToStringHyphenated(); | ||
185 | ArrayList InventoryRoot = new ArrayList(); | ||
186 | InventoryRoot.Add(InventoryRootHash); | ||
187 | |||
188 | Hashtable InitialOutfitHash = new Hashtable(); | ||
189 | InitialOutfitHash["folder_name"] = "Nightclub Female"; | ||
190 | InitialOutfitHash["gender"] = "female"; | ||
191 | ArrayList InitialOutfit = new ArrayList(); | ||
192 | InitialOutfit.Add(InitialOutfitHash); | ||
193 | |||
194 | uint circode = (uint)(Util.RandomClass.Next()); | ||
195 | //TheUser.AddSimCircuit(circode, SimInfo.UUID); | ||
196 | |||
197 | responseData["last_name"] = TheUser.lastname; | ||
198 | responseData["ui-config"] = ui_config; | ||
199 | responseData["sim_ip"] = "127.0.0.1"; //SimInfo.sim_ip.ToString(); | ||
200 | responseData["login-flags"] = LoginFlags; | ||
201 | responseData["global-textures"] = GlobalTextures; | ||
202 | responseData["classified_categories"] = ClassifiedCategories; | ||
203 | responseData["event_categories"] = new ArrayList(); | ||
204 | responseData["inventory-skeleton"] = AgentInventory; | ||
205 | responseData["inventory-skel-lib"] = new ArrayList(); | ||
206 | responseData["inventory-root"] = InventoryRoot; | ||
207 | responseData["event_notifications"] = new ArrayList(); | ||
208 | responseData["gestures"] = new ArrayList(); | ||
209 | responseData["inventory-lib-owner"] = new ArrayList(); | ||
210 | responseData["initial-outfit"] = InitialOutfit; | ||
211 | responseData["seconds_since_epoch"] = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; | ||
212 | responseData["start_location"] = "last"; | ||
213 | responseData["home"] = "{'region_handle':[r" + (0 * 256).ToString() + ",r" + (0 * 256).ToString() + "], 'position':[r" + TheUser.homepos.X.ToString() + ",r" + TheUser.homepos.Y.ToString() + ",r" + TheUser.homepos.Z.ToString() + "], 'look_at':[r" + TheUser.homelookat.X.ToString() + ",r" + TheUser.homelookat.Y.ToString() + ",r" + TheUser.homelookat.Z.ToString() + "]}"; | ||
214 | responseData["message"] = DefaultStartupMsg; | ||
215 | responseData["first_name"] = TheUser.firstname; | ||
216 | responseData["circuit_code"] = (Int32)circode; | ||
217 | responseData["sim_port"] = 0; //(Int32)SimInfo.sim_port; | ||
218 | responseData["secure_session_id"] = TheUser.CurrentSecureSessionID.ToStringHyphenated(); | ||
219 | responseData["look_at"] = "\n[r" + TheUser.homelookat.X.ToString() + ",r" + TheUser.homelookat.Y.ToString() + ",r" + TheUser.homelookat.Z.ToString() + "]\n"; | ||
220 | responseData["agent_id"] = AgentID.ToStringHyphenated(); | ||
221 | responseData["region_y"] = (Int32)0 * 256; // (Int32)SimInfo.RegionLocY * 256; | ||
222 | responseData["region_x"] = (Int32)0 * 256; //SimInfo.RegionLocX * 256; | ||
223 | responseData["seed_capability"] = ""; | ||
224 | responseData["agent_access"] = "M"; | ||
225 | responseData["session_id"] = TheUser.CurrentSessionID.ToStringHyphenated(); | ||
226 | responseData["login"] = "true"; | ||
227 | |||
228 | this.CustomiseResponse(ref responseData, TheUser); | ||
229 | response.Value = responseData; | ||
230 | // TheUser.SendDataToSim(SimInfo); | ||
231 | return response; | ||
232 | |||
233 | } | ||
234 | catch (Exception E) | ||
235 | { | ||
236 | Console.WriteLine(E.ToString()); | ||
237 | } | ||
238 | //} | ||
239 | } | ||
240 | return response; | ||
241 | |||
242 | } | ||
243 | |||
244 | private static XmlRpcResponse CreateErrorConnectingToGridResponse() | ||
245 | { | ||
246 | XmlRpcResponse response = new XmlRpcResponse(); | ||
247 | Hashtable ErrorRespData = new Hashtable(); | ||
248 | ErrorRespData["reason"] = "key"; | ||
249 | ErrorRespData["message"] = "Error connecting to grid. Please double check your login details and check with the grid owner if you are sure these are correct"; | ||
250 | ErrorRespData["login"] = "false"; | ||
251 | response.Value = ErrorRespData; | ||
252 | return response; | ||
253 | } | ||
254 | |||
255 | private static XmlRpcResponse CreateAlreadyLoggedInResponse() | ||
256 | { | ||
257 | XmlRpcResponse response = new XmlRpcResponse(); | ||
258 | Hashtable PresenceErrorRespData = new Hashtable(); | ||
259 | PresenceErrorRespData["reason"] = "presence"; | ||
260 | PresenceErrorRespData["message"] = "You appear to be already logged in, if this is not the case please wait for your session to timeout, if this takes longer than a few minutes please contact the grid owner"; | ||
261 | PresenceErrorRespData["login"] = "false"; | ||
262 | response.Value = PresenceErrorRespData; | ||
263 | return response; | ||
264 | } | ||
265 | |||
266 | public virtual void CustomiseResponse(ref Hashtable response, UserProfile theUser) | ||
267 | { | ||
268 | //default method set up to act as ogs user server | ||
269 | SimProfile SimInfo= new SimProfile(); | ||
270 | //get siminfo from grid server | ||
271 | SimInfo = SimInfo.LoadFromGrid(theUser.homeregionhandle, GridURL, GridSendKey, GridRecvKey); | ||
272 | Int32 circode = (Int32)Convert.ToUInt32(response["circuit_code"]); | ||
273 | theUser.AddSimCircuit((uint)circode, SimInfo.UUID); | ||
274 | response["home"] = "{'region_handle':[r" + (SimInfo.RegionLocX * 256).ToString() + ",r" + (SimInfo.RegionLocY * 256).ToString() + "], 'position':[r" + theUser.homepos.X.ToString() + ",r" + theUser.homepos.Y.ToString() + ",r" + theUser.homepos.Z.ToString() + "], 'look_at':[r" + theUser.homelookat.X.ToString() + ",r" + theUser.homelookat.Y.ToString() + ",r" + theUser.homelookat.Z.ToString() + "]}"; | ||
275 | response["sim_ip"] = SimInfo.sim_ip; | ||
276 | response["sim_port"] = (Int32)SimInfo.sim_port; | ||
277 | response["region_y"] = (Int32)SimInfo.RegionLocY * 256; | ||
278 | response["region_x"] = (Int32)SimInfo.RegionLocX * 256; | ||
279 | |||
280 | //default is ogs user server, so let the sim know about the user via a XmlRpcRequest | ||
281 | Console.WriteLine(SimInfo.caps_url); | ||
282 | Hashtable SimParams = new Hashtable(); | ||
283 | SimParams["session_id"] = theUser.CurrentSessionID.ToString(); | ||
284 | SimParams["secure_session_id"] = theUser.CurrentSecureSessionID.ToString(); | ||
285 | SimParams["firstname"] = theUser.firstname; | ||
286 | SimParams["lastname"] = theUser.lastname; | ||
287 | SimParams["agent_id"] = theUser.UUID.ToString(); | ||
288 | SimParams["circuit_code"] = (Int32)circode; | ||
289 | SimParams["startpos_x"] = theUser.homepos.X.ToString(); | ||
290 | SimParams["startpos_y"] = theUser.homepos.Y.ToString(); | ||
291 | SimParams["startpos_z"] = theUser.homepos.Z.ToString(); | ||
292 | ArrayList SendParams = new ArrayList(); | ||
293 | SendParams.Add(SimParams); | ||
294 | |||
295 | XmlRpcRequest GridReq = new XmlRpcRequest("expect_user", SendParams); | ||
296 | XmlRpcResponse GridResp = GridReq.Send(SimInfo.caps_url, 3000); | ||
297 | } | ||
298 | } | ||
299 | } | ||