line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package OIDC::Lite::Client::TokenResponseParser; |
2
|
1
|
|
|
1
|
|
906
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
27
|
|
3
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
27
|
|
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
1027
|
use Try::Tiny qw/try catch/; |
|
1
|
|
|
|
|
1683
|
|
|
1
|
|
|
|
|
49
|
|
6
|
1
|
|
|
1
|
|
6
|
use OIDC::Lite::Client::Token; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
7
|
|
7
|
1
|
|
|
1
|
|
465
|
use OAuth::Lite2::Formatters; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
use OAuth::Lite2::Client::Error; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub new { |
11
|
|
|
|
|
|
|
bless {}, $_[0]; |
12
|
|
|
|
|
|
|
} |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub parse { |
15
|
|
|
|
|
|
|
my ($self, $http_res) = @_; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
my $formatter = |
18
|
|
|
|
|
|
|
OAuth::Lite2::Formatters->get_formatter_by_type( |
19
|
|
|
|
|
|
|
$http_res->content_type); |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
my $token; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
if ($http_res->is_success) { |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
OAuth::Lite2::Client::Error::InvalidResponse->throw( |
26
|
|
|
|
|
|
|
message => sprintf(q{Invalid response content-type: %s}, |
27
|
|
|
|
|
|
|
$http_res->content_type||'') |
28
|
|
|
|
|
|
|
) unless $formatter; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
my $result = try { |
31
|
|
|
|
|
|
|
return $formatter->parse($http_res->content); |
32
|
|
|
|
|
|
|
} catch { |
33
|
|
|
|
|
|
|
OAuth::Lite2::Client::Error::InvalidResponse->throw( |
34
|
|
|
|
|
|
|
message => sprintf(q{Invalid response format: %s}, $_), |
35
|
|
|
|
|
|
|
); |
36
|
|
|
|
|
|
|
}; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
OAuth::Lite2::Client::Error::InvalidResponse->throw( |
39
|
|
|
|
|
|
|
message => sprintf("Response doesn't include 'access_token'") |
40
|
|
|
|
|
|
|
) unless exists $result->{access_token}; |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
$token = OIDC::Lite::Client::Token->new($result); |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
} else { |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
my $errmsg = $http_res->content || $http_res->status_line; |
47
|
|
|
|
|
|
|
if ($formatter && $http_res->content) { |
48
|
|
|
|
|
|
|
try { |
49
|
|
|
|
|
|
|
my $result = $formatter->parse($http_res->content); |
50
|
|
|
|
|
|
|
$errmsg = $result->{error} |
51
|
|
|
|
|
|
|
if exists $result->{error}; |
52
|
|
|
|
|
|
|
} catch { |
53
|
|
|
|
|
|
|
return OAuth::Lite2::Client::Error::InvalidResponse->throw; |
54
|
|
|
|
|
|
|
}; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
OAuth::Lite2::Client::Error::InvalidResponse->throw( message => $errmsg ); |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
return $token; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head1 AUTHOR |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
Ryo Ito, Eritou.06@gmail.comE |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
Copyright (C) 2012 by Ryo Ito |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
70
|
|
|
|
|
|
|
it under the same terms as Perl itself, either Perl version 5.8.8 or, |
71
|
|
|
|
|
|
|
at your option, any later version of Perl 5 you may have available. |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=cut |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
1; |