Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Made things threadsafe as they should have been to begin with. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | sourceforge |
Files: | files | file ages | folders |
SHA1: |
e5c3ca2b22f1347a2ba6f288bd9efd2c |
User & Date: | jeffreyabecker 2006-03-02 02:34:23 |
Context
2006-03-02
| ||
18:02 | 1.0.27.1 check-in: bd1f4f5d01 user: rmsimpson tags: sourceforge | |
02:34 | Made things threadsafe as they should have been to begin with. check-in: e5c3ca2b22 user: jeffreyabecker tags: sourceforge | |
2006-03-01
| ||
22:40 | updated membership to have sane defaults check-in: de05d61657 user: jeffreyabecker tags: sourceforge | |
Changes
Changes to Membership/MembershipProvider/Initialize.cs.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
namespace SQLiteProvider { public sealed partial class SQLiteMembershipProvider : MembershipProvider { public override void Initialize(string name, NameValueCollection config) { // // Initialize values from web.config. // if (config == null) throw new ArgumentNullException("config"); if (name == null || name.Length == 0) name = "SQLiteMembershipProvider"; if (String.IsNullOrEmpty(config["description"])) { config.Remove("description"); config.Add("description", "SQLite Membership provider"); } // Initialize the abstract base class. base.Initialize(name, config); _MaxInvalidPasswordAttempts = Convert.ToInt32(GetConfigValue(config["maxInvalidPasswordAttempts"], "5")); _PasswordAttemptWindow = Convert.ToInt32(GetConfigValue(config["passwordAttemptWindow"], "10")); _MinRequiredNonAlphanumericCharacters = Convert.ToInt32(GetConfigValue(config["minRequiredNonAlphanumericCharacters"], "1")); _MinRequiredPasswordLength = Convert.ToInt32(GetConfigValue(config["minRequiredPasswordLength"], "7")); _PasswordStrengthRegularExpression = Convert.ToString(GetConfigValue(config["passwordStrengthRegularExpression"], "")); _EnablePasswordReset = Convert.ToBoolean(GetConfigValue(config["enablePasswordReset"], "true")); _EnablePasswordRetrieval = Convert.ToBoolean(GetConfigValue(config["enablePasswordRetrieval"], "false")); _RequiresQuestionAndAnswer = Convert.ToBoolean(GetConfigValue(config["requiresQuestionAndAnswer"], "false")); _RequiresUniqueEmail = Convert.ToBoolean(GetConfigValue(config["requiresUniqueEmail"], "true")); string temp_format = config["passwordFormat"]; if (temp_format == null) { temp_format = "Hashed"; } switch (temp_format) { case "Hashed": _PasswordFormat = MembershipPasswordFormat.Hashed; break; case "Encrypted": _PasswordFormat = MembershipPasswordFormat.Encrypted; break; case "Clear": _PasswordFormat = MembershipPasswordFormat.Clear; break; default: throw new ProviderException("Password format not supported."); } _WriteExceptionsToEventLog = ProviderUtility.GetExceptionDesitination(config["writeExceptionsToEventLog"]); connectionString = ProviderUtility.GetConnectionString(config["connectionStringName"]); ApplicationName = ProviderUtility.GetApplicationName(config["applicationName"]); // Get encryption and decryption key information from the configuration. Configuration cfg = WebConfigurationManager.OpenWebConfiguration(System.Web.Hosting.HostingEnvironment.ApplicationVirtualPath); machineKey = (MachineKeySection)cfg.GetSection("system.web/machineKey"); if (machineKey.ValidationKey.Contains("AutoGenerate")) if (PasswordFormat != MembershipPasswordFormat.Clear) throw new ProviderException("Hashed or Encrypted passwords " + "are not supported with auto-generated keys."); // Application Name has to be last since we use it to get our AppID this.ApplicationName = GetConfigValue(config["applicationName"], System.Web.Hosting.HostingEnvironment.ApplicationVirtualPath); } // // A helper function to retrieve config values from the configuration file. // private string GetConfigValue(string configValue, string defaultValue) { if (String.IsNullOrEmpty(configValue)) return defaultValue; return configValue; } } } |
> > > > > | < < < > | > | | | | | | | | | | | | | | | | | | | | | < < | < > > > > | > | < < < < < < < < < < < < | | > | | | | | | | | | | < > | < < < > | | > > > | > > > > > > > > > > > > > |
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
namespace SQLiteProvider { public sealed partial class SQLiteMembershipProvider : MembershipProvider { private bool _initialized = false; private Object _InitLock = new Object(); public override void Initialize(string name, NameValueCollection config) { bool te = _initialized; if (te) return; lock (_InitLock) { if (config == null) throw new ArgumentNullException("config"); if (name == null || name.Length == 0) name = "SQLiteMembershipProvider"; if (String.IsNullOrEmpty(config["description"])) { config.Remove("description"); config.Add("description", "SQLite Membership provider"); } // Initialize the abstract base class. base.Initialize(name, config); _MaxInvalidPasswordAttempts = ConfigAsInt32(config["maxInvalidPasswordAttempts"], 5); _PasswordAttemptWindow = ConfigAsInt32(config["passwordAttemptWindow"], 10); _MinRequiredNonAlphanumericCharacters = ConfigAsInt32(config["minRequiredNonAlphanumericCharacters"], 0); _MinRequiredPasswordLength = ConfigAsInt32(config["minRequiredPasswordLength"], 7); _PasswordStrengthRegularExpression = ConfigAsString(config["passwordStrengthRegularExpression"], ""); _EnablePasswordReset = ConfigAsBoolean(config["enablePasswordReset"], true); _EnablePasswordRetrieval = ConfigAsBoolean(config["enablePasswordRetrieval"], false); _RequiresQuestionAndAnswer = ConfigAsBoolean(config["requiresQuestionAndAnswer"], false); _RequiresUniqueEmail = ConfigAsBoolean(config["requiresUniqueEmail"], true); string temp_format = Convert.ToString(ConfigAsString(config["passwordFormat"], "Hashed")); try { _PasswordFormat = (MembershipPasswordFormat)Enum.Parse(MembershipPasswordFormat, temp_format); } catch { throw new ProviderException("Invalid Password Format."); } _WriteExceptionsToEventLog = ProviderUtility.GetExceptionDesitination(config["writeExceptionsToEventLog"]); connectionString = ProviderUtility.GetConnectionString(config["connectionStringName"]); ApplicationName = ProviderUtility.GetApplicationName(config["applicationName"]); // Get encryption and decryption key information from the configuration. Configuration cfg = WebConfigurationManager.OpenWebConfiguration(System.Web.Hosting.HostingEnvironment.ApplicationVirtualPath); machineKey = (MachineKeySection)cfg.GetSection("system.web/machineKey"); if (machineKey.ValidationKey.Contains("AutoGenerate")) if (PasswordFormat != MembershipPasswordFormat.Clear) throw new ProviderException("Hashed or Encrypted passwords are not supported with auto-generated keys."); _initialized = true; } } // // A helper function to retrieve config values from the configuration file. // private string ConfigAsString(string configValue, string defaultValue) { if (String.IsNullOrEmpty(configValue)) return defaultValue; return configValue; } private bool ConfigAsBoolean(string configValue, bool defaultValue){ if (String.IsNullOrEmpty(configValue)) return defaultValue; return Convert.ToBoolean(configValue); } private Int32 ConfigAsInt32(string configValue, int defaultValue) { if (String.IsNullOrEmpty(configValue)) return defaultValue; return Convert.ToInt32(configValue); } } } |
Changes to Membership/MembershipProvider/ProviderProperties.cs.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
namespace SQLiteProvider { public sealed partial class SQLiteMembershipProvider : MembershipProvider { public override string ApplicationName { get { return _ApplicationName; } set { _ApplicationName = value; _AppID = ProviderUtility.GetApplicationID(connectionString, value); } } public override bool EnablePasswordReset { get { return _EnablePasswordReset; } } |
> > > | | > |
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
namespace SQLiteProvider { public sealed partial class SQLiteMembershipProvider : MembershipProvider { private Object _appLock = new Object(); public override string ApplicationName { get { return _ApplicationName; } set { lock (_appLock) { _ApplicationName = value; _AppID = ProviderUtility.GetApplicationID(connectionString, value); } } } public override bool EnablePasswordReset { get { return _EnablePasswordReset; } } |
Changes to Membership/RoleProvider/RoleProvider.cs.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 ... 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 ... 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 ... 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 ... 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 ... 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 ... 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 ... 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 ... 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 ... 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 ... 566 567 568 569 570 571 572 573 574 575 576 577 578 579 |
public sealed partial class SQLiteRoleProvider : RoleProvider { private string eventSource = "SQLiteRoleProvider"; private string connectionString; private bool _WriteExceptionsToEventLog = false; private string _ApplicationName; private long _AppID; public bool WriteExceptionsToEventLog { get { return _WriteExceptionsToEventLog; } set { _WriteExceptionsToEventLog = value; } } // // System.Configuration.Provider.ProviderBase.Initialize Method // public override void Initialize(string name, NameValueCollection config) { // // Initialize values from web.config. // if (config == null) throw new ArgumentNullException("config"); if (name == null || name.Length == 0) name = "SQLiteRoleProvider"; if (String.IsNullOrEmpty(config["description"])) { config.Remove("description"); config.Add("description", "SQLite Role Privider"); } // Initialize the abstract base class. base.Initialize(name, config); _WriteExceptionsToEventLog = ProviderUtility.GetExceptionDesitination(config["writeExceptionsToEventLog"]); connectionString = ProviderUtility.GetConnectionString(config["connectionStringName"]); ApplicationName = ProviderUtility.GetApplicationName(config["applicationName"]); } // // System.Web.Security.RoleProvider properties. // public override string ApplicationName { get { return _ApplicationName; } set { _ApplicationName = value; _AppID = ProviderUtility.GetApplicationID(connectionString, value); } } // // System.Web.Security.RoleProvider methods. // // // RoleProvider.AddUsersToRoles // public override void AddUsersToRoles(string[] usernames, string[] rolenames) { foreach (string rolename in rolenames) { if (!RoleExists(rolename)) { throw new ProviderException("Role name not found."); } } foreach (string username in usernames) { if (username.IndexOf(',') > 0) { throw new ArgumentException("User names cannot contain commas."); } foreach (string rolename in rolenames) { if (IsUserInRole(username, rolename)) { throw new ProviderException("User is already in role."); } } ................................................................................ } finally { conn.Close(); } } // // RoleProvider.CreateRole // public override void CreateRole(string rolename) { if (rolename.IndexOf(',') > 0) { throw new ArgumentException("Role names cannot contain commas."); } if (RoleExists(rolename)) { throw new ProviderException("Role name already exists."); } SQLiteConnection conn = new SQLiteConnection(connectionString); SQLiteCommand cmd = new SQLiteCommand(RoleSql.CreateRole, conn); ................................................................................ } finally { conn.Close(); } } // // RoleProvider.DeleteRole // public override bool DeleteRole(string rolename, bool throwOnPopulatedRole) { if (!RoleExists(rolename)) { throw new ProviderException("Role does not exist."); } ................................................................................ finally { conn.Close(); } return true; } // // RoleProvider.GetAllRoles // public override string[] GetAllRoles() { List<String> names = new List<string>(); SQLiteConnection conn = new SQLiteConnection(connectionString); SQLiteCommand cmd = new SQLiteCommand(RoleSql.GetAllRoles, conn); cmd.Parameters.Add("$AppID", DbType.Int64).Value = _AppID; ................................................................................ if (reader != null) { reader.Close(); } conn.Close(); } return names.ToArray(); } // // RoleProvider.GetRolesForUser // public override string[] GetRolesForUser(string username) { List<string> roles = new List<string>(); SQLiteConnection conn = new SQLiteConnection(connectionString); SQLiteCommand cmd = new SQLiteCommand(RoleSql.GetRolesForUser, conn); ................................................................................ if (reader != null) { reader.Close(); } conn.Close(); } return roles.ToArray(); } // // RoleProvider.GetUsersInRole // public override string[] GetUsersInRole(string rolename) { List<String> users = new List<string>(); SQLiteConnection conn = new SQLiteConnection(connectionString); SQLiteCommand cmd = new SQLiteCommand(RoleSql.GetUsersInRole, conn); ................................................................................ finally { if (reader != null) { reader.Close(); } conn.Close(); } return users.ToArray(); } // // RoleProvider.IsUserInRole // public override bool IsUserInRole(string username, string rolename) { long count = 0; SQLiteConnection conn = new SQLiteConnection(connectionString); SQLiteCommand cmd = new SQLiteCommand(RoleSql.IsUserInRole, conn); ................................................................................ finally { conn.Close(); } return (count != 0); } // // RoleProvider.RemoveUsersFromRoles // public override void RemoveUsersFromRoles(string[] usernames, string[] rolenames) { foreach (string rolename in rolenames) { if (!RoleExists(rolename)) { throw new ProviderException("Role name not found."); ................................................................................ } finally { conn.Close(); } } // // RoleProvider.RoleExists // public override bool RoleExists(string rolename) { long count = 0; SQLiteConnection conn = new SQLiteConnection(connectionString); SQLiteCommand cmd = new SQLiteCommand(RoleSql.RoleExists, conn); ................................................................................ finally { conn.Close(); } return (count != 0); } // // RoleProvider.FindUsersInRole // public override string[] FindUsersInRole(string rolename, string usernameToMatch) { SQLiteConnection conn = new SQLiteConnection(connectionString); SQLiteCommand cmd = new SQLiteCommand(RoleSql.FindUsersInRole, conn); cmd.Parameters.Add("$Username", DbType.String).Value = usernameToMatch; cmd.Parameters.Add("$Rolename", DbType.String).Value = rolename; cmd.Parameters.Add("$AppID", DbType.Int64).Value = _AppID; ................................................................................ if (reader != null) { reader.Close(); } conn.Close(); } return users.ToArray(); } } } |
< < > > > > < > | < < > > | < < > | < < < < | | | | | | | | | | | < < < < | | | > | | < < < < < < < < < < > > | | | | | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 ... 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 ... 167 168 169 170 171 172 173 174 175 176 177 178 179 180 ... 222 223 224 225 226 227 228 229 230 231 232 233 234 235 ... 256 257 258 259 260 261 262 263 264 265 266 267 268 269 ... 292 293 294 295 296 297 298 299 300 301 302 303 304 305 ... 326 327 328 329 330 331 332 333 334 335 336 337 338 339 ... 353 354 355 356 357 358 359 360 361 362 363 364 365 366 ... 417 418 419 420 421 422 423 424 425 426 427 428 429 430 ... 445 446 447 448 449 450 451 452 453 454 455 456 457 458 ... 481 482 483 484 485 486 487 488 489 490 491 492 |
public sealed partial class SQLiteRoleProvider : RoleProvider { private string eventSource = "SQLiteRoleProvider"; private string connectionString; private bool _WriteExceptionsToEventLog = false; private string _ApplicationName; private long _AppID; private bool _initialized = false; private object _InitLock = new Object(); private object _AppLock = new Object(); public bool WriteExceptionsToEventLog { get { return _WriteExceptionsToEventLog; } } public override void Initialize(string name, NameValueCollection config) { bool TempInit = _initialized; if (_initialized) return; lock (_InitLock) { if (config == null) throw new ArgumentNullException("config"); if (name == null || name.Length == 0) name = "SQLiteRoleProvider"; if (String.IsNullOrEmpty(config["description"])) { config.Remove("description"); config.Add("description", "SQLite Role Privider"); } // Initialize the abstract base class. base.Initialize(name, config); _WriteExceptionsToEventLog = ProviderUtility.GetExceptionDesitination(config["writeExceptionsToEventLog"]); connectionString = ProviderUtility.GetConnectionString(config["connectionStringName"]); ApplicationName = ProviderUtility.GetApplicationName(config["applicationName"]); _initialized = true; } } public override string ApplicationName { get { return _ApplicationName; } set { lock (_AppLock) { _ApplicationName = value; _AppID = ProviderUtility.GetApplicationID(connectionString, value); } } } public override void AddUsersToRoles(string[] usernames, string[] rolenames) { foreach (string rolename in rolenames) { if (!RoleExists(rolename)) { throw new ProviderException("Role name not found."); } } foreach (string username in usernames) { foreach (string rolename in rolenames) { if (IsUserInRole(username, rolename)) { throw new ProviderException("User is already in role."); } } ................................................................................ } finally { conn.Close(); } } public override void CreateRole(string rolename) { if (RoleExists(rolename)) { throw new ProviderException("Role name already exists."); } SQLiteConnection conn = new SQLiteConnection(connectionString); SQLiteCommand cmd = new SQLiteCommand(RoleSql.CreateRole, conn); ................................................................................ } finally { conn.Close(); } } public override bool DeleteRole(string rolename, bool throwOnPopulatedRole) { if (!RoleExists(rolename)) { throw new ProviderException("Role does not exist."); } ................................................................................ finally { conn.Close(); } return true; } public override string[] GetAllRoles() { List<String> names = new List<string>(); SQLiteConnection conn = new SQLiteConnection(connectionString); SQLiteCommand cmd = new SQLiteCommand(RoleSql.GetAllRoles, conn); cmd.Parameters.Add("$AppID", DbType.Int64).Value = _AppID; ................................................................................ if (reader != null) { reader.Close(); } conn.Close(); } return names.ToArray(); } public override string[] GetRolesForUser(string username) { List<string> roles = new List<string>(); SQLiteConnection conn = new SQLiteConnection(connectionString); SQLiteCommand cmd = new SQLiteCommand(RoleSql.GetRolesForUser, conn); ................................................................................ if (reader != null) { reader.Close(); } conn.Close(); } return roles.ToArray(); } public override string[] GetUsersInRole(string rolename) { List<String> users = new List<string>(); SQLiteConnection conn = new SQLiteConnection(connectionString); SQLiteCommand cmd = new SQLiteCommand(RoleSql.GetUsersInRole, conn); ................................................................................ finally { if (reader != null) { reader.Close(); } conn.Close(); } return users.ToArray(); } public override bool IsUserInRole(string username, string rolename) { long count = 0; SQLiteConnection conn = new SQLiteConnection(connectionString); SQLiteCommand cmd = new SQLiteCommand(RoleSql.IsUserInRole, conn); ................................................................................ finally { conn.Close(); } return (count != 0); } public override void RemoveUsersFromRoles(string[] usernames, string[] rolenames) { foreach (string rolename in rolenames) { if (!RoleExists(rolename)) { throw new ProviderException("Role name not found."); ................................................................................ } finally { conn.Close(); } } public override bool RoleExists(string rolename) { long count = 0; SQLiteConnection conn = new SQLiteConnection(connectionString); SQLiteCommand cmd = new SQLiteCommand(RoleSql.RoleExists, conn); ................................................................................ finally { conn.Close(); } return (count != 0); } public override string[] FindUsersInRole(string rolename, string usernameToMatch) { SQLiteConnection conn = new SQLiteConnection(connectionString); SQLiteCommand cmd = new SQLiteCommand(RoleSql.FindUsersInRole, conn); cmd.Parameters.Add("$Username", DbType.String).Value = usernameToMatch; cmd.Parameters.Add("$Rolename", DbType.String).Value = rolename; cmd.Parameters.Add("$AppID", DbType.Int64).Value = _AppID; ................................................................................ if (reader != null) { reader.Close(); } conn.Close(); } return users.ToArray(); } } } |
Changes to Membership/SQLiteProvider.suo.
cannot compute difference between binary files