Compare commits

...

4 Commits

Author SHA1 Message Date
BlueWall
445caca18b Merge branch 'master' of /home/opensim/var/repo/opensim 2012-04-01 11:10:21 -04:00
BlueWall
4b90dcfb73 Missed these files 2012-04-01 11:05:05 -04:00
BlueWall
ade1acc9d4 Making IntegrationService pluggable
First steps to making a pluggable IntegrationService.
2012-04-01 09:38:59 -04:00
BlueWall
e8eb9b7e84 Add Integration Service
Adding an integration service to provide base services at endpoints for external application integration. So far, landtool.php is converted to use the IntegrationService. Others will follow to provide coverage for the base helperuri applications needed in OpenSim.
2012-03-31 17:57:58 -04:00
20 changed files with 460 additions and 3 deletions

View File

@@ -49,6 +49,7 @@ namespace OpenSim.Data
bool Store(PresenceData data);
PresenceData Get(UUID sessionID);
PresenceData Verify(UUID s_sessionID);
void LogoutRegionAgents(UUID regionID);
bool ReportAgent(UUID sessionID, UUID regionID);
PresenceData[] Get(string field, string data);

View File

@@ -61,6 +61,17 @@ namespace OpenSim.Data.MSSQL
return ret[0];
}
public PresenceData Verify(UUID s_sessionID)
{
PresenceData[] ret = Get("SecureSessionID",
s_sessionID.ToString());
if (ret.Length == 0)
return null;
return ret[0];
}
public void LogoutRegionAgents(UUID regionID)
{
using (SqlConnection conn = new SqlConnection(m_ConnectionString))

View File

@@ -61,6 +61,17 @@ namespace OpenSim.Data.MySQL
return ret[0];
}
public PresenceData Verify(UUID s_sessionID)
{
PresenceData[] ret = Get("SecureSessionID",
s_sessionID.ToString());
if (ret.Length == 0)
return null;
return ret[0];
}
public void LogoutRegionAgents(UUID regionID)
{
MySqlCommand cmd = new MySqlCommand();

View File

@@ -79,6 +79,19 @@ namespace OpenSim.Data.Null
return null;
}
public PresenceData Verify(UUID s_sessionID)
{
if (Instance != this)
return Instance.Verify(s_sessionID);
if (m_presenceData.ContainsKey(s_sessionID))
{
return m_presenceData[s_sessionID];
}
return null;
}
public void LogoutRegionAgents(UUID regionID)
{
if (Instance != this)

View File

@@ -193,6 +193,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence
return m_PresenceService.GetAgents(userIDs);
}
public PresenceInfo VerifyAgent(UUID s_sessionID)
{
return m_PresenceService.VerifyAgent(s_sessionID);
}
#endregion
}

View File

@@ -153,6 +153,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence
return m_RemoteConnector.GetAgents(userIDs);
}
public PresenceInfo VerifyAgent(UUID sessionID)
{
return m_RemoteConnector.VerifyAgent(sessionID);
}
#endregion
}

View File

@@ -35,6 +35,7 @@ using System.Collections.Generic;
using log4net;
using OpenSim.Framework;
using OpenMetaverse;
using OpenMetaverse.StructuredData;
namespace OpenSim.Server.Base
{
@@ -330,5 +331,36 @@ namespace OpenSim.Server.Base
return ret;
}
public static bool ParseStringToOSDMap(string input, out OSDMap map)
{
try
{
map = null;
OSD tmpbuff = null;
try
{
tmpbuff = OSDParser.DeserializeJson(input);
}
catch
{
m_log.DebugFormat("[ServerUtils]: Parse Caught Error Deserializei {0} ", input);
return false;
}
if (tmpbuff.Type == OSDType.Map)
{
map = (OSDMap)tmpbuff;
return true;
}
else
return false;
}
catch (NullReferenceException e)
{
m_log.ErrorFormat("[ServerUtils]: exception on ParseStringToJson {0}", e.Message);
map = null;
return false;
}
}
}
}

View File

