rublon-ssh/PAM/ssh/include/rublon/session.hpp
rublon-bwi 6b9d2f938c
Bwi/v2.1.0 (#15)
* Add phone call authentication method

* Remove dynamic mem allocation from error handler

* Add more error handling code

* Move error handling to different file

* Remove Socket IO dependency

* cleanup in websocket code

* Add rapidjson as cmake dependency

* Added Dockerfiles as primary build system for packages

* Changed policy in CMakeList to work with lower version of CMake

* Fix opensuse builds

* Link filesystem library in gcc 8.5 or older
2024-11-18 12:57:20 +01:00

77 lines
1.8 KiB
C++

#pragma once
#include "rublon/utils.hpp"
#include <rapidjson/document.h>
#include <rublon/bits.hpp>
#include <rublon/configuration.hpp>
#include <rublon/json.hpp>
#include <string_view>
namespace rublon {
class Session {
const Pam_t & _pam;
const Configuration _config;
std::pmr::string _tid;
CoreHandler_t _coreHandler;
/// TODO log
/// TODO momory resource
public:
Session(const Pam_t & pam, const Configuration & config) : _pam{pam}, _config{config}, _coreHandler{_config} {
log(LogLevel::Debug, __PRETTY_FUNCTION__);
}
Session(Session &&) noexcept = default;
Session(const Session &) = delete;
Session& operator=(Session &&) noexcept = default;
Session& operator=(const Session &) = delete;
const auto & coreHandler() const {
return _coreHandler;
}
const auto & pam() const {
return _pam;
}
const auto & config() const {
return _config;
}
std::string_view systemToken() const {
return _config.systemToken;
}
const char * csystemToken() const {
return systemToken().data();
}
/// TODO validate tid
void updateTransactionId(const Value * tid) {
if(tid == nullptr) {
log(LogLevel::Warning, "Transaction ID is not defined");
} else {
_tid = tid->GetString();
}
}
std::string_view transactionID() const {
if(_tid.empty()) {
log(LogLevel::Warning, "Transaction ID is not defined, but requested");
return "";
} else {
return _tid;
}
}
const char * ctransactionID() const {
if(_tid.empty()) {
log(LogLevel::Warning, "Transaction ID is not defined, but requested");
return "";
} else {
return _tid.data();
}
}
};
} // namespace rublon