#pragma once #include "rublon/pam_action.hpp" #include #include namespace rublon { template < typename Impl > class AuthenticationStep { protected: std::string _systemToken; std::string _tid; public: AuthenticationStep(){} AuthenticationStep(std::string systemToken, std::string tid) : _systemToken{std::move(systemToken)}, _tid{std::move(tid)} {} template < typename Handler_t > auto fire(const CoreHandlerInterface< Handler_t > & coreHandler) const { // log step log(Info, "Starting %s step", static_cast< const Impl * >(this)->name); return static_cast< const Impl * >(this)->handle(coreHandler); } template < typename HandlerReturn_t > PamAction coreErrorHandler(const HandlerReturn_t & coreResponse) const { switch(coreResponse.error().errorClass) { case CoreHandlerError::ErrorClass::BadSigature: log(LogLevel::Error, "ErrorClass::BadSigature"); return PamAction::decline; case CoreHandlerError::ErrorClass::CoreException: /// TODO exception handling log(LogLevel::Error, "ErrorClass::CoreException"); return PamAction::decline; /// TODO accept? case CoreHandlerError::ErrorClass::ConnectionError: log(LogLevel::Error, "ErrorClass::ConnectionError"); return PamAction::decline; /// TODO decline? case CoreHandlerError::ErrorClass::BrokenData: log(LogLevel::Error, "ErrorClass::BrokenData"); return PamAction::decline; } } }; } // namespace rublon