Пример #1
0
        public override IISSiteOptions Aquire(IOptionsService optionsService, IInputService inputService, RunLevel runLevel)
        {
            var ret    = new IISSiteOptions();
            var chosen = inputService.ChooseFromList("Choose site",
                                                     _helper.GetSites(optionsService.MainArguments.HideHttps, true).Where(x => x.Hidden == false),
                                                     x => new Choice <IISSiteHelper.IISSiteOption>(x)
            {
                Description = x.Name
            },
                                                     true);

            if (chosen != null)
            {
                ret.SiteId = chosen.Id;
                ret.FriendlyNameSuggestion = $"Site-{chosen.Id}";

                // Exclude bindings
                inputService.WritePagedList(chosen.Hosts.Select(x => Choice.Create(x, "")));
                ret.ExcludeBindings = inputService.RequestString("Press enter to include all listed hosts, or type a comma-separated lists of exclusions").ParseCsv();
                if (runLevel.HasFlag(RunLevel.Advanced))
                {
                    ret.CommonName = inputService.ChooseFromList(
                        "Select common name",
                        chosen.Hosts.Except(ret.ExcludeBindings ?? new List <string>()),
                        x => new Choice <string>(x),
                        true);
                }
                return(ret);
            }
            return(null);
        }
        /// <summary>
        /// Allow user to choose a TargetPlugin
        /// </summary>
        /// <returns></returns>
        public override ITargetPluginFactory GetTargetPlugin(ILifetimeScope scope)
        {
            // List options for generating new certificates
            var ret = _input.ChooseFromList("Which kind of certificate would you like to create?",
                                            _plugins.TargetPluginFactories(scope),
                                            x => Choice.Create(x, description: x.Description),
                                            true);

            return(ret ?? new NullTargetFactory());
        }
Пример #3
0
        /// <summary>
        /// Allow user to choose a TargetPlugin
        /// </summary>
        /// <returns></returns>
        public override ITargetPluginOptionsFactory GetTargetPlugin(ILifetimeScope scope)
        {
            // List options for generating new certificates
            var options = _plugins.TargetPluginFactories(scope).Where(x => !x.Hidden).OrderBy(x => x.Description);
            var ret     = _input.ChooseFromList("Which kind of certificate would you like to create?",
                                                _plugins.TargetPluginFactories(scope).Where(x => !x.Hidden),
                                                x => Choice.Create(x, description: x.Description),
                                                "Abort");

            return(ret ?? new NullTargetFactory());
        }
        public override IISSiteOptions Aquire(IArgumentsService arguments, IInputService inputService, RunLevel runLevel)
        {
            var ret   = new IISSiteOptions();
            var sites = _helper.
                        GetSites(arguments.MainArguments.HideHttps, true).
                        Where(x => x.Hidden == false).
                        Where(x => x.Hosts.Any());

            if (!sites.Any())
            {
                _log.Error($"No sites with named bindings have been configured in IIS. Add one or choose '{ManualOptions.DescriptionText}'.");
                return(null);
            }
            var chosen = inputService.ChooseFromList("Choose site",
                                                     sites,
                                                     x => new Choice <IISSiteHelper.IISSiteOption>(x)
            {
                Description = x.Name
            },
                                                     true);

            if (chosen != null)
            {
                ret.SiteId = chosen.Id;

                // Exclude bindings
                inputService.WritePagedList(chosen.Hosts.Select(x => Choice.Create(x, "")));
                ret.ExcludeBindings = inputService.RequestString("Press enter to include all listed hosts, or type a comma-separated lists of exclusions").ParseCsv();
                var remaining = chosen.Hosts.Except(ret.ExcludeBindings ?? new List <string>());
                if (remaining.Count() == 0)
                {
                    _log.Error("No bindings remain");
                    return(null);
                }

                // Set common name
                if (remaining.Count() > 1)
                {
                    ret.CommonName = inputService.ChooseFromList(
                        "Select primary domain (common name)",
                        remaining,
                        x => new Choice <string>(x),
                        true);
                }
                return(ret);
            }
            return(null);
        }
