summaryrefslogtreecommitdiffstats
path: root/src/main.lib/Plugins/ValidationPlugins/Http/WebDav/WebDav.cs
blob: 16bc141c942e08bcba59fa0ea2172a8f1bfeb781 (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
using PKISharp.WACS.Client;
using PKISharp.WACS.Services;
using System.Threading.Tasks;

namespace PKISharp.WACS.Plugins.ValidationPlugins.Http
{
    internal class WebDav : HttpValidation<WebDavOptions, WebDav>
    {
        private readonly WebDavClientWrapper _webdavClient;

        public WebDav(
            WebDavOptions options, HttpValidationParameters pars,
            RunLevel runLevel, ProxyService proxy) :
            base(options, runLevel, pars) => _webdavClient = new WebDavClientWrapper(_options.Credential, pars.LogService, proxy);

        protected override async Task DeleteFile(string path) => _webdavClient.Delete(path);

        protected override async Task DeleteFolder(string path) => _webdavClient.Delete(path);

        protected override async Task<bool> IsEmpty(string path) => !_webdavClient.IsEmpty(path);

        protected override char PathSeparator => '/';

        protected override async Task WriteFile(string path, string content) => _webdavClient.Upload(path, content);
        public override async Task CleanUp()
        {
            await base.CleanUp();
            _webdavClient.Dispose();
        }
    }
}