SQLite connector better, but access to tables still doesn't work.
parent
0ab6aac052
commit
df59d098b3
|
@ -52,12 +52,16 @@ namespace OpenSim.Data.SQLite
|
||||||
|
|
||||||
if (!m_initialized)
|
if (!m_initialized)
|
||||||
{
|
{
|
||||||
|
m_Connection = new SqliteConnection(connectionString);
|
||||||
|
m_Connection.Open();
|
||||||
|
|
||||||
using (SqliteConnection dbcon = new SqliteConnection(m_connectionString))
|
using (SqliteConnection dbcon = new SqliteConnection(m_connectionString))
|
||||||
{
|
{
|
||||||
dbcon.Open();
|
dbcon.Open();
|
||||||
Migration m = new Migration(dbcon, GetType().Assembly, "AuthStore");
|
Migration m = new Migration(dbcon, GetType().Assembly, "AuthStore");
|
||||||
m.Update();
|
m.Update();
|
||||||
}
|
}
|
||||||
|
|
||||||
m_initialized = true;
|
m_initialized = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -117,13 +121,17 @@ namespace OpenSim.Data.SQLite
|
||||||
|
|
||||||
SqliteCommand cmd = new SqliteCommand();
|
SqliteCommand cmd = new SqliteCommand();
|
||||||
|
|
||||||
string update = "update `"+m_Realm+"` set ";
|
if (Get(data.PrincipalID) != null)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
string update = "update `" + m_Realm + "` set ";
|
||||||
bool first = true;
|
bool first = true;
|
||||||
foreach (string field in fields)
|
foreach (string field in fields)
|
||||||
{
|
{
|
||||||
if (!first)
|
if (!first)
|
||||||
update += ", ";
|
update += ", ";
|
||||||
update += "`" + field + "` = " + data.Data[field];
|
update += "`" + field + "` = '" + data.Data[field] + "'";
|
||||||
|
|
||||||
first = false;
|
first = false;
|
||||||
|
|
||||||
|
@ -132,21 +140,46 @@ namespace OpenSim.Data.SQLite
|
||||||
update += " where UUID = '" + data.PrincipalID.ToString() + "'";
|
update += " where UUID = '" + data.PrincipalID.ToString() + "'";
|
||||||
|
|
||||||
cmd.CommandText = update;
|
cmd.CommandText = update;
|
||||||
|
Console.WriteLine("XXX " + cmd.CommandText);
|
||||||
|
try
|
||||||
|
{
|
||||||
if (ExecuteNonQuery(cmd) < 1)
|
if (ExecuteNonQuery(cmd) < 1)
|
||||||
|
{
|
||||||
|
cmd.Dispose();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
cmd.Dispose();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
{
|
{
|
||||||
string insert = "insert into `" + m_Realm + "` (`UUID`, `" +
|
string insert = "insert into `" + m_Realm + "` (`UUID`, `" +
|
||||||
String.Join("`, `", fields) +
|
String.Join("`, `", fields) +
|
||||||
"`) values ('" + data.PrincipalID.ToString() + "', " + String.Join(", '", values) + "')";
|
"`) values ('" + data.PrincipalID.ToString() + "', '" + String.Join("', '", values) + "')";
|
||||||
|
|
||||||
cmd.CommandText = insert;
|
cmd.CommandText = insert;
|
||||||
|
|
||||||
|
Console.WriteLine("XXX " + cmd.CommandText);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
if (ExecuteNonQuery(cmd) < 1)
|
if (ExecuteNonQuery(cmd) < 1)
|
||||||
{
|
{
|
||||||
cmd.Dispose();
|
cmd.Dispose();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
cmd.Dispose();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
cmd.Dispose();
|
cmd.Dispose();
|
||||||
|
|
||||||
|
|
|
@ -40,17 +40,12 @@ namespace OpenSim.Data.SQLite
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class SQLiteFramework
|
public class SQLiteFramework
|
||||||
{
|
{
|
||||||
protected static SqliteConnection m_Connection;
|
protected SqliteConnection m_Connection;
|
||||||
private bool m_initialized;
|
|
||||||
|
|
||||||
protected SQLiteFramework(string connectionString)
|
protected SQLiteFramework(string connectionString)
|
||||||
{
|
{
|
||||||
if (!m_initialized)
|
//m_Connection = new SqliteConnection(connectionString);
|
||||||
{
|
//m_Connection.Open();
|
||||||
m_Connection = new SqliteConnection(connectionString);
|
|
||||||
m_Connection.Open();
|
|
||||||
m_initialized = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////
|
||||||
|
@ -63,6 +58,7 @@ namespace OpenSim.Data.SQLite
|
||||||
lock (m_Connection)
|
lock (m_Connection)
|
||||||
{
|
{
|
||||||
cmd.Connection = m_Connection;
|
cmd.Connection = m_Connection;
|
||||||
|
Console.WriteLine("XXX " + cmd.CommandText);
|
||||||
|
|
||||||
return cmd.ExecuteNonQuery();
|
return cmd.ExecuteNonQuery();
|
||||||
}
|
}
|
||||||
|
@ -75,6 +71,7 @@ namespace OpenSim.Data.SQLite
|
||||||
newConnection.Open();
|
newConnection.Open();
|
||||||
|
|
||||||
cmd.Connection = newConnection;
|
cmd.Connection = newConnection;
|
||||||
|
Console.WriteLine("XXX " + cmd.CommandText);
|
||||||
return cmd.ExecuteReader();
|
return cmd.ExecuteReader();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -57,6 +57,9 @@ namespace OpenSim.Data.SQLite
|
||||||
|
|
||||||
if (!m_initialized)
|
if (!m_initialized)
|
||||||
{
|
{
|
||||||
|
m_Connection = new SqliteConnection(connectionString);
|
||||||
|
m_Connection.Open();
|
||||||
|
|
||||||
if (storeName != String.Empty)
|
if (storeName != String.Empty)
|
||||||
{
|
{
|
||||||
Assembly assem = GetType().Assembly;
|
Assembly assem = GetType().Assembly;
|
||||||
|
@ -64,6 +67,7 @@ namespace OpenSim.Data.SQLite
|
||||||
Migration m = new Migration(m_Connection, assem, storeName);
|
Migration m = new Migration(m_Connection, assem, storeName);
|
||||||
m.Update();
|
m.Update();
|
||||||
}
|
}
|
||||||
|
|
||||||
m_initialized = true;
|
m_initialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,7 +121,7 @@ namespace OpenSim.Data.SQLite
|
||||||
for (int i = 0 ; i < fields.Length ; i++)
|
for (int i = 0 ; i < fields.Length ; i++)
|
||||||
{
|
{
|
||||||
cmd.Parameters.Add(new SqliteParameter(":" + fields[i], keys[i]));
|
cmd.Parameters.Add(new SqliteParameter(":" + fields[i], keys[i]));
|
||||||
terms.Add("`" + fields[i] + "` = :" + fields[i]);
|
terms.Add("`" + fields[i] + "`='" + keys[i] + "'");
|
||||||
}
|
}
|
||||||
|
|
||||||
string where = String.Join(" and ", terms.ToArray());
|
string where = String.Join(" and ", terms.ToArray());
|
||||||
|
@ -215,8 +219,8 @@ namespace OpenSim.Data.SQLite
|
||||||
foreach (FieldInfo fi in m_Fields.Values)
|
foreach (FieldInfo fi in m_Fields.Values)
|
||||||
{
|
{
|
||||||
names.Add(fi.Name);
|
names.Add(fi.Name);
|
||||||
values.Add(":" + fi.Name);
|
values.Add(fi.GetValue(row).ToString());
|
||||||
cmd.Parameters.Add(new SqliteParameter(":" + fi.Name, fi.GetValue(row).ToString()));
|
cmd.Parameters.Add(new SqliteParameter(fi.Name, fi.GetValue(row).ToString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_DataField != null)
|
if (m_DataField != null)
|
||||||
|
@ -227,12 +231,12 @@ namespace OpenSim.Data.SQLite
|
||||||
foreach (KeyValuePair<string, string> kvp in data)
|
foreach (KeyValuePair<string, string> kvp in data)
|
||||||
{
|
{
|
||||||
names.Add(kvp.Key);
|
names.Add(kvp.Key);
|
||||||
values.Add(":" + kvp.Key);
|
values.Add(kvp.Value);
|
||||||
cmd.Parameters.Add(new SqliteParameter(":" + kvp.Key, kvp.Value));
|
cmd.Parameters.Add(new SqliteParameter(kvp.Key, kvp.Value));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
query = String.Format("replace into {0} (`", m_Realm) + String.Join("`,`", names.ToArray()) + "`) values (" + String.Join(",", values.ToArray()) + ")";
|
query = String.Format("replace into {0} (`", m_Realm) + String.Join("`,`", names.ToArray()) + "`) values ('" + String.Join("', '", values.ToArray()) + "')";
|
||||||
|
|
||||||
cmd.CommandText = query;
|
cmd.CommandText = query;
|
||||||
|
|
||||||
|
|
|
@ -106,12 +106,17 @@ namespace OpenSim.Services.AuthenticationService
|
||||||
string passwordSalt = Util.Md5Hash(UUID.Random().ToString());
|
string passwordSalt = Util.Md5Hash(UUID.Random().ToString());
|
||||||
string md5PasswdHash = Util.Md5Hash(Util.Md5Hash(password) + ":" + passwordSalt);
|
string md5PasswdHash = Util.Md5Hash(Util.Md5Hash(password) + ":" + passwordSalt);
|
||||||
|
|
||||||
AuthenticationData auth = new AuthenticationData();
|
AuthenticationData auth = m_Database.Get(principalID);
|
||||||
|
if (auth == null)
|
||||||
|
{
|
||||||
|
auth = new AuthenticationData();
|
||||||
auth.PrincipalID = principalID;
|
auth.PrincipalID = principalID;
|
||||||
auth.Data = new System.Collections.Generic.Dictionary<string, object>();
|
auth.Data = new System.Collections.Generic.Dictionary<string, object>();
|
||||||
|
auth.Data["accountType"] = "UserAccount";
|
||||||
|
auth.Data["webLoginKey"] = UUID.Zero.ToString();
|
||||||
|
}
|
||||||
auth.Data["passwordHash"] = md5PasswdHash;
|
auth.Data["passwordHash"] = md5PasswdHash;
|
||||||
auth.Data["passwordSalt"] = passwordSalt;
|
auth.Data["passwordSalt"] = passwordSalt;
|
||||||
auth.Data["webLoginKey"] = UUID.Zero.ToString();
|
|
||||||
if (!m_Database.Store(auth))
|
if (!m_Database.Store(auth))
|
||||||
{
|
{
|
||||||
m_log.DebugFormat("[AUTHENTICATION DB]: Failed to store authentication data");
|
m_log.DebugFormat("[AUTHENTICATION DB]: Failed to store authentication data");
|
||||||
|
|
Loading…
Reference in New Issue