Mercurial > pub > Impl
diff Lib/Security/Authz.pm @ 49:16ada169ca75
migrating to the Eclipse IDE
author | wizard@linux-odin.local |
---|---|
date | Fri, 26 Feb 2010 10:49:21 +0300 |
parents | 03e58a454b20 |
children |
line wrap: on
line diff
--- a/Lib/Security/Authz.pm Fri Feb 26 01:43:42 2010 +0300 +++ b/Lib/Security/Authz.pm Fri Feb 26 10:49:21 2010 +0300 @@ -1,33 +1,33 @@ -package Security::Authz; -use Common; -use Security; - -our @ISA = qw(Object); - -BEGIN { - DeclareProperty User => ACCESS_READ; -} - -sub _CurrentUser { - my ($class) = @_; - - if (ref $class) { - return $class->{$User}; - } else { - if (Security->CurrentSession) { - Security->CurrentSession->User; - } else { - return undef; - } - } -} - -sub demand { - my ($class,@Roles) = @_; - - return 0 if not $class->_CurrentUser; - - my %UserRoles = map { $_->Name, 1 } $class->_CurrentUser->Roles; - - return not grep {not $UserRoles{$_}} @Roles; -} \ No newline at end of file +package Security::Authz; +use Common; +use Security; + +our @ISA = qw(Object); + +BEGIN { + DeclareProperty User => ACCESS_READ; +} + +sub _CurrentUser { + my ($class) = @_; + + if (ref $class) { + return $class->{$User}; + } else { + if (Security->CurrentSession) { + Security->CurrentSession->User; + } else { + return undef; + } + } +} + +sub demand { + my ($class,@Roles) = @_; + + return 0 if not $class->_CurrentUser; + + my %UserRoles = map { $_->Name, 1 } $class->_CurrentUser->Roles; + + return not grep {not $UserRoles{$_}} @Roles; +}