Prepare Pro 1.0.1 imports and license tooling

This commit is contained in:
livio committed 2026-09-28 19:41:57 +02:00
1 parent 62f28c5621
commit 0b5017739c
13 files changed
+437 -48

No files matched your search

+27 -1
View File
@@ -5,6 +5,21 @@ internal static class Program
[STAThread]
private static void Main(string[] args)
{
if (args.Length == 2 && args[0].Equals("--export-key", StringComparison.OrdinalIgnoreCase))
{
var password = Environment.GetEnvironmentVariable("LME_LICENSE_BACKUP_PASSWORD");
if (string.IsNullOrWhiteSpace(password))
{
throw new InvalidOperationException("Imposta LME_LICENSE_BACKUP_PASSWORD per esportare la chiave.");
}
var exportRepository = new LicenseRepository();
exportRepository.Initialize();
exportRepository.ExportSigningKeyBackup(Path.GetFullPath(args[1]), password);
Console.WriteLine($"Backup chiave creato: {Path.GetFullPath(args[1])}");
return;
}
if (args.Contains("--self-test", StringComparer.OrdinalIgnoreCase))
{
RunSelfTest();
@@ -26,6 +41,7 @@ internal static class Program
{
var testDirectory = Path.Combine(Path.GetTempPath(), $"LME-License-SelfTest-{Guid.NewGuid():N}");
var importedDirectory = Path.Combine(Path.GetTempPath(), $"LME-License-SelfTest-{Guid.NewGuid():N}");
var incompatibleDirectory = Path.Combine(Path.GetTempPath(), $"LME-License-SelfTest-{Guid.NewGuid():N}");
const string backupPassword = "LME-Test-Backup-Password-2026";
try
{
@@ -60,11 +76,21 @@ internal static class Program
throw new InvalidOperationException("La chiave importata non produce licenze compatibili.");
}
var incompatibleRepository = new LicenseRepository(incompatibleDirectory, allowKeyGeneration: true);
incompatibleRepository.Initialize();
var strictRepository = new LicenseRepository(incompatibleDirectory);
strictRepository.Initialize();
if (File.Exists(Path.Combine(incompatibleDirectory, "manual-license-private.dpapi"))
|| Directory.GetFiles(incompatibleDirectory, "manual-license-private-incompatible-*.dpapi").Length != 1)
{
throw new InvalidOperationException("La chiave incompatibile non e stata conservata correttamente.");
}
Console.WriteLine("Self-test licenze e portabilita chiave completato.");
}
finally
{
foreach (var directory in new[] { testDirectory, importedDirectory })
foreach (var directory in new[] { testDirectory, importedDirectory, incompatibleDirectory })
{
var fullPath = Path.GetFullPath(directory);
var tempRoot = Path.GetFullPath(Path.GetTempPath());