diff options
author | gareth | 2007-03-22 10:11:15 +0000 |
---|---|---|
committer | gareth | 2007-03-22 10:11:15 +0000 |
commit | 7daa3955bc3a1918e40962851f9e8d38597a245e (patch) | |
tree | bee3e1372a7eed0c1b220a8a49f7bee7d29a6b91 /OpenSim.GridInterfaces/Remote/RemoteGridServer.cs | |
parent | Load XML for neighbourinfo from grid (diff) | |
download | opensim-SC_OLD-7daa3955bc3a1918e40962851f9e8d38597a245e.zip opensim-SC_OLD-7daa3955bc3a1918e40962851f9e8d38597a245e.tar.gz opensim-SC_OLD-7daa3955bc3a1918e40962851f9e8d38597a245e.tar.bz2 opensim-SC_OLD-7daa3955bc3a1918e40962851f9e8d38597a245e.tar.xz |
brought zircon branch into trunk
Diffstat (limited to '')
-rw-r--r-- | OpenSim.GridInterfaces/Remote/RemoteGridServer.cs | 156 |
1 files changed, 156 insertions, 0 deletions
diff --git a/OpenSim.GridInterfaces/Remote/RemoteGridServer.cs b/OpenSim.GridInterfaces/Remote/RemoteGridServer.cs new file mode 100644 index 0000000..5f48916 --- /dev/null +++ b/OpenSim.GridInterfaces/Remote/RemoteGridServer.cs | |||
@@ -0,0 +1,156 @@ | |||
1 | /* | ||
2 | * Copyright (c) OpenSim project, http://sim.opensecondlife.org/ | ||
3 | * | ||
4 | * Redistribution and use in source and binary forms, with or without | ||
5 | * modification, are permitted provided that the following conditions are met: | ||
6 | * * Redistributions of source code must retain the above copyright | ||
7 | * notice, this list of conditions and the following disclaimer. | ||
8 | * * Redistributions in binary form must reproduce the above copyright | ||
9 | * notice, this list of conditions and the following disclaimer in the | ||
10 | * documentation and/or other materials provided with the distribution. | ||
11 | * * Neither the name of the <organization> nor the | ||
12 | * names of its contributors may be used to endorse or promote products | ||
13 | * derived from this software without specific prior written permission. | ||
14 | * | ||
15 | * THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY | ||
16 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
17 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
18 | * DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY | ||
19 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
20 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
21 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
22 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
24 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
25 | * | ||
26 | */ | ||
27 | using System; | ||
28 | using System.Collections.Generic; | ||
29 | using System.Threading; | ||
30 | using System.Net; | ||
31 | using System.Net.Sockets; | ||
32 | using System.IO; | ||
33 | using libsecondlife; | ||
34 | using OpenSim.Framework.Interfaces; | ||
35 | using OpenSim.Framework.Assets; | ||
36 | |||
37 | namespace OpenSim.GridInterfaces.Remote | ||
38 | { | ||
39 | public class RemoteGridServer : RemoteGridBase | ||
40 | { | ||
41 | private string GridServerUrl; | ||
42 | private string GridSendKey; | ||
43 | private string GridRecvKey; | ||
44 | private Dictionary<uint, AgentCircuitData> AgentCircuits = new Dictionary<uint, AgentCircuitData>(); | ||
45 | |||
46 | public override Dictionary<uint, AgentCircuitData> agentcircuits | ||
47 | { | ||
48 | get { return AgentCircuits; } | ||
49 | set { AgentCircuits = value; } | ||
50 | } | ||
51 | |||
52 | public RemoteGridServer() | ||
53 | { | ||
54 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Remote Grid Server class created"); | ||
55 | } | ||
56 | |||
57 | public override bool RequestConnection() | ||
58 | { | ||
59 | return true; | ||
60 | } | ||
61 | |||
62 | public override AuthenticateResponse AuthenticateSession(LLUUID sessionID, LLUUID agentID, uint circuitcode) | ||
63 | { | ||
64 | AgentCircuitData validcircuit = null; | ||
65 | if (this.AgentCircuits.ContainsKey(circuitcode)) | ||
66 | { | ||
67 | validcircuit = this.AgentCircuits[circuitcode]; | ||
68 | } | ||
69 | AuthenticateResponse user = new AuthenticateResponse(); | ||
70 | if (validcircuit == null) | ||
71 | { | ||
72 | //don't have this circuit code in our list | ||
73 | user.Authorised = false; | ||
74 | return (user); | ||
75 | } | ||
76 | |||
77 | if ((sessionID == validcircuit.SessionID) && (agentID == validcircuit.AgentID)) | ||
78 | { | ||
79 | // YAY! Valid login | ||
80 | user.Authorised = true; | ||
81 | user.LoginInfo = new Login(); | ||
82 | user.LoginInfo.Agent = agentID; | ||
83 | user.LoginInfo.Session = sessionID; | ||
84 | user.LoginInfo.SecureSession = validcircuit.SecureSessionID; | ||
85 | user.LoginInfo.First = validcircuit.firstname; | ||
86 | user.LoginInfo.Last = validcircuit.lastname; | ||
87 | } | ||
88 | else | ||
89 | { | ||
90 | // Invalid | ||
91 | user.Authorised = false; | ||
92 | } | ||
93 | |||
94 | return (user); | ||
95 | } | ||
96 | |||
97 | public override bool LogoutSession(LLUUID sessionID, LLUUID agentID, uint circuitCode) | ||
98 | { | ||
99 | WebRequest DeleteSession = WebRequest.Create(GridServerUrl + "/usersessions/" + sessionID.ToString()); | ||
100 | DeleteSession.Method = "DELETE"; | ||
101 | DeleteSession.ContentType = "text/plaintext"; | ||
102 | DeleteSession.ContentLength = 0; | ||
103 | |||
104 | StreamWriter stOut = new StreamWriter(DeleteSession.GetRequestStream(), System.Text.Encoding.ASCII); | ||
105 | stOut.Write(""); | ||
106 | stOut.Close(); | ||
107 | |||
108 | StreamReader stIn = new StreamReader(DeleteSession.GetResponse().GetResponseStream()); | ||
109 | string GridResponse = stIn.ReadToEnd(); | ||
110 | stIn.Close(); | ||
111 | return (true); | ||
112 | } | ||
113 | |||
114 | public override UUIDBlock RequestUUIDBlock() | ||
115 | { | ||
116 | UUIDBlock uuidBlock = new UUIDBlock(); | ||
117 | return (uuidBlock); | ||
118 | } | ||
119 | |||
120 | public override NeighbourInfo[] RequestNeighbours() | ||
121 | { | ||
122 | return null; | ||
123 | } | ||
124 | |||
125 | public override void SetServerInfo(string ServerUrl, string SendKey, string RecvKey) | ||
126 | { | ||
127 | this.GridServerUrl = ServerUrl; | ||
128 | this.GridSendKey = SendKey; | ||
129 | this.GridRecvKey = RecvKey; | ||
130 | } | ||
131 | |||
132 | public override string GetName() | ||
133 | { | ||
134 | return "Remote"; | ||
135 | } | ||
136 | |||
137 | public override void Close() | ||
138 | { | ||
139 | |||
140 | } | ||
141 | } | ||
142 | |||
143 | public class RemoteGridPlugin : IGridPlugin | ||
144 | { | ||
145 | public RemoteGridPlugin() | ||
146 | { | ||
147 | |||
148 | } | ||
149 | |||
150 | public IGridServer GetGridServer() | ||
151 | { | ||
152 | return (new RemoteGridServer()); | ||
153 | } | ||
154 | } | ||
155 | |||
156 | } | ||