@@ -0,0 +1,39 @@
using System;
using Nini.Config;
using OpenSim.Server.Base;
using OpenSim.Services.Interfaces;
using OpenSim.Framework.Servers.HttpServer;
using OpenSim.Server.Handlers.Base;
using OpenSim.Framework;
namespace OpenSim.Server.Handlers.Integration
{
public class IntegrationServiceConnector : ServiceConnector
{
private IIntegrationService m_IntegrationService;
private string m_ConfigName = "IntegrationService";
public IntegrationServiceConnector(IConfigSource config, IHttpServer server, string configName) :
base(config, server, configName)
{
IConfig serverConfig = config.Configs[m_ConfigName];
if (serverConfig == null)
throw new Exception(String.Format("No section {0} in config file", m_ConfigName));
string service = serverConfig.GetString("LocalServiceModule",
String.Empty);
if (service == String.Empty)
throw new Exception("No LocalServiceModule in config file");
Object[] args = new Object[] { config };
m_IntegrationService = ServerUtils.LoadPlugin<IIntegrationService>(service, args);
server.AddStreamHandler(new IntegrationServerHandler(m_IntegrationService));
}
}
}

View File

@@ -0,0 +1,127 @@
using OpenSim.Server.Base;
using OpenSim.Services.Interfaces;
using OpenSim.Framework;
using OpenSim.Framework.Servers.HttpServer;
using OpenMetaverse;
using OpenMetaverse.StructuredData;
using log4net;
using System;
using System.Reflection;
using System.IO;
using System.Net;
using System.Text;
using System.Text.RegularExpressions;
using System.Collections;
using System.Collections.Generic;
namespace OpenSim.Server.Handlers.Integration
{
public class IntegrationServerHandler : BaseStreamHandler
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private IIntegrationService m_IntegrationService;
public IntegrationServerHandler(IIntegrationService service) :
base("POST", "/integration")
{
m_IntegrationService = service;
}
public override byte[] Handle(string path, Stream requestData, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
{
StreamReader sr = new StreamReader(requestData);
string body = sr.ReadToEnd();
sr.Close();
body = body.Trim();
try
{
OSDMap request = null;
if (ServerUtils.ParseStringToOSDMap(body, out request) == false)
return FailureResult();
// Dictionary<string, object> request = ServerUtils.ParseQueryString(body);
if (!request.ContainsKey("command"))
return FailureResult("Error, no command defined!");
string command = request["command"].AsString();
// command...
switch (command)
{
// agent
case "verify_agent_ssession":
return HandleVerifyAgentSession(request);
case "verify_agent_region":
return FailureResult("Not Implemented");
default:
m_log.DebugFormat("[IntegrationHandler]: unknown method {0} request {1}", command.Length, command);
return FailureResult("IntegrationHandler: Unrecognized method requested!");
}
}
catch (Exception e)
{
m_log.DebugFormat("[IntegrationHandler]: Exception {0}", e);
}
return FailureResult();
}
#region Handlers
/// <summary>
/// Verifies the agent to external applications.
/// </summary>
/// <returns>
/// UUID of the agent.
/// </returns>
/// <param name='request'>
/// request - Send SecureSessionID and optionally Encoding=xml for xml Output
/// </param>
byte[] HandleVerifyAgentSession(OSDMap request)
{
UUID s_session = UUID.Zero;
if (!request.ContainsKey("SecureSessionID"))
return FailureResult();
if (!UUID.TryParse(request["SecureSessionID"].AsString(), out s_session))
return FailureResult();
PresenceInfo pinfo = m_IntegrationService.VerifyAgent(s_session);
OSDMap result = new OSDMap();
if (pinfo == null)
result["agent_id"] = OSD.FromUUID(UUID.Zero);
else
result["agent_id"] = OSD.FromString(pinfo.UserID.ToString());
return Encoding.UTF8.GetBytes(OSDParser.SerializeJsonString(result));
}
#endregion Handlers
#region utility
private byte[] FailureResult()
{
return FailureResult(String.Empty);
}
private byte[] FailureResult(string msg)
{
OSDMap doc = new OSDMap(2);
doc["Result"] = OSD.FromString("Failure");
doc["Message"] = OSD.FromString(msg);
return DocToBytes(doc);
}
private byte[] DocToBytes(OSDMap doc)
{
return Encoding.UTF8.GetBytes(OSDParser.SerializeJsonString(doc));
}
#endregion utility
}
}

