Пример #1
0
        public void ConvertTarget(LegacyScheduledRenewal legacy, Renewal ret)
        {
            if (legacy.Binding == null)
            {
                throw new Exception("Cannot convert renewal with empty binding");
            }
            if (string.IsNullOrEmpty(legacy.Binding.TargetPluginName))
            {
                legacy.Binding.TargetPluginName = legacy.Binding.PluginName switch
                {
                    "IIS" => legacy.Binding.HostIsDns == false ? "IISSite" : "IISBinding",
                    "IISSiteServer" => "IISSites",
                    _ => "Manual",
                };
            }
            switch (legacy.Binding.TargetPluginName.ToLower())
            {
            case "iisbinding":
                var options = new target.IISOptions();
                if (!string.IsNullOrEmpty(legacy.Binding.Host))
                {
                    options.IncludeHosts = new List <string>()
                    {
                        legacy.Binding.Host
                    };
                }
                var siteId = legacy.Binding.TargetSiteId ?? legacy.Binding.SiteId ?? 0;
                if (siteId > 0)
                {
                    options.IncludeSiteIds = new List <long>()
                    {
                        siteId
                    };
                }
                ret.TargetPluginOptions = options;
                break;

            case "iissite":
                options = new target.IISOptions();
                if (!string.IsNullOrEmpty(legacy.Binding.CommonName))
                {
                    options.CommonName = legacy.Binding.CommonName.ConvertPunycode();
                }
                siteId = legacy.Binding.TargetSiteId ?? legacy.Binding.SiteId ?? 0;
                if (siteId > 0)
                {
                    options.IncludeSiteIds = new List <long>()
                    {
                        siteId
                    };
                }
                options.ExcludeHosts    = legacy.Binding.ExcludeBindings.ParseCsv();
                ret.TargetPluginOptions = options;
                break;

            case "iissites":
                options = new target.IISOptions();
                if (!string.IsNullOrEmpty(legacy.Binding.CommonName))
                {
                    options.CommonName = legacy.Binding.CommonName.ConvertPunycode();
                }
                if (!string.IsNullOrEmpty(legacy.Binding.Host))
                {
                    options.IncludeSiteIds = legacy.Binding.Host.ParseCsv() !.Select(x => long.Parse(x)).ToList();
                }
                options.ExcludeHosts    = legacy.Binding.ExcludeBindings.ParseCsv();
                ret.TargetPluginOptions = options;
                break;

            case "manual":
                var manual = new target.ManualOptions()
                {
                    CommonName       = string.IsNullOrEmpty(legacy.Binding.CommonName) ? legacy.Binding.Host : legacy.Binding.CommonName.ConvertPunycode(),
                    AlternativeNames = legacy.Binding.AlternativeNames.Select(x => x.ConvertPunycode()).ToList()
                };
                if (!string.IsNullOrEmpty(manual.CommonName) &&
                    !manual.AlternativeNames.Contains(manual.CommonName))
                {
                    manual.AlternativeNames.Insert(0, manual.CommonName);
                }
                ret.TargetPluginOptions = manual;
                break;
            }
        }
Пример #2
0
 public Manual(ILogService logService, ManualOptions options)
 {
     _log     = logService;
     _options = options;
 }
Пример #3
0
 public Manual(ManualOptions options) => _options = options;