aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenGrid.Framework.Data.MySQL/MySQLGridData.cs51
-rw-r--r--OpenGrid.Framework.Data.MySQL/MySQLManager.cs84
-rw-r--r--OpenGrid.Framework.Data.MySQL/OpenGrid.Framework.Data.MySQL.csproj62
-rw-r--r--OpenGrid.Framework.Data.MySQL/Properties/AssemblyInfo.cs35
-rw-r--r--OpenGrid.Framework.Data/GridData.cs14
-rw-r--r--OpenGrid.Framework.Data/OpenGrid.Framework.Data.csproj52
-rw-r--r--OpenGrid.Framework.Data/Properties/AssemblyInfo.cs35
-rw-r--r--OpenGrid.Framework.Data/SimProfileData.cs65
-rw-r--r--OpenGrid.Framework.Data/UserProfileData.cs33
-rw-r--r--OpenGridServices.GridServer/SimProfiles.cs2
-rw-r--r--bin/MySql.Data.dllbin0 -> 143360 bytes
11 files changed, 432 insertions, 1 deletions
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 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using OpenGrid.Framework.Data;
5
6namespace OpenGrid.Framework.Data.MySQL
7{
8 public class MySQLGridData : IGridData
9 {
10 MySQLManager database;
11
12 public void Initialise()
13 {
14 database = new MySQLManager("localhost", "db", "user", "password", "false");
15 }
16 public SimProfileData GetProfileByHandle(ulong handle)
17 {
18 return new SimProfileData();
19 }
20 public SimProfileData GetProfileByLLUUID(libsecondlife.LLUUID uuid)
21 {
22 return new SimProfileData();
23 }
24 public bool AuthenticateSim(libsecondlife.LLUUID uuid, ulong handle, string authkey)
25 {
26 throw new Exception("CRYPTOWEAK AUTHENTICATE: Refusing to authenticate due to replay potential.");
27 }
28
29 /// <summary>
30 /// Provides a cryptographic authentication of a region
31 /// </summary>
32 /// <remarks>This requires a security audit.</remarks>
33 /// <param name="uuid"></param>
34 /// <param name="handle"></param>
35 /// <param name="authhash"></param>
36 /// <param name="challenge"></param>
37 /// <returns></returns>
38 public bool AuthenticateSim(libsecondlife.LLUUID uuid, ulong handle, string authhash, string challenge)
39 {
40 System.Security.Cryptography.SHA512Managed HashProvider = new System.Security.Cryptography.SHA512Managed();
41 System.Text.ASCIIEncoding TextProvider = new ASCIIEncoding();
42
43 byte[] stream = TextProvider.GetBytes(uuid.ToStringHyphenated() + ":" + handle.ToString() + ":" + challenge);
44 byte[] hash = HashProvider.ComputeHash(stream);
45
46 return false;
47 }
48 }
49
50
51}
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 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using System.Data;
5
6// MySQL Native
7using MySql;
8using MySql.Data;
9using MySql.Data.Types;
10using MySql.Data.MySqlClient;
11
12namespace OpenGrid.Framework.Data.MySQL
13{
14 class MySQLManager
15 {
16 IDbConnection dbcon;
17
18 /// <summary>
19 /// Initialises and creates a new MySQL connection and maintains it.
20 /// </summary>
21 /// <param name="hostname">The MySQL server being connected to</param>
22 /// <param name="database">The name of the MySQL database being used</param>
23 /// <param name="username">The username logging into the database</param>
24 /// <param name="password">The password for the user logging in</param>
25 /// <param name="cpooling">Whether to use connection pooling or not, can be one of the following: 'yes', 'true', 'no' or 'false', if unsure use 'false'.</param>
26 public MySQLManager(string hostname, string database, string username, string password, string cpooling)
27 {
28 try
29 {
30 string connectionString = "Server=" + hostname + ";Database=" + database + ";User ID=" + username + ";Password=" + password + ";Pooling=" + cpooling + ";";
31 dbcon = new MySqlConnection(connectionString);
32
33 dbcon.Open();
34 }
35 catch (Exception e)
36 {
37 throw new Exception("Error initialising MySql Database: " + e.ToString());
38 }
39 }
40
41 /// <summary>
42 /// Shuts down the database connection
43 /// </summary>
44 public void Close()
45 {
46 dbcon.Close();
47 dbcon = null;
48 }
49
50 /// <summary>
51 /// Runs a query with protection against SQL Injection by using parameterised input.
52 /// </summary>
53 /// <param name="sql">The SQL string - replace any variables such as WHERE x = "y" with WHERE x = @y</param>
54 /// <param name="parameters">The parameters - index so that @y is indexed as 'y'</param>
55 /// <returns>A MySQL DB Command</returns>
56 public IDbCommand Query(string sql, Dictionary<string, string> parameters)
57 {
58 MySqlCommand dbcommand = (MySqlCommand)dbcon.CreateCommand();
59 dbcommand.CommandText = sql;
60 foreach (KeyValuePair<string, string> param in parameters)
61 {
62 dbcommand.Parameters.Add(param.Key, param.Value);
63 }
64
65 return (IDbCommand)dbcommand;
66 }
67
68 public SimProfileData getRow(IDataReader reader)
69 {
70 SimProfileData retval = new SimProfileData();
71
72 if (reader.Read())
73 {
74 //retval.regionDataURI = reader["regionDataURI"];
75
76 }
77 else
78 {
79 return null;
80 }
81 return retval;
82 }
83 }
84}
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 @@
1<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2 <PropertyGroup>
3 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
4 <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
5 <ProductVersion>8.0.50727</ProductVersion>
6 <SchemaVersion>2.0</SchemaVersion>
7 <ProjectGuid>{66164B45-4821-48E4-9399-14FE2D92D854}</ProjectGuid>
8 <OutputType>Library</OutputType>
9 <AppDesignerFolder>Properties</AppDesignerFolder>
10 <RootNamespace>OpenGrid.Framework.Data.MySQL</RootNamespace>
11 <AssemblyName>OpenGrid.Framework.Data.MySQL</AssemblyName>
12 </PropertyGroup>
13 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
14 <DebugSymbols>true</DebugSymbols>
15 <DebugType>full</DebugType>
16 <Optimize>false</Optimize>
17 <OutputPath>bin\Debug\</OutputPath>
18 <DefineConstants>DEBUG;TRACE</DefineConstants>
19 <ErrorReport>prompt</ErrorReport>
20 <WarningLevel>4</WarningLevel>
21 </PropertyGroup>
22 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
23 <DebugType>pdbonly</DebugType>
24 <Optimize>true</Optimize>
25 <OutputPath>bin\Release\</OutputPath>
26 <DefineConstants>TRACE</DefineConstants>
27 <ErrorReport>prompt</ErrorReport>
28 <WarningLevel>4</WarningLevel>
29 </PropertyGroup>
30 <ItemGroup>
31 <Reference Include="libsecondlife, Version=0.9.0.0, Culture=neutral, processorArchitecture=MSIL">
32 <SpecificVersion>False</SpecificVersion>
33 <HintPath>..\bin\libsecondlife.dll</HintPath>
34 </Reference>
35 <Reference Include="MySql.Data, Version=1.0.7.30072, Culture=neutral, PublicKeyToken=c5687fc88969c44d, processorArchitecture=MSIL">
36 <SpecificVersion>False</SpecificVersion>
37 <HintPath>..\bin\MySql.Data.dll</HintPath>
38 </Reference>
39 <Reference Include="System" />
40 <Reference Include="System.Data" />
41 <Reference Include="System.Xml" />
42 </ItemGroup>
43 <ItemGroup>
44 <Compile Include="MySQLGridData.cs" />
45 <Compile Include="MySQLManager.cs" />
46 <Compile Include="Properties\AssemblyInfo.cs" />
47 </ItemGroup>
48 <ItemGroup>
49 <ProjectReference Include="..\OpenGrid.Framework.Data\OpenGrid.Framework.Data.csproj">
50 <Project>{70E6CBC5-2DD0-44F1-87B8-2CFB2458EDE9}</Project>
51 <Name>OpenGrid.Framework.Data</Name>
52 </ProjectReference>
53 </ItemGroup>
54 <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
55 <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
56 Other similar extension points exist, see Microsoft.Common.targets.
57 <Target Name="BeforeBuild">
58 </Target>
59 <Target Name="AfterBuild">
60 </Target>
61 -->
62</Project> \ 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 @@
1using System.Reflection;
2using System.Runtime.CompilerServices;
3using System.Runtime.InteropServices;
4
5// General Information about an assembly is controlled through the following
6// set of attributes. Change these attribute values to modify the information
7// associated with an assembly.
8[assembly: AssemblyTitle("OpenGrid.Framework.Data.MySQL")]
9[assembly: AssemblyDescription("")]
10[assembly: AssemblyConfiguration("")]
11[assembly: AssemblyCompany("")]
12[assembly: AssemblyProduct("OpenGrid.Framework.Data.MySQL")]
13[assembly: AssemblyCopyright("Copyright © 2007")]
14[assembly: AssemblyTrademark("")]
15[assembly: AssemblyCulture("")]
16
17// Setting ComVisible to false makes the types in this assembly not visible
18// to COM components. If you need to access a type in this assembly from
19// COM, set the ComVisible attribute to true on that type.
20[assembly: ComVisible(false)]
21
22// The following GUID is for the ID of the typelib if this project is exposed to COM
23[assembly: Guid("e49826b2-dcef-41be-a5bd-596733fa3304")]
24
25// Version information for an assembly consists of the following four values:
26//
27// Major Version
28// Minor Version
29// Build Number
30// Revision
31//
32// You can specify all the values or you can default the Revision and Build Numbers
33// by using the '*' as shown below:
34[assembly: AssemblyVersion("1.0.0.0")]
35[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 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4
5namespace OpenGrid.Framework.Data
6{
7 public interface IGridData
8 {
9 SimProfileData GetProfileByHandle(ulong regionHandle);
10 SimProfileData GetProfileByLLUUID(libsecondlife.LLUUID UUID);
11 bool AuthenticateSim(libsecondlife.LLUUID UUID, ulong regionHandle, string simrecvkey);
12 void Initialise();
13 }
14}
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 @@
1<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2 <PropertyGroup>
3 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
4 <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
5 <ProductVersion>8.0.50727</ProductVersion>
6 <SchemaVersion>2.0</SchemaVersion>
7 <ProjectGuid>{70E6CBC5-2DD0-44F1-87B8-2CFB2458EDE9}</ProjectGuid>
8 <OutputType>Library</OutputType>
9 <AppDesignerFolder>Properties</AppDesignerFolder>
10 <RootNamespace>OpenGrid.Framework.Data</RootNamespace>
11 <AssemblyName>OpenGrid.Framework.Data</AssemblyName>
12 </PropertyGroup>
13 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
14 <DebugSymbols>true</DebugSymbols>
15 <DebugType>full</DebugType>
16 <Optimize>false</Optimize>
17 <OutputPath>bin\Debug\</OutputPath>
18 <DefineConstants>DEBUG;TRACE</DefineConstants>
19 <ErrorReport>prompt</ErrorReport>
20 <WarningLevel>4</WarningLevel>
21 </PropertyGroup>
22 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
23 <DebugType>pdbonly</DebugType>
24 <Optimize>true</Optimize>
25 <OutputPath>bin\Release\</OutputPath>
26 <DefineConstants>TRACE</DefineConstants>
27 <ErrorReport>prompt</ErrorReport>
28 <WarningLevel>4</WarningLevel>
29 </PropertyGroup>
30 <ItemGroup>
31 <Reference Include="libsecondlife, Version=0.9.0.0, Culture=neutral, processorArchitecture=MSIL">
32 <SpecificVersion>False</SpecificVersion>
33 <HintPath>..\bin\libsecondlife.dll</HintPath>
34 </Reference>
35 <Reference Include="System" />
36 <Reference Include="System.Data" />
37 <Reference Include="System.Xml" />
38 </ItemGroup>
39 <ItemGroup>
40 <Compile Include="GridData.cs" />
41 <Compile Include="Properties\AssemblyInfo.cs" />
42 <Compile Include="SimProfileData.cs" />
43 </ItemGroup>
44 <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
45 <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
46 Other similar extension points exist, see Microsoft.Common.targets.
47 <Target Name="BeforeBuild">
48 </Target>
49 <Target Name="AfterBuild">
50 </Target>
51 -->
52</Project> \ 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 @@
1using System.Reflection;
2using System.Runtime.CompilerServices;
3using System.Runtime.InteropServices;
4
5// General Information about an assembly is controlled through the following
6// set of attributes. Change these attribute values to modify the information
7// associated with an assembly.
8[assembly: AssemblyTitle("OpenGrid.Framework.Data")]
9[assembly: AssemblyDescription("")]
10[assembly: AssemblyConfiguration("")]
11[assembly: AssemblyCompany("")]
12[assembly: AssemblyProduct("OpenGrid.Framework.Data")]
13[assembly: AssemblyCopyright("Copyright © 2007")]
14[assembly: AssemblyTrademark("")]
15[assembly: AssemblyCulture("")]
16
17// Setting ComVisible to false makes the types in this assembly not visible
18// to COM components. If you need to access a type in this assembly from
19// COM, set the ComVisible attribute to true on that type.
20[assembly: ComVisible(false)]
21
22// The following GUID is for the ID of the typelib if this project is exposed to COM
23[assembly: Guid("3a711c34-b0c0-4264-b0fe-f366eabf9d7b")]
24
25// Version information for an assembly consists of the following four values:
26//
27// Major Version
28// Minor Version
29// Build Number
30// Revision
31//
32// You can specify all the values or you can default the Revision and Build Numbers
33// by using the '*' as shown below:
34[assembly: AssemblyVersion("1.0.0.0")]
35[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 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4
5namespace OpenGrid.Framework.Data
6{
7 public class SimProfileData
8 {
9 /// <summary>
10 /// The name of the region
11 /// </summary>
12 public string regionName;
13
14 /// <summary>
15 /// A 64-bit number combining map position into a (mostly) unique ID
16 /// </summary>
17 public ulong regionHandle;
18
19 /// <summary>
20 /// OGS/OpenSim Specific ID for a region
21 /// </summary>
22 public libsecondlife.LLUUID UUID;
23
24 /// <summary>
25 /// Coordinates of the region
26 /// </summary>
27 public uint regionLocX;
28 public uint regionLocY;
29 public uint regionLocZ; // Reserved (round-robin, layers, etc)
30
31 /// <summary>
32 /// Authentication secrets
33 /// </summary>
34 /// <remarks>Not very secure, needs improvement.</remarks>
35 public string regionSendKey;
36 public string regionRecvKey;
37 public string regionSecret;
38
39 /// <summary>
40 /// Whether the region is online
41 /// </summary>
42 public bool regionOnline;
43
44 /// <summary>
45 /// Information about the server that the region is currently hosted on
46 /// </summary>
47 public string serverIP;
48 public uint serverPort;
49 public string serverURI;
50
51 /// <summary>
52 /// Set of optional overrides. Can be used to create non-eulicidean spaces.
53 /// </summary>
54 public ulong regionNorthOverrideHandle;
55 public ulong regionSouthOverrideHandle;
56 public ulong regionEastOverrideHandle;
57 public ulong regionWestOverrideHandle;
58
59 /// <summary>
60 /// Optional: URI Location of the region database
61 /// </summary>
62 /// <remarks>Used for floating sim pools where the region data is not nessecarily coupled to a specific server</remarks>
63 public string regionDataURI;
64 }
65}
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 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using libsecondlife;
5
6namespace OpenGrid.Framework.Data
7{
8 public class UserProfileData
9 {
10 string username; // The configurable part of the users username
11 string surname; // The users surname (can be used to indicate user class - eg 'Test User' or 'Test Admin')
12
13 ulong homeRegion; // RegionHandle of home
14 LLVector3 homeLocation; // Home Location inside the sim
15
16 int created; // UNIX Epoch Timestamp (User Creation)
17 int lastLogin; // UNIX Epoch Timestamp (Last Login Time)
18
19 string userInventoryURI; // URI to inventory server for this user
20 string userAssetURI; // URI to asset server for this user
21
22 uint profileCanDoMask; // Profile window "I can do" mask
23 uint profileWantDoMask; // Profile window "I want to" mask
24
25 string profileAboutText; // My about window text
26 string profileFirstText; // First Life Text
27
28 LLUUID profileImage; // My avatars profile image
29 LLUUID profileFirstImage; // First-life image
30
31
32 }
33}
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
278 } 278 }
279 catch (Exception e) 279 catch (Exception e)
280 { 280 {
281 return "ERROR! could not save to database!"; 281 return "ERROR! could not save to database! (" + e.ToString() + ")";
282 } 282 }
283 283
284 } 284 }
diff --git a/bin/MySql.Data.dll b/bin/MySql.Data.dll
new file mode 100644
index 0000000..0467dd6
--- /dev/null
+++ b/bin/MySql.Data.dll
Binary files differ