TsgcWSAPIKeyManagerMethods › LoadFromFile

LoadFromFile Method

Restores keys and audit log from file.

Syntax

procedure LoadFromFile(const aFileName: string = '');

Parameters

NameTypeDescription
aFileNameconst stringSource path. Empty means use Storage.FileName. Returns silently when the path does not exist (first-run scenario).

Remarks

Populates the in-memory store and audit log from a previously saved file, decrypting it with Storage.EncryptionKey when the file is encrypted. Existing in-memory entries are replaced wholesale — call it exactly once at startup, before assigning the manager to a server's APIKeyManager property. Validates the versioned header and raises on a mismatch or a failed decryption. Stats counters are rebuilt from the loaded entries.

Example

// Restore state at startup, then attach the manager to the server
sgcWSAPIKeyManager1.LoadFromFile('apikeys.dat');
sgcWebSocketHTTPServer1.APIKeyManager := sgcWSAPIKeyManager1;
sgcWebSocketHTTPServer1.Active := True;

Back to Methods