diff options
author | WouterTinus <wouter.tinus@gmail.com> | 2019-09-07 01:36:12 +0200 |
---|---|---|
committer | WouterTinus <wouter.tinus@gmail.com> | 2019-09-07 01:36:12 +0200 |
commit | 7673fa357a81444cf6c216267dfab4e76684ba5c (patch) | |
tree | 73c0bd36e5b6261cd89a168c2a099f6556c59f4d /src/main.lib/Plugins/TargetPlugins/IISBinding/IISBinding.cs | |
parent | 42aa0faa4de6ea4184cfe1a5830508777418b11a (diff) | |
download | letsencrypt-win-simple-7673fa357a81444cf6c216267dfab4e76684ba5c.zip letsencrypt-win-simple-7673fa357a81444cf6c216267dfab4e76684ba5c.tar.gz letsencrypt-win-simple-7673fa357a81444cf6c216267dfab4e76684ba5c.tar.bz2 |
move plugins & re-implement WebDav
Diffstat (limited to 'src/main.lib/Plugins/TargetPlugins/IISBinding/IISBinding.cs')
-rw-r--r-- | src/main.lib/Plugins/TargetPlugins/IISBinding/IISBinding.cs | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/src/main.lib/Plugins/TargetPlugins/IISBinding/IISBinding.cs b/src/main.lib/Plugins/TargetPlugins/IISBinding/IISBinding.cs new file mode 100644 index 0000000..b6125cc --- /dev/null +++ b/src/main.lib/Plugins/TargetPlugins/IISBinding/IISBinding.cs @@ -0,0 +1,54 @@ +using PKISharp.WACS.Clients; +using PKISharp.WACS.Clients.IIS; +using PKISharp.WACS.DomainObjects; +using PKISharp.WACS.Plugins.Interfaces; +using PKISharp.WACS.Services; +using System.Collections.Generic; +using System.Linq; + +namespace PKISharp.WACS.Plugins.TargetPlugins +{ + internal class IISBinding : ITargetPlugin + { + private readonly ILogService _log; + private readonly IIISClient _iisClient; + private IISBindingOptions _options; + private readonly IISBindingHelper _helper; + + public IISBinding(ILogService logService, IIISClient iisClient, IISBindingHelper helper, IISBindingOptions options) + { + _iisClient = iisClient; + _log = logService; + _options = options; + _helper = helper; + } + + public Target Generate() + { + var allBindings = _helper.GetBindings(false); + var matchingBindings = allBindings.Where(x => x.HostUnicode == _options.Host); + if (matchingBindings.Count() == 0) + { + _log.Error("Binding {binding} not yet found in IIS, create it or use the Manual target plugin instead", _options.Host); + return null; + } + else if (!matchingBindings.Any(b => b.SiteId == _options.SiteId)) + { + var newMatch = matchingBindings.First(); + _log.Warning("Binding {binding} moved from site {a} to site {b}", _options.Host, _options.SiteId, newMatch.SiteId); + _options.SiteId = newMatch.SiteId; + } + return new Target() + { + FriendlyName = $"[{nameof(IISBinding)}] {_options.Host}", + CommonName = _options.Host, + Parts = new[] { + new TargetPart { + Identifiers = new List<string> { _options.Host }, + SiteId = _options.SiteId + } + } + }; + } + } +} |