1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
|
#ifndef CEPH_RGW_ACL_S3_H
#define CEPH_RGW_ACL_S3_H
#include <map>
#include <string>
#include <iostream>
#include <include/types.h>
#include <expat.h>
#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(ostream& out);
bool xml_end(const char *el);
bool xml_start(const char *el, const char **attr);
static ACLGroupTypeEnum uri_to_group(string& uri);
};
class RGWAccessControlList_S3 : public RGWAccessControlList, public XMLObj
{
public:
RGWAccessControlList_S3() {}
~RGWAccessControlList_S3() {}
bool xml_end(const char *el);
void to_xml(ostream& out) {
multimap<string, ACLGrant>::iterator iter;
out << "<AccessControlList>";
for (iter = grant_map.begin(); iter != grant_map.end(); ++iter) {
ACLGrant_S3& grant = static_cast<ACLGrant_S3 &>(iter->second);
grant.to_xml(out);
}
out << "</AccessControlList>";
}
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 << "<Owner>" << "<ID>" << id << "</ID>";
if (!display_name.empty())
out << "<DisplayName>" << display_name << "</DisplayName>";
out << "</Owner>";
}
};
class RGWAccessControlPolicy_S3 : public RGWAccessControlPolicy, public XMLObj
{
public:
RGWAccessControlPolicy_S3() {}
~RGWAccessControlPolicy_S3() {}
bool xml_end(const char *el);
void to_xml(ostream& out) {
out << "<AccessControlPolicy xmlns=\"http://s3.amazonaws.com/doc/2006-03-01/\">";
ACLOwner_S3& _owner = static_cast<ACLOwner_S3 &>(owner);
RGWAccessControlList_S3& _acl = static_cast<RGWAccessControlList_S3 &>(acl);
_owner.to_xml(out);
_acl.to_xml(out);
out << "</AccessControlPolicy>";
}
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<RGWAccessControlList_S3 &>(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
{
XMLObj *alloc_obj(const char *el);
public:
RGWACLXMLParser_S3() {}
};
#endif
|