< Summary

Information
Class: LOCKnet.App.AppServices
Assembly: LOCKnet.App
File(s): /home/runner/work/LOCKnet/LOCKnet/src/LOCKnet.App/AppServices.cs
Line coverage
100%
Covered lines: 31
Uncovered lines: 0
Coverable lines: 31
Total lines: 71
Line coverage: 100%
Branch coverage
50%
Covered branches: 1
Total branches: 2
Branch coverage: 50%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_Current()50%22100%
get_MasterKeyManager()100%11100%
get_SessionManager()100%11100%
get_ActivityMonitor()100%11100%
get_CredentialService()100%11100%
get_StorageDescriptor()100%11100%
.ctor(...)100%11100%
Initialize(...)100%11100%

File(s)

/home/runner/work/LOCKnet/LOCKnet/src/LOCKnet.App/AppServices.cs

#LineLine coverage
 1using LOCKnet.Core.Crypto;
 2using LOCKnet.Core.DataAbstractions;
 3using LOCKnet.Core.Security;
 4using LOCKnet.Core.Services;
 5using LOCKnet.Data;
 6using LOCKnet.Data.Repositories;
 7
 8namespace LOCKnet.App;
 9
 10/// <summary>
 11/// Zentraler Service-Container. Wird einmalig beim App-Start erzeugt
 12/// und von ViewModels über AppServices.Current zugegriffen.
 13/// </summary>
 14public sealed class AppServices
 15{
 16  private static AppServices? _current;
 17
 18  /// <summary>Die aktuelle, einmalig erzeugte Instanz.</summary>
 17219  public static AppServices Current => _current
 17220    ?? throw new InvalidOperationException("AppServices wurde noch nicht initialisiert.");
 21
 22  // ── Exposed services ──────────────────────────────────────────────────────
 23
 6524  public IMasterKeyManager MasterKeyManager { get; }
 4325  public ISessionManager SessionManager { get; }
 4126  public IActivityMonitor ActivityMonitor { get; }
 2127  public ICredentialService CredentialService { get; }
 228  public VaultStorageDescriptor StorageDescriptor { get; }
 29
 30  // ── Constructor ───────────────────────────────────────────────────────────
 31
 1932  private AppServices(string dbPath)
 1933  {
 1934    var storage = new VaultStorageBootstrap(dbPath);
 1935    StorageDescriptor = storage.Storage;
 36
 37    // Data layer
 1938    storage.InitializeAccessibleStorage();
 39
 1940    ICredentialRepository credRepo = storage.CreateCredentialRepository();
 1941    IMasterKeyRepository masterKeyRepo = storage.CreateMasterKeyRepository();
 1942    IVaultMigrationRepository vaultMigrationRepo = storage.CreateVaultMigrationRepository();
 43
 44    // Crypto layer
 1945    IKeyDerivationService kdf = new Pbkdf2KeyDerivationService();
 1946    IEncryptionService encryption = new AesGcmEncryptionService();
 1947    ICredentialEnvelopeService credentialEnvelope = new CredentialEnvelopeService(encryption);
 1948    ISecureStringService secureStr = new SecureStringService();
 49
 50    // Security layer
 1951    var sessionManager = new SessionManager();
 1952    SessionManager = sessionManager;
 1953    MasterKeyManager = new MasterKeyManager(kdf, masterKeyRepo, vaultMigrationRepo, encryption, credentialEnvelope, sess
 1954    ActivityMonitor = new ActivityMonitor(sessionManager)
 1955    {
 1956      Timeout = TimeSpan.FromSeconds(60)
 1957    };
 58
 59    // Service layer
 1960    CredentialService = new CredentialService(credRepo, masterKeyRepo, encryption, credentialEnvelope, sessionManager, s
 1961  }
 62
 63  /// <summary>
 64  /// Initialisiert die AppServices einmalig.
 65  /// </summary>
 66  /// <param name="dbPath">Pfad zur SQLite-Datenbank.</param>
 67  public static void Initialize(string dbPath)
 1968  {
 1969    _current = new AppServices(dbPath);
 1970  }
 71}