Merge branch 'presence-refactor' of melanie@opensimulator.org:/var/git/opensim into presence-refactor

slimupdates
Melanie 2009-12-31 23:30:09 +00:00
commit a876cfad01
7 changed files with 296 additions and 22 deletions

View File

@ -0,0 +1,139 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* 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 OpenSimulator Project 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 THE DEVELOPERS ``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 THE CONTRIBUTORS 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.Collections;
using System.IO;
using System.Reflection;
using System.Net;
using System.Text;
using OpenSim.Server.Base;
using OpenSim.Server.Handlers.Base;
using OpenSim.Services.Interfaces;
using OpenSim.Framework;
using OpenSim.Framework.Servers.HttpServer;
using OpenMetaverse;
using OpenMetaverse.StructuredData;
using Nwc.XmlRpc;
using Nini.Config;
using log4net;
namespace OpenSim.Server.Handlers.Login
{
public class LLLoginHandlers
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private ILoginService m_LocalService;
public LLLoginHandlers(ILoginService service)
{
m_LocalService = service;
}
public XmlRpcResponse HandleXMLRPCLogin(XmlRpcRequest request, IPEndPoint remoteClient)
{
Hashtable requestData = (Hashtable)request.Params[0];
if (requestData != null)
{
if (requestData.ContainsKey("first") && requestData["first"] != null &&
requestData.ContainsKey("last") && requestData["last"] != null &&
requestData.ContainsKey("passwd") && requestData["passwd"] != null)
{
string startLocation = string.Empty;
if (requestData.ContainsKey("start"))
startLocation = requestData["start"].ToString();
LoginResponse reply = null;
reply = m_LocalService.Login(requestData["first"].ToString(), requestData["last"].ToString(), requestData["passwd"].ToString(), startLocation);
XmlRpcResponse response = new XmlRpcResponse();
response.Value = reply.ToHashtable();
return response;
}
}
return FailedXMLRPCResponse();
}
public OSD HandleLLSDLogin(OSD request, IPEndPoint remoteClient)
{
if (request.Type == OSDType.Map)
{
OSDMap map = (OSDMap)request;
if (map.ContainsKey("first") && map.ContainsKey("last") && map.ContainsKey("passwd"))
{
string startLocation = string.Empty;
if (map.ContainsKey("start"))
startLocation = map["start"].AsString();
m_log.Info("[LOGIN]: LLSD Login Requested for: '" + map["first"].AsString() + "' '" + map["last"].AsString() + "' / " + startLocation);
LoginResponse reply = null;
reply = m_LocalService.Login(map["first"].AsString(), map["last"].AsString(), map["passwd"].AsString(), startLocation);
return reply.ToOSDMap();
}
}
return FailedOSDResponse();
}
private XmlRpcResponse FailedXMLRPCResponse()
{
Hashtable hash = new Hashtable();
hash["reason"] = "key";
hash["message"] = "Incomplete login credentials. Check your username and password.";
hash["login"] = "false";
XmlRpcResponse response = new XmlRpcResponse();
response.Value = hash;
return response;
}
private OSD FailedOSDResponse()
{
OSDMap map = new OSDMap();
map["reason"] = OSD.FromString("key");
map["message"] = OSD.FromString("Invalid login credentials. Check your username and passwd.");
map["login"] = OSD.FromString("false");
return map;
}
}
}

View File

@ -0,0 +1,93 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* 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 OpenSimulator Project 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 THE DEVELOPERS ``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 THE CONTRIBUTORS 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.Collections.Generic;
using System.Reflection;
using log4net;
using Nini.Config;
using OpenSim.Server.Base;
using OpenSim.Services.Interfaces;
using OpenSim.Framework;
using OpenSim.Framework.Servers.HttpServer;
using OpenSim.Server.Handlers.Base;
namespace OpenSim.Server.Handlers.Login
{
public class LLLoginServiceInConnector : ServiceConnector
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private ILoginService m_LoginService;
public LLLoginServiceInConnector(IConfigSource config, IHttpServer server, IScene scene) :
base(config, server, String.Empty)
{
string loginService = ReadLocalServiceFromConfig(config);
ISimulationService simService = scene.RequestModuleInterface<ISimulationService>();
Object[] args = new Object[] { config, simService };
m_LoginService = ServerUtils.LoadPlugin<ILoginService>(loginService, args);
InitializeHandlers(server);
}
public LLLoginServiceInConnector(IConfigSource config, IHttpServer server) :
base(config, server, String.Empty)
{
string loginService = ReadLocalServiceFromConfig(config);
Object[] args = new Object[] { config };
m_LoginService = ServerUtils.LoadPlugin<ILoginService>(loginService, args);
InitializeHandlers(server);
}
private string ReadLocalServiceFromConfig(IConfigSource config)
{
IConfig serverConfig = config.Configs["LoginService"];
if (serverConfig == null)
throw new Exception(String.Format("No section LoginService in config file"));
string loginService = serverConfig.GetString("LocalServiceModule", String.Empty);
if (loginService == string.Empty)
throw new Exception(String.Format("No LocalServiceModule for LoginService in config file"));
return loginService;
}
private void InitializeHandlers(IHttpServer server)
{
LLLoginHandlers loginHandlers = new LLLoginHandlers(m_LoginService);
server.AddXmlRPCHandler("Login_to_simulator", loginHandlers.HandleXMLRPCLogin, false);
server.SetDefaultLLSDHandler(loginHandlers.HandleLLSDLogin);
}
}
}

