This class represents the manager for the users in nymead. More...
Header: | #include <UserManager> |
Inherits: |
enum | UserError { UserErrorNoError, UserErrorBackendError, UserErrorInvalidUserId, UserErrorDuplicateUserId, ..., UserErrorPermissionDenied } |
UserManager(const QString & dbName, QObject * parent = nullptr) | |
QByteArray | authenticate(const QString & username, const QString & password, const QString & deviceName) |
void | cancelPushButtonAuth(int transactionId) |
UserError | createUser(const QString & username, const QString & password) |
bool | initRequired() const |
bool | pushButtonAuthAvailable() const |
nymeaserver::UserManager::UserError | removeToken(const QUuid & tokenId) |
UserError | removeUser(const QString & username) |
int | requestPushButtonAuth(const QString & deviceName) |
QList<TokenInfo> | tokens(const QString & username) const |
QString | userForToken(const QByteArray & token) const |
QStringList | users() const |
bool | verifyToken(const QByteArray & token) |
void | pushButtonAuthFinished(int transactionId, bool success, const QByteArray & token) |
This class represents the manager for the users in nymead.
The user manager is responsible for managing the user database, tokens and authentication. The user manager creates a user database where all relevant information will be stored.
See also TokenInfo and PushButtonDBusService.
This enum represents the possible errors the UserManager can have.
Constant | Value | Description |
---|---|---|
nymeaserver::UserManager::UserErrorNoError | 0 | No error occured. Everything is ok.4 |
nymeaserver::UserManager::UserErrorBackendError | 1 | Something went wrong in the manager. This is probably caused by a database error. |
nymeaserver::UserManager::UserErrorInvalidUserId | 2 | The given user name is not valid. |
nymeaserver::UserManager::UserErrorDuplicateUserId | 3 | The given user name already exits. Please use a different user name. |
nymeaserver::UserManager::UserErrorBadPassword | 4 | The given password is to weak. Please use a stronger password. |
nymeaserver::UserManager::UserErrorTokenNotFound | 5 | The given token is unknown to the UserManager. |
nymeaserver::UserManager::UserErrorPermissionDenied | 6 | The permission is denied. Either invalid username, password or token. |
Constructs a new UserManager with the given dbName and parent.
Authenticated the given username with the given password for the deviceName. If the authentication was successfull, the token will be returned, otherwise the return value will be an empty byte array.
Cancel the push button authentication with the given transactionId.
See also requestPushButtonAuth.
Creates a new user with the given username and password. Returns the UserError to inform about the result.
Will return true if the database is working fine but doesn't have any information on users whatsoever. That is, neither a user nor an anonymous token. This may be used to determine whether a first-time setup is required.
Returns true if the push button authentication is available for this system.
[signal]
void UserManager::pushButtonAuthFinished(int transactionId, bool success, const QByteArray & token)This signal is emitted when the push authentication for the given transactionId is finished. If success is true, the resulting token contains a non empty string.
See also requestPushButtonAuth.
Removes the token with the given tokenId. Returns UserError to inform about the result.
Remove the user with the given username and all of its tokens. If the username is empty, all anonymous tokens (e.g. issued by pushbutton auth) will be cleared.
Start the push button authentication for the device with the given deviceName. Returns the transaction id as refference to the request.
Returns a list of tokens for the given username.
See also TokenInfo.
Returns the username for the given token. If the token is invalid, an empty string will be returned.
Returns the list of user names for this UserManager.
Returns true, if the given token is valid.