File Coverage

blib/lib/OIDC/Lite/Server/GrantHandlers.pm
Criterion Covered Total %
statement 7 9 77.7
branch n/a
condition n/a
subroutine 3 3 100.0
pod n/a
total 10 12 83.3


line stmt bran cond sub pod time code
1             package OIDC::Lite::Server::GrantHandlers;
2 1     1   1219 use strict;
  1         2  
  1         29  
3 1     1   3 use warnings;
  1         1  
  1         20  
4              
5 1     1   373 use OIDC::Lite::Server::GrantHandler::AuthorizationCode;
  0            
  0            
6             use OAuth::Lite2::Server::GrantHandler::Password;
7             use OAuth::Lite2::Server::GrantHandler::RefreshToken;
8             use OAuth::Lite2::Server::GrantHandler::ClientCredentials;
9             use OAuth::Lite2::Server::GrantHandler::GroupingRefreshToken;
10             use OAuth::Lite2::Server::GrantHandler::ServerState;
11              
12             my %HANDLERS;
13              
14             sub add_handler {
15             my ($class, $type, $handler) = @_;
16             $HANDLERS{$type} = $handler;
17             }
18              
19             __PACKAGE__->add_handler( 'authorization_code' =>
20             OIDC::Lite::Server::GrantHandler::AuthorizationCode->new );
21             __PACKAGE__->add_handler( 'password' =>
22             OAuth::Lite2::Server::GrantHandler::Password->new );
23             __PACKAGE__->add_handler( 'refresh_token' =>
24             OAuth::Lite2::Server::GrantHandler::RefreshToken->new );
25             __PACKAGE__->add_handler( 'client_credentials' =>
26             OAuth::Lite2::Server::GrantHandler::ClientCredentials->new );
27             # Grant types which is not defined in RFC
28             __PACKAGE__->add_handler( 'grouping_refresh_token' =>
29             OAuth::Lite2::Server::GrantHandler::GroupingRefreshToken->new );
30             __PACKAGE__->add_handler( 'server_state' =>
31             OAuth::Lite2::Server::GrantHandler::ServerState->new );
32             __PACKAGE__->add_handler( 'external_service' =>
33             OAuth::Lite2::Server::GrantHandler::ExternalService->new );
34              
35             #__PACKAGE__->add_handler( 'assertion' => );
36             #__PACKAGE__->add_handler( 'none' => );
37              
38             sub get_handler {
39             my ($class, $type) = @_;
40             return $HANDLERS{$type};
41             }
42              
43             =head1 NAME
44              
45             OIDC::Lite::Server::GrantHandlers - store of handlers for each grant_type.
46              
47             =head1 SYNOPSIS
48              
49             my $handler = OIDC::Lite::Server::GrantHandlers->get_handler( $grant_type );
50             $handler->handle_request( $ctx );
51              
52             =head1 DESCRIPTION
53              
54             store of handlers for each grant_type.
55              
56             =head1 METHODS
57              
58             =head2 add_handler( $grant_type, $handler )
59              
60             add GrantHandler instance
61              
62             =head2 get_handler( $grant_type )
63              
64             get GrantHandler instance
65              
66             =head1 SEE ALSO
67              
68             L
69             L
70             L
71             L
72             L
73             L
74             L
75              
76             =head1 AUTHOR
77              
78             Ryo Ito, Eritou.06@gmail.comE
79              
80             =head1 COPYRIGHT AND LICENSE
81              
82             Copyright (C) 2012 by Ryo Ito
83              
84             This library is free software; you can redistribute it and/or modify
85             it under the same terms as Perl itself, either Perl version 5.8.8 or,
86             at your option, any later version of Perl 5 you may have available.
87              
88             =cut
89              
90             1;
91