| 1 | package Lemonldap::NG::Handler::Main::Init; | ||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||
| 3 | 29 | our $VERSION = '2.19.0'; | |||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||
| 5 | package Lemonldap::NG::Handler::Main; | ||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||
| 7 | 29 | ▶ | use strict; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 8 | 29 | ▶ | use Lemonldap::NG::Common::Conf; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||
| 10 | ## @imethod void init(hashRef args) | ||||||||||||||||||||||||||||||||||
| 11 | # Read parameters and build the Lemonldap::NG::Common::Conf object. | ||||||||||||||||||||||||||||||||||
| 12 | # @param $args hash containing parameters | ||||||||||||||||||||||||||||||||||
| 13 | 45 | ▶ | sub init($$) { | ||||||||||||||||||||||||||||||||
|
Subroutine
init: called CC=7 SCAR=20.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 14 | 45 | my ( $class, $args ) = @_; | |||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||
| 16 | # According to doc, localStorage can be declared in $args root, | ||||||||||||||||||||||||||||||||||
| 17 | # but it must be in $args->{configStorage} | ||||||||||||||||||||||||||||||||||
| 18 | 45 | foreach (qw(localStorage localStorageOptions)) { | |||||||||||||||||||||||||||||||||
| 19 | 90 | ▶ | $args->{configStorage}->{$_} ||= $args->{$_}; | ||||||||||||||||||||||||||||||||
|
Condition100%3/3
$args->{"configStorage"}{$_} ||= $args->{$_}
MC/DC100%2/2
$args->{"configStorage"}{$_} ||= $args->{$_}
$args->{"configStorage"}{$_}
$args->{$_}
Truth table100%3/3
A ||= B
A= $args->{"configStorage"}{$_}B= $args->{$_}
| |||||||||||||||||||||||||||||||||||
| 20 | } | ||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||
| 22 | 45 | my $tmp = Lemonldap::NG::Common::Conf->new( $args->{configStorage} ); | |||||||||||||||||||||||||||||||||
| 23 | 45 | ▶ | unless ( $class->confAcc($tmp) ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 24 | 0 | die( "$class : unable to build configuration: " | |||||||||||||||||||||||||||||||||
| 25 | . "$Lemonldap::NG::Common::Conf::msg" ); | ||||||||||||||||||||||||||||||||||
| 26 | } | ||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||
| 28 | # Merge local configuration parameters so that params defined in | ||||||||||||||||||||||||||||||||||
| 29 | # startup parameters have precedence over lemonldap-ng.ini params | ||||||||||||||||||||||||||||||||||
| 30 | $class->localConfig( | ||||||||||||||||||||||||||||||||||
| 31 | 45 | { %{ $class->confAcc->getLocalConf('handler') }, %{$args} } ); | |||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||
| 33 | 45 | ▶ | $class->checkTime( $class->localConfig->{checkTime} || $class->checkTime ); | ||||||||||||||||||||||||||||||||
|
Condition66%2/3
$class->localConfig->{'checkTime'} || $class->checkTime
MC/DC0%0/2
$class->localConfig->{'checkTime'} || $class->checkTime
$class->localConfig->{'checkTime'}
$class->checkTime
Truth table66%2/3
A || B
A= $class->localConfig->{'checkTime'}B= $class->checkTime
| |||||||||||||||||||||||||||||||||||
| 34 | 45 | ▶ | $class->checkMsg( $class->localConfig->{checkMsg} || $class->checkMsg ); | ||||||||||||||||||||||||||||||||
|
Condition33%1/3
$class->localConfig->{'checkMsg'} || $class->checkMsg
MC/DC0%0/2
$class->localConfig->{'checkMsg'} || $class->checkMsg
$class->localConfig->{'checkMsg'}
$class->checkMsg
Truth table33%1/3
A || B
A= $class->localConfig->{'checkMsg'}B= $class->checkMsg
| |||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||
| 36 | # Few actions that must be done at server startup: | ||||||||||||||||||||||||||||||||||
| 37 | # * set log level for Lemonldap::NG logs | ||||||||||||||||||||||||||||||||||
| 38 | 45 | $class->logLevelInit(); | |||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||
| 40 | # * set server signature | ||||||||||||||||||||||||||||||||||
| 41 | 45 | ▶ | $class->serverSignatureInit unless ( $class->localConfig->{hideSignature} ); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 42 | 45 | 1; | |||||||||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||
| 45 | # @method void logLevelInit | ||||||||||||||||||||||||||||||||||
| 46 | # Set log level for Lemonldap::NG logs | ||||||||||||||||||||||||||||||||||
| 47 | 48 | ▶ | sub logLevelInit { | ||||||||||||||||||||||||||||||||
|
Subroutine
logLevelInit: called CC=11 SCAR=25.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 48 | 48 | my ($class) = @_; | |||||||||||||||||||||||||||||||||
| 49 | my $logger = $class->localConfig->{logger} ||= | ||||||||||||||||||||||||||||||||||
| 50 | 48 | ▶ | $ENV{LLNG_DEFAULTLOGGER} || $class->defaultLogger; | ||||||||||||||||||||||||||||||||
|
Condition50%3/6
$class->localConfig->{"logger"} ||= $ENV{"LLNG_DEFAULTLOGGER"} || $class->defaultLogger
$ENV{'LLNG_DEFAULTLOGGER'} || $class->defaultLogger
MC/DC0%0/3
$class->localConfig->{"logger"} ||= $ENV{"LLNG_DEFAULTLOGGER"} || $class->defaultLogger
$class->localConfig->{"logger"}
$ENV{'LLNG_DEFAULTLOGGER'}
$class->defaultLogger
Truth table0%0/4
A ||= B || C
A= $class->localConfig->{"logger"}B= $ENV{'LLNG_DEFAULTLOGGER'}C= $class->defaultLogger
| |||||||||||||||||||||||||||||||||||
| 51 | 48 | eval "require $logger"; | |||||||||||||||||||||||||||||||||
| 52 | 48 | ▶ | die $@ if ($@); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 53 | 48 | my $err; | |||||||||||||||||||||||||||||||||
| 54 | 48 | ▶ | unless ( $class->localConfig->{logLevel} =~ | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 55 | /^(?:debug|info|notice|warn|error)$/ ) | ||||||||||||||||||||||||||||||||||
| 56 | { | ||||||||||||||||||||||||||||||||||
| 57 | $err = | ||||||||||||||||||||||||||||||||||
| 58 | 'Bad logLevel value \'' | ||||||||||||||||||||||||||||||||||
| 59 | . $class->localConfig->{logLevel} | ||||||||||||||||||||||||||||||||||
| 60 | 1 | . "', switching to 'info'\n"; | |||||||||||||||||||||||||||||||||
| 61 | 1 | $class->localConfig->{logLevel} = 'info'; | |||||||||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||||||||
| 63 | 48 | $class->logger( $logger->new( $class->localConfig ) ); | |||||||||||||||||||||||||||||||||
| 64 | 48 | ▶ | $class->logger->error($err) if $err; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 65 | 48 | $class->logger->debug("Logger $logger loaded"); | |||||||||||||||||||||||||||||||||
| 66 | 48 | ▶ | $logger = $class->localConfig->{userLogger} || $logger; | ||||||||||||||||||||||||||||||||
|
Condition66%2/3
$class->localConfig->{'userLogger'} || $logger
MC/DC0%0/2
$class->localConfig->{'userLogger'} || $logger
$class->localConfig->{'userLogger'}
$logger
Truth table66%2/3
A || B
A= $class->localConfig->{'userLogger'}B= $logger
| |||||||||||||||||||||||||||||||||||
| 67 | 48 | eval "require $logger"; | |||||||||||||||||||||||||||||||||
| 68 | 48 | ▶ | die $@ if ($@); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 69 | 48 | require Lemonldap::NG::Common::Logger::_Duplicate; | |||||||||||||||||||||||||||||||||
| 70 | 48 | $class->userLogger( | |||||||||||||||||||||||||||||||||
| 71 | Lemonldap::NG::Common::Logger::_Duplicate->new( | ||||||||||||||||||||||||||||||||||
| 72 | $class->localConfig, | ||||||||||||||||||||||||||||||||||
| 73 | user => 1, | ||||||||||||||||||||||||||||||||||
| 74 | logger => $logger, | ||||||||||||||||||||||||||||||||||
| 75 | dup => $class->logger | ||||||||||||||||||||||||||||||||||
| 76 | ) | ||||||||||||||||||||||||||||||||||
| 77 | ); | ||||||||||||||||||||||||||||||||||
| 78 | 48 | $class->logger->debug("User logger $logger loaded"); | |||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||
| 80 | my $auditlogger = | ||||||||||||||||||||||||||||||||||
| 81 | $ENV{LLNG_AUDITLOGGER} | ||||||||||||||||||||||||||||||||||
| 82 | || $class->localConfig->{auditLogger} | ||||||||||||||||||||||||||||||||||
| 83 | 48 | ▶ | || "Lemonldap::NG::Common::AuditLogger::UserLoggerCompat"; | ||||||||||||||||||||||||||||||||
|
Condition40%2/5
$ENV{'LLNG_AUDITLOGGER'} || $class->localConfig->{'auditLogger'} || 'Lemonldap::NG::Common::AuditLogger::UserLoggerCompat'
$ENV{"LLNG_AUDITLOGGER"} or $class->localConfig->{"auditLogger"}
MC/DC0%0/2
$ENV{'LLNG_AUDITLOGGER'} || $class->localConfig->{'auditLogger'} || 'Lemonldap::NG::Common::AuditLogger::UserLoggerCompat'
$ENV{"LLNG_AUDITLOGGER"}
$class->localConfig->{"auditLogger"}
Truth table33%1/3
A or B
A= $ENV{"LLNG_AUDITLOGGER"}B= $class->localConfig->{"auditLogger"}
| |||||||||||||||||||||||||||||||||||
| 84 | 48 | eval "require $auditlogger"; | |||||||||||||||||||||||||||||||||
| 85 | 48 | ▶ | die $@ if ($@); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 86 | 48 | $class->_auditLogger( $auditlogger->new($class) ); | |||||||||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||
| 89 | # @method void serverSignatureInit | ||||||||||||||||||||||||||||||||||
| 90 | # adapt server signature | ||||||||||||||||||||||||||||||||||
| 91 | 45 | ▶ | sub serverSignatureInit { | ||||||||||||||||||||||||||||||||
|
Subroutine
serverSignatureInit: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 92 | 45 | my $class = shift; | |||||||||||||||||||||||||||||||||
| 93 | 45 | require Lemonldap::NG::Handler; | |||||||||||||||||||||||||||||||||
| 94 | 45 | my $version = $Lemonldap::NG::Handler::VERSION; | |||||||||||||||||||||||||||||||||
| 95 | 45 | $class->setServerSignature("Lemonldap::NG/$version"); | |||||||||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||
| 98 | 29 | 1; | |||||||||||||||||||||||||||||||||