View File

@@ -41,6 +41,7 @@ using OpenSim.Services.Interfaces;
using OpenSim.Framework;
using OpenSim.Framework.Servers.HttpServer;
using OpenMetaverse;
using OpenMetaverse.StructuredData;
namespace OpenSim.Server.Handlers.Presence
{
@@ -244,7 +245,6 @@ namespace OpenSim.Server.Handlers.Presence
UTF8Encoding encoding = new UTF8Encoding();
return encoding.GetBytes(xmlString);
}
private byte[] SuccessResult()
{

View File

@@ -371,6 +371,49 @@ namespace OpenSim.Services.Connectors
return rinfos.ToArray();
}
public PresenceInfo VerifyAgent(UUID s_sessionID)
{
Dictionary<string, object> sendData = new Dictionary<string, object>();
//sendData["SCOPEID"] = scopeID.ToString();
sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString();
sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString();
sendData["METHOD"] = "verifyagent";
sendData["SecureSessionID"] = s_sessionID.ToString();
string reply = string.Empty;
string reqString = ServerUtils.BuildQueryString(sendData);
string uri = m_ServerURI + "/presence";
// m_log.DebugFormat("[PRESENCE CONNECTOR]: queryString = {0}", reqString);
try
{
reply = SynchronousRestFormsRequester.MakeRequest("POST",
uri,
reqString);
if (reply == null || (reply != null && reply == string.Empty))
{
m_log.DebugFormat("[PRESENCE CONNECTOR]: VerifyAgent received null or empty reply");
return null;
}
}
catch (Exception e)
{
m_log.DebugFormat("[PRESENCE CONNECTOR]: Exception when contacting presence server at {0}: {1}", uri, e.Message);
}
Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
PresenceInfo pinfo = null;
if ((replyData != null) && replyData.ContainsKey("result") && (replyData["result"] != null))
{
if (replyData["result"] is Dictionary<string, object>)
{
pinfo = new PresenceInfo((Dictionary<string, object>)replyData["result"]);
}
}
return pinfo;
}
#endregion

View File

