rublon-ssh/PAM/ssh/include/rublon/session.hpp
rublon-bwi af64f8e9e3
Bwi/v2.2.0 (#16)
* Remove dynamic memory usage from core

* Refacor status check to use json pointers

* Move access token to session

* Remove code duplication

* Fix compile warnings from rapidjson sources

* Add 'interactive mode option to session configuration

* Implement non interactive mode connector

* Add 'non interactove' implementation

* Apply rapidjson patch

* Build on all cores

* Rename build script

* Split configure and build steps

* Add scripts for building all images

* Change bash to python for build scripts

* Stop printing methods name in non interactive mode

* Add trace log level, adn more params to init message

* Fix build

* Fix non interactive method selection and refactor vagrant files for debian like systems

* Refactor log messages

* Remove exces dependencies from vagrant configuration files

* Fixed vagrantfiles

* Added repo for rhel

* Add nonInteractiveMode option

* Added instalation script for pubkey

* Fixed pubkey install script and postrm for rhel
2025-03-07 11:41:12 +01:00

94 lines
2.3 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>
#include <string_view>
namespace rublon {
class Session {
const Pam_t & _pam;
const Configuration _config;
std::pmr::string _tid;
std::pmr::string _accessToken;
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 = delete;
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();
}
bool inInteractiveMode() const {
return _config.nonInteractiveMode == false;
}
void updateTransactionId(const Value * tid) {
log(LogLevel::Debug, "Set transaction ID %s", tid->GetString());
_tid = tid->GetString();
}
void updateAccessToken(const Value * accessToken) {
log(LogLevel::Debug, "AccessToken %s", accessToken->GetString());
_accessToken = accessToken->GetString();
}
bool hasAccessToken() const {
return not _accessToken.empty();
}
std::string_view accessToken() const {
return _accessToken;
}
const char * caccessToken() const {
return _accessToken.c_str();
}
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