* Extracted request-response handling
parent
3147def23f
commit
59e7586558
|
@ -168,7 +168,32 @@ namespace OpenSim.GridServers
|
||||||
XmlRpcRequest request = (XmlRpcRequest)(new XmlRpcRequestDeserializer()).Deserialize(new String(content));
|
XmlRpcRequest request = (XmlRpcRequest)(new XmlRpcRequestDeserializer()).Deserialize(new String(content));
|
||||||
if(request.MethodName == "login_to_simulator")
|
if(request.MethodName == "login_to_simulator")
|
||||||
{
|
{
|
||||||
|
XmlRpcResponse response = ProcessRequest(request);
|
||||||
|
|
||||||
|
// forward the XML-RPC response to the client
|
||||||
|
writer.WriteLine("HTTP/1.0 200 OK");
|
||||||
|
writer.WriteLine("Content-type: text/xml");
|
||||||
|
writer.WriteLine();
|
||||||
|
|
||||||
|
XmlTextWriter responseWriter = new XmlTextWriter(writer);
|
||||||
|
XmlRpcResponseSerializer.Singleton.Serialize(responseWriter, response);
|
||||||
|
responseWriter.Close();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
writer.WriteLine("HTTP/1.0 403 Authentication Forbidden");
|
||||||
|
writer.WriteLine();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private XmlRpcResponse ProcessRequest(XmlRpcRequest request)
|
||||||
|
{
|
||||||
|
XmlRpcResponse response = (XmlRpcResponse)(new XmlRpcResponseDeserializer()).Deserialize(this._defaultResponse);
|
||||||
|
|
||||||
|
Hashtable responseData = (Hashtable)response.Value;
|
||||||
Hashtable requestData = (Hashtable)request.Params[0];
|
Hashtable requestData = (Hashtable)request.Params[0];
|
||||||
|
|
||||||
string first;
|
string first;
|
||||||
string last;
|
string last;
|
||||||
string passwd;
|
string passwd;
|
||||||
|
@ -203,9 +228,6 @@ namespace OpenSim.GridServers
|
||||||
passwd = "notfound";
|
passwd = "notfound";
|
||||||
}
|
}
|
||||||
|
|
||||||
XmlRpcResponse response =(XmlRpcResponse)(new XmlRpcResponseDeserializer()).Deserialize(this._defaultResponse);
|
|
||||||
Hashtable responseData = (Hashtable)response.Value;
|
|
||||||
|
|
||||||
if( !Authenticate(first, last, passwd))
|
if( !Authenticate(first, last, passwd))
|
||||||
{
|
{
|
||||||
responseData["reason"] = "key";
|
responseData["reason"] = "key";
|
||||||
|
@ -277,22 +299,7 @@ namespace OpenSim.GridServers
|
||||||
((LocalGridBase)this._gridServer).AddNewSession(_login);
|
((LocalGridBase)this._gridServer).AddNewSession(_login);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return response;
|
||||||
// forward the XML-RPC response to the client
|
|
||||||
writer.WriteLine("HTTP/1.0 200 OK");
|
|
||||||
writer.WriteLine("Content-type: text/xml");
|
|
||||||
writer.WriteLine();
|
|
||||||
|
|
||||||
XmlTextWriter responseWriter = new XmlTextWriter(writer);
|
|
||||||
XmlRpcResponseSerializer.Singleton.Serialize(responseWriter, response);
|
|
||||||
responseWriter.Close();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
writer.WriteLine("HTTP/1.0 403 Authentication Forbidden");
|
|
||||||
writer.WriteLine();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void CustomiseLoginResponse( Hashtable responseData, string first, string last )
|
protected virtual void CustomiseLoginResponse( Hashtable responseData, string first, string last )
|
||||||
|
|
Loading…
Reference in New Issue