aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Data.SQLite/SQLiteGridData.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Framework/Data.SQLite/SQLiteGridData.cs')
-rw-r--r--OpenSim/Framework/Data.SQLite/SQLiteGridData.cs234
1 files changed, 0 insertions, 234 deletions
diff --git a/OpenSim/Framework/Data.SQLite/SQLiteGridData.cs b/OpenSim/Framework/Data.SQLite/SQLiteGridData.cs
deleted file mode 100644
index 94e8e50..0000000
--- a/OpenSim/Framework/Data.SQLite/SQLiteGridData.cs
+++ /dev/null
@@ -1,234 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using System.Data;
31using System.Security.Cryptography;
32using System.Text;
33using libsecondlife;
34
35namespace OpenSim.Framework.Data.SQLite
36{
37 /// <summary>
38 /// A Grid Interface to the SQLite database
39 /// </summary>
40 public class SQLiteGridData : GridDataBase
41 {
42 /// <summary>
43 /// A database manager
44 /// </summary>
45 private SQLiteManager database;
46
47 /// <summary>
48 /// Initialises the Grid Interface
49 /// </summary>
50 override public void Initialise()
51 {
52 database = new SQLiteManager("localhost", "db", "user", "password", "false");
53 }
54
55 /// <summary>
56 /// Shuts down the grid interface
57 /// </summary>
58 override public void Close()
59 {
60 database.Close();
61 }
62
63 /// <summary>
64 /// Returns the name of this grid interface
65 /// </summary>
66 /// <returns>A string containing the grid interface</returns>
67 override public string getName()
68 {
69 return "SQLite OpenGridData";
70 }
71
72 /// <summary>
73 /// Returns the version of this grid interface
74 /// </summary>
75 /// <returns>A string containing the version</returns>
76 override public string getVersion()
77 {
78 return "0.1";
79 }
80
81 /// <summary>
82 /// Returns a list of regions within the specified ranges
83 /// </summary>
84 /// <param name="a">minimum X coordinate</param>
85 /// <param name="b">minimum Y coordinate</param>
86 /// <param name="c">maximum X coordinate</param>
87 /// <param name="d">maximum Y coordinate</param>
88 /// <returns>An array of region profiles</returns>
89 override public RegionProfileData[] GetProfilesInRange(uint a, uint b, uint c, uint d)
90 {
91 return null;
92 }
93
94 /// <summary>
95 /// Returns a sim profile from it's location
96 /// </summary>
97 /// <param name="handle">Region location handle</param>
98 /// <returns>Sim profile</returns>
99 override public RegionProfileData GetProfileByHandle(ulong handle)
100 {
101 Dictionary<string, string> param = new Dictionary<string, string>();
102 param["handle"] = handle.ToString();
103
104 IDbCommand result = database.Query("SELECT * FROM regions WHERE handle = @handle", param);
105 IDataReader reader = result.ExecuteReader();
106
107 RegionProfileData row = database.getRow(reader);
108 reader.Close();
109 result.Dispose();
110
111 return row;
112 }
113
114 /// <summary>
115 /// Returns a sim profile from it's Region name string
116 /// </summary>
117 /// <param name="regionName">The region name search query</param>
118 /// <returns>The sim profile</returns>
119 override public RegionProfileData GetProfileByString(string regionName)
120 {
121 if (regionName.Length > 2)
122 {
123 Dictionary<string, string> param = new Dictionary<string, string>();
124 // Add % because this is a like query.
125 param["?regionName"] = regionName + "%";
126 // Only returns one record or no record.
127 IDbCommand result = database.Query("SELECT * FROM regions WHERE regionName like ?regionName LIMIT 1", param);
128 IDataReader reader = result.ExecuteReader();
129
130 RegionProfileData row = database.getRow(reader);
131 reader.Close();
132 result.Dispose();
133
134 return row;
135 }
136 else
137 {
138 //m_log.Error("[DATABASE]: Searched for a Region Name shorter then 3 characters");
139 return null;
140 }
141 }
142
143 /// <summary>
144 /// Returns a sim profile from it's UUID
145 /// </summary>
146 /// <param name="uuid">The region UUID</param>
147 /// <returns>The sim profile</returns>
148 override public RegionProfileData GetProfileByLLUUID(LLUUID uuid)
149 {
150 Dictionary<string, string> param = new Dictionary<string, string>();
151 param["uuid"] = uuid.ToString();
152
153 IDbCommand result = database.Query("SELECT * FROM regions WHERE uuid = @uuid", param);
154 IDataReader reader = result.ExecuteReader();
155
156 RegionProfileData row = database.getRow(reader);
157 reader.Close();
158 result.Dispose();
159
160 return row;
161 }
162
163 /// <summary>
164 /// // Returns a list of avatar and UUIDs that match the query
165 /// </summary>
166 public List<AvatarPickerAvatar> GeneratePickerResults(LLUUID queryID, string query)
167 {
168 //Do nothing yet
169 List<AvatarPickerAvatar> returnlist = new List<AvatarPickerAvatar>();
170 return returnlist;
171 }
172
173 /// <summary>
174 /// Adds a new specified region to the database
175 /// </summary>
176 /// <param name="profile">The profile to add</param>
177 /// <returns>A dataresponse enum indicating success</returns>
178 override public DataResponse AddProfile(RegionProfileData profile)
179 {
180 if (database.insertRow(profile))
181 {
182 return DataResponse.RESPONSE_OK;
183 }
184 else
185 {
186 return DataResponse.RESPONSE_ERROR;
187 }
188 }
189
190 /// <summary>
191 /// DEPRECATED. Attempts to authenticate a region by comparing a shared secret.
192 /// </summary>
193 /// <param name="uuid">The UUID of the challenger</param>
194 /// <param name="handle">The attempted regionHandle of the challenger</param>
195 /// <param name="authkey">The secret</param>
196 /// <returns>Whether the secret and regionhandle match the database entry for UUID</returns>
197 override public bool AuthenticateSim(LLUUID uuid, ulong handle, string authkey)
198 {
199 bool throwHissyFit = false; // Should be true by 1.0
200
201 if (throwHissyFit)
202 throw new Exception("CRYPTOWEAK AUTHENTICATE: Refusing to authenticate due to replay potential.");
203
204 RegionProfileData data = GetProfileByLLUUID(uuid);
205
206 return (handle == data.regionHandle && authkey == data.regionSecret);
207 }
208
209 /// <summary>
210 /// NOT YET FUNCTIONAL. Provides a cryptographic authentication of a region
211 /// </summary>
212 /// <remarks>This requires a security audit.</remarks>
213 /// <param name="uuid"></param>
214 /// <param name="handle"></param>
215 /// <param name="authhash"></param>
216 /// <param name="challenge"></param>
217 /// <returns></returns>
218 public bool AuthenticateSim(LLUUID uuid, ulong handle, string authhash, string challenge)
219 {
220 SHA512Managed HashProvider = new SHA512Managed();
221 ASCIIEncoding TextProvider = new ASCIIEncoding();
222
223 byte[] stream = TextProvider.GetBytes(uuid.ToString() + ":" + handle.ToString() + ":" + challenge);
224 byte[] hash = HashProvider.ComputeHash(stream);
225
226 return false;
227 }
228
229 override public ReservationData GetReservationAtPoint(uint x, uint y)
230 {
231 return null;
232 }
233 }
234}