diff 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
line wrap: on
line diff
--- a/Lib/IMPL/Security/Auth/Simple.pm	Mon Mar 01 17:25:36 2010 +0300
+++ b/Lib/IMPL/Security/Auth/Simple.pm	Tue Mar 02 20:12:02 2010 +0300
@@ -2,15 +2,38 @@
 
 use base qw(IMPL::Security::Auth);
 use Digest::MD5;
-import IMPL::Security::Auth qw(:Const);
+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,$clientData,$serverData) = @_;
+	my ($this,$challenge) = @_;
 
-	if (Digest::MD5::md5_hex($clientData) eq $serverData) {
-		return SUCCESS;
+	if (Digest::MD5::md5_hex($challenge) eq $this->_passwordImage) {
+		return (SUCCESS,$this->_sessionCookie(GenSSID));
 	} elsee {
-		return FAIL;
+		return (FAIL,undef);
+	}
+}
+
+sub ValidateSession {
+	my ($this,$cookie) = @_;
+	
+	if ($cookie eq $this->_sessionCookie) {
+		return (SUCCESS,undef);
+	} else {
+		return (FAIL,undef);
 	}
 }