diff options
author | Melanie | 2009-09-04 03:13:32 +0100 |
---|---|---|
committer | Melanie | 2009-09-04 03:13:32 +0100 |
commit | c9a24ece546fb20977d27abef736cd5e45d976e2 (patch) | |
tree | 65a1a6079ad2f904f770670fc0d9e64849e362c3 | |
parent | Flech out the Authentication service. Add the database loader. Introduce (diff) | |
download | opensim-SC_OLD-c9a24ece546fb20977d27abef736cd5e45d976e2.zip opensim-SC_OLD-c9a24ece546fb20977d27abef736cd5e45d976e2.tar.gz opensim-SC_OLD-c9a24ece546fb20977d27abef736cd5e45d976e2.tar.bz2 opensim-SC_OLD-c9a24ece546fb20977d27abef736cd5e45d976e2.tar.xz |
More work on new authentication service
Diffstat (limited to '')
5 files changed, 42 insertions, 17 deletions
diff --git a/OpenSim/Data/MySQL/MySQLAuthenticationData.cs b/OpenSim/Data/MySQL/MySQLAuthenticationData.cs index 625d3b1..19575ec 100644 --- a/OpenSim/Data/MySQL/MySQLAuthenticationData.cs +++ b/OpenSim/Data/MySQL/MySQLAuthenticationData.cs | |||
@@ -38,7 +38,7 @@ 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 DataTable m_SchemaTable = null; | 41 | private List<string> m_ColumnNames = null; |
42 | 42 | ||
43 | public MySqlAuthenticationData(string connectionString, string realm) | 43 | public MySqlAuthenticationData(string connectionString, string realm) |
44 | : base(connectionString) | 44 | : base(connectionString) |
@@ -63,15 +63,21 @@ namespace OpenSim.Data.MySQL | |||
63 | { | 63 | { |
64 | ret.PrincipalID = principalID; | 64 | ret.PrincipalID = principalID; |
65 | 65 | ||
66 | if (m_SchemaTable == null) | 66 | if (m_ColumnNames == null) |
67 | m_SchemaTable = result.GetSchemaTable(); | 67 | { |
68 | m_ColumnNames = new List<string>(); | ||
69 | |||
70 | DataTable schemaTable = result.GetSchemaTable(); | ||
71 | foreach (DataRow row in schemaTable.Rows) | ||
72 | m_ColumnNames.Add(row["ColumnName"].ToString()); | ||
73 | } | ||
68 | 74 | ||
69 | foreach (DataColumn c in m_SchemaTable.Columns) | 75 | foreach (string s in m_ColumnNames) |
70 | { | 76 | { |
71 | if (c.ColumnName == "UUID") | 77 | if (s == "UUID") |
72 | continue; | 78 | continue; |
73 | 79 | ||
74 | ret.Data[c.ColumnName] = result[c.ColumnName].ToString(); | 80 | ret.Data[s] = result[s].ToString(); |
75 | } | 81 | } |
76 | 82 | ||
77 | result.Close(); | 83 | result.Close(); |
@@ -105,21 +111,23 @@ namespace OpenSim.Data.MySQL | |||
105 | 111 | ||
106 | first = false; | 112 | first = false; |
107 | 113 | ||
108 | cmd.Parameters.AddWithValue(field, data.Data[field]); | 114 | cmd.Parameters.AddWithValue("?"+field, data.Data[field]); |
109 | } | 115 | } |
110 | 116 | ||
111 | update += " where UUID = ?principalID"; | 117 | update += " where UUID = ?principalID"; |
112 | 118 | ||
113 | cmd.CommandText = update; | 119 | cmd.CommandText = update; |
114 | cmd.Parameters.AddWithValue("UUID", data.PrincipalID.ToString()); | 120 | cmd.Parameters.AddWithValue("?principalID", data.PrincipalID.ToString()); |
115 | 121 | ||
116 | if (ExecuteNonQuery(cmd) < 1) | 122 | if (ExecuteNonQuery(cmd) < 1) |
117 | { | 123 | { |
118 | string insert = "insert into `" + m_Realm + "` (`UUID`, `" + | 124 | string insert = "insert into `" + m_Realm + "` (`UUID`, `" + |
119 | String.Join("`, `", fields) + | 125 | String.Join("`, `", fields) + |
120 | "`) values ( ?UUID, ?" + String.Join(", ?", fields) + ")"; | 126 | "`) values ( ?principalID, ?" + String.Join(", ?", fields) + ")"; |
121 | 127 | ||
122 | if (ExecuteNonQuery(cmd) < 0) | 128 | cmd.CommandText = insert; |
129 | |||
130 | if (ExecuteNonQuery(cmd) < 1) | ||
123 | { | 131 | { |
124 | cmd.Dispose(); | 132 | cmd.Dispose(); |
125 | return false; | 133 | return false; |
@@ -137,8 +145,11 @@ namespace OpenSim.Data.MySQL | |||
137 | "` set `" + item + "` = ?" + item + " where UUID = ?UUID"); | 145 | "` set `" + item + "` = ?" + item + " where UUID = ?UUID"); |
138 | 146 | ||
139 | 147 | ||
140 | cmd.Parameters.AddWithValue(item, value); | 148 | cmd.Parameters.AddWithValue("?"+item, value); |
141 | cmd.Parameters.AddWithValue("UUID", principalID.ToString()); | 149 | cmd.Parameters.AddWithValue("?UUID", principalID.ToString()); |
150 | |||
151 | if (ExecuteNonQuery(cmd) > 0) | ||
152 | return true; | ||
142 | 153 | ||
143 | return false; | 154 | return false; |
144 | } | 155 | } |
diff --git a/OpenSim/Data/MySQL/MySQLFramework.cs b/OpenSim/Data/MySQL/MySQLFramework.cs index f2b31c4..6c73249 100644 --- a/OpenSim/Data/MySQL/MySQLFramework.cs +++ b/OpenSim/Data/MySQL/MySQLFramework.cs | |||
@@ -70,6 +70,7 @@ namespace OpenSim.Data.MySQL | |||
70 | } | 70 | } |
71 | catch (MySqlException e) | 71 | catch (MySqlException e) |
72 | { | 72 | { |
73 | Console.WriteLine(e.ToString()); | ||
73 | if (errorSeen) | 74 | if (errorSeen) |
74 | throw; | 75 | throw; |
75 | 76 | ||
@@ -88,6 +89,13 @@ namespace OpenSim.Data.MySQL | |||
88 | 89 | ||
89 | cmd.Connection = m_Connection; | 90 | cmd.Connection = m_Connection; |
90 | } | 91 | } |
92 | else | ||
93 | throw; | ||
94 | } | ||
95 | catch (Exception e) | ||
96 | { | ||
97 | Console.WriteLine(e.ToString()); | ||
98 | return 0; | ||
91 | } | 99 | } |
92 | } | 100 | } |
93 | } | 101 | } |
diff --git a/OpenSim/Server/Handlers/Authentication/AuthenticationServerConnector.cs b/OpenSim/Server/Handlers/Authentication/AuthenticationServerConnector.cs index c3c2f69..03a7980 100644 --- a/OpenSim/Server/Handlers/Authentication/AuthenticationServerConnector.cs +++ b/OpenSim/Server/Handlers/Authentication/AuthenticationServerConnector.cs | |||
@@ -36,7 +36,7 @@ namespace OpenSim.Server.Handlers.Authentication | |||
36 | { | 36 | { |
37 | public class AuthenticationServiceConnector : ServiceConnector | 37 | public class AuthenticationServiceConnector : ServiceConnector |
38 | { | 38 | { |
39 | //private IAuthenticationService m_AuthenticationService; | 39 | private IAuthenticationService m_AuthenticationService; |
40 | 40 | ||
41 | public AuthenticationServiceConnector(IConfigSource config, IHttpServer server) : | 41 | public AuthenticationServiceConnector(IConfigSource config, IHttpServer server) : |
42 | base(config, server) | 42 | base(config, server) |
@@ -51,8 +51,8 @@ namespace OpenSim.Server.Handlers.Authentication | |||
51 | if (authenticationService == String.Empty) | 51 | if (authenticationService == String.Empty) |
52 | throw new Exception("No AuthenticationService in config file"); | 52 | throw new Exception("No AuthenticationService in config file"); |
53 | 53 | ||
54 | //Object[] args = new Object[] { config }; | 54 | Object[] args = new Object[] { config }; |
55 | //m_AuthenticationService = ServerUtils.LoadPlugin<IAuthenticationService>(authenticationService, args); | 55 | m_AuthenticationService = ServerUtils.LoadPlugin<IAuthenticationService>(authenticationService, args); |
56 | 56 | ||
57 | //server.AddStreamHandler(new AuthenticationServerGetHandler(m_AuthenticationService)); | 57 | //server.AddStreamHandler(new AuthenticationServerGetHandler(m_AuthenticationService)); |
58 | } | 58 | } |
diff --git a/OpenSim/Services/AuthenticationService/AuthenticationServiceBase.cs b/OpenSim/Services/AuthenticationService/AuthenticationServiceBase.cs index 57d0300..200268b 100644 --- a/OpenSim/Services/AuthenticationService/AuthenticationServiceBase.cs +++ b/OpenSim/Services/AuthenticationService/AuthenticationServiceBase.cs | |||
@@ -53,6 +53,7 @@ namespace OpenSim.Services.AuthenticationService | |||
53 | { | 53 | { |
54 | string dllName = String.Empty; | 54 | string dllName = String.Empty; |
55 | string connString = String.Empty; | 55 | string connString = String.Empty; |
56 | string realm = String.Empty; | ||
56 | 57 | ||
57 | // | 58 | // |
58 | // Try reading the [AuthenticationService] section first, if it exists | 59 | // Try reading the [AuthenticationService] section first, if it exists |
@@ -62,6 +63,7 @@ namespace OpenSim.Services.AuthenticationService | |||
62 | { | 63 | { |
63 | dllName = authConfig.GetString("StorageProvider", dllName); | 64 | dllName = authConfig.GetString("StorageProvider", dllName); |
64 | connString = authConfig.GetString("ConnectionString", connString); | 65 | connString = authConfig.GetString("ConnectionString", connString); |
66 | realm = authConfig.GetString("Realm", realm); | ||
65 | } | 67 | } |
66 | 68 | ||
67 | // | 69 | // |
@@ -79,11 +81,11 @@ namespace OpenSim.Services.AuthenticationService | |||
79 | // | 81 | // |
80 | // We tried, but this doesn't exist. We can't proceed. | 82 | // We tried, but this doesn't exist. We can't proceed. |
81 | // | 83 | // |
82 | if (dllName.Equals(String.Empty)) | 84 | if (dllName == String.Empty || realm == String.Empty) |
83 | throw new Exception("No StorageProvider configured"); | 85 | throw new Exception("No StorageProvider configured"); |
84 | 86 | ||
85 | m_Database = LoadPlugin<IAuthenticationData>(dllName, | 87 | m_Database = LoadPlugin<IAuthenticationData>(dllName, |
86 | new Object[] {connString}); | 88 | new Object[] {connString, realm}); |
87 | if (m_Database == null) | 89 | if (m_Database == null) |
88 | throw new Exception("Could not find a storage interface in the given module"); | 90 | throw new Exception("Could not find a storage interface in the given module"); |
89 | } | 91 | } |
diff --git a/OpenSim/Services/AuthenticationService/PasswordAuthenticationService.cs b/OpenSim/Services/AuthenticationService/PasswordAuthenticationService.cs index 5c83299..83ce0d0 100644 --- a/OpenSim/Services/AuthenticationService/PasswordAuthenticationService.cs +++ b/OpenSim/Services/AuthenticationService/PasswordAuthenticationService.cs | |||
@@ -26,11 +26,15 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | ||
29 | using OpenMetaverse; | 30 | using OpenMetaverse; |
30 | using OpenSim.Services.Interfaces; | 31 | using OpenSim.Services.Interfaces; |
31 | using log4net; | 32 | using log4net; |
32 | using Nini.Config; | 33 | using Nini.Config; |
33 | using System.Reflection; | 34 | using System.Reflection; |
35 | using OpenSim.Data; | ||
36 | using OpenSim.Framework; | ||
37 | using OpenSim.Framework.Console; | ||
34 | 38 | ||
35 | namespace OpenSim.Services.AuthenticationService | 39 | namespace OpenSim.Services.AuthenticationService |
36 | { | 40 | { |