annotate Lib/Engine/Security.pm @ 32:56cef8e3cda6

+1
author Sergey
date Mon, 09 Nov 2009 01:39:31 +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 use strict;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
2 package Engine::Security;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
3 use Security::Auth;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
4 use Security;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
5 use Engine::Security::Auth;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
6
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
7 our @AuthMethods;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
8 my $AuthResult;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
9 my $AuthMod;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
10 my $AuthMethod;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
11
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
12 # use last auth method as default
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
13 $AuthMethod = Engine::Security::Auth->new(%{$AuthMethods[$#AuthMethods]}) if @AuthMethods;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
14
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
15 sub AuthenticateContext {
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
16 Security->CurrentSession(undef); #prevent previous session from closing
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
17 foreach my $method (@AuthMethods) {
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
18 my $AuthObj = Engine::Security::Auth->new(%$method);
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
19 $AuthResult = $AuthObj->DoAuth();
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
20 # îáíîâèòü òåêóùèé êîíòåêñò áåçîïàñíîñòè, òîëüêî åñëè ýòî íåîáõîäèìî
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
21 $AuthObj->SetAuthResult($AuthResult) if $AuthResult->State == Security::AUTH_FAILED or $AuthResult->State == Security::AUTH_SUCCESS;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
22 $AuthMethod = $AuthObj and last if $AuthResult->State != Security::AUTH_FAILED and $AuthResult->State != Security::AUTH_NOAUTH;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
23 }
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
24 $AuthMod = $AuthMethod->AuthMod if $AuthMethod;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
25 }
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
26
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
27 sub SetAuthResult {
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
28 shift;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
29 $AuthMethod->SetAuthResult(@_) if $AuthMethod;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
30 }
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
31
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
32 sub AuthMod {
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
33 return $AuthMethod ? $AuthMethod->AuthMod : undef;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
34 }
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
35
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
36 1;