TsgcWSAPIKeyManager › Methods › LoadFromFile
Restores keys and audit log from file.
procedure LoadFromFile(const aFileName: string = '');
| Name | Type | Description |
|---|---|---|
aFileName | const string | Source path. Empty means use Storage.FileName. Returns silently when the path does not exist (first-run scenario). |
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.
// Restore state at startup, then attach the manager to the server
sgcWSAPIKeyManager1.LoadFromFile('apikeys.dat');
sgcWebSocketHTTPServer1.APIKeyManager := sgcWSAPIKeyManager1;
sgcWebSocketHTTPServer1.Active := True;