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