51
|
1 package IMPL::Security::Auth::Simple;
|
71
|
2 use strict;
|
51
|
3
|
|
4 use base qw(IMPL::Security::Auth);
|
|
5 use Digest::MD5;
|
52
|
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 }
|
51
|
19
|
|
20 sub DoAuth {
|
52
|
21 my ($this,$challenge) = @_;
|
51
|
22
|
52
|
23 if (Digest::MD5::md5_hex($challenge) eq $this->_passwordImage) {
|
68
|
24 return (SUCCESS,$this->_sessionCookie($this->GenSSID));
|
51
|
25 } elsee {
|
52
|
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);
|
51
|
37 }
|
|
38 }
|
|
39
|
71
|
40 sub CreateSecData {
|
|
41 my ($self,%args) = @_;
|
|
42
|
|
43 die new IMPL::InvalidArgumentException("The parameter is required",'password') unless $args{password};
|
|
44
|
|
45 return md5_hex($args{password});
|
|
46 }
|
|
47
|
|
48 sub SecDataArgs {
|
|
49
|
|
50
|
|
51 }
|
|
52
|
51
|
53 1;
|
|
54
|
|
55 __END__
|
|
56
|
|
57 =pod
|
|
58
|
71
|
59 =head1 NAME
|
|
60
|
|
61 C<IMPL::Security::Auth::Simple> Модуль простой авторизации.
|
|
62
|
51
|
63 =head1 DESCRIPTION
|
|
64
|
71
|
65
|
|
66
|
51
|
67
|
|
68 =cut |