#ifndef CEPH_RGW_ACL_S3_H #define CEPH_RGW_ACL_S3_H #include #include #include #include #include #include "rgw_xml.h" #include "rgw_acl.h" using namespace std; class ACLPermission_S3 : public ACLPermission, public XMLObj { public: ACLPermission_S3() {} ~ACLPermission_S3() {} bool xml_end(const char *el); void to_xml(ostream& out); }; class ACLGrantee_S3 : public ACLGrantee, public XMLObj { public: ACLGrantee_S3() {} ~ACLGrantee_S3() {} bool xml_start(const char *el, const char **attr); }; class ACLGrant_S3 : public ACLGrant, public XMLObj { public: ACLGrant_S3() {} ~ACLGrant_S3() {} void to_xml(CephContext *cct, ostream& out); bool xml_end(const char *el); bool xml_start(const char *el, const char **attr); static ACLGroupTypeEnum uri_to_group(string& uri); static bool group_to_uri(ACLGroupTypeEnum group, string& uri); }; class RGWAccessControlList_S3 : public RGWAccessControlList, public XMLObj { public: RGWAccessControlList_S3(CephContext *_cct) : RGWAccessControlList(_cct) {} ~RGWAccessControlList_S3() {} bool xml_end(const char *el); void to_xml(ostream& out) { multimap::iterator iter; out << ""; for (iter = grant_map.begin(); iter != grant_map.end(); ++iter) { ACLGrant_S3& grant = static_cast(iter->second); grant.to_xml(cct, out); } out << ""; } bool create_canned(string id, string name, string canned_acl); }; class ACLOwner_S3 : public ACLOwner, public XMLObj { public: ACLOwner_S3() {} ~ACLOwner_S3() {} bool xml_end(const char *el); void to_xml(ostream& out) { if (id.empty()) return; out << "" << "" << id << ""; if (!display_name.empty()) out << "" << display_name << ""; out << ""; } }; class RGWAccessControlPolicy_S3 : public RGWAccessControlPolicy, public XMLObj { public: RGWAccessControlPolicy_S3(CephContext *_cct) : RGWAccessControlPolicy(_cct) {} ~RGWAccessControlPolicy_S3() {} bool xml_end(const char *el); void to_xml(ostream& out) { out << ""; ACLOwner_S3& _owner = static_cast(owner); RGWAccessControlList_S3& _acl = static_cast(acl); _owner.to_xml(out); _acl.to_xml(out); out << ""; } int rebuild(ACLOwner *owner, RGWAccessControlPolicy& dest); bool compare_group_name(string& id, ACLGroupTypeEnum group); virtual bool create_canned(string id, string name, string canned_acl) { RGWAccessControlList_S3& _acl = static_cast(acl); bool ret = _acl.create_canned(id, name, canned_acl); owner.set_id(id); owner.set_name(name); return ret; } }; /** * Interfaces with the webserver's XML handling code * to parse it in a way that makes sense for the rgw. */ class RGWACLXMLParser_S3 : public RGWXMLParser { CephContext *cct; XMLObj *alloc_obj(const char *el); public: RGWACLXMLParser_S3(CephContext *_cct) : cct(_cct) {} }; #endif