summaryrefslogtreecommitdiffstats
path: root/src/main.lib/Plugins/ValidationPlugins/Dns/Acme/Acme.cs
blob: b24cc38ff1f4281ec67f6065143614d69ed6d3a6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
using PKISharp.WACS.Clients;
using PKISharp.WACS.Clients.DNS;
using PKISharp.WACS.Plugins.Interfaces;
using PKISharp.WACS.Services;
using System;
using System.Threading.Tasks;

namespace PKISharp.WACS.Plugins.ValidationPlugins.Dns
{
    internal class Acme : DnsValidation<Acme>
    {
        private readonly IInputService _input;
        private readonly ProxyService _proxy;
        private readonly AcmeOptions _options;

        public Acme(
            LookupClientProvider dnsClient,
            ILogService log,
            ISettingsService settings,
            IInputService input,
            ProxyService proxy,
            AcmeOptions options) :
            base(dnsClient, log, settings)
        {
            _options = options;
            _input = input;
            _proxy = proxy;
        }

        /// <summary>
        /// Send API call to the acme-dns server
        /// </summary>
        /// <param name="recordName"></param>
        /// <param name="token"></param>
        public override async Task<bool> CreateRecord(ValidationContext context, string recordName, string token)
        {
            var client = new AcmeDnsClient(_dnsClient, _proxy, _log, _settings, _input, new Uri(_options.BaseUri));
            return await client.Update(context.Identifier, token);
        }

        public override Task DeleteRecord(ValidationContext context, string recordName, string token) => Task.CompletedTask;
    }
}