annotate Lib/IMPL/Security/Role.pm @ 206:c8fe3f84feba

+IMPL::Web::Handlers::ViewSelector +IMPL::Web::Handlers::ErrorHandler *IMPL::Web::Handlers::RestController moved types mappings to ViewSelector
author sergey
date Thu, 03 May 2012 16:48:39 +0400
parents 4d0e1962161c
children 6d8092d8ce1b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
51
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
1 package IMPL::Security::Role;
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
2
166
4267a2ac3d46 Added Class::Template,
wizard
parents: 144
diff changeset
3 use parent qw(IMPL::Object);
51
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
4
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
5 use IMPL::Class::Property;
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
6
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
7 BEGIN {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
8 public property roleName => prop_get | owner_set;
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
9 public property parentRoles => prop_get | owner_set | prop_list;
51
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
10 }
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
11
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
12 sub CTOR {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
13 my ($this,$name,$parentRoles) = @_;
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
14
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
15 $this->roleName($name) if $name;
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
16 $this->parentRoles($parentRoles) if $parentRoles;
51
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
17 }
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
18
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
19 sub Satisfy {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
20 my ($this,@roles) = @_;
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
21
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
22 return 1 unless $this->_FilterRoles( @roles );
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
23 return 0;
51
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
24 }
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
25
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
26 sub _FilterRoles {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
27 my ($this,@roles) = @_;
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
28
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
29 @roles = grep not (ref $_ ? $this == $_ : $this->roleName eq $_), @roles;
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
30
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
31 @roles = $_->_FilterRoles(@roles) or return foreach $this->parentRoles ;
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
32
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
33 return @roles;
51
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
34 }
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
35
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
36
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
37 1;
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
38
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
39 __END__
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
40
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
41 =pod
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
42
73
wizard
parents: 51
diff changeset
43 =head1 NAME
wizard
parents: 51
diff changeset
44
180
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 172
diff changeset
45 C<IMPL::Security::Role> Роль
73
wizard
parents: 51
diff changeset
46
51
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
47 =head1 DESCRIPTION
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
48
180
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 172
diff changeset
49 Может включать в себя базовые роли.
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 172
diff changeset
50 Имеется метод для проверки наличия необходимых ролей в текущей роли.
51
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
51
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
52 =head1 MEMBERS
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
53
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
54 =over
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
55
73
wizard
parents: 51
diff changeset
56 =item C<[get] roleName>
51
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
57
180
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 172
diff changeset
58 Имя роли, ее идентификатор
51
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
59
73
wizard
parents: 51
diff changeset
60 =item C<[get,list] parentRoles>
51
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
61
180
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 172
diff changeset
62 Список родительских ролей
51
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
63
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
64 =item C<Satisfy(@roles_list)>
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
65
180
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 172
diff changeset
66 Проверяет наличие ролей указанных ролей из списка @roles_list.
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 172
diff changeset
67 Допускается использование как самих объектов, так и имен ролей.
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 172
diff changeset
68 Возвращает 0 в случае неудачи (хотябы одна роль не была удовлетворена), 1 при наличии необходимых ролей.
51
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
69
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
70 =back
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
71
180
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 172
diff changeset
72 =cut