diff options
Diffstat (limited to 'OpenGridServices/OpenGrid.Framework.Manager/GridManagementAgent.cs')
-rw-r--r-- | OpenGridServices/OpenGrid.Framework.Manager/GridManagementAgent.cs | 76 |
1 files changed, 76 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..f4483fb --- /dev/null +++ b/OpenGridServices/OpenGrid.Framework.Manager/GridManagementAgent.cs | |||
@@ -0,0 +1,76 @@ | |||
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 | |||
11 | public delegate void GridManagerCallback(string param); | ||
12 | |||
13 | public class GridManagementAgent | ||
14 | { | ||
15 | |||
16 | private GridManagerCallback thecallback; | ||
17 | private string sendkey; | ||
18 | private string recvkey; | ||
19 | private string component_type; | ||
20 | |||
21 | private static ArrayList Sessions; | ||
22 | |||
23 | public GridManagementAgent(BaseHttpServer app_httpd, string component_type, string sendkey, string recvkey, GridManagerCallback thecallback) | ||
24 | { | ||
25 | this.sendkey = sendkey; | ||
26 | this.recvkey = recvkey; | ||
27 | this.component_type = component_type; | ||
28 | this.thecallback = thecallback; | ||
29 | Sessions = new ArrayList(); | ||
30 | |||
31 | app_httpd.AddXmlRPCHandler("manager_login", XmlRpcLoginMethod); | ||
32 | |||
33 | switch (component_type) | ||
34 | { | ||
35 | case "gridserver": | ||
36 | GridServerManager.sendkey = this.sendkey; | ||
37 | GridServerManager.recvkey = this.recvkey; | ||
38 | GridServerManager.thecallback = thecallback; | ||
39 | app_httpd.AddXmlRPCHandler("shutdown", GridServerManager.XmlRpcShutdownMethod); | ||
40 | break; | ||
41 | } | ||
42 | } | ||
43 | |||
44 | public static bool SessionExists(LLUUID sessionID) | ||
45 | { | ||
46 | return Sessions.Contains(sessionID); | ||
47 | } | ||
48 | |||
49 | public static XmlRpcResponse XmlRpcLoginMethod(XmlRpcRequest request) | ||
50 | { | ||
51 | XmlRpcResponse response = new XmlRpcResponse(); | ||
52 | Hashtable requestData = (Hashtable)request.Params[0]; | ||
53 | Hashtable responseData = new Hashtable(); | ||
54 | |||
55 | // TODO: Switch this over to using OpenGrid.Framework.Data | ||
56 | if (requestData["username"].Equals("admin") && requestData["password"].Equals("supersecret")) | ||
57 | { | ||
58 | response.IsFault = false; | ||
59 | LLUUID new_session = LLUUID.Random(); | ||
60 | Sessions.Add(new_session); | ||
61 | responseData["session_id"] = new_session.ToString(); | ||
62 | responseData["msg"] = "Login OK"; | ||
63 | } | ||
64 | else | ||
65 | { | ||
66 | response.IsFault = true; | ||
67 | responseData["error"] = "Invalid username or password"; | ||
68 | } | ||
69 | |||
70 | response.Value = responseData; | ||
71 | return response; | ||
72 | |||
73 | } | ||
74 | |||
75 | } | ||
76 | } | ||