11#include <QCryptographicHash>
68template<
class CryptoImplementation>
86 bool auth(
int allowedTimeRangeSec, QString* retLoginedUserId)
const {
94 if (diff >= allowedTimeRangeSec) {
99 data.insert(0,
reinterpret_cast<const char*
>(&
_unixTime),
104 if (result && retLoginedUserId) {
119 data.insert(0,
reinterpret_cast<const char*
>(&
_unixTime),
169 QCryptographicHash::Sha256).
170 toBase64(QByteArray::Base64UrlEncoding);
195 QByteArray
decrypt(
const QByteArray &message,
const QByteArray &key)
override {
196 return CryptoImplementation::decrypt(message, key);
199 QByteArray
encrypt(
const QByteArray &message,
const QByteArray &key)
override {
200 return CryptoImplementation::encrypt(message, key);
203 QByteArray
signMessage(
const QByteArray &message,
const QByteArray &key)
const override {
204 return CryptoImplementation::signMessage(message, key);
207 bool checkSign(
const QByteArray &message,
const QByteArray &
signature,
const QByteArray &key)
const override {
208 return CryptoImplementation::checkSign(message,
signature, key);
The AsyncKeysAuth class is temaplate class for works with authorization of a pair of asynchronous key...
virtual QByteArray getPrivateKey() const =0
getPrivateKey This method should be return private key for the public key that saved in this object.
void setSignature(const QByteArray &newSignature)
setSignature Tihis is internal method for sets new signature value.
QByteArray encrypt(const QByteArray &message, const QByteArray &key) override
bool auth(int allowedTimeRangeSec, QString *retLoginedUserId) const
auth This method make authentication and return true if the authentication finished successful else f...
QByteArray decrypt(const QByteArray &message, const QByteArray &key) override
bool checkSign(const QByteArray &message, const QByteArray &signature, const QByteArray &key) const override
void setPublicKey(const QByteArray &newPublicKey)
setPublicKey This method sets new public key for authentication.
void setUnixTime(unsigned int newUnixTime)
setUnixTime This method sets new value of the unixTime propertye.
QByteArray signMessage(const QByteArray &message, const QByteArray &key) const override
unsigned int unixTime() const
unixTime This method return unix time that client added for authentication.
bool isValid() const
isValid this method check this ibject to valid.
const QByteArray & signature() const
signature This method return signature array.
const QByteArray & publicKey() const
publicKey This method return public key that client added for authentication.
bool prepare()
prepare This method will generate signature for autentication of client. Please inboke this method be...
QString getUserId() const
getUserId This method return user id that generated from the public key.
@ Signing
Signin and check sign of the data.