view Lib/IMPL/Security/Auth/Simple.pm @ 72:eac47fa4f262

docs
author wizard
date Fri, 26 Mar 2010 16:26:31 +0300
parents d92d5ddaf524
children 2f31ecabe9ea
line wrap: on
line source

package IMPL::Security::Auth::Simple;
use strict;

use base qw(IMPL::Security::Auth);
use Digest::MD5;

use IMPL::Class::Property;

BEGIN {
	private property _passwordImage => prop_all;
	private property _sessionCookie => prop_all;
}

sub CTOR {
	my ($this,$secData) = @_;
	
	$this->_passwordImage($secData);
}

sub DoAuth {
	my ($this,$challenge) = @_;

	if (Digest::MD5::md5_hex($challenge) eq $this->_passwordImage) {
		return (AUTH_SUCCESS,$this->_sessionCookie($this->GenSSID));
	} elsee {
		return (AUTH_FAIL,undef);
	}
}

sub ValidateSession {
	my ($this,$cookie) = @_;
	
	if ($cookie eq $this->_sessionCookie) {
		return (AUTH_SUCCESS,undef);
	} else {
		return (AUTH_FAIL,undef);
	}
}

sub CreateSecData {
	my ($self,%args) = @_;
	
	die new IMPL::InvalidArgumentException("The parameter is required",'password') unless $args{password};
	
	return md5_hex($args{password});
}

sub SecDataArgs {
	password => 'SCALAR'		
}

1;

__END__

=pod

=head1 NAME

C<IMPL::Security::Auth::Simple> Модуль простой авторизации.

=head1 DESCRIPTION

Использует алгоритм MD5 для хранения образа пароля.

=head1 MEMBERS

=over

=item C<DoAuth($challenge)>

Аутентифицирует пользователя. Используется один этап. C<$challenge>
открытый пароль пользователя.

Возвращает C<($status,$challenge)>

=over

=item C<$status>

Результат либо C<AUTH_SUCCESS>, либо C<AUTH_FAIL>

=item

=back

=back

=cut