LEMONLDAP::NG : Doxygen documentation in progress

This commit is contained in:
Xavier Guimard 2008-12-30 09:37:56 +00:00
parent cef50ff78f
commit 62b02d49fd
11 changed files with 225 additions and 80 deletions

View File

@ -665,7 +665,7 @@ STRIP_CODE_COMMENTS = YES
# then for each documented function all documented # then for each documented function all documented
# functions referencing it will be listed. # functions referencing it will be listed.
REFERENCED_BY_RELATION = NO REFERENCED_BY_RELATION = YES
# If the REFERENCES_RELATION tag is set to YES # If the REFERENCES_RELATION tag is set to YES
# then for each documented function all documented entities # then for each documented function all documented entities

View File

@ -141,12 +141,24 @@ sub more {
} }
my @order = ( my @order = (
'Public Initialization Methods',
'Public Initialization Functions',
'Public Running Methods',
'Public Running Functions',
'Public Class Methods', 'Public Class Methods',
'Public Object Methods', 'Public Object Methods',
'Public Functions', 'Public Functions',
'Protected Initialization Methods',
'Protected Initialization Functions',
'Protected Running Methods',
'Protected Running Functions',
'Protected Class Methods', 'Protected Class Methods',
'Protected Object Methods', 'Protected Object Methods',
'Protected Functions', 'Protected Functions',
'Private Initialization Methods',
'Private Initialization Functions',
'Private Running Methods',
'Private Running Functions',
'Private Class Methods', 'Private Class Methods',
'Private Object Methods', 'Private Object Methods',
'Private Functions', 'Private Functions',

View File

@ -113,6 +113,24 @@ print LOG $_;
@more, @more,
"\@nosubgrouping" "\@nosubgrouping"
] ); ] );
} elsif ($command eq 'imethod') {
unless ($args) {
($args) = $self->analyze_sub( $line-1 );
}
$args = $self->munge_parameters($args);
$self->push($self->protection($args).' Initialization Methods');
$self->start("\@fn $args")->more(@more)->end;
$self->print($args, ";\n");
$self->pop;
} elsif ($command eq 'rmethod') {
unless ($args) {
($args) = $self->analyze_sub( $line-1 );
}
$args = $self->munge_parameters($args);
$self->push($self->protection($args).' Running Methods');
$self->start("\@fn $args")->more(@more)->end;
$self->print($args, ";\n");
$self->pop;
} elsif ($command eq 'cmethod') { } elsif ($command eq 'cmethod') {
unless ($args) { unless ($args) {
($args) = $self->analyze_sub( $line-1 ); ($args) = $self->analyze_sub( $line-1 );
@ -122,6 +140,24 @@ print LOG $_;
$self->start("\@fn $args")->more(@more)->end; $self->start("\@fn $args")->more(@more)->end;
$self->print($args, ";\n"); $self->print($args, ";\n");
$self->pop; $self->pop;
} elsif ($command eq 'ifn') {
unless ($args) {
($args) = $self->analyze_sub( $line-1 );
}
$args = $self->munge_parameters($args);
$self->push($self->protection($args).' Initialization Functions');
$self->start("\@fn $args")->more(@more)->end;
$self->print($args, ";\n");
$self->pop;
} elsif ($command eq 'rfn') {
unless ($args) {
($args) = $self->analyze_sub( $line-1 );
}
$args = $self->munge_parameters($args);
$self->push($self->protection($args).' Running Functions');
$self->start("\@fn $args")->more(@more)->end;
$self->print($args, ";\n");
$self->pop;
} elsif ($command eq 'fn') { } elsif ($command eq 'fn') {
unless ($args) { unless ($args) {
($args) = $self->analyze_sub( $line-1 ); ($args) = $self->analyze_sub( $line-1 );
@ -169,6 +205,9 @@ print LOG $_;
if( $current_class && @args && ($args[0] eq "\$self") ) { if( $current_class && @args && ($args[0] eq "\$self") ) {
$self->push($self->protection($proto).' Object Methods'); $self->push($self->protection($proto).' Object Methods');
$proto =~ s/\$self,*\s*//; $proto =~ s/\$self,*\s*//;
} elsif( $current_class && @args && ($args[0] eq "\$self") ) {
$self->push($self->protection($proto).' Initialization Methods');
$proto =~ s/\$self,*\s*//;
} elsif( $current_class } elsif( $current_class
&& ((@args && ($args[0] eq "\$class")) || ($name eq "new")) ) { && ((@args && ($args[0] eq "\$class")) || ($name eq "new")) ) {
$self->push($self->protection($proto).' Class Methods'); $self->push($self->protection($proto).' Class Methods');

View File

@ -1,4 +1,4 @@
#!/usr/bin/perl -I. #!/usr/bin/perl -Iscripts
eval 'exec /usr/bin/perl -S $0 ${1+"$@"}' eval 'exec /usr/bin/perl -S $0 ${1+"$@"}'
if 0; # not running under some shell if 0; # not running under some shell

View File

@ -1,3 +1,10 @@
##@file
# Base package for Lemonldap::NG configuration system
##@class
# Implements Lemonldap::NG shared configuration system.
# In case of error or warning, the message is stored in the global variable
# $Lemonldap::NG::Common::Conf::msg
package Lemonldap::NG::Common::Conf; package Lemonldap::NG::Common::Conf;
use strict; use strict;
@ -13,6 +20,21 @@ our $msg;
our %_confFiles; our %_confFiles;
## @cmethod Lemonldap::NG::Common::Conf new(hashRef arg)
# Constructor.
# Succeed if it has found a way to access to Lemonldap::NG configuration with
# $arg (or default file). It can be :
# - Nothing: default configuration file is tested,
# - { File => "/path/to/storage.conf" },
# - { Type => "File", dirName => "/path/to/conf/dir/" },
# - { Type => "DBI", dbiChain => "DBI:mysql:database=lemonldap-ng;host=1.2.3.4",
# dbiUser => "user", dbiPassword => "password" },
# - { Type => "SOAP", proxy => "https://manager.example.com/soapmanager.pl" },
#
# $self->{type} contains the type of configuration access system and the
# corresponding package is loaded.
# @param $arg hash reference or hash table
# @return New Lemonldap::NG::Common::Conf object
sub new { sub new {
my $class = shift; my $class = shift;
my $self = bless {}, $class; my $self = bless {}, $class;
@ -52,6 +74,10 @@ sub new {
return $self; return $self;
} }
## @method private boolean _readConfFile(string file)
# Read $file to know how to access to Lemonldap::NG configuration.
# @param $file Optional file name (default: /etc/lemonldap-ng/storage.conf)
# @return True if the file was successfuly read
sub _readConfFile { sub _readConfFile {
my $self = shift; my $self = shift;
my $file = shift || DEFAULTCONFFILE; my $file = shift || DEFAULTCONFFILE;
@ -81,6 +107,10 @@ sub _readConfFile {
return 1; return 1;
} }
## @method int saveConf(hashRef conf)
# Serialize $conf and call store().
# @param $conf Lemonldap::NG configuration hashRef
# @return Number of the saved configuration, 0 if case of error.
sub saveConf { sub saveConf {
my ( $self, $conf ) = @_; my ( $self, $conf ) = @_;
@ -115,6 +145,14 @@ sub saveConf {
return $self->store($fields); return $self->store($fields);
} }
## @method hashRef getConf(hashRef args)
# Get configuration from remote configuration storage system or from local
# cache if configuration has not been changed. If $args->{local} is set and if
# a local configuration is available, remote configuration is not tested.
#
# Uses lastCfg to test and getDBConf() to get the remote configuration
# @param $args Optional, contains {local=>1} or nothing
# @return Lemonldap::NG configuration
sub getConf { sub getConf {
my ( $self, $args ) = @_; my ( $self, $args ) = @_;
if ( $args->{'local'} if ( $args->{'local'}
@ -139,11 +177,20 @@ sub getConf {
} }
} }
## @method void setLocalConf(hashRef conf)
# Store $conf in the local cache.
# @param $conf Lemonldap::NG configuration hashRef
sub setLocalConf { sub setLocalConf {
my ( $self, $conf ) = @_; my ( $self, $conf ) = @_;
$self->{refLocalStorage}->set( "conf", $conf ); $self->{refLocalStorage}->set( "conf", $conf );
} }
## @method hashRef getDBConf(hashRef args)
# Get configuration from remote storage system.
# @param $args hashRef that must contains a key "cfgNum" (number of the wanted
# configuration) and optionaly a key "fields" that points to an array of wanted
# configuration keys
# @return Lemonldap::NG configuration hashRef
sub getDBConf { sub getDBConf {
my ( $self, $args ) = @_; my ( $self, $args ) = @_;
return undef unless $args->{cfgNum}; return undef unless $args->{cfgNum};
@ -198,38 +245,67 @@ sub getDBConf {
return $conf; return $conf;
} }
## @method boolean prereq()
# Call prereq() from the $self->{type} package.
# @return True if succeed
sub prereq { sub prereq {
return &{ $_[0]->{type} . '::prereq' }(@_); return &{ $_[0]->{type} . '::prereq' }(@_);
} }
## @method @ available()
# Call available() from the $self->{type} package.
# @return list of available configuration numbers
sub available { sub available {
return &{ $_[0]->{type} . '::available' }(@_); return &{ $_[0]->{type} . '::available' }(@_);
} }
## @method int lastCfg()
# Call lastCfg() from the $self->{type} package.
# @return Number of the last configuration available
sub lastCfg { sub lastCfg {
return &{ $_[0]->{type} . '::lastCfg' }(@_); return &{ $_[0]->{type} . '::lastCfg' }(@_);
} }
## @method boolean lock()
# Call lock() from the $self->{type} package.
# @return True if succeed
sub lock { sub lock {
return &{ $_[0]->{type} . '::lock' }(@_); return &{ $_[0]->{type} . '::lock' }(@_);
} }
## @method boolean isLocked()
# Call isLocked() from the $self->{type} package.
# @return True if database is locked
sub isLocked { sub isLocked {
return &{ $_[0]->{type} . '::isLocked' }(@_); return &{ $_[0]->{type} . '::isLocked' }(@_);
} }
## @method boolean unlock()
# Call unlock() from the $self->{type} package.
# @return True if succeed
sub unlock { sub unlock {
return &{ $_[0]->{type} . '::unlock' }(@_); return &{ $_[0]->{type} . '::unlock' }(@_);
} }
## @method int store(hashRef conf)
# Call store() from the $self->{type} package.
# @param $conf Lemondlap configuration serialized
# @return Number of new configuration stored if succeed, 0 else.
sub store { sub store {
return &{ $_[0]->{type} . '::store' }(@_); return &{ $_[0]->{type} . '::store' }(@_);
} }
## @method load(int cfgNum, arrayRef fields)
# Call load() from the $self->{type} package.
# @return Lemonldap::NG Configuration hashRef if succeed, 0 else.
sub load { sub load {
return &{ $_[0]->{type} . '::load' }(@_); return &{ $_[0]->{type} . '::load' }(@_);
} }
## @method boolean delete(int cfgNum)
# Call delete() from the $self->{type} package.
# @param $cfgNum Number of configuration to delete
# @return True if succeed
sub delete { sub delete {
my ( $self, $c ) = @_; my ( $self, $c ) = @_;
my @a = $self->available(); my @a = $self->available();

View File

@ -5,6 +5,16 @@
## @class ## @class
# Main handler. # Main handler.
# All methods in handler are class methods: in ModPerl environment, handlers
# are always launched without object created.
#
# The main method is run() who is called by Apache for each requests (using
# handler() wrapper).
#
# The initialization process is splitted in two parts :
# - init() is launched as Apache startup
# - globalInit() is launched at each first request received by an Apache child
# and each time a new configuration is detected
package Lemonldap::NG::Handler::SharedConf; package Lemonldap::NG::Handler::SharedConf;
use strict; use strict;
@ -46,7 +56,7 @@ BEGIN {
# INIT PROCESS # INIT PROCESS
## @cmethod void init(hashRef args) ## @imethod void init(hashRef args)
# Constructor. # Constructor.
# init is overloaded to call only localInit. globalInit is called later. # init is overloaded to call only localInit. globalInit is called later.
# @param $args hash containing parameters # @param $args hash containing parameters
@ -57,7 +67,7 @@ sub init($$) {
$class->localInit($args); $class->localInit($args);
} }
## @cmethod void defaultValuesInit(hashRef args) ## @imethod protected void defaultValuesInit(hashRef args)
# Set default values for non-customized variables # Set default values for non-customized variables
# @param $args hash containing parameters # @param $args hash containing parameters
# @return boolean # @return boolean
@ -69,7 +79,7 @@ sub defaultValuesInit {
return $class->SUPER::defaultValuesInit( \%h ); return $class->SUPER::defaultValuesInit( \%h );
} }
## @cmethod void localInit(hashRef args) ## @imethod void localInit(hashRef args)
# Load parameters and build the Lemonldap::NG::Common::Conf object. # Load parameters and build the Lemonldap::NG::Common::Conf object.
# @return boolean # @return boolean
sub localInit { sub localInit {
@ -88,7 +98,7 @@ sub localInit {
# MAIN # MAIN
## @cmethod int run(Apache2::RequestRec r) ## @rmethod int run(Apache2::RequestRec r)
# Check configuration and launch Lemonldap::NG::Handler::Simple::run(). # Check configuration and launch Lemonldap::NG::Handler::Simple::run().
# Each $reloadTime, the Apache child verify if its configuration is the same # Each $reloadTime, the Apache child verify if its configuration is the same
# as the configuration stored in the local storage. # as the configuration stored in the local storage.
@ -107,7 +117,7 @@ sub run($$) {
# CONFIGURATION UPDATE # CONFIGURATION UPDATE
## @cmethod int testConf(boolean local) ## @rmethod protected int testConf(boolean local)
# Test if configuration has changed and launch setConf() if needed. # Test if configuration has changed and launch setConf() if needed.
# If the optional boolean $local is true, remote configuration is not tested: # If the optional boolean $local is true, remote configuration is not tested:
# only local cached configuration is tested if available. $local is given to # only local cached configuration is tested if available. $local is given to
@ -131,7 +141,7 @@ sub testConf {
OK; OK;
} }
## @cmethod int setConf(hashRef conf) ## @rmethod protected int setConf(hashRef conf)
# Launch globalInit(). # Launch globalInit().
# Local parameters have best precedence on configuration parameters. # Local parameters have best precedence on configuration parameters.
# @return Apache constant # @return Apache constant
@ -149,10 +159,12 @@ sub setConf {
*reload = *refresh; *reload = *refresh;
## @cmethod int refresh(Apache::RequestRec r) ## @rmethod int refresh(Apache::RequestRec r)
# Launch testConf() with $local=0, so remote configuration is tested. # Launch testConf() with $local=0, so remote configuration is tested.
# Then build a simple HTTP response that just returns "200 OK" or
# "500 Server Error".
# @param $r current request # @param $r current request
# @return Apache constant # @return Apache constant (OK or SERVER_ERROR)
sub refresh($$) { sub refresh($$) {
my ( $class, $r ) = @_; my ( $class, $r ) = @_;
$class->lmLog( "$class: request for configuration reload", 'notice' ); $class->lmLog( "$class: request for configuration reload", 'notice' );

View File

@ -4,7 +4,15 @@
# @copy 2005, 2006, 2007, 2008 Xavier Guimard <x.guimard@free.fr> # @copy 2005, 2006, 2007, 2008 Xavier Guimard <x.guimard@free.fr>
## @class ## @class
# Base class for Lemonldap::NG handlers # Base class for Lemonldap::NG handlers.
# All methods in handler are class methods: in ModPerl environment, handlers
# are always launched without object created.
#
# The main method is run() who is called by Apache for each requests (using
# handler() wrapper).
#
# The main initialization subroutine is init() who launch localInit() and
# globalInit().
package Lemonldap::NG::Handler::Simple; package Lemonldap::NG::Handler::Simple;
use strict; use strict;
@ -142,31 +150,31 @@ BEGIN {
*logout = ( MP() == 2 ) ? \&logout_mp2 : \&logout_mp1; *logout = ( MP() == 2 ) ? \&logout_mp2 : \&logout_mp1;
} }
## @cmethod int handler_mp1() ## @rmethod protected int handler_mp1()
# Launch run() when used under mod_perl version 1 # Launch run() when used under mod_perl version 1
# @return Apache constant # @return Apache constant
sub handler_mp1 ($$) { shift->run(@_); } sub handler_mp1 ($$) { shift->run(@_); }
## @cmethod int handler_mp2() ## @rmethod protected int handler_mp2()
# Launch run() when used under mod_perl version 2 # Launch run() when used under mod_perl version 2
# @return Apache constant # @return Apache constant
sub handler_mp2 : method { sub handler_mp2 : method {
shift->run(@_); shift->run(@_);
} }
## @cmethod int logout_mp1() ## @rmethod protected int logout_mp1()
# Launch unlog() when used under mod_perl version 1 # Launch unlog() when used under mod_perl version 1
# @return Apache constant # @return Apache constant
sub logout_mp1 ($$) { shift->unlog(@_); } sub logout_mp1 ($$) { shift->unlog(@_); }
## @cmethod int logout_mp2() ## @rmethod protected int logout_mp2()
# Launch unlog() when used under mod_perl version 2 # Launch unlog() when used under mod_perl version 2
# @return Apache constant # @return Apache constant
sub logout_mp2 : method { sub logout_mp2 : method {
shift->unlog(@_); shift->unlog(@_);
} }
## @cmethod void lmLog(string mess, string level) ## @rmethod void lmLog(string mess, string level)
# Wrapper for Apache log system # Wrapper for Apache log system
# @param $mess message to log # @param $mess message to log
# @param $level string (debug, info, warning or error) # @param $level string (debug, info, warning or error)
@ -183,7 +191,7 @@ sub lmLog {
} }
} }
## @fn void lmSetApacheUser(Apache2::RequestRec r,string s) ## @rfn protected void lmSetApacheUser(Apache2::RequestRec r,string s)
# Inform Apache for the data to use as user for logs # Inform Apache for the data to use as user for logs
# @param $r current request # @param $r current request
# @param $s string to use # @param $s string to use
@ -193,7 +201,7 @@ sub lmSetApacheUser {
$r->connection->user($s); $r->connection->user($s);
} }
## @fn string protected regRemoteIp(string str) ## @ifn protected string protected regRemoteIp(string str)
# Replaces $ip by the client IP address in the string # Replaces $ip by the client IP address in the string
# @param $str string # @param $str string
# @return string # @return string
@ -208,7 +216,7 @@ sub regRemoteIp {
return $str; return $str;
} }
## @fn void lmSetHeaderIn(Apache2::RequestRec r, string h, string v) ## @rfn void lmSetHeaderIn(Apache2::RequestRec r, string h, string v)
# Set an HTTP header in the HTTP request. # Set an HTTP header in the HTTP request.
# @param $r Current request # @param $r Current request
# @param $h Name of the header # @param $h Name of the header
@ -223,7 +231,7 @@ sub lmSetHeaderIn {
} }
} }
## @fn string lmtHeaderIn(Apache2::RequestRec r, string h) ## @rfn string lmtHeaderIn(Apache2::RequestRec r, string h)
# Return an HTTP header value from the HTTP request. # Return an HTTP header value from the HTTP request.
# @param $r Current request # @param $r Current request
# @param $h Name of the header # @param $h Name of the header
@ -238,7 +246,7 @@ sub lmHeaderIn {
} }
} }
## @fn void lmSetErrHeaderOut(Apache2::RequestRec r, string h, string v) ## @rfn void lmSetErrHeaderOut(Apache2::RequestRec r, string h, string v)
# Set an HTTP header in the HTTP response in error context # Set an HTTP header in the HTTP response in error context
# @param $r Current request # @param $r Current request
# @param $h Name of the header # @param $h Name of the header
@ -253,7 +261,7 @@ sub lmSetErrHeaderOut {
} }
} }
## @fn void lmSetHeaderOut(Apache2::RequestRec r, string h, string v) ## @rfn void lmSetHeaderOut(Apache2::RequestRec r, string h, string v)
# Set an HTTP header in the HTTP response in normal context # Set an HTTP header in the HTTP response in normal context
# @param $r Current request # @param $r Current request
# @param $h Name of the header # @param $h Name of the header
@ -268,7 +276,7 @@ sub lmSetHeaderOut {
} }
} }
## @fn string lmtHeaderOut(Apache2::RequestRec r, string h) ## @rfn string lmtHeaderOut(Apache2::RequestRec r, string h)
# Return an HTTP header value from the HTTP response. # Return an HTTP header value from the HTTP response.
# @param $r Current request # @param $r Current request
# @param $h Name of the header # @param $h Name of the header
@ -285,7 +293,7 @@ sub lmHeaderOut {
# Status daemon creation # Status daemon creation
## @fn void statusProcess() ## @ifn protected void statusProcess()
# Launch the status processus. # Launch the status processus.
sub statusProcess { sub statusProcess {
require IO::Pipe; require IO::Pipe;
@ -319,7 +327,7 @@ sub statusProcess {
# Initialization subroutines # # Initialization subroutines #
############################## ##############################
## @cmethod Safe safe() ## @imethod protected Safe safe()
# Build and return the security jail used to compile rules and headers. # Build and return the security jail used to compile rules and headers.
# @return Safe object # @return Safe object
sub safe { sub safe {
@ -348,7 +356,7 @@ sub safe {
return $safe; return $safe;
} }
## @cmethod void init(hashRef args) ## @imethod void init(hashRef args)
# Calls localInit() and globalInit(). # Calls localInit() and globalInit().
# @param $args reference to the initialization hash # @param $args reference to the initialization hash
sub init($$) { sub init($$) {
@ -357,7 +365,7 @@ sub init($$) {
$class->globalInit(@_); $class->globalInit(@_);
} }
## @cmethod void localInit(hashRef args) ## @imethod void localInit(hashRef args)
# Call purgeCache() to purge the local cache, launch the status process # Call purgeCache() to purge the local cache, launch the status process
# (statusProcess()) in wanted and launch childInit(). # (statusProcess()) in wanted and launch childInit().
# @param $args reference to the initialization hash # @param $args reference to the initialization hash
@ -375,7 +383,7 @@ sub localInit($$) {
$class->childInit(); $class->childInit();
} }
## @cmethod boolean childInit() ## @imethod protected boolean childInit()
# Indicates to Apache that it has to launch: # Indicates to Apache that it has to launch:
# - initLocalStorage() for each child process (after uid change) # - initLocalStorage() for each child process (after uid change)
# - cleanLocalStorage() after each requests # - cleanLocalStorage() after each requests
@ -408,7 +416,7 @@ sub childInit {
1; 1;
} }
## @cmethod void purgeCache() ## @imethod protected void purgeCache()
# Purge the local cache. # Purge the local cache.
# Launched at Apache startup. # Launched at Apache startup.
sub purgeCache { sub purgeCache {
@ -429,7 +437,7 @@ sub purgeCache {
} }
} }
## @cmethod void globalInit(hashRef args) ## @imethod void globalInit(hashRef args)
# Global initialization process. Launch : # Global initialization process. Launch :
# - locationRulesInit() # - locationRulesInit()
# - defaultValuesInit() # - defaultValuesInit()
@ -446,7 +454,7 @@ sub globalInit {
$class->forgeHeadersInit(@_); $class->forgeHeadersInit(@_);
} }
## @cmethod void locationRulesInit(hashRef args) ## @imethod protected void locationRulesInit(hashRef args)
# Compile rules. # Compile rules.
# Rules are stored in $args->{locationRules} that contains regexp=>test # Rules are stored in $args->{locationRules} that contains regexp=>test
# expressions where : # expressions where :
@ -481,7 +489,7 @@ sub locationRulesInit {
1; 1;
} }
## @cmethod codeRef conditionSub(string cond) ## @imethod protected codeRef conditionSub(string cond)
# Returns a compiled function used to grant users (used by # Returns a compiled function used to grant users (used by
# locationRulesInit(). # locationRulesInit().
# @param $cond The boolean expression to use # @param $cond The boolean expression to use
@ -534,7 +542,7 @@ sub conditionSub {
return $sub; return $sub;
} }
## @cmethod void defaultValuesInit(hashRef args) ## @imethod protected void defaultValuesInit(hashRef args)
# Set default values for non-customized variables # Set default values for non-customized variables
# @param $args reference to the configuration hash # @param $args reference to the configuration hash
sub defaultValuesInit { sub defaultValuesInit {
@ -552,7 +560,7 @@ sub defaultValuesInit {
1; 1;
} }
## @cmethod void portalInit(hashRef args) ## @imethod protected void portalInit(hashRef args)
# Verify that portal variable exists. Die unless # Verify that portal variable exists. Die unless
# @param $args reference to the configuration hash # @param $args reference to the configuration hash
sub portalInit { sub portalInit {
@ -560,7 +568,7 @@ sub portalInit {
$portal = $args->{portal} or die("portal parameter required"); $portal = $args->{portal} or die("portal parameter required");
} }
## @cmethod void globalStorageInit(hashRef args) ## @imethod protected void globalStorageInit(hashRef args)
# Initialize the Apache::Session::* module choosed to share user's variables. # Initialize the Apache::Session::* module choosed to share user's variables.
# @param $args reference to the configuration hash # @param $args reference to the configuration hash
sub globalStorageInit { sub globalStorageInit {
@ -571,7 +579,7 @@ sub globalStorageInit {
$globalStorageOptions = $args->{globalStorageOptions}; $globalStorageOptions = $args->{globalStorageOptions};
} }
## @cmethod void forgeHeadersInit(hashRef args) ## @imethod protected void forgeHeadersInit(hashRef args)
# Create the &$forgeHeaders subroutine used to insert # Create the &$forgeHeaders subroutine used to insert
# headers into the HTTP request. # headers into the HTTP request.
# @param $args reference to the configuration hash # @param $args reference to the configuration hash
@ -603,7 +611,24 @@ sub forgeHeadersInit {
1; 1;
} }
## @cmethod void updateStatus(string user,string url,string action) ## @imethod protected int initLocalStorage()
# Prepare local cache (if not done before by Lemonldap::NG::Common::Conf)
# @return Apache2::Const::DECLINED
sub initLocalStorage {
my ( $class, $r ) = @_;
if ( $localStorage and not $refLocalStorage ) {
eval "use $localStorage;\$refLocalStorage = new $localStorage(\$localStorageOptions);";
$class->lmLog( "Local cache initialization failed: $@", 'error' )
unless ( defined $refLocalStorage );
}
return DECLINED;
}
###################
# RUNNING METHODS #
###################
## @rmethod protected void updateStatus(string user,string url,string action)
# Inform the status process of the result of the request if it is available. # Inform the status process of the result of the request if it is available.
sub updateStatus { sub updateStatus {
my ( $class, $user, $url, $action ) = @_; my ( $class, $user, $url, $action ) = @_;
@ -615,11 +640,7 @@ sub updateStatus {
}; };
} }
################### ## @rmethod protected boolean grant()
# RUNNING METHODS #
###################
## @cmethod boolean grant()
# Grant or refuse client using compiled regexp and functions # Grant or refuse client using compiled regexp and functions
# @return True if the user is granted to access to the current URL # @return True if the user is granted to access to the current URL
sub grant { sub grant {
@ -631,7 +652,7 @@ sub grant {
return &$defaultCondition($datas); return &$defaultCondition($datas);
} }
## @cmethod int forbidden() ## @rmethod protected int forbidden()
# Used to reject non authorizated requests. # Used to reject non authorizated requests.
# Inform the status processus and call logForbidden(). # Inform the status processus and call logForbidden().
# @return Apache2::Const::FORBIDDEN # @return Apache2::Const::FORBIDDEN
@ -648,7 +669,7 @@ sub forbidden {
return FORBIDDEN; return FORBIDDEN;
} }
## @cmethod void logForbidden() ## @rmethod protected void logForbidden()
# Insert a log in Apache errors log system to inform that the user was rejected. # Insert a log in Apache errors log system to inform that the user was rejected.
# This method has to be overloaded to use different logs systems # This method has to be overloaded to use different logs systems
sub logForbidden { sub logForbidden {
@ -662,7 +683,7 @@ sub logForbidden {
); );
} }
## @cmethod void hideCookie() ## @rmethod protected void hideCookie()
# Hide Lemonldap::NG cookie to the protected application. # Hide Lemonldap::NG cookie to the protected application.
sub hideCookie { sub hideCookie {
my $class = shift; my $class = shift;
@ -672,7 +693,7 @@ sub hideCookie {
lmSetHeaderIn( $apacheRequest, 'Cookie' => $tmp ); lmSetHeaderIn( $apacheRequest, 'Cookie' => $tmp );
} }
## @cmethod string encodeUrl(string url) ## @rmethod protected string encodeUrl(string url)
# Encode URl in the format used by Lemonldap::NG::Portal for redirections. # Encode URl in the format used by Lemonldap::NG::Portal for redirections.
sub encodeUrl { sub encodeUrl {
my ( $class, $url ) = @_; my ( $class, $url ) = @_;
@ -694,7 +715,7 @@ sub encodeUrl {
return $u; return $u;
} }
## @cmethod int goToPortal(string url, string arg) ## @rmethod protected int goToPortal(string url, string arg)
# Redirect non-authenticated users to the portal by setting "Location:" header. # Redirect non-authenticated users to the portal by setting "Location:" header.
# @param $url Url requested # @param $url Url requested
# @param $arg optionnal GET parameters # @param $arg optionnal GET parameters
@ -713,7 +734,7 @@ sub goToPortal {
return REDIRECT; return REDIRECT;
} }
## @cmethod $ fetchId() ## @rmethod protected $ fetchId()
# Get user cookies and search for Lemonldap::NG cookie. # Get user cookies and search for Lemonldap::NG cookie.
# @return Value of the cookie if found, 0 else # @return Value of the cookie if found, 0 else
sub fetchId { sub fetchId {
@ -723,7 +744,7 @@ sub fetchId {
# MAIN SUBROUTINE called by Apache (using PerlHeaderParserHandler option) # MAIN SUBROUTINE called by Apache (using PerlHeaderParserHandler option)
## @cmethod int run(Apache2::RequestRec apacheRequest) ## @rmethod int run(Apache2::RequestRec apacheRequest)
# Main method used to control access. # Main method used to control access.
# Calls : # Calls :
# - fetchId() # - fetchId()
@ -805,13 +826,13 @@ sub run ($$) {
OK; OK;
} }
## @cmethod void sendHeaders() ## @rmethod protected void sendHeaders()
# Launch function compiled by forgeHeadersInit() # Launch function compiled by forgeHeadersInit()
sub sendHeaders { sub sendHeaders {
&$forgeHeaders; &$forgeHeaders;
} }
## @cmethod int unprotect() ## @rmethod int unprotect()
# Used to unprotect an area. # Used to unprotect an area.
# To use it, set "PerlHeaderParserHandler My::Package->unprotect" Apache # To use it, set "PerlHeaderParserHandler My::Package->unprotect" Apache
# configuration file. # configuration file.
@ -821,7 +842,7 @@ sub unprotect {
OK; OK;
} }
## @cmethod void localUnlog() ## @rmethod protected void localUnlog()
# Delete current user from local cache entry. # Delete current user from local cache entry.
sub localUnlog { sub localUnlog {
my $class = shift; my $class = shift;
@ -839,7 +860,7 @@ sub localUnlog {
} }
} }
## @cmethod int unlog(Apache::RequestRec apacheRequest) ## @rmethod protected int unlog(Apache::RequestRec apacheRequest)
# Call localUnlog() then goToPortal() to unlog the current user. # Call localUnlog() then goToPortal() to unlog the current user.
# @return Apache2::Const value returned by goToPortal() # @return Apache2::Const value returned by goToPortal()
sub unlog ($$) { sub unlog ($$) {
@ -850,7 +871,7 @@ sub unlog ($$) {
return $class->goToPortal( '/', 'logout=1' ); return $class->goToPortal( '/', 'logout=1' );
} }
## @cmethod int redirectFilter(string url, Apache2::Filter f) ## @rmethod protected int redirectFilter(string url, Apache2::Filter f)
# Launch the current HTTP request then redirects the user to $url. # Launch the current HTTP request then redirects the user to $url.
# Used by logout_app and logout_app_sso targets # Used by logout_app and logout_app_sso targets
# @param $url URL to redirect the user # @param $url URL to redirect the user
@ -876,7 +897,7 @@ sub redirectFilter {
return REDIRECT; return REDIRECT;
} }
## @cmethod int status(Apache2::RequestRec $r) ## @rmethod int status(Apache2::RequestRec $r)
# Get the result from the status process and launch a PerlResponseHandler to # Get the result from the status process and launch a PerlResponseHandler to
# display it. # display it.
# @param $r Current request # @param $r Current request
@ -920,20 +941,7 @@ sub status($$) {
# OTHER METHODS # # OTHER METHODS #
################# #################
## @cmethod int initLocalStorage() ## @rmethod protected int cleanLocalStorage()
# Prepare local cache (if not done before by Lemonldap::NG::Common::Conf)
# @return Apache2::Const::DECLINED
sub initLocalStorage {
my ( $class, $r ) = @_;
if ( $localStorage and not $refLocalStorage ) {
eval "use $localStorage;\$refLocalStorage = new $localStorage(\$localStorageOptions);";
$class->lmLog( "Local cache initialization failed: $@", 'error' )
unless ( defined $refLocalStorage );
}
return DECLINED;
}
## @cmethod cleanLocalStorage()
# Clean expired values from the local cache. # Clean expired values from the local cache.
# @return Apache2::Const::DECLINED # @return Apache2::Const::DECLINED
sub cleanLocalStorage { sub cleanLocalStorage {

View File

@ -3,8 +3,6 @@
# #
# @copy 2008 Xavier Guimard <x.guimard@free.fr> # @copy 2008 Xavier Guimard <x.guimard@free.fr>
## @class
# Status process mechanism
package Lemonldap::NG::Handler::Status; package Lemonldap::NG::Handler::Status;
use strict; use strict;
@ -18,7 +16,7 @@ our $activity = [];
our $start = int( time / 60 ); our $start = int( time / 60 );
use constant MN_COUNT => 5; use constant MN_COUNT => 5;
## @fn hashRef portalTab() ## @fn private hashRef portalTab()
# @return Constant hash used to convert error codes into string. # @return Constant hash used to convert error codes into string.
sub portalTab { sub portalTab {
return { return {
@ -55,7 +53,7 @@ eval {
POSIX::setuid( ( getpwnam( $ENV{APACHE_RUN_USER} ) )[2] ); POSIX::setuid( ( getpwnam( $ENV{APACHE_RUN_USER} ) )[2] );
}; };
## @fn void run(string localStorage, hashRef localStorageOptions) ## @rfn void run(string localStorage, hashRef localStorageOptions)
# Main. # Main.
# Reads requests from STDIN to : # Reads requests from STDIN to :
# - update counts # - update counts
@ -213,7 +211,7 @@ sub run {
} }
} }
## @fn string timeUp(int d) ## @rfn private string timeUp(int d)
# Return the time since the status process was launched (last Apache reload). # Return the time since the status process was launched (last Apache reload).
# @param $d Number of minutes since start # @param $d Number of minutes since start
# @return Date in format "day hour minute" # @return Date in format "day hour minute"
@ -226,7 +224,7 @@ sub timeUp {
return "$d\d $h\h $mn\mn"; return "$d\d $h\h $mn\mn";
} }
## @fn void topByCat(string cat,int max) ## @rfn private void topByCat(string cat,int max)
# Display the "top 10" fao a category (OK, REDIRECT,...). # Display the "top 10" fao a category (OK, REDIRECT,...).
# @param $cat Category to display # @param $cat Category to display
# @param $max Number of lines to display # @param $max Number of lines to display
@ -247,7 +245,7 @@ sub topByCat {
print "</pre>\n"; print "</pre>\n";
} }
## @fn void head() ## @rfn private void head()
# Display head of HTML status responses. # Display head of HTML status responses.
sub head { sub head {
print <<"EOF"; print <<"EOF";

View File

@ -15,7 +15,7 @@ our $VERSION = '0.54';
## @cmethod void locationRulesInit(hashRef args) ## @cmethod void locationRulesInit(hashRef args)
# Compile rules. # Compile rules.
# Rules are stored in $args->{locationRules}->{<virtualHost>} that contains # Rules are stored in $args->{locationRules}->{&lt;virtualhost&gt;} that contains
# regexp=>test expressions where : # regexp=>test expressions where :
# - regexp is used to test URIs # - regexp is used to test URIs
# - test contains an expression used to grant the user # - test contains an expression used to grant the user
@ -51,7 +51,7 @@ sub locationRulesInit {
} }
## @cmethod void forgeHeadersInit(hashRef args) ## @cmethod void forgeHeadersInit(hashRef args)
# Create the &$forgeHeaders->{<virtualHost>} subroutines used to insert # Create the &$forgeHeaders->{&lt;virtualhost&gt;} subroutines used to insert
# headers into the HTTP request. # headers into the HTTP request.
# @param $args reference to the configuration hash # @param $args reference to the configuration hash
sub forgeHeadersInit { sub forgeHeadersInit {

View File

@ -138,7 +138,7 @@ sub error {
*error_type = *Lemonldap::NG::Portal::Simple::error_type; *error_type = *Lemonldap::NG::Portal::Simple::error_type;
## @method boolean displayModule(modulename) ## @method boolean displayModule(string modulename)
# Return true if the user can see the module. # Return true if the user can see the module.
# Use for HTML::Template variable. # Use for HTML::Template variable.
# @param $modulename string # @param $modulename string

View File

@ -73,7 +73,7 @@ sub search {
PE_OK; PE_OK;
} }
## @methor int setSessionInfo() ## @method int setSessionInfo()
# 7) Load all parameters included in exportedVars parameter. # 7) Load all parameters included in exportedVars parameter.
# Multi-value parameters are loaded in a single string with # Multi-value parameters are loaded in a single string with
# '; ' separator # '; ' separator