Auth/ApplicationToken.pm

filter: Statementstmt 28.5% 10 / 35 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 33.3% 3 / 9 Podpod 0.0% 0 / 5 totaltotal 23.2% 13 / 56 CC 3 SCAR 11.6
CC
3
Cov
25%
new
6.0
_process
6.0
as_string
2.0
CRAP 3.2
« Auth/Offer.pm ↑ Summary Auth/SecretKey.pm »
1 package WWW::Live::Auth::ApplicationToken;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 ▶use WWW::Live::Auth::Utils;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 0 ▶sub new {
Subroutine new: not called CC=2 SCAR=17.9
Pod undocumented
9 0 my ( $proto, $signature_key, $app_id, $client_ip ) = @_;
10 0 ▶ my $class = ref $proto || $proto;
Condition0%0/3
ref $proto || $proto
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $proto || $proto
ref $proto $proto
Truth table0%0/3
A || B
A= ref $protoB= $proto
ABresult
1X1
011
000
11  
12 0 my $self = bless {}, $class;
13 0 $self->_process( $signature_key, $app_id, $client_ip );
14  
15 0 return $self;
16 }
17  
18 0 ▶sub as_string {
Subroutine as_string: not called CC=1 SCAR=6.9
Pod undocumented
19 0 my $self = shift;
20 0 return $self->{'string'};
21 }
22  
23 0 ▶sub application_id {
Subroutine application_id: not called CC=1 SCAR=6.9
Pod undocumented
24 0 my $self = shift;
25 0 return $self->{'application_id'};
26 }
27  
28 0 ▶sub timestamp {
Subroutine timestamp: not called CC=1 SCAR=6.9
Pod undocumented
29 0 my $self = shift;
30 0 return $self->{'timestamp'};
31 }
32  
33 0 ▶sub client_ip {
Subroutine client_ip: not called CC=1 SCAR=6.9
Pod undocumented
34 0 my $self = shift;
35 0 return $self->{'client_ip'};
36 }
37  
38 0 ▶sub _process {
Subroutine _process: not called CC=2 SCAR=17.9
39 0 my ( $self, $signature_key, $app_id, $client_ip ) = @_;
40  
41 0 my $timestamp = _timestamp();
42 0 $self->{'timestamp'} = $timestamp;
43 0 $self->{'application_id'} = $app_id;
44  
45 0 my $token = sprintf "appid=%s&ts=%s", $app_id, $timestamp;
46 0 ▶ if ( $client_ip ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($client_ip) 0 0 0
47 0 $token .= sprintf "&ip=%s", $client_ip;
48 0 $self->{'client_ip'} = $client_ip;
49 }
50  
51 0 my $signature = _escape( _encode( _sign( $token, $signature_key ) ) );
52 0 $self->{'signature'} = $signature;
53 0 $token .= sprintf '&sig=%s', $signature;
54  
55 0 $self->{'string'} = _escape( $token );
56 }
57  
58 1 1;
59 __END__
« Auth/Offer.pm ↑ Summary Auth/SecretKey.pm »