diff options
Renamed the new Directories. (removed the "-Source" from the end of them)
Diffstat (limited to 'OpenGridServices/OpenGrid.Framework.Manager/GridManagementAgent.cs')
-rw-r--r-- | OpenGridServices/OpenGrid.Framework.Manager/GridManagementAgent.cs | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/OpenGridServices/OpenGrid.Framework.Manager/GridManagementAgent.cs b/OpenGridServices/OpenGrid.Framework.Manager/GridManagementAgent.cs new file mode 100644 index 0000000..e43ce87 --- /dev/null +++ b/OpenGridServices/OpenGrid.Framework.Manager/GridManagementAgent.cs | |||
@@ -0,0 +1,71 @@ | |||
1 | using Nwc.XmlRpc; | ||
2 | using OpenSim.Framework; | ||
3 | using OpenSim.Servers; | ||
4 | using System.Collections; | ||
5 | using System.Collections.Generic; | ||
6 | using libsecondlife; | ||
7 | |||
8 | namespace OpenGrid.Framework.Manager { | ||
9 | |||
10 | public delegate void GridManagerCallback(string param); | ||
11 | |||
12 | public class GridManagementAgent { | ||
13 | |||
14 | private GridManagerCallback thecallback; | ||
15 | private string sendkey; | ||
16 | private string recvkey; | ||
17 | private string component_type; | ||
18 | |||
19 | private static ArrayList Sessions; | ||
20 | |||
21 | public GridManagementAgent(BaseHttpServer app_httpd, string component_type, string sendkey, string recvkey, GridManagerCallback thecallback) | ||
22 | { | ||
23 | this.sendkey=sendkey; | ||
24 | this.recvkey=recvkey; | ||
25 | this.component_type=component_type; | ||
26 | this.thecallback=thecallback; | ||
27 | Sessions = new ArrayList(); | ||
28 | |||
29 | app_httpd.AddXmlRPCHandler("manager_login",XmlRpcLoginMethod); | ||
30 | |||
31 | switch(component_type) | ||
32 | { | ||
33 | case "gridserver": | ||
34 | GridServerManager.sendkey=this.sendkey; | ||
35 | GridServerManager.recvkey=this.recvkey; | ||
36 | GridServerManager.thecallback=thecallback; | ||
37 | app_httpd.AddXmlRPCHandler("shutdown", GridServerManager.XmlRpcShutdownMethod); | ||
38 | break; | ||
39 | } | ||
40 | } | ||
41 | |||
42 | public static bool SessionExists(LLUUID sessionID) | ||
43 | { | ||
44 | return Sessions.Contains(sessionID); | ||
45 | } | ||
46 | |||
47 | public static XmlRpcResponse XmlRpcLoginMethod(XmlRpcRequest request) | ||
48 | { | ||
49 | XmlRpcResponse response = new XmlRpcResponse(); | ||
50 | Hashtable requestData = (Hashtable)request.Params[0]; | ||
51 | Hashtable responseData = new Hashtable(); | ||
52 | |||
53 | // TODO: Switch this over to using OpenGrid.Framework.Data | ||
54 | if( requestData["username"].Equals("admin") && requestData["password"].Equals("supersecret")) { | ||
55 | response.IsFault=false; | ||
56 | LLUUID new_session=LLUUID.Random(); | ||
57 | Sessions.Add(new_session); | ||
58 | responseData["session_id"]=new_session.ToString(); | ||
59 | responseData["msg"]="Login OK"; | ||
60 | } else { | ||
61 | response.IsFault=true; | ||
62 | responseData["error"]="Invalid username or password"; | ||
63 | } | ||
64 | |||
65 | response.Value = responseData; | ||
66 | return response; | ||
67 | |||
68 | } | ||
69 | |||
70 | } | ||
71 | } | ||