Пример #5
0
        public bool AquireAdvancedOptions(IInputService input, IEnumerable <string> chosen, RunLevel runLevel, IIISSiteOptions ret)
        {
            if (runLevel.HasFlag(RunLevel.Advanced))
            {
                // Exclude bindings
                input.WritePagedList(chosen.Select(x => Choice.Create(x, "")));
                ret.ExcludeBindings = input.RequestString("Press enter to include all listed hosts, or type a comma-separated lists of exclusions").ParseCsv();
            }

            var remaining = chosen.Except(ret.ExcludeBindings ?? new List <string>());

            if (remaining.Count() == 0)
            {
                _log.Error("No bindings remain");
                return(false);
            }

            // Set common name
            if (remaining.Count() > 1)
            {
                ret.CommonName = input.ChooseFromList(
                    "Select primary domain (common name)",
                    remaining,
                    x => Choice.Create(x),
                    "Default");
            }
            return(true);
        }
Пример #6
0
        public override IISSitesOptions Aquire(IOptionsService optionsService, IInputService inputService, RunLevel runLevel)
        {
            var ret   = new IISSitesOptions();
            var sites = _helper.GetSites(optionsService.MainArguments.HideHttps, true).Where(x => x.Hidden == false).ToList();

            inputService.WritePagedList(sites.Select(x => Choice.Create(x, $"{x.Name} ({x.Hosts.Count()} bindings)", x.Id.ToString())).ToList());
            var sanInput = inputService.RequestString("Enter a comma separated list of SiteIds or 'S' for all sites").ToLower().Trim();

            sites = ProcessSiteIds(ret, sites, sanInput);
            if (sites == null)
            {
                return(null);
            }
            var hosts = sites.SelectMany(x => x.Hosts).Distinct().OrderBy(x => x);

            inputService.WritePagedList(hosts.Select(x => Choice.Create(x, "")));
            ret.ExcludeBindings = inputService.RequestString("Press enter to include all listed hosts, or type a comma-separated lists of exclusions").ParseCsv();

            if (runLevel.HasFlag(RunLevel.Advanced))
            {
                ret.CommonName = inputService.ChooseFromList(
                    "Select common name",
                    hosts.Except(ret.ExcludeBindings ?? new List <string>()),
                    (x) => new Choice <string>(x),
                    true);
            }
            return(ret);
        }
Пример #7
0
        public override IISWebOptions Aquire(Target target, IArgumentsService arguments, IInputService inputService, RunLevel runLevel)
        {
            var args = arguments.GetArguments <IISWebArguments>();
            var ret  = new IISWebOptions(args);
            var ask  = true;

            if (target.IIS)
            {
                if (runLevel.HasFlag(RunLevel.Advanced))
                {
                    ask = inputService.PromptYesNo("Use different site for installation?");
                }
                else
                {
                    ask = false;
                }
            }
            if (ask)
            {
                var chosen = inputService.ChooseFromList("Choose site to create new bindings",
                                                         _iisClient.WebSites,
                                                         x => new Choice <long>(x.Id)
                {
                    Description = x.Name,
                    Command     = x.Id.ToString()
                },
                                                         false);
                ret.SiteId = chosen;
            }
            return(ret);
        }
Пример #8
0
 Target ITargetPlugin.Aquire(IOptionsService optionsService, IInputService inputService, RunLevel runLevel)
 {
     return(inputService.ChooseFromList("Choose site",
                                        GetBindings(optionsService.Options.HideHttps, true).Where(x => x.Hidden == false),
                                        x => Choice.Create(x, description: $"{x.Host} (SiteId {x.TargetSiteId}) [@{x.WebRootPath}]"),
                                        true));
 }
