aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/MySQL/MySQLAuthenticationData.cs
diff options
context:
space:
mode:
authorTeravus Ovares (Dan Olivares)2009-09-04 04:26:14 -0400
committerTeravus Ovares (Dan Olivares)2009-09-04 04:26:14 -0400
commitd49ee1f8ab34a4328adacbedf5daec7b25d0df14 (patch)
tree771f738ab34d0a7c66ca69f31ba23d42ffab666e /OpenSim/Data/MySQL/MySQLAuthenticationData.cs
parent* Make the RegionCombinerModule also register to handle permissions for the v... (diff)
parentpreparing LandData seriali(s|z)ation into OAR [not yet functional] (diff)
downloadopensim-SC_OLD-d49ee1f8ab34a4328adacbedf5daec7b25d0df14.zip
opensim-SC_OLD-d49ee1f8ab34a4328adacbedf5daec7b25d0df14.tar.gz
opensim-SC_OLD-d49ee1f8ab34a4328adacbedf5daec7b25d0df14.tar.bz2
opensim-SC_OLD-d49ee1f8ab34a4328adacbedf5daec7b25d0df14.tar.xz
Merge branch 'master' of ssh://MyConnection/var/git/opensim
Diffstat (limited to 'OpenSim/Data/MySQL/MySQLAuthenticationData.cs')
-rw-r--r--OpenSim/Data/MySQL/MySQLAuthenticationData.cs55
1 files changed, 55 insertions, 0 deletions
diff --git a/OpenSim/Data/MySQL/MySQLAuthenticationData.cs b/OpenSim/Data/MySQL/MySQLAuthenticationData.cs
index 19575ec..afd59bd 100644
--- a/OpenSim/Data/MySQL/MySQLAuthenticationData.cs
+++ b/OpenSim/Data/MySQL/MySQLAuthenticationData.cs
@@ -39,11 +39,15 @@ namespace OpenSim.Data.MySQL
39 { 39 {
40 private string m_Realm; 40 private string m_Realm;
41 private List<string> m_ColumnNames = null; 41 private List<string> m_ColumnNames = null;
42 private int m_LastExpire = 0;
42 43
43 public MySqlAuthenticationData(string connectionString, string realm) 44 public MySqlAuthenticationData(string connectionString, string realm)
44 : base(connectionString) 45 : base(connectionString)
45 { 46 {
46 m_Realm = realm; 47 m_Realm = realm;
48
49 Migration m = new Migration(m_Connection, GetType().Assembly, "AuthStore");
50 m.Update();
47 } 51 }
48 52
49 public AuthenticationData Get(UUID principalID) 53 public AuthenticationData Get(UUID principalID)
@@ -153,5 +157,56 @@ namespace OpenSim.Data.MySQL
153 157
154 return false; 158 return false;
155 } 159 }
160
161 public bool SetToken(UUID principalID, string token, int lifetime)
162 {
163 if (System.Environment.TickCount - m_LastExpire > 30000)
164 DoExpire();
165
166 MySqlCommand cmd = new MySqlCommand("insert into tokens (UUID, token, validity) values (?principalID, ?token, date_add(now(), interval ?lifetime minute))");
167 cmd.Parameters.AddWithValue("?principalID", principalID.ToString());
168 cmd.Parameters.AddWithValue("?token", token);
169 cmd.Parameters.AddWithValue("?lifetime", lifetime.ToString());
170
171 if (ExecuteNonQuery(cmd) > 0)
172 {
173 cmd.Dispose();
174 return true;
175 }
176
177 cmd.Dispose();
178 return false;
179 }
180
181 public bool CheckToken(UUID principalID, string token, int lifetime)
182 {
183 if (System.Environment.TickCount - m_LastExpire > 30000)
184 DoExpire();
185
186 MySqlCommand cmd = new MySqlCommand("update tokens set validity = date_add(now(), interval ?lifetime minute) where UUID = ?principalID and token = ?token and validity > now()");
187 cmd.Parameters.AddWithValue("?principalID", principalID.ToString());
188 cmd.Parameters.AddWithValue("?token", token);
189 cmd.Parameters.AddWithValue("?lifetime", lifetime.ToString());
190
191 if (ExecuteNonQuery(cmd) > 0)
192 {
193 cmd.Dispose();
194 return true;
195 }
196
197 cmd.Dispose();
198
199 return false;
200 }
201
202 private void DoExpire()
203 {
204 MySqlCommand cmd = new MySqlCommand("delete from tokens where validity < now()");
205 ExecuteNonQuery(cmd);
206
207 cmd.Dispose();
208
209 m_LastExpire = System.Environment.TickCount;
210 }
156 } 211 }
157} 212}