From 10f75f936e1322ea1e328799cfba08229d667a78 Mon Sep 17 00:00:00 2001
From: Adam Frisby
Date: Fri, 4 May 2007 03:25:20 +0000
Subject: Committing OpenGrid.Framework.Data and MySql Adaptor - not in
functional state yet, posted for reference and future use.
---
OpenGrid.Framework.Data.MySQL/MySQLGridData.cs | 51 +++++++++++++
OpenGrid.Framework.Data.MySQL/MySQLManager.cs | 84 +++++++++++++++++++++
.../OpenGrid.Framework.Data.MySQL.csproj | 62 +++++++++++++++
.../Properties/AssemblyInfo.cs | 35 +++++++++
OpenGrid.Framework.Data/GridData.cs | 14 ++++
.../OpenGrid.Framework.Data.csproj | 52 +++++++++++++
OpenGrid.Framework.Data/Properties/AssemblyInfo.cs | 35 +++++++++
OpenGrid.Framework.Data/SimProfileData.cs | 65 ++++++++++++++++
OpenGrid.Framework.Data/UserProfileData.cs | 33 ++++++++
OpenGridServices.GridServer/SimProfiles.cs | 2 +-
bin/MySql.Data.dll | Bin 0 -> 143360 bytes
11 files changed, 432 insertions(+), 1 deletion(-)
create mode 100644 OpenGrid.Framework.Data.MySQL/MySQLGridData.cs
create mode 100644 OpenGrid.Framework.Data.MySQL/MySQLManager.cs
create mode 100644 OpenGrid.Framework.Data.MySQL/OpenGrid.Framework.Data.MySQL.csproj
create mode 100644 OpenGrid.Framework.Data.MySQL/Properties/AssemblyInfo.cs
create mode 100644 OpenGrid.Framework.Data/GridData.cs
create mode 100644 OpenGrid.Framework.Data/OpenGrid.Framework.Data.csproj
create mode 100644 OpenGrid.Framework.Data/Properties/AssemblyInfo.cs
create mode 100644 OpenGrid.Framework.Data/SimProfileData.cs
create mode 100644 OpenGrid.Framework.Data/UserProfileData.cs
create mode 100644 bin/MySql.Data.dll
diff --git a/OpenGrid.Framework.Data.MySQL/MySQLGridData.cs b/OpenGrid.Framework.Data.MySQL/MySQLGridData.cs
new file mode 100644
index 0000000..65a0fff
--- /dev/null
+++ b/OpenGrid.Framework.Data.MySQL/MySQLGridData.cs
@@ -0,0 +1,51 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using OpenGrid.Framework.Data;
+
+namespace OpenGrid.Framework.Data.MySQL
+{
+ public class MySQLGridData : IGridData
+ {
+ MySQLManager database;
+
+ public void Initialise()
+ {
+ database = new MySQLManager("localhost", "db", "user", "password", "false");
+ }
+ public SimProfileData GetProfileByHandle(ulong handle)
+ {
+ return new SimProfileData();
+ }
+ public SimProfileData GetProfileByLLUUID(libsecondlife.LLUUID uuid)
+ {
+ return new SimProfileData();
+ }
+ public bool AuthenticateSim(libsecondlife.LLUUID uuid, ulong handle, string authkey)
+ {
+ throw new Exception("CRYPTOWEAK AUTHENTICATE: Refusing to authenticate due to replay potential.");
+ }
+
+ ///
+ /// Provides a cryptographic authentication of a region
+ ///
+ /// This requires a security audit.
+ ///
+ ///
+ ///
+ ///
+ ///
+ public bool AuthenticateSim(libsecondlife.LLUUID uuid, ulong handle, string authhash, string challenge)
+ {
+ System.Security.Cryptography.SHA512Managed HashProvider = new System.Security.Cryptography.SHA512Managed();
+ System.Text.ASCIIEncoding TextProvider = new ASCIIEncoding();
+
+ byte[] stream = TextProvider.GetBytes(uuid.ToStringHyphenated() + ":" + handle.ToString() + ":" + challenge);
+ byte[] hash = HashProvider.ComputeHash(stream);
+
+ return false;
+ }
+ }
+
+
+}
diff --git a/OpenGrid.Framework.Data.MySQL/MySQLManager.cs b/OpenGrid.Framework.Data.MySQL/MySQLManager.cs
new file mode 100644
index 0000000..30ad314
--- /dev/null
+++ b/OpenGrid.Framework.Data.MySQL/MySQLManager.cs
@@ -0,0 +1,84 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Data;
+
+// MySQL Native
+using MySql;
+using MySql.Data;
+using MySql.Data.Types;
+using MySql.Data.MySqlClient;
+
+namespace OpenGrid.Framework.Data.MySQL
+{
+ class MySQLManager
+ {
+ IDbConnection dbcon;
+
+ ///
+ /// Initialises and creates a new MySQL connection and maintains it.
+ ///
+ /// The MySQL server being connected to
+ /// The name of the MySQL database being used
+ /// The username logging into the database
+ /// The password for the user logging in
+ /// Whether to use connection pooling or not, can be one of the following: 'yes', 'true', 'no' or 'false', if unsure use 'false'.
+ public MySQLManager(string hostname, string database, string username, string password, string cpooling)
+ {
+ try
+ {
+ string connectionString = "Server=" + hostname + ";Database=" + database + ";User ID=" + username + ";Password=" + password + ";Pooling=" + cpooling + ";";
+ dbcon = new MySqlConnection(connectionString);
+
+ dbcon.Open();
+ }
+ catch (Exception e)
+ {
+ throw new Exception("Error initialising MySql Database: " + e.ToString());
+ }
+ }
+
+ ///
+ /// Shuts down the database connection
+ ///
+ public void Close()
+ {
+ dbcon.Close();
+ dbcon = null;
+ }
+
+ ///
+ /// Runs a query with protection against SQL Injection by using parameterised input.
+ ///
+ /// The SQL string - replace any variables such as WHERE x = "y" with WHERE x = @y
+ /// The parameters - index so that @y is indexed as 'y'
+ /// A MySQL DB Command
+ public IDbCommand Query(string sql, Dictionary parameters)
+ {
+ MySqlCommand dbcommand = (MySqlCommand)dbcon.CreateCommand();
+ dbcommand.CommandText = sql;
+ foreach (KeyValuePair param in parameters)
+ {
+ dbcommand.Parameters.Add(param.Key, param.Value);
+ }
+
+ return (IDbCommand)dbcommand;
+ }
+
+ public SimProfileData getRow(IDataReader reader)
+ {
+ SimProfileData retval = new SimProfileData();
+
+ if (reader.Read())
+ {
+ //retval.regionDataURI = reader["regionDataURI"];
+
+ }
+ else
+ {
+ return null;
+ }
+ return retval;
+ }
+ }
+}
diff --git a/OpenGrid.Framework.Data.MySQL/OpenGrid.Framework.Data.MySQL.csproj b/OpenGrid.Framework.Data.MySQL/OpenGrid.Framework.Data.MySQL.csproj
new file mode 100644
index 0000000..dfb6e48
--- /dev/null
+++ b/OpenGrid.Framework.Data.MySQL/OpenGrid.Framework.Data.MySQL.csproj
@@ -0,0 +1,62 @@
+
+
+ Debug
+ AnyCPU
+ 8.0.50727
+ 2.0
+ {66164B45-4821-48E4-9399-14FE2D92D854}
+ Library
+ Properties
+ OpenGrid.Framework.Data.MySQL
+ OpenGrid.Framework.Data.MySQL
+
+
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+
+
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+
+
+
+ False
+ ..\bin\libsecondlife.dll
+
+
+ False
+ ..\bin\MySql.Data.dll
+
+
+
+
+
+
+
+
+
+
+
+
+ {70E6CBC5-2DD0-44F1-87B8-2CFB2458EDE9}
+ OpenGrid.Framework.Data
+
+
+
+
+
\ No newline at end of file
diff --git a/OpenGrid.Framework.Data.MySQL/Properties/AssemblyInfo.cs b/OpenGrid.Framework.Data.MySQL/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..0bfd1d6
--- /dev/null
+++ b/OpenGrid.Framework.Data.MySQL/Properties/AssemblyInfo.cs
@@ -0,0 +1,35 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("OpenGrid.Framework.Data.MySQL")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("OpenGrid.Framework.Data.MySQL")]
+[assembly: AssemblyCopyright("Copyright © 2007")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("e49826b2-dcef-41be-a5bd-596733fa3304")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Revision and Build Numbers
+// by using the '*' as shown below:
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/OpenGrid.Framework.Data/GridData.cs b/OpenGrid.Framework.Data/GridData.cs
new file mode 100644
index 0000000..9bc2ce3
--- /dev/null
+++ b/OpenGrid.Framework.Data/GridData.cs
@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace OpenGrid.Framework.Data
+{
+ public interface IGridData
+ {
+ SimProfileData GetProfileByHandle(ulong regionHandle);
+ SimProfileData GetProfileByLLUUID(libsecondlife.LLUUID UUID);
+ bool AuthenticateSim(libsecondlife.LLUUID UUID, ulong regionHandle, string simrecvkey);
+ void Initialise();
+ }
+}
diff --git a/OpenGrid.Framework.Data/OpenGrid.Framework.Data.csproj b/OpenGrid.Framework.Data/OpenGrid.Framework.Data.csproj
new file mode 100644
index 0000000..2be7ea9
--- /dev/null
+++ b/OpenGrid.Framework.Data/OpenGrid.Framework.Data.csproj
@@ -0,0 +1,52 @@
+
+
+ Debug
+ AnyCPU
+ 8.0.50727
+ 2.0
+ {70E6CBC5-2DD0-44F1-87B8-2CFB2458EDE9}
+ Library
+ Properties
+ OpenGrid.Framework.Data
+ OpenGrid.Framework.Data
+
+
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+
+
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+
+
+
+ False
+ ..\bin\libsecondlife.dll
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/OpenGrid.Framework.Data/Properties/AssemblyInfo.cs b/OpenGrid.Framework.Data/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..1446673
--- /dev/null
+++ b/OpenGrid.Framework.Data/Properties/AssemblyInfo.cs
@@ -0,0 +1,35 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("OpenGrid.Framework.Data")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("OpenGrid.Framework.Data")]
+[assembly: AssemblyCopyright("Copyright © 2007")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("3a711c34-b0c0-4264-b0fe-f366eabf9d7b")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Revision and Build Numbers
+// by using the '*' as shown below:
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/OpenGrid.Framework.Data/SimProfileData.cs b/OpenGrid.Framework.Data/SimProfileData.cs
new file mode 100644
index 0000000..a701875
--- /dev/null
+++ b/OpenGrid.Framework.Data/SimProfileData.cs
@@ -0,0 +1,65 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace OpenGrid.Framework.Data
+{
+ public class SimProfileData
+ {
+ ///
+ /// The name of the region
+ ///
+ public string regionName;
+
+ ///
+ /// A 64-bit number combining map position into a (mostly) unique ID
+ ///
+ public ulong regionHandle;
+
+ ///
+ /// OGS/OpenSim Specific ID for a region
+ ///
+ public libsecondlife.LLUUID UUID;
+
+ ///
+ /// Coordinates of the region
+ ///
+ public uint regionLocX;
+ public uint regionLocY;
+ public uint regionLocZ; // Reserved (round-robin, layers, etc)
+
+ ///
+ /// Authentication secrets
+ ///
+ /// Not very secure, needs improvement.
+ public string regionSendKey;
+ public string regionRecvKey;
+ public string regionSecret;
+
+ ///
+ /// Whether the region is online
+ ///
+ public bool regionOnline;
+
+ ///
+ /// Information about the server that the region is currently hosted on
+ ///
+ public string serverIP;
+ public uint serverPort;
+ public string serverURI;
+
+ ///
+ /// Set of optional overrides. Can be used to create non-eulicidean spaces.
+ ///
+ public ulong regionNorthOverrideHandle;
+ public ulong regionSouthOverrideHandle;
+ public ulong regionEastOverrideHandle;
+ public ulong regionWestOverrideHandle;
+
+ ///
+ /// Optional: URI Location of the region database
+ ///
+ /// Used for floating sim pools where the region data is not nessecarily coupled to a specific server
+ public string regionDataURI;
+ }
+}
diff --git a/OpenGrid.Framework.Data/UserProfileData.cs b/OpenGrid.Framework.Data/UserProfileData.cs
new file mode 100644
index 0000000..d99394e
--- /dev/null
+++ b/OpenGrid.Framework.Data/UserProfileData.cs
@@ -0,0 +1,33 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using libsecondlife;
+
+namespace OpenGrid.Framework.Data
+{
+ public class UserProfileData
+ {
+ string username; // The configurable part of the users username
+ string surname; // The users surname (can be used to indicate user class - eg 'Test User' or 'Test Admin')
+
+ ulong homeRegion; // RegionHandle of home
+ LLVector3 homeLocation; // Home Location inside the sim
+
+ int created; // UNIX Epoch Timestamp (User Creation)
+ int lastLogin; // UNIX Epoch Timestamp (Last Login Time)
+
+ string userInventoryURI; // URI to inventory server for this user
+ string userAssetURI; // URI to asset server for this user
+
+ uint profileCanDoMask; // Profile window "I can do" mask
+ uint profileWantDoMask; // Profile window "I want to" mask
+
+ string profileAboutText; // My about window text
+ string profileFirstText; // First Life Text
+
+ LLUUID profileImage; // My avatars profile image
+ LLUUID profileFirstImage; // First-life image
+
+
+ }
+}
diff --git a/OpenGridServices.GridServer/SimProfiles.cs b/OpenGridServices.GridServer/SimProfiles.cs
index ae40133..6e228ae 100644
--- a/OpenGridServices.GridServer/SimProfiles.cs
+++ b/OpenGridServices.GridServer/SimProfiles.cs
@@ -278,7 +278,7 @@ namespace OpenGridServices.GridServer
}
catch (Exception e)
{
- return "ERROR! could not save to database!";
+ return "ERROR! could not save to database! (" + e.ToString() + ")";
}
}
diff --git a/bin/MySql.Data.dll b/bin/MySql.Data.dll
new file mode 100644
index 0000000..0467dd6
Binary files /dev/null and b/bin/MySql.Data.dll differ
--
cgit v1.1