aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services/Connectors
diff options
context:
space:
mode:
authorDiva Canto2010-01-18 16:34:23 -0800
committerDiva Canto2010-01-18 16:34:23 -0800
commit3d536944153d4931cf891d6a788a47484f3e6f4d (patch)
tree53802c5f051e8fbb089aeed02e0b9de760fabd8a /OpenSim/Services/Connectors
parent* Added missing GatekeeperServiceConnector (diff)
downloadopensim-SC_OLD-3d536944153d4931cf891d6a788a47484f3e6f4d.zip
opensim-SC_OLD-3d536944153d4931cf891d6a788a47484f3e6f4d.tar.gz
opensim-SC_OLD-3d536944153d4931cf891d6a788a47484f3e6f4d.tar.bz2
opensim-SC_OLD-3d536944153d4931cf891d6a788a47484f3e6f4d.tar.xz
Go Home works. With security!!
Diffstat (limited to 'OpenSim/Services/Connectors')
-rw-r--r--OpenSim/Services/Connectors/Hypergrid/HomeUsersSecurityServiceConnector.cs132
1 files changed, 132 insertions, 0 deletions
diff --git a/OpenSim/Services/Connectors/Hypergrid/HomeUsersSecurityServiceConnector.cs b/OpenSim/Services/Connectors/Hypergrid/HomeUsersSecurityServiceConnector.cs
new file mode 100644
index 0000000..150690b
--- /dev/null
+++ b/OpenSim/Services/Connectors/Hypergrid/HomeUsersSecurityServiceConnector.cs
@@ -0,0 +1,132 @@
1using System;
2using System.Collections;
3using System.Collections.Generic;
4using System.Net;
5using System.Reflection;
6
7using OpenSim.Services.Interfaces;
8
9using OpenMetaverse;
10using log4net;
11using Nwc.XmlRpc;
12using Nini.Config;
13
14namespace OpenSim.Services.Connectors.Hypergrid
15{
16 public class HomeUsersSecurityServiceConnector : IHomeUsersSecurityService
17 {
18 private static readonly ILog m_log =
19 LogManager.GetLogger(
20 MethodBase.GetCurrentMethod().DeclaringType);
21
22 string m_ServerURL;
23 public HomeUsersSecurityServiceConnector(string url)
24 {
25 m_ServerURL = url;
26 }
27
28 public HomeUsersSecurityServiceConnector(IConfigSource config)
29 {
30 }
31
32 public void SetEndPoint(UUID sessionID, IPEndPoint ep)
33 {
34 Hashtable hash = new Hashtable();
35 hash["sessionID"] = sessionID.ToString();
36 hash["ep_addr"] = ep.Address.ToString();
37 hash["ep_port"] = ep.Port.ToString();
38
39 Call("ep_set", hash);
40 }
41
42 public void RemoveEndPoint(UUID sessionID)
43 {
44 Hashtable hash = new Hashtable();
45 hash["sessionID"] = sessionID.ToString();
46
47 Call("ep_remove", hash);
48 }
49
50 public IPEndPoint GetEndPoint(UUID sessionID)
51 {
52 Hashtable hash = new Hashtable();
53 hash["sessionID"] = sessionID.ToString();
54
55 IList paramList = new ArrayList();
56 paramList.Add(hash);
57
58 XmlRpcRequest request = new XmlRpcRequest("ep_get", paramList);
59 //m_log.Debug("[HGrid]: Linking to " + uri);
60 XmlRpcResponse response = null;
61 try
62 {
63 response = request.Send(m_ServerURL, 10000);
64 }
65 catch (Exception e)
66 {
67 m_log.Debug("[HGrid]: Exception " + e.Message);
68 return null;
69 }
70
71 if (response.IsFault)
72 {
73 m_log.ErrorFormat("[HGrid]: remote call returned an error: {0}", response.FaultString);
74 return null;
75 }
76
77 hash = (Hashtable)response.Value;
78 //foreach (Object o in hash)
79 // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value);
80 try
81 {
82 bool success = false;
83 Boolean.TryParse((string)hash["result"], out success);
84 if (success)
85 {
86 IPEndPoint ep = null;
87 int port = 0;
88 if (hash["ep_port"] != null)
89 Int32.TryParse((string)hash["ep_port"], out port);
90 if (hash["ep_addr"] != null)
91 ep = new IPEndPoint(IPAddress.Parse((string)hash["ep_addr"]), port);
92
93 return ep;
94 }
95
96 }
97 catch (Exception e)
98 {
99 m_log.Error("[HGrid]: Got exception while parsing GetEndPoint response " + e.StackTrace);
100 return null;
101 }
102
103 return null;
104 }
105
106 private void Call(string method, Hashtable hash)
107 {
108 IList paramList = new ArrayList();
109 paramList.Add(hash);
110
111 XmlRpcRequest request = new XmlRpcRequest(method, paramList);
112 XmlRpcResponse response = null;
113 try
114 {
115 response = request.Send(m_ServerURL, 10000);
116 }
117 catch (Exception e)
118 {
119 m_log.Debug("[HGrid]: Exception " + e.Message);
120 return ;
121 }
122
123 if (response.IsFault)
124 {
125 m_log.ErrorFormat("[HGrid]: remote call returned an error: {0}", response.FaultString);
126 return ;
127 }
128
129 }
130
131 }
132}