Пример #9
0
        public async override Task <IISSiteOptions> Aquire(IInputService input, RunLevel runLevel)
        {
            var ret   = new IISSiteOptions();
            var sites = _siteHelper.
                        GetSites(true).
                        Where(x => !_arguments.MainArguments.HideHttps || x.Https == false).
                        Where(x => x.Hosts.Any());

            if (!sites.Any())
            {
                _log.Error($"No sites with named bindings have been configured in IIS. Add one or choose '{ManualOptions.DescriptionText}'.");
                return(null);
            }

            var chosen = await input.ChooseFromList("Choose site",
                                                    sites,
                                                    x => Choice.Create(x,
                                                                       $"{x.Name} ({x.Hosts.Count()} binding{(x.Hosts.Count() == 1 ? "" : "s")})",
                                                                       x.Id.ToString(),
                                                                       color: x.Https ? ConsoleColor.DarkGray : (ConsoleColor?)null),
                                                    "Abort");

            if (chosen != null)
            {
                ret.SiteId = chosen.Id;
                if (await _optionsHelper.AquireAdvancedOptions(input, chosen.Hosts, runLevel, ret))
                {
                    return(ret);
                }
            }
            return(null);
        }
Пример #10
0
 /// <summary>
 /// Remove renewal from the list of scheduled items
 /// </summary>
 private void CancelRenewal(RunLevel runLevel)
 {
     if (runLevel.HasFlag(RunLevel.Unattended))
     {
         var friendlyName = _arguments.TryGetRequiredArgument(nameof(MainArguments.FriendlyName), _args.FriendlyName);
         foreach (var r in _renewalService.FindByFriendlyName(friendlyName))
         {
             _renewalService.Cancel(r);
         }
     }
     else
     {
         var renewal = _input.ChooseFromList("Which renewal would you like to cancel?",
                                             _renewalService.Renewals,
                                             x => Choice.Create(x),
                                             "Back");
         if (renewal != null)
         {
             if (_input.PromptYesNo($"Are you sure you want to cancel the renewal for {renewal}", false))
             {
                 _renewalService.Cancel(renewal);
             }
         }
     }
 }
Пример #11
0
        /// <summary>
        /// Allow user to choose a TargetPlugin
        /// </summary>
        /// <returns></returns>
        public override async Task <ITargetPluginOptionsFactory> GetTargetPlugin(ILifetimeScope scope)
        {
            // List options for generating new certificates
            _input.Show(null, "Please specify how the list of domain names that will be included in the certificate " +
                        "should be determined. If you choose for one of the \"all bindings\" options, the list will automatically be " +
                        "updated for future renewals to reflect the bindings at that time.",
                        true);

            var options = _plugins.TargetPluginFactories(scope).
                          Where(x => !x.Hidden).
                          OrderBy(x => x.Order).
                          ThenBy(x => x.Description);

            var defaultType = typeof(IISSiteOptionsFactory);

            if (!options.OfType <IISSiteOptionsFactory>().Any(x => !x.Disabled))
            {
                defaultType = typeof(ManualOptionsFactory);
            }

            var ret = await _input.ChooseFromList("How shall we determine the domain(s) to include in the certificate?",
                                                  options,
                                                  x => Choice.Create(
                                                      x,
                                                      description: x.Description,
                                                      @default: x.GetType() == defaultType,
                                                      disabled: x.Disabled),
                                                  "Abort");

            return(ret ?? new NullTargetFactory());
        }
Пример #12
0
        public override void Aquire(ScheduledRenewal renewal, IOptionsService optionsService, IInputService inputService, RunLevel runLevel)
        {
            var ask = true;

            if (renewal.Binding.IIS == true)
            {
                if (runLevel == RunLevel.Advanced)
                {
                    ask = inputService.PromptYesNo("Use different site for installation?");
                }
                else
                {
                    ask = false;
                }
            }
            if (ask)
            {
                var chosen = inputService.ChooseFromList("Choose site to create new bindings",
                                                         _iisClient.RunningWebsites(),
                                                         x => new Choice <long>(x.Id)
                {
                    Description = x.Name, Command = x.Id.ToString()
                },
                                                         false);
                renewal.Binding.InstallationSiteId = chosen;
            }
        }
