diff options
author | Kitto Flora | 2010-02-12 14:08:32 -0500 |
---|---|---|
committer | Kitto Flora | 2010-02-12 14:08:32 -0500 |
commit | 6a70349512a612948918db2f2f485e87b0bc87e6 (patch) | |
tree | bdbb11f3ec840c7a14402f0acdc302b04d5a0692 /OpenSim/Data/MySQL/MySQLAuthenticationData.cs | |
parent | Merge branch 'master' of ssh://3dhosting.de/var/git/careminster (diff) | |
parent | Resolve a merge issue (diff) | |
download | opensim-SC-6a70349512a612948918db2f2f485e87b0bc87e6.zip opensim-SC-6a70349512a612948918db2f2f485e87b0bc87e6.tar.gz opensim-SC-6a70349512a612948918db2f2f485e87b0bc87e6.tar.bz2 opensim-SC-6a70349512a612948918db2f2f485e87b0bc87e6.tar.xz |
Merge branch 'master' of ssh://3dhosting.de/var/git/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) |