Added dummy CAPS/REST/XML-RPC HTTP server

Modified RemoteGridServers to check against authenticated circuit codes
ogs-cs
gareth 2007-03-13 17:48:47 +00:00
parent 04d4ba297a
commit 179adbf242
12 changed files with 172 additions and 22 deletions

View File

@ -69,6 +69,7 @@
<include name="world/*.cs" /> <include name="world/*.cs" />
<include name="GridServers/*.cs" /> <include name="GridServers/*.cs" />
<include name="Assets/*.cs" /> <include name="Assets/*.cs" />
<include name="CAPS/*.cs" />
</sources> </sources>
</csc> </csc>

144
opensim/src/CAPS/SimHttp.cs Normal file
View File

@ -0,0 +1,144 @@
/*
Copyright (c) OpenSimCAPS project, http://osgrid.org/
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the <organization> nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using System.Text;
using Nwc.XmlRpc;
using System.Threading;
using System.Text.RegularExpressions;
using System.Net;
using System.IO;
using System.Collections;
using System.Collections.Generic;
using libsecondlife;
using ServerConsole;
namespace OpenSim
{
// Dummy HTTP server, does nothing useful for now
public class SimCAPSHTTPServer {
public Thread HTTPD;
public HttpListener Listener;
public SimCAPSHTTPServer() {
ServerConsole.MainConsole.Instance.WriteLine("Starting up HTTP Server");
HTTPD = new Thread(new ThreadStart(StartHTTP));
HTTPD.Start();
}
public void StartHTTP() {
ServerConsole.MainConsole.Instance.WriteLine("SimHttp.cs:StartHTTP() - Spawned main thread OK");
Listener = new HttpListener();
Listener.Prefixes.Add("http://+:" + OpenSim_Main.cfg.IPListenPort + "/");
Listener.Start();
HttpListenerContext context;
while(true) {
context = Listener.GetContext();
ThreadPool.QueueUserWorkItem(new WaitCallback(HandleRequest), context);
}
}
static string ParseXMLRPC(string requestBody) {
try{
XmlRpcRequest request = (XmlRpcRequest)(new XmlRpcRequestDeserializer()).Deserialize(requestBody);
Hashtable requestData = (Hashtable)request.Params[0];
switch(request.MethodName) {
// Eventually will be used for useful things if we actually use XML-RPC
case "":
break;
}
} catch(Exception e) {
Console.WriteLine(e.ToString());
}
return "";
}
static string ParseREST(string requestBody, string requestURL) {
return "";
}
static string ParseLLSDXML(string requestBody) {
// dummy function for now - IMPLEMENT ME!
return "";
}
static void HandleRequest(Object stateinfo) {
HttpListenerContext context=(HttpListenerContext)stateinfo;
HttpListenerRequest request = context.Request;
HttpListenerResponse response = context.Response;
response.KeepAlive=false;
response.SendChunked=false;
System.IO.Stream body = request.InputStream;
System.Text.Encoding encoding = System.Text.Encoding.UTF8;
System.IO.StreamReader reader = new System.IO.StreamReader(body, encoding);
string requestBody = reader.ReadToEnd();
body.Close();
reader.Close();
string responseString="";
switch(request.ContentType) {
case "text/xml":
// must be XML-RPC, so pass to the XML-RPC parser
responseString=ParseXMLRPC(requestBody);
response.AddHeader("Content-type","text/xml");
break;
case "application/xml":
// probably LLSD we hope, otherwise it should be ignored by the parser
responseString=ParseLLSDXML(requestBody);
response.AddHeader("Content-type","application/xml");
break;
case null:
// must be REST or invalid crap, so pass to the REST parser
responseString=ParseREST(request.Url.OriginalString,requestBody);
break;
}
byte[] buffer = System.Text.Encoding.UTF8.GetBytes(responseString);
System.IO.Stream output = response.OutputStream;
response.SendChunked=false;
response.ContentLength64=buffer.Length;
output.Write(buffer,0,buffer.Length);
output.Close();
}
}
}

View File

@ -14,7 +14,7 @@ using System.Runtime.InteropServices;
[assembly: ComVisibleAttribute(false)] [assembly: ComVisibleAttribute(false)]
[assembly: CLSCompliantAttribute(false)] [assembly: CLSCompliantAttribute(false)]
[assembly: AssemblyVersionAttribute("0.1.*.195")] [assembly: AssemblyVersionAttribute("0.1.*.196")]
[assembly: AssemblyTitleAttribute("opensim-simconfig")] [assembly: AssemblyTitleAttribute("opensim-simconfig")]
[assembly: AssemblyDescriptionAttribute("The default configuration handler")] [assembly: AssemblyDescriptionAttribute("The default configuration handler")]
[assembly: AssemblyCopyrightAttribute("Copyright © OGS development team 2007")] [assembly: AssemblyCopyrightAttribute("Copyright © OGS development team 2007")]

View File

@ -14,7 +14,7 @@ using System.Runtime.InteropServices;
[assembly: ComVisibleAttribute(false)] [assembly: ComVisibleAttribute(false)]
[assembly: CLSCompliantAttribute(false)] [assembly: CLSCompliantAttribute(false)]
[assembly: AssemblyVersionAttribute("0.1.*.195")] [assembly: AssemblyVersionAttribute("0.1.*.196")]
[assembly: AssemblyTitleAttribute("opensim-gridinterfaces")] [assembly: AssemblyTitleAttribute("opensim-gridinterfaces")]
[assembly: AssemblyDescriptionAttribute("Definitions for OGS interface")] [assembly: AssemblyDescriptionAttribute("Definitions for OGS interface")]
[assembly: AssemblyCopyrightAttribute("Copyright © OGS development team 2007")] [assembly: AssemblyCopyrightAttribute("Copyright © OGS development team 2007")]

View File

@ -14,7 +14,7 @@ using System.Runtime.InteropServices;
[assembly: ComVisibleAttribute(false)] [assembly: ComVisibleAttribute(false)]
[assembly: CLSCompliantAttribute(false)] [assembly: CLSCompliantAttribute(false)]
[assembly: AssemblyVersionAttribute("0.1.*.195")] [assembly: AssemblyVersionAttribute("0.1.*.196")]
[assembly: AssemblyTitleAttribute("opensim-localservers")] [assembly: AssemblyTitleAttribute("opensim-localservers")]
[assembly: AssemblyDescriptionAttribute("local grid servers")] [assembly: AssemblyDescriptionAttribute("local grid servers")]
[assembly: AssemblyCopyrightAttribute("Copyright © OGS development team 2007")] [assembly: AssemblyCopyrightAttribute("Copyright © OGS development team 2007")]

View File

@ -14,7 +14,7 @@ using System.Runtime.InteropServices;
[assembly: ComVisibleAttribute(false)] [assembly: ComVisibleAttribute(false)]
[assembly: CLSCompliantAttribute(false)] [assembly: CLSCompliantAttribute(false)]
[assembly: AssemblyVersionAttribute("0.1.*.195")] [assembly: AssemblyVersionAttribute("0.1.*.196")]
[assembly: AssemblyTitleAttribute("opensim-localstorage")] [assembly: AssemblyTitleAttribute("opensim-localstorage")]
[assembly: AssemblyDescriptionAttribute("The local storage handler")] [assembly: AssemblyDescriptionAttribute("The local storage handler")]
[assembly: AssemblyCopyrightAttribute("Copyright © OGS development team 2007")] [assembly: AssemblyCopyrightAttribute("Copyright © OGS development team 2007")]

View File

@ -14,7 +14,7 @@ using System.Runtime.InteropServices;
[assembly: ComVisibleAttribute(false)] [assembly: ComVisibleAttribute(false)]
[assembly: CLSCompliantAttribute(false)] [assembly: CLSCompliantAttribute(false)]
[assembly: AssemblyVersionAttribute("0.1.*.195")] [assembly: AssemblyVersionAttribute("0.1.*.196")]
[assembly: AssemblyTitleAttribute("opensim-remoteservers")] [assembly: AssemblyTitleAttribute("opensim-remoteservers")]
[assembly: AssemblyDescriptionAttribute("Connects to remote OGS installation")] [assembly: AssemblyDescriptionAttribute("Connects to remote OGS installation")]
[assembly: AssemblyCopyrightAttribute("Copyright © OGS development team 2007")] [assembly: AssemblyCopyrightAttribute("Copyright © OGS development team 2007")]

View File

@ -69,6 +69,7 @@ namespace RemoteGridServers
{ {
private string GridServerUrl; private string GridServerUrl;
private string GridSendKey; private string GridSendKey;
private Dictionary<uint, agentcircuitdata> AgentCircuits = new Dictionary<uint, agentcircuitdata>();
public RemoteGridServer() public RemoteGridServer()
{ {
@ -79,26 +80,20 @@ namespace RemoteGridServers
{ {
return true; return true;
} }
public AuthenticateResponse AuthenticateSession(LLUUID sessionID, LLUUID agentID, uint circuitCode)
{
AuthenticateResponse user = new AuthenticateResponse();
WebRequest CheckSession = WebRequest.Create(GridServerUrl + "/usersessions/" + GridSendKey + "/" + agentID.ToString() + "/" + circuitCode.ToString() + "/exists"); public AuthenticateResponse AuthenticateSession(LLUUID sessionID, LLUUID agentID, uint circuitcode)
WebResponse GridResponse = CheckSession.GetResponse(); {
StreamReader sr = new StreamReader(GridResponse.GetResponseStream()); agentcircuitdata validcircuit=this.AgentCircuits[circuitcode];
String grTest = sr.ReadLine(); AuthenticateResponse user = new AuthenticateResponse();
sr.Close(); if((sessionID==validcircuit.SessionID) && (agentID==validcircuit.AgentID))
GridResponse.Close();
if(String.IsNullOrEmpty(grTest) || grTest.Equals("1"))
{ {
// YAY! Valid login // YAY! Valid login
user.Authorised = true; user.Authorised = true;
user.LoginInfo = new Login(); user.LoginInfo = new Login();
user.LoginInfo.Agent = agentID; user.LoginInfo.Agent = agentID;
user.LoginInfo.Session = sessionID; user.LoginInfo.Session = sessionID;
user.LoginInfo.First = ""; user.LoginInfo.First = validcircuit.firstname;
user.LoginInfo.Last = ""; user.LoginInfo.Last = validcircuit.lastname;
} }
else else
{ {
@ -214,6 +209,16 @@ namespace RemoteGridServers
} }
} }
public class agentcircuitdata {
public agentcircuitdata() { }
public LLUUID AgentID;
public LLUUID SessionID;
public LLUUID SecureSessionID;
public string firstname;
public string lastname;
public uint circuitcode;
}
public class BlockingQueue< T > { public class BlockingQueue< T > {
private Queue< T > _queue = new Queue< T >(); private Queue< T > _queue = new Queue< T >();
private object _queueSync = new object(); private object _queueSync = new object();

View File

@ -14,7 +14,7 @@ using System.Runtime.InteropServices;
[assembly: ComVisibleAttribute(false)] [assembly: ComVisibleAttribute(false)]
[assembly: CLSCompliantAttribute(false)] [assembly: CLSCompliantAttribute(false)]
[assembly: AssemblyVersionAttribute("0.1.*.195")] [assembly: AssemblyVersionAttribute("0.1.*.196")]
[assembly: AssemblyTitleAttribute("opensim-serverconsole")] [assembly: AssemblyTitleAttribute("opensim-serverconsole")]
[assembly: AssemblyDescriptionAttribute("The default server console")] [assembly: AssemblyDescriptionAttribute("The default server console")]
[assembly: AssemblyCopyrightAttribute("Copyright © OGS development team 2007")] [assembly: AssemblyCopyrightAttribute("Copyright © OGS development team 2007")]

View File

@ -32,6 +32,6 @@ namespace OpenSim
/// </summary> /// </summary>
public class VersionInfo public class VersionInfo
{ {
public static string Version = "0.1, Build 1173804949, Revision 195"; public static string Version = "0.1, Build 1173807988, Revision 196M";
} }
} }

View File

@ -14,7 +14,7 @@ using System.Runtime.InteropServices;
[assembly: ComVisibleAttribute(false)] [assembly: ComVisibleAttribute(false)]
[assembly: CLSCompliantAttribute(false)] [assembly: CLSCompliantAttribute(false)]
[assembly: AssemblyVersionAttribute("0.1.*.195")] [assembly: AssemblyVersionAttribute("0.1.*.196")]
[assembly: AssemblyTitleAttribute("opensim-physicsmanager")] [assembly: AssemblyTitleAttribute("opensim-physicsmanager")]
[assembly: AssemblyDescriptionAttribute("Handles physics plugins")] [assembly: AssemblyDescriptionAttribute("Handles physics plugins")]
[assembly: AssemblyCopyrightAttribute("Copyright © OGS development team 2007")] [assembly: AssemblyCopyrightAttribute("Copyright © OGS development team 2007")]

View File

@ -14,7 +14,7 @@ using System.Runtime.InteropServices;
[assembly: ComVisibleAttribute(false)] [assembly: ComVisibleAttribute(false)]
[assembly: CLSCompliantAttribute(false)] [assembly: CLSCompliantAttribute(false)]
[assembly: AssemblyVersionAttribute("0.1.*.195")] [assembly: AssemblyVersionAttribute("0.1.*.196")]
[assembly: AssemblyTitleAttribute("opensim-physicsmanager-physx")] [assembly: AssemblyTitleAttribute("opensim-physicsmanager-physx")]
[assembly: AssemblyDescriptionAttribute("PhysX plugin for OpenSim")] [assembly: AssemblyDescriptionAttribute("PhysX plugin for OpenSim")]
[assembly: AssemblyCopyrightAttribute("Copyright © OGS development team 2007")] [assembly: AssemblyCopyrightAttribute("Copyright © OGS development team 2007")]