forked from ondra/colnod-connector
71 lines
2.3 KiB
C++
71 lines
2.3 KiB
C++
#pragma once
|
|
|
|
#include "entity.h"
|
|
#include <QSet>
|
|
#include <qsqlquery.h>
|
|
#include <QVariant>
|
|
#include <QDebug>
|
|
#include <QDateTime>
|
|
|
|
class Token : public Entity {
|
|
public:
|
|
// using Entity::Entity;
|
|
|
|
Token() = default;
|
|
Token(const QString& name, QString tokenData, const QString& decription = "mobile");
|
|
explicit Token(const QString& name);
|
|
~Token() override;
|
|
|
|
friend bool operator<(const Token &lToken, const Token &rToken){
|
|
return lToken.getLastModified() < rToken.getLastUpdate();
|
|
}
|
|
friend bool operator>(const Token &lToken, const Token &rToken){
|
|
return lToken.getLastModified() > rToken.getLastUpdate();
|
|
}
|
|
friend bool operator==(const Token &lToken, const Token &rToken){
|
|
return lToken.getId() == rToken.getId() &&
|
|
lToken.getName() == rToken.getName() &&
|
|
lToken.getDescription() == rToken.getDescription() &&
|
|
lToken.getLastUpdate() == rToken.getLastUpdate() &&
|
|
lToken.tokenType == rToken.tokenType &&
|
|
lToken.tokenBits == rToken.tokenBits &&
|
|
lToken.tokenData == rToken.tokenData &&
|
|
lToken.timeToLive == rToken.timeToLive &&
|
|
lToken.authErrors == rToken.authErrors &&
|
|
lToken.flags == rToken.flags &&
|
|
lToken.subjectId == rToken.subjectId;
|
|
}
|
|
|
|
|
|
const QString &getTokenType() const;
|
|
void setTokenType(const QString &tokenType);
|
|
int getTokenBits() const;
|
|
void setTokenBits(int tokenBits);
|
|
const QString &getTokenData() const;
|
|
void setTokenData(const QString &tokenData);
|
|
int getTimeToLive() const;
|
|
void setTimeToLive(int timeToLive);
|
|
int getAuthErrors() const;
|
|
void setAuthErrors(int authErrors);
|
|
const QSet<QString> &getFlags() const;
|
|
void setFlags(const QSet<QString> &flags);
|
|
const QUuid &getSubjectId() const;
|
|
void setSubjectId(const QUuid &subjectId);
|
|
|
|
|
|
QString subjectIdToStringWithoutBraces();
|
|
|
|
void fromSQLRecord(const QSqlQuery& query);
|
|
void fromJSON(const QJsonObject &json) override;
|
|
QJsonObject toJSON() const override;
|
|
|
|
private:
|
|
QString tokenType;
|
|
int tokenBits{};
|
|
QString tokenData;
|
|
int timeToLive{};
|
|
int authErrors{};
|
|
QSet<QString> flags;
|
|
QUuid subjectId;
|
|
};
|