blob: a71763bc3e01abc10492169e981d21aba9c5cc6e (
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
44
45
46
47
48
49
50
51
52
53
54
55
56
|
using PKISharp.WACS.Configuration;
using PKISharp.WACS.DomainObjects;
using PKISharp.WACS.Services;
using System;
using System.Threading.Tasks;
namespace PKISharp.WACS.Plugins.ValidationPlugins.Http
{
internal class FtpOptionsFactory : HttpValidationOptionsFactory<Ftp, FtpOptions>
{
private readonly ILogService _log;
public FtpOptionsFactory(
ILogService log, IArgumentsService arguments) :
base(arguments) => _log = log;
public override bool PathIsValid(string path)
{
try
{
var uri = new Uri(path);
return uri.Scheme == "ftp" || uri.Scheme == "ftps";
}
catch (Exception ex)
{
_log.Error(ex, "Invalid path");
return false;
}
}
public override string[] WebrootHint(bool allowEmpty)
{
return new[] {
"Enter an ftp path that leads to the web root of the host for http authentication",
" Example, ftp://domain.com:21/site/wwwroot/",
" Example, ftps://domain.com:990/site/wwwroot/"
};
}
public override async Task<FtpOptions?> Default(Target target)
{
return new FtpOptions(BaseDefault(target))
{
Credential = new NetworkCredentialOptions(_arguments)
};
}
public override async Task<FtpOptions?> Aquire(Target target, IInputService inputService, RunLevel runLevel)
{
return new FtpOptions(await BaseAquire(target, inputService))
{
Credential = new NetworkCredentialOptions(_arguments, inputService)
};
}
}
}
|