|
Revision 2528, 1.2 kB
(checked in by fumiakiy, 18 months ago)
|
|
Updated Net::OAuth modules to the latest version. BugId:80041
|
| Line | |
|---|
| 1 | package Net::OAuth::SignatureMethod::RSA_SHA1; |
|---|
| 2 | use warnings; |
|---|
| 3 | use strict; |
|---|
| 4 | use MIME::Base64; |
|---|
| 5 | |
|---|
| 6 | sub sign { |
|---|
| 7 | my $self = shift; |
|---|
| 8 | my $request = shift; |
|---|
| 9 | my $key = shift || $request->signature_key; |
|---|
| 10 | die '$request->signature_key must be an RSA key object (e.g. Crypt::OpenSSL::RSA) that can sign($text)' |
|---|
| 11 | unless UNIVERSAL::can($key, 'sign'); |
|---|
| 12 | return encode_base64($key->sign($request->signature_base_string), ""); |
|---|
| 13 | } |
|---|
| 14 | |
|---|
| 15 | sub verify { |
|---|
| 16 | my $self = shift; |
|---|
| 17 | my $request = shift; |
|---|
| 18 | my $key = shift || $request->signature_key; |
|---|
| 19 | die 'You must pass an RSA key object (e.g. Crypt::OpenSSL::RSA) that can verify($text,$sig)' |
|---|
| 20 | unless UNIVERSAL::can($key, 'verify'); |
|---|
| 21 | return $key->verify($request->signature_base_string, decode_base64($request->signature)); |
|---|
| 22 | } |
|---|
| 23 | |
|---|
| 24 | =head1 NAME |
|---|
| 25 | |
|---|
| 26 | Net::OAuth::SignatureMethod::RSA_SHA1 - RSA_SHA1 Signature Method for OAuth protocol |
|---|
| 27 | |
|---|
| 28 | =head1 SEE ALSO |
|---|
| 29 | |
|---|
| 30 | L<Net::OAuth::Request>, L<http://oauth.net> |
|---|
| 31 | |
|---|
| 32 | =head1 AUTHOR |
|---|
| 33 | |
|---|
| 34 | Keith Grennan, C<< <kgrennan at cpan.org> >> |
|---|
| 35 | |
|---|
| 36 | =head1 COPYRIGHT & LICENSE |
|---|
| 37 | |
|---|
| 38 | Copyright 2007 Keith Grennan, all rights reserved. |
|---|
| 39 | |
|---|
| 40 | This program is free software; you can redistribute it and/or modify it |
|---|
| 41 | under the same terms as Perl itself. |
|---|
| 42 | |
|---|
| 43 | =cut |
|---|
| 44 | |
|---|
| 45 | 1; |
|---|