PROXY  WHOIS  RQUOTE  TEXTS  SOFT  FOREX  BBOARD
 Music  Philosophy  Code  Literature  Russian

= ROOT|Technical|Code_Examples|Perl|site_perl|Authen|Simple.pm =

page 1 of 2



package Authen::Simple;

use strict;
use warnings;

use Params::Validate qw[];

our $VERSION = 0.4;

sub new {
    my $class = shift;

    my %adapter = (
        isa      => 'Authen::Simple::Adapter',
        type     => Params::Validate::OBJECT,
        optional => 1
    );

    my @spec     = ( { %adapter, optional => 0 }, ( \%adapter ) x @_ );
    my $adapters = Params::Validate::validate_pos( @_, @spec );

    return bless( $adapters, $class );
}

sub authenticate {
    my ( $self, $username, $password ) = @_;

    foreach ( $username, $password ) {
        return 0 unless defined($_) && !ref($_) && length($_);
    }

    foreach my $adapter ( @{$self} ) {
        return 1 if $adapter->authenticate( $username, $password );
    }

    return 0;
}

1;

__END__

=head1 NAME

Authen::Simple - Simple Authentication

=head1 SYNOPSIS

    use Authen::Simple;
    use Authen::Simple::Kerberos;
    use Authen::Simple::SMB;

    my $simple = Authen::Simple->new(
        Authen::Simple::Kerberos->new( realm => 'REALM.COMPANY.COM' ),
        Authen::Simple::SMB->new( domain => 'DOMAIN', pdc => 'PDC' )
    );
    
    if ( $simple->authenticate( $username, $password ) ) {
        # successfull authentication
    }

=head1 DESCRIPTION

Simple and consistent framework for authentication.

=head1 METHODS

=over 4

=item * new

This method takes an array of C<Authen::Simple> adapters. Required.

=item * authenticate( $username, $password )

Returns true on success and false on failure.

=back

=head1 SEE ALSO

L<Authen::Simple::ActiveDirectory>.

L<Authen::Simple::CDBI>.

L<Authen::Simple::DBI>.

L<Authen::Simple::FTP>.

L<Authen::Simple::HTTP>.

L<Authen::Simple::Kerberos>.

L<Authen::Simple::LDAP>.

L<Authen::Simple::NIS>.

L<Authen::Simple::PAM>.

L<Authen::Simple::Passwd>.
=1=

= PAGE 1 = NEXT > |2

UP TO ROOT | UP TO DIR

Google
 


E-mail Facebook Google Digg del.icio.us BlinkList Fark Furl Ma.gnolia Netscape NewsVine Reddit Slashdot Spurl StumbleUpon Technorati YahooMyWeb LiveJournal Blogmarks TwitThis Live News2.ru BobrDobr.ru Memori.ru MoeMesto.ru

0.038954 wallclock secs ( 0.01 usr + 0.00 sys = 0.01 CPU)