I broke the build and am reverting until I can get the MainLog call proper.

afrisby
Charles Krinke 2007-10-12 19:31:29 +00:00
parent a19ec6fc54
commit 4c8d175564
2 changed files with 291 additions and 291 deletions

View File

@ -1,287 +1,287 @@
using System; using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Reflection; using System.Reflection;
using System.Security.Cryptography; using System.Security.Cryptography;
using libsecondlife; using libsecondlife;
using Nwc.XmlRpc; using Nwc.XmlRpc;
using OpenSim.Framework.Console; using OpenSim.Framework.Console;
using OpenSim.Framework.Interfaces; using OpenSim.Framework.Interfaces;
using OpenSim.Framework.Inventory; using OpenSim.Framework.Inventory;
using OpenSim.Framework.Types; using OpenSim.Framework.Types;
using OpenSim.Framework.Utilities; using OpenSim.Framework.Utilities;
using OpenSim.Framework.Configuration; using OpenSim.Framework.Configuration;
using InventoryFolder = OpenSim.Framework.Inventory.InventoryFolder; using InventoryFolder = OpenSim.Framework.Inventory.InventoryFolder;
namespace OpenSim.Framework.UserManagement namespace OpenSim.Framework.UserManagement
{ {
public class LoginService public class LoginService
{ {
protected string m_welcomeMessage = "Welcome to OpenSim"; protected string m_welcomeMessage = "Welcome to OpenSim";
protected UserManagerBase m_userManager = null; protected UserManagerBase m_userManager = null;
public LoginService(UserManagerBase userManager, string welcomeMess) public LoginService(UserManagerBase userManager, string welcomeMess)
{ {
m_userManager = userManager; m_userManager = userManager;
if (welcomeMess != "") if (welcomeMess != "")
{ {
m_welcomeMessage = welcomeMess; m_welcomeMessage = welcomeMess;
} }
} }
/// <summary> /// <summary>
/// Main user login function /// Main user login function
/// </summary> /// </summary>
/// <param name="request">The XMLRPC request</param> /// <param name="request">The XMLRPC request</param>
/// <returns>The response to send</returns> /// <returns>The response to send</returns>
public XmlRpcResponse XmlRpcLoginMethod(XmlRpcRequest request) public XmlRpcResponse XmlRpcLoginMethod(XmlRpcRequest request)
{ {
MainLog.Instance.Verbose("Attempting login now..."); MainLog.Instance.Verbose("Attempting login now...");
XmlRpcResponse response = new XmlRpcResponse(); XmlRpcResponse response = new XmlRpcResponse();
Hashtable requestData = (Hashtable)request.Params[0]; Hashtable requestData = (Hashtable)request.Params[0];
bool GoodXML = (requestData.Contains("first") && requestData.Contains("last") && requestData.Contains("passwd")); bool GoodXML = (requestData.Contains("first") && requestData.Contains("last") && requestData.Contains("passwd"));
bool GoodLogin = false; bool GoodLogin = false;
UserProfileData userProfile; UserProfileData userProfile;
LoginResponse logResponse = new LoginResponse(); LoginResponse logResponse = new LoginResponse();
if (GoodXML) if (GoodXML)
{ {
string firstname = (string)requestData["first"]; string firstname = (string)requestData["first"];
string lastname = (string)requestData["last"]; string lastname = (string)requestData["last"];
string passwd = (string)requestData["passwd"]; string passwd = (string)requestData["passwd"];
userProfile = GetTheUser(firstname, lastname); userProfile = GetTheUser(firstname, lastname);
if (userProfile == null) if (userProfile == null)
return logResponse.CreateLoginFailedResponse(); return logResponse.CreateLoginFailedResponse();
GoodLogin = AuthenticateUser(userProfile, passwd); GoodLogin = AuthenticateUser(userProfile, passwd);
} }
else else
{ {
return logResponse.CreateGridErrorResponse(); return logResponse.CreateGridErrorResponse();
} }
if (!GoodLogin) if (!GoodLogin)
{ {
return logResponse.CreateLoginFailedResponse(); return logResponse.CreateLoginFailedResponse();
} }
else else
{ {
// If we already have a session... // If we already have a session...
if (userProfile.currentAgent != null && userProfile.currentAgent.agentOnline) if (userProfile.currentAgent != null && userProfile.currentAgent.agentOnline)
{
// Reject the login
return logResponse.CreateAlreadyLoggedInResponse();
}
// Otherwise...
// Create a new agent session
CreateAgent(userProfile, request);
try
{
LLUUID agentID = userProfile.UUID;
// Inventory Library Section
InventoryData inventData = this.CreateInventoryData(agentID);
ArrayList AgentInventoryArray = inventData.InventoryArray;
Hashtable InventoryRootHash = new Hashtable();
InventoryRootHash["folder_id"] = inventData.RootFolderID.ToStringHyphenated();
ArrayList InventoryRoot = new ArrayList();
InventoryRoot.Add(InventoryRootHash);
userProfile.rootInventoryFolderID = inventData.RootFolderID;
// Circuit Code
uint circode = (uint)(Util.RandomClass.Next());
logResponse.Lastname = userProfile.surname;
logResponse.Firstname = userProfile.username;
logResponse.AgentID = agentID.ToStringHyphenated();
logResponse.SessionID = userProfile.currentAgent.sessionID.ToStringHyphenated();
logResponse.SecureSessionID = userProfile.currentAgent.secureSessionID.ToStringHyphenated();
logResponse.InventoryRoot = InventoryRoot;
logResponse.InventorySkeleton = AgentInventoryArray;
logResponse.InventoryLibrary = this.GetInventoryLibrary();
logResponse.InventoryLibraryOwner = this.GetLibraryOwner();
logResponse.CircuitCode = (Int32)circode;
//logResponse.RegionX = 0; //overwritten
//logResponse.RegionY = 0; //overwritten
logResponse.Home = "!!null temporary value {home}!!"; // Overwritten
//logResponse.LookAt = "\n[r" + TheUser.homeLookAt.X.ToString() + ",r" + TheUser.homeLookAt.Y.ToString() + ",r" + TheUser.homeLookAt.Z.ToString() + "]\n";
//logResponse.SimAddress = "127.0.0.1"; //overwritten
//logResponse.SimPort = 0; //overwritten
logResponse.Message = this.GetMessage();
try
{
this.CustomiseResponse(logResponse, userProfile);
}
catch (Exception e)
{
MainLog.Instance.Verbose(e.ToString());
return logResponse.CreateDeadRegionResponse();
//return logResponse.ToXmlRpcResponse();
}
CommitAgent(ref userProfile);
return logResponse.ToXmlRpcResponse();
}
catch (Exception E)
{ {
MainLog.Instance.Verbose(E.ToString()); // Reject the login
} return logResponse.CreateAlreadyLoggedInResponse();
//} }
} // Otherwise...
return response; // Create a new agent session
CreateAgent(userProfile, request);
}
try
/// <summary> {
/// Customises the login response and fills in missing values. LLUUID agentID = userProfile.UUID;
/// </summary>
/// <param name="response">The existing response</param> // Inventory Library Section
/// <param name="theUser">The user profile</param> InventoryData inventData = this.CreateInventoryData(agentID);
public virtual void CustomiseResponse(LoginResponse response, UserProfileData theUser) ArrayList AgentInventoryArray = inventData.InventoryArray;
{
} Hashtable InventoryRootHash = new Hashtable();
InventoryRootHash["folder_id"] = inventData.RootFolderID.ToStringHyphenated();
/// <summary> ArrayList InventoryRoot = new ArrayList();
/// Saves a target agent to the database InventoryRoot.Add(InventoryRootHash);
/// </summary> userProfile.rootInventoryFolderID = inventData.RootFolderID;
/// <param name="profile">The users profile</param>
/// <returns>Successful?</returns> // Circuit Code
public bool CommitAgent(ref UserProfileData profile) uint circode = (uint)(Util.RandomClass.Next());
{
// Saves the agent to database logResponse.Lastname = userProfile.surname;
return true; logResponse.Firstname = userProfile.username;
} logResponse.AgentID = agentID.ToStringHyphenated();
logResponse.SessionID = userProfile.currentAgent.sessionID.ToStringHyphenated();
logResponse.SecureSessionID = userProfile.currentAgent.secureSessionID.ToStringHyphenated();
/// <summary> logResponse.InventoryRoot = InventoryRoot;
/// Checks a user against it's password hash logResponse.InventorySkeleton = AgentInventoryArray;
/// </summary> logResponse.InventoryLibrary = this.GetInventoryLibrary();
/// <param name="profile">The users profile</param> logResponse.InventoryLibraryOwner = this.GetLibraryOwner();
/// <param name="password">The supplied password</param> logResponse.CircuitCode = (Int32)circode;
/// <returns>Authenticated?</returns> //logResponse.RegionX = 0; //overwritten
public virtual bool AuthenticateUser(UserProfileData profile, string password) //logResponse.RegionY = 0; //overwritten
{ logResponse.Home = "!!null temporary value {home}!!"; // Overwritten
//logResponse.LookAt = "\n[r" + TheUser.homeLookAt.X.ToString() + ",r" + TheUser.homeLookAt.Y.ToString() + ",r" + TheUser.homeLookAt.Z.ToString() + "]\n";
MainLog.Instance.Verbose( //logResponse.SimAddress = "127.0.0.1"; //overwritten
"Authenticating " + profile.username + " " + profile.surname); //logResponse.SimPort = 0; //overwritten
logResponse.Message = this.GetMessage();
password = password.Remove(0, 3); //remove $1$
try
string s = Util.Md5Hash(password + ":" + profile.passwordSalt); {
this.CustomiseResponse(logResponse, userProfile);
return profile.passwordHash.Equals(s.ToString(), StringComparison.InvariantCultureIgnoreCase); }
} catch (Exception e)
{
/// <summary> MainLog.Instance.Verbose(e.ToString());
/// return logResponse.CreateDeadRegionResponse();
/// </summary> //return logResponse.ToXmlRpcResponse();
/// <param name="profile"></param> }
/// <param name="request"></param> CommitAgent(ref userProfile);
public void CreateAgent(UserProfileData profile, XmlRpcRequest request) return logResponse.ToXmlRpcResponse();
{
this.m_userManager.CreateAgent(profile, request); }
}
catch (Exception E)
/// <summary> {
/// MainLog.Instance.Verbose(E.ToString());
/// </summary> }
/// <param name="firstname"></param> //}
/// <param name="lastname"></param> }
/// <returns></returns> return response;
public virtual UserProfileData GetTheUser(string firstname, string lastname)
{ }
return this.m_userManager.GetUserProfile(firstname, lastname);
} /// <summary>
/// Customises the login response and fills in missing values.
/// <summary> /// </summary>
/// /// <param name="response">The existing response</param>
/// </summary> /// <param name="theUser">The user profile</param>
/// <returns></returns> public virtual void CustomiseResponse(LoginResponse response, UserProfileData theUser)
public virtual string GetMessage() {
{ }
return m_welcomeMessage;
} /// <summary>
/// Saves a target agent to the database
/// <summary> /// </summary>
/// /// <param name="profile">The users profile</param>
/// </summary> /// <returns>Successful?</returns>
/// <returns></returns> public bool CommitAgent(ref UserProfileData profile)
protected virtual ArrayList GetInventoryLibrary() {
{ // Saves the agent to database
//return new ArrayList(); return true;
Hashtable TempHash = new Hashtable(); }
TempHash["name"] = "OpenSim Library";
TempHash["parent_id"] = LLUUID.Zero.ToStringHyphenated();
TempHash["version"] = 1; /// <summary>
TempHash["type_default"] = -1; /// Checks a user against it's password hash
TempHash["folder_id"] = "00000112-000f-0000-0000-000100bba000"; /// </summary>
ArrayList temp = new ArrayList(); /// <param name="profile">The users profile</param>
temp.Add(TempHash); /// <param name="password">The supplied password</param>
/// <returns>Authenticated?</returns>
TempHash = new Hashtable(); public virtual bool AuthenticateUser(UserProfileData profile, string password)
TempHash["name"] = "Texture Library"; {
TempHash["parent_id"] = "00000112-000f-0000-0000-000100bba000";
TempHash["version"] = 1; MainLog.Instance.Verbose(
TempHash["type_default"] = -1; "Authenticating " + profile.username + " " + profile.surname);
TempHash["folder_id"] = "00000112-000f-0000-0000-000100bba001";
temp.Add(TempHash); password = password.Remove(0, 3); //remove $1$
return temp;
} string s = Util.Md5Hash(password + ":" + profile.passwordSalt);
/// <summary> return profile.passwordHash.Equals(s.ToString(), StringComparison.InvariantCultureIgnoreCase);
/// }
/// </summary>
/// <returns></returns> /// <summary>
protected virtual ArrayList GetLibraryOwner() ///
{ /// </summary>
//for now create random inventory library owner /// <param name="profile"></param>
Hashtable TempHash = new Hashtable(); /// <param name="request"></param>
TempHash["agent_id"] = "11111111-1111-0000-0000-000100bba000"; public void CreateAgent(UserProfileData profile, XmlRpcRequest request)
ArrayList inventoryLibOwner = new ArrayList(); {
inventoryLibOwner.Add(TempHash); this.m_userManager.CreateAgent(profile, request);
return inventoryLibOwner; }
}
/// <summary>
protected virtual InventoryData CreateInventoryData(LLUUID userID) ///
{ /// </summary>
AgentInventory userInventory = new AgentInventory(); /// <param name="firstname"></param>
userInventory.CreateRootFolder(userID, false); /// <param name="lastname"></param>
/// <returns></returns>
ArrayList AgentInventoryArray = new ArrayList(); public virtual UserProfileData GetTheUser(string firstname, string lastname)
Hashtable TempHash; {
foreach (InventoryFolder InvFolder in userInventory.InventoryFolders.Values) return this.m_userManager.GetUserProfile(firstname, lastname);
{ }
TempHash = new Hashtable();
TempHash["name"] = InvFolder.FolderName; /// <summary>
TempHash["parent_id"] = InvFolder.ParentID.ToStringHyphenated(); ///
TempHash["version"] = (Int32)InvFolder.Version; /// </summary>
TempHash["type_default"] = (Int32)InvFolder.DefaultType; /// <returns></returns>
TempHash["folder_id"] = InvFolder.FolderID.ToStringHyphenated(); public virtual string GetMessage()
AgentInventoryArray.Add(TempHash); {
} return m_welcomeMessage;
}
return new InventoryData(AgentInventoryArray, userInventory.InventoryRoot.FolderID);
} /// <summary>
///
public class InventoryData /// </summary>
{ /// <returns></returns>
public ArrayList InventoryArray = null; protected virtual ArrayList GetInventoryLibrary()
public LLUUID RootFolderID = LLUUID.Zero; {
//return new ArrayList();
public InventoryData(ArrayList invList, LLUUID rootID) Hashtable TempHash = new Hashtable();
{ TempHash["name"] = "OpenSim Library";
InventoryArray = invList; TempHash["parent_id"] = LLUUID.Zero.ToStringHyphenated();
RootFolderID = rootID; TempHash["version"] = 1;
} TempHash["type_default"] = -1;
} TempHash["folder_id"] = "00000112-000f-0000-0000-000100bba000";
} ArrayList temp = new ArrayList();
} temp.Add(TempHash);
TempHash = new Hashtable();
TempHash["name"] = "Texture Library";
TempHash["parent_id"] = "00000112-000f-0000-0000-000100bba000";
TempHash["version"] = 1;
TempHash["type_default"] = -1;
TempHash["folder_id"] = "00000112-000f-0000-0000-000100bba001";
temp.Add(TempHash);
return temp;
}
/// <summary>
///
/// </summary>
/// <returns></returns>
protected virtual ArrayList GetLibraryOwner()
{
//for now create random inventory library owner
Hashtable TempHash = new Hashtable();
TempHash["agent_id"] = "11111111-1111-0000-0000-000100bba000";
ArrayList inventoryLibOwner = new ArrayList();
inventoryLibOwner.Add(TempHash);
return inventoryLibOwner;
}
protected virtual InventoryData CreateInventoryData(LLUUID userID)
{
AgentInventory userInventory = new AgentInventory();
userInventory.CreateRootFolder(userID, false);
ArrayList AgentInventoryArray = new ArrayList();
Hashtable TempHash;
foreach (InventoryFolder InvFolder in userInventory.InventoryFolders.Values)
{
TempHash = new Hashtable();
TempHash["name"] = InvFolder.FolderName;
TempHash["parent_id"] = InvFolder.ParentID.ToStringHyphenated();
TempHash["version"] = (Int32)InvFolder.Version;
TempHash["type_default"] = (Int32)InvFolder.DefaultType;
TempHash["folder_id"] = InvFolder.FolderID.ToStringHyphenated();
AgentInventoryArray.Add(TempHash);
}
return new InventoryData(AgentInventoryArray, userInventory.InventoryRoot.FolderID);
}
public class InventoryData
{
public ArrayList InventoryArray = null;
public LLUUID RootFolderID = LLUUID.Zero;
public InventoryData(ArrayList invList, LLUUID rootID)
{
InventoryArray = invList;
RootFolderID = rootID;
}
}
}
}

View File

@ -37,8 +37,8 @@ namespace OpenSim.Grid.UserServer
"'position':[r" + theUser.homeLocation.X.ToString() + ",r" + theUser.homeLocation.Y.ToString() + ",r" + theUser.homeLocation.Z.ToString() + "], " + "'position':[r" + theUser.homeLocation.X.ToString() + ",r" + theUser.homeLocation.Y.ToString() + ",r" + theUser.homeLocation.Z.ToString() + "], " +
"'look_at':[r" + theUser.homeLocation.X.ToString() + ",r" + theUser.homeLocation.Y.ToString() + ",r" + theUser.homeLocation.Z.ToString() + "]}"; "'look_at':[r" + theUser.homeLocation.X.ToString() + ",r" + theUser.homeLocation.Y.ToString() + ",r" + theUser.homeLocation.Z.ToString() + "]}";
// Destination // Destination
MainLog.Instance.Verbose("CUSTOMISERESPONSE: Region X: " + SimInfo.regionLocX + "; Region Y: " + SimInfo.regionLocY); Console.WriteLine("CUSTOMISERESPONSE: Region X: " + SimInfo.regionLocX + "; Region Y: " + SimInfo.regionLocY);
response.SimAddress = Util.GetHostFromDNS(SimInfo.serverIP).ToString(); response.SimAddress = Util.GetHostFromDNS(SimInfo.serverIP).ToString();
response.SimPort = (Int32)SimInfo.serverPort; response.SimPort = (Int32)SimInfo.serverPort;
response.RegionX = SimInfo.regionLocX; response.RegionX = SimInfo.regionLocX;
@ -48,8 +48,8 @@ namespace OpenSim.Grid.UserServer
string capsPath = Util.GetRandomCapsPath(); string capsPath = Util.GetRandomCapsPath();
response.SeedCapability = SimInfo.httpServerURI + "CAPS/" + capsPath + "0000/"; response.SeedCapability = SimInfo.httpServerURI + "CAPS/" + capsPath + "0000/";
// Notify the target of an incoming user // Notify the target of an incoming user
MainLog.Instance.Verbose("Notifying " + SimInfo.regionName + " (" + SimInfo.serverURI + ")"); Console.WriteLine("Notifying " + SimInfo.regionName + " (" + SimInfo.serverURI + ")");
// Prepare notification // Prepare notification
Hashtable SimParams = new Hashtable(); Hashtable SimParams = new Hashtable();
@ -69,9 +69,9 @@ namespace OpenSim.Grid.UserServer
// Update agent with target sim // Update agent with target sim
theUser.currentAgent.currentRegion = SimInfo.UUID; theUser.currentAgent.currentRegion = SimInfo.UUID;
theUser.currentAgent.currentHandle = SimInfo.regionHandle; theUser.currentAgent.currentHandle = SimInfo.regionHandle;
MainLog.Instance.Verbose("Informing region --> " + SimInfo.httpServerURI); System.Console.WriteLine("Informing region --> " + SimInfo.httpServerURI);
// Send // Send
try try
{ {