View File

@ -37,7 +37,7 @@ namespace OpenSim.Server.Handlers.Simulation
{
public class SimulationServiceInConnector : ServiceConnector
{
private ISimulationService m_SimulationService;
private ISimulationService m_LocalSimulationService;
private IAuthenticationService m_AuthenticationService;
public SimulationServiceInConnector(IConfigSource config, IHttpServer server, IScene scene) :
@ -54,20 +54,16 @@ namespace OpenSim.Server.Handlers.Simulation
// throw new Exception("No SimulationService in config file");
//Object[] args = new Object[] { config };
m_SimulationService = scene.RequestModuleInterface<ISimulationService>();
m_LocalSimulationService = scene.RequestModuleInterface<ISimulationService>();
//ServerUtils.LoadPlugin<ISimulationService>(simService, args);
if (m_SimulationService == null)
throw new Exception("No Local ISimulationService Module");
//System.Console.WriteLine("XXXXXXXXXXXXXXXXXXX m_AssetSetvice == null? " + ((m_AssetService == null) ? "yes" : "no"));
//server.AddStreamHandler(new AgentGetHandler(m_SimulationService, m_AuthenticationService));
//server.AddStreamHandler(new AgentPostHandler(m_SimulationService, m_AuthenticationService));
//server.AddStreamHandler(new AgentPutHandler(m_SimulationService, m_AuthenticationService));
//server.AddStreamHandler(new AgentDeleteHandler(m_SimulationService, m_AuthenticationService));
server.AddHTTPHandler("/agent/", new AgentHandler(m_SimulationService).Handler);
server.AddHTTPHandler("/object/", new ObjectHandler(m_SimulationService).Handler);
server.AddHTTPHandler("/agent/", new AgentHandler(m_LocalSimulationService).Handler);
server.AddHTTPHandler("/object/", new ObjectHandler(m_LocalSimulationService).Handler);
//server.AddStreamHandler(new ObjectPostHandler(m_SimulationService, authentication));
}

View File

@ -29,11 +29,14 @@ using System;
using System.Collections;
using System.Collections.Generic;
using OpenMetaverse.StructuredData;
namespace OpenSim.Services.Interfaces
{
public abstract class LoginResponse
{
public abstract Hashtable ToHashtable();
public abstract OSD ToOSDMap();
}
public abstract class FailedLoginResponse : LoginResponse

View File

@ -92,7 +92,7 @@ namespace OpenSim.Services.LLLoginService
return loginError;
}
public OSD ToOSDMap()
public override OSD ToOSDMap()
{
OSDMap map = new OSDMap();
@ -327,7 +327,7 @@ namespace OpenSim.Services.LLLoginService
}
}
public OSD ToLLSDResponse()
public override OSD ToOSDMap()
{
try
{

View File

@ -23,12 +23,12 @@ namespace OpenSim.Services.LLLoginService
private IInventoryService m_InventoryService;
private IGridService m_GridService;
private IPresenceService m_PresenceService;
private ISimulationService m_LocalSimulationService;
private string m_DefaultRegionName;
private string m_LocalSimulationDll;
private string m_RemoteSimulationDll;
public LLLoginService(IConfigSource config)
public LLLoginService(IConfigSource config, ISimulationService simService)
{
IConfig serverConfig = config.Configs["LoginService"];
if (serverConfig == null)
@ -41,7 +41,6 @@ namespace OpenSim.Services.LLLoginService
string presenceService = serverConfig.GetString("PresenceService", String.Empty);
m_DefaultRegionName = serverConfig.GetString("DefaultRegion", String.Empty);
m_LocalSimulationDll = serverConfig.GetString("LocalSimulationService", String.Empty);
m_RemoteSimulationDll = serverConfig.GetString("RemoteSimulationService", String.Empty);
// These 3 are required; the other 2 aren't
@ -57,11 +56,18 @@ namespace OpenSim.Services.LLLoginService
m_GridService = ServerUtils.LoadPlugin<IGridService>(gridService, args);
if (presenceService != string.Empty)
m_PresenceService = ServerUtils.LoadPlugin<IPresenceService>(presenceService, args);
m_LocalSimulationService = simService;
}
public LLLoginService(IConfigSource config) : this(config, null)
{
}
public LoginResponse Login(string firstName, string lastName, string passwd, string startLocation)
{
bool success = false;
// Get the account and check that it exists
UserAccount account = m_UserAccountService.GetUserAccount(UUID.Zero, firstName, lastName);
if (account == null)
@ -82,31 +88,46 @@ namespace OpenSim.Services.LLLoginService
UUID session = UUID.Random();
if (m_PresenceService != null)
{
bool success = m_PresenceService.LoginAgent(account.PrincipalID.ToString(), session, secureSession);
success = m_PresenceService.LoginAgent(account.PrincipalID.ToString(), session, secureSession);
if (!success)
return LLFailedLoginResponse.GridProblem;
}
// lots of things missing... need to do the simulation service
// Find the destination region/grid
string where = string.Empty;
Vector3 position = Vector3.Zero;
Vector3 lookAt = Vector3.Zero;
GridRegion destination = FindDestination(account, session, startLocation, out where, out position, out lookAt);
if (destination == null)
{
m_PresenceService.LogoutAgent(session);
return LLFailedLoginResponse.GridProblem;
}
ISimulationService sim = null;
// Instantiate/get the simulation interface and launch an agent at the destination
ISimulationService simConnector = null;
success = false;
string reason = string.Empty;
Object[] args = new Object[] { destination };
// HG standalones have both a localSimulatonDll and a remoteSimulationDll
// non-HG standalones have just a localSimulationDll
// independent login servers have just a remoteSimulationDll
if (!startLocation.Contains("@") && (m_LocalSimulationDll != string.Empty))
sim = ServerUtils.LoadPlugin<ISimulationService>(m_LocalSimulationDll, args);
else
sim = ServerUtils.LoadPlugin<ISimulationService>(m_RemoteSimulationDll, args);
if (!startLocation.Contains("@") && (m_LocalSimulationService != null))
simConnector = m_LocalSimulationService;
else if (m_RemoteSimulationDll != string.Empty)
simConnector = ServerUtils.LoadPlugin<ISimulationService>(m_RemoteSimulationDll, args);
if (simConnector != null)
success = LaunchAgent(simConnector, destination, account, session, out reason);
if (!success)
{
m_PresenceService.LogoutAgent(session);
return LLFailedLoginResponse.GridProblem;
}
return null;
// Finally, fill out the response and return it
LLLoginResponse response = new LLLoginResponse();
//....
return response;
}
private GridRegion FindDestination(UserAccount account, UUID sessionID, string startLocation, out string where, out Vector3 position, out Vector3 lookAt)
@ -228,5 +249,26 @@ namespace OpenSim.Services.LLLoginService
}
}
private bool LaunchAgent(ISimulationService simConnector, GridRegion region, UserAccount account, UUID session, out string reason)
{
reason = string.Empty;
AgentCircuitData aCircuit = new AgentCircuitData();
aCircuit.AgentID = account.PrincipalID;
//aCircuit.Appearance = optional
//aCircuit.BaseFolder = irrelevant
//aCircuit.CapsPath = required
aCircuit.child = false;
//aCircuit.circuitcode = required
aCircuit.firstname = account.FirstName;
//aCircuit.InventoryFolder = irrelevant
aCircuit.lastname = account.LastName;
//aCircuit.SecureSessionID = required
aCircuit.SessionID = session;
//aCircuit.startpos = required
return simConnector.CreateAgent(region.RegionHandle, aCircuit, 0, out reason);
}
}
}

View File

@ -646,6 +646,7 @@
<Reference name="System"/>
<Reference name="OpenMetaverseTypes.dll"/>
<Reference name="OpenMetaverse.dll"/>
<Reference name="OpenMetaverse.StructuredData.dll"/>
<Reference name="OpenSim.Framework"/>
<Reference name="OpenSim.Framework.Console"/>
<Reference name="OpenSim.Framework.Servers.HttpServer"/>