annotate Lib/Security/Auth/Simple.pm @ 31:d59526f6310e

Small fixes to Test framework (correct handlinf of the compilation errors in the test units) Imported and refactored SQL DB schema from the old project
author Sergey
date Mon, 09 Nov 2009 01:39:16 +0300
parents 03e58a454b20
children 16ada169ca75
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
1 package Security::Auth::Simple;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
2 use strict;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
3 use Common;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
4
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
5 our $Strict;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
6
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
7 our @ISA = qw(Object);
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
8
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
9 sub Name {
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
10 return 'Simple';
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
11 }
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
12
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
13 sub ConstructAuthData {
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
14 my ($class,$SecData) = @_;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
15 return new Security::Auth::Simple::AuthData(DataMD5 => $SecData);
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
16 }
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
17
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
18 sub NewAuthData {
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
19 my ($class,$SecData) = @_;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
20 return new Security::Auth::Simple::AuthData(Data => $SecData);
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
21
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
22 }
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
23
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
24 package Security::Auth::Simple::AuthData;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
25 use Common;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
26 use Security;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
27 use Security::Auth;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
28 use Digest::MD5 qw(md5_hex);
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
29 our @ISA = qw(Object);
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
30
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
31 BEGIN {
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
32 DeclareProperty Data => ACCESS_READ;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
33 DeclareProperty DataMD5 => ACCESS_READ;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
34 }
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
35
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
36 sub CTOR {
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
37 my ($this,%args) = @_;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
38
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
39 if ($args{'Data'}) {
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
40 $args{'DataMD5'}= $args{'Data'} ? md5_hex($args{'Data'}) : undef ;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
41 $this->{$Data} = $args{'Data'};
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
42 }
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
43 $this->{$DataMD5} = $args{'DataMD5'};
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
44 }
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
45
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
46 sub DoAuth {
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
47 my ($this,$SecData) = @_;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
48
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
49 if (not ($this->{$DataMD5} or $SecData) or $this->{$DataMD5} eq md5_hex($SecData)) {
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
50 if ($Strict) {
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
51 $this->{$Data} = Security::Auth::GenSSID;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
52 $this->{$DataMD5} = md5_hex($this->{$Data});
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
53 } else {
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
54 $this->{$Data} = $SecData;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
55 }
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
56 return Security::AUTH_SUCCESS;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
57 } else {
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
58 return Security::AUTH_FAILED;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
59 }
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
60 }
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
61
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
62 sub SessionAuthData {
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
63 my ($this) = @_;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
64
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
65 return $this->{$DataMD5};
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
66 }
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
67
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
68 sub ClientAuthData {
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
69 my ($this) = @_;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
70 return $this->{$Data};
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
71 }
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
72
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
73 1;