annotate Lib/IMPL/Security/Role.pm @ 63:76b878ad6596

Added serialization support for the IMPL::Object::List More intelligent Exception message Fixed encoding support in the actions Improoved tests Minor fixes
author wizard
date Mon, 15 Mar 2010 02:38:09 +0300
parents a1498298d3ee
children 2f31ecabe9ea
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 {
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
8 public property roleName => prop_get;
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
9 public property parentRoles => prop_get;
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
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
42 =head1 DESCRIPTION
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
43
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
44 Роль. Может включать в себя базовые роли.
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
45 Имеется метод для проверки наличия необходимых ролей в текущей роли.
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
46
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
47 =head1 MEMBERS
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
48
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
49 =over
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
50
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
51 =item C<roleName>
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
52
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
53 Имя роли, ее идентификатор
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
54
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
55 =item C<parentRoles>
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
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
59 =item C<Satisfy(@roles_list)>
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
60
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
61 Проверяет наличие ролей указанных ролей из списка @roles_list.
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
62 Допускается использование как самих объектов, так и имен ролей.
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
63 Возвращает 0 в случае неудачи, 1 при наличии необходимых ролей
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
64
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
65 =back
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
66
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
67 =cut