QcIdentityStore Class
The player identities a world has seen (decision E-252), kept in identities.json in the world directory: the server's salt and, per player name, the identity its first login registered (trust on first use). More...
| Header: | #include <server/login/QcIdentityStore.h> |
Public Types
| struct | Identity |
Public Functions
| QcIdentityStore() | |
| bool | add(const QString &name, const QByteArray &identity, const QDateTime &now) |
| const QcIdentityStore::Identity * | find(const QString &name) const |
| QString | fingerprintOf(const QString &name) const |
| QcStatus | flush() |
| bool | hasUnsavedChanges() const |
| bool | isFull() const |
| QStringList | open(const QString &directory) |
| const QByteArray & | salt() const |
| qsizetype | size() const |
Static Public Members
| const QStringView | fileName |
| const int | formatVersion |
| const qsizetype | maxEntries |
| const qint64 | maxFileBytes |
Detailed Description
Later logins of that name must prove the same identity. Names compare like the access list's (cleaned, without case). Without a world directory everything lives in memory. A damaged file is copied aside and the world starts with a new salt and no identities (every fingerprint changes, so access entries bound to the old ones match nobody: fail closed).
Member Function Documentation
QcIdentityStore::QcIdentityStore()
A store in memory with a random salt.
bool QcIdentityStore::add(const QString &name, const QByteArray &identity, const QDateTime &now)
Registers identity as the first one of name at now. Returns false when the store is full, the name is taken or the identity has the wrong size. It counts at once and is written by the next flush() (decision E-273).
const QcIdentityStore::Identity *QcIdentityStore::find(const QString &name) const
Returns the identity registered for name; nullptr when there is none.
QString QcIdentityStore::fingerprintOf(const QString &name) const
Returns the fingerprint registered for name, empty when there is none.
QcStatus QcIdentityStore::flush()
Writes the file when identities were added since the last flush. Returns an error when it could not be written (the identities still count until the restart, the next addition tries again).
bool QcIdentityStore::hasUnsavedChanges() const
Returns whether identities were added since the last flush.
bool QcIdentityStore::isFull() const
Returns whether maxEntries identities are registered.
QStringList QcIdentityStore::open(const QString &directory)
Reads identities.json in directory. Returns the warnings that name its problems. A new store keeps its random salt, written with the first identity.
const QByteArray &QcIdentityStore::salt() const
Returns the server's salt of the fingerprints.
qsizetype QcIdentityStore::size() const
Returns the number of identities.
Member Variable Documentation
const QStringView QcIdentityStore::fileName
The name of the file in the world directory.
const int QcIdentityStore::formatVersion
The format of the file.
const qsizetype QcIdentityStore::maxEntries
Identities kept at most.
const qint64 QcIdentityStore::maxFileBytes
The largest file read.