CppCMS
session_cookies.h
1 //
3 // Copyright (C) 2008-2012 Artyom Beilis (Tonkikh) <artyomtnk@yahoo.com>
4 //
5 // See accompanying file COPYING.TXT file for licensing details.
6 //
8 #ifndef CPPCMS_SESSION_COOKIES_H
9 #define CPPCMS_SESSION_COOKIES_H
10 #include <cppcms/session_api.h>
11 #include <booster/hold_ptr.h>
12 #include <booster/noncopyable.h>
13 #include <booster/auto_ptr_inc.h>
14 #include <string>
15 namespace cppcms {
16 class session_interface;
17 
21 namespace sessions {
22 
35  public:
40  virtual std::string encrypt(std::string const &plain) = 0;
46  virtual bool decrypt(std::string const &cipher,std::string &plain) = 0;
50  virtual ~encryptor() {}
51  };
52 
59  public:
63  virtual std::auto_ptr<encryptor> get() = 0;
64 
68  virtual ~encryptor_factory() {}
69  };
70 
74  class CPPCMS_API session_cookies : public session_api {
75  public:
79  session_cookies(std::auto_ptr<encryptor> encryptor);
83  ~session_cookies();
84 
88  virtual void save(session_interface &,std::string const &data,time_t timeout,bool newone ,bool on_server);
89 
93  virtual bool load(session_interface &,std::string &data,time_t &timeout);
94 
98  virtual bool is_blocking();
99 
103  virtual void clear(session_interface &);
104  private:
105  struct _data;
107  std::auto_ptr<encryptor> encryptor_;
108  };
109 } // sessions
110 } // cppcms
111 
112 #endif
This is an interface for an object that creates new encryptors.
Definition: session_cookies.h:58
virtual bool decrypt(std::string const &cipher, std::string &plain)=0
The implementation of session_api using encrypted or signed cookies.
Definition: session_cookies.h:74
This class provides an access to an application for session management.
Definition: session_interface.h:107
This is the namespace where all CppCMS functionality is placed.
Definition: application.h:19
virtual std::string encrypt(std::string const &plain)=0
virtual ~encryptor()
Definition: session_cookies.h:50
This class represents the most generic implementation of session storage device.
Definition: session_api.h:32
virtual ~encryptor_factory()
Definition: session_cookies.h:68
This is an interface to generic session cookies encryption or signing API.
Definition: session_cookies.h:34
This class makes impossible to copy any class derived from this one.
Definition: noncopyable.h:15