Unified · Split
| @@ -58,7 +58,6 @@ namespace GSF.Security · 57 unmodified lines | ||
| 58 | 58 | |
| 59 | 59 | //Constants |
| 60 | 60 | private const string SettingsCategory = "SecurityProvider"; |
| 61 | − private const string AlternateSettingsCategory = "AlternateSecurityProvider"; | |
| 62 | 61 | private const string DefaultProviderType = "GSF.Security.LdapSecurityProvider, GSF.Security"; |
| 63 | 62 | private const string DefaultIncludedResources = "*=*"; |
| 64 | 63 | private const string DefaultExcludedResources = ""; |
| @@ -75,7 +74,8 @@ namespace GSF.Security · 10 unmodified lines | ||
| 75 | 74 | private static readonly string s_notificationSmtpServer; |
| 76 | 75 | private static readonly string s_notificationSenderEmail; |
| 77 | 76 | |
| 78 | − private static Dictionary<string,Func<string, ISecurityProvider>> s_providerFactory; | |
| 77 | + private static Dictionary<string, Func<string, ISecurityProvider>> s_providerFactory; | |
| 78 | + private static readonly object s_providerFactoryLock = new object(); | |
| 79 | 79 | |
| 80 | 80 | // Static Constructor |
| 81 | 81 | static SecurityProviderUtility() |
| @@ -87,7 +87,7 @@ namespace GSF.Security · 5 unmodified lines | ||
| 87 | 87 | settings.Add("ExcludedResources", DefaultExcludedResources, "Semicolon delimited list of resources to be excluded from being secured."); |
| 88 | 88 | settings.Add("NotificationSmtpServer", DefaultNotificationSmtpServer, "SMTP server to be used for sending out email notification messages."); |
| 89 | 89 | settings.Add("NotificationSenderEmail", DefaultNotificationSenderEmail, "Email address of the sender of email notification messages."); |
| 90 | − | |
| 90 | + | |
| 91 | 91 | s_includedResources = settings["IncludedResources"].ValueAsString().ParseKeyValuePairs(); |
| 92 | 92 | s_excludedResources = settings["ExcludedResources"].ValueAsString().Split(';'); |
| 93 | 93 | s_notificationSmtpServer = settings["NotificationSmtpServer"].ValueAsString(); |
| @@ -150,7 +150,7 @@ namespace GSF.Security · 56 unmodified lines | ||
| 150 | 150 | /// </summary> |
| 151 | 151 | /// <param name="userData">Object that contains data about the user to be used by the security provider.</param> |
| 152 | 152 | /// <returns>An object that implements <see cref="ISecurityProvider"/>.</returns> |
| 153 | − public static ISecurityProvider CreateProvider(UserData userData, string settingsCategory=null) | |
| 153 | + public static ISecurityProvider CreateProvider(UserData userData, string settingsCategory = null) | |
| 154 | 154 | { |
| 155 | 155 | // Initialize the username |
| 156 | 156 | string username = userData.Username; |
| @@ -304,14 +304,16 @@ namespace GSF.Security · 147 unmodified lines | ||
| 304 | 304 | if (settingsCategory == null) |
| 305 | 305 | settingsCategory = SettingsCategory; |
| 306 | 306 | |
| 307 | − if (s_providerFactory is null) | |
| 308 | − s_providerFactory = new Dictionary<string, Func<string, ISecurityProvider>>() { }; | |
| 307 | + lock (s_providerFactoryLock) | |
| 308 | + { | |
| 309 | + if (s_providerFactory is null) | |
| 310 | + s_providerFactory = new Dictionary<string, Func<string, ISecurityProvider>>() { }; | |
| 309 | 311 | |
| 310 | − if (s_providerFactory.ContainsKey(settingsCategory)) | |
| 312 | + if (s_providerFactory.ContainsKey(settingsCategory)) | |
| 313 | + return s_providerFactory[settingsCategory]; | |
| 314 | + s_providerFactory.Add(settingsCategory, CreateSecurityProviderFactory(settingsCategory)); | |
| 311 | 315 | return s_providerFactory[settingsCategory]; |
| 312 | − s_providerFactory.Add(settingsCategory,CreateSecurityProviderFactory(settingsCategory)); | |
| 313 | − return s_providerFactory[settingsCategory]; | |
| 314 | − | |
| 316 | + } | |
| 315 | 317 | } |
| 316 | 318 | #endregion |
| 317 | 319 | } |