Пример #13
0
        public override async Task <IISWebOptions> Aquire(Target target, IInputService inputService, RunLevel runLevel)
        {
            var args = _arguments.GetArguments <IISWebArguments>();
            var ret  = new IISWebOptions(args);
            var ask  = true;

            if (target.IIS)
            {
                if (runLevel.HasFlag(RunLevel.Advanced))
                {
                    ask = await inputService.PromptYesNo("Use different site for installation?", false);
                }
                else
                {
                    ask = false;
                }
            }
            if (ask)
            {
                var chosen = await inputService.ChooseFromList("Choose site to create new bindings",
                                                               _iisClient.WebSites,
                                                               x => Choice.Create(x.Id, x.Name, x.Id.ToString()));

                ret.SiteId = chosen;
            }
            return(ret);
        }
Пример #14
0
        public override IISSiteOptions Aquire(IArgumentsService arguments, IInputService input, RunLevel runLevel)
        {
            var ret   = new IISSiteOptions();
            var sites = _siteHelper.
                        GetSites(arguments.MainArguments.HideHttps, true).
                        Where(x => x.Hidden == false).
                        Where(x => x.Hosts.Any());

            if (!sites.Any())
            {
                _log.Error($"No sites with named bindings have been configured in IIS. Add one or choose '{ManualOptions.DescriptionText}'.");
                return(null);
            }
            var chosen = input.ChooseFromList("Choose site",
                                              sites,
                                              x => Choice.Create(x, x.Name),
                                              "Abort");

            if (chosen != null)
            {
                ret.SiteId = chosen.Id;
                if (_optionsHelper.AquireAdvancedOptions(input, chosen.Hosts, runLevel, ret))
                {
                    return(ret);
                }
            }
            return(null);
        }
Пример #15
0
        public override IISBindingOptions Aquire(IArgumentsService arguments, IInputService inputService, RunLevel runLevel)
        {
            var ret      = new IISBindingOptions();
            var bindings = _helper.GetBindings(arguments.MainArguments.HideHttps).Where(x => !x.Hidden);

            if (!bindings.Any())
            {
                _log.Error($"No sites with named bindings have been configured in IIS. Add one or choose '{ManualOptions.DescriptionText}'.");
                return(null);
            }
            var chosenTarget = inputService.ChooseFromList(
                "Choose binding",
                bindings,
                x => Choice.Create(x),
                "Abort");

            if (chosenTarget != null)
            {
                ret.SiteId = chosenTarget.SiteId;
                ret.Host   = chosenTarget.HostUnicode;
                return(ret);
            }
            else
            {
                return(null);
            }
        }
Пример #16
0
        /// <summary>
        /// Main user experience
        /// </summary>
        private async Task MainMenu()
        {
            var options = new List <Choice <Func <Task> > >
            {
                Choice.Create <Func <Task> >(() => _renewalManager.SetupRenewal(RunLevel.Interactive | RunLevel.Simple), "Create new certificate (simple for IIS)", "N", @default: _userRoleService.AllowIIS, disabled: !_userRoleService.AllowIIS),
                Choice.Create <Func <Task> >(() => _renewalManager.SetupRenewal(RunLevel.Interactive | RunLevel.Advanced), "Create new certificate (full options)", "M", @default: !_userRoleService.AllowIIS),
                Choice.Create <Func <Task> >(() => _renewalManager.ShowRenewals(), "List scheduled renewals", "L"),
                Choice.Create <Func <Task> >(() => _renewalManager.CheckRenewals(RunLevel.Interactive), "Renew scheduled", "R"),
                Choice.Create <Func <Task> >(() => _renewalManager.RenewSpecific(), "Renew specific", "S"),
                Choice.Create <Func <Task> >(() => _renewalManager.CheckRenewals(RunLevel.Interactive | RunLevel.ForceRenew), "Renew *all*", "A"),
                Choice.Create <Func <Task> >(() => ExtraMenu(), "More options...", "O"),
                Choice.Create <Func <Task> >(() => { _args.CloseOnFinish = true; _args.Test = false; return(Task.CompletedTask); }, "Quit", "Q")
            };
            var chosen = await _input.ChooseFromList("Please choose from the menu", options);

            await chosen.Invoke();
        }
        /// <summary>
        /// Allow user to choose a TargetPlugin
        /// </summary>
        /// <returns></returns>
        public override ITargetPluginFactory GetTargetPlugin(ILifetimeScope scope)
        {
            // List options for generating new certificates
            var options = _plugins.TargetPluginFactories(scope).Where(x => !x.Hidden).OrderBy(x => x.Description);

            if (_type > 0)
            {
                var s = options.Where(i => i.Name == "Manual");
                var x = s.FirstOrDefault();
                return(x);
            }
            var ret = _input.ChooseFromList("Which kind of certificate would you like to create?",
                                            _plugins.TargetPluginFactories(scope).Where(x => !x.Hidden),
                                            x => Choice.Create(x, description: x.Description),
                                            true);

            return(ret ?? new NullTargetFactory());
        }
        public static void AskForCommonNameChoice(this Target target, IInputService inputService)
        {
            if (target.AlternativeNames.Count < 2)
            {
                return;
            }
            var sanChoices = target.AlternativeNames.OrderBy(x => x).Select(san => Choice.Create <string>(san)).ToList();

            target.CommonName = inputService.ChooseFromList("Choose a domain name to be the certificate's common name", sanChoices, false);
        }
