public void InstallAddon(string base64Addon, bool force) { if (!_safeguardLogic.ValidateLicense()) { throw LogAndException("Invalid licenses."); } if (base64Addon == null) { throw LogAndException("Add-on cannot be null"); } var bytes = Convert.FromBase64String(base64Addon); try { var signatureResult = ValidateAddonSignature(bytes); if (signatureResult.Item1) { var isProduction = signatureResult.Item2; // Skip the signature bytes to get to the zip file var data = bytes.Skip(512).ToArray(); using (var zipArchive = new ZipArchive(new MemoryStream(data), ZipArchiveMode.Read)) { InstallAddon(zipArchive, isProduction, force); } } } catch (Exception ex) { throw LogAndException($"Failed to install the vault plugin. {ex.Message}"); } }
private Plugin ConfigureIfSystemOwned(Plugin plugin) { var notLicensed = !_safeguardLogic.ValidateLicense(); var addons = _configDb.GetAllAddons(); foreach (var addon in addons) { if (addon.Manifest.PluginName.Equals(plugin.Name, StringComparison.OrdinalIgnoreCase)) { plugin.IsSystemOwned = addon.Manifest.IsPluginSystemOwned; plugin.IsDisabled = notLicensed; } } return(plugin); }