line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package WWW::Live::Auth::ApplicationToken; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
7
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
47
|
|
4
|
1
|
|
|
1
|
|
7
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
29
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
7
|
use WWW::Live::Auth::Utils; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
848
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub new { |
9
|
0
|
|
|
0
|
0
|
|
my ( $proto, $signature_key, $app_id, $client_ip ) = @_; |
10
|
0
|
|
0
|
|
|
|
my $class = ref $proto || $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
|
|
|
0
|
0
|
|
my $self = shift; |
20
|
0
|
|
|
|
|
|
return $self->{'string'}; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub application_id { |
24
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
25
|
0
|
|
|
|
|
|
return $self->{'application_id'}; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub timestamp { |
29
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
30
|
0
|
|
|
|
|
|
return $self->{'timestamp'}; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub client_ip { |
34
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
35
|
0
|
|
|
|
|
|
return $self->{'client_ip'}; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub _process { |
39
|
0
|
|
|
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
|
0
|
|
|
|
|
if ( $client_ip ) { |
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; |
59
|
|
|
|
|
|
|
__END__ |