aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenGridServices.UserServer/Main.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenGridServices.UserServer/Main.cs')
-rw-r--r--OpenGridServices.UserServer/Main.cs206
1 files changed, 103 insertions, 103 deletions
diff --git a/OpenGridServices.UserServer/Main.cs b/OpenGridServices.UserServer/Main.cs
index 9132a54..c348a74 100644
--- a/OpenGridServices.UserServer/Main.cs
+++ b/OpenGridServices.UserServer/Main.cs
@@ -39,126 +39,126 @@ using OpenSim.Framework.Sims;
39using OpenSim.Framework.Inventory; 39using OpenSim.Framework.Inventory;
40using OpenSim.Framework.Interfaces; 40using OpenSim.Framework.Interfaces;
41using OpenSim.Framework.Console; 41using OpenSim.Framework.Console;
42using OpenSim.Servers;
42 43
43namespace OpenGridServices.UserServer 44namespace OpenGridServices.UserServer
44{ 45{
45 /// <summary> 46 /// <summary>
46 /// </summary> 47 /// </summary>
47 public class OpenUser_Main : conscmd_callback 48 public class OpenUser_Main : BaseServer, conscmd_callback
48 { 49 {
49 private string ConfigDll = "OpenUser.Config.UserConfigDb4o.dll"; 50 private string ConfigDll = "OpenUser.Config.UserConfigDb4o.dll";
50 private UserConfig Cfg; 51 private UserConfig Cfg;
51 52
52 public static OpenUser_Main userserver; 53 private UserProfileManager m_userProfileManager;
53 54
54 public UserHTTPServer _httpd; 55 public Dictionary<LLUUID, UserProfile> UserSessions = new Dictionary<LLUUID, UserProfile>();
55 public UserProfileManager _profilemanager; 56
56 57 ConsoleBase m_console;
57 public Dictionary<LLUUID, UserProfile> UserSessions = new Dictionary<LLUUID, UserProfile>(); 58
58 59 [STAThread]
59 ConsoleBase m_console; 60 public static void Main(string[] args)
60 61 {
61 [STAThread] 62 Console.WriteLine("Starting...\n");
62 public static void Main( string[] args ) 63
63 { 64 OpenUser_Main userserver = new OpenUser_Main();
64 Console.WriteLine("Starting...\n"); 65 userserver.Startup();
65 66 userserver.Work();
66 userserver = new OpenUser_Main(); 67 }
67 userserver.Startup(); 68
68 69 private OpenUser_Main()
69 userserver.Work(); 70 {
70 } 71 m_console = new ConsoleBase("opengrid-userserver-console.log", "OpenUser", this);
71 72 MainConsole.Instance = m_console;
72 private OpenUser_Main() 73 }
73 { 74
74 m_console = new ConsoleBase("opengrid-userserver-console.log", "OpenUser", this); 75 private void Work()
75 MainConsole.Instance = m_console; 76 {
77 m_console.WriteLine("\nEnter help for a list of commands\n");
78
79 while (true)
80 {
81 m_console.MainConsolePrompt();
82 }
83 }
84
85 public void Startup()
86 {
87 MainConsole.Instance.WriteLine("Main.cs:Startup() - Loading configuration");
88 Cfg = this.LoadConfigDll(this.ConfigDll);
89 Cfg.InitConfig();
90
91 MainConsole.Instance.WriteLine("Main.cs:Startup() - Creating user profile manager");
92 m_userProfileManager = new UserProfileManager();
93 m_userProfileManager.InitUserProfiles();
94 m_userProfileManager.SetKeys(Cfg.GridSendKey, Cfg.GridRecvKey, Cfg.GridServerURL, Cfg.DefaultStartupMsg);
95
96 MainConsole.Instance.WriteLine("Main.cs:Startup() - Starting HTTP process");
97 BaseHttpServer httpServer = new BaseHttpServer(8002);
98
99 httpServer.AddXmlRPCHandler("login_to_simulator", m_userProfileManager.XmlRpcLoginMethod);
100 httpServer.AddRestHandler("DELETE", "/usersessions/", m_userProfileManager.RestDeleteUserSessionMethod);
101
102 // I guess that this was never used?
103 //Listener.Prefixes.Add("http://+:8002/userserver/");
104
105 httpServer.Start();
106 }
107
108
109 public void do_create(string what)
110 {
111 switch (what)
112 {
113 case "user":
114 m_console.WriteLine("Creating new user profile");
115 string tempfirstname;
116 string templastname;
117 string tempMD5Passwd;
118
119 tempfirstname = m_console.CmdPrompt("First name");
120 templastname = m_console.CmdPrompt("Last name");
121 tempMD5Passwd = m_console.PasswdPrompt("Password");
122
123 System.Security.Cryptography.MD5CryptoServiceProvider x = new System.Security.Cryptography.MD5CryptoServiceProvider();
124 byte[] bs = System.Text.Encoding.UTF8.GetBytes(tempMD5Passwd);
125 bs = x.ComputeHash(bs);
126 System.Text.StringBuilder s = new System.Text.StringBuilder();
127 foreach (byte b in bs)
128 {
129 s.Append(b.ToString("x2").ToLower());
130 }
131 tempMD5Passwd = s.ToString();
132
133 UserProfile newuser = m_userProfileManager.CreateNewProfile(tempfirstname, templastname, tempMD5Passwd);
134 newuser.homelookat = new LLVector3(-0.57343f, -0.819255f, 0f);
135 newuser.homepos = new LLVector3(128f, 128f, 23f);
136 m_userProfileManager.SaveUserProfiles();
137 break;
76 } 138 }
77 139 }
78 private void Work() 140
79 {
80 m_console.WriteLine("\nEnter help for a list of commands\n");
81
82 while (true)
83 {
84 m_console.MainConsolePrompt();
85 }
86 }
87
88 public void Startup() {
89 MainConsole.Instance.WriteLine("Main.cs:Startup() - Loading configuration");
90 Cfg = this.LoadConfigDll(this.ConfigDll);
91 Cfg.InitConfig();
92
93 MainConsole.Instance.WriteLine("Main.cs:Startup() - Creating user profile manager");
94 _profilemanager = new UserProfileManager();
95 _profilemanager.InitUserProfiles();
96 _profilemanager.SetKeys(Cfg.GridSendKey, Cfg.GridRecvKey, Cfg.GridServerURL, Cfg.DefaultStartupMsg);
97
98 MainConsole.Instance.WriteLine("Main.cs:Startup() - Starting HTTP process");
99 _httpd = new UserHTTPServer();
100
101 _httpd.AddXmlRPCHandler("login_to_simulator", _profilemanager.XmlRpcLoginMethod);
102 _httpd.AddRestHandler( "DELETE", "/usersessions/", _profilemanager.RestDeleteUserSessionMethod );
103
104 _httpd.Start();
105
106 }
107
108
109 public void do_create(string what)
110 {
111 switch(what)
112 {
113 case "user":
114 m_console.WriteLine("Creating new user profile");
115 string tempfirstname;
116 string templastname;
117 string tempMD5Passwd;
118
119 tempfirstname=m_console.CmdPrompt("First name: ");
120 templastname=m_console.CmdPrompt("Last name: ");
121 tempMD5Passwd=m_console.PasswdPrompt("Password: ");
122
123 System.Security.Cryptography.MD5CryptoServiceProvider x = new System.Security.Cryptography.MD5CryptoServiceProvider();
124 byte[] bs = System.Text.Encoding.UTF8.GetBytes(tempMD5Passwd);
125 bs = x.ComputeHash(bs);
126 System.Text.StringBuilder s = new System.Text.StringBuilder();
127 foreach (byte b in bs)
128 {
129 s.Append(b.ToString("x2").ToLower());
130 }
131 tempMD5Passwd = s.ToString();
132
133 UserProfile newuser=_profilemanager.CreateNewProfile(tempfirstname,templastname,tempMD5Passwd);
134 newuser.homelookat = new LLVector3(-0.57343f, -0.819255f, 0f);
135 newuser.homepos = new LLVector3(128f,128f,23f);
136 _profilemanager.SaveUserProfiles();
137 break;
138 }
139 }
140
141 public void RunCmd(string cmd, string[] cmdparams) 141 public void RunCmd(string cmd, string[] cmdparams)
142 { 142 {
143 switch (cmd) 143 switch (cmd)
144 { 144 {
145 case "help": 145 case "help":
146 m_console.WriteLine("create user - create a new user"); 146 m_console.WriteLine("create user - create a new user");
147 m_console.WriteLine("shutdown - shutdown the grid (USE CAUTION!)"); 147 m_console.WriteLine("shutdown - shutdown the grid (USE CAUTION!)");
148 break; 148 break;
149 149
150 case "create": 150 case "create":
151 do_create(cmdparams[0]); 151 do_create(cmdparams[0]);
152 break; 152 break;
153 153
154 case "shutdown": 154 case "shutdown":
155 m_console.Close(); 155 m_console.Close();
156 Environment.Exit(0); 156 Environment.Exit(0);
157 break; 157 break;
158 } 158 }
159 } 159 }
160 160
161 private UserConfig LoadConfigDll(string dllName) 161 private UserConfig LoadConfigDll(string dllName)
162 { 162 {
163 Assembly pluginAssembly = Assembly.LoadFrom(dllName); 163 Assembly pluginAssembly = Assembly.LoadFrom(dllName);
164 UserConfig config = null; 164 UserConfig config = null;
@@ -185,9 +185,9 @@ namespace OpenGridServices.UserServer
185 pluginAssembly = null; 185 pluginAssembly = null;
186 return config; 186 return config;
187 } 187 }
188 188
189 public void Show(string ShowWhat) 189 public void Show(string ShowWhat)
190 { 190 {
191 } 191 }
192 } 192 }
193} 193}