diff options
author | Melanie | 2010-02-08 22:11:38 +0000 |
---|---|---|
committer | Melanie | 2010-02-08 22:11:38 +0000 |
commit | c8f3bb56ff20493b9f51a123a1d89e876e0cab75 (patch) | |
tree | 0f878d1eb21f821f517ebe8170776023952e6e2c /OpenSim/Data/MySQL/MySQLAuthenticationData.cs | |
parent | Merge branch 'master' into careminster (diff) | |
parent | Merge branch 'master' of melanie@opensimulator.org:/var/git/opensim (diff) | |
download | opensim-SC_OLD-c8f3bb56ff20493b9f51a123a1d89e876e0cab75.zip opensim-SC_OLD-c8f3bb56ff20493b9f51a123a1d89e876e0cab75.tar.gz opensim-SC_OLD-c8f3bb56ff20493b9f51a123a1d89e876e0cab75.tar.bz2 opensim-SC_OLD-c8f3bb56ff20493b9f51a123a1d89e876e0cab75.tar.xz |
Merge branch 'master' into careminster
Diffstat (limited to 'OpenSim/Data/MySQL/MySQLAuthenticationData.cs')
-rw-r--r-- | OpenSim/Data/MySQL/MySQLAuthenticationData.cs | 71 |
1 files changed, 37 insertions, 34 deletions
diff --git a/OpenSim/Data/MySQL/MySQLAuthenticationData.cs b/OpenSim/Data/MySQL/MySQLAuthenticationData.cs index e508b52..5056aee 100644 --- a/OpenSim/Data/MySQL/MySQLAuthenticationData.cs +++ b/OpenSim/Data/MySQL/MySQLAuthenticationData.cs | |||
@@ -38,16 +38,22 @@ namespace OpenSim.Data.MySQL | |||
38 | public class MySqlAuthenticationData : MySqlFramework, IAuthenticationData | 38 | public class MySqlAuthenticationData : MySqlFramework, IAuthenticationData |
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; |
42 | private int m_LastExpire = 0; | 42 | private int m_LastExpire; |
43 | // private string m_connectionString; | ||
43 | 44 | ||
44 | public MySqlAuthenticationData(string connectionString, string realm) | 45 | public MySqlAuthenticationData(string connectionString, string realm) |
45 | : base(connectionString) | 46 | : base(connectionString) |
46 | { | 47 | { |
47 | m_Realm = realm; | 48 | m_Realm = realm; |
49 | m_connectionString = connectionString; | ||
48 | 50 | ||
49 | Migration m = new Migration(m_Connection, GetType().Assembly, "AuthStore"); | 51 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
50 | m.Update(); | 52 | { |
53 | dbcon.Open(); | ||
54 | Migration m = new Migration(dbcon, GetType().Assembly, "AuthStore"); | ||
55 | m.Update(); | ||
56 | } | ||
51 | } | 57 | } |
52 | 58 | ||
53 | public AuthenticationData Get(UUID principalID) | 59 | public AuthenticationData Get(UUID principalID) |
@@ -55,45 +61,42 @@ namespace OpenSim.Data.MySQL | |||
55 | AuthenticationData ret = new AuthenticationData(); | 61 | AuthenticationData ret = new AuthenticationData(); |
56 | ret.Data = new Dictionary<string, object>(); | 62 | ret.Data = new Dictionary<string, object>(); |
57 | 63 | ||
58 | MySqlCommand cmd = new MySqlCommand( | 64 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
59 | "select * from `"+m_Realm+"` where UUID = ?principalID" | ||
60 | ); | ||
61 | |||
62 | cmd.Parameters.AddWithValue("?principalID", principalID.ToString()); | ||
63 | |||
64 | IDataReader result = ExecuteReader(cmd); | ||
65 | |||
66 | if (result.Read()) | ||
67 | { | 65 | { |
68 | ret.PrincipalID = principalID; | 66 | dbcon.Open(); |
67 | MySqlCommand cmd = new MySqlCommand("select * from `" + m_Realm + "` where UUID = ?principalID", dbcon); | ||
68 | cmd.Parameters.AddWithValue("?principalID", principalID.ToString()); | ||
69 | 69 | ||
70 | if (m_ColumnNames == null) | 70 | IDataReader result = cmd.ExecuteReader(); |
71 | { | ||
72 | m_ColumnNames = new List<string>(); | ||
73 | 71 | ||
74 | DataTable schemaTable = result.GetSchemaTable(); | 72 | if (result.Read()) |
75 | foreach (DataRow row in schemaTable.Rows) | ||
76 | m_ColumnNames.Add(row["ColumnName"].ToString()); | ||
77 | } | ||
78 | |||
79 | foreach (string s in m_ColumnNames) | ||
80 | { | 73 | { |
81 | if (s == "UUID") | 74 | ret.PrincipalID = principalID; |
82 | continue; | ||
83 | 75 | ||
84 | ret.Data[s] = result[s].ToString(); | 76 | if (m_ColumnNames == null) |
85 | } | 77 | { |
78 | m_ColumnNames = new List<string>(); | ||
86 | 79 | ||
87 | result.Close(); | 80 | DataTable schemaTable = result.GetSchemaTable(); |
88 | CloseReaderCommand(cmd); | 81 | foreach (DataRow row in schemaTable.Rows) |
82 | m_ColumnNames.Add(row["ColumnName"].ToString()); | ||
83 | } | ||
89 | 84 | ||
90 | return ret; | 85 | foreach (string s in m_ColumnNames) |
91 | } | 86 | { |
87 | if (s == "UUID") | ||
88 | continue; | ||
92 | 89 | ||
93 | result.Close(); | 90 | ret.Data[s] = result[s].ToString(); |
94 | CloseReaderCommand(cmd); | 91 | } |
95 | 92 | ||
96 | return null; | 93 | return ret; |
94 | } | ||
95 | else | ||
96 | { | ||
97 | return null; | ||
98 | } | ||
99 | } | ||
97 | } | 100 | } |
98 | 101 | ||
99 | public bool Store(AuthenticationData data) | 102 | public bool Store(AuthenticationData data) |