1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 * Ceph - scalable distributed file system
6 * Copyright (C) 2004-2009 Sage Weil <sage@newdream.net>
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.
15 #ifndef CEPH_CEPHXCLIENTHANDLER_H
16 #define CEPH_CEPHXCLIENTHANDLER_H
18 #include "auth/AuthClientHandler.h"
19 #include "CephxProtocol.h"
20 #include "auth/RotatingKeyRing.h"
25 class CephxClientHandler : public AuthClientHandler {
28 /* envelope protocol parameters */
29 uint64_t server_challenge;
31 CephXTicketManager tickets;
32 CephXTicketHandler* ticket_handler;
34 RotatingKeyRing *rotating_secrets;
38 CephxClientHandler(CephContext *cct_, RotatingKeyRing *rsecrets)
39 : AuthClientHandler(cct_),
44 rotating_secrets(rsecrets),
45 keyring(rsecrets->get_keyring())
50 void reset() override {
51 RWLock::WLocker l(lock);
55 void prepare_build_request() override;
56 int build_request(bufferlist& bl) const override;
57 int handle_response(int ret, bufferlist::iterator& iter) override;
58 bool build_rotating_request(bufferlist& bl) const override;
60 int get_protocol() const override { return CEPH_AUTH_CEPHX; }
62 AuthAuthorizer *build_authorizer(uint32_t service_id) const override;
64 bool need_tickets() override;
66 void set_global_id(uint64_t id) override {
67 RWLock::WLocker l(lock);
69 tickets.global_id = id;
72 void validate_tickets() override;
73 bool _need_tickets() const;