From e8a960920fd406170be7bf07cf16fd70a5b9ddb7 Mon Sep 17 00:00:00 2001 From: gareth Date: Thu, 8 Mar 2007 02:27:59 +0000 Subject: [PATCH] Began implementing use profile manager framework --- ServerConsole/ServerConsole.cs | 2 + common/src/OGS-Console.cs | 14 +++++++ gridserver/default.build | 2 + gridserver/src/Main.cs | 13 ++++++ gridserver/src/UserProfiles.cs | 75 ++++++++++++++++++++++++++++++++++ 5 files changed, 106 insertions(+) create mode 100644 gridserver/src/UserProfiles.cs diff --git a/ServerConsole/ServerConsole.cs b/ServerConsole/ServerConsole.cs index d1bbf11c30..d50a7e2b56 100644 --- a/ServerConsole/ServerConsole.cs +++ b/ServerConsole/ServerConsole.cs @@ -75,6 +75,8 @@ namespace ServerConsole public abstract void Write(string Line) ; + public abstract string PasswdPrompt(string prompt); + // Displays a command prompt and waits for the user to enter a string, then returns that string public abstract string CmdPrompt(string prompt) ; diff --git a/common/src/OGS-Console.cs b/common/src/OGS-Console.cs index e9d5a64e52..c35c75c396 100644 --- a/common/src/OGS-Console.cs +++ b/common/src/OGS-Console.cs @@ -110,6 +110,20 @@ namespace OpenGridServices return; } + + // Displays a prompt and waits for the user to enter a string, then returns that string + // Done with no echo and suitable for passwords + public override string PasswdPrompt(string prompt) { + // FIXME: Needs to be better abstracted + Log.WriteLine(prompt); + this.Write(prompt); + ConsoleColor oldfg=Console.ForegroundColor; + Console.ForegroundColor=Console.BackgroundColor; + string temp=Console.ReadLine(); + Console.ForegroundColor=oldfg; + return temp; + } + // Displays a command prompt and waits for the user to enter a string, then returns that string public override string CmdPrompt(string prompt) { this.Write(prompt); diff --git a/gridserver/default.build b/gridserver/default.build index d5e94d824a..c199514557 100644 --- a/gridserver/default.build +++ b/gridserver/default.build @@ -45,11 +45,13 @@ + + diff --git a/gridserver/src/Main.cs b/gridserver/src/Main.cs index 36dc55541b..6ac1bdee88 100644 --- a/gridserver/src/Main.cs +++ b/gridserver/src/Main.cs @@ -43,6 +43,7 @@ namespace OpenGridServices public string DefaultStartupMsg; public string DefaultAssetServer; public string DefaultUserServer; + public UserProfileManager _profilemanager; [STAThread] public static void Main( string[] args ) @@ -69,6 +70,18 @@ namespace OpenGridServices this.DefaultAssetServer=ServerConsole.MainConsole.Instance.CmdPrompt("Default asset server [no default] :"); this.DefaultUserServer=ServerConsole.MainConsole.Instance.CmdPrompt("Default user server [no default] :"); + ServerConsole.MainConsole.Instance.WriteLine("Main.cs:Startup() - Creating user profile manager"); + _profilemanager = new UserProfileManager(); + _profilemanager.InitUserProfiles(); + + string tempfirstname; + string templastname; + string tempMD5Passwd; + + ServerConsole.MainConsole.Instance.WriteLine("Main.cs:Startup() - Please configure the grid god user:"); + tempfirstname=ServerConsole.MainConsole.Instance.CmdPrompt("First name: "); + templastname=ServerConsole.MainConsole.Instance.CmdPrompt("Last name: "); + tempMD5Passwd=ServerConsole.MainConsole.Instance.PasswdPrompt("Password: "); } } } diff --git a/gridserver/src/UserProfiles.cs b/gridserver/src/UserProfiles.cs new file mode 100644 index 0000000000..38126b4cfc --- /dev/null +++ b/gridserver/src/UserProfiles.cs @@ -0,0 +1,75 @@ +/* +Copyright (c) OpenSim project, http://osgrid.org/ + + +* All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +using System; +using System.Text; +using System.Collections; +using System.Collections.Generic; +using libsecondlife; +using ServerConsole; + +namespace OpenGridServices +{ + /// + /// + public class UserProfileManager { + + private Dictionary UserProfiles = new Dictionary(); + + public UserProfileManager() { + } + + public void InitUserProfiles() { + // TODO: need to load from database + } + + public UserProfile GetProfileByName(string firstname, string lastname) { + foreach (libsecondlife.LLUUID UUID in UserProfiles.Keys) { + if((UserProfiles[UUID].firstname==firstname) && (UserProfiles[UUID].lastname==lastname)) return UserProfiles[UUID]; + } + return null; + } + + public UserProfile GetProfileByLLUUID(LLUUID ProfileLLUUID) { + return UserProfiles[ProfileLLUUID]; + } + } + + public class UserProfile { + + public string firstname; + public string lastname; + public bool IsGridGod; + public string MD5passwd; + + public UserProfile() { + } + + } +}