More work on new authentication service
parent
e39d0ef627
commit
c9a24ece54
|
@ -38,7 +38,7 @@ namespace OpenSim.Data.MySQL
|
|||
public class MySqlAuthenticationData : MySqlFramework, IAuthenticationData
|
||||
{
|
||||
private string m_Realm;
|
||||
private DataTable m_SchemaTable = null;
|
||||
private List<string> m_ColumnNames = null;
|
||||
|
||||
public MySqlAuthenticationData(string connectionString, string realm)
|
||||
: base(connectionString)
|
||||
|
@ -63,15 +63,21 @@ namespace OpenSim.Data.MySQL
|
|||
{
|
||||
ret.PrincipalID = principalID;
|
||||
|
||||
if (m_SchemaTable == null)
|
||||
m_SchemaTable = result.GetSchemaTable();
|
||||
|
||||
foreach (DataColumn c in m_SchemaTable.Columns)
|
||||
if (m_ColumnNames == null)
|
||||
{
|
||||
if (c.ColumnName == "UUID")
|
||||
m_ColumnNames = new List<string>();
|
||||
|
||||
DataTable schemaTable = result.GetSchemaTable();
|
||||
foreach (DataRow row in schemaTable.Rows)
|
||||
m_ColumnNames.Add(row["ColumnName"].ToString());
|
||||
}
|
||||
|
||||
foreach (string s in m_ColumnNames)
|
||||
{
|
||||
if (s == "UUID")
|
||||
continue;
|
||||
|
||||
ret.Data[c.ColumnName] = result[c.ColumnName].ToString();
|
||||
ret.Data[s] = result[s].ToString();
|
||||
}
|
||||
|
||||
result.Close();
|
||||
|
@ -105,21 +111,23 @@ namespace OpenSim.Data.MySQL
|
|||
|
||||
first = false;
|
||||
|
||||
cmd.Parameters.AddWithValue(field, data.Data[field]);
|
||||
cmd.Parameters.AddWithValue("?"+field, data.Data[field]);
|
||||
}
|
||||
|
||||
update += " where UUID = ?principalID";
|
||||
|
||||
cmd.CommandText = update;
|
||||
cmd.Parameters.AddWithValue("UUID", data.PrincipalID.ToString());
|
||||
cmd.Parameters.AddWithValue("?principalID", data.PrincipalID.ToString());
|
||||
|
||||
if (ExecuteNonQuery(cmd) < 1)
|
||||
{
|
||||
string insert = "insert into `" + m_Realm + "` (`UUID`, `" +
|
||||
String.Join("`, `", fields) +
|
||||
"`) values ( ?UUID, ?" + String.Join(", ?", fields) + ")";
|
||||
"`) values ( ?principalID, ?" + String.Join(", ?", fields) + ")";
|
||||
|
||||
if (ExecuteNonQuery(cmd) < 0)
|
||||
cmd.CommandText = insert;
|
||||
|
||||
if (ExecuteNonQuery(cmd) < 1)
|
||||
{
|
||||
cmd.Dispose();
|
||||
return false;
|
||||
|
@ -137,8 +145,11 @@ namespace OpenSim.Data.MySQL
|
|||
"` set `" + item + "` = ?" + item + " where UUID = ?UUID");
|
||||
|
||||
|
||||
cmd.Parameters.AddWithValue(item, value);
|
||||
cmd.Parameters.AddWithValue("UUID", principalID.ToString());
|
||||
cmd.Parameters.AddWithValue("?"+item, value);
|
||||
cmd.Parameters.AddWithValue("?UUID", principalID.ToString());
|
||||
|
||||
if (ExecuteNonQuery(cmd) > 0)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -70,6 +70,7 @@ namespace OpenSim.Data.MySQL
|
|||
}
|
||||
catch (MySqlException e)
|
||||
{
|
||||
Console.WriteLine(e.ToString());
|
||||
if (errorSeen)
|
||||
throw;
|
||||
|
||||
|
@ -88,6 +89,13 @@ namespace OpenSim.Data.MySQL
|
|||
|
||||
cmd.Connection = m_Connection;
|
||||
}
|
||||
else
|
||||
throw;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine(e.ToString());
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ namespace OpenSim.Server.Handlers.Authentication
|
|||
{
|
||||
public class AuthenticationServiceConnector : ServiceConnector
|
||||
{
|
||||
//private IAuthenticationService m_AuthenticationService;
|
||||
private IAuthenticationService m_AuthenticationService;
|
||||
|
||||
public AuthenticationServiceConnector(IConfigSource config, IHttpServer server) :
|
||||
base(config, server)
|
||||
|
@ -51,8 +51,8 @@ namespace OpenSim.Server.Handlers.Authentication
|
|||
if (authenticationService == String.Empty)
|
||||
throw new Exception("No AuthenticationService in config file");
|
||||
|
||||
//Object[] args = new Object[] { config };
|
||||
//m_AuthenticationService = ServerUtils.LoadPlugin<IAuthenticationService>(authenticationService, args);
|
||||
Object[] args = new Object[] { config };
|
||||
m_AuthenticationService = ServerUtils.LoadPlugin<IAuthenticationService>(authenticationService, args);
|
||||
|
||||
//server.AddStreamHandler(new AuthenticationServerGetHandler(m_AuthenticationService));
|
||||
}
|
||||
|
|
|
@ -53,6 +53,7 @@ namespace OpenSim.Services.AuthenticationService
|
|||
{
|
||||
string dllName = String.Empty;
|
||||
string connString = String.Empty;
|
||||
string realm = String.Empty;
|
||||
|
||||
//
|
||||
// Try reading the [AuthenticationService] section first, if it exists
|
||||
|
@ -62,6 +63,7 @@ namespace OpenSim.Services.AuthenticationService
|
|||
{
|
||||
dllName = authConfig.GetString("StorageProvider", dllName);
|
||||
connString = authConfig.GetString("ConnectionString", connString);
|
||||
realm = authConfig.GetString("Realm", realm);
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -79,11 +81,11 @@ namespace OpenSim.Services.AuthenticationService
|
|||
//
|
||||
// We tried, but this doesn't exist. We can't proceed.
|
||||
//
|
||||
if (dllName.Equals(String.Empty))
|
||||
if (dllName == String.Empty || realm == String.Empty)
|
||||
throw new Exception("No StorageProvider configured");
|
||||
|
||||
m_Database = LoadPlugin<IAuthenticationData>(dllName,
|
||||
new Object[] {connString});
|
||||
new Object[] {connString, realm});
|
||||
if (m_Database == null)
|
||||
throw new Exception("Could not find a storage interface in the given module");
|
||||
}
|
||||
|
|
|
@ -26,11 +26,15 @@
|
|||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Services.Interfaces;
|
||||
using log4net;
|
||||
using Nini.Config;
|
||||
using System.Reflection;
|
||||
using OpenSim.Data;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Framework.Console;
|
||||
|
||||
namespace OpenSim.Services.AuthenticationService
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue