Session.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. //
  2. // Session.h
  3. //
  4. // $Id: //poco/1.4/NetSSL_OpenSSL/include/Poco/Net/Session.h#1 $
  5. //
  6. // Library: NetSSL_OpenSSL
  7. // Package: SSLCore
  8. // Module: Session
  9. //
  10. // Definition of the Session class.
  11. //
  12. // Copyright (c) 2010, Applied Informatics Software Engineering GmbH.
  13. // and Contributors.
  14. //
  15. // Permission is hereby granted, free of charge, to any person or organization
  16. // obtaining a copy of the software and accompanying documentation covered by
  17. // this license (the "Software") to use, reproduce, display, distribute,
  18. // execute, and transmit the Software, and to prepare derivative works of the
  19. // Software, and to permit third-parties to whom the Software is furnished to
  20. // do so, all subject to the following:
  21. //
  22. // The copyright notices in the Software and this entire statement, including
  23. // the above license grant, this restriction and the following disclaimer,
  24. // must be included in all copies of the Software, in whole or in part, and
  25. // all derivative works of the Software, unless such copies or derivative
  26. // works are solely in the form of machine-executable object code generated by
  27. // a source language processor.
  28. //
  29. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  30. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  31. // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
  32. // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
  33. // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
  34. // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  35. // DEALINGS IN THE SOFTWARE.
  36. //
  37. #ifndef NetSSL_Session_INCLUDED
  38. #define NetSSL_Session_INCLUDED
  39. #include "Poco/Net/NetSSL.h"
  40. #include "Poco/RefCountedObject.h"
  41. #include "Poco/AutoPtr.h"
  42. #include <openssl/ssl.h>
  43. namespace Poco {
  44. namespace Net {
  45. class NetSSL_API Session: public Poco::RefCountedObject
  46. /// This class encapsulates a SSL session object
  47. /// used with session caching on the client side.
  48. ///
  49. /// For session caching to work, a client must
  50. /// save the session object from an existing connection,
  51. /// if it wants to reuse it with a future connection.
  52. {
  53. public:
  54. typedef Poco::AutoPtr<Session> Ptr;
  55. SSL_SESSION* sslSession() const;
  56. /// Returns the stored OpenSSL SSL_SESSION object.
  57. protected:
  58. Session(SSL_SESSION* pSession);
  59. /// Creates a new Session object, using the given
  60. /// SSL_SESSION object.
  61. ///
  62. /// The SSL_SESSION's reference count is not changed.
  63. ~Session();
  64. /// Destroys the Session.
  65. ///
  66. /// Calls SSL_SESSION_free() on the stored
  67. /// SSL_SESSION object.
  68. private:
  69. Session();
  70. SSL_SESSION* _pSession;
  71. friend class SecureSocketImpl;
  72. };
  73. //
  74. // inlines
  75. //
  76. inline SSL_SESSION* Session::sslSession() const
  77. {
  78. return _pSession;
  79. }
  80. } } // namespace Poco::Net
  81. #endif // NetSSL_Session_INCLUDED