view Lib/IMPL/Security/Auth/Simple.pm @ 59:0f3e369553bd

Rewritten property implementation (probably become slower but more flexible) Configuration infrastructure in progress (in the aspect of the lazy activation) Initial concept for the code generator
author wizard
date Tue, 09 Mar 2010 02:50:45 +0300
parents 15d720913562
children 739f1288ca84
line wrap: on
line source

package IMPL::Security::Auth::Simple;

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

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 (SUCCESS,$this->_sessionCookie(GenSSID));
	} elsee {
		return (FAIL,undef);
	}
}

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

1;

__END__

=pod

=head1 DESCRIPTION

Модуль простой авторизации

=cut