CppCMS
cppcms/session_cookies.h
00001 
00002 //                                                                             
00003 //  Copyright (C) 2008-2012  Artyom Beilis (Tonkikh) <artyomtnk@yahoo.com>     
00004 //                                                                             
00005 //  See accompanying file COPYING.TXT file for licensing details.
00006 //
00008 #ifndef CPPCMS_SESSION_COOKIES_H
00009 #define CPPCMS_SESSION_COOKIES_H
00010 #include <cppcms/session_api.h>
00011 #include <booster/hold_ptr.h>
00012 #include <booster/noncopyable.h>
00013 #include <memory>
00014 #include <string>
00015 namespace cppcms {
00016 class session_interface;
00017 
00021 namespace sessions {
00022 
00034         class encryptor : public booster::noncopyable {
00035         public:
00040                 virtual std::string encrypt(std::string const &plain) = 0;
00046                 virtual bool decrypt(std::string const &cipher,std::string &plain) = 0;
00050                 virtual ~encryptor() {}
00051         };
00052 
00058         class encryptor_factory {
00059         public:
00063                 virtual std::auto_ptr<encryptor> get() = 0;
00064 
00068                 virtual ~encryptor_factory() {}
00069         };
00070 
00074         class CPPCMS_API session_cookies : public session_api {
00075         public:
00079                 session_cookies(std::auto_ptr<encryptor> encryptor);
00083                 ~session_cookies();
00084                 
00088                 virtual void save(session_interface &,std::string const &data,time_t timeout,bool newone ,bool on_server);
00089                 
00093                 virtual bool load(session_interface &,std::string &data,time_t &timeout);
00094                 
00098                 virtual bool is_blocking();
00099                 
00103                 virtual void clear(session_interface &);
00104         private:
00105                 struct _data;
00106                 booster::hold_ptr<_data> d;
00107                 std::auto_ptr<encryptor> encryptor_;
00108         };
00109 } // sessions
00110 } // cppcms
00111 
00112 #endif