line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package OAuth::Lite2::ParamMethods; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
1476
|
use strict; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
109
|
|
4
|
3
|
|
|
3
|
|
16
|
use warnings; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
117
|
|
5
|
|
|
|
|
|
|
|
6
|
3
|
|
|
3
|
|
1698
|
use OAuth::Lite2::ParamMethod::AuthHeader; |
|
3
|
|
|
|
|
12
|
|
|
3
|
|
|
|
|
132
|
|
7
|
3
|
|
|
3
|
|
1902
|
use OAuth::Lite2::ParamMethod::FormEncodedBody; |
|
3
|
|
|
|
|
10
|
|
|
3
|
|
|
|
|
111
|
|
8
|
3
|
|
|
3
|
|
1580
|
use OAuth::Lite2::ParamMethod::URIQueryParameter; |
|
3
|
|
|
|
|
9
|
|
|
3
|
|
|
|
|
120
|
|
9
|
|
|
|
|
|
|
|
10
|
3
|
|
|
3
|
|
21
|
use base 'Exporter'; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
486
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( all => [qw/ |
13
|
|
|
|
|
|
|
AUTH_HEADER FORM_BODY URI_QUERY |
14
|
|
|
|
|
|
|
/] ); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
our @EXPORT_OK = map { @$_ } values %EXPORT_TAGS; |
17
|
|
|
|
|
|
|
|
18
|
3
|
|
|
3
|
|
19
|
use constant AUTH_HEADER => 0; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
250
|
|
19
|
3
|
|
|
3
|
|
17
|
use constant FORM_BODY => 1; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
168
|
|
20
|
3
|
|
|
3
|
|
21
|
use constant URI_QUERY => 2; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
668
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
my @METHODS = ( |
23
|
|
|
|
|
|
|
OAuth::Lite2::ParamMethod::AuthHeader->new, |
24
|
|
|
|
|
|
|
OAuth::Lite2::ParamMethod::FormEncodedBody->new, |
25
|
|
|
|
|
|
|
OAuth::Lite2::ParamMethod::URIQueryParameter->new, |
26
|
|
|
|
|
|
|
); |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub get_param_parser { |
29
|
40
|
|
|
40
|
1
|
3811
|
my ($self, $req) = @_; |
30
|
40
|
|
|
|
|
70
|
for my $method ( @METHODS ) { |
31
|
77
|
100
|
|
|
|
284
|
return $method if $method->match($req) |
32
|
|
|
|
|
|
|
} |
33
|
0
|
|
|
|
|
0
|
return; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub get_request_builder { |
37
|
4
|
|
|
4
|
1
|
22
|
my ($self, $type) = @_; |
38
|
4
|
|
|
|
|
9
|
return $METHODS[ $type ]; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head1 NAME |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
OAuth::Lite2::ParamMethods - store of builders/parsers for OAuth 2.0 parameters |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=head1 SYNOPSIS |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
use OAuth::Lite2::ParamMethods qw(AUTH_HEADER FORM_BODY URI_QUERY); |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
# client side |
50
|
|
|
|
|
|
|
my $builder = OAuth::Lite2::ParamMethods->get_request_builder( AUTH_HEADER ); |
51
|
|
|
|
|
|
|
my $req = $builder->build_request(...); |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
# server side |
54
|
|
|
|
|
|
|
my $parser = OAuth::Lite2::ParamMethods->get_param_parser( $plack_request ) |
55
|
|
|
|
|
|
|
or $app->error("This is not OAuth 2.0 request"); |
56
|
|
|
|
|
|
|
my ($token, $params) = $parser->parse( $plack_request ); |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head1 DESCRIPTION |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
Store of builders/parsers for OAuth 2.0 parameters |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head1 CONSTANTS |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=over 4 |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=item AUTH_HEADER |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=item FORM_BODY |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=item URI_QUERY |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=back |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head1 METHODS |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head2 get_param_parser( $plack_request ) |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
Pass a L object and proper parser for the request. |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
my $parser = OAuth::Lite2::ParamMethods->get_param_parser( $plack_request ) |
81
|
|
|
|
|
|
|
or $app->error("This is not OAuth 2.0 request"); |
82
|
|
|
|
|
|
|
my ($token, $params) = $parser->parse( $plack_request ); |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head2 get_request_builder( $type ) |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
Returns proper HTTP request builder for the passed $type. |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
my $builder = OAuth::Lite2::ParamMethods->get_request_builder( AUTH_HEADER ); |
89
|
|
|
|
|
|
|
my $req = $builder->build_request(...); |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head1 SEE ALSO |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
L |
94
|
|
|
|
|
|
|
L |
95
|
|
|
|
|
|
|
L |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head1 AUTHOR |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
Lyo Kato, Elyo.kato@gmail.comE |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
Copyright (C) 2010 by Lyo Kato |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
106
|
|
|
|
|
|
|
it under the same terms as Perl itself, either Perl version 5.8.8 or, |
107
|
|
|
|
|
|
|
at your option, any later version of Perl 5 you may have available. |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=cut |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
1; |