From 6c86721f6de2acbe68e9419064ff21111ff3a223 Mon Sep 17 00:00:00 2001 From: LukePulverenti Date: Sat, 23 Feb 2013 17:44:42 -0500 Subject: [PATCH] placeholder for plugin security fix --- MediaBrowser.Common/Kernel/IKernel.cs | 5 +++ .../Plugins/PluginSecurityManager.cs | 40 +++++++++++++++---- 2 files changed, 38 insertions(+), 7 deletions(-) diff --git a/MediaBrowser.Common/Kernel/IKernel.cs b/MediaBrowser.Common/Kernel/IKernel.cs index 1685f1f648..253368f4ff 100644 --- a/MediaBrowser.Common/Kernel/IKernel.cs +++ b/MediaBrowser.Common/Kernel/IKernel.cs @@ -151,5 +151,10 @@ namespace MediaBrowser.Common.Kernel /// /// The rest services. IEnumerable RestServices { get; } + + /// + /// Notifies the pending restart. + /// + void NotifyPendingRestart(); } } diff --git a/MediaBrowser.Controller/Plugins/PluginSecurityManager.cs b/MediaBrowser.Controller/Plugins/PluginSecurityManager.cs index f559d1fd04..bac7c61357 100644 --- a/MediaBrowser.Controller/Plugins/PluginSecurityManager.cs +++ b/MediaBrowser.Controller/Plugins/PluginSecurityManager.cs @@ -1,5 +1,8 @@ using Mediabrowser.Model.Entities; using Mediabrowser.PluginSecurity; +using MediaBrowser.Common.Kernel; +using MediaBrowser.Common.Net; +using System; using System.Threading; using System.Threading.Tasks; @@ -8,7 +11,7 @@ namespace MediaBrowser.Controller.Plugins /// /// Class PluginSecurityManager /// - public class PluginSecurityManager : BaseManager + public class PluginSecurityManager { /// /// The _is MB supporter @@ -36,12 +39,32 @@ namespace MediaBrowser.Controller.Plugins } } + /// + /// The _network manager + /// + private INetworkManager _networkManager; + + private IKernel _kernel; + /// /// Initializes a new instance of the class. /// /// The kernel. - public PluginSecurityManager(Kernel kernel) : base(kernel) + /// The network manager. + public PluginSecurityManager(IKernel kernel, INetworkManager networkManager) { + if (kernel == null) + { + throw new ArgumentNullException("kernel"); + } + + if (networkManager == null) + { + throw new ArgumentNullException("networkManager"); + } + + _kernel = kernel; + _networkManager = networkManager; } /// @@ -52,6 +75,7 @@ namespace MediaBrowser.Controller.Plugins /// Task{MBRegistrationRecord}. public async Task GetRegistrationStatus(string feature, string mb2Equivalent = null) { + // Update this method to add _networkManager as a param. return await MBRegistration.GetRegistrationStatus(feature, mb2Equivalent).ConfigureAwait(false); } @@ -62,15 +86,16 @@ namespace MediaBrowser.Controller.Plugins public string SupporterKey { get { return MBRegistration.SupporterKey; } - set { + set + { if (value != MBRegistration.SupporterKey) { MBRegistration.SupporterKey = value; // Clear this so it will re-evaluate ResetSupporterInfo(); // And we'll need to restart to re-evaluate the status of plug-ins - Kernel.NotifyPendingRestart(); - + _kernel.NotifyPendingRestart(); + } } } @@ -82,10 +107,11 @@ namespace MediaBrowser.Controller.Plugins public string LegacyKey { get { return MBRegistration.LegacyKey; } - set { + set + { MBRegistration.LegacyKey = value; // And we'll need to restart to re-evaluate the status of plug-ins - Kernel.NotifyPendingRestart(); + _kernel.NotifyPendingRestart(); } }