• UserManager
  • UserManager Class


    This class represents the manager for the users in nymead. More...

    Header: #include <UserManager>

    Public Types

    enum UserError { UserErrorNoError, UserErrorBackendError, UserErrorInvalidUserId, UserErrorDuplicateUserId, ..., UserErrorPermissionDenied }

    Public Functions

    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)

    Detailed Description

    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.

    Member Type Documentation

    enum UserManager::UserError

    This enum represents the possible errors the UserManager can have.

    nymeaserver::UserManager::UserErrorNoError0No error occured. Everything is ok.4
    nymeaserver::UserManager::UserErrorBackendError1Something went wrong in the manager. This is probably caused by a database error.
    nymeaserver::UserManager::UserErrorInvalidUserId2The given user name is not valid.
    nymeaserver::UserManager::UserErrorDuplicateUserId3The given user name already exits. Please use a different user name.
    nymeaserver::UserManager::UserErrorBadPassword4The given password is to weak. Please use a stronger password.
    nymeaserver::UserManager::UserErrorTokenNotFound5The given token is unknown to the UserManager.
    nymeaserver::UserManager::UserErrorPermissionDenied6The permission is denied. Either invalid username, password or token.

    Member Function Documentation

    UserManager::UserManager(const QString & dbName, QObject * parent = nullptr)

    Constructs a new UserManager with the given dbName and parent.

    QByteArray UserManager::authenticate(const QString & username, const QString & password, const QString & deviceName)

    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.

    void UserManager::cancelPushButtonAuth(int transactionId)

    Cancel the push button authentication with the given transactionId.

    See also requestPushButtonAuth.

    UserError UserManager::createUser(const QString & username, const QString & password)

    Creates a new user with the given username and password. Returns the UserError to inform about the result.

    bool UserManager::initRequired() const

    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 anonimous token. This may be used to determine whether a first-time setup is required.

    bool UserManager::pushButtonAuthAvailable() const

    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.

    nymeaserver::UserManager::UserError UserManager::removeToken(const QUuid & tokenId)

    Removes the token with the given tokenId. Returns UserError to inform about the result.

    UserError UserManager::removeUser(const QString & username)

    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.

    int UserManager::requestPushButtonAuth(const QString & deviceName)

    Start the push button authentication for the device with the given deviceName. Returns the transaction id as refference to the request.

    QList<TokenInfo> UserManager::tokens(const QString & username) const

    Returns a list of tokens for the given username.

    See also TokenInfo.

    QString UserManager::userForToken(const QByteArray & token) const

    Returns the username for the given token. If the token is invalid, an empty string will be returned.

    QStringList UserManager::users() const

    Returns the list of user names for this UserManager.

    bool UserManager::verifyToken(const QByteArray & token)

    Returns true, if the given token is valid.