Fix some bugs when testing opensds ansible
[stor4nfv.git] / src / 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 "common/RWLock.h"
21
22 class CephContext;
23 struct MAuthReply;
24 class RotatingKeyRing;
25
26 class AuthClientHandler {
27 protected:
28   CephContext *cct;
29   EntityName name;
30   uint64_t global_id;
31   uint32_t want;
32   uint32_t have;
33   uint32_t need;
34   RWLock lock;
35
36 public:
37   explicit AuthClientHandler(CephContext *cct_)
38     : cct(cct_), global_id(0), want(CEPH_ENTITY_TYPE_AUTH), have(0), need(0),
39       lock("AuthClientHandler::lock") {}
40   virtual ~AuthClientHandler() {}
41
42   void init(const EntityName& n) { name = n; }
43   
44   void set_want_keys(__u32 keys) {
45     RWLock::WLocker l(lock);
46     want = keys | CEPH_ENTITY_TYPE_AUTH;
47     validate_tickets();
48   }
49
50   virtual int get_protocol() const = 0;
51
52   virtual void reset() = 0;
53   virtual void prepare_build_request() = 0;
54   virtual int build_request(bufferlist& bl) const = 0;
55   virtual int handle_response(int ret, bufferlist::iterator& iter) = 0;
56   virtual bool build_rotating_request(bufferlist& bl) const = 0;
57
58   virtual AuthAuthorizer *build_authorizer(uint32_t service_id) const = 0;
59
60   virtual bool need_tickets() = 0;
61
62   virtual void set_global_id(uint64_t id) = 0;
63 protected:
64   virtual void validate_tickets() = 0;
65 };
66
67
68 extern AuthClientHandler *get_auth_client_handler(CephContext *cct,
69                                       int proto, RotatingKeyRing *rkeys);
70
71 #endif
72