Author: spadkins
Date: Mon May 15 10:07:13 2006
New Revision: 6298
Modified:
p5ee/trunk/App-Context/lib/App/Authorization.pm
Log:
first workable (always returns true) version
Modified: p5ee/trunk/App-Context/lib/App/Authorization.pm
==============================================================================
--- p5ee/trunk/App-Context/lib/App/Authorization.pm (original)
+++ p5ee/trunk/App-Context/lib/App/Authorization.pm Mon May 15 10:07:13 2006
@@ -3,7 +3,7 @@
## $Id$
#############################################################################
-package App::LogChannel;
+package App::Authorization;
$VERSION = (q$Revision$ =~ /(\d[\d\.]*)/)[0]; # VERSION numbers generated by
svn
use App;
@@ -14,21 +14,20 @@
=head1 NAME
-App::LogChannel - Interface for logging
+App::Authorization - A service that is used by various application components
to know what the current user is authorized to do
=head1 SYNOPSIS
use App;
$context = App->context();
- $logchannel = $context->service("LogChannel"); # or ...
- $logchannel = $context->logchannel();
+ $auth = $context->service("Authorization"); # or ...
+ $auth = $context->authorization();
=head1 DESCRIPTION
-A LogChannel service is a means by which messages are logged through a
-logging system. This perhaps ends up in a file, or perhaps it
-ends up on someone's operator console screen somewhere.
+An Authorization service is a means by which
+by various application components to know what the current user is authorized
to do.
=cut
@@ -36,17 +35,15 @@
# CLASS GROUP
#############################################################################
-=head1 Class Group: LogChannel
+=head1 Class Group: Authorization
-The following classes might be a part of the LogChannel Class Group.
+The following classes might be a part of the Authorization Class Group.
=over
-=item * Class: App::LogChannel
+=item * Class: App::Authorization
-=item * Class: App::LogChannel::LogDispatch
-
-=item * Class: App::LogChannel::NetDaemon
+=item * Class: App::Authorization::SharedDatastore
=back
@@ -56,11 +53,11 @@
# CLASS
#############################################################################
-=head1 Class: App::LogChannel
+=head1 Class: App::Authorization
-A LogChannel service ...
+An Authorization service ...
- * Throws: App::Exception::LogChannel
+ * Throws: App::Exception::Authorization
* Since: 0.01
=head2 Class Design
@@ -97,28 +94,43 @@
=cut
#############################################################################
-# log()
+# is_authorized()
#############################################################################
-=head2 log()
+=head2 is_authorized()
- * Signature: $logchannel->log(@text);
- * Param: @text array[string]
- * Return: void
- * Throws: App::Exception::LogChannel
+ * Signature: $auth->is_authorized($key);
+ * Signature: $auth->is_authorized($key, $user);
+ * Signature: $auth->is_authorized($key, $user, $options);
+ * Signature: $auth->is_authorized($key, undef, $options);
+ * Param: $key string
+ * Param: $user string
+ * Param: $options HASH
+ * Return: $is_auth boolean
+ * Throws: App::Exception::Authorization
* Since: 0.01
Sample Usage:
$context = App->context();
- $logchannel = $context->service("LogChannel"); # or ...
- $logchannel->log("Error occurred");
+ $auth = $context->service("Authorization"); # or ...
+ $auth = $context->authorization();
+ if ($auth->is_authorized("/main/data/edit")) {
+ # ...
+ }
=cut
-sub log {
- my ($self, @text) = @_;
- print STDERR @text, "\n";
+sub is_authorized {
+ &App::sub_entry if ($App::trace);
+ my ($self, $key, $user, $options) = @_;
+ $user = $self->{context}->user() if (!$user);
+ my $is_auth = 0;
+
+ $is_auth = 1;
+
+ &App::sub_exit($is_auth) if ($App::trace);
+ return($is_auth);
}
#############################################################################
@@ -135,14 +147,14 @@
=head2 service_type()
-Returns 'LogChannel';
+Returns 'Authorization';
- * Signature: $service_type = App::LogChannel->service_type();
+ * Signature: $service_type = App::Authorization->service_type();
* Param: void
* Return: $service_type string
* Since: 0.01
- $service_type = $authz->service_type();
+ $service_type = $auth->service_type();
=cut