annotate Lib/IMPL/Security/AbstractRole.pm @ 274:8d36073411b1

+Added AutoDispose class *code cleanups
author cin
date Wed, 30 Jan 2013 03:30:28 +0400
parents 6d8092d8ce1b
children 69a1f1508696
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
230
6d8092d8ce1b *reworked IMPL::Security
sergey
parents:
diff changeset
1 package IMPL::Security::AbstractRole;
6d8092d8ce1b *reworked IMPL::Security
sergey
parents:
diff changeset
2 use strict;
6d8092d8ce1b *reworked IMPL::Security
sergey
parents:
diff changeset
3
6d8092d8ce1b *reworked IMPL::Security
sergey
parents:
diff changeset
4 use IMPL::Const qw(:prop);
6d8092d8ce1b *reworked IMPL::Security
sergey
parents:
diff changeset
5
6d8092d8ce1b *reworked IMPL::Security
sergey
parents:
diff changeset
6 use parent qw(IMPL::Class::Meta);
6d8092d8ce1b *reworked IMPL::Security
sergey
parents:
diff changeset
7
6d8092d8ce1b *reworked IMPL::Security
sergey
parents:
diff changeset
8 __PACKAGE__->static_accessor_clone( abstractProps => [
6d8092d8ce1b *reworked IMPL::Security
sergey
parents:
diff changeset
9 roleName => PROP_RW,
6d8092d8ce1b *reworked IMPL::Security
sergey
parents:
diff changeset
10 parentRoles => PROP_RW | PROP_LIST
6d8092d8ce1b *reworked IMPL::Security
sergey
parents:
diff changeset
11 ]);
6d8092d8ce1b *reworked IMPL::Security
sergey
parents:
diff changeset
12
6d8092d8ce1b *reworked IMPL::Security
sergey
parents:
diff changeset
13 sub Satisfy {
6d8092d8ce1b *reworked IMPL::Security
sergey
parents:
diff changeset
14 my ($this,@roles) = @_;
6d8092d8ce1b *reworked IMPL::Security
sergey
parents:
diff changeset
15
6d8092d8ce1b *reworked IMPL::Security
sergey
parents:
diff changeset
16 return 1 unless $this->_FilterRoles( @roles );
6d8092d8ce1b *reworked IMPL::Security
sergey
parents:
diff changeset
17 return 0;
6d8092d8ce1b *reworked IMPL::Security
sergey
parents:
diff changeset
18 }
6d8092d8ce1b *reworked IMPL::Security
sergey
parents:
diff changeset
19
6d8092d8ce1b *reworked IMPL::Security
sergey
parents:
diff changeset
20 sub _FilterRoles {
6d8092d8ce1b *reworked IMPL::Security
sergey
parents:
diff changeset
21 my ($this,@roles) = @_;
6d8092d8ce1b *reworked IMPL::Security
sergey
parents:
diff changeset
22
6d8092d8ce1b *reworked IMPL::Security
sergey
parents:
diff changeset
23 @roles = grep not (ref $_ ? $this->roleName eq $_->roleName : $this->roleName eq $_), @roles;
6d8092d8ce1b *reworked IMPL::Security
sergey
parents:
diff changeset
24
6d8092d8ce1b *reworked IMPL::Security
sergey
parents:
diff changeset
25 @roles = $_->_FilterRoles(@roles) or return foreach $this->parentRoles ;
6d8092d8ce1b *reworked IMPL::Security
sergey
parents:
diff changeset
26
6d8092d8ce1b *reworked IMPL::Security
sergey
parents:
diff changeset
27 return @roles;
6d8092d8ce1b *reworked IMPL::Security
sergey
parents:
diff changeset
28 }
6d8092d8ce1b *reworked IMPL::Security
sergey
parents:
diff changeset
29
6d8092d8ce1b *reworked IMPL::Security
sergey
parents:
diff changeset
30 1;
6d8092d8ce1b *reworked IMPL::Security
sergey
parents:
diff changeset
31
6d8092d8ce1b *reworked IMPL::Security
sergey
parents:
diff changeset
32 __END__
6d8092d8ce1b *reworked IMPL::Security
sergey
parents:
diff changeset
33
6d8092d8ce1b *reworked IMPL::Security
sergey
parents:
diff changeset
34 =pod
6d8092d8ce1b *reworked IMPL::Security
sergey
parents:
diff changeset
35
6d8092d8ce1b *reworked IMPL::Security
sergey
parents:
diff changeset
36 =head1 NAME
6d8092d8ce1b *reworked IMPL::Security
sergey
parents:
diff changeset
37
6d8092d8ce1b *reworked IMPL::Security
sergey
parents:
diff changeset
38 C<IMPL::Security::Role> Роль
6d8092d8ce1b *reworked IMPL::Security
sergey
parents:
diff changeset
39
6d8092d8ce1b *reworked IMPL::Security
sergey
parents:
diff changeset
40 =head1 DESCRIPTION
6d8092d8ce1b *reworked IMPL::Security
sergey
parents:
diff changeset
41
6d8092d8ce1b *reworked IMPL::Security
sergey
parents:
diff changeset
42 Может включать в себя базовые роли.
6d8092d8ce1b *reworked IMPL::Security
sergey
parents:
diff changeset
43 Имеется метод для проверки наличия необходимых ролей в текущей роли.
6d8092d8ce1b *reworked IMPL::Security
sergey
parents:
diff changeset
44
6d8092d8ce1b *reworked IMPL::Security
sergey
parents:
diff changeset
45 =head1 MEMBERS
6d8092d8ce1b *reworked IMPL::Security
sergey
parents:
diff changeset
46
6d8092d8ce1b *reworked IMPL::Security
sergey
parents:
diff changeset
47 =over
6d8092d8ce1b *reworked IMPL::Security
sergey
parents:
diff changeset
48
6d8092d8ce1b *reworked IMPL::Security
sergey
parents:
diff changeset
49 =item C<[get] roleName>
6d8092d8ce1b *reworked IMPL::Security
sergey
parents:
diff changeset
50
6d8092d8ce1b *reworked IMPL::Security
sergey
parents:
diff changeset
51 Имя роли, ее идентификатор
6d8092d8ce1b *reworked IMPL::Security
sergey
parents:
diff changeset
52
6d8092d8ce1b *reworked IMPL::Security
sergey
parents:
diff changeset
53 =item C<[get,list] parentRoles>
6d8092d8ce1b *reworked IMPL::Security
sergey
parents:
diff changeset
54
6d8092d8ce1b *reworked IMPL::Security
sergey
parents:
diff changeset
55 Список родительских ролей
6d8092d8ce1b *reworked IMPL::Security
sergey
parents:
diff changeset
56
6d8092d8ce1b *reworked IMPL::Security
sergey
parents:
diff changeset
57 =item C<Satisfy(@roles_list)>
6d8092d8ce1b *reworked IMPL::Security
sergey
parents:
diff changeset
58
6d8092d8ce1b *reworked IMPL::Security
sergey
parents:
diff changeset
59 Проверяет наличие ролей указанных ролей из списка @roles_list.
6d8092d8ce1b *reworked IMPL::Security
sergey
parents:
diff changeset
60 Допускается использование как самих объектов, так и имен ролей.
6d8092d8ce1b *reworked IMPL::Security
sergey
parents:
diff changeset
61 Возвращает 0 в случае неудачи (хотябы одна роль не была удовлетворена), 1 при наличии необходимых ролей.
6d8092d8ce1b *reworked IMPL::Security
sergey
parents:
diff changeset
62
6d8092d8ce1b *reworked IMPL::Security
sergey
parents:
diff changeset
63 =back
6d8092d8ce1b *reworked IMPL::Security
sergey
parents:
diff changeset
64
6d8092d8ce1b *reworked IMPL::Security
sergey
parents:
diff changeset
65 =cut