annotate Lib/IMPL/Security/Role.pm @ 140:fb896377389f

to_json and escape_string functions for the templates minor changes
author wizard
date Mon, 05 Jul 2010 02:22:42 +0400
parents 79bf75223afe
children b56ebc31bf18
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 );
94
79bf75223afe Fixed security related bugs
wizard
parents: 73
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 {
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
27 my ($this,@roles) = @_;
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
28
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
29 @roles = grep not (ref $_ ? $this == $_ : $this->roleName eq $_), @roles;
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
30
94
79bf75223afe Fixed security related bugs
wizard
parents: 73
diff changeset
31 @roles = $_->_FilterRoles(@roles) or return foreach $this->parentRoles ;
51
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
32
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
33 return @roles;
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
wizard
parents: 51
diff changeset
45 C<IMPL::Security::Role> Роль
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
73
wizard
parents: 51
diff changeset
49 Может включать в себя базовые роли.
51
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
50 Имеется метод для проверки наличия необходимых ролей в текущей роли.
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
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
58 Имя роли, ее идентификатор
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
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
62 Список родительских ролей
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
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
66 Проверяет наличие ролей указанных ролей из списка @roles_list.
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
67 Допускается использование как самих объектов, так и имен ролей.
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
68 Возвращает 0 в случае неудачи, 1 при наличии необходимых ролей
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
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
72 =cut