big changes
This commit is contained in:
@@ -2,10 +2,41 @@ namespace ZA.CoreService.ESBCertificateManager.Models;
|
||||
|
||||
public sealed class AppSettings
|
||||
{
|
||||
public string EnvironmentCode { get; set; } = "TEST";
|
||||
|
||||
public string LogDirectory { get; set; } = "Logs";
|
||||
|
||||
/// <summary>
|
||||
/// Sonic-/SMC-Verbindungen. Container kommen aus KnownContainers bzw. Live-Discovery.
|
||||
/// </summary>
|
||||
public List<SonicConnection> SonicConnections { get; set; } = [];
|
||||
public DatabaseSettings Database { get; set; } = new();
|
||||
|
||||
public RuntimeSettings Runtime { get; set; } = new();
|
||||
|
||||
public AlwaysEncryptedSettings AlwaysEncrypted { get; set; } = new();
|
||||
}
|
||||
|
||||
public sealed class DatabaseSettings
|
||||
{
|
||||
public string ConnectionString { get; set; } = string.Empty;
|
||||
}
|
||||
|
||||
public sealed class RuntimeSettings
|
||||
{
|
||||
public string JavaExecutablePath { get; set; } =
|
||||
@"Runtime\bin\java.exe";
|
||||
|
||||
public string SonicClientLibraryPath { get; set; } =
|
||||
@"Runtime\SonicClient\lib";
|
||||
|
||||
public bool SetupCompleted { get; set; }
|
||||
}
|
||||
|
||||
public sealed class AlwaysEncryptedSettings
|
||||
{
|
||||
public string CertificateThumbprint { get; set; } =
|
||||
string.Empty;
|
||||
|
||||
public string StoreName { get; set; } =
|
||||
"My";
|
||||
|
||||
public string StoreLocation { get; set; } =
|
||||
"CurrentUser";
|
||||
}
|
||||
@@ -0,0 +1,136 @@
|
||||
using ZA.CoreService.ESBCertificateManager.Services;
|
||||
|
||||
namespace ZA.CoreService.ESBCertificateManager.Models;
|
||||
|
||||
/// <summary>
|
||||
/// Aus dbo.SonicConnection geladene Verbindungsdaten.
|
||||
/// CredentialSecret wird durch Microsoft.Data.SqlClient
|
||||
/// clientseitig entschlüsselt.
|
||||
/// </summary>
|
||||
public sealed class DatabaseSonicConnection
|
||||
{
|
||||
public int Id { get; init; }
|
||||
|
||||
public required string Name { get; init; }
|
||||
|
||||
public required string ManagementHost { get; init; }
|
||||
|
||||
public int? ManagementPort { get; init; }
|
||||
|
||||
public string? ConnectionProtocol { get; init; }
|
||||
|
||||
public string? DomainName { get; init; }
|
||||
|
||||
public string? CredentialUserName { get; init; }
|
||||
|
||||
public string? CredentialReference { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Nur zur Laufzeit verfügbar.
|
||||
/// Darf niemals protokolliert oder angezeigt werden.
|
||||
/// </summary>
|
||||
public string? CredentialSecret { get; init; }
|
||||
|
||||
public string? JavaHomePath { get; init; }
|
||||
|
||||
public string? SonicHomePath { get; init; }
|
||||
|
||||
public string? Notes { get; init; }
|
||||
|
||||
public bool IsActive { get; init; }
|
||||
|
||||
public bool HasCredentials =>
|
||||
!string.IsNullOrWhiteSpace(CredentialUserName)
|
||||
&& !string.IsNullOrEmpty(CredentialSecret);
|
||||
|
||||
public string BuildConnectionUrl()
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(ConnectionProtocol))
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
$"Bei der Sonic-Verbindung '{Name}' fehlt ConnectionProtocol.");
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(ManagementHost))
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
$"Bei der Sonic-Verbindung '{Name}' fehlt ManagementHost.");
|
||||
}
|
||||
|
||||
if (ManagementPort is null or < 1 or > 65535)
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
$"Bei der Sonic-Verbindung '{Name}' fehlt ein gültiger ManagementPort.");
|
||||
}
|
||||
|
||||
string protocol = ConnectionProtocol
|
||||
.Trim()
|
||||
.TrimEnd(':', '/');
|
||||
|
||||
string host = ManagementHost.Trim();
|
||||
|
||||
return $"{protocol}://{host}:{ManagementPort.Value}";
|
||||
}
|
||||
|
||||
public SonicConnection ToRuntimeConnection(
|
||||
RuntimeSettings runtimeSettings)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(DomainName))
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
$"Bei der Sonic-Verbindung '{Name}' fehlt DomainName.");
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(CredentialUserName))
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
$"Bei der Sonic-Verbindung '{Name}' fehlt der Benutzername.");
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(CredentialSecret))
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
$"Bei der Sonic-Verbindung '{Name}' fehlen die Zugangsdaten. " +
|
||||
"Bitte das Setup ausführen.");
|
||||
}
|
||||
|
||||
string javaExecutablePath =
|
||||
PathResolver.ResolvePath(
|
||||
runtimeSettings.JavaExecutablePath);
|
||||
|
||||
string sonicClientLibraryPath =
|
||||
PathResolver.ResolvePath(
|
||||
runtimeSettings.SonicClientLibraryPath);
|
||||
|
||||
string javaBinDirectory =
|
||||
Path.GetDirectoryName(javaExecutablePath)
|
||||
?? string.Empty;
|
||||
|
||||
string javaHome =
|
||||
Directory.GetParent(javaBinDirectory)?.FullName
|
||||
?? string.Empty;
|
||||
|
||||
string sonicHome =
|
||||
Directory.GetParent(sonicClientLibraryPath)?.FullName
|
||||
?? string.Empty;
|
||||
|
||||
return new SonicConnection
|
||||
{
|
||||
Name = Name,
|
||||
DomainName = DomainName,
|
||||
ConnectionUrl = BuildConnectionUrl(),
|
||||
Username = CredentialUserName,
|
||||
|
||||
// Nur Laufzeitwert, bereits clientseitig entschlüsselt.
|
||||
Password = CredentialSecret,
|
||||
|
||||
JavaPath = javaExecutablePath,
|
||||
JavaHome = javaHome,
|
||||
MfClientLibPath = sonicClientLibraryPath,
|
||||
SonicHome = sonicHome,
|
||||
|
||||
TimeoutSeconds = 120,
|
||||
PostRestartDelaySeconds = 20
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,12 @@ public sealed class DeploymentTarget
|
||||
public required string TargetDirectory { get; init; }
|
||||
public required string CertificateFileName { get; init; }
|
||||
|
||||
public bool BackupEnabled { get; init; } = true;
|
||||
|
||||
public string BackupDirectoryName { get; init; } = "Backup";
|
||||
|
||||
public int? BackupRetentionDays { get; init; }
|
||||
|
||||
/// <summary>Name des Sonic-ESB-Containers (z.B. "sonic-container-a").</summary>
|
||||
public string ContainerName { get; init; } = string.Empty;
|
||||
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
namespace ZA.CoreService.ESBCertificateManager.Models;
|
||||
|
||||
public sealed class LocalSetupSelection
|
||||
{
|
||||
public string EnvironmentCode { get; set; } =
|
||||
string.Empty;
|
||||
|
||||
public int SonicConnectionId { get; set; }
|
||||
|
||||
public int SonicCredentialId { get; set; }
|
||||
|
||||
public string ConnectionName { get; set; } =
|
||||
string.Empty;
|
||||
|
||||
public string CredentialName { get; set; } =
|
||||
string.Empty;
|
||||
|
||||
public DateTimeOffset SavedAtUtc { get; set; }
|
||||
}
|
||||
@@ -15,7 +15,16 @@ public sealed class SonicConnection
|
||||
public required string ConnectionUrl { get; init; }
|
||||
|
||||
public required string Username { get; init; }
|
||||
public required string Password { get; init; }
|
||||
/// <summary>
|
||||
/// Nur zur Laufzeit aus Always Encrypted geladen.
|
||||
/// Darf nicht geloggt oder dauerhaft gespeichert werden.
|
||||
/// </summary>
|
||||
public string Password { get; init; } = string.Empty;
|
||||
/// <summary>
|
||||
/// Verweis auf eine generische Windows-Anmeldeinformation.
|
||||
/// Enthält ausdrücklich kein Kennwort.
|
||||
/// </summary>
|
||||
public string CredentialReference { get; init; } = string.Empty;
|
||||
|
||||
/// <summary>Installationsroot (optional; Libs oft unter lib).</summary>
|
||||
public string SonicHome { get; init; } = @"C:\Sonic\MQ10.0";
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
namespace ZA.CoreService.ESBCertificateManager.Models;
|
||||
|
||||
public sealed class SonicCredentialProfile
|
||||
{
|
||||
public int SonicCredentialId { get; init; }
|
||||
|
||||
public int SonicConnectionId { get; init; }
|
||||
|
||||
public required string CredentialName { get; init; }
|
||||
|
||||
public required string UserName { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Durch Microsoft.Data.SqlClient clientseitig entschlüsselt.
|
||||
/// Darf niemals angezeigt oder protokolliert werden.
|
||||
/// </summary>
|
||||
public required string Secret { get; init; }
|
||||
|
||||
public bool IsDefault { get; init; }
|
||||
|
||||
public bool IsActive { get; init; }
|
||||
|
||||
public bool IsComplete =>
|
||||
!string.IsNullOrWhiteSpace(UserName)
|
||||
&& !string.IsNullOrEmpty(Secret);
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return CredentialName;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
namespace ZA.CoreService.ESBCertificateManager.Models;
|
||||
|
||||
public sealed class SonicSystemOption
|
||||
{
|
||||
public int SonicConnectionId { get; init; }
|
||||
|
||||
public required string ConnectionName { get; init; }
|
||||
|
||||
public required string EnvironmentCode { get; init; }
|
||||
|
||||
public required string DomainName { get; init; }
|
||||
|
||||
public required string ManagementHost { get; init; }
|
||||
|
||||
public int ManagementPort { get; init; }
|
||||
|
||||
public required string ConnectionProtocol { get; init; }
|
||||
|
||||
public required string ValidationContainerName { get; init; }
|
||||
|
||||
public string ConnectionUrl
|
||||
{
|
||||
get
|
||||
{
|
||||
string protocol = ConnectionProtocol
|
||||
.Trim()
|
||||
.TrimEnd(':', '/');
|
||||
|
||||
return
|
||||
$"{protocol}://{ManagementHost.Trim()}:{ManagementPort}";
|
||||
}
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return ConnectionName;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user