TsgcWSAPIKeyManager › Methods › ImportKeys
Stream-based import of keys and audit log.
procedure ImportKeys(aStream: TStream);
| Name | Type | Description |
|---|---|---|
aStream | TStream | Source stream positioned at the start of a payload previously produced by ExportKeys or SaveToFile. Read from the current Position to the end. |
Stream-based counterpart of LoadFromFile. Parses the versioned header, decrypts the payload with Storage.EncryptionKey when needed, then replaces the in-memory key store and audit log with the contents of the stream. Raises on header mismatch, bad decryption or truncated input. Useful for failover (pull state from an HTTP replication endpoint) and for tests (snapshot the store into a TMemoryStream, mutate, then roll back with ImportKeys).
// Pull the key store from a replication endpoint on startup
var
oStream: TMemoryStream;
begin
oStream := TMemoryStream.Create;
try
oHTTPClient.Get('https://primary/apikeys/replicate', oStream);
oStream.Position := 0;
sgcWSAPIKeyManager1.ImportKeys(oStream);
finally
sgcFree(oStream);
end;
end;