From 19fcec84d8d7d21e796c7624e521b60d28ee21ed Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 20:45:59 +0200 Subject: Adding upstream version 16.2.11+ds. Signed-off-by: Daniel Baumann --- src/cls/otp/cls_otp_client.h | 60 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 src/cls/otp/cls_otp_client.h (limited to 'src/cls/otp/cls_otp_client.h') diff --git a/src/cls/otp/cls_otp_client.h b/src/cls/otp/cls_otp_client.h new file mode 100644 index 000000000..a921e4e38 --- /dev/null +++ b/src/cls/otp/cls_otp_client.h @@ -0,0 +1,60 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab + +#ifndef CEPH_CLS_OTP_CLIENT_H +#define CEPH_CLS_OTP_CLIENT_H + +#include "include/rados/librados_fwd.hpp" +#include "cls/otp/cls_otp_types.h" + +namespace rados { + namespace cls { + namespace otp { + + class OTP { + public: + static void create(librados::ObjectWriteOperation *op, const otp_info_t& config); + static void set(librados::ObjectWriteOperation *op, const std::list& entries); + static void remove(librados::ObjectWriteOperation *op, const std::string& id); + static int get(librados::ObjectReadOperation *op, + librados::IoCtx& ioctx, const std::string& oid, + const std::string& id, otp_info_t *result); + static int get_all(librados::ObjectReadOperation *op, + librados::IoCtx& ioctx, const std::string& oid, + std::list *result); +// these overloads which call io_ctx.operate() or io_ctx.exec() should not be called in the rgw. +// rgw_rados_operate() should be called after the overloads w/o calls to io_ctx.operate()/exec() +#ifndef CLS_CLIENT_HIDE_IOCTX + static int get(librados::ObjectReadOperation *op, + librados::IoCtx& ioctx, const std::string& oid, + const std::list *ids, bool get_all, std::list *result); + static int check(CephContext *cct, librados::IoCtx& ioctx, const std::string& oid, + const std::string& id, const std::string& val, otp_check_t *result); + static int get_current_time(librados::IoCtx& ioctx, const std::string& oid, + ceph::real_time *result); +#endif + }; + + class TOTPConfig { + otp_info_t config; + public: + TOTPConfig(const std::string& id, const std::string& seed) { + config.type = OTP_TOTP; + config.id = id; + config.seed = seed; + } + void set_step_size(int step_size) { + config.step_size = step_size; + } + void set_window(int window) { + config.window = window; + } + void get_config(otp_info_t *conf) { + *conf = config; + } + }; + } // namespace otp + } // namespace cls +} // namespace rados + +#endif -- cgit v1.2.3