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