annotate Lib/IMPL/Security/Context.pm @ 236:2904da230022

DOM refactoring
author sergey
date Mon, 15 Oct 2012 04:23:01 +0400
parents 6d8092d8ce1b
children b8c724f6de36
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 47
diff changeset
1 package IMPL::Security::Context;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 47
diff changeset
2 use strict;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 47
diff changeset
3 use warnings;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 47
diff changeset
4
230
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
5 use IMPL::require {
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
6 Principal => 'IMPL::Security::Principal',
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
7 Role => 'IMPL::Security::Role',
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
8 AbstractContext => 'IMPL::Security::AbstractContext',
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
9 Exception => 'IMPL::Exception',
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
10 ArgumentException => '-IMPL::InvalidArgumentException'
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
11
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
12 };
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 47
diff changeset
13
230
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
14 use IMPL::declare {
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
15 base => [
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
16 'IMPL::Object' => undef,
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
17 'IMPL::Object::Autofill' => undef,
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
18 'IMPL::Security::AbstractContext' => undef,
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
19 ],
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
20 props => [
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
21 @{AbstractContext->abstractProps()}
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
22 ]
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
23 };
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 47
diff changeset
24
230
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
25 __PACKAGE__->abstractProps([]);
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
26
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
27
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
28 my $nobody;
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 47
diff changeset
29
74
wizard
parents: 68
diff changeset
30 sub CTOR {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
31 my ($this) = @_;
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
32
230
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
33 die ArgumentException->new("The parameter is required", 'principal') unless $this->principal;
81
077357224bec IMPL::Web::Security alpha version
Sergey
parents: 74
diff changeset
34 }
077357224bec IMPL::Web::Security alpha version
Sergey
parents: 74
diff changeset
35
74
wizard
parents: 68
diff changeset
36 sub nobody {
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 47
diff changeset
37 my ($self) = @_;
230
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
38 $nobody = $self->new(principal => Principal->nobody) unless $nobody;
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 47
diff changeset
39 $nobody;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 47
diff changeset
40 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 47
diff changeset
41
230
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
42 sub isTrusted {
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
43 return 1;
94
79bf75223afe Fixed security related bugs
wizard
parents: 81
diff changeset
44 }
79bf75223afe Fixed security related bugs
wizard
parents: 81
diff changeset
45
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 47
diff changeset
46 1;
74
wizard
parents: 68
diff changeset
47
wizard
parents: 68
diff changeset
48 __END__
wizard
parents: 68
diff changeset
49
wizard
parents: 68
diff changeset
50 =pod
wizard
parents: 68
diff changeset
51
wizard
parents: 68
diff changeset
52 =head1 NAME
wizard
parents: 68
diff changeset
53
230
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
54 C<IMPL::Security::Context> - реализация контекста безопасности создаваемого в
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
55 приложении.
74
wizard
parents: 68
diff changeset
56
230
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
57 =head1 SYNOPSIS
74
wizard
parents: 68
diff changeset
58
wizard
parents: 68
diff changeset
59 =begin code
wizard
parents: 68
diff changeset
60
wizard
parents: 68
diff changeset
61 my $context = IMPL::Security::Context->nobody;
wizard
parents: 68
diff changeset
62
wizard
parents: 68
diff changeset
63 my $result = $context->Impersonate(
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
64 sub {
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
65 # do some untrusted code
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
66 }
74
wizard
parents: 68
diff changeset
67 );
wizard
parents: 68
diff changeset
68
230
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
69 $context = IMPL::Security::Context->new(
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
70 principal => $user,
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
71 assignedRoles => [
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
72 $backupRole,
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
73 $controlRole
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
74 ]
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
75 );
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
76
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
77 $context->Impersonate(
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
78 sub {
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
79
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
80 # do some authorized operations
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
81
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
82 $service->backupData('current.bak');
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
83 $service->stop();
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
84 }
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
85 );
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
86
74
wizard
parents: 68
diff changeset
87 =end code
wizard
parents: 68
diff changeset
88
wizard
parents: 68
diff changeset
89 =head1 DESCRIPTION
wizard
parents: 68
diff changeset
90
230
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
91 C<autofill>
74
wizard
parents: 68
diff changeset
92
230
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
93 Данная реализация контекста безопасности не привязана ни к источнику данных
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
94 ни к пакету аутентификации и авторизации, ее приложение может создать в любой
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
95 момент, при этом система сама несет ответственность за последствия.
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
96
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
97 Данный контекст нужен для выполнения системой служебных функций.
74
wizard
parents: 68
diff changeset
98
wizard
parents: 68
diff changeset
99 =head1 MEMBERS
wizard
parents: 68
diff changeset
100
230
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
101 см. также C<IMPL::Security::AbstractContext>.
74
wizard
parents: 68
diff changeset
102
230
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
103 =head2 C<CTOR(%props)>
74
wizard
parents: 68
diff changeset
104
230
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
105 Создает объект и заполняет его свойствами. C<principal> должен быть обязательно
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
106 указан.
74
wizard
parents: 68
diff changeset
107
230
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
108 =head2 C<[static,get] nobody>
74
wizard
parents: 68
diff changeset
109
180
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 173
diff changeset
110 Контекст для неаутентифицированных пользователей, минимум прав.
74
wizard
parents: 68
diff changeset
111
180
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 173
diff changeset
112 =cut