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.
integration
BlueWall 2012-03-31 17:57:58 -04:00
parent e5343bccdf
commit e8eb9b7e84
18 changed files with 277 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

@ -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
{
@ -245,7 +246,6 @@ namespace OpenSim.Server.Handlers.Presence
return encoding.GetBytes(xmlString);
}
private byte[] SuccessResult()
{
XmlDocument doc = new XmlDocument();

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,40 @@
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;
namespace OpenSim.Services.IntegrationService
{
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 };
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,40 @@
</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/"/>
<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>