diff --git a/MediaBrowser.Common.Implementations/BaseApplicationHost.cs b/MediaBrowser.Common.Implementations/BaseApplicationHost.cs
index b6b956602f..90cb59bbe2 100644
--- a/MediaBrowser.Common.Implementations/BaseApplicationHost.cs
+++ b/MediaBrowser.Common.Implementations/BaseApplicationHost.cs
@@ -279,7 +279,7 @@ namespace MediaBrowser.Common.Implementations
NetworkManager = new NetworkManager();
RegisterSingleInstance(NetworkManager);
- SecurityManager = new PluginSecurityManager(this, HttpClient, JsonSerializer, ApplicationPaths);
+ SecurityManager = new PluginSecurityManager(this, HttpClient, JsonSerializer, ApplicationPaths, NetworkManager);
RegisterSingleInstance(SecurityManager);
InstallationManager = new InstallationManager(Logger, this, ApplicationPaths, HttpClient, JsonSerializer, SecurityManager, NetworkManager, ConfigurationManager);
diff --git a/MediaBrowser.Common.Implementations/MediaBrowser.Common.Implementations.csproj b/MediaBrowser.Common.Implementations/MediaBrowser.Common.Implementations.csproj
index 350d1eba5a..2397d4c2ce 100644
--- a/MediaBrowser.Common.Implementations/MediaBrowser.Common.Implementations.csproj
+++ b/MediaBrowser.Common.Implementations/MediaBrowser.Common.Implementations.csproj
@@ -51,7 +51,6 @@
-
diff --git a/MediaBrowser.Common.Implementations/Security/MBRegistration.cs b/MediaBrowser.Common.Implementations/Security/MBRegistration.cs
index 1019ed8b9b..1f9e63e684 100644
--- a/MediaBrowser.Common.Implementations/Security/MBRegistration.cs
+++ b/MediaBrowser.Common.Implementations/Security/MBRegistration.cs
@@ -1,10 +1,9 @@
-using MediaBrowser.Model.Entities;
-using MediaBrowser.Common.Configuration;
+using MediaBrowser.Common.Configuration;
using MediaBrowser.Common.Net;
+using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Serialization;
using System;
using System.Collections.Generic;
-using System.Management;
using System.Threading;
using System.Threading.Tasks;
@@ -17,6 +16,7 @@ namespace MediaBrowser.Common.Implementations.Security
private const string MBValidateUrl = "http://mb3admin.com/admin/service/registration/validate";
private static IApplicationPaths _appPaths;
+ private static INetworkManager _networkManager;
private static MBLicenseFile LicenseFile
{
@@ -35,16 +35,17 @@ namespace MediaBrowser.Common.Implementations.Security
set { LicenseFile.LegacyKey = value; LicenseFile.Save(); }
}
- public static void Init(IApplicationPaths appPaths)
+ public static void Init(IApplicationPaths appPaths, INetworkManager networkManager)
{
// Ugly alert (static init)
_appPaths = appPaths;
+ _networkManager = networkManager;
}
public static async Task GetRegistrationStatus(IHttpClient httpClient, IJsonSerializer jsonSerializer, string feature, string mb2Equivalent = null)
{
- var mac = GetMacAddress();
+ var mac = _networkManager.GetMacAddress();
var data = new Dictionary {{"feature", feature}, {"key",SupporterKey}, {"mac",mac}, {"mb2equiv",mb2Equivalent}, {"legacykey", LegacyKey} };
var reg = new RegRecord();
@@ -69,35 +70,6 @@ namespace MediaBrowser.Common.Implementations.Security
return new MBRegistrationRecord {IsRegistered = reg.registered, ExpirationDate = reg.expDate, RegChecked = true};
}
-
- ///
- /// Returns MAC Address from first Network Card in Computer
- ///
- /// [string] MAC Address
- public static string GetMacAddress()
- {
- var mc = new ManagementClass("Win32_NetworkAdapterConfiguration");
- var moc = mc.GetInstances();
- var macAddress = String.Empty;
- foreach (ManagementObject mo in moc)
- {
- if (macAddress == String.Empty) // only return MAC Address from first card
- {
- try
- {
- if ((bool)mo["IPEnabled"]) macAddress = mo["MacAddress"].ToString();
- }
- catch
- {
- mo.Dispose();
- return "";
- }
- }
- mo.Dispose();
- }
-
- return macAddress.Replace(":", "");
- }
}
class RegRecord
diff --git a/MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs b/MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs
index 3abdeada40..19a1ed646d 100644
--- a/MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs
+++ b/MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs
@@ -1,14 +1,13 @@
-using System.Collections.Generic;
-using MediaBrowser.Common.Configuration;
+using MediaBrowser.Common.Configuration;
+using MediaBrowser.Common.Net;
using MediaBrowser.Common.Security;
-using MediaBrowser.Model.Serialization;
-using MediaBrowser.Common.Implementations.Security;
using MediaBrowser.Model.Entities;
-using MediaBrowser.Common.Net;
+using MediaBrowser.Model.Serialization;
using System;
+using System.Collections.Generic;
+using System.Linq;
using System.Threading;
using System.Threading.Tasks;
-using System.Linq;
namespace MediaBrowser.Common.Implementations.Security
{
@@ -47,7 +46,9 @@ namespace MediaBrowser.Common.Implementations.Security
private readonly IJsonSerializer _jsonSerializer;
private readonly IApplicationHost _appHost;
private readonly IApplicationPaths _applciationPaths;
- private IEnumerable _registeredEntities;
+ private readonly INetworkManager _networkManager;
+
+ private IEnumerable _registeredEntities;
protected IEnumerable RegisteredEntities
{
get
@@ -59,7 +60,7 @@ namespace MediaBrowser.Common.Implementations.Security
///
/// Initializes a new instance of the class.
///
- public PluginSecurityManager(IApplicationHost appHost, IHttpClient httpClient, IJsonSerializer jsonSerializer, IApplicationPaths appPaths)
+ public PluginSecurityManager(IApplicationHost appHost, IHttpClient httpClient, IJsonSerializer jsonSerializer, IApplicationPaths appPaths, INetworkManager networkManager)
{
if (httpClient == null)
{
@@ -67,6 +68,7 @@ namespace MediaBrowser.Common.Implementations.Security
}
_applciationPaths = appPaths;
+ _networkManager = networkManager;
_appHost = appHost;
_httpClient = httpClient;
_jsonSerializer = jsonSerializer;
@@ -95,7 +97,7 @@ namespace MediaBrowser.Common.Implementations.Security
{
// Do this on demend instead of in the constructor to delay the external assembly load
// Todo: Refactor external methods to take app paths as a param
- MBRegistration.Init(_applciationPaths);
+ MBRegistration.Init(_applciationPaths, _networkManager);
return await MBRegistration.GetRegistrationStatus(_httpClient, _jsonSerializer, feature, mb2Equivalent).ConfigureAwait(false);
}
@@ -109,14 +111,14 @@ namespace MediaBrowser.Common.Implementations.Security
{
// Do this on demend instead of in the constructor to delay the external assembly load
// Todo: Refactor external methods to take app paths as a param
- MBRegistration.Init(_applciationPaths);
+ MBRegistration.Init(_applciationPaths, _networkManager);
return MBRegistration.SupporterKey;
}
set
{
// Do this on demend instead of in the constructor to delay the external assembly load
// Todo: Refactor external methods to take app paths as a param
- MBRegistration.Init(_applciationPaths);
+ MBRegistration.Init(_applciationPaths, _networkManager);
if (value != MBRegistration.SupporterKey)
{
MBRegistration.SupporterKey = value;
@@ -136,14 +138,14 @@ namespace MediaBrowser.Common.Implementations.Security
{
// Do this on demend instead of in the constructor to delay the external assembly load
// Todo: Refactor external methods to take app paths as a param
- MBRegistration.Init(_applciationPaths);
+ MBRegistration.Init(_applciationPaths, _networkManager);
return MBRegistration.LegacyKey;
}
set
{
// Do this on demend instead of in the constructor to delay the external assembly load
// Todo: Refactor external methods to take app paths as a param
- MBRegistration.Init(_applciationPaths);
+ MBRegistration.Init(_applciationPaths, _networkManager);
if (value != MBRegistration.LegacyKey)
{
MBRegistration.LegacyKey = value;