# HG changeset patch # User sergey # Date 1351642715 -14400 # Node ID 2270de2469ffc8f462cb9ca852e8d89d9f28a987 # Parent 2746a8e5a6c4376176e8bd31756ba87a063d0262 sync diff -r 2746a8e5a6c4 -r 2270de2469ff Lib/IMPL/Security.pm --- 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;