line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::Amazon::S3::ACL::Set; |
2
|
|
|
|
|
|
|
# Abstract: Representation of explicit ACL |
3
|
|
|
|
|
|
|
$Net::Amazon::S3::ACL::Set::VERSION = '0.98'; |
4
|
97
|
|
|
97
|
|
1562
|
use Moose 0.85; |
|
97
|
|
|
|
|
2356
|
|
|
97
|
|
|
|
|
789
|
|
5
|
97
|
|
|
97
|
|
675058
|
use MooseX::StrictConstructor 0.16; |
|
97
|
|
|
|
|
2237
|
|
|
97
|
|
|
|
|
1070
|
|
6
|
97
|
|
|
97
|
|
334439
|
use Moose::Util::TypeConstraints; |
|
97
|
|
|
|
|
291
|
|
|
97
|
|
|
|
|
906
|
|
7
|
|
|
|
|
|
|
|
8
|
97
|
|
|
97
|
|
217373
|
use Ref::Util (); |
|
97
|
|
|
|
|
275
|
|
|
97
|
|
|
|
|
2085
|
|
9
|
97
|
|
|
97
|
|
594
|
use Safe::Isa (); |
|
97
|
|
|
|
|
224
|
|
|
97
|
|
|
|
|
2384
|
|
10
|
|
|
|
|
|
|
|
11
|
97
|
|
|
97
|
|
46084
|
use Net::Amazon::S3::Constants; |
|
97
|
|
|
|
|
290
|
|
|
97
|
|
|
|
|
3358
|
|
12
|
97
|
|
|
97
|
|
48926
|
use Net::Amazon::S3::ACL::Grantee::User; |
|
97
|
|
|
|
|
335
|
|
|
97
|
|
|
|
|
3950
|
|
13
|
97
|
|
|
97
|
|
56160
|
use Net::Amazon::S3::ACL::Grantee::Group; |
|
97
|
|
|
|
|
351
|
|
|
97
|
|
|
|
|
4225
|
|
14
|
97
|
|
|
97
|
|
55688
|
use Net::Amazon::S3::ACL::Grantee::Email; |
|
97
|
|
|
|
|
344
|
|
|
97
|
|
|
|
|
64582
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
class_type 'Net::Amazon::S3::ACL::Set'; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
my %permission_map = ( |
19
|
|
|
|
|
|
|
full_control => Net::Amazon::S3::Constants::HEADER_GRANT_FULL_CONTROL, |
20
|
|
|
|
|
|
|
read => Net::Amazon::S3::Constants::HEADER_GRANT_READ, |
21
|
|
|
|
|
|
|
read_acp => Net::Amazon::S3::Constants::HEADER_GRANT_READ_ACP, |
22
|
|
|
|
|
|
|
write => Net::Amazon::S3::Constants::HEADER_GRANT_WRITE, |
23
|
|
|
|
|
|
|
write_acp => Net::Amazon::S3::Constants::HEADER_GRANT_WRITE_ACP, |
24
|
|
|
|
|
|
|
); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
my %grantees_map = ( |
27
|
|
|
|
|
|
|
id => 'Net::Amazon::S3::ACL::Grantee::User', |
28
|
|
|
|
|
|
|
user => 'Net::Amazon::S3::ACL::Grantee::User', |
29
|
|
|
|
|
|
|
uri => 'Net::Amazon::S3::ACL::Grantee::Group', |
30
|
|
|
|
|
|
|
group => 'Net::Amazon::S3::ACL::Grantee::Group', |
31
|
|
|
|
|
|
|
email => 'Net::Amazon::S3::ACL::Grantee::Email', |
32
|
|
|
|
|
|
|
); |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
has _grantees => ( |
35
|
|
|
|
|
|
|
is => 'ro', |
36
|
|
|
|
|
|
|
default => sub { +{} }, |
37
|
|
|
|
|
|
|
); |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub build_headers { |
40
|
30
|
|
|
30
|
0
|
100
|
my ($self) = @_; |
41
|
|
|
|
|
|
|
|
42
|
30
|
|
|
|
|
68
|
my %headers; |
43
|
30
|
|
|
|
|
71
|
while (my ($header, $grantees) = each %{ $self->_grantees }) { |
|
91
|
|
|
|
|
2590
|
|
44
|
61
|
|
|
|
|
283
|
$headers{$header} = join ', ', map $_->format_for_header, @$grantees; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
30
|
|
|
|
|
303
|
%headers; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub grant_full_control { |
51
|
1
|
|
|
1
|
1
|
359
|
my ($self, @grantees) = @_; |
52
|
|
|
|
|
|
|
|
53
|
1
|
|
|
|
|
4
|
$self->_grant (full_control => @grantees); |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub grant_read { |
57
|
15
|
|
|
15
|
1
|
5244
|
my ($self, @grantees) = @_; |
58
|
|
|
|
|
|
|
|
59
|
15
|
|
|
|
|
90
|
$self->_grant (read => @grantees); |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub grant_read_acp { |
63
|
0
|
|
|
0
|
1
|
0
|
my ($self, @grantees) = @_; |
64
|
|
|
|
|
|
|
|
65
|
0
|
|
|
|
|
0
|
$self->_grant (read_acp => @grantees); |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub grant_write { |
69
|
16
|
|
|
16
|
1
|
611
|
my ($self, @grantees) = @_; |
70
|
|
|
|
|
|
|
|
71
|
16
|
|
|
|
|
96
|
$self->_grant (write => @grantees); |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub grant_write_acp { |
75
|
0
|
|
|
0
|
1
|
0
|
my ($self, @grantees) = @_; |
76
|
|
|
|
|
|
|
|
77
|
0
|
|
|
|
|
0
|
$self->_grant (write_acp => @grantees); |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub _grant { |
81
|
32
|
|
|
32
|
|
114
|
my ($self, $permission, @grantees) = @_; |
82
|
32
|
50
|
|
|
|
130
|
$self = $self->new unless ref $self; |
83
|
|
|
|
|
|
|
|
84
|
32
|
|
|
|
|
85
|
my $key = lc $permission; |
85
|
32
|
|
|
|
|
82
|
$key =~ tr/-/_/; |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
die "Unknown permission $permission" |
88
|
32
|
50
|
|
|
|
136
|
unless exists $permission_map{$key}; |
89
|
|
|
|
|
|
|
|
90
|
32
|
50
|
|
|
|
99
|
return unless @grantees; |
91
|
|
|
|
|
|
|
|
92
|
32
|
|
100
|
|
|
1099
|
my $list = $self->_grantees->{$permission_map{$key}} ||= []; |
93
|
32
|
|
|
|
|
112
|
while (@grantees) { |
94
|
49
|
|
|
|
|
9723
|
my $type = shift @grantees; |
95
|
|
|
|
|
|
|
|
96
|
49
|
100
|
|
|
|
190
|
if ($type->$Safe::Isa::_isa ('Net::Amazon::S3::ACL::Grantee')) { |
97
|
2
|
|
|
|
|
32
|
push @{ $list }, $type; |
|
2
|
|
|
|
|
5
|
|
98
|
2
|
|
|
|
|
6
|
next; |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
die "Unknown grantee type $type" |
102
|
47
|
50
|
|
|
|
574
|
unless exists $grantees_map{$type}; |
103
|
|
|
|
|
|
|
|
104
|
47
|
50
|
|
|
|
127
|
die "Grantee type $type requires one argument" |
105
|
|
|
|
|
|
|
unless @grantees; |
106
|
|
|
|
|
|
|
|
107
|
47
|
|
|
|
|
130
|
my @grantee = (shift @grantees); |
108
|
47
|
50
|
|
|
|
157
|
@grantees = @{ $grantee[0] } |
|
0
|
|
|
|
|
0
|
|
109
|
|
|
|
|
|
|
if Ref::Util::is_plain_arrayref ($grantee[0]); |
110
|
|
|
|
|
|
|
|
111
|
47
|
|
|
|
|
79
|
push @{ $list }, map $grantees_map{$type}->new ($_), @grantee; |
|
47
|
|
|
|
|
434
|
|
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
32
|
|
|
|
|
16089
|
return $self; |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
1; |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
__END__ |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=pod |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=encoding UTF-8 |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=head1 NAME |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
Net::Amazon::S3::ACL::Set |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=head1 VERSION |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
version 0.98 |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=head1 SYNOPSIS |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
use Net::Amazon::S3::ACL; |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
$acl = Net::Amazon::S3::ACL->new |
138
|
|
|
|
|
|
|
->grant_full_control ( |
139
|
|
|
|
|
|
|
id => 11112222333, |
140
|
|
|
|
|
|
|
id => 444455556666, |
141
|
|
|
|
|
|
|
uri => 'predefined group uri', |
142
|
|
|
|
|
|
|
email => 'email-address', |
143
|
|
|
|
|
|
|
) |
144
|
|
|
|
|
|
|
->grant_write ( |
145
|
|
|
|
|
|
|
... |
146
|
|
|
|
|
|
|
) |
147
|
|
|
|
|
|
|
; |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=head1 DESCRIPTION |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
Class representing explicit Amazon S3 ACL configuration. |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=head1 METHODS |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=head2 new |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
Creates new instance. |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=head2 grant_full_control (@grantees) |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=head2 grant_read (@grantees) |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=head2 grant_read_acp (@grantees) |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=head2 grant_write (@grantees) |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=head2 grant_write_acp (@grantees) |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=head1 GRANTEES |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
See also L<"Who Is a Grantee?"|https://docs.aws.amazon.com/AmazonS3/latest/dev/acl-overview.html#specifying-grantee> |
172
|
|
|
|
|
|
|
in Amazon S3 documentation. |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
Each grant_* method accepts list of grantees either in key-value format or as an |
175
|
|
|
|
|
|
|
instance of C<Net::Amazon::S3::ACL::Grantee::*>. |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=over |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
=item canonical user ID |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
->grant_read ( |
182
|
|
|
|
|
|
|
id => 123, |
183
|
|
|
|
|
|
|
Net::Amazon::S3::ACL::Grantee::User->new (123), |
184
|
|
|
|
|
|
|
) |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
=item predefined group uri |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
->grant_read ( |
189
|
|
|
|
|
|
|
uri => 'http://...', |
190
|
|
|
|
|
|
|
Net::Amazon::S3::ACL::Grantee::Group->new ('http://...'), |
191
|
|
|
|
|
|
|
Net::Amazon::S3::ACL::Grantee::Group->ALL_USERS, |
192
|
|
|
|
|
|
|
) |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
=item email address |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
->grant_read ( |
197
|
|
|
|
|
|
|
email => 'foo@bar.baz', |
198
|
|
|
|
|
|
|
Net::Amazon::S3::ACL::Grantee::Email->new ('foo@bar.baz'), |
199
|
|
|
|
|
|
|
); |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
=over |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
=head1 AUTHOR |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
Branislav Zahradník <barney@cpan.org> |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
This module is part of L<Net::Amazon::S3>. |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
=head1 AUTHOR |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
Branislav Zahradník <barney@cpan.org> |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
This software is copyright (c) 2021 by Amazon Digital Services, Leon Brocard, Brad Fitzpatrick, Pedro Figueiredo, Rusty Conover, Branislav Zahradník. |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
220
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
=cut |