Granada  1.54.0
Structured layer on top of C++ REST SDK for building server applications in C++. Granada implements sessions, server side plug-in framework, C++ OAuth 2.0 server, data storage access, server script running, server browsing.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
Public Member Functions | Protected Member Functions | Static Protected Attributes | List of all members
granada::http::session::SessionHandler Class Reference

#include <session.h>

Inheritance diagram for granada::http::session::SessionHandler:
granada::http::session::MapSessionHandler granada::http::session::RedisSessionHandler

Public Member Functions

 SessionHandler ()
 
virtual const bool SessionExists (const std::string &token)
 
virtual const std::string GenerateToken ()
 
virtual void LoadSession (const std::string &token, granada::http::session::Session *virgin)
 
virtual void SaveSession (granada::http::session::Session *session)
 
virtual void DeleteSession (granada::http::session::Session *session)
 
virtual void CleanSessions ()
 
virtual void CleanSessions (bool recursive)
 
virtual
granada::cache::CacheHandler
cache ()
 

Protected Member Functions

virtual void LoadProperties ()
 
virtual
granada::crypto::NonceGenerator
nonce_generator ()
 
virtual
granada::http::session::SessionFactory
factory ()
 
virtual int & token_length ()
 
virtual double & clean_sessions_frequency ()
 
virtual const std::string session_value_hash (const std::string &token)
 

Static Protected Attributes

static int token_length_
 
static double clean_sessions_frequency_
 

Detailed Description

Abstract class for managing sessions life.

Constructor & Destructor Documentation

granada::http::session::SessionHandler::SessionHandler ( )
inline

Constructor

Member Function Documentation

virtual granada::cache::CacheHandler* granada::http::session::SessionHandler::cache ( )
inlinevirtual

Returns a pointer to the cache handler used to store the sessions data.

Returns
Pointer to the cache handler used to store the sessions data.

Reimplemented in granada::http::session::MapSessionHandler, and granada::http::session::RedisSessionHandler.

virtual double& granada::http::session::SessionHandler::clean_sessions_frequency ( )
inlineprotectedvirtual

Returns the frequency in seconds the CleanSessions function will be executed.

Returns
The frequency in seconds the CleanSessions function will be executed.
virtual void granada::http::session::SessionHandler::CleanSessions ( )
virtual

Remove garbage sessions from wherever sessions are stored. It can be called from an application control panel, or better called every n seconds, hours or days.

virtual void granada::http::session::SessionHandler::CleanSessions ( bool  recursive)
virtual

Clean session function but optionaly recursive each x seconds, with x equal to the value given in the "session_clean_frequency" property.

Parameters
recursivetrue if recursive, false if not.
virtual void granada::http::session::SessionHandler::DeleteSession ( granada::http::session::Session session)
virtual

Remove session from wherever the sessions are stored.

Parameters
sessionSession to remove.
virtual granada::http::session::SessionFactory* granada::http::session::SessionHandler::factory ( )
inlineprotectedvirtual

Returns a pointer to a session factory. It Aallows to have a unique point for checking and setting sessions. Used to create a new session if it does not exist or if it is timed out.

Returns
Pointer to a session factory

Reimplemented in granada::http::session::MapSessionHandler, and granada::http::session::RedisSessionHandler.

virtual const std::string granada::http::session::SessionHandler::GenerateToken ( )
virtual

Generate a new unique token.

Returns
Generated Token.
virtual void granada::http::session::SessionHandler::LoadProperties ( )
protectedvirtual

Loads properties needed, like clean session frequency.

virtual void granada::http::session::SessionHandler::LoadSession ( const std::string &  token,
granada::http::session::Session virgin 
)
virtual

Search if the session exists wherever the sessions are stored, retrieves the value and assign it to the virgin session.

Parameters
tokenToken of the session to search.
virginPointer of the virgin session.
virtual granada::crypto::NonceGenerator* granada::http::session::SessionHandler::nonce_generator ( )
inlineprotectedvirtual

Returns a pointer to a generator of random alphanumeric strings. Used to generate sessions' tokens.

Returns
Pointer to a generator of random alphanumeric strings.

Reimplemented in granada::http::session::MapSessionHandler, and granada::http::session::RedisSessionHandler.

virtual void granada::http::session::SessionHandler::SaveSession ( granada::http::session::Session session)
virtual

Insert or replace a session wherever the sessions are stored.

Parameters
sessionPointer to Session to save.
virtual const std::string granada::http::session::SessionHandler::session_value_hash ( const std::string &  token)
inlineprotectedvirtual

Returns the key used to identify the session data in the cache.

Parameters
tokenSession token.
Returns
Key used to identify the session data in the cache.
virtual const bool granada::http::session::SessionHandler::SessionExists ( const std::string &  token)
virtual

Check if session exists wherever sessions are stored. Returns true if session exists and false if it does not.

Parameters
tokenToken of the session to check.
Returns
true if session exists and false if it does not.
virtual int& granada::http::session::SessionHandler::token_length ( )
inlineprotectedvirtual

Returns the lenght that the sesions' tokens will have.

Returns
Lenght that the sesions' tokens will have.

Member Data Documentation

double granada::http::session::SessionHandler::clean_sessions_frequency_
staticprotected

Frequency in seconds the CleanSessions function will be executed. it will be set on LoadProperties(), if not found, it will take the value of default_numbers::session_clean_sessions_frequency.

int granada::http::session::SessionHandler::token_length_
staticprotected

Token length. It will be set on LoadProperties(), if not found, it will take the value of nonce_lengths::Session_token.


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