]> git.proxmox.com Git - ceph.git/blob - ceph/src/auth/AuthClientHandler.h
import 15.2.0 Octopus source
[ceph.git] / ceph / src / auth / AuthClientHandler.h
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_AUTHCLIENTHANDLER_H
16 #define CEPH_AUTHCLIENTHANDLER_H
17
18
19 #include "auth/Auth.h"
20 #include "include/common_fwd.h"
21
22 struct MAuthReply;
23 class RotatingKeyRing;
24
25 class AuthClientHandler {
26 protected:
27 CephContext *cct;
28 EntityName name;
29 uint64_t global_id;
30 uint32_t want;
31 uint32_t have;
32 uint32_t need;
33
34 public:
35 explicit AuthClientHandler(CephContext *cct_)
36 : cct(cct_), global_id(0), want(CEPH_ENTITY_TYPE_AUTH), have(0), need(0)
37 {}
38 virtual ~AuthClientHandler() {}
39
40 void init(const EntityName& n) { name = n; }
41
42 void set_want_keys(__u32 keys) {
43 want = keys | CEPH_ENTITY_TYPE_AUTH;
44 validate_tickets();
45 }
46
47 virtual int get_protocol() const = 0;
48
49 virtual void reset() = 0;
50 virtual void prepare_build_request() = 0;
51 virtual void build_initial_request(ceph::buffer::list *bl) const {
52 // this is empty for methods cephx and none.
53 }
54 virtual int build_request(ceph::buffer::list& bl) const = 0;
55 virtual int handle_response(int ret, ceph::buffer::list::const_iterator& iter,
56 CryptoKey *session_key,
57 std::string *connection_secret) = 0;
58 virtual bool build_rotating_request(ceph::buffer::list& bl) const = 0;
59
60 virtual AuthAuthorizer *build_authorizer(uint32_t service_id) const = 0;
61
62 virtual bool need_tickets() = 0;
63
64 virtual void set_global_id(uint64_t id) = 0;
65
66 static AuthClientHandler* create(CephContext* cct, int proto, RotatingKeyRing* rkeys);
67 protected:
68 virtual void validate_tickets() = 0;
69 };
70
71 #endif
72