]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- |
2 | // vim: ts=8 sw=2 smarttab | |
3 | /* | |
4 | * Ceph - scalable distributed file system | |
5 | * | |
6 | * Copyright (C) 2004-2009 Sage Weil <sage@newdream.net> | |
7 | * | |
8 | * This is free software; you can redistribute it and/or | |
9 | * modify it under the terms of the GNU Lesser General Public | |
10 | * License version 2.1, as published by the Free Software | |
11 | * Foundation. See file COPYING. | |
12 | * | |
13 | */ | |
14 | ||
15 | #ifndef CEPH_CEPHXCLIENTHANDLER_H | |
16 | #define CEPH_CEPHXCLIENTHANDLER_H | |
17 | ||
18 | #include "auth/AuthClientHandler.h" | |
19 | #include "CephxProtocol.h" | |
20 | #include "auth/RotatingKeyRing.h" | |
9f95a23c | 21 | #include "include/common_fwd.h" |
7c673cae | 22 | |
7c673cae FG |
23 | class KeyRing; |
24 | ||
25 | class CephxClientHandler : public AuthClientHandler { | |
26 | bool starting; | |
27 | ||
28 | /* envelope protocol parameters */ | |
29 | uint64_t server_challenge; | |
30 | ||
31 | CephXTicketManager tickets; | |
32 | CephXTicketHandler* ticket_handler; | |
33 | ||
11fdf7f2 | 34 | RotatingKeyRing* rotating_secrets; |
7c673cae FG |
35 | KeyRing *keyring; |
36 | ||
37 | public: | |
11fdf7f2 TL |
38 | CephxClientHandler(CephContext *cct_, |
39 | RotatingKeyRing *rsecrets) | |
7c673cae FG |
40 | : AuthClientHandler(cct_), |
41 | starting(false), | |
42 | server_challenge(0), | |
43 | tickets(cct_), | |
44 | ticket_handler(NULL), | |
45 | rotating_secrets(rsecrets), | |
46 | keyring(rsecrets->get_keyring()) | |
47 | { | |
48 | reset(); | |
49 | } | |
50 | ||
c5c27e9a TL |
51 | CephxClientHandler* clone() const override { |
52 | return new CephxClientHandler(*this); | |
53 | } | |
54 | ||
11fdf7f2 | 55 | void reset() override; |
7c673cae | 56 | void prepare_build_request() override; |
f67539c2 TL |
57 | int build_request(ceph::buffer::list& bl) const override; |
58 | int handle_response(int ret, ceph::buffer::list::const_iterator& iter, | |
11fdf7f2 TL |
59 | CryptoKey *session_key, |
60 | std::string *connection_secret) override; | |
f67539c2 | 61 | bool build_rotating_request(ceph::buffer::list& bl) const override; |
7c673cae FG |
62 | |
63 | int get_protocol() const override { return CEPH_AUTH_CEPHX; } | |
64 | ||
65 | AuthAuthorizer *build_authorizer(uint32_t service_id) const override; | |
66 | ||
67 | bool need_tickets() override; | |
68 | ||
69 | void set_global_id(uint64_t id) override { | |
7c673cae FG |
70 | global_id = id; |
71 | tickets.global_id = id; | |
72 | } | |
73 | private: | |
74 | void validate_tickets() override; | |
75 | bool _need_tickets() const; | |
76 | }; | |
77 | ||
78 | #endif |