@@ -260,6 +260,12 @@ namespace OpenSim.Services.Connectors.SimianGrid
return null;
}
public PresenceInfo VerifyAgent(UUID s_sessionID)
{
// Not implemented
return null;
}
public bool LoggedOut(string userID, UUID sessionID, UUID regionID, Vector3 lastPosition, Vector3 lastLookAt)
{
// m_log.DebugFormat("[SIMIAN PRESENCE CONNECTOR]: Logging out user " + userID);

View File

@@ -0,0 +1,29 @@
using OpenSim.Server.Base;
using OpenSim.Services.Interfaces;
using OpenSim.Framework;
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
using OpenMetaverse;
using Nini.Config;
namespace OpenSim.Services.IntegrationService
{
public class IntegrationService : IntegrationServiceBase, IIntegrationService
{
public IntegrationService(IConfigSource config)
: base(config)
{
}
#region IIntegrationService implementation
public PresenceInfo VerifyAgent(UUID SecureSessionID)
{
return m_PresenceService.VerifyAgent(SecureSessionID);
}
#endregion
}
}

View File

@@ -0,0 +1,56 @@
using System;
using OpenSim.Services.Interfaces;
using OpenSim.Services.Base;
using System.Reflection;
using Nini.Config;
using OpenSim.Framework;
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
using Mono.Addins;
[assembly:AddinRoot ("IntegrationService", "1.0")]
namespace OpenSim.Services.IntegrationService
{
[TypeExtensionPoint (Path="/OpenSim/IntegrationService", Name="IntegrationService")]
public interface IntegrationPlugin
{
void run();
}
public class IntegrationServiceBase : ServiceBase
{
protected IPresenceService m_PresenceService;
protected IGridService m_GridService;
IConfig m_IntegrationServerConfig;
public IntegrationServiceBase(IConfigSource config)
: base(config)
{
Object[] args = new Object[] { config };
AddinManager.Initialize (".");
AddinManager.Registry.Update ();
foreach (IntegrationPlugin cmd in AddinManager.GetExtensionObjects("/OpenSim/IntegrationService"))
cmd.run ();
m_IntegrationServerConfig = config.Configs["IntegrationService"];
if (m_IntegrationServerConfig == null)
{
throw new Exception("[IntegrationService]: Missing configuration");
return;
}
string gridService = m_IntegrationServerConfig.GetString("GridService", String.Empty);
string presenceService = m_IntegrationServerConfig.GetString("PresenceService", String.Empty);
if (gridService != string.Empty)
m_GridService = LoadPlugin<IGridService>(gridService, args);
if (presenceService != string.Empty)
m_PresenceService = LoadPlugin<IPresenceService>(presenceService, args);
}
}
}

View File

@@ -0,0 +1,15 @@
using System;
using System.Collections;
using System.Collections.Generic;
using OpenMetaverse;
using OpenMetaverse.StructuredData;
using OpenSim.Framework;
namespace OpenSim.Services.Interfaces
{
public interface IIntegrationService
{
PresenceInfo VerifyAgent(UUID SecretSessionID);
}
}

View File

@@ -68,6 +68,7 @@ namespace OpenSim.Services.Interfaces
bool ReportAgent(UUID sessionID, UUID regionID);
PresenceInfo GetAgent(UUID sessionID);
PresenceInfo VerifyAgent(UUID s_sessionID);
PresenceInfo[] GetAgents(string[] userIDs);
}
}

View File

@@ -158,5 +158,19 @@ namespace OpenSim.Services.PresenceService
return info.ToArray();
}
public PresenceInfo VerifyAgent(UUID s_sessionID)
{
PresenceInfo ret = new PresenceInfo();
PresenceData data = m_Database.Verify(s_sessionID);
if (data == null)
return null;
ret.UserID = data.UserID;
ret.RegionID = data.RegionID;
return ret;
}
}
}

View File

