File Coverage

blib/lib/WebService/Amazon/Signature.pm
Criterion Covered Total %
statement 16 17 94.1
branch 2 4 50.0
condition 1 2 50.0
subroutine 4 4 100.0
pod 1 1 100.0
total 24 28 85.7


line stmt bran cond sub pod time code
1             package WebService::Amazon::Signature;
2             # ABSTRACT: support for various ways to sign AWS requests
3 1     1   81564 use strict;
  1         2  
  1         33  
4 1     1   7 use warnings;
  1         2  
  1         97  
5              
6             our $VERSION = '0.001';
7              
8             =head1 NAME
9              
10             WebService::Amazon::Signature - handle signatures for Amazon webservices
11              
12             =head1 VERSION
13              
14             version 0.001
15              
16             =head1 SYNOPSIS
17              
18             my $req = 'GET / HTTP/1.1 ...';
19             my $amz = WebService::Amazon::Signature->new(
20             version => 4,
21             algorithm => 'AWS4-HMAC-SHA256',
22             scope => '20110909/us-east-1/host/aws4_request',
23             access_key => 'AKIDEXAMPLE',
24             secret_key => 'wJalrXUtnFEMI/K7MDENG+bPxRfiCYEXAMPLEKEY',
25             host_port => 'localhost:8000',
26             );
27             $amz->parse_request($req)
28             my $signed_req = $amz->signed_request($req);
29              
30             =head1 DESCRIPTION
31              
32             Provides methods for signing requests and verifying responses for Amazon webservices,
33             as described in L.
34              
35             =cut
36              
37 1     1   659 use WebService::Amazon::Signature::v4;
  1         4  
  1         157  
38              
39             =head1 METHODS
40              
41             =head2 new
42              
43             Instantiate a signing object.
44              
45             Will extract the C named parameter, if it exists, and use that
46             to select the appropriate subclass for instantiation. Other parameters
47             are as defined by the subclass.
48              
49             =over 4
50              
51             =item * L
52              
53             =item * L
54              
55             =back
56              
57             =cut
58              
59             sub new {
60 31     31 1 93281 my $class = shift;
61 31         159 my %args = @_;
62 31   50     132 my $version = delete $args{version} || 4;
63 31         75 my $pkg = 'WebService::Amazon::Signature::v' . $version;
64 31 50       316 if(my $code = $pkg->can('new')) {
65 31 50       90 $class = $pkg if $class eq __PACKAGE__;
66 31         159 return $code->($class, %args)
67             }
68 0           die "No support for version $version";
69             }
70              
71             1;
72              
73             __END__