51
+ − 1 package IMPL::Security::Role;
+ − 2
+ − 3 use base qw(IMPL::Object);
+ − 4
+ − 5 use IMPL::Class::Property;
+ − 6
+ − 7 BEGIN {
73
+ − 8 public property roleName => prop_get | owner_set;
+ − 9 public property parentRoles => prop_get | owner_set | prop_list;
51
+ − 10 }
+ − 11
+ − 12 sub CTOR {
+ − 13 my ($this,$name,$parentRoles) = @_;
+ − 14
+ − 15 $this->roleName($name);
+ − 16 $this->parentRoles($parentRoles);
+ − 17 }
+ − 18
+ − 19 sub Satisfy {
+ − 20 my ($this,@roles) = @_;
+ − 21
+ − 22 return 1 unless $this->_FilterRoles( @roles );
94
+ − 23 return 0;
51
+ − 24 }
+ − 25
+ − 26 sub _FilterRoles {
+ − 27 my ($this,@roles) = @_;
+ − 28
+ − 29 @roles = grep not (ref $_ ? $this == $_ : $this->roleName eq $_), @roles;
+ − 30
94
+ − 31 @roles = $_->_FilterRoles(@roles) or return foreach $this->parentRoles ;
51
+ − 32
+ − 33 return @roles;
+ − 34 }
+ − 35
+ − 36
+ − 37 1;
+ − 38
+ − 39 __END__
+ − 40
+ − 41 =pod
+ − 42
73
+ − 43 =head1 NAME
+ − 44
+ − 45 C<IMPL::Security::Role> ����
+ − 46
51
+ − 47 =head1 DESCRIPTION
+ − 48
73
+ − 49 ����� �������� � ���� ������� ����.
51
+ − 50 ������� ����� ��� �������� ������� ����������� ����� � ������� ����.
+ − 51
+ − 52 =head1 MEMBERS
+ − 53
+ − 54 =over
+ − 55
73
+ − 56 =item C<[get] roleName>
51
+ − 57
+ − 58 ��� ����, �� �������������
+ − 59
73
+ − 60 =item C<[get,list] parentRoles>
51
+ − 61
+ − 62 ������ ������������ �����
+ − 63
+ − 64 =item C<Satisfy(@roles_list)>
+ − 65
+ − 66 ��������� ������� ����� ��������� ����� �� ������ @roles_list.
+ − 67 ����������� ������������� ��� ����� ��������, ��� � ���� �����.
+ − 68 ���������� 0 � ������ �������, 1 ��� ������� ����������� �����
+ − 69
+ − 70 =back
+ − 71
+ − 72 =cut