| 1 | package OAuth::Lite2::Signer::Algorithms; | ||
| 2 | |||
| 3 | 2 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 2 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | |||
| 6 | #use OAuth::Lite2::Signer::Algorithm::HMAC_SHA1; | ||
| 7 | 2 | ▶ | use OAuth::Lite2::Signer::Algorithm::HMAC_SHA256; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | |||
| 9 | 2 | my %ALGORITHMS; | |
| 10 | |||
| 11 | sub add_algorithm { | ||
| 12 | 2 | ▶ | my ($class, $signer) = @_; |
|
Subroutine
add_algorithm: called CC=1 SCAR=0.0
Pod
documented
| |||
| 13 | 2 | $ALGORITHMS{$signer->name} = $signer; | |
| 14 | } | ||
| 15 | |||
| 16 | #__PACKAGE__->add_algorithm( OAuth::Lite2::Signer::Algorithm::HMAC_SHA1->new ); | ||
| 17 | 2 | __PACKAGE__->add_algorithm( OAuth::Lite2::Signer::Algorithm::HMAC_SHA256->new ); | |
| 18 | |||
| 19 | sub get_algorithm { | ||
| 20 | 4 | ▶ | my ($class, $name) = @_; |
|
Subroutine
get_algorithm: called CC=1 SCAR=0.0
Pod
documented
| |||
| 21 | 4 | return $ALGORITHMS{$name}; | |
| 22 | } | ||
| 23 | |||
| 24 | =head1 NAME | ||
| 25 | |||
| 26 | OAuth::Lite2::Signer::Algorithms - signature algorithms | ||
| 27 | |||
| 28 | =head1 SYNOPSIS | ||
| 29 | |||
| 30 | my $algorithm = OAuth::Lite2::Signer::Algorithms->get_algorithm('hmac-sha256'); | ||
| 31 | my $signature = $algorithm->hash($key, $text); | ||
| 32 | |||
| 33 | =head1 DESCRIPTION | ||
| 34 | |||
| 35 | DEPRECATED. algorithm object store for OAuth 2.0 signature. | ||
| 36 | |||
| 37 | =head1 METHODS | ||
| 38 | |||
| 39 | =head2 add_algorithm( $signer ) | ||
| 40 | |||
| 41 | Add signer algorithm object. the class should be L<OAuth::Lite2::Signer::Algorithm> or its child. | ||
| 42 | L<OAuth::Lite2::Signer::Algorithm::HMAC_SHA256> is automatically added by default. | ||
| 43 | |||
| 44 | =head2 get_algorithm( $algorithm_name ) | ||
| 45 | |||
| 46 | Get algorithm object by its name. | ||
| 47 | |||
| 48 | my $algorithm = OAuth::Lite2::Signer::Algorithms->get_algorithm('hmac-sha256'); | ||
| 49 | |||
| 50 | =head1 SEE ALSO | ||
| 51 | |||
| 52 | L<OAuth::Lite2::Signer::Algorithm> | ||
| 53 | L<OAuth::Lite2::Signer::Algorithm::HMAC_SHA1> | ||
| 54 | L<OAuth::Lite2::Signer::Algorithm::HMAC_SHA256> | ||
| 55 | |||
| 56 | =head1 AUTHOR | ||
| 57 | |||
| 58 | Lyo Kato, E<lt>lyo.kato@gmail.comE<gt> | ||
| 59 | |||
| 60 | =head1 COPYRIGHT AND LICENSE | ||
| 61 | |||
| 62 | Copyright (C) 2010 by Lyo Kato | ||
| 63 | |||
| 64 | This library is free software; you can redistribute it and/or modify | ||
| 65 | it under the same terms as Perl itself, either Perl version 5.8.8 or, | ||
| 66 | at your option, any later version of Perl 5 you may have available. | ||
| 67 | |||
| 68 | =cut | ||
| 69 | |||
| 70 | |||
| 71 | 2 | 1; | |