diff options
author | Diva Canto | 2010-01-10 20:29:09 -0800 |
---|---|---|
committer | Diva Canto | 2010-01-10 20:29:09 -0800 |
commit | dc4bbf6065ad4cb914c9d44f2e6496a2e3d99814 (patch) | |
tree | f4cf3aa9f25ca879b87e14941ca4c19197e7c942 /OpenSim/Framework/Communications/Clients/AuthClient.cs | |
parent | All grid servers deleted, including user server. They served us well. (diff) | |
download | opensim-SC-dc4bbf6065ad4cb914c9d44f2e6496a2e3d99814.zip opensim-SC-dc4bbf6065ad4cb914c9d44f2e6496a2e3d99814.tar.gz opensim-SC-dc4bbf6065ad4cb914c9d44f2e6496a2e3d99814.tar.bz2 opensim-SC-dc4bbf6065ad4cb914c9d44f2e6496a2e3d99814.tar.xz |
All Framework.Communications.Clients and Framework.Communications.Services deleted, including old LoginService.
Diffstat (limited to 'OpenSim/Framework/Communications/Clients/AuthClient.cs')
-rw-r--r-- | OpenSim/Framework/Communications/Clients/AuthClient.cs | 151 |
1 files changed, 0 insertions, 151 deletions
diff --git a/OpenSim/Framework/Communications/Clients/AuthClient.cs b/OpenSim/Framework/Communications/Clients/AuthClient.cs deleted file mode 100644 index adae637..0000000 --- a/OpenSim/Framework/Communications/Clients/AuthClient.cs +++ /dev/null | |||
@@ -1,151 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.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 OpenSimulator 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; | ||
30 | using System.Collections.Generic; | ||
31 | using Nwc.XmlRpc; | ||
32 | using OpenMetaverse; | ||
33 | |||
34 | namespace OpenSim.Framework.Communications.Clients | ||
35 | { | ||
36 | public class AuthClient | ||
37 | { | ||
38 | public static string GetNewKey(string authurl, UUID userID, UUID authToken) | ||
39 | { | ||
40 | //Hashtable keyParams = new Hashtable(); | ||
41 | //keyParams["user_id"] = userID; | ||
42 | //keyParams["auth_token"] = authKey; | ||
43 | |||
44 | List<string> SendParams = new List<string>(); | ||
45 | SendParams.Add(userID.ToString()); | ||
46 | SendParams.Add(authToken.ToString()); | ||
47 | |||
48 | XmlRpcRequest request = new XmlRpcRequest("hg_new_auth_key", SendParams); | ||
49 | XmlRpcResponse reply; | ||
50 | try | ||
51 | { | ||
52 | reply = request.Send(authurl, 6000); | ||
53 | } | ||
54 | catch (Exception e) | ||
55 | { | ||
56 | System.Console.WriteLine("[HGrid]: Failed to get new key. Reason: " + e.Message); | ||
57 | return string.Empty; | ||
58 | } | ||
59 | |||
60 | if (!reply.IsFault) | ||
61 | { | ||
62 | string newKey = string.Empty; | ||
63 | if (reply.Value != null) | ||
64 | newKey = (string)reply.Value; | ||
65 | |||
66 | return newKey; | ||
67 | } | ||
68 | else | ||
69 | { | ||
70 | System.Console.WriteLine("[HGrid]: XmlRpc request to get auth key failed with message {0}" + reply.FaultString + ", code " + reply.FaultCode); | ||
71 | return string.Empty; | ||
72 | } | ||
73 | |||
74 | } | ||
75 | |||
76 | public static bool VerifyKey(string authurl, UUID userID, string authKey) | ||
77 | { | ||
78 | List<string> SendParams = new List<string>(); | ||
79 | SendParams.Add(userID.ToString()); | ||
80 | SendParams.Add(authKey); | ||
81 | |||
82 | System.Console.WriteLine("[HGrid]: Verifying user key with authority " + authurl); | ||
83 | |||
84 | XmlRpcRequest request = new XmlRpcRequest("hg_verify_auth_key", SendParams); | ||
85 | XmlRpcResponse reply; | ||
86 | try | ||
87 | { | ||
88 | reply = request.Send(authurl, 10000); | ||
89 | } | ||
90 | catch (Exception e) | ||
91 | { | ||
92 | System.Console.WriteLine("[HGrid]: Failed to verify key. Reason: " + e.Message); | ||
93 | return false; | ||
94 | } | ||
95 | |||
96 | if (reply != null) | ||
97 | { | ||
98 | if (!reply.IsFault) | ||
99 | { | ||
100 | bool success = false; | ||
101 | if (reply.Value != null) | ||
102 | success = (bool)reply.Value; | ||
103 | |||
104 | return success; | ||
105 | } | ||
106 | else | ||
107 | { | ||
108 | System.Console.WriteLine("[HGrid]: XmlRpc request to verify key failed with message {0}" + reply.FaultString + ", code " + reply.FaultCode); | ||
109 | return false; | ||
110 | } | ||
111 | } | ||
112 | else | ||
113 | { | ||
114 | System.Console.WriteLine("[HGrid]: XmlRpc request to verify key returned null reply"); | ||
115 | return false; | ||
116 | } | ||
117 | } | ||
118 | |||
119 | public static bool VerifySession(string authurl, UUID userID, UUID sessionID) | ||
120 | { | ||
121 | Hashtable requestData = new Hashtable(); | ||
122 | requestData["avatar_uuid"] = userID.ToString(); | ||
123 | requestData["session_id"] = sessionID.ToString(); | ||
124 | ArrayList SendParams = new ArrayList(); | ||
125 | SendParams.Add(requestData); | ||
126 | XmlRpcRequest UserReq = new XmlRpcRequest("check_auth_session", SendParams); | ||
127 | XmlRpcResponse UserResp = null; | ||
128 | try | ||
129 | { | ||
130 | UserResp = UserReq.Send(authurl, 3000); | ||
131 | } | ||
132 | catch (Exception e) | ||
133 | { | ||
134 | System.Console.WriteLine("[Session Auth]: VerifySession XmlRpc: " + e.Message); | ||
135 | return false; | ||
136 | } | ||
137 | |||
138 | Hashtable responseData = (Hashtable)UserResp.Value; | ||
139 | if (responseData != null && responseData.ContainsKey("auth_session") && responseData["auth_session"] != null && responseData["auth_session"].ToString() == "TRUE") | ||
140 | { | ||
141 | //System.Console.WriteLine("[Authorization]: userserver reported authorized session for user " + userID); | ||
142 | return true; | ||
143 | } | ||
144 | else | ||
145 | { | ||
146 | //System.Console.WriteLine("[Authorization]: userserver reported unauthorized session for user " + userID); | ||
147 | return false; | ||
148 | } | ||
149 | } | ||
150 | } | ||
151 | } | ||