comparison Lib/IMPL/Security/Auth/Simple.pm @ 52:15d720913562

security in work
author wizard@linux-odin.local
date Tue, 02 Mar 2010 20:12:02 +0300
parents a1498298d3ee
children 739f1288ca84
comparison
equal deleted inserted replaced
51:a1498298d3ee 52:15d720913562
1 package IMPL::Security::Auth::Simple; 1 package IMPL::Security::Auth::Simple;
2 2
3 use base qw(IMPL::Security::Auth); 3 use base qw(IMPL::Security::Auth);
4 use Digest::MD5; 4 use Digest::MD5;
5 import IMPL::Security::Auth qw(:Const); 5 import IMPL::Security::Auth qw(:Const GenSSID);
6
7 use IMPL::Class::Property;
8
9 BEGIN {
10 private property _passwordImage => prop_all;
11 private property _sessionCookie => prop_all;
12 }
13
14 sub CTOR {
15 my ($this,$secData) = @_;
16
17 $this->_passwordImage($secData);
18 }
6 19
7 sub DoAuth { 20 sub DoAuth {
8 my ($this,$clientData,$serverData) = @_; 21 my ($this,$challenge) = @_;
9 22
10 if (Digest::MD5::md5_hex($clientData) eq $serverData) { 23 if (Digest::MD5::md5_hex($challenge) eq $this->_passwordImage) {
11 return SUCCESS; 24 return (SUCCESS,$this->_sessionCookie(GenSSID));
12 } elsee { 25 } elsee {
13 return FAIL; 26 return (FAIL,undef);
27 }
28 }
29
30 sub ValidateSession {
31 my ($this,$cookie) = @_;
32
33 if ($cookie eq $this->_sessionCookie) {
34 return (SUCCESS,undef);
35 } else {
36 return (FAIL,undef);
14 } 37 }
15 } 38 }
16 39
17 1; 40 1;
18 41