Mercurial > pub > Impl
changeset 247:2270de2469ff
sync
author | sergey |
---|---|
date | Wed, 31 Oct 2012 04:18:35 +0400 |
parents | 2746a8e5a6c4 |
children | 814d755e5d12 |
files | Lib/IMPL/Security.pm |
diffstat | 1 files changed, 14 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/Lib/IMPL/Security.pm Tue Oct 30 01:17:31 2012 +0400 +++ b/Lib/IMPL/Security.pm Wed Oct 31 04:18:35 2012 +0400 @@ -5,22 +5,22 @@ ##VERSION## require IMPL::Exception; -require IMPL::Security::Principal; -require IMPL::Security::AbstractContext; require IMPL::Security::Rule::RoleCheck; -our @rules = ( - \&IMPL::Security::Rule::RoleCheck::SatisfyAll -); +use IMPL::require { + Principal => 'IMPL::Security::Principal', + AbstractContext => 'IMPL::Security::AbstractContext', + Context => 'IMPL::Security::Context' +}; -our $authority = undef; +our @RULES; sub AccessCheck { my ($self, $object, $desiredAccess, $context) = @_; - $context ||= IMPL::Security::AbstractContext->context; + $context ||= $self->context; - $_->() or return 0 foreach @{$self->Rules}; + $_->($self,$object,$desiredAccess,$context) or return 0 foreach @{$self->Rules}; return 1; } @@ -34,7 +34,7 @@ sub MakeContext { my ($this,$principal,$refRoles,$auth) = @_; - return new IMPL::Security::Context( + return Context->new( principal => $principal, rolesAssigned => $refRoles, auth => $auth @@ -42,22 +42,18 @@ } sub Rules { - return \@rules; -} - -sub authority { - return $authority; + return \@RULES; } sub principal { return - IMPL::Security::AbstractContext->current - && IMPL::Security::AbstractContext->current->principal - || IMPL::Security::Principal->nobody; + AbstractContext->current + && AbstractContext->current->principal + || Principal->nobody; } sub context { - IMPL::Security::AbstractContext->current; + AbstractContext->current; } 1;