X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fceph%2Fsrc%2Frgw%2Frgw_basic_types.cc;fp=src%2Fceph%2Fsrc%2Frgw%2Frgw_basic_types.cc;h=c16d920f21b0be67ce9873900987ead3a6602757;hb=812ff6ca9fcd3e629e49d4328905f33eee8ca3f5;hp=0000000000000000000000000000000000000000;hpb=15280273faafb77777eab341909a3f495cf248d9;p=stor4nfv.git diff --git a/src/ceph/src/rgw/rgw_basic_types.cc b/src/ceph/src/rgw/rgw_basic_types.cc new file mode 100644 index 0000000..c16d920 --- /dev/null +++ b/src/ceph/src/rgw/rgw_basic_types.cc @@ -0,0 +1,42 @@ +#include +#include +#include + +#include "rgw_basic_types.h" +#include "common/ceph_json.h" + +using std::string; +using std::stringstream; + +void decode_json_obj(rgw_user& val, JSONObj *obj) +{ + string s = obj->get_data(); + val.from_str(s); +} + +void encode_json(const char *name, const rgw_user& val, Formatter *f) +{ + string s = val.to_str(); + f->dump_string(name, s); +} + +namespace rgw { +namespace auth { +ostream& operator <<(ostream& m, const Principal& p) { + if (p.is_wildcard()) { + return m << "*"; + } + + m << "arn:aws:iam:" << p.get_tenant() << ":"; + if (p.is_tenant()) { + return m << "root"; + } + return m << (p.is_user() ? "user/" : "role/") << p.get_id(); +} +string to_string(const Principal& p) { + stringstream s; + s << p; + return s.str(); +} +} +}