Debian Codegraph @

src/neon/neonsession.hpp

raw
1 /*
2 * This File is part of Davix, The IO library for HTTP based protocols
3 * Copyright (C) CERN 2013
4 * Author: Adrien Devresse <[email protected]>
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 *
20 */
21
22 #ifndef NEONSESSION_HPP
23 #define NEONSESSION_HPP
24
25 #include <utils/davix_logger_internal.hpp>
26 #include <davix_context_internal.hpp>
27 #include <params/davixrequestparams.hpp>
28
29 #include <pthread.h>
30 #include <ne_session.h>
31 #include <memory>
32
33 namespace Davix{
34
35 struct NeonHandle;
36 typedef std::shared_ptr<NeonHandle> NeonHandlePtr;
37
38 class NEONSessionFactory;
39
40 class NEONSession
41 {
42 public:
43 NEONSession(NEONSessionFactory &f, NeonHandlePtr sess, const Uri & uri, const RequestParams & p, DavixError** err);
44 virtual ~NEONSession();
45
46
47 ne_session* get_ne_sess();
48
49 inline bool isRecycledSession(){
50 return reused;
51 }
52
53 inline void do_not_reuse_this_session(){
54 DAVIX_SLOG(DAVIX_LOG_DEBUG, DAVIX_LOG_SSL, "Disable Session recycling");
55 _session_recycling = false;
56 }
57
58 private:
59 NEONSessionFactory & _f;
60 NeonHandlePtr _sess;
61 const RequestParams & _params;
62 DavixError* _last_error;
63 bool _session_recycling;
64 bool reused;
65 Uri _u;
66
67 NEONSession(const NEONSession &);
68 NEONSession& operator=(const NEONSession &);
69
70
71 // auth callback mapper
72 //
73 static void authNeonCliCertMapper(void *userdata, ne_session *sess,
74 const ne_ssl_dname *const *dnames,
75 int dncount);
76
77 static int provide_login_passwd_fn(void *userdata, const char *realm, int attempt,
78 char *username, char *password);
79
80 };
81
82
83 void configureSession(NeonHandlePtr &_sess, const Uri & uri, const RequestParams &params, ne_auth_creds lp_callbac, void* lp_userdata,
84 ne_ssl_provide_fn cred_callback, void* cred_userdata, bool & reused);
85
86
87 }
88
89 #endif // NEONSESSION_HPP