session_cookies.h
//
// Copyright (C) 2008-2012 Artyom Beilis (Tonkikh) <artyomtnk@yahoo.com>
//
// See accompanying file COPYING.TXT file for licensing details.
//
#ifndef CPPCMS_SESSION_COOKIES_H
#define CPPCMS_SESSION_COOKIES_H
#include <cppcms/session_api.h>
#include <booster/hold_ptr.h>
#include <booster/noncopyable.h>
#include <memory>
#include <string>
namespace cppcms {
class session_interface;
namespace sessions {
class encryptor : public booster::noncopyable {
public:
virtual std::string encrypt(std::string const &plain) = 0;
virtual bool decrypt(std::string const &cipher,std::string &plain) = 0;
virtual ~encryptor() {}
};
class encryptor_factory {
public:
virtual std::auto_ptr<encryptor> get() = 0;
virtual ~encryptor_factory() {}
};
class CPPCMS_API session_cookies : public session_api {
public:
session_cookies(std::auto_ptr<encryptor> encryptor);
~session_cookies();
virtual void save(session_interface &,std::string const &data,time_t timeout,bool newone ,bool on_server);
virtual bool load(session_interface &,std::string &data,time_t &timeout);
virtual bool is_blocking();
virtual void clear(session_interface &);
private:
struct _data;
booster::hold_ptr<_data> d;
std::auto_ptr<encryptor> encryptor_;
};
} // sessions
} // cppcms
#endif
cppcms::sessions::encryptor_factory
This is an interface for an object that creates new encryptors.
Definition: session_cookies.h:58
booster::hold_ptr< _data >
cppcms::sessions::encryptor::decrypt
virtual bool decrypt(std::string const &cipher, std::string &plain)=0
cppcms::sessions::session_cookies
The implementation of session_api using encrypted or signed cookies.
Definition: session_cookies.h:74
cppcms::session_interface
This class provides an access to an application for session management.
Definition: session_interface.h:69
cppcms::sessions::encryptor::encrypt
virtual std::string encrypt(std::string const &plain)=0
cppcms::sessions::encryptor::~encryptor
virtual ~encryptor()
Definition: session_cookies.h:50
cppcms::session_api
This class represents the most generic implementation of session storage device.
Definition: session_api.h:32
cppcms::sessions::encryptor_factory::~encryptor_factory
virtual ~encryptor_factory()
Definition: session_cookies.h:68
cppcms::sessions::encryptor
This is an interface to generic session cookies encryption or signing API.
Definition: session_cookies.h:34
booster::noncopyable
This class makes impossible to copy any class derived from this one.
Definition: noncopyable.h:15