Heart 1.3.842.34c2ab5
Heart is base back end library for your c++ Qt projects.
QH::AccessToken Class Reference

The AccessToken class contains information duration of the access. Token are byte array for validation access users or another network member on nodes. In usually cases toke add permissions for database objects. More...

#include <accesstoken.h>

Inheritance diagram for QH::AccessToken:
Inheritance graph
Collaboration diagram for QH::AccessToken:
Collaboration graph

Public Types

enum  Duration : int {
  Second = 1 , Minute = 60 * Second , Hour = 60 * Minute , Day = 24 * Hour ,
  Week = 7 * Day , Month = 30 * Day , Year = 365 * Day
}
 The Duration enum. This enum contains a long time unit. More...
 

Public Member Functions

 AccessToken (int duration, const QByteArray &entropy="")
 AccessToken This constructor create token on duration (in seconds).
 
 AccessToken (const QByteArray &other)
 AccessToken - Create token from bytes array of another token.
 
 AccessToken ()
 AccessToken constructor by default create not valid token.
 
 AccessToken (const AccessToken &other)
 AccessToken copy constructor.
 
bool isValid () const
 isValid This method check this toke to valid.
 
void clear ()
 clearThis Method reset all data of token.
 
bool operator== (const AccessToken &other) const
 operator == compare left and right values with type AccessToken.
 
bool operator!= (const AccessToken &other) const
 operator != compare left and right values with type AccessToken.
 
AccessTokenoperator= (const AccessToken &other)
 operator = this is operator of copy objects.
 
- Public Member Functions inherited from QH::StreamBase
 StreamBase ()
 
virtual ~StreamBase ()
 
bool fromBytes (const QByteArray &data)
 fromBytes This method provide initialization of object from byte array.
 
QByteArray toBytes () const
 toBytes This method convert a current object to bytes array.
 
bool fromBase64 (const QString &data)
 fromBase64 This method provide initialization of object from the base64 string.
 
bool fromBase64 (const QByteArray &data)
 fromBase64 This method provide initialization of object from the base64 string.
 
QByteArray toBase64 () const
 toBase64 This method convert a current object to the base64 string.
 
template<class T >
T & copy (const StreamBase &right)
 copy This is base copy method for all StreamBase structures. Default implementation it is copy from byteArray.
 
template<class T >
bool compare (const T &right)
 compare This method compare array signatures of this and right objects.
 

Protected Member Functions

QDataStream & fromStream (QDataStream &stream)
 fromStream This method should be read all bytes from the stream object and full the current object.
 
QDataStream & toStream (QDataStream &stream) const
 fromStream This method should be write all members of the current object to the stream object.
 
- Protected Member Functions inherited from QH::StreamBase
virtual int parsingVersion () const
 parsingVersion this method return parsing version of Qt. By Default is 0 (last available parsing). see https://doc.qt.io/qt-6/qdatastream.html#Version-enum
 
virtual unsigned int typeId () const
 typeId This method return id of type.
 

Detailed Description

The AccessToken class contains information duration of the access. Token are byte array for validation access users or another network member on nodes. In usually cases toke add permissions for database objects.

Definition at line 24 of file accesstoken.h.

Member Enumeration Documentation

◆ Duration

The Duration enum. This enum contains a long time unit.

Enumerator
Second 

The one second.

Minute 

The one minute.

Hour 

The one hour.

Day 

The one day.

Week 

The one Week.

Month 

The one Month.

Year 

The one year.

Definition at line 31 of file accesstoken.h.

Constructor & Destructor Documentation

◆ AccessToken() [1/4]

QH::AccessToken::AccessToken ( int  duration,
const QByteArray &  entropy = "" 
)
explicit

AccessToken This constructor create token on duration (in seconds).

Parameters
durationThis is value in seconds.
entropyThis is random bytes array for generate token. By Default is empty string.

Definition at line 27 of file accesstoken.cpp.

◆ AccessToken() [2/4]

QH::AccessToken::AccessToken ( const QByteArray &  other)
explicit

AccessToken - Create token from bytes array of another token.

Parameters
otherThis is bytes array of another token value.

Definition at line 32 of file accesstoken.cpp.

Here is the call graph for this function:

◆ AccessToken() [3/4]

QH::AccessToken::AccessToken ( )
explicitdefault

AccessToken constructor by default create not valid token.

◆ AccessToken() [4/4]

QH::AccessToken::AccessToken ( const AccessToken other)
default

AccessToken copy constructor.

Parameters
other

Member Function Documentation

◆ clear()

void QH::AccessToken::clear ( )

clearThis Method reset all data of token.

Definition at line 45 of file accesstoken.cpp.

◆ fromStream()

QDataStream & QH::AccessToken::fromStream ( QDataStream &  stream)
protectedvirtual

fromStream This method should be read all bytes from the stream object and full the current object.

Note
The implementation of this method should be invoke a method of base class.
Parameters
streamThis is Qt stream object.
Returns
Qt stream object.

Examle of base simple implementation:

QDataStream &ExampleClass::fromStream(QDataStream &stream) const {
stream >> exampleMember;
return stream;
}
virtual QDataStream & toStream(QDataStream &stream) const =0
fromStream This method should be write all members of the current object to the stream object.

Implements QH::StreamBase.

Definition at line 61 of file accesstoken.cpp.

◆ isValid()

bool QH::AccessToken::isValid ( ) const

isValid This method check this toke to valid.

Returns
Return true if token is valid.

Definition at line 40 of file accesstoken.cpp.

◆ operator!=()

bool QH::AccessToken::operator!= ( const AccessToken other) const

operator != compare left and right values with type AccessToken.

Parameters
otherThis is another object of the AccessTokens.
Returns
False if 2 object is equals.

Definition at line 55 of file accesstoken.cpp.

Here is the call graph for this function:

◆ operator=()

AccessToken & QH::AccessToken::operator= ( const AccessToken other)
default

operator = this is operator of copy objects.

Parameters
other
Returns

◆ operator==()

bool QH::AccessToken::operator== ( const AccessToken other) const

operator == compare left and right values with type AccessToken.

Parameters
otherThis is another object of the AccessTokens.
Returns
True if 2 object is equals.

Definition at line 51 of file accesstoken.cpp.

Here is the caller graph for this function:

◆ toStream()

QDataStream & QH::AccessToken::toStream ( QDataStream &  stream) const
protectedvirtual

fromStream This method should be write all members of the current object to the stream object.

Note
The implementation of this method should be invoke a method of base class.
Parameters
streamThis is Qt stream object.
Returns
Qt stream object.

Examle of base simple implementation:

QDataStream &ExampleClass::toStream(QDataStream &stream) const {
stream << exampleMember;
return stream;
}

Implements QH::StreamBase.

Definition at line 68 of file accesstoken.cpp.


The documentation for this class was generated from the following files: