NAME
   CGI::AppBuilder::Security - Security Procedures

SYNOPSIS
     use CGI::AppBuilder::Security;

     my $sec = CGI::AppBuilder::Security->new();
     my ($sta, $msg) = $sec->access_ok($ar);

DESCRIPTION
   This class provides methods for reading and parsing configuration files.

 new (ifn => 'file.cfg', opt => 'hvS:')
   This is a inherited method from CGI::AppBuilder. See the same method in
   CGI::AppBuilder for more details.

 access_ok($ar)
   Input variables:

     $ar  - array ref containing the following variables:
     task          : task name required ($t)
     sel_sn1       : select one (DB/server name)
     sel_sn2       : select two (Argument)
     allowed_ip    : allowed ip address for each task
     roles         : roles allowed to access a list of tasks
     svr_allowed   : server allowed for each task
     arg_required  : required argument for each task

   Variables used or routines called:

     None

   How to use:

   First define the parameters in the initial file or define all the
   parameters in a hash array reference as $ar->{$p} where $p are

     task     = task_name
     sel_sn1  = a_db_name_or_server_name
     app_user = logname_or_logid
     usr_role = {
       usr1 = [qw(dba owb)],
       usr2 = [qw(r1 r2)],
      }
     usr_task = {
       usr1 = [qw(task1 task2)],
       usr2 = [qw(task3 task4)],
       }
     rol_task = {
       dba => [qw(task1 task3 task5)],
       owb => [qw(task2 task4)],
       }
     allowed_ip = {
       all   => [10.0.0.127,10.0.0.185,10.0.1.125)],
       task1 => [192.168.1.1,192.168.1.2],
       task2 => [10.0.0.5],
       }
     arg_required = {
       task1 => 'input1:input2',
       task2 => 'p_dnm:p_prj:p_tab:p_own',
       }
     svr_allowed = {
       task1 => {svr1=>1},
       task2 => {svr1=>1,svr2=>1,svr3=>1},
       }
     # $time = timelocal($sec,$min,$hour,$mday,$mon,$year);
     #   $sec : 0~59
     #   $min : 0~59
     #   $hour: 0~23
     #   $mday: 1~31
     #   $mon : 0~11
     #   $year: yyyy-1900
     #   ex   : [0,0,0,16,8,109] = 2009/09/16 00:00:00
     task_expired = {
       task1 => [0,0,0,25,0,109],   # 2009/01/25
       task1 => [0,0,0,17,8,119],   # 2019/09/17
       }

     my ($q, $ar, $ar_log) = $self->start_app($0, \@ARGV);
     or
     my $ar = $self->read_init_file('/tmp/my_init.cfg');
     my ($status, $err_msg) = $self->access_ok($ar);
     if ($status > 0) {
       print "OK\n";
     } else {
       print "Failed: $err_msg\n";
     }

     my ($ok, $msg) = $self->access_ok($task, $ar);
     if ($ok) {
         $self->exe_sql($q, $ar);
     } else {
         print $self->disp_form($q, $ar);
         print "<font color=red>$msg</font>\n" if $ar->{write_log};
         $self->echo_msg($msg,0);
     }

   Return: ($status, $msg) where $status is 1 (ok) or 0 (not), and the msg
   is the error message.

  get_cookies ($cgi,$ar)
   Input variables:

     $cgi - CGI object
     $ar  - Array ref containing all the parameters

   Variables used or routines called:

     disp_param - display parameters

   How to use:

     my $q = new CGI;
     my %cfg = (usr=>'jsmith', pwd=>'jojo');
     my @names = $q->param;
     foreach my $k (@names) { $cfg{$k} = $q->param($k) if ! exists $cfg{$k}; }
     $self->get_cookies($q, \%cfg);

   Return: ($ck_ar, $ck1, $ck2, $ck3) - hash array reference for cookies
   (${$ck_ar}{$ck}{$ck}) and cookie names.

   This method retrieves and parses cookies set by previous process and
   returns them in a hash array reference.

  set_cookies ($cgi,$ar, $cr, $dr)
   Input variables:

     $cgi - CGI object
     $ar  - Array ref containing all the parameters
     $cr  - cookie array ref
     $dr  - access array ref

   Variables used or routines called:

     get_cookies - get cookie hash array ref
     get_access  - get access hash array ref

   How to use:

     my $q = new CGI;
     my %cfg = (usr=>'jsmith', pwd=>'jojo');
     my @names = $q->param;
     foreach my $k (@names) { $cfg{$k} = $q->param($k) if ! exists $cfg{$k}; }
     $self->get_cookies($q, \%cfg);

   Return: 1 or 0 to indicates whether setting cookies is sucessfull.

   This method retrieves and parses cookies set by previous process and
   returns them in a hash array reference.

HISTORY
   *   Version 0.10

       This version ported from ora_jobs.pl on 9/17/2009.

   *   Version 0.20

SEE ALSO (some of docs that I check often)
   Oracle::Loader, Oracle::Trigger, CGI::AppBuilder, File::Xcopy,
   CGI::AppBuilder::Message

AUTHOR
   Copyright (c) 2009 Hanming Tu. All rights reserved.

   This package is free software and is provided "as is" without express or
   implied warranty. It may be used, redistributed and/or modified under
   the terms of the Perl Artistic License (see
   http://www.perl.com/perl/misc/Artistic.html)

POD ERRORS
   Hey! The above document had some coding errors, which are explained
   below:

   Around line 412:
       You forgot a '=back' before '=head1'