comparison Lib/IMPL/Web/Handler/SecureCookie.pm @ 231:ff1e8fa932f2

sync
author sergey
date Tue, 09 Oct 2012 03:09:41 +0400
parents 6d8092d8ce1b
children 3cebcf6fdb9b
comparison
equal deleted inserted replaced
230:6d8092d8ce1b 231:ff1e8fa932f2
8 use IMPL::declare { 8 use IMPL::declare {
9 require => { 9 require => {
10 SecurityContext => 'IMPL::Security::Context', 10 SecurityContext => 'IMPL::Security::Context',
11 User => 'IMPL::Security::User', 11 User => 'IMPL::Security::User',
12 AuthSimple => 'IMPL::Security::Auth::Simple', 12 AuthSimple => 'IMPL::Security::Auth::Simple',
13 Exception => 'IMPL::Exception',
14 OperationException => '-IMPL::InvalidOperationException',
15 HttpResponse => '-IMPL::Web::HttpResponse'
13 }, 16 },
14 base => { 17 base => {
15 'IMPL::Object' => undef, 18 'IMPL::Object' => undef,
16 'IMPL::Object::Autofill' => '@_', 19 'IMPL::Object::Autofill' => '@_',
17 'IMPL::Object::Serializable' => undef 20 'IMPL::Object::Serializable' => undef
66 } 69 }
67 } 70 }
68 71
69 } 72 }
70 73
71 $context = SecurityContext->new(principal => User->nobody, authority => $this); 74 $context ||= SecurityContext->new(principal => User->nobody, authority => $this);
72 75
73 my $httpResponse = $context->Impersonate($nextHandler); 76 my $httpResponse = $context->Impersonate($nextHandler);
74 77
75 $this->WriteResponse($httpResponse); 78 die OperationException->new("A HttpResponse instance is expected")
79 unless ref $httpResponse && eval { $httpResponse->isa(HttpResponse) };
76 80
81 return $this->WriteResponse($httpResponse);
77 } 82 }
78 83
79 sub CreateContext { 84 sub InitSession {
80 my ($this,$user,$auth,$roles) = @_; 85 my ($this,$user,$auth,$roles) = @_;
81 86
82 my $sid = GenSSID(); 87 my $sid = GenSSID();
83 my $cookie = GenSSID(); 88 my $cookie = GenSSID();
84 89
88 }) 93 })
89 94
90 my $context = $this->$manager->CreateSession( 95 my $context = $this->$manager->CreateSession(
91 sessionId => $sid, 96 sessionId => $sid,
92 principal => $user, 97 principal => $user,
93 auth => AuthSimple->(password => $cookie), 98 auth => AuthSimple->new(password => $cookie),
94 authority => $this, 99 authority => $this,
95 assignedRoles => $roles 100 assignedRoles => $roles
96 ); 101 );
97 102
98 $context->Apply(); 103 $context->Apply();
114 119
115 $response->cookies->{sid} = $data->{sid}; 120 $response->cookies->{sid} = $data->{sid};
116 $response->cookies->{sdata} = $data->{sdata}; 121 $response->cookies->{sdata} = $data->{sdata};
117 $response->cookies->{sign} = $sign; 122 $response->cookies->{sign} = $sign;
118 } 123 }
124
125 return $response;
119 } 126 }
120 127
121 1; 128 1;
122 129
123 __END__ 130 __END__
139 146
140 147
141 148
142 =head1 MEMBERS 149 =head1 MEMBERS
143 150
144 =over 151 =head2 C<[get,set] salt>
145
146 =item C<[get,set] salt>
147 152
148 Скаляр, использующийся для подписи данных. 153 Скаляр, использующийся для подписи данных.
149 154
150 =back 155 =head2 C<InitSession($user,$auth,$roles)>
151 156
152 =cut 157 =cut