Skip to content

Commit

Permalink
Quick fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Aymen TROUDI authored and Aymen TROUDI committed Aug 8, 2023
1 parent 88b42e3 commit 0fc5e1e
Show file tree
Hide file tree
Showing 6 changed files with 168 additions and 169 deletions.
23 changes: 11 additions & 12 deletions src/App/Commands/EccCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,23 @@ public class EccCommand : PfxCommand
public EccCommand(ICertificateService certificateService, IConsoleService consoleService) : base(certificateService, consoleService)
{
CertificateFile = $"ECC-{DateTime.Now:yyyyMMddTHHmmss}.pfx";
KeySize = KeySizes.First();
KeySize = KeySizes[0];
}

protected override void Execute(CommandLineApplication app)
{
var parameters = new PfxParameters
{
DnsName = DnsName,
KeySize = KeySize,
ValidityInYears = ValidityInYears,
CertificateFile = CertificateFile,
CertificatePassword = CertificatePassword,
OutputDirectory = OutputDirectory,
PfxType = PfxType.Ecc
};

ConsoleService.RenderStatus(() =>
{
var parameters = new PfxParameters
{
DnsName = DnsName,
KeySize = KeySize,
ValidityInYears = ValidityInYears,
CertificateFile = CertificateFile,
CertificatePassword = CertificatePassword,
OutputDirectory = OutputDirectory,
PfxType = PfxType.Ecc
};
CertificateService.GenerateEcc(parameters);
ConsoleService.RenderPfx(parameters);
});
Expand Down
22 changes: 12 additions & 10 deletions src/App/Commands/JwkCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,18 @@ public JwkCommand(ICertificateService certificateService, IConsoleService consol

protected override void Execute(CommandLineApplication app)
{
var parameters = new JwkParameters
ConsoleService.RenderStatus(() =>
{
KeyId = KeyId,
KeyUse = KeyUse,
CertificateFile = CertificateFile,
CertificatePassword = CertificatePassword
};

var jwk = _certificateService.GenerateJwk(parameters);
ConsoleService.RenderJwk(parameters, jwk);
ConsoleService.CopyTextToClipboard(jwk);
var parameters = new JwkParameters
{
KeyId = KeyId,
KeyUse = KeyUse,
CertificateFile = CertificateFile,
CertificatePassword = CertificatePassword
};
var jwk = _certificateService.GenerateJwk(parameters);
ConsoleService.RenderJwk(parameters, jwk);
ConsoleService.CopyTextToClipboard(jwk);
});
}
}
23 changes: 11 additions & 12 deletions src/App/Commands/RsaCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,23 @@ public class RsaCommand : PfxCommand
public RsaCommand(ICertificateService certificateService, IConsoleService consoleService) : base(certificateService, consoleService)
{
CertificateFile = $"RSA-{DateTime.Now:yyyyMMddTHHmmss}.pfx";
KeySize = KeySizes.First();
KeySize = KeySizes[0];
}

protected override void Execute(CommandLineApplication app)
{
var parameters = new PfxParameters
{
DnsName = DnsName,
KeySize = KeySize,
ValidityInYears = ValidityInYears,
CertificateFile = CertificateFile,
CertificatePassword = CertificatePassword,
OutputDirectory = OutputDirectory,
PfxType = PfxType.Rsa
};

ConsoleService.RenderStatus(() =>
{
var parameters = new PfxParameters
{
DnsName = DnsName,
KeySize = KeySize,
ValidityInYears = ValidityInYears,
CertificateFile = CertificateFile,
CertificatePassword = CertificatePassword,
OutputDirectory = OutputDirectory,
PfxType = PfxType.Rsa
};
CertificateService.GenerateRsa(parameters);
ConsoleService.RenderPfx(parameters);
});
Expand Down
8 changes: 4 additions & 4 deletions src/App/Extensions/FluentValidationExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,21 @@ public static IRuleBuilderOptions<T, TProperty> Required<T, TProperty>(this IRul
return ruleBuilder
.NotNull()
.NotEmpty()
.WithMessage("{PropertyName} is required.");
.WithMessage("'{PropertyName}' is required.");
}

public static IRuleBuilderOptions<T, string> FileExists<T>(this IRuleBuilder<T, string> ruleBuilder)
{
return ruleBuilder
.Must<T, string>((Func<T, string, bool>) ((x, val) => File.Exists(val)))
.WithMessage("File {PropertyName} does not exist.");
.WithMessage("File '{PropertyValue}' does not exist.");
}

public static IRuleBuilderOptions<T, string> DirectoryExists<T>(this IRuleBuilder<T, string> ruleBuilder)
{
return ruleBuilder
.Must<T, string>((Func<T, string, bool>) ((x, val) => Directory.Exists(val)))
.WithMessage("Directory {PropertyName} does not exist.");
.WithMessage("Directory '{PropertyValue}' does not exist.");
}

public static IRuleBuilderOptions<T, TProperty> In<T, TProperty>(this IRuleBuilder<T, TProperty> ruleBuilder, params TProperty[] values)
Expand All @@ -39,6 +39,6 @@ public static IRuleBuilderOptions<T, TProperty> In<T, TProperty>(this IRuleBuild

return ruleBuilder
.Must(values.Contains)
.WithMessage($"{{PropertyName}} must be one of these values '{string.Join(",", values)}'.");
.WithMessage($"'{{PropertyName}}' must be one of these values '{string.Join(",", values)}'.");
}
}
Loading

0 comments on commit 0fc5e1e

Please sign in to comment.