@@ -21,7 +21,7 @@
; * [[<ConfigName>@]<port>/]<dll name>[:<class name>]
; *
[Startup]
ServiceConnectors = "8003/OpenSim.Server.Handlers.dll:AssetServiceConnector,8003/OpenSim.Server.Handlers.dll:XInventoryInConnector,8004/OpenSim.Server.Handlers.dll:FreeswitchServerConnector,8003/OpenSim.Server.Handlers.dll:GridServiceConnector,8002/OpenSim.Server.Handlers.dll:GridInfoServerInConnector,8003/OpenSim.Server.Handlers.dll:AuthenticationServiceConnector,8002/OpenSim.Server.Handlers.dll:OpenIdServerConnector,8003/OpenSim.Server.Handlers.dll:AvatarServiceConnector,8002/OpenSim.Server.Handlers.dll:LLLoginServiceInConnector,8003/OpenSim.Server.Handlers.dll:PresenceServiceConnector,8003/OpenSim.Server.Handlers.dll:UserAccountServiceConnector,8003/OpenSim.Server.Handlers.dll:GridUserServiceConnector,8003/OpenSim.Server.Handlers.dll:FriendsServiceConnector,8002/OpenSim.Server.Handlers.dll:GatekeeperServiceInConnector,8002/OpenSim.Server.Handlers.dll:UserAgentServerConnector,HGInventoryService@8002/OpenSim.Server.Handlers.dll:XInventoryInConnector,HGAssetService@8002/OpenSim.Server.Handlers.dll:AssetServiceConnector,8002/OpenSim.Server.Handlers.dll:HeloServiceInConnector,8002/OpenSim.Server.Handlers.dll:HGFriendsServerConnector,8002/OpenSim.Server.Handlers.dll:InstantMessageServerConnector,8003/OpenSim.Server.Handlers.dll:MapAddServiceConnector,8002/OpenSim.Server.Handlers.dll:MapGetServiceConnector"
ServiceConnectors = "8003/OpenSim.Server.Handlers.dll:AssetServiceConnector,8003/OpenSim.Server.Handlers.dll:XInventoryInConnector,8004/OpenSim.Server.Handlers.dll:FreeswitchServerConnector,8003/OpenSim.Server.Handlers.dll:GridServiceConnector,8002/OpenSim.Server.Handlers.dll:GridInfoServerInConnector,8003/OpenSim.Server.Handlers.dll:AuthenticationServiceConnector,8002/OpenSim.Server.Handlers.dll:OpenIdServerConnector,8003/OpenSim.Server.Handlers.dll:AvatarServiceConnector,8002/OpenSim.Server.Handlers.dll:LLLoginServiceInConnector,8003/OpenSim.Server.Handlers.dll:PresenceServiceConnector,8003/OpenSim.Server.Handlers.dll:UserAccountServiceConnector,8003/OpenSim.Server.Handlers.dll:GridUserServiceConnector,8003/OpenSim.Server.Handlers.dll:FriendsServiceConnector,8002/OpenSim.Server.Handlers.dll:GatekeeperServiceInConnector,8002/OpenSim.Server.Handlers.dll:UserAgentServerConnector,HGInventoryService@8002/OpenSim.Server.Handlers.dll:XInventoryInConnector,HGAssetService@8002/OpenSim.Server.Handlers.dll:AssetServiceConnector,8002/OpenSim.Server.Handlers.dll:HeloServiceInConnector,8002/OpenSim.Server.Handlers.dll:HGFriendsServerConnector,8002/OpenSim.Server.Handlers.dll:InstantMessageServerConnector,8003/OpenSim.Server.Handlers.dll:MapAddServiceConnector,8002/OpenSim.Server.Handlers.dll:MapGetServiceConnector,8002/OpenSim.Server.Handlers:IntegrationServiceConnector"
; * This is common for all services, it's the network setup for the entire
; * server instance, if none is specified above
@@ -426,3 +426,9 @@ ServiceConnectors = "8003/OpenSim.Server.Handlers.dll:AssetServiceConnector,8003
;; This applies to the core groups module (Flotsam) only.
; ForwardOfflineGroupMessages = true
[IntegrationService]
LocalServiceModule = "OpenSim.Services.IntegrationService.dll:IntegrationService"
GridService = "OpenSim.Services.GridService.dll:GridService"
PresenceService = "OpenSim.Services.PresenceService.dll:PresenceService"

View File

