Mercurial > pub > Impl
annotate Lib/IMPL/Security/Role.pm @ 144:b56ebc31bf18
Empty nodes no more created while transforming a post request to the DOM document
minor speed improvements to the object CTOR caching
Added support for a secure processing (and 'laundering' ) a CGI parameters
Many minor fixes
author | wizard |
---|---|
date | Tue, 13 Jul 2010 02:05:38 +0400 |
parents | 79bf75223afe |
children | 4267a2ac3d46 |
rev | line source |
---|---|
51 | 1 package IMPL::Security::Role; |
2 | |
3 use base qw(IMPL::Object); | |
4 | |
5 use IMPL::Class::Property; | |
6 | |
7 BEGIN { | |
73 | 8 public property roleName => prop_get | owner_set; |
9 public property parentRoles => prop_get | owner_set | prop_list; | |
51 | 10 } |
11 | |
12 sub CTOR { | |
13 my ($this,$name,$parentRoles) = @_; | |
14 | |
144
b56ebc31bf18
Empty nodes no more created while transforming a post request to the DOM document
wizard
parents:
94
diff
changeset
|
15 $this->roleName($name) if $name; |
b56ebc31bf18
Empty nodes no more created while transforming a post request to the DOM document
wizard
parents:
94
diff
changeset
|
16 $this->parentRoles($parentRoles) if $parentRoles; |
51 | 17 } |
18 | |
19 sub Satisfy { | |
20 my ($this,@roles) = @_; | |
21 | |
22 return 1 unless $this->_FilterRoles( @roles ); | |
94 | 23 return 0; |
51 | 24 } |
25 | |
26 sub _FilterRoles { | |
27 my ($this,@roles) = @_; | |
28 | |
29 @roles = grep not (ref $_ ? $this == $_ : $this->roleName eq $_), @roles; | |
30 | |
94 | 31 @roles = $_->_FilterRoles(@roles) or return foreach $this->parentRoles ; |
51 | 32 |
33 return @roles; | |
34 } | |
35 | |
36 | |
37 1; | |
38 | |
39 __END__ | |
40 | |
41 =pod | |
42 | |
73 | 43 =head1 NAME |
44 | |
45 C<IMPL::Security::Role> Роль | |
46 | |
51 | 47 =head1 DESCRIPTION |
48 | |
73 | 49 Может включать в себя базовые роли. |
51 | 50 Имеется метод для проверки наличия необходимых ролей в текущей роли. |
51 | |
52 =head1 MEMBERS | |
53 | |
54 =over | |
55 | |
73 | 56 =item C<[get] roleName> |
51 | 57 |
58 Имя роли, ее идентификатор | |
59 | |
73 | 60 =item C<[get,list] parentRoles> |
51 | 61 |
62 Список родительских ролей | |
63 | |
64 =item C<Satisfy(@roles_list)> | |
65 | |
66 Проверяет наличие ролей указанных ролей из списка @roles_list. | |
67 Допускается использование как самих объектов, так и имен ролей. | |
68 Возвращает 0 в случае неудачи, 1 при наличии необходимых ролей | |
69 | |
70 =back | |
71 | |
72 =cut |