Heart 1.4.918.d927d9c
Heart is base back end library for your c++ Qt projects.
Loading...
Searching...
No Matches
accesstoken.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2018-2025 QuasarApp.
3 * Distributed under the lgplv3 software license, see the accompanying
4 * Everyone is permitted to copy and distribute verbatim copies
5 * of this license document, but changing it is not allowed.
6*/
7
8#ifndef ACCSESTOKEN_H
9#define ACCSESTOKEN_H
10
11#include "streambase.h"
12
13#include <QByteArray>
14#include <QDateTime>
15#include <heart_global.h>
16
17namespace QH {
18
24class HEARTSHARED_EXPORT AccessToken : public StreamBase
25{
26public:
27
31 enum Duration: int {
33 Second = 1,
35 Minute = 60 * Second,
37 Hour = 60 * Minute,
39 Day = 24 * Hour,
41 Week = 7 * Day,
43 Month = 30 * Day,
45 Year = 365 * Day,
46 };
47
53 explicit AccessToken(int duration, const QByteArray& entropy = "");
54
59 explicit AccessToken(const QByteArray& other);
60
64 explicit AccessToken();
65
70 AccessToken(const AccessToken& other);
71
76 bool isValid() const;
77
81 void clear();
82
88 bool operator == (const AccessToken& other) const;
89
95 bool operator != (const AccessToken& other) const;
96
102 AccessToken &operator =(const AccessToken& other);
103
104protected:
105 QDataStream &fromStream(QDataStream &stream);
106 QDataStream &toStream(QDataStream &stream) const;
107
108private:
109 QByteArray _data;
110 int _duration;
111
112 // StreamBase interface
113
114
115 QByteArray generate(const QByteArray &user);
116};
117
118}
119
120#endif // ACCSESTOKEN_H
The AccessToken class contains information duration of the access. Token are byte array for validatio...
Definition accesstoken.h:25
QDataStream & toStream(QDataStream &stream) const
fromStream This method should be write all members of the current object to the stream object.
AccessToken(const AccessToken &other)
AccessToken copy constructor.
QDataStream & fromStream(QDataStream &stream)
fromStream This method should be read all bytes from the stream object and full the current object.
AccessToken(int duration, const QByteArray &entropy="")
AccessToken This constructor create token on duration (in seconds).
bool isValid() const
isValid This method check this toke to valid.
void clear()
clearThis Method reset all data of token.
Duration
The Duration enum. This enum contains a long time unit.
Definition accesstoken.h:31
@ Minute
The one minute.
Definition accesstoken.h:35
@ Week
The one Week.
Definition accesstoken.h:41
@ Month
The one Month.
Definition accesstoken.h:43
@ Day
The one day.
Definition accesstoken.h:39
@ Second
The one second.
Definition accesstoken.h:33
@ Year
The one year.
Definition accesstoken.h:45
@ Hour
The one hour.
Definition accesstoken.h:37
AccessToken()
AccessToken constructor by default create not valid token.
The QH namespace - QuasarApp Heart namespace. This namespace contains all classes of the Heart librar...
Definition heart.cpp:13