diff Lib/ObjectStore/CDBI/Users.pm @ 49:16ada169ca75

migrating to the Eclipse IDE
author wizard@linux-odin.local
date Fri, 26 Feb 2010 10:49:21 +0300
parents 03e58a454b20
children
line wrap: on
line diff
--- a/Lib/ObjectStore/CDBI/Users.pm	Fri Feb 26 01:43:42 2010 +0300
+++ b/Lib/ObjectStore/CDBI/Users.pm	Fri Feb 26 10:49:21 2010 +0300
@@ -1,100 +1,100 @@
-#!/usr/bin/perl -w
-use strict;
-
-package ObjectStore::CDBI::Users;
-use Common;
-use Digest::MD5 qw(md5_hex);
-our @ISA = qw(Object);
-
-our $Namespace;
-our $DataModule;
-
-our $Prefix = $Namespace ? $Namespace.'::' : '';
-
-if ($DataModule) {
-    $DataModule =~ s/::/\//g;
-    $DataModule .= '.pm';
-    require $DataModule;
-}
-
-BEGIN {
-    DeclareProperty DSNamespace => ACCESS_NONE;
-}
-
-sub CTOR {
-    my ($this,%args) = @_;
-    
-    $this->{$DSNamespace} = $args{'DSNamespace'};
-}
-
-sub ClassName {
-    return $_[0]->{$DSNamespace} ? $_[0]->{$DSNamespace}. $_[1] : $_[1];
-}
-
-sub FindUser {
-    my ($this,$uname) = @_;
-    
-    my @Users = $this->ClassName('Principal')->search(Name => $uname);
-    return shift @Users;
-}
-
-sub CreateUser {
-    my ($this,$uname,$description,$active) = @_;
-    
-    if (my $user = $this->FindUser($uname)) {
-        die new Exception("The user is already exists",$uname);
-    } else {
-        return $this->ClassName('Principal')->insert({Name => $uname, Description => $description, Active => $active});
-    }
-}
-
-sub DeleteUser {
-    my ($this,$objUser) = @_;
-    
-    $objUser->delete;
-}
-
-sub GetUserAuthData {
-    my ($this,$objUser,$objSecPackage) = @_;
-    
-    my @Data = $this->ClassName('AuthData')->search(User => $objUser,Package => $objSecPackage->Name);
-    return $Data[0];
-}
-
-sub SetUserAuthData {
-    my ($this,$objUser,$objSecPackage,$objAuthData) = @_;
-    
-    if (my $AuthData = $this->GetUserAuthData($objUser,$objSecPackage)) {
-        $AuthData->AuthData(objAuthData->SessionAuthData);
-        $AuthData->update;
-    } else {
-        $this->ClassName('AuthData')->insert({ User => $objUser, Package => $objSecPackage->Name, AuthData => $objAuthData->SessionAuthData});
-    }
-}
-
-sub CreateSession {
-    my ($this,$SSID,$objUser,$objAuthData) = @_;
-    
-    my $session = $this->ClassName('Session')->insert({SSID => $SSID, User => $objUser, SecData => $objAuthData->SessionAuthData, LastUsage => DateTime->now() });
-    $session->autoupdate(1);
-    return $session;
-}
-
-sub CloseSession {
-    my ($this,$objSession) = @_;
-    
-    $objSession->delete;
-}
-
-sub LoadSession {
-    my ($this,$SSID) = @_;
-    my @Data = $this->ClassName('Session')->search(SSID => $SSID);
-    if ($Data[0]) {
-        $Data[0]->autoupdate(1);
-        return $Data[0];
-    }
-}
-
-sub construct {
-    return __PACKAGE__->new(DSNamespace => $Prefix);
-}
\ No newline at end of file
+#!/usr/bin/perl -w
+use strict;
+
+package ObjectStore::CDBI::Users;
+use Common;
+use Digest::MD5 qw(md5_hex);
+our @ISA = qw(Object);
+
+our $Namespace;
+our $DataModule;
+
+our $Prefix = $Namespace ? $Namespace.'::' : '';
+
+if ($DataModule) {
+    $DataModule =~ s/::/\//g;
+    $DataModule .= '.pm';
+    require $DataModule;
+}
+
+BEGIN {
+    DeclareProperty DSNamespace => ACCESS_NONE;
+}
+
+sub CTOR {
+    my ($this,%args) = @_;
+    
+    $this->{$DSNamespace} = $args{'DSNamespace'};
+}
+
+sub ClassName {
+    return $_[0]->{$DSNamespace} ? $_[0]->{$DSNamespace}. $_[1] : $_[1];
+}
+
+sub FindUser {
+    my ($this,$uname) = @_;
+    
+    my @Users = $this->ClassName('Principal')->search(Name => $uname);
+    return shift @Users;
+}
+
+sub CreateUser {
+    my ($this,$uname,$description,$active) = @_;
+    
+    if (my $user = $this->FindUser($uname)) {
+        die new Exception("The user is already exists",$uname);
+    } else {
+        return $this->ClassName('Principal')->insert({Name => $uname, Description => $description, Active => $active});
+    }
+}
+
+sub DeleteUser {
+    my ($this,$objUser) = @_;
+    
+    $objUser->delete;
+}
+
+sub GetUserAuthData {
+    my ($this,$objUser,$objSecPackage) = @_;
+    
+    my @Data = $this->ClassName('AuthData')->search(User => $objUser,Package => $objSecPackage->Name);
+    return $Data[0];
+}
+
+sub SetUserAuthData {
+    my ($this,$objUser,$objSecPackage,$objAuthData) = @_;
+    
+    if (my $AuthData = $this->GetUserAuthData($objUser,$objSecPackage)) {
+        $AuthData->AuthData(objAuthData->SessionAuthData);
+        $AuthData->update;
+    } else {
+        $this->ClassName('AuthData')->insert({ User => $objUser, Package => $objSecPackage->Name, AuthData => $objAuthData->SessionAuthData});
+    }
+}
+
+sub CreateSession {
+    my ($this,$SSID,$objUser,$objAuthData) = @_;
+    
+    my $session = $this->ClassName('Session')->insert({SSID => $SSID, User => $objUser, SecData => $objAuthData->SessionAuthData, LastUsage => DateTime->now() });
+    $session->autoupdate(1);
+    return $session;
+}
+
+sub CloseSession {
+    my ($this,$objSession) = @_;
+    
+    $objSession->delete;
+}
+
+sub LoadSession {
+    my ($this,$SSID) = @_;
+    my @Data = $this->ClassName('Session')->search(SSID => $SSID);
+    if ($Data[0]) {
+        $Data[0]->autoupdate(1);
+        return $Data[0];
+    }
+}
+
+sub construct {
+    return __PACKAGE__->new(DSNamespace => $Prefix);
+}