Mercurial > pub > Impl
diff Lib/IMPL/Security/Context.pm @ 49:16ada169ca75
migrating to the Eclipse IDE
author | wizard@linux-odin.local |
---|---|
date | Fri, 26 Feb 2010 10:49:21 +0300 |
parents | a9b70d836b28 |
children | a1498298d3ee |
line wrap: on
line diff
--- a/Lib/IMPL/Security/Context.pm Fri Feb 26 01:43:42 2010 +0300 +++ b/Lib/IMPL/Security/Context.pm Fri Feb 26 10:49:21 2010 +0300 @@ -1,42 +1,42 @@ -package IMPL::Security::Context; -use strict; -use warnings; - -use base qw(IMPL::Object); - -use IMPL::Class::Property; - -require IMPL::Security::Principal; - -my $current = __PACKAGE__->nobody; -my $nobody; - -BEGIN { - public property Principal => prop_get; - public property AssignedRoles => prop_all; -} - -sub Impersonate { - my ($this,$code) = @_; - - my $old = $current; - my $result; - local $@; - eval { - $result = $code->(); - }; - $current = $old; - if($@) { - die $@; - } else { - return $result; - } -} - -sub nobody { - my ($self) = @_; - $nobody = $self->new(Principal => IMPL::Security::Principal->nobody, AssignedRoles => undef) unless $nobody; - $nobody; -} - -1; +package IMPL::Security::Context; +use strict; +use warnings; + +use base qw(IMPL::Object); + +use IMPL::Class::Property; + +require IMPL::Security::Principal; + +my $current = __PACKAGE__->nobody; +my $nobody; + +BEGIN { + public property Principal => prop_get; + public property AssignedRoles => prop_all; +} + +sub Impersonate { + my ($this,$code) = @_; + + my $old = $current; + my $result; + local $@; + eval { + $result = $code->(); + }; + $current = $old; + if($@) { + die $@; + } else { + return $result; + } +} + +sub nobody { + my ($self) = @_; + $nobody = $self->new(Principal => IMPL::Security::Principal->nobody, AssignedRoles => undef) unless $nobody; + $nobody; +} + +1;