| 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 | sub new { | ||||||||||||||||||||
| 9 | 0 | ▶ | my ( $proto, $signature_key, $app_id, $client_ip ) = @_; | ||||||||||||||||||
|
Subroutine
new: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||
| 10 | 0 | ▶ | my $class = ref $proto || $proto; | ||||||||||||||||||
|
Condition0%0/3
ref $proto || $proto
MC/DC0%0/2
ref $proto || $proto
ref $proto
$proto
Truth table0%0/3
A || B
A= ref $protoB= $proto
| |||||||||||||||||||||
| 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 | sub as_string { | ||||||||||||||||||||
| 19 | 0 | ▶ | my $self = shift; | ||||||||||||||||||
|
Subroutine
as_string: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 20 | 0 | return $self->{'string'}; | |||||||||||||||||||
| 21 | } | ||||||||||||||||||||
| 22 | |||||||||||||||||||||
| 23 | sub application_id { | ||||||||||||||||||||
| 24 | 0 | ▶ | my $self = shift; | ||||||||||||||||||
|
Subroutine
application_id: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 25 | 0 | return $self->{'application_id'}; | |||||||||||||||||||
| 26 | } | ||||||||||||||||||||
| 27 | |||||||||||||||||||||
| 28 | sub timestamp { | ||||||||||||||||||||
| 29 | 0 | ▶ | my $self = shift; | ||||||||||||||||||
|
Subroutine
timestamp: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 30 | 0 | return $self->{'timestamp'}; | |||||||||||||||||||
| 31 | } | ||||||||||||||||||||
| 32 | |||||||||||||||||||||
| 33 | sub client_ip { | ||||||||||||||||||||
| 34 | 0 | ▶ | my $self = shift; | ||||||||||||||||||
|
Subroutine
client_ip: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 35 | 0 | return $self->{'client_ip'}; | |||||||||||||||||||
| 36 | } | ||||||||||||||||||||
| 37 | |||||||||||||||||||||
| 38 | sub _process { | ||||||||||||||||||||
| 39 | 0 | ▶ | my ( $self, $signature_key, $app_id, $client_ip ) = @_; | ||||||||||||||||||
|
Subroutine
_process: not called CC=2 SCAR=17.9
| |||||||||||||||||||||
| 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
| |||||||||||||||||||||
| 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__ | ||||||||||||||||||||