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

docs
author wizard
date Thu, 25 Mar 2010 13:05:18 +0300
parents 739f1288ca84
children eac47fa4f262
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
51
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
1 package IMPL::Security::Auth::Simple;
71
wizard
parents: 68
diff changeset
2 use strict;
51
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
3
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
4 use base qw(IMPL::Security::Auth);
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
5 use Digest::MD5;
52
15d720913562 security in work
wizard@linux-odin.local
parents: 51
diff changeset
6
15d720913562 security in work
wizard@linux-odin.local
parents: 51
diff changeset
7 use IMPL::Class::Property;
15d720913562 security in work
wizard@linux-odin.local
parents: 51
diff changeset
8
15d720913562 security in work
wizard@linux-odin.local
parents: 51
diff changeset
9 BEGIN {
15d720913562 security in work
wizard@linux-odin.local
parents: 51
diff changeset
10 private property _passwordImage => prop_all;
15d720913562 security in work
wizard@linux-odin.local
parents: 51
diff changeset
11 private property _sessionCookie => prop_all;
15d720913562 security in work
wizard@linux-odin.local
parents: 51
diff changeset
12 }
15d720913562 security in work
wizard@linux-odin.local
parents: 51
diff changeset
13
15d720913562 security in work
wizard@linux-odin.local
parents: 51
diff changeset
14 sub CTOR {
15d720913562 security in work
wizard@linux-odin.local
parents: 51
diff changeset
15 my ($this,$secData) = @_;
15d720913562 security in work
wizard@linux-odin.local
parents: 51
diff changeset
16
15d720913562 security in work
wizard@linux-odin.local
parents: 51
diff changeset
17 $this->_passwordImage($secData);
15d720913562 security in work
wizard@linux-odin.local
parents: 51
diff changeset
18 }
51
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
19
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
20 sub DoAuth {
52
15d720913562 security in work
wizard@linux-odin.local
parents: 51
diff changeset
21 my ($this,$challenge) = @_;
51
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
22
52
15d720913562 security in work
wizard@linux-odin.local
parents: 51
diff changeset
23 if (Digest::MD5::md5_hex($challenge) eq $this->_passwordImage) {
68
739f1288ca84 Auth in progress
wizard
parents: 52
diff changeset
24 return (SUCCESS,$this->_sessionCookie($this->GenSSID));
51
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
25 } elsee {
52
15d720913562 security in work
wizard@linux-odin.local
parents: 51
diff changeset
26 return (FAIL,undef);
15d720913562 security in work
wizard@linux-odin.local
parents: 51
diff changeset
27 }
15d720913562 security in work
wizard@linux-odin.local
parents: 51
diff changeset
28 }
15d720913562 security in work
wizard@linux-odin.local
parents: 51
diff changeset
29
15d720913562 security in work
wizard@linux-odin.local
parents: 51
diff changeset
30 sub ValidateSession {
15d720913562 security in work
wizard@linux-odin.local
parents: 51
diff changeset
31 my ($this,$cookie) = @_;
15d720913562 security in work
wizard@linux-odin.local
parents: 51
diff changeset
32
15d720913562 security in work
wizard@linux-odin.local
parents: 51
diff changeset
33 if ($cookie eq $this->_sessionCookie) {
15d720913562 security in work
wizard@linux-odin.local
parents: 51
diff changeset
34 return (SUCCESS,undef);
15d720913562 security in work
wizard@linux-odin.local
parents: 51
diff changeset
35 } else {
15d720913562 security in work
wizard@linux-odin.local
parents: 51
diff changeset
36 return (FAIL,undef);
51
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
37 }
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
38 }
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
39
71
wizard
parents: 68
diff changeset
40 sub CreateSecData {
wizard
parents: 68
diff changeset
41 my ($self,%args) = @_;
wizard
parents: 68
diff changeset
42
wizard
parents: 68
diff changeset
43 die new IMPL::InvalidArgumentException("The parameter is required",'password') unless $args{password};
wizard
parents: 68
diff changeset
44
wizard
parents: 68
diff changeset
45 return md5_hex($args{password});
wizard
parents: 68
diff changeset
46 }
wizard
parents: 68
diff changeset
47
wizard
parents: 68
diff changeset
48 sub SecDataArgs {
wizard
parents: 68
diff changeset
49
wizard
parents: 68
diff changeset
50
wizard
parents: 68
diff changeset
51 }
wizard
parents: 68
diff changeset
52
51
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
53 1;
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
54
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
55 __END__
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
56
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
57 =pod
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
58
71
wizard
parents: 68
diff changeset
59 =head1 NAME
wizard
parents: 68
diff changeset
60
wizard
parents: 68
diff changeset
61 C<IMPL::Security::Auth::Simple> Модуль простой авторизации.
wizard
parents: 68
diff changeset
62
51
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
63 =head1 DESCRIPTION
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
64
71
wizard
parents: 68
diff changeset
65
wizard
parents: 68
diff changeset
66
51
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
67
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
68 =cut