annotate Lib/IMPL/Security/Role.pm @ 85:190c794a41ae

DateTime renamed because of collision
author wizard
date Fri, 16 Apr 2010 16:33:11 +0400
parents 2f31ecabe9ea
children 79bf75223afe
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
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
3 use base qw(IMPL::Object);
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 {
73
wizard
parents: 51
diff changeset
8 public property roleName => prop_get | owner_set;
wizard
parents: 51
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 {
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
13 my ($this,$name,$parentRoles) = @_;
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
14
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
15 $this->roleName($name);
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
16 $this->parentRoles($parentRoles);
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 {
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
20 my ($this,@roles) = @_;
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
21
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
22 return 1 unless $this->_FilterRoles( @roles );
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
23 }
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
24
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
25 sub _FilterRoles {
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
26 my ($this,@roles) = @_;
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
27
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
28 @roles = grep not (ref $_ ? $this == $_ : $this->roleName eq $_), @roles;
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
29
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
30 @roles = $_->_FilterRoles(@roles) or return foreach @{$this->parentRoles} ;
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
31
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
32 return @roles;
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
33 }
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 1;
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
37
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
38 __END__
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
39
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
40 =pod
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
41
73
wizard
parents: 51
diff changeset
42 =head1 NAME
wizard
parents: 51
diff changeset
43
wizard
parents: 51
diff changeset
44 C<IMPL::Security::Role> Роль
wizard
parents: 51
diff changeset
45
51
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
46 =head1 DESCRIPTION
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
47
73
wizard
parents: 51
diff changeset
48 Может включать в себя базовые роли.
51
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
49 Имеется метод для проверки наличия необходимых ролей в текущей роли.
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
50
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
51 =head1 MEMBERS
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
52
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
53 =over
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
54
73
wizard
parents: 51
diff changeset
55 =item C<[get] roleName>
51
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
56
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
57 Имя роли, ее идентификатор
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
58
73
wizard
parents: 51
diff changeset
59 =item C<[get,list] parentRoles>
51
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
60
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
61 Список родительских ролей
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
62
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
63 =item C<Satisfy(@roles_list)>
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
64
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
65 Проверяет наличие ролей указанных ролей из списка @roles_list.
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
66 Допускается использование как самих объектов, так и имен ролей.
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
67 Возвращает 0 в случае неудачи, 1 при наличии необходимых ролей
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
68
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
69 =back
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
70
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
71 =cut