From 20406498711d1f26037ae32e1b7f8378b01ad848 Mon Sep 17 00:00:00 2001
From: John Hurliman
Date: Thu, 11 Mar 2010 10:05:03 -0800
Subject: Adding the SimianGrid connectors
---
.../SimianAuthenticationServiceConnector.cs | 198 +++++++++++++++++++++
1 file changed, 198 insertions(+)
create mode 100644 OpenSim/Services/Connectors/SimianGrid/SimianAuthenticationServiceConnector.cs
(limited to 'OpenSim/Services/Connectors/SimianGrid/SimianAuthenticationServiceConnector.cs')
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianAuthenticationServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianAuthenticationServiceConnector.cs
new file mode 100644
index 0000000..ec66341
--- /dev/null
+++ b/OpenSim/Services/Connectors/SimianGrid/SimianAuthenticationServiceConnector.cs
@@ -0,0 +1,198 @@
+/*
+ * 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.Specialized;
+using System.Reflection;
+using log4net;
+using Mono.Addins;
+using Nini.Config;
+using OpenMetaverse;
+using OpenMetaverse.StructuredData;
+using OpenSim.Framework;
+using OpenSim.Region.Framework.Interfaces;
+using OpenSim.Region.Framework.Scenes;
+using OpenSim.Services.Interfaces;
+
+namespace OpenSim.Services.Connectors.SimianGrid
+{
+ ///
+ /// Connects authentication/authorization to the SimianGrid backend
+ ///
+ [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")]
+ public class SimianAuthenticationServiceConnector : IAuthenticationService, ISharedRegionModule
+ {
+ private static readonly ILog m_log =
+ LogManager.GetLogger(
+ MethodBase.GetCurrentMethod().DeclaringType);
+
+ private string m_serverUrl = String.Empty;
+
+ #region ISharedRegionModule
+
+ public Type ReplaceableInterface { get { return null; } }
+ public void RegionLoaded(Scene scene) { }
+ public void PostInitialise() { }
+ public void Close() { }
+
+ public SimianAuthenticationServiceConnector() { }
+ public string Name { get { return "SimianAuthenticationServiceConnector"; } }
+ public void AddRegion(Scene scene) { scene.RegisterModuleInterface(this); }
+ public void RemoveRegion(Scene scene) { scene.UnregisterModuleInterface(this); }
+
+ #endregion ISharedRegionModule
+
+ public SimianAuthenticationServiceConnector(IConfigSource source)
+ {
+ Initialise(source);
+ }
+
+ public void Initialise(IConfigSource source)
+ {
+ IConfig assetConfig = source.Configs["AuthenticationService"];
+ if (assetConfig == null)
+ {
+ m_log.Error("[AUTH CONNECTOR]: AuthenticationService missing from OpenSim.ini");
+ throw new Exception("Authentication connector init error");
+ }
+
+ string serviceURI = assetConfig.GetString("AuthenticationServerURI");
+ if (String.IsNullOrEmpty(serviceURI))
+ {
+ m_log.Error("[AUTH CONNECTOR]: No Server URI named in section AuthenticationService");
+ throw new Exception("Authentication connector init error");
+ }
+
+ m_serverUrl = serviceURI;
+ }
+
+ public string Authenticate(UUID principalID, string password, int lifetime)
+ {
+ NameValueCollection requestArgs = new NameValueCollection
+ {
+ { "RequestMethod", "GetIdentities" },
+ { "UserID", principalID.ToString() }
+ };
+
+ OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs);
+ if (response["Success"].AsBoolean() && response["Identities"] is OSDArray)
+ {
+ OSDArray identities = (OSDArray)response["Identities"];
+ for (int i = 0; i < identities.Count; i++)
+ {
+ OSDMap identity = identities[i] as OSDMap;
+ if (identity != null)
+ {
+ if (identity["Type"].AsString() == "md5hash")
+ {
+ string credential = identity["Credential"].AsString();
+
+ if (password == credential || Utils.MD5String(password) == credential)
+ return Authorize(principalID);
+ }
+ }
+ }
+
+ m_log.Warn("[AUTH CONNECTOR]: Authentication failed for " + principalID);
+ }
+ else
+ {
+ m_log.Warn("[AUTH CONNECTOR]: Failed to retrieve identities for " + principalID + ": " +
+ response["Message"].AsString());
+ }
+
+ return String.Empty;
+ }
+
+ public bool Verify(UUID principalID, string token, int lifetime)
+ {
+ NameValueCollection requestArgs = new NameValueCollection
+ {
+ { "RequestMethod", "GetSession" },
+ { "SessionID", token }
+ };
+
+ OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs);
+ if (response["Success"].AsBoolean())
+ {
+ return true;
+ }
+ else
+ {
+ m_log.Warn("[AUTH CONNECTOR]: Could not verify session for " + principalID + ": " +
+ response["Message"].AsString());
+ }
+
+ return false;
+ }
+
+ public bool Release(UUID principalID, string token)
+ {
+ NameValueCollection requestArgs = new NameValueCollection
+ {
+ { "RequestMethod", "RemoveSession" },
+ { "UserID", principalID.ToString() }
+ };
+
+ OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs);
+ if (response["Success"].AsBoolean())
+ {
+ return true;
+ }
+ else
+ {
+ m_log.Warn("[AUTH CONNECTOR]: Failed to remove session for " + principalID + ": " +
+ response["Message"].AsString());
+ }
+
+ return false;
+ }
+
+ public bool SetPassword(UUID principalID, string passwd)
+ {
+ // TODO: Use GetIdentities to find the md5hash identity for principalID
+ // and then update it with AddIdentity
+ m_log.Error("[AUTH CONNECTOR]: Changing passwords is not implemented yet");
+ return false;
+ }
+
+ private string Authorize(UUID userID)
+ {
+ NameValueCollection requestArgs = new NameValueCollection
+ {
+ { "RequestMethod", "AddSession" },
+ { "UserID", userID.ToString() }
+ };
+
+ OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs);
+ if (response["Success"].AsBoolean())
+ return response["SessionID"].AsUUID().ToString();
+ else
+ return String.Empty;
+ }
+ }
+}
--
cgit v1.1
From aad17e751383069b799c6a78a3ac4e0ca1020a4d Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Fri, 12 Mar 2010 20:29:17 +0000
Subject: Simplify database setup and remove migration problems by moving all
sqlite config-include settings to a separate file for standalone Update
information in StandaloneCommon.ini.example to reflect this Remove
ISharedRegionModule interfaces from all SimianGrid connector classes
temporarily since this stopped standalone from working (due to absence of
AssetURI settings, etc.). Solution here may be to create separate region
module connectors as done by local/grid/hypergrid so that loading can be
controlled via include files Or otherwise work out how to stop these modules
from being loaded for all OpenSim invocations
---
.../Connectors/SimianGrid/SimianAuthenticationServiceConnector.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'OpenSim/Services/Connectors/SimianGrid/SimianAuthenticationServiceConnector.cs')
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianAuthenticationServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianAuthenticationServiceConnector.cs
index ec66341..25e04d7 100644
--- a/OpenSim/Services/Connectors/SimianGrid/SimianAuthenticationServiceConnector.cs
+++ b/OpenSim/Services/Connectors/SimianGrid/SimianAuthenticationServiceConnector.cs
@@ -44,7 +44,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
/// Connects authentication/authorization to the SimianGrid backend
///
[Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")]
- public class SimianAuthenticationServiceConnector : IAuthenticationService, ISharedRegionModule
+ public class SimianAuthenticationServiceConnector : IAuthenticationService
{
private static readonly ILog m_log =
LogManager.GetLogger(
--
cgit v1.1
From 0b5141d45bcd409544e909aedabc3e58e6a86a13 Mon Sep 17 00:00:00 2001
From: John Hurliman
Date: Fri, 12 Mar 2010 13:16:44 -0800
Subject: Fixed SimianGrid connectors to gracefully exit if the required config
sections are missing
---
.../SimianGrid/SimianAuthenticationServiceConnector.cs | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
(limited to 'OpenSim/Services/Connectors/SimianGrid/SimianAuthenticationServiceConnector.cs')
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianAuthenticationServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianAuthenticationServiceConnector.cs
index 25e04d7..55aca36 100644
--- a/OpenSim/Services/Connectors/SimianGrid/SimianAuthenticationServiceConnector.cs
+++ b/OpenSim/Services/Connectors/SimianGrid/SimianAuthenticationServiceConnector.cs
@@ -44,7 +44,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
/// Connects authentication/authorization to the SimianGrid backend
///
[Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")]
- public class SimianAuthenticationServiceConnector : IAuthenticationService
+ public class SimianAuthenticationServiceConnector : IAuthenticationService, ISharedRegionModule
{
private static readonly ILog m_log =
LogManager.GetLogger(
@@ -61,8 +61,8 @@ namespace OpenSim.Services.Connectors.SimianGrid
public SimianAuthenticationServiceConnector() { }
public string Name { get { return "SimianAuthenticationServiceConnector"; } }
- public void AddRegion(Scene scene) { scene.RegisterModuleInterface(this); }
- public void RemoveRegion(Scene scene) { scene.UnregisterModuleInterface(this); }
+ public void AddRegion(Scene scene) { if (!String.IsNullOrEmpty(m_serverUrl)) { scene.RegisterModuleInterface(this); } }
+ public void RemoveRegion(Scene scene) { if (!String.IsNullOrEmpty(m_serverUrl)) { scene.UnregisterModuleInterface(this); } }
#endregion ISharedRegionModule
@@ -76,8 +76,8 @@ namespace OpenSim.Services.Connectors.SimianGrid
IConfig assetConfig = source.Configs["AuthenticationService"];
if (assetConfig == null)
{
- m_log.Error("[AUTH CONNECTOR]: AuthenticationService missing from OpenSim.ini");
- throw new Exception("Authentication connector init error");
+ m_log.Info("[AUTH CONNECTOR]: AuthenticationService missing from OpenSim.ini, skipping SimianAuthenticationServiceConnector");
+ return;
}
string serviceURI = assetConfig.GetString("AuthenticationServerURI");
--
cgit v1.1
From 9e3cdc4da5483ce0187c7774fa274e99845da232 Mon Sep 17 00:00:00 2001
From: John Hurliman
Date: Fri, 12 Mar 2010 13:28:16 -0800
Subject: Fixing the previous patch to work correctly with standalone mode
---
.../Connectors/SimianGrid/SimianAuthenticationServiceConnector.cs | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
(limited to 'OpenSim/Services/Connectors/SimianGrid/SimianAuthenticationServiceConnector.cs')
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianAuthenticationServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianAuthenticationServiceConnector.cs
index 55aca36..0876efb 100644
--- a/OpenSim/Services/Connectors/SimianGrid/SimianAuthenticationServiceConnector.cs
+++ b/OpenSim/Services/Connectors/SimianGrid/SimianAuthenticationServiceConnector.cs
@@ -76,15 +76,15 @@ namespace OpenSim.Services.Connectors.SimianGrid
IConfig assetConfig = source.Configs["AuthenticationService"];
if (assetConfig == null)
{
- m_log.Info("[AUTH CONNECTOR]: AuthenticationService missing from OpenSim.ini, skipping SimianAuthenticationServiceConnector");
- return;
+ m_log.Error("[AUTH CONNECTOR]: AuthenticationService missing from OpenSim.ini");
+ throw new Exception("Authentication connector init error");
}
string serviceURI = assetConfig.GetString("AuthenticationServerURI");
if (String.IsNullOrEmpty(serviceURI))
{
- m_log.Error("[AUTH CONNECTOR]: No Server URI named in section AuthenticationService");
- throw new Exception("Authentication connector init error");
+ m_log.Info("[AUTH CONNECTOR]: No Server URI named in section AuthenticationService, skipping SimianAuthenticationServiceConnector");
+ return;
}
m_serverUrl = serviceURI;
--
cgit v1.1
From 3036aba875187923b4e4d8481d46334e53393107 Mon Sep 17 00:00:00 2001
From: John Hurliman
Date: Fri, 12 Mar 2010 14:28:31 -0800
Subject: * Added a better check to the SimianGrid connectors to test if they
are enabled or not. This method should work equally well with standalone or
robust mode * Applying #4602 from Misterblu to add collision detection to
BulletDotNET
---
.../SimianAuthenticationServiceConnector.cs | 27 ++++++++++++----------
1 file changed, 15 insertions(+), 12 deletions(-)
(limited to 'OpenSim/Services/Connectors/SimianGrid/SimianAuthenticationServiceConnector.cs')
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianAuthenticationServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianAuthenticationServiceConnector.cs
index 0876efb..6317b87 100644
--- a/OpenSim/Services/Connectors/SimianGrid/SimianAuthenticationServiceConnector.cs
+++ b/OpenSim/Services/Connectors/SimianGrid/SimianAuthenticationServiceConnector.cs
@@ -73,21 +73,24 @@ namespace OpenSim.Services.Connectors.SimianGrid
public void Initialise(IConfigSource source)
{
- IConfig assetConfig = source.Configs["AuthenticationService"];
- if (assetConfig == null)
+ if (Simian.IsSimianEnabled(source, "AuthenticationServices"))
{
- m_log.Error("[AUTH CONNECTOR]: AuthenticationService missing from OpenSim.ini");
- throw new Exception("Authentication connector init error");
- }
+ IConfig assetConfig = source.Configs["AuthenticationService"];
+ if (assetConfig == null)
+ {
+ m_log.Error("[AUTH CONNECTOR]: AuthenticationService missing from OpenSim.ini");
+ throw new Exception("Authentication connector init error");
+ }
- string serviceURI = assetConfig.GetString("AuthenticationServerURI");
- if (String.IsNullOrEmpty(serviceURI))
- {
- m_log.Info("[AUTH CONNECTOR]: No Server URI named in section AuthenticationService, skipping SimianAuthenticationServiceConnector");
- return;
- }
+ string serviceURI = assetConfig.GetString("AuthenticationServerURI");
+ if (String.IsNullOrEmpty(serviceURI))
+ {
+ m_log.Error("[AUTH CONNECTOR]: No Server URI named in section AuthenticationService");
+ throw new Exception("Authentication connector init error");
+ }
- m_serverUrl = serviceURI;
+ m_serverUrl = serviceURI;
+ }
}
public string Authenticate(UUID principalID, string password, int lifetime)
--
cgit v1.1