line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Amazon::API::Signature4; |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
141795
|
use strict; |
|
4
|
|
|
|
|
12
|
|
|
4
|
|
|
|
|
115
|
|
4
|
4
|
|
|
4
|
|
19
|
use warnings; |
|
4
|
|
|
|
|
12
|
|
|
4
|
|
|
|
|
118
|
|
5
|
|
|
|
|
|
|
|
6
|
4
|
|
|
4
|
|
398
|
use parent qw( Exporter AWS::Signature4 ); |
|
4
|
|
|
|
|
270
|
|
|
4
|
|
|
|
|
24
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '2.0.10'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our @EXPORT_OK = qw{ parse_service_url }; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our @SERVICE_URL_REGEXP = ( |
13
|
|
|
|
|
|
|
qr/(s3)[.]amazonaws[.]com\z/xsm, |
14
|
|
|
|
|
|
|
qr/(s3)[.]([^.]+)[.]amazonaws[.]com\z/xsm, |
15
|
|
|
|
|
|
|
qr/(s3)[.][^.]+[.]([^.]+)[.]amazonaws[.]com\z/xsm, |
16
|
|
|
|
|
|
|
qr/(s3)[-][^.]+.+[.]([^.]+)[.]amazonaws[.]com\z/xsm, |
17
|
|
|
|
|
|
|
qr/^([[:alpha:]-]+)[.]amazonaws[.]com\z/xsm, |
18
|
|
|
|
|
|
|
qr/^([[:alpha:]-]+)[.]([^.]*)[.]amazonaws[.]com/xsm, |
19
|
|
|
|
|
|
|
); |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
######################################################################## |
22
|
|
|
|
|
|
|
sub new { |
23
|
|
|
|
|
|
|
######################################################################## |
24
|
0
|
|
|
0
|
1
|
0
|
my ( $class, @options ) = @_; |
25
|
0
|
|
0
|
|
|
0
|
$class = ref $class || $class; |
26
|
|
|
|
|
|
|
|
27
|
0
|
0
|
|
|
|
0
|
my %args = ref $options[0] ? $options[0] : @options; |
28
|
|
|
|
|
|
|
|
29
|
0
|
|
|
|
|
0
|
my $self = $class->SUPER::new(%args); |
30
|
|
|
|
|
|
|
|
31
|
0
|
|
|
|
|
0
|
my @extra = grep { !/access_key|secret_key|security_token/xsm } keys %args; |
|
0
|
|
|
|
|
0
|
|
32
|
|
|
|
|
|
|
|
33
|
0
|
|
|
|
|
0
|
@{$self}{@extra} = @args{@extra}; |
|
0
|
|
|
|
|
0
|
|
34
|
|
|
|
|
|
|
|
35
|
0
|
|
|
|
|
0
|
return $self; |
36
|
|
|
|
|
|
|
} ## end sub new |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
######################################################################## |
39
|
|
|
|
|
|
|
sub parse_service_url { |
40
|
|
|
|
|
|
|
######################################################################## |
41
|
14
|
|
|
14
|
0
|
21588
|
my (%args) = @_; |
42
|
|
|
|
|
|
|
|
43
|
14
|
|
|
|
|
39
|
my ( $host, $service ) = @args{qw{host service}}; |
44
|
14
|
|
|
|
|
27
|
my ( $region, $default_region ) = @args{qw{region default_region}}; |
45
|
|
|
|
|
|
|
|
46
|
14
|
50
|
33
|
|
|
40
|
if ( !$service || !$region ) { |
47
|
14
|
|
|
|
|
30
|
foreach my $regexp (@SERVICE_URL_REGEXP) { |
48
|
51
|
100
|
|
|
|
277
|
if ( $host =~ $regexp ) { |
49
|
|
|
|
|
|
|
# print Dumper [ $host, $regexp ]; |
50
|
|
|
|
|
|
|
|
51
|
14
|
|
|
|
|
37
|
$service = $1; |
52
|
14
|
|
66
|
|
|
59
|
$region = $2 || $region || $default_region; |
53
|
14
|
|
|
|
|
26
|
last; |
54
|
|
|
|
|
|
|
} ## end if ( $host =~ $regexp ) |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
} ## end foreach my $regexp (@SERVICE_URL_REGEXP) |
57
|
|
|
|
|
|
|
} ## end if ( !$service || !$region) |
58
|
|
|
|
|
|
|
|
59
|
14
|
|
|
|
|
59
|
return ( $host, $service, $region ); |
60
|
|
|
|
|
|
|
} ## end sub parse_service_url |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
############################################################### |
63
|
|
|
|
|
|
|
sub scope { |
64
|
|
|
|
|
|
|
############################################################### |
65
|
0
|
|
|
0
|
0
|
|
goto &_scope; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
############################################################### |
69
|
|
|
|
|
|
|
sub _scope { |
70
|
|
|
|
|
|
|
############################################################### |
71
|
0
|
|
|
0
|
|
|
my ( $self, $request, $region ) = @_; |
72
|
|
|
|
|
|
|
|
73
|
0
|
|
|
|
|
|
my $host = $request->uri->host; |
74
|
0
|
|
|
|
|
|
my $datetime = $self->_datetime($request); |
75
|
0
|
|
|
|
|
|
my ($date) = $datetime =~ /^(\d+)T/xsm; |
76
|
|
|
|
|
|
|
|
77
|
0
|
|
|
|
|
|
my $service = $self->{service}; |
78
|
|
|
|
|
|
|
|
79
|
0
|
|
|
|
|
|
( $host, $service, $region ) = parse_service_url( |
80
|
|
|
|
|
|
|
host => $host, |
81
|
|
|
|
|
|
|
service => $service, |
82
|
|
|
|
|
|
|
region => $region, |
83
|
|
|
|
|
|
|
default_region => 'us-east-1' |
84
|
|
|
|
|
|
|
); |
85
|
|
|
|
|
|
|
|
86
|
0
|
|
|
|
|
|
return "$date/$region/$service/aws4_request"; |
87
|
|
|
|
|
|
|
} ## end sub _scope |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
1; |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
__END__ |