@@ -13,7 +13,7 @@
; * [[<ConfigName>@]<port>/]<dll name>[:<class name>]
; *
[Startup]
ServiceConnectors = "8003/OpenSim.Server.Handlers.dll:AssetServiceConnector,8003/OpenSim.Server.Handlers.dll:XInventoryInConnector,8004/OpenSim.Server.Handlers.dll:FreeswitchServerConnector,8003/OpenSim.Server.Handlers.dll:GridServiceConnector,8002/OpenSim.Server.Handlers.dll:GridInfoServerInConnector,8003/OpenSim.Server.Handlers.dll:AuthenticationServiceConnector,8002/OpenSim.Server.Handlers.dll:OpenIdServerConnector,8003/OpenSim.Server.Handlers.dll:AvatarServiceConnector,8002/OpenSim.Server.Handlers.dll:LLLoginServiceInConnector,8003/OpenSim.Server.Handlers.dll:PresenceServiceConnector,8003/OpenSim.Server.Handlers.dll:UserAccountServiceConnector,8003/OpenSim.Server.Handlers.dll:GridUserServiceConnector,8003/OpenSim.Server.Handlers.dll:FriendsServiceConnector,8003/OpenSim.Server.Handlers.dll:MapAddServiceConnector,8002/OpenSim.Server.Handlers.dll:MapGetServiceConnector"
ServiceConnectors = "8003/OpenSim.Server.Handlers.dll:AssetServiceConnector,8003/OpenSim.Server.Handlers.dll:XInventoryInConnector,8004/OpenSim.Server.Handlers.dll:FreeswitchServerConnector,8003/OpenSim.Server.Handlers.dll:GridServiceConnector,8002/OpenSim.Server.Handlers.dll:GridInfoServerInConnector,8003/OpenSim.Server.Handlers.dll:AuthenticationServiceConnector,8002/OpenSim.Server.Handlers.dll:OpenIdServerConnector,8003/OpenSim.Server.Handlers.dll:AvatarServiceConnector,8002/OpenSim.Server.Handlers.dll:LLLoginServiceInConnector,8003/OpenSim.Server.Handlers.dll:PresenceServiceConnector,8003/OpenSim.Server.Handlers.dll:UserAccountServiceConnector,8003/OpenSim.Server.Handlers.dll:GridUserServiceConnector,8003/OpenSim.Server.Handlers.dll:FriendsServiceConnector,8003/OpenSim.Server.Handlers.dll:MapAddServiceConnector,8002/OpenSim.Server.Handlers.dll:MapGetServiceConnector,8002/OpenSim.Server.Handlers:IntegrationServiceConnector"
; * This is common for all services, it's the network setup for the entire
; * server instance, if none is specified above
@@ -294,3 +294,10 @@ ServiceConnectors = "8003/OpenSim.Server.Handlers.dll:AssetServiceConnector,8003
; password help: optional: page providing password assistance for users of your grid
;password = http://127.0.0.1/password
[IntegrationService]
LocalServiceModule = "OpenSim.Services.IntegrationService.dll:IntegrationService"
GridService = "OpenSim.Services.GridService.dll:GridService"
PresenceService = "OpenSim.Services.PresenceService.dll:PresenceService"

View File

@@ -787,6 +787,7 @@
<Reference name="System.Xml"/>
<Reference name="System.Web"/>
<Reference name="OpenMetaverseTypes" path="../../../bin/"/>
<Reference name="OpenMetaverse.StructuredData" path="../../../bin/"/>
<Reference name="OpenMetaverse" path="../../../bin/"/>
<Reference name="OpenSim.Framework"/>
<Reference name="OpenSim.Framework.Console"/>
@@ -1150,6 +1151,41 @@
</Files>
</Project>
<Project frameworkVersion="v3_5" name="OpenSim.Services.IntegrationService" path="OpenSim/Services/IntegrationService" type="Library">
<Configuration name="Debug">
<Options>
<OutputPath>../../../bin/</OutputPath>
</Options>
</Configuration>
<Configuration name="Release">
<Options>
<OutputPath>../../../bin/</OutputPath>
</Options>
</Configuration>
<ReferencePath>../../../bin/</ReferencePath>
<Reference name="System"/>
<Reference name="System.Core"/>
<Reference name="System.Xml"/>
<Reference name="OpenMetaverseTypes" path="../../../bin/"/>
<Reference name="OpenMetaverse" path="../../../bin/"/>
<Reference name="OpenSim.Framework"/>
<Reference name="OpenSim.Framework.Console"/>
<Reference name="OpenSim.Framework.Servers.HttpServer"/>
<Reference name="OpenSim.Services.Interfaces"/>
<Reference name="OpenSim.Services.Base"/>
<Reference name="OpenSim.Services.Connectors"/>
<Reference name="OpenSim.Data"/>
<Reference name="OpenSim.Server.Base"/>
<Reference name="Nini" path="../../../bin/"/>
<Reference name="log4net" path="../../../bin/"/>
<Reference name="Mono.Addins" path="../../../bin/"/>
<Files>
<Match pattern="*.cs" recurse="true"/>
</Files>
</Project>
<Project frameworkVersion="v3_5" name="OpenSim.Services.InventoryService" path="OpenSim/Services/InventoryService" type="Library">
<Configuration name="Debug">
<Options>