| 1 | # WWW:Auth::FTP | ||
| 2 | # | ||
| 3 | # Copyright (c) 2002 Jonathan A. Waxman <jowaxman@law.upenn.edu> | ||
| 4 | # All rights reserved. | ||
| 5 | # | ||
| 6 | # This program is free software; you can redistribute it and/or | ||
| 7 | # modify it under the same terms as Perl itself. | ||
| 8 | |||
| 9 | |||
| 10 | package WWW::Auth::FTP; | ||
| 11 | use base 'WWW::Auth::Base'; | ||
| 12 | |||
| 13 | |||
| 14 | use strict; | ||
| 15 | use WWW::Auth::Config; | ||
| 16 | use Net::FTP; | ||
| 17 | |||
| 18 | |||
| 19 | sub _init { | ||
| 20 | my $self = shift; | ||
| 21 | my %params = @_; | ||
| 22 | |||
| 23 | $self->{_ftphost} = $params{FTPHost} || WWW::Auth::Config->ftphost | ||
| 24 | || return $self->error ('No FTP host specified.'); | ||
| 25 | |||
| 26 | return 1; | ||
| 27 | } | ||
| 28 | |||
| 29 | sub auth { | ||
| 30 | my $self = shift; | ||
| 31 | my ($uid, $pwd, %params) = @_; | ||
| 32 | |||
| 33 | my $ftp = Net::FTP->new ($self->{_ftphost}); | ||
| 34 | my $success = $ftp->login ($uid, $pwd); | ||
| 35 | $ftp->quit; | ||
| 36 | |||
| 37 | return ($success, 'Username/Password incorrect'); | ||
| 38 | } | ||
| 39 | |||
| 40 | |||
| 41 | 1; |