# HG changeset patch # User sergey # Date 1349737781 -14400 # Node ID ff1e8fa932f272d21208b5bf7359f0f88dc136d2 # Parent 6d8092d8ce1b1a0331cc2414f7aa8657f891a7c1 sync diff -r 6d8092d8ce1b -r ff1e8fa932f2 Lib/IMPL/Web/Handler/SecureCookie.pm --- a/Lib/IMPL/Web/Handler/SecureCookie.pm Mon Oct 08 03:37:37 2012 +0400 +++ b/Lib/IMPL/Web/Handler/SecureCookie.pm Tue Oct 09 03:09:41 2012 +0400 @@ -10,6 +10,9 @@ SecurityContext => 'IMPL::Security::Context', User => 'IMPL::Security::User', AuthSimple => 'IMPL::Security::Auth::Simple', + Exception => 'IMPL::Exception', + OperationException => '-IMPL::InvalidOperationException', + HttpResponse => '-IMPL::Web::HttpResponse' }, base => { 'IMPL::Object' => undef, @@ -68,15 +71,17 @@ } - $context = SecurityContext->new(principal => User->nobody, authority => $this); + $context ||= SecurityContext->new(principal => User->nobody, authority => $this); my $httpResponse = $context->Impersonate($nextHandler); - $this->WriteResponse($httpResponse); + die OperationException->new("A HttpResponse instance is expected") + unless ref $httpResponse && eval { $httpResponse->isa(HttpResponse) }; + return $this->WriteResponse($httpResponse); } -sub CreateContext { +sub InitSession { my ($this,$user,$auth,$roles) = @_; my $sid = GenSSID(); @@ -90,7 +95,7 @@ my $context = $this->$manager->CreateSession( sessionId => $sid, principal => $user, - auth => AuthSimple->(password => $cookie), + auth => AuthSimple->new(password => $cookie), authority => $this, assignedRoles => $roles ); @@ -116,6 +121,8 @@ $response->cookies->{sdata} = $data->{sdata}; $response->cookies->{sign} = $sign; } + + return $response; } 1; @@ -141,12 +148,10 @@ =head1 MEMBERS -=over - -=item C<[get,set] salt> +=head2 C<[get,set] salt> Скаляр, использующийся для подписи данных. -=back +=head2 C =cut diff -r 6d8092d8ce1b -r ff1e8fa932f2 Lib/IMPL/Web/Security.pm --- a/Lib/IMPL/Web/Security.pm Mon Oct 08 03:37:37 2012 +0400 +++ b/Lib/IMPL/Web/Security.pm Tue Oct 09 03:09:41 2012 +0400 @@ -29,12 +29,11 @@ my ($status,$answer) = $auth->DoAuth($challenge); if ($status != AUTH_FAIL) { - SecurityContext->current->authority->CreateContext( + SecurityContext->current->authority->InitSession( $user, $auth, [$user->roles], - $answer, - $this + $answer ); }