File Coverage

blib/lib/Eidolon/Driver/User.pm
Criterion Covered Total %
statement 12 30 40.0
branch 0 12 0.0
condition 0 3 0.0
subroutine 4 9 44.4
pod 4 4 100.0
total 20 58 34.4


line stmt bran cond sub pod time code
1             package Eidolon::Driver::User;
2             # ==============================================================================
3             #
4             # Eidolon
5             # Copyright (c) 2009, Atma 7
6             # ---
7             # Eidolon/Driver/User.pm - generic user driver
8             #
9             # ==============================================================================
10              
11 1     1   1599 use base qw/Eidolon::Driver Class::Accessor::Fast/;
  1         2  
  1         549  
12 1     1   613 use Eidolon::Driver::User::Exceptions;
  1         2  
  1         25  
13 1     1   5 use warnings;
  1         2  
  1         38  
14 1     1   6 use strict;
  1         2  
  1         379  
15              
16             __PACKAGE__->mk_accessors(qw/agent ip language referer/);
17              
18             our $VERSION = "0.02"; # 2009-05-14 05:33:34
19              
20             # ------------------------------------------------------------------------------
21             # \% new()
22             # constructor
23             # ------------------------------------------------------------------------------
24             sub new
25             {
26 0     0 1   my ($class, $self);
27              
28 0           $class = shift;
29              
30             # class attributes
31 0           $self =
32             {
33             "ip" => undef,
34             "agent" => undef,
35             "language" => undef,
36             "referer" => undef
37             };
38              
39 0           bless $self, $class;
40 0           $self->_init;
41              
42 0           return $self;
43             }
44              
45             # ------------------------------------------------------------------------------
46             # _init()
47             # class initialization
48             # ------------------------------------------------------------------------------
49             sub _init()
50             {
51 0     0     my ($self, $buffer);
52              
53 0           $self = shift;
54              
55 0 0         $self->agent ( $ENV{"HTTP_USER_AGENT"} ) if ($ENV{"HTTP_USER_AGENT"});
56 0 0         $self->referer( $ENV{"HTTP_REFERER"} ) if ($ENV{"HTTP_REFERER"});
57 0 0         $self->ip ( $ENV{"REMOTE_ADDR"} ) if ($ENV{"REMOTE_ADDR"});
58 0 0         $self->ip ( $ENV{"HTTP_X_FORWARDED_FOR"} ) if ($ENV{"HTTP_X_FORWARDED_FOR"});
59              
60 0 0         if ($ENV{"HTTP_ACCEPT_LANGUAGE"})
61             {
62 0           ($buffer) = $ENV{"HTTP_ACCEPT_LANGUAGE"} =~ /^([^;]+);/;
63 0 0 0       $self->language( substr($buffer, 0, index($buffer, ",")) ) if ($buffer && index($buffer, ",") != -1);
64             }
65             }
66              
67             # ------------------------------------------------------------------------------
68             # authorize($login)
69             # authorize user
70             # ------------------------------------------------------------------------------
71             sub authorize
72             {
73 0     0 1   throw CoreError::AbstractMethod;
74             }
75              
76             # ------------------------------------------------------------------------------
77             # unauthorize()
78             # unauthorize user
79             # ------------------------------------------------------------------------------
80             sub unauthorize
81             {
82 0     0 1   throw CoreError::AbstractMethod;
83             }
84              
85             # ------------------------------------------------------------------------------
86             # $ authorized()
87             # check if user is authorized
88             # ------------------------------------------------------------------------------
89             sub authorized
90             {
91 0     0 1   throw CoreError::AbstractMethod;
92             }
93              
94             1;
95              
96             __END__