| 1 | package Net::Amazon::S3::ACL::Grant::URI; | ||||||||||||||
| 2 | |||||||||||||||
| 3 | 3 | ▶ | use warnings; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 4 | 3 | ▶ | use strict; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 5 | 3 | ▶ | use Carp; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 6 | 3 | ▶ | use English qw( -no_match_vars ); | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 7 | |||||||||||||||
| 8 | 3 | ▶ | use base qw(Net::Amazon::S3::ACL::Grant); | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 9 | 3 | __PACKAGE__->mk_accessors(qw( URI )); | |||||||||||||
| 10 | |||||||||||||||
| 11 | # Module implementation here | ||||||||||||||
| 12 | 2 | ▶ | sub parse_grantee { | ||||||||||||
|
Subroutine
parse_grantee: called CC=4 SCAR=14.3
Pod
documented
| |||||||||||||||
| 13 | 2 | my ($self, $xpc, $node) = @_; | |||||||||||||
| 14 | |||||||||||||||
| 15 | 2 | ▶ | my $URI = $xpc->findvalue('.//s3:Grantee/s3:URI', $node) | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 16 | or croak 'no URI grant in provided node'; | ||||||||||||||
| 17 | 1 | $self->URI($URI); | |||||||||||||
| 18 | |||||||||||||||
| 19 | 1 | (my $key = $URI) =~ s{.*/}{}mxs; | |||||||||||||
| 20 | 1 | ▶ | $key = | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 21 | ($key eq 'AllUsers') ? 'ALL' | ||||||||||||||
| 22 | : ($key eq 'AuthenticatedUsers') ? 'AUTH' | ||||||||||||||
| 23 | : $URI; | ||||||||||||||
| 24 | 1 | $self->key($key); | |||||||||||||
| 25 | |||||||||||||||
| 26 | 1 | return $self; | |||||||||||||
| 27 | } ## end sub _parse_acl_grant | ||||||||||||||
| 28 | |||||||||||||||
| 29 | 3 | my (%canonical_key_for, %URI_for); | |||||||||||||
| 30 | |||||||||||||||
| 31 | 3 | ▶ | BEGIN { | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 32 | 3 | %canonical_key_for = ( | |||||||||||||
| 33 | 'AUTHENTICATED' => 'AUTH', | ||||||||||||||
| 34 | 'AUTH' => 'AUTH', | ||||||||||||||
| 35 | 'ALL' => 'ALL', | ||||||||||||||
| 36 | 'ANY' => 'ALL', | ||||||||||||||
| 37 | 'ANONYMOUS' => 'ALL', | ||||||||||||||
| 38 | 'ANON' => 'ALL', | ||||||||||||||
| 39 | '*' => 'ALL', | ||||||||||||||
| 40 | ); | ||||||||||||||
| 41 | 3 | %URI_for = ( | |||||||||||||
| 42 | AUTH => 'http://acs.amazonaws.com/groups/global/AuthenticatedUsers', | ||||||||||||||
| 43 | ALL => 'http://acs.amazonaws.com/groups/global/AllUsers', | ||||||||||||||
| 44 | ); | ||||||||||||||
| 45 | } | ||||||||||||||
| 46 | |||||||||||||||
| 47 | 50 | ▶ | sub canonical_key_for { | ||||||||||||
|
Subroutine
canonical_key_for: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||
| 48 | 50 | my ($self, $key) = @_; | |||||||||||||
| 49 | 50 | ▶ | if (my ($type) = $key =~ m{\A http://.*/(All | Authenticated)Users \z}imxs) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 50 | 4 | $key = $type; | |||||||||||||
| 51 | } | ||||||||||||||
| 52 | croak "no canonical name for '$key'" | ||||||||||||||
| 53 | 50 | ▶ | unless exists $canonical_key_for{uc $key}; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 54 | 7 | return $canonical_key_for{uc $key}; | |||||||||||||
| 55 | } | ||||||||||||||
| 56 | |||||||||||||||
| 57 | 46 | ▶ | sub populate_from_target { | ||||||||||||
|
Subroutine
populate_from_target: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||
| 58 | 46 | my ($self, $target) = @_; | |||||||||||||
| 59 | |||||||||||||||
| 60 | 46 | $target = $self->canonical_key_for($target); | |||||||||||||
| 61 | 3 | $self->key($target); | |||||||||||||
| 62 | 3 | $self->URI($URI_for{$target}); | |||||||||||||
| 63 | |||||||||||||||
| 64 | 3 | return $self; | |||||||||||||
| 65 | } | ||||||||||||||
| 66 | |||||||||||||||
| 67 | 4 | ▶ | sub _set_key { | ||||||||||||
|
Subroutine
_set_key: called CC=1 SCAR=0.0
| |||||||||||||||
| 68 | 4 | $_[0]->key($_[0]->canonical_key_for($_[0]->URI())); | |||||||||||||
| 69 | } | ||||||||||||||
| 70 | |||||||||||||||
| 71 | 2 | ▶ | sub stringify_grantee { | ||||||||||||
|
Subroutine
stringify_grantee: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||
| 72 | 2 | my ($self) = @_; | |||||||||||||
| 73 | 2 | my $URI = $self->URI(); | |||||||||||||
| 74 | 2 | return <<"END_OF_GRANTEE"; | |||||||||||||
| 75 | <Grantee xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="Group"> | ||||||||||||||
| 76 | <URI>$URI</URI> | ||||||||||||||
| 77 | </Grantee> | ||||||||||||||
| 78 | END_OF_GRANTEE | ||||||||||||||
| 79 | } | ||||||||||||||
| 80 | |||||||||||||||
| 81 | 3 | 1; # Magic true value required at end of module | |||||||||||||
| 82 | __END__ | ||||||||||||||