Пример #19
0
        /// <summary>
        /// Allow user to choose a TargetPlugin
        /// </summary>
        /// <returns></returns>
        public override ITargetPluginOptionsFactory GetTargetPlugin(ILifetimeScope scope)
        {
            // List options for generating new certificates
            _input.Show(null, "Please specify how the list of domain names that will be included in the certificate " +
                        "should be determined. If you choose for one of the \"all bindings\" options, the list will automatically be " +
                        "updated for future renewals to reflect the bindings at that time.",
                        true);
            var options = _plugins.TargetPluginFactories(scope).
                          Where(x => !x.Hidden).
                          OrderBy(x => x.Order).
                          ThenBy(x => x.Description);

            var ret = _input.ChooseFromList("How shall we determine the domain(s) to include in the certificate?",
                                            _plugins.TargetPluginFactories(scope).Where(x => !x.Hidden),
                                            x => Choice.Create(x, description: x.Description),
                                            "Abort");

            return(ret ?? new NullTargetFactory());
        }
Пример #20
0
        public override IISFtpOptions Aquire(Target renewal, IArgumentsService arguments, IInputService inputService, RunLevel runLevel)
        {
            var ret    = new IISFtpOptions();
            var chosen = inputService.ChooseFromList("Choose ftp site to bind the certificate to",
                                                     _iisClient.FtpSites,
                                                     x => Choice.Create(x.Id, x.Name, x.Id.ToString()));

            ret.SiteId = chosen;
            return(ret);
        }
Пример #21
0
        public override void Aquire(ScheduledRenewal renewal, IOptionsService optionsService, IInputService inputService, RunLevel runLevel)
        {
            var chosen = inputService.ChooseFromList("Choose ftp site to bind the certificate to",
                                                     _iisClient.FtpSites,
                                                     x => new Choice <long>(x.Id)
            {
                Description = x.Name, Command = x.Id.ToString()
            },
                                                     false);

            renewal.Binding.FtpSiteId = chosen;
        }
Пример #22
0
 public override void Aquire(Target target, IOptionsService optionsService, IInputService inputService, RunLevel runLevel)
 {
     if (inputService.PromptYesNo("Use different site for validation?"))
     {
         target.ValidationSiteId = inputService.ChooseFromList("Validation site, must receive requests for all hosts on port 80",
                                                               _iisClient.RunningWebsites(),
                                                               x => new Choice <long>(x.Id)
         {
             Command = x.Id.ToString(), Description = x.Name
         }, true);
     }
 }
