diff options
Diffstat (limited to 'OpenGridServices/OpenGrid.Framework.Manager/GridManagementAgent.cs')
-rw-r--r-- | OpenGridServices/OpenGrid.Framework.Manager/GridManagementAgent.cs | 140 |
1 files changed, 0 insertions, 140 deletions
diff --git a/OpenGridServices/OpenGrid.Framework.Manager/GridManagementAgent.cs b/OpenGridServices/OpenGrid.Framework.Manager/GridManagementAgent.cs deleted file mode 100644 index dfc572a..0000000 --- a/OpenGridServices/OpenGrid.Framework.Manager/GridManagementAgent.cs +++ /dev/null | |||
@@ -1,140 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSim Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | * | ||
27 | */ | ||
28 | using Nwc.XmlRpc; | ||
29 | using OpenSim.Framework; | ||
30 | using OpenSim.Servers; | ||
31 | using System.Collections; | ||
32 | using System.Collections.Generic; | ||
33 | using libsecondlife; | ||
34 | |||
35 | namespace OpenGrid.Framework.Manager | ||
36 | { | ||
37 | /// <summary> | ||
38 | /// Used to pass messages to the gridserver | ||
39 | /// </summary> | ||
40 | /// <param name="param">Pass this argument</param> | ||
41 | public delegate void GridManagerCallback(string param); | ||
42 | |||
43 | /// <summary> | ||
44 | /// Serverside listener for grid commands | ||
45 | /// </summary> | ||
46 | public class GridManagementAgent | ||
47 | { | ||
48 | /// <summary> | ||
49 | /// Passes grid server messages | ||
50 | /// </summary> | ||
51 | private GridManagerCallback thecallback; | ||
52 | |||
53 | /// <summary> | ||
54 | /// Security keys | ||
55 | /// </summary> | ||
56 | private string sendkey; | ||
57 | private string recvkey; | ||
58 | |||
59 | /// <summary> | ||
60 | /// Our component type | ||
61 | /// </summary> | ||
62 | private string component_type; | ||
63 | |||
64 | /// <summary> | ||
65 | /// List of active sessions | ||
66 | /// </summary> | ||
67 | private static ArrayList Sessions; | ||
68 | |||
69 | /// <summary> | ||
70 | /// Initialises a new GridManagementAgent | ||
71 | /// </summary> | ||
72 | /// <param name="app_httpd">HTTP Daemon for this server</param> | ||
73 | /// <param name="component_type">What component type are we?</param> | ||
74 | /// <param name="sendkey">Security send key</param> | ||
75 | /// <param name="recvkey">Security recieve key</param> | ||
76 | /// <param name="thecallback">Message callback</param> | ||
77 | public GridManagementAgent(BaseHttpServer app_httpd, string component_type, string sendkey, string recvkey, GridManagerCallback thecallback) | ||
78 | { | ||
79 | this.sendkey = sendkey; | ||
80 | this.recvkey = recvkey; | ||
81 | this.component_type = component_type; | ||
82 | this.thecallback = thecallback; | ||
83 | Sessions = new ArrayList(); | ||
84 | |||
85 | app_httpd.AddXmlRPCHandler("manager_login", XmlRpcLoginMethod); | ||
86 | |||
87 | switch (component_type) | ||
88 | { | ||
89 | case "gridserver": | ||
90 | GridServerManager.sendkey = this.sendkey; | ||
91 | GridServerManager.recvkey = this.recvkey; | ||
92 | GridServerManager.thecallback = thecallback; | ||
93 | app_httpd.AddXmlRPCHandler("shutdown", GridServerManager.XmlRpcShutdownMethod); | ||
94 | break; | ||
95 | } | ||
96 | } | ||
97 | |||
98 | /// <summary> | ||
99 | /// Checks if a session exists | ||
100 | /// </summary> | ||
101 | /// <param name="sessionID">The session ID</param> | ||
102 | /// <returns>Exists?</returns> | ||
103 | public static bool SessionExists(LLUUID sessionID) | ||
104 | { | ||
105 | return Sessions.Contains(sessionID); | ||
106 | } | ||
107 | |||
108 | /// <summary> | ||
109 | /// Logs a new session to the grid manager | ||
110 | /// </summary> | ||
111 | /// <param name="request">the XMLRPC request</param> | ||
112 | /// <returns>An XMLRPC reply</returns> | ||
113 | public static XmlRpcResponse XmlRpcLoginMethod(XmlRpcRequest request) | ||
114 | { | ||
115 | XmlRpcResponse response = new XmlRpcResponse(); | ||
116 | Hashtable requestData = (Hashtable)request.Params[0]; | ||
117 | Hashtable responseData = new Hashtable(); | ||
118 | |||
119 | // TODO: Switch this over to using OpenGrid.Framework.Data | ||
120 | if (requestData["username"].Equals("admin") && requestData["password"].Equals("supersecret")) | ||
121 | { | ||
122 | response.IsFault = false; | ||
123 | LLUUID new_session = LLUUID.Random(); | ||
124 | Sessions.Add(new_session); | ||
125 | responseData["session_id"] = new_session.ToString(); | ||
126 | responseData["msg"] = "Login OK"; | ||
127 | } | ||
128 | else | ||
129 | { | ||
130 | response.IsFault = true; | ||
131 | responseData["error"] = "Invalid username or password"; | ||
132 | } | ||
133 | |||
134 | response.Value = responseData; | ||
135 | return response; | ||
136 | |||
137 | } | ||
138 | |||
139 | } | ||
140 | } | ||