« blib/lib/Paws/Credential/ECSContainerProfile.pm
↑ Summary
blib/lib/Paws/Credential/CredProcess.pm »
| 1 | package Paws::Net::S3Signature; | ||||||||||||
| 2 | 15 | ▶ | use Moose::Role; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 3 | 15 | requires 'service'; | |||||||||||
| 4 | |||||||||||||
| 5 | 71 | ▶ | sub BUILD { | ||||||||||
|
Subroutine
BUILD: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||
| 6 | 71 | my $self = shift; | |||||||||||
| 7 | |||||||||||||
| 8 | # These calls are here so that when you construct | ||||||||||||
| 9 | # the object the endpoint information and the _region_for_signature | ||||||||||||
| 10 | # are calculated during construction. This is to avoid the fact that | ||||||||||||
| 11 | # these attributes are lazy (because they depend on other attributes) | ||||||||||||
| 12 | # and they don't get used until the first method is called, so if | ||||||||||||
| 13 | # they are incorrect, they don't throw until the first method is called. | ||||||||||||
| 14 | # It's much better to have them throw when $paws->service('...') is called | ||||||||||||
| 15 | # as this is the point where the user had specified "incorrect" information, | ||||||||||||
| 16 | # instead of the problem happening in the first method call. | ||||||||||||
| 17 | 71 | $self->endpoint; | |||||||||||
| 18 | 71 | $self->_region_for_signature; | |||||||||||
| 19 | } | ||||||||||||
| 20 | |||||||||||||
| 21 | 15 | ▶ | use Digest::SHA; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 22 | 15 | ▶ | use Net::Amazon::Signature::V4; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 23 | |||||||||||||
| 24 | 130 | ▶ | sub sign { | ||||||||||
|
Subroutine
sign: called CC=4 SCAR=14.1
Pod
undocumented
| |||||||||||||
| 25 | 130 | my ($self, $request) = @_; | |||||||||||
| 26 | |||||||||||||
| 27 | 130 | ▶ | if ($self->session_token) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 28 | 0 | $request->header( 'X-Amz-Security-Token' => $self->session_token ); | |||||||||||
| 29 | } | ||||||||||||
| 30 | |||||||||||||
| 31 | 130 | my $hasher = Digest::SHA->new(256); | |||||||||||
| 32 | 130 | ▶ | $hasher->add($request->content || q[]); | ||||||||||
|
Condition100%2/2
$request->content || ''
MC/DC100%1/1
$request->content || ''
$request->content
Truth table100%2/2
A
A= $request->content
| |||||||||||||
| 33 | 130 | $request->header('X-Amz-Content-Sha256' => $hasher->hexdigest); | |||||||||||
| 34 | |||||||||||||
| 35 | # AWS prefers X-Amz-Date but Net::Amazon::Signature::V4 only handles Date in the headerpackage Paws::Net::S3Signature; | ||||||||||||
| 36 | 130 | $request->header( 'Date' => $request->{'date'} ); | |||||||||||
| 37 | |||||||||||||
| 38 | 130 | ▶ | $request->header( | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 39 | 'Host' => $self->endpoint->default_port == $self->endpoint->port | ||||||||||||
| 40 | ? $self->endpoint->host | ||||||||||||
| 41 | : $self->endpoint->host_port); | ||||||||||||
| 42 | |||||||||||||
| 43 | 130 | my $sig = Net::Amazon::Signature::V4->new( $self->access_key, $self->secret_key, $self->region, $self->service ); | |||||||||||
| 44 | 130 | my $signed_req = $sig->sign( $request ); | |||||||||||
| 45 | 130 | return $signed_req; | |||||||||||
| 46 | |||||||||||||
| 47 | } | ||||||||||||
| 48 | 15 | 1; | |||||||||||