comparison Lib/Engine/Security.pm @ 0:03e58a454b20

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