aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/SQLite/SQLiteGridData.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Data/SQLite/SQLiteGridData.cs')
-rw-r--r--OpenSim/Data/SQLite/SQLiteGridData.cs286
1 files changed, 0 insertions, 286 deletions
diff --git a/OpenSim/Data/SQLite/SQLiteGridData.cs b/OpenSim/Data/SQLite/SQLiteGridData.cs
deleted file mode 100644
index 18abb88..0000000
--- a/OpenSim/Data/SQLite/SQLiteGridData.cs
+++ /dev/null
@@ -1,286 +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 OpenSimulator 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.Reflection;
32using log4net;
33using OpenMetaverse;
34using OpenSim.Framework;
35
36namespace OpenSim.Data.SQLite
37{
38 /// <summary>
39 /// A Grid Interface to the SQLite database
40 /// </summary>
41 public class SQLiteGridData : GridDataBase
42 {
43 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
44
45 /// <summary>
46 /// SQLite database manager
47 /// </summary>
48 private SQLiteManager database;
49
50 override public void Initialise()
51 {
52 m_log.Info("[SQLite]: " + Name + " cannot be default-initialized!");
53 throw new PluginNotInitialisedException (Name);
54 }
55
56 /// <summary>
57 /// <list type="bullet">
58 /// <item>Initialises Inventory interface</item>
59 /// <item>Loads and initialises a new SQLite connection and maintains it.</item>
60 /// <item>use default URI if connect string is empty.</item>
61 /// </list>
62 /// </summary>
63 /// <param name="dbconnect">connect string</param>
64 override public void Initialise(string connect)
65 {
66 database = new SQLiteManager(connect);
67 }
68
69 /// <summary>
70 /// Shuts down the grid interface
71 /// </summary>
72 override public void Dispose()
73 {
74 database.Close();
75 }
76
77 /// <summary>
78 /// Returns the name of this grid interface
79 /// </summary>
80 /// <returns>A string containing the grid interface</returns>
81 override public string Name
82 {
83 get { return "SQLite OpenGridData"; }
84 }
85
86 /// <summary>
87 /// Returns the version of this grid interface
88 /// </summary>
89 /// <returns>A string containing the version</returns>
90 override public string Version
91 {
92 get { return "0.1"; }
93 }
94
95 /// <summary>
96 /// Returns a list of regions within the specified ranges
97 /// </summary>
98 /// <param name="a">minimum X coordinate</param>
99 /// <param name="b">minimum Y coordinate</param>
100 /// <param name="c">maximum X coordinate</param>
101 /// <param name="d">maximum Y coordinate</param>
102 /// <returns>An array of region profiles</returns>
103 /// <remarks>NOT IMPLEMENTED ? always return null</remarks>
104 override public RegionProfileData[] GetProfilesInRange(uint a, uint b, uint c, uint d)
105 {
106 return null;
107 }
108
109
110 /// <summary>
111 /// Returns up to maxNum profiles of regions that have a name starting with namePrefix
112 /// </summary>
113 /// <param name="name">The name to match against</param>
114 /// <param name="maxNum">Maximum number of profiles to return</param>
115 /// <returns>A list of sim profiles</returns>
116 override public List<RegionProfileData> GetRegionsByName (string namePrefix, uint maxNum)
117 {
118 return null;
119 }
120
121 /// <summary>
122 /// Returns a sim profile from it's handle
123 /// </summary>
124 /// <param name="handle">Region location handle</param>
125 /// <returns>Sim profile</returns>
126 override public RegionProfileData GetProfileByHandle(ulong handle)
127 {
128 Dictionary<string, string> param = new Dictionary<string, string>();
129 param["handle"] = handle.ToString();
130
131 IDbCommand result = database.Query("SELECT * FROM regions WHERE handle = @handle", param);
132 IDataReader reader = result.ExecuteReader();
133
134 RegionProfileData row = database.getRow(reader);
135 reader.Close();
136 result.Dispose();
137
138 return row;
139 }
140
141 /// <summary>
142 /// Returns a sim profile from it's Region name string
143 /// </summary>
144 /// <param name="regionName">The region name search query</param>
145 /// <returns>The sim profile</returns>
146 override public RegionProfileData GetProfileByString(string regionName)
147 {
148 if (regionName.Length > 2)
149 {
150 Dictionary<string, string> param = new Dictionary<string, string>();
151 // Add % because this is a like query.
152 param["?regionName"] = regionName + "%";
153 // Only returns one record or no record.
154 IDbCommand result = database.Query("SELECT * FROM regions WHERE regionName like ?regionName LIMIT 1", param);
155 IDataReader reader = result.ExecuteReader();
156
157 RegionProfileData row = database.getRow(reader);
158 reader.Close();
159 result.Dispose();
160
161 return row;
162 }
163 else
164 {
165 //m_log.Error("[DATABASE]: Searched for a Region Name shorter then 3 characters");
166 return null;
167 }
168 }
169
170 /// <summary>
171 /// Returns a sim profile from it's UUID
172 /// </summary>
173 /// <param name="uuid">The region UUID</param>
174 /// <returns>The sim profile</returns>
175 override public RegionProfileData GetProfileByUUID(UUID uuid)
176 {
177 Dictionary<string, string> param = new Dictionary<string, string>();
178 param["uuid"] = uuid.ToString();
179
180 IDbCommand result = database.Query("SELECT * FROM regions WHERE uuid = @uuid", param);
181 IDataReader reader = result.ExecuteReader();
182
183 RegionProfileData row = database.getRow(reader);
184 reader.Close();
185 result.Dispose();
186
187 return row;
188 }
189
190 /// <summary>
191 /// Returns a list of avatar and UUIDs that match the query
192 /// </summary>
193 /// <remarks>do nothing yet</remarks>
194 public List<AvatarPickerAvatar> GeneratePickerResults(UUID queryID, string query)
195 {
196 //Do nothing yet
197 List<AvatarPickerAvatar> returnlist = new List<AvatarPickerAvatar>();
198 return returnlist;
199 }
200
201 /// <summary>
202 /// Adds a new specified region to the database
203 /// </summary>
204 /// <param name="profile">The profile to add</param>
205 /// <returns>A dataresponse enum indicating success</returns>
206 override public DataResponse StoreProfile(RegionProfileData profile)
207 {
208 if (database.insertRow(profile))
209 {
210 return DataResponse.RESPONSE_OK;
211 }
212 else
213 {
214 return DataResponse.RESPONSE_ERROR;
215 }
216 }
217
218 /// <summary>
219 /// Deletes a sim profile from the database
220 /// </summary>
221 /// <param name="uuid">the sim UUID</param>
222 /// <returns>Successful?</returns>
223 override public DataResponse DeleteProfile(string uuid)
224 {
225 Dictionary<string, string> param = new Dictionary<string, string>();
226 param["uuid"] = uuid;
227
228 IDbCommand result = database.Query("DELETE FROM regions WHERE uuid = @uuid", param);
229 if (result.ExecuteNonQuery() > 0)
230 {
231 return DataResponse.RESPONSE_OK;
232 }
233 return DataResponse.RESPONSE_ERROR;
234 }
235
236 /// <summary>
237 /// DEPRECATED. Attempts to authenticate a region by comparing a shared secret.
238 /// </summary>
239 /// <param name="uuid">The UUID of the challenger</param>
240 /// <param name="handle">The attempted regionHandle of the challenger</param>
241 /// <param name="authkey">The secret</param>
242 /// <returns>Whether the secret and regionhandle match the database entry for UUID</returns>
243 override public bool AuthenticateSim(UUID uuid, ulong handle, string authkey)
244 {
245 bool throwHissyFit = false; // Should be true by 1.0
246
247 if (throwHissyFit)
248 throw new Exception("CRYPTOWEAK AUTHENTICATE: Refusing to authenticate due to replay potential.");
249
250 RegionProfileData data = GetProfileByUUID(uuid);
251
252 return (handle == data.regionHandle && authkey == data.regionSecret);
253 }
254
255 /// <summary>
256 /// NOT YET FUNCTIONAL. Provides a cryptographic authentication of a region
257 /// </summary>
258 /// <remarks>This requires a security audit.</remarks>
259 /// <param name="uuid"></param>
260 /// <param name="handle"></param>
261 /// <param name="authhash"></param>
262 /// <param name="challenge"></param>
263 /// <returns></returns>
264 public bool AuthenticateSim(UUID uuid, ulong handle, string authhash, string challenge)
265 {
266 // SHA512Managed HashProvider = new SHA512Managed();
267 // Encoding TextProvider = new UTF8Encoding();
268
269 // byte[] stream = TextProvider.GetBytes(uuid.ToString() + ":" + handle.ToString() + ":" + challenge);
270 // byte[] hash = HashProvider.ComputeHash(stream);
271
272 return false;
273 }
274
275 /// <summary>
276 /// NOT IMPLEMENTED
277 /// </summary>
278 /// <param name="x">x coordinate</param>
279 /// <param name="y">y coordinate</param>
280 /// <returns>always return null</returns>
281 override public ReservationData GetReservationAtPoint(uint x, uint y)
282 {
283 return null;
284 }
285 }
286}