File Coverage

blib/lib/OAuth/Lite/Problems.pm
Criterion Covered Total %
statement 66 66 100.0
branch 2 2 100.0
condition n/a
subroutine 22 22 100.0
pod 1 1 100.0
total 91 91 100.0


line stmt bran cond sub pod time code
1             package OAuth::Lite::Problems;
2              
3 3     3   573 use strict;
  3         7  
  3         93  
4 3     3   15 use warnings;
  3         7  
  3         84  
5              
6 3     3   16 use base 'Exporter';
  3         4  
  3         633  
7              
8             our %EXPORT_TAGS = ( all => [qw/
9             VERSION_REJECTED
10             PARAMETER_ABSENT
11             PARAMETER_REJECTED
12             TIMESTAMP_REFUSED
13             NONCE_USED
14             SIGNATURE_METHOD_REJECTED
15             SIGNATURE_INVALID
16             CONSUMER_KEY_UNKNOWN
17             CONSUMER_KEY_REJECTED
18             CONSUMER_KEY_REFUSED
19             TOKEN_USED
20             TOKEN_EXPIRED
21             TOKEN_REVOKED
22             TOKEN_REJECTED
23             ADDITIONAL_AUTHORIZATION_REQUIRED
24             PERMISSION_UNKNOWN
25             PERMISSION_DENIED
26             USER_REFUSED
27             /] );
28              
29             our @EXPORT_OK = map { @$_ } values %EXPORT_TAGS;
30              
31 3     3   24 use constant VERSION_REJECTED => 'version_rejected';
  3         14  
  3         317  
32 3     3   21 use constant PARAMETER_ABSENT => 'parameter_absent';
  3         5  
  3         172  
33 3     3   20 use constant PARAMETER_REJECTED => 'parameter_rejected';
  3         5  
  3         146  
34 3     3   19 use constant TIMESTAMP_REFUSED => 'timestamp_refused';
  3         17  
  3         184  
35 3     3   20 use constant NONCE_USED => 'nonce_used';
  3         5  
  3         170  
36 3     3   19 use constant SIGNATURE_METHOD_REJECTED => 'signature_method_rejected';
  3         13  
  3         146  
37 3     3   18 use constant SIGNATURE_INVALID => 'signature_invalid';
  3         6  
  3         192  
38 3     3   20 use constant CONSUMER_KEY_UNKNOWN => 'consumer_key_unknown';
  3         6  
  3         163  
39 3     3   18 use constant CONSUMER_KEY_REJECTED => 'consumer_key_rejected';
  3         14  
  3         153  
40 3     3   18 use constant CONSUMER_KEY_REFUSED => 'consumer_key_refused';
  3         7  
  3         159  
41 3     3   20 use constant TOKEN_USED => 'token_used';
  3         6  
  3         191  
42 3     3   20 use constant TOKEN_EXPIRED => 'token_expired';
  3         5  
  3         516  
43 3     3   20 use constant TOKEN_REVOKED => 'token_revoked';
  3         5  
  3         158  
44 3     3   21 use constant TOKEN_REJECTED => 'token_rejected';
  3         6  
  3         140  
45 3     3   18 use constant ADDITIONAL_AUTHORIZATION_REQUIRED => 'additional_authorization_required';
  3         5  
  3         156  
46 3     3   18 use constant PERMISSION_UNKNOWN => 'permission_unknown';
  3         6  
  3         162  
47 3     3   19 use constant PERMISSION_DENIED => 'permission_denied';
  3         12  
  3         141  
48 3     3   19 use constant USER_REFUSED => 'user_refused';
  3         5  
  3         418  
49              
50             my %PROBLEMS = map { __PACKAGE__->$_() => 1 } @EXPORT_OK;
51              
52             sub match {
53 20     20 1 4631 my $class = shift;
54 20         31 my $error = shift;
55 20 100       70 return $PROBLEMS{$error} ? 1 : 0;
56             }
57              
58              
59             1;
60              
61             =head1 NAME
62              
63             OAuth::Lite::Problems - constants for OAuth Problem Reporting Extension
64              
65             =head1 SYNOPSIS
66              
67             use OAuth::Problems qw(:all);
68              
69             $server->error( TOKEN_REJECTED );
70              
71             =head1 DESCRIPTION
72              
73             This provides constants which used in OAuth Problem Reporting spec.
74              
75             =head1 METHODS
76              
77             =head2 match($error)
78              
79             my $error = 'token_rejected';
80             if (OAuth::Lite::Problems->match($error)) {
81             say "This error is OAuth Problem";
82             $server->error(sprintf "oauth_problem=%s", $error);
83             }
84              
85             =head1 CONSTANTS
86              
87             =head2 VERSION_REJECTED
88             =head2 PARAMETER_ABSENT
89             =head2 PARAMETER_REJECTED
90             =head2 TIMESTAMP_REFUSED
91             =head2 NONCE_USED
92             =head2 SIGNATURE_METHOD_REJECTED
93             =head2 SIGNATURE_INVALID
94             =head2 CONSUMER_KEY_UNKNOWN
95             =head2 CONSUMER_KEY_REJECTED
96             =head2 CONSUMER_KEY_REFUSED
97             =head2 TOKEN_USED
98             =head2 TOKEN_EXPIRED
99             =head2 TOKEN_REVOKED
100             =head2 TOKEN_REJECTED
101             =head2 ADDITIONAL_AUTHORIZATION_REQUIRED
102             =head2 PERMISSION_UNKNOWN
103             =head2 PERMISSION_DENIED
104             =head2 USER_REFUSED
105              
106             =head1 SEE ALSO
107              
108             http://oauth.pbworks.com/ProblemReporting
109              
110             =head1 AUTHOR
111              
112             Lyo Kato, C
113              
114             =head1 COPYRIGHT AND LICENSE
115              
116             This library is free software; you can redistribute it and/or modify
117             it under the same terms as Perl itself, either Perl version 5.8.6 or,
118             at your option, any later version of Perl 5 you may have available.
119              
120             =cut
121