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