line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::PT::Test; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
20845
|
use 5.006; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
60
|
|
4
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
36
|
|
5
|
1
|
|
|
1
|
|
5
|
use warnings FATAL => 'all'; |
|
1
|
|
|
|
|
13
|
|
|
1
|
|
|
|
|
65
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 NAME |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
Net::PT::Test - The great new Net::PT! |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 VERSION |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
Version 0.01 |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
Copyright 2013 Paul Taylor. |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
This program is released under the following license: BSD |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=cut |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
31
|
|
|
|
|
|
|
|
32
|
1
|
|
|
1
|
|
13
|
use 5.006; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
39
|
|
33
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
34
|
|
34
|
1
|
|
|
1
|
|
4
|
use warnings FATAL => 'all'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
33
|
|
35
|
|
|
|
|
|
|
|
36
|
1
|
|
|
1
|
|
1100
|
use Time::HiRes qw(gettimeofday); |
|
1
|
|
|
|
|
2062
|
|
|
1
|
|
|
|
|
5
|
|
37
|
1
|
|
|
1
|
|
1220
|
use Math::Random::Secure qw(irand); |
|
1
|
|
|
|
|
105650
|
|
|
1
|
|
|
|
|
81
|
|
38
|
1
|
|
|
1
|
|
1089
|
use JSON; |
|
1
|
|
|
|
|
16532
|
|
|
1
|
|
|
|
|
6
|
|
39
|
1
|
|
|
1
|
|
1319
|
use MIME::Base64 qw(decode_base64 decode_base64url encode_base64url); |
|
1
|
|
|
|
|
838
|
|
|
1
|
|
|
|
|
83
|
|
40
|
1
|
|
|
1
|
|
799
|
use Crypt::Mac::HMAC qw( hmac_b64u ); |
|
1
|
|
|
|
|
6121
|
|
|
1
|
|
|
|
|
61
|
|
41
|
1
|
|
|
1
|
|
8
|
use Carp; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
61
|
|
42
|
1
|
|
|
1
|
|
1027
|
use URI::Encode qw(uri_encode); |
|
1
|
|
|
|
|
15542
|
|
|
1
|
|
|
|
|
64
|
|
43
|
1
|
|
|
1
|
|
927
|
use Mozilla::CA; |
|
1
|
|
|
|
|
235
|
|
|
1
|
|
|
|
|
25
|
|
44
|
|
|
|
|
|
|
|
45
|
1
|
|
|
1
|
|
443
|
use Data::Printer; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub test { |
48
|
|
|
|
|
|
|
my ($class, $s) = @_; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
print "Net::PT::Test - test(${class}, ${s})\n"; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
my $map = { |
53
|
|
|
|
|
|
|
class => $class, |
54
|
|
|
|
|
|
|
msg => $s |
55
|
|
|
|
|
|
|
}; |
56
|
|
|
|
|
|
|
print "Net::PT::Test - map = \n"; |
57
|
|
|
|
|
|
|
p $map; |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
my $json = encode_json $map; |
61
|
|
|
|
|
|
|
print "Net:PT - json = \n"; |
62
|
|
|
|
|
|
|
p $json; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
my $b64 = encode_base64url $json; |
65
|
|
|
|
|
|
|
print "Net::PT::Test - base64 url = \n"; |
66
|
|
|
|
|
|
|
p $b64; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
my $key = "monkey"; |
69
|
|
|
|
|
|
|
my $hmac = hmac_b64u('SHA256', $key, $b64); |
70
|
|
|
|
|
|
|
print "Net::PT::Test - hmac = \n"; |
71
|
|
|
|
|
|
|
p $hmac; |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
my $json2 = decode_base64url $b64; |
74
|
|
|
|
|
|
|
print "Net:PT - json2 = \n"; |
75
|
|
|
|
|
|
|
p $json2; |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
my $map2 = decode_json $json2; |
78
|
|
|
|
|
|
|
print "Net:PT - map2 = \n"; |
79
|
|
|
|
|
|
|
p $map2; |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
1; |
89
|
|
|
|
|
|
|
|