view Lib/IMPL/Security/Auth/Simple.pm @ 71:d92d5ddaf524

docs
author wizard
date Thu, 25 Mar 2010 13:05:18 +0300
parents 739f1288ca84
children eac47fa4f262
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 (SUCCESS,$this->_sessionCookie($this->GenSSID));
	} elsee {
		return (FAIL,undef);
	}
}

sub ValidateSession {
	my ($this,$cookie) = @_;
	
	if ($cookie eq $this->_sessionCookie) {
		return (SUCCESS,undef);
	} else {
		return (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 {
	
		
}

1;

__END__

=pod

=head1 NAME

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

=head1 DESCRIPTION




=cut