/[cvs]/nfo/perl/libs/OEF/API/Session.pm
ViewVC logotype

Contents of /nfo/perl/libs/OEF/API/Session.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations)
Fri Apr 4 17:26:09 2003 UTC (21 years, 1 month ago) by joko
Branch: MAIN
CVS Tags: HEAD
initial commit

1 ## -------------------------------------------------------------------------
2 ## $Id: Jobs.pm,v 1.2 2003/03/28 03:07:41 joko Exp $
3 ## -------------------------------------------------------------------------
4 ## $Log: Jobs.pm,v $
5 ## Revision 1.2 2003/03/28 03:07:41 joko
6 ## minor fix: 'run_cmd' required here
7 ##
8 ## Revision 1.1 2003/03/27 15:39:55 joko
9 ## initial commit, jobs -core and -api
10 ##
11 ## -------------------------------------------------------------------------
12
13
14 package OEF::API::Session;
15
16 use strict;
17 use warnings;
18
19 use base qw( DesignPattern::Object );
20 use base qw( OEF::API::Abstract );
21
22
23 use Data::Dumper;
24
25 # get logger instance
26 my $logger = Log::Dispatch::Config->instance;
27
28
29 #my $bizWorks = $main::bizWorks;
30 my $bizProcess = $main::bizProcess;
31 #my $process = $main::bizProcess;
32
33 #print Dumper($bizProcess);
34 #push @{$process->{app}->{use_databases}}, 'control';
35 #my $boot = $main::boot;
36 #$boot->_bootDatabases();
37
38
39 sub _api_init {
40 my $self = shift;
41 #return;
42 my $procs = [
43 {
44 name => "session_id",
45 version => "0.02",
46 hidden => 0,
47 code => \&session_id,
48 #signature => [ 'string array' ],
49 signature => [ 'string', 'string struct' ],
50 help => "",
51 },
52 {
53 name => "authenticate",
54 version => "0.02",
55 hidden => 0,
56 code => \&login,
57 signature => [
58 'string struct', # w/o session
59 'string struct struct', # with session
60 ],
61 help => "",
62 },
63 {
64 name => "example1",
65 version => "0.01",
66 hidden => 0,
67 code => \&example1,
68 signature => [ 'string', 'string struct' ],
69 help => "a non-protected example",
70 },
71 {
72 name => "example2",
73 version => "0.01",
74 hidden => 0,
75 code => \&example2,
76 signature => [ 'string', 'string struct' ],
77 help => "a non-protected, but session-based example",
78 },
79 {
80 name => "example3",
81 version => "0.01",
82 hidden => 0,
83 code => \&example3,
84 signature => [ 'string', 'string struct' ],
85 help => "a session-based, protected example",
86 protected => 1,
87 },
88 ];
89 $self->register($procs);
90 }
91
92
93
94
95 sub session_id {
96 my $self = shift;
97
98 # get session-id
99 my $session_id = $self->get_session_id();
100 #my $daemon = $self->{__daemon};
101 #pr
102
103 $logger->info( __PACKAGE__ . "->session_id: Client requested session identifier '$session_id'." );
104 return $session_id;
105 }
106
107 sub login {
108 my $self = shift;
109 my $credentials = shift;
110 my $user = $credentials->{user};
111 my $pass = $credentials->{pass};
112 return $self->authenticate($user, $pass);
113 #print "login: $user:$pass", "\n";
114 }
115
116 sub example1 {
117 my $self = shift;
118 return "example - free";
119 }
120
121 sub example2 {
122 my $self = shift;
123 #protected($self);
124 return "example - session";
125 }
126
127 sub example3 {
128 my $self = shift;
129 #protected($self);
130 return "example - protected";
131 }
132
133
134
135 #my $meta = {};
136 sub protected {
137 my $self = shift;
138 my $pack = __PACKAGE__;
139 print "$pack: Checking Authentication", "\n";
140 if ($self->{$pack}->{login}) {
141 print "YAI!", "\n";
142 return 1;
143 }
144
145 #print Dumper($self);
146
147 #print "Session not established!", "\n";
148 #exit;
149 #$self->{method_name} = 'hello';
150
151 # V1 - just die
152 #die();
153
154 # V2 - intercept the response and send custom one
155 # code taken from RPC::XML::Server::process_request
156 #my $conn = $self->{server}->{client};
157 my $daemon = $self->{__daemon};
158 #print Dumper($daemon);
159 #bless $conn, 'HTTP::Daemon::ClientConn';
160 #${*$conn}{'httpd_daemon'} = $self;
161 print "authentication failed!", "\n";
162 #$conn->send_error(&HTTP::Status::RC_FORBIDDEN);
163
164 # get connection instance
165 =pod
166 my $conn;
167 {
168 $conn = $daemon->{server}->{client};
169 bless $conn, 'HTTP::Daemon::ClientConn';
170 ${*$conn}{'httpd_daemon'} = $self;
171 }
172 =cut
173
174 #my $conn = $daemon->accept();
175 my $conn = $self->daemon();
176 #{server}->{client};
177 print Dumper($conn);
178 $conn->send_error(&HTTP::Status::RC_FORBIDDEN);
179
180
181 }
182
183
184 1;
185 __END__

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed