diff Lib/IMPL/Web/Security.pm @ 194:4d0e1962161c

Replaced tabs with spaces IMPL::Web::View - fixed document model, new features (control classes, document constructor parameters)
author cin
date Tue, 10 Apr 2012 20:08:29 +0400
parents d1676be8afcc
children 6d8092d8ce1b
line wrap: on
line diff
--- a/Lib/IMPL/Web/Security.pm	Tue Apr 10 08:13:22 2012 +0400
+++ b/Lib/IMPL/Web/Security.pm	Tue Apr 10 20:08:29 2012 +0400
@@ -10,48 +10,48 @@
 __PACKAGE__->PassThroughArgs;
 
 BEGIN {
-	public property sourceUser => prop_all;
-	public property sourceSession => prop_all;
+    public property sourceUser => prop_all;
+    public property sourceSession => prop_all;
 }
 
 sub CTOR {
-	my ($this) = @_;
-	
-	die new IMPL::InvalidArgumentException("An argument is required",'sourceUser') unless $this->sourceUser;
-	die new IMPL::InvalidArgumentException("An argument is required",'sourceSession') unless $this->sourceSession;
+    my ($this) = @_;
+    
+    die new IMPL::InvalidArgumentException("An argument is required",'sourceUser') unless $this->sourceUser;
+    die new IMPL::InvalidArgumentException("An argument is required",'sourceSession') unless $this->sourceSession;
 }
 
 sub AuthUser {
-	my ($this,$name,$package,$challenge) = @_;
-	
-	my $user = $this->sourceUser->find({name => $name}) or return { status => AUTH_FAIL, answer => "Can't find a user '$name'" };
-	
-	my $auth;	
-	if ( my $secData = $user->secData($package) ) {
-		$auth = $package->new($secData);
-	} else {
-		die new IMPL::SecurityException("Authentication failed","A sec data for the $package isn't found");
-	}
-	
-	my ($status,$answer) = $auth->DoAuth($challenge);
-	
-	return {
-		status => $status,
-		answer => $answer,
-		context => $this->MakeContext( $user, [$user->roles], $auth )
-	}
+    my ($this,$name,$package,$challenge) = @_;
+    
+    my $user = $this->sourceUser->find({name => $name}) or return { status => AUTH_FAIL, answer => "Can't find a user '$name'" };
+    
+    my $auth;    
+    if ( my $secData = $user->secData($package) ) {
+        $auth = $package->new($secData);
+    } else {
+        die new IMPL::SecurityException("Authentication failed","A sec data for the $package isn't found");
+    }
+    
+    my ($status,$answer) = $auth->DoAuth($challenge);
+    
+    return {
+        status => $status,
+        answer => $answer,
+        context => $this->MakeContext( $user, [$user->roles], $auth )
+    }
 }
 
 sub MakeContext {
-	my ($this,$principal,$roles,$auth) = @_;
-	
-	return $this->sourceSession->create(
-		{
-			principal => $principal,
-			rolesAssigned => $roles,
-			auth => $auth
-		}
-	);
+    my ($this,$principal,$roles,$auth) = @_;
+    
+    return $this->sourceSession->create(
+        {
+            principal => $principal,
+            rolesAssigned => $roles,
+            auth => $auth
+        }
+    );
 }
 
 1;
@@ -69,13 +69,13 @@
 =begin code xml
 
 <security type='IMPL::Config::Activator'>
-	<factory>IMPL::Web::Security</factory>
-	<parameters type='HASH'>
-		<sessionFactory type='IMPL::Object::Factory'>
-			<factory type='IMPL::Object::Factory'>App::Data::Session</factory>
-			<method>insert</method>
-		</sessionFactory>
-	</parameters>
+    <factory>IMPL::Web::Security</factory>
+    <parameters type='HASH'>
+        <sessionFactory type='IMPL::Object::Factory'>
+            <factory type='IMPL::Object::Factory'>App::Data::Session</factory>
+            <method>insert</method>
+        </sessionFactory>
+    </parameters>
 </security>
 
 =end code xml