Пример #23
0
        public override async Task <ScriptOptions> Aquire(Target target, IInputService input, RunLevel runLevel)
        {
            var args         = _arguments.GetArguments <ScriptArguments>();
            var ret          = new ScriptOptions();
            var createScript = "";

            do
            {
                createScript = await _arguments.TryGetArgument(args.DnsCreateScript, input, "Path to script that creates DNS records");
            }while (!createScript.ValidFile(_log));

            var deleteScript = "";
            var chosen       = await input.ChooseFromList(
                "How to delete records after validation",
                new List <Choice <Func <Task> > >()
            {
                Choice.Create <Func <Task> >(() => {
                    deleteScript = createScript;
                    return(Task.CompletedTask);
                }, "Using the same script"),
                Choice.Create <Func <Task> >(async() => {
                    do
                    {
                        deleteScript = await _arguments.TryGetArgument(
                            args.DnsDeleteScript,
                            input,
                            "Path to script that deletes DNS records");
                    }while (!deleteScript.ValidFile(_log));
                }, "Using a different script"),
                Choice.Create <Func <Task> >(() => Task.CompletedTask, "Do not delete")
            });

            await chosen.Invoke();

            ProcessScripts(ret, null, createScript, deleteScript);

            input.Show("{Identifier}", "Domain that's being validated");
            input.Show("{RecordName}", "Full TXT record name");
            input.Show("{Token}", "Expected value in the TXT record");
            var createArgs = await _arguments.TryGetArgument(args.DnsCreateScriptArguments, input, $"Input parameters for create script, or enter for default \"{Script.DefaultCreateArguments}\"");

            var deleteArgs = "";

            if (!string.IsNullOrWhiteSpace(ret.DeleteScript) ||
                !string.IsNullOrWhiteSpace(ret.Script))
            {
                deleteArgs = await _arguments.TryGetArgument(args.DnsDeleteScriptArguments, input, $"Input parameters for delete script, or enter for default \"{Script.DefaultDeleteArguments}\"");
            }
            ProcessArgs(ret, createArgs, deleteArgs);
            return(ret);
        }
Пример #24
0
        /// <summary>
        /// Remove renewal from the list of scheduled items
        /// </summary>
        internal async Task CancelRenewal(RunLevel runLevel)
        {
            if (runLevel.HasFlag(RunLevel.Unattended))
            {
                if (!_arguments.HasFilter())
                {
                    _log.Error("Specify which renewal to cancel using the parameter --id or --friendlyname.");
                    return;
                }
                var targets = _renewalStore.FindByArguments(
                    _arguments.MainArguments.Id,
                    _arguments.MainArguments.FriendlyName);
                if (targets.Count() == 0)
                {
                    _log.Error("No renewals matched.");
                    return;
                }
                foreach (var r in targets)
                {
                    _renewalStore.Cancel(r);
                }
            }
            else
            {
                var renewal = await _input.ChooseFromList("Which renewal would you like to cancel?",
                                                          _renewalStore.Renewals,
                                                          x => Choice.Create(x),
                                                          "Back");

                if (renewal != null)
                {
                    if (await _input.PromptYesNo($"Are you sure you want to cancel the renewal for {renewal}", false))
                    {
                        _renewalStore.Cancel(renewal);
                    }
                }
            }
        }
Пример #25
0
        public override IISFtpOptions Aquire(Target renewal, IArgumentsService arguments, IInputService inputService, RunLevel runLevel)
        {
            var ret    = new IISFtpOptions();
            var chosen = inputService.ChooseFromList("Choose ftp site to bind the certificate to",
                                                     _iisClient.FtpSites,
                                                     x => new Choice <long>(x.Id)
            {
                Description = x.Name, Command = x.Id.ToString()
            },
                                                     false);

            ret.SiteId = chosen;
            return(ret);
        }
