mirror of
https://github.com/opensim/opensim.git
synced 2026-08-04 16:22:50 +08:00
SandBox mode login now shares a base class with the grid mode user server.
To allow people to login without creating accounts first in sandbox mode anytime a login request is received without a matching account already being in the database, a new account will be made. (also in sandbox mode, passwords aren't currently used).
This commit is contained in:
656
Common/OpenGrid.Framework.UserManager/LoginResponse.cs
Normal file
656
Common/OpenGrid.Framework.UserManager/LoginResponse.cs
Normal file
@@ -0,0 +1,656 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading;
|
||||
using System.Collections;
|
||||
using System.Xml;
|
||||
using libsecondlife;
|
||||
using OpenSim.Framework.Utilities;
|
||||
using OpenSim.Framework.Interfaces;
|
||||
using Nwc.XmlRpc;
|
||||
|
||||
namespace OpenGrid.Framework.UserManagement
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// A temp class to handle login response.
|
||||
/// Should make use of UserProfileManager where possible.
|
||||
/// </summary>
|
||||
|
||||
public class LoginResponse
|
||||
{
|
||||
private Hashtable loginFlagsHash;
|
||||
private Hashtable globalTexturesHash;
|
||||
private Hashtable loginError;
|
||||
private Hashtable eventCategoriesHash;
|
||||
private Hashtable uiConfigHash;
|
||||
private Hashtable classifiedCategoriesHash;
|
||||
|
||||
private ArrayList loginFlags;
|
||||
private ArrayList globalTextures;
|
||||
private ArrayList eventCategories;
|
||||
private ArrayList uiConfig;
|
||||
private ArrayList classifiedCategories;
|
||||
private ArrayList inventoryRoot;
|
||||
private ArrayList initialOutfit;
|
||||
private ArrayList agentInventory;
|
||||
|
||||
private UserInfo userProfile;
|
||||
|
||||
private LLUUID agentID;
|
||||
private LLUUID sessionID;
|
||||
private LLUUID secureSessionID;
|
||||
private LLUUID baseFolderID;
|
||||
private LLUUID inventoryFolderID;
|
||||
|
||||
// Login Flags
|
||||
private string dst;
|
||||
private string stipendSinceLogin;
|
||||
private string gendered;
|
||||
private string everLoggedIn;
|
||||
private string login;
|
||||
private int simPort;
|
||||
private string simAddress;
|
||||
private string agentAccess;
|
||||
private Int32 circuitCode;
|
||||
private uint regionX;
|
||||
private uint regionY;
|
||||
|
||||
// Login
|
||||
private string firstname;
|
||||
private string lastname;
|
||||
|
||||
// Global Textures
|
||||
private string sunTexture;
|
||||
private string cloudTexture;
|
||||
private string moonTexture;
|
||||
|
||||
// Error Flags
|
||||
private string errorReason;
|
||||
private string errorMessage;
|
||||
|
||||
// Response
|
||||
private XmlRpcResponse xmlRpcResponse;
|
||||
private XmlRpcResponse defaultXmlRpcResponse;
|
||||
|
||||
private string welcomeMessage;
|
||||
private string startLocation;
|
||||
private string allowFirstLife;
|
||||
private string home;
|
||||
private string seedCapability;
|
||||
private string lookAt;
|
||||
|
||||
public LoginResponse()
|
||||
{
|
||||
this.loginFlags = new ArrayList();
|
||||
this.globalTextures = new ArrayList();
|
||||
this.eventCategories = new ArrayList();
|
||||
this.uiConfig = new ArrayList();
|
||||
this.classifiedCategories = new ArrayList();
|
||||
|
||||
this.loginError = new Hashtable();
|
||||
this.eventCategoriesHash = new Hashtable();
|
||||
this.classifiedCategoriesHash = new Hashtable();
|
||||
this.uiConfigHash = new Hashtable();
|
||||
|
||||
this.defaultXmlRpcResponse = new XmlRpcResponse();
|
||||
this.userProfile = new UserInfo();
|
||||
this.inventoryRoot = new ArrayList();
|
||||
this.initialOutfit = new ArrayList();
|
||||
this.agentInventory = new ArrayList();
|
||||
|
||||
this.xmlRpcResponse = new XmlRpcResponse();
|
||||
this.defaultXmlRpcResponse = new XmlRpcResponse();
|
||||
|
||||
this.SetDefaultValues();
|
||||
} // LoginServer
|
||||
|
||||
public void SetDefaultValues()
|
||||
{
|
||||
try
|
||||
{
|
||||
this.DST = "N";
|
||||
this.StipendSinceLogin = "N";
|
||||
this.Gendered = "Y";
|
||||
this.EverLoggedIn = "Y";
|
||||
this.login = "false";
|
||||
this.firstname = "Test";
|
||||
this.lastname = "User";
|
||||
this.agentAccess = "M";
|
||||
this.startLocation = "last";
|
||||
this.allowFirstLife = "Y";
|
||||
|
||||
this.SunTexture = "cce0f112-878f-4586-a2e2-a8f104bba271";
|
||||
this.CloudTexture = "fc4b9f0b-d008-45c6-96a4-01dd947ac621";
|
||||
this.MoonTexture = "fc4b9f0b-d008-45c6-96a4-01dd947ac621";
|
||||
|
||||
this.ErrorMessage = "You have entered an invalid name/password combination. Check Caps/lock.";
|
||||
this.ErrorReason = "key";
|
||||
this.welcomeMessage = "Welcome to OpenSim!";
|
||||
this.seedCapability = "";
|
||||
this.home = "{'region_handle':[r" + (997 * 256).ToString() + ",r" + (996 * 256).ToString() + "], 'position':[r" + this.userProfile.homepos.X.ToString() + ",r" + this.userProfile.homepos.Y.ToString() + ",r" + this.userProfile.homepos.Z.ToString() + "], 'look_at':[r" + this.userProfile.homelookat.X.ToString() + ",r" + this.userProfile.homelookat.Y.ToString() + ",r" + this.userProfile.homelookat.Z.ToString() + "]}";
|
||||
this.lookAt = "[r0.99949799999999999756,r0.03166859999999999814,r0]";
|
||||
this.RegionX = (uint)255232;
|
||||
this.RegionY = (uint)254976;
|
||||
|
||||
// Classifieds;
|
||||
this.AddClassifiedCategory((Int32)1, "Shopping");
|
||||
this.AddClassifiedCategory((Int32)2, "Land Rental");
|
||||
this.AddClassifiedCategory((Int32)3, "Property Rental");
|
||||
this.AddClassifiedCategory((Int32)4, "Special Attraction");
|
||||
this.AddClassifiedCategory((Int32)5, "New Products");
|
||||
this.AddClassifiedCategory((Int32)6, "Employment");
|
||||
this.AddClassifiedCategory((Int32)7, "Wanted");
|
||||
this.AddClassifiedCategory((Int32)8, "Service");
|
||||
this.AddClassifiedCategory((Int32)9, "Personal");
|
||||
|
||||
|
||||
this.SessionID = LLUUID.Random();
|
||||
this.SecureSessionID = LLUUID.Random();
|
||||
this.AgentID = LLUUID.Random();
|
||||
|
||||
Hashtable InitialOutfitHash = new Hashtable();
|
||||
InitialOutfitHash["folder_name"] = "Nightclub Female";
|
||||
InitialOutfitHash["gender"] = "female";
|
||||
this.initialOutfit.Add(InitialOutfitHash);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
OpenSim.Framework.Console.MainLog.Instance.WriteLine(
|
||||
OpenSim.Framework.Console.LogPriority.LOW,
|
||||
"LoginResponse: Unable to set default values: " + e.Message
|
||||
);
|
||||
}
|
||||
|
||||
} // SetDefaultValues
|
||||
|
||||
#region Login Failure Methods
|
||||
public XmlRpcResponse GenerateFailureResponse(string reason, string message, string login)
|
||||
{
|
||||
// Overwrite any default values;
|
||||
this.xmlRpcResponse = new XmlRpcResponse();
|
||||
|
||||
// Ensure Login Failed message/reason;
|
||||
this.ErrorMessage = message;
|
||||
this.ErrorReason = reason;
|
||||
|
||||
this.loginError["reason"] = this.ErrorReason;
|
||||
this.loginError["message"] = this.ErrorMessage;
|
||||
this.loginError["login"] = login;
|
||||
this.xmlRpcResponse.Value = this.loginError;
|
||||
return (this.xmlRpcResponse);
|
||||
} // GenerateResponse
|
||||
|
||||
public XmlRpcResponse CreateFailedResponse()
|
||||
{
|
||||
return (this.CreateLoginFailedResponse());
|
||||
} // CreateErrorConnectingToGridResponse()
|
||||
|
||||
public XmlRpcResponse CreateLoginFailedResponse()
|
||||
{
|
||||
return (this.GenerateFailureResponse("key", "Could not authenticate your avatar. Please check your username and password, and check the grid if problems persist.", "false"));
|
||||
} // LoginFailedResponse
|
||||
|
||||
public XmlRpcResponse CreateAlreadyLoggedInResponse()
|
||||
{
|
||||
return (this.GenerateFailureResponse("presence", "You appear to be already logged in, if this is not the case please wait for your session to timeout, if this takes longer than a few minutes please contact the grid owner", "false"));
|
||||
} // CreateAlreadyLoggedInResponse()
|
||||
|
||||
public XmlRpcResponse CreateDeadRegionResponse()
|
||||
{
|
||||
return (this.GenerateFailureResponse("key", "The region you are attempting to log into is not responding. Please select another region and try again.", "false"));
|
||||
}
|
||||
|
||||
public XmlRpcResponse CreateGridErrorResponse()
|
||||
{
|
||||
return (this.GenerateFailureResponse("key", "Error connecting to grid. Could not percieve credentials from login XML.", "false"));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public XmlRpcResponse ToXmlRpcResponse()
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
Hashtable responseData = new Hashtable();
|
||||
|
||||
this.loginFlagsHash = new Hashtable();
|
||||
this.loginFlagsHash["daylight_savings"] = this.DST;
|
||||
this.loginFlagsHash["stipend_since_login"] = this.StipendSinceLogin;
|
||||
this.loginFlagsHash["gendered"] = this.Gendered;
|
||||
this.loginFlagsHash["ever_logged_in"] = this.EverLoggedIn;
|
||||
this.loginFlags.Add(this.loginFlagsHash);
|
||||
|
||||
responseData["first_name"] = this.Firstname;
|
||||
responseData["last_name"] = this.Lastname;
|
||||
responseData["agent_access"] = this.agentAccess;
|
||||
|
||||
this.globalTexturesHash = new Hashtable();
|
||||
this.globalTexturesHash["sun_texture_id"] = this.SunTexture;
|
||||
this.globalTexturesHash["cloud_texture_id"] = this.CloudTexture;
|
||||
this.globalTexturesHash["moon_texture_id"] = this.MoonTexture;
|
||||
this.globalTextures.Add(this.globalTexturesHash);
|
||||
this.eventCategories.Add(this.eventCategoriesHash);
|
||||
|
||||
this.AddToUIConfig("allow_first_life", this.allowFirstLife);
|
||||
this.uiConfig.Add(this.uiConfigHash);
|
||||
|
||||
responseData["sim_port"] =(Int32) this.SimPort;
|
||||
responseData["sim_ip"] = this.SimAddress;
|
||||
responseData["agent_id"] = this.AgentID.ToStringHyphenated();
|
||||
responseData["session_id"] = this.SessionID.ToStringHyphenated();
|
||||
responseData["secure_session_id"] = this.SecureSessionID.ToStringHyphenated();
|
||||
responseData["circuit_code"] = this.CircuitCode;
|
||||
responseData["seconds_since_epoch"] = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;
|
||||
responseData["login-flags"] = this.loginFlags;
|
||||
responseData["global-textures"] = this.globalTextures;
|
||||
responseData["seed_capability"] = this.seedCapability;
|
||||
|
||||
responseData["event_categories"] = this.eventCategories;
|
||||
responseData["event_notifications"] = new ArrayList(); // todo
|
||||
responseData["classified_categories"] = this.classifiedCategories;
|
||||
responseData["ui-config"] = this.uiConfig;
|
||||
|
||||
responseData["inventory-skeleton"] = this.agentInventory;
|
||||
responseData["inventory-skel-lib"] = new ArrayList(); // todo
|
||||
responseData["inventory-root"] = this.inventoryRoot;
|
||||
responseData["gestures"] = new ArrayList(); // todo
|
||||
responseData["inventory-lib-owner"] = new ArrayList(); // todo
|
||||
responseData["initial-outfit"] = this.initialOutfit;
|
||||
responseData["start_location"] = this.startLocation;
|
||||
responseData["seed_capability"] = this.seedCapability;
|
||||
responseData["home"] = this.home;
|
||||
responseData["look_at"] = this.lookAt;
|
||||
responseData["message"] = this.welcomeMessage;
|
||||
responseData["region_x"] = (Int32)this.RegionX * 256;
|
||||
responseData["region_y"] = (Int32)this.RegionY * 256;
|
||||
|
||||
//responseData["inventory-lib-root"] = new ArrayList(); // todo
|
||||
//responseData["buddy-list"] = new ArrayList(); // todo
|
||||
|
||||
responseData["login"] = "true";
|
||||
this.xmlRpcResponse.Value = responseData;
|
||||
|
||||
return (this.xmlRpcResponse);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
OpenSim.Framework.Console.MainLog.Instance.WriteLine(
|
||||
OpenSim.Framework.Console.LogPriority.LOW,
|
||||
"LoginResponse: Error creating XML-RPC Response: " + e.Message
|
||||
);
|
||||
return (this.GenerateFailureResponse("Internal Error", "Error generating Login Response", "false"));
|
||||
|
||||
}
|
||||
|
||||
} // ToXmlRpcResponse
|
||||
|
||||
public void SetEventCategories(string category, string value)
|
||||
{
|
||||
this.eventCategoriesHash[category] = value;
|
||||
} // SetEventCategories
|
||||
|
||||
public void AddToUIConfig(string itemName, string item)
|
||||
{
|
||||
this.uiConfigHash[itemName] = item;
|
||||
} // SetUIConfig
|
||||
|
||||
public void AddClassifiedCategory(Int32 ID, string categoryName)
|
||||
{
|
||||
this.classifiedCategoriesHash["category_name"] = categoryName;
|
||||
this.classifiedCategoriesHash["category_id"] = ID;
|
||||
this.classifiedCategories.Add(this.classifiedCategoriesHash);
|
||||
// this.classifiedCategoriesHash.Clear();
|
||||
} // SetClassifiedCategory
|
||||
|
||||
#region Properties
|
||||
public string Login
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.login;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.login = value;
|
||||
}
|
||||
} // Login
|
||||
|
||||
public string DST
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.dst;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.dst = value;
|
||||
}
|
||||
} // DST
|
||||
|
||||
public string StipendSinceLogin
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.stipendSinceLogin;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.stipendSinceLogin = value;
|
||||
}
|
||||
} // StipendSinceLogin
|
||||
|
||||
public string Gendered
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.gendered;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.gendered = value;
|
||||
}
|
||||
} // Gendered
|
||||
|
||||
public string EverLoggedIn
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.everLoggedIn;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.everLoggedIn = value;
|
||||
}
|
||||
} // EverLoggedIn
|
||||
|
||||
public int SimPort
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.simPort;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.simPort = value;
|
||||
}
|
||||
} // SimPort
|
||||
|
||||
public string SimAddress
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.simAddress;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.simAddress = value;
|
||||
}
|
||||
} // SimAddress
|
||||
|
||||
public LLUUID AgentID
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.agentID;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.agentID = value;
|
||||
}
|
||||
} // AgentID
|
||||
|
||||
public LLUUID SessionID
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.sessionID;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.sessionID = value;
|
||||
}
|
||||
} // SessionID
|
||||
|
||||
public LLUUID SecureSessionID
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.secureSessionID;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.secureSessionID = value;
|
||||
}
|
||||
} // SecureSessionID
|
||||
|
||||
public Int32 CircuitCode
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.circuitCode;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.circuitCode = value;
|
||||
}
|
||||
} // CircuitCode
|
||||
|
||||
public uint RegionX
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.regionX;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.regionX = value;
|
||||
}
|
||||
} // RegionX
|
||||
|
||||
public uint RegionY
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.regionY;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.regionY = value;
|
||||
}
|
||||
} // RegionY
|
||||
|
||||
public string SunTexture
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.sunTexture;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.sunTexture = value;
|
||||
}
|
||||
} // SunTexture
|
||||
|
||||
public string CloudTexture
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.cloudTexture;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.cloudTexture = value;
|
||||
}
|
||||
} // CloudTexture
|
||||
|
||||
public string MoonTexture
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.moonTexture;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.moonTexture = value;
|
||||
}
|
||||
} // MoonTexture
|
||||
|
||||
public string Firstname
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.firstname;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.firstname = value;
|
||||
}
|
||||
} // Firstname
|
||||
|
||||
public string Lastname
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.lastname;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.lastname = value;
|
||||
}
|
||||
} // Lastname
|
||||
|
||||
public string AgentAccess
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.agentAccess;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.agentAccess = value;
|
||||
}
|
||||
}
|
||||
|
||||
public string StartLocation
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.startLocation;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.startLocation = value;
|
||||
}
|
||||
} // StartLocation
|
||||
|
||||
public string LookAt
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.lookAt;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.lookAt = value;
|
||||
}
|
||||
}
|
||||
|
||||
public string SeedCapability
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.seedCapability;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.seedCapability = value;
|
||||
}
|
||||
} // SeedCapability
|
||||
|
||||
public string ErrorReason
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.errorReason;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.errorReason = value;
|
||||
}
|
||||
} // ErrorReason
|
||||
|
||||
public string ErrorMessage
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.errorMessage;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.errorMessage = value;
|
||||
}
|
||||
} // ErrorMessage
|
||||
|
||||
public ArrayList InventoryRoot
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.inventoryRoot;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.inventoryRoot = value;
|
||||
}
|
||||
}
|
||||
|
||||
public ArrayList InventorySkeleton
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.agentInventory;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.agentInventory = value;
|
||||
}
|
||||
}
|
||||
|
||||
public string Home
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.home;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.home = value;
|
||||
}
|
||||
}
|
||||
|
||||
public string Message
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.welcomeMessage;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.welcomeMessage = value;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
public class UserInfo
|
||||
{
|
||||
public string firstname;
|
||||
public string lastname;
|
||||
public ulong homeregionhandle;
|
||||
public LLVector3 homepos;
|
||||
public LLVector3 homelookat;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,6 +108,9 @@
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="LoginResponse.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="UserManagerBase.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
<resources prefix="OpenGrid.Framework.UserManagement" dynamicprefix="true" >
|
||||
</resources>
|
||||
<sources failonempty="true">
|
||||
<include name="LoginResponse.cs" />
|
||||
<include name="UserManagerBase.cs" />
|
||||
</sources>
|
||||
<references basedir="${project::get-base-directory()}">
|
||||
|
||||
@@ -79,37 +79,7 @@ namespace OpenGrid.Framework.UserManagement
|
||||
pluginAssembly = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="user"></param>
|
||||
public void AddUserProfile(string firstName, string lastName, string pass, uint regX, uint regY)
|
||||
{
|
||||
UserProfileData user = new UserProfileData();
|
||||
user.homeLocation = new LLVector3(128, 128, 100);
|
||||
user.UUID = LLUUID.Random();
|
||||
user.username = firstName;
|
||||
user.surname = lastName;
|
||||
user.passwordHash = pass;
|
||||
user.passwordSalt = "";
|
||||
user.created = Util.UnixTimeSinceEpoch();
|
||||
user.homeLookAt = new LLVector3(100, 100, 100);
|
||||
user.homeRegion = Util.UIntsToLong((regX * 256), (regY * 256));
|
||||
|
||||
foreach (KeyValuePair<string, IUserData> plugin in _plugins)
|
||||
{
|
||||
try
|
||||
{
|
||||
plugin.Value.addNewUserProfile(user);
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
OpenSim.Framework.Console.MainLog.Instance.Verbose( "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#region Get UserProfile
|
||||
/// <summary>
|
||||
/// Loads a user profile from a database by UUID
|
||||
/// </summary>
|
||||
@@ -190,7 +160,9 @@ namespace OpenGrid.Framework.UserManagement
|
||||
|
||||
return null;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Get UserAgent
|
||||
/// <summary>
|
||||
/// Loads a user agent by uuid (not called directly)
|
||||
/// </summary>
|
||||
@@ -258,94 +230,9 @@ namespace OpenGrid.Framework.UserManagement
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a error response caused by invalid XML
|
||||
/// </summary>
|
||||
/// <returns>An XMLRPC response</returns>
|
||||
private static XmlRpcResponse CreateErrorConnectingToGridResponse()
|
||||
{
|
||||
XmlRpcResponse response = new XmlRpcResponse();
|
||||
Hashtable ErrorRespData = new Hashtable();
|
||||
ErrorRespData["reason"] = "key";
|
||||
ErrorRespData["message"] = "Error connecting to grid. Could not percieve credentials from login XML.";
|
||||
ErrorRespData["login"] = "false";
|
||||
response.Value = ErrorRespData;
|
||||
return response;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates an error response caused by bad login credentials
|
||||
/// </summary>
|
||||
/// <returns>An XMLRPC response</returns>
|
||||
private static XmlRpcResponse CreateLoginErrorResponse()
|
||||
{
|
||||
XmlRpcResponse response = new XmlRpcResponse();
|
||||
Hashtable ErrorRespData = new Hashtable();
|
||||
ErrorRespData["reason"] = "key";
|
||||
ErrorRespData["message"] = "Could not authenticate your avatar. Please check your username and password, and check the grid if problems persist.";
|
||||
ErrorRespData["login"] = "false";
|
||||
response.Value = ErrorRespData;
|
||||
return response;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates an error response caused by being logged in already
|
||||
/// </summary>
|
||||
/// <returns>An XMLRPC Response</returns>
|
||||
private static XmlRpcResponse CreateAlreadyLoggedInResponse()
|
||||
{
|
||||
XmlRpcResponse response = new XmlRpcResponse();
|
||||
Hashtable PresenceErrorRespData = new Hashtable();
|
||||
PresenceErrorRespData["reason"] = "presence";
|
||||
PresenceErrorRespData["message"] = "You appear to be already logged in, if this is not the case please wait for your session to timeout, if this takes longer than a few minutes please contact the grid owner";
|
||||
PresenceErrorRespData["login"] = "false";
|
||||
response.Value = PresenceErrorRespData;
|
||||
return response;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates an error response caused by target region being down
|
||||
/// </summary>
|
||||
/// <returns>An XMLRPC Response</returns>
|
||||
private static XmlRpcResponse CreateDeadRegionResponse()
|
||||
{
|
||||
XmlRpcResponse response = new XmlRpcResponse();
|
||||
Hashtable PresenceErrorRespData = new Hashtable();
|
||||
PresenceErrorRespData["reason"] = "key";
|
||||
PresenceErrorRespData["message"] = "The region you are attempting to log into is not responding. Please select another region and try again.";
|
||||
PresenceErrorRespData["login"] = "false";
|
||||
response.Value = PresenceErrorRespData;
|
||||
return response;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Customises the login response and fills in missing values.
|
||||
/// </summary>
|
||||
/// <param name="response">The existing response</param>
|
||||
/// <param name="theUser">The user profile</param>
|
||||
public virtual void CustomiseResponse(ref Hashtable response, ref UserProfileData theUser)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks a user against it's password hash
|
||||
/// </summary>
|
||||
/// <param name="profile">The users profile</param>
|
||||
/// <param name="password">The supplied password</param>
|
||||
/// <returns>Authenticated?</returns>
|
||||
public bool AuthenticateUser(ref UserProfileData profile, string password)
|
||||
{
|
||||
OpenSim.Framework.Console.MainLog.Instance.Verbose(
|
||||
"Authenticating " + profile.username + " " + profile.surname);
|
||||
|
||||
password = password.Remove(0, 3); //remove $1$
|
||||
|
||||
string s = Util.Md5Hash(password + ":" + profile.passwordSalt);
|
||||
|
||||
return profile.passwordHash.Equals(s.ToString(), StringComparison.InvariantCultureIgnoreCase);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region CreateAgent
|
||||
/// <summary>
|
||||
/// Creates and initialises a new user agent - make sure to use CommitAgent when done to submit to the DB
|
||||
/// </summary>
|
||||
@@ -390,7 +277,7 @@ namespace OpenGrid.Framework.UserManagement
|
||||
{
|
||||
string[] parts = startLoc.Remove(0, 4).Split('&');
|
||||
string region = parts[0];
|
||||
|
||||
|
||||
////////////////////////////////////////////////////
|
||||
//SimProfile SimInfo = new SimProfile();
|
||||
//SimInfo = SimInfo.LoadFromGrid(theUser.currentAgent.currentHandle, _config.GridServerURL, _config.GridSendKey, _config.GridRecvKey);
|
||||
@@ -424,6 +311,58 @@ namespace OpenGrid.Framework.UserManagement
|
||||
return true;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Checks a user against it's password hash
|
||||
/// </summary>
|
||||
/// <param name="profile">The users profile</param>
|
||||
/// <param name="password">The supplied password</param>
|
||||
/// <returns>Authenticated?</returns>
|
||||
public virtual bool AuthenticateUser(ref UserProfileData profile, string password)
|
||||
{
|
||||
OpenSim.Framework.Console.MainLog.Instance.Verbose(
|
||||
"Authenticating " + profile.username + " " + profile.surname);
|
||||
|
||||
password = password.Remove(0, 3); //remove $1$
|
||||
|
||||
string s = Util.Md5Hash(password + ":" + profile.passwordSalt);
|
||||
|
||||
return profile.passwordHash.Equals(s.ToString(), StringComparison.InvariantCultureIgnoreCase);
|
||||
}
|
||||
|
||||
#region Xml Response
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="firstname"></param>
|
||||
/// <param name="lastname"></param>
|
||||
/// <returns></returns>
|
||||
public virtual UserProfileData GetTheUser(string firstname, string lastname)
|
||||
{
|
||||
return getUserProfile(firstname, lastname);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public virtual string GetMessage()
|
||||
{
|
||||
return _config.DefaultStartupMsg;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Customises the login response and fills in missing values.
|
||||
/// </summary>
|
||||
/// <param name="response">The existing response</param>
|
||||
/// <param name="theUser">The user profile</param>
|
||||
public virtual void CustomiseResponse(ref LoginResponse response, ref UserProfileData theUser)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Main user login function
|
||||
/// </summary>
|
||||
@@ -441,6 +380,7 @@ namespace OpenGrid.Framework.UserManagement
|
||||
string passwd = "";
|
||||
|
||||
UserProfileData TheUser;
|
||||
LoginResponse logResponse = new LoginResponse();
|
||||
|
||||
if (GoodXML)
|
||||
{
|
||||
@@ -448,20 +388,20 @@ namespace OpenGrid.Framework.UserManagement
|
||||
lastname = (string)requestData["last"];
|
||||
passwd = (string)requestData["passwd"];
|
||||
|
||||
TheUser = getUserProfile(firstname, lastname);
|
||||
TheUser = GetTheUser(firstname, lastname);
|
||||
if (TheUser == null)
|
||||
return CreateLoginErrorResponse();
|
||||
return logResponse.CreateLoginFailedResponse();
|
||||
|
||||
GoodLogin = AuthenticateUser(ref TheUser, passwd);
|
||||
}
|
||||
else
|
||||
{
|
||||
return CreateErrorConnectingToGridResponse();
|
||||
return logResponse.CreateGridErrorResponse();
|
||||
}
|
||||
|
||||
if (!GoodLogin)
|
||||
{
|
||||
return CreateLoginErrorResponse();
|
||||
return logResponse.CreateLoginFailedResponse();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -469,7 +409,7 @@ namespace OpenGrid.Framework.UserManagement
|
||||
if (TheUser.currentAgent != null && TheUser.currentAgent.agentOnline)
|
||||
{
|
||||
// Reject the login
|
||||
return CreateAlreadyLoggedInResponse();
|
||||
return logResponse.CreateAlreadyLoggedInResponse();
|
||||
}
|
||||
// Otherwise...
|
||||
// Create a new agent session
|
||||
@@ -477,39 +417,8 @@ namespace OpenGrid.Framework.UserManagement
|
||||
|
||||
try
|
||||
{
|
||||
Hashtable responseData = new Hashtable();
|
||||
|
||||
LLUUID AgentID = TheUser.UUID;
|
||||
|
||||
// Global Texture Section
|
||||
Hashtable GlobalT = new Hashtable();
|
||||
GlobalT["sun_texture_id"] = "cce0f112-878f-4586-a2e2-a8f104bba271";
|
||||
GlobalT["cloud_texture_id"] = "fc4b9f0b-d008-45c6-96a4-01dd947ac621";
|
||||
GlobalT["moon_texture_id"] = "fc4b9f0b-d008-45c6-96a4-01dd947ac621";
|
||||
ArrayList GlobalTextures = new ArrayList();
|
||||
GlobalTextures.Add(GlobalT);
|
||||
|
||||
// Login Flags Section
|
||||
Hashtable LoginFlagsHash = new Hashtable();
|
||||
LoginFlagsHash["daylight_savings"] = "N";
|
||||
LoginFlagsHash["stipend_since_login"] = "N";
|
||||
LoginFlagsHash["gendered"] = "Y"; // Needs to be combined with below...
|
||||
LoginFlagsHash["ever_logged_in"] = "Y"; // Should allow male/female av selection
|
||||
ArrayList LoginFlags = new ArrayList();
|
||||
LoginFlags.Add(LoginFlagsHash);
|
||||
|
||||
// UI Customisation Section
|
||||
Hashtable uiconfig = new Hashtable();
|
||||
uiconfig["allow_first_life"] = "Y";
|
||||
ArrayList ui_config = new ArrayList();
|
||||
ui_config.Add(uiconfig);
|
||||
|
||||
// Classified Categories Section
|
||||
Hashtable ClassifiedCategoriesHash = new Hashtable();
|
||||
ClassifiedCategoriesHash["category_name"] = "Generic";
|
||||
ClassifiedCategoriesHash["category_id"] = (Int32)1;
|
||||
ArrayList ClassifiedCategories = new ArrayList();
|
||||
ClassifiedCategories.Add(ClassifiedCategoriesHash);
|
||||
|
||||
// Inventory Library Section
|
||||
ArrayList AgentInventoryArray = new ArrayList();
|
||||
@@ -534,62 +443,37 @@ namespace OpenGrid.Framework.UserManagement
|
||||
ArrayList InventoryRoot = new ArrayList();
|
||||
InventoryRoot.Add(InventoryRootHash);
|
||||
|
||||
Hashtable InitialOutfitHash = new Hashtable();
|
||||
InitialOutfitHash["folder_name"] = "Nightclub Female";
|
||||
InitialOutfitHash["gender"] = "female";
|
||||
ArrayList InitialOutfit = new ArrayList();
|
||||
InitialOutfit.Add(InitialOutfitHash);
|
||||
|
||||
// Circuit Code
|
||||
uint circode = (uint)(Util.RandomClass.Next());
|
||||
|
||||
// Generics
|
||||
responseData["last_name"] = TheUser.surname;
|
||||
responseData["ui-config"] = ui_config;
|
||||
responseData["sim_ip"] = "127.0.0.1"; //SimInfo.sim_ip.ToString();
|
||||
responseData["login-flags"] = LoginFlags;
|
||||
responseData["global-textures"] = GlobalTextures;
|
||||
responseData["classified_categories"] = ClassifiedCategories;
|
||||
responseData["event_categories"] = new ArrayList();
|
||||
responseData["inventory-skeleton"] = AgentInventoryArray;
|
||||
responseData["inventory-skel-lib"] = new ArrayList();
|
||||
responseData["inventory-root"] = InventoryRoot;
|
||||
responseData["event_notifications"] = new ArrayList();
|
||||
responseData["gestures"] = new ArrayList();
|
||||
responseData["inventory-lib-owner"] = new ArrayList();
|
||||
responseData["initial-outfit"] = InitialOutfit;
|
||||
responseData["seconds_since_epoch"] = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;
|
||||
responseData["start_location"] = "last";
|
||||
responseData["home"] = "!!null temporary value {home}!!"; // Overwritten
|
||||
responseData["message"] = _config.DefaultStartupMsg;
|
||||
responseData["first_name"] = TheUser.username;
|
||||
responseData["circuit_code"] = (Int32)circode;
|
||||
responseData["sim_port"] = 0; //(Int32)SimInfo.sim_port;
|
||||
responseData["secure_session_id"] = TheUser.currentAgent.secureSessionID.ToStringHyphenated();
|
||||
responseData["look_at"] = "\n[r" + TheUser.homeLookAt.X.ToString() + ",r" + TheUser.homeLookAt.Y.ToString() + ",r" + TheUser.homeLookAt.Z.ToString() + "]\n";
|
||||
responseData["agent_id"] = AgentID.ToStringHyphenated();
|
||||
responseData["region_y"] = (Int32)0; // Overwritten
|
||||
responseData["region_x"] = (Int32)0; // Overwritten
|
||||
responseData["seed_capability"] = "";
|
||||
responseData["agent_access"] = "M";
|
||||
responseData["session_id"] = TheUser.currentAgent.sessionID.ToStringHyphenated();
|
||||
responseData["login"] = "true";
|
||||
|
||||
logResponse.Lastname = TheUser.surname;
|
||||
logResponse.Firstname = TheUser.username;
|
||||
logResponse.AgentID = AgentID.ToStringHyphenated();
|
||||
logResponse.SessionID = TheUser.currentAgent.sessionID.ToStringHyphenated();
|
||||
logResponse.SecureSessionID = TheUser.currentAgent.secureSessionID.ToStringHyphenated();
|
||||
logResponse.InventoryRoot = InventoryRoot;
|
||||
logResponse.InventorySkeleton = AgentInventoryArray;
|
||||
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(ref responseData, ref TheUser);
|
||||
this.CustomiseResponse(ref logResponse, ref TheUser);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine(e.ToString());
|
||||
return CreateDeadRegionResponse();
|
||||
return logResponse.CreateDeadRegionResponse();
|
||||
}
|
||||
|
||||
CommitAgent(ref TheUser);
|
||||
|
||||
response.Value = responseData;
|
||||
// TheUser.SendDataToSim(SimInfo);
|
||||
return response;
|
||||
return logResponse.ToXmlRpcResponse();
|
||||
|
||||
}
|
||||
catch (Exception E)
|
||||
@@ -602,6 +486,8 @@ namespace OpenGrid.Framework.UserManagement
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Deletes an active agent session
|
||||
/// </summary>
|
||||
@@ -616,6 +502,37 @@ namespace OpenGrid.Framework.UserManagement
|
||||
return "OK";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="user"></param>
|
||||
public void AddUserProfile(string firstName, string lastName, string pass, uint regX, uint regY)
|
||||
{
|
||||
UserProfileData user = new UserProfileData();
|
||||
user.homeLocation = new LLVector3(128, 128, 100);
|
||||
user.UUID = LLUUID.Random();
|
||||
user.username = firstName;
|
||||
user.surname = lastName;
|
||||
user.passwordHash = pass;
|
||||
user.passwordSalt = "";
|
||||
user.created = Util.UnixTimeSinceEpoch();
|
||||
user.homeLookAt = new LLVector3(100, 100, 100);
|
||||
user.homeRegion = Util.UIntsToLong((regX * 256), (regY * 256));
|
||||
|
||||
foreach (KeyValuePair<string, IUserData> plugin in _plugins)
|
||||
{
|
||||
try
|
||||
{
|
||||
plugin.Value.addNewUserProfile(user);
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
OpenSim.Framework.Console.MainLog.Instance.Verbose("Unable to add user via " + plugin.Key + "(" + e.ToString() + ")");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns an error message that the user could not be found in the database
|
||||
/// </summary>
|
||||
@@ -693,6 +610,8 @@ namespace OpenGrid.Framework.UserManagement
|
||||
return sw.ToString();
|
||||
}
|
||||
|
||||
#region REST Methods
|
||||
//should most likely move out of here and into the grid's userserver sub class
|
||||
public string RestGetUserMethodName(string request, string path, string param)
|
||||
{
|
||||
UserProfileData userProfile = getUserProfile(param.Trim());
|
||||
@@ -716,6 +635,7 @@ namespace OpenGrid.Framework.UserManagement
|
||||
|
||||
return ProfileToXml(userProfile);
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user