Пример #26
0
        public override void Aquire(ScheduledRenewal renewal, IOptionsService optionsService, IInputService inputService, RunLevel runLevel)
        {
            if (renewal.Binding.IIS != true || runLevel < RunLevel.Advanced || !inputService.PromptYesNo("Use different site for installation?"))
            {
                return;
            }
            var chosen = inputService.ChooseFromList("Choose site to create new bindings",
                                                     _iisClient.WebSites,
                                                     x => new Choice <long>(x.Id)
            {
                Description = x.Name, Command = x.Id.ToString()
            },
                                                     false);

            renewal.Binding.InstallationSiteId = chosen;
        }
        public override IISSitesOptions Aquire(IArgumentsService arguments, IInputService inputService, RunLevel runLevel)
        {
            var ret   = new IISSitesOptions();
            var sites = _helper.GetSites(arguments.MainArguments.HideHttps, true).
                        Where(x => x.Hidden == false).
                        Where(x => x.Hosts.Any()).
                        ToList();

            if (!sites.Any())
            {
                _log.Error($"No sites with named bindings have been configured in IIS. Add one or choose '{ManualOptions.DescriptionText}'.");
                return(null);
            }
            inputService.WritePagedList(sites.Select(x => Choice.Create(x, $"{x.Name} ({x.Hosts.Count()} bindings)", x.Id.ToString())).ToList());
            var sanInput = inputService.RequestString("Enter a comma separated list of SiteIds or 'S' for all sites").ToLower().Trim();

            sites = ProcessSiteIds(ret, sites, sanInput);
            if (sites == null)
            {
                return(null);
            }
            var hosts = sites.SelectMany(x => x.Hosts).Distinct().OrderBy(x => x);

            inputService.WritePagedList(hosts.Select(x => Choice.Create(x, "")));
            ret.ExcludeBindings = inputService.RequestString("Press enter to include all listed hosts, or type a comma-separated lists of exclusions").ParseCsv();
            var remaining = hosts.Except(ret.ExcludeBindings ?? new List <string>());

            if (remaining.Count() == 0)
            {
                _log.Error("No bindings remain after excluding");
                return(null);
            }

            // Set common name
            if (remaining.Count() > 1)
            {
                ret.CommonName = inputService.ChooseFromList(
                    "Select primary domain (common name)",
                    remaining,
                    x => new Choice <string>(x),
                    true);
            }
            return(ret);
        }
Пример #28
0
        Target ITargetPlugin.Aquire(IOptionsService optionsService, IInputService inputService)
        {
            var chosen = inputService.ChooseFromList("Choose site",
                                                     GetSites(optionsService.Options.HideHttps, true).Where(x => x.Hidden == false),
                                                     x => new Choice <Target>(x)
            {
                Description = x.Host
            },
                                                     true);

            if (chosen != null)
            {
                // Exclude bindings
                inputService.WritePagedList(chosen.AlternativeNames.Select(x => Choice.Create(x, "")));
                chosen.ExcludeBindings = inputService.RequestString("Press enter to include all listed hosts, or type a comma-separated lists of exclusions");
                return(chosen);
            }
            return(null);
        }
Пример #29
0
 public override void Aquire(Target target, IOptionsService optionsService, IInputService inputService, RunLevel runLevel)
 {
     // Choose alternative site for validation
     if (target.IIS == true && _iisClient.Version.Major > 0)
     {
         if (inputService.PromptYesNo("Use different site for validation?"))
         {
             var site = inputService.ChooseFromList("Validation site, must receive requests for all hosts on port 80",
                                                    _iisClient.WebSites,
                                                    x => new Choice <Site>(x)
             {
                 Command = x.Id.ToString(), Description = x.Name
             }, true);
             if (site != null)
             {
                 target.ValidationSiteId = site.Id;
                 target.WebRootPath      = site.WebRoot();
             }
         }
     }
     base.Aquire(target, optionsService, inputService, runLevel);
 }
Пример #30
0
        public override IISBindingOptions Aquire(IOptionsService optionsService, IInputService inputService, RunLevel runLevel)
        {
            var ret          = new IISBindingOptions();
            var filterSet    = _helper.GetBindings(false, false);
            var chosenTarget = inputService.ChooseFromList(
                "Choose binding",
                filterSet.Where(x => x.Hidden == false),
                x => Choice.Create(x, description: $"{x.HostUnicode} (SiteId {x.SiteId})"),
                true);

            if (chosenTarget != null)
            {
                ret.SiteId = chosenTarget.SiteId;
                ret.Host   = chosenTarget.HostUnicode;
                ret.FriendlyNameSuggestion = chosenTarget.HostUnicode;
                return(ret);
            }
            else
            {
                return(null);
            }
        }