Tidy all the code (make tidy)
This commit is contained in:
parent
8f576d09c2
commit
979d1abe62
|
@ -331,14 +331,15 @@ sub _sub {
|
|||
##@method string extract_lang
|
||||
#@return array of user's preferred languages (two letters)
|
||||
sub extract_lang {
|
||||
my $self = shift;
|
||||
my $self = shift;
|
||||
my @langs = split /,\s*/, ( $ENV{HTTP_ACCEPT_LANGUAGE} || "" );
|
||||
my @res = ();
|
||||
my @res = ();
|
||||
foreach (@langs) {
|
||||
# languages are supposed to be sorted by preference
|
||||
# only 2-letters lang tags are considered
|
||||
my $lang = (split /;/)[0];
|
||||
push @res, $lang if (length($lang) == 2);
|
||||
|
||||
# languages are supposed to be sorted by preference
|
||||
# only 2-letters lang tags are considered
|
||||
my $lang = ( split /;/ )[0];
|
||||
push @res, $lang if ( length($lang) == 2 );
|
||||
}
|
||||
return \@res;
|
||||
}
|
||||
|
@ -359,7 +360,7 @@ sub translate_template {
|
|||
# Test if a translation is available for the selected language
|
||||
# If not available, return the first translated string
|
||||
# <lang en="Please enter your credentials" fr="Merci de vous autentifier"/>
|
||||
foreach (@{ $self->{lang} }) {
|
||||
foreach ( @{ $self->{lang} } ) {
|
||||
if ( $$text_ref =~ m/$_=\"(.*?)\"/ ) {
|
||||
$$text_ref =~ s/<lang.*$_=\"(.*?)\".*?\/>/$1/gx;
|
||||
return;
|
||||
|
|
|
@ -23,11 +23,11 @@ our $msg;
|
|||
# @param mode Crypt::Rijndael constant
|
||||
# @return Lemonldap::NG::Common::Crypto object
|
||||
sub new {
|
||||
my ($class, $key, $mode) = @_;
|
||||
my ( $class, $key, $mode ) = @_;
|
||||
$mode ||= Crypt::Rijndael::MODE_CBC();
|
||||
my $self = {
|
||||
key => $key,
|
||||
mode => $mode,
|
||||
key => $key,
|
||||
mode => $mode,
|
||||
ciphers => {}
|
||||
};
|
||||
return bless $self, $class;
|
||||
|
@ -40,10 +40,10 @@ sub new {
|
|||
# @param key that secondary key
|
||||
# @return Crypt::Rijndael object
|
||||
sub _getCipher {
|
||||
my ($self, $key) = @_;
|
||||
my ( $self, $key ) = @_;
|
||||
$key ||= "";
|
||||
$self->{ciphers}->{$key} ||=
|
||||
Crypt::Rijndael->new(($self->{key})^$key, $self->{mode});
|
||||
Crypt::Rijndael->new( ( $self->{key} ) ^ $key, $self->{mode} );
|
||||
return $self->{ciphers}->{$key};
|
||||
}
|
||||
|
||||
|
@ -56,11 +56,9 @@ sub encrypt {
|
|||
|
||||
# pad $data so that its length be multiple of 16 bytes
|
||||
my $l = bytes::length($data) % 16;
|
||||
$data .= "\0" x ( 16 - $l ) unless ($l == 0);
|
||||
$data .= "\0" x ( 16 - $l ) unless ( $l == 0 );
|
||||
|
||||
eval {
|
||||
$data = encode_base64( $self->_getCipher->encrypt( $data ) );
|
||||
};
|
||||
eval { $data = encode_base64( $self->_getCipher->encrypt($data) ); };
|
||||
if ($@) {
|
||||
$msg = "Crypt::Rijndael error : $@";
|
||||
return undef;
|
||||
|
@ -77,7 +75,7 @@ sub encrypt {
|
|||
# @param data datas to decrypt in Base64 format
|
||||
# @return decrypted datas
|
||||
sub decrypt {
|
||||
my ($self, $data) = @_;
|
||||
my ( $self, $data ) = @_;
|
||||
$data =~ s/%2B/\+/ig;
|
||||
$data =~ s/%2F/\//ig;
|
||||
$data =~ s/%3D/=/ig;
|
||||
|
@ -104,8 +102,8 @@ sub decrypt {
|
|||
# @param key optional secondary key
|
||||
# @return encrypted datas in hexadecimal data
|
||||
sub encryptHex {
|
||||
my ($self, $data, $key) = @_;
|
||||
return _cryptHex($self, $data, $key, "encrypt")
|
||||
my ( $self, $data, $key ) = @_;
|
||||
return _cryptHex( $self, $data, $key, "encrypt" );
|
||||
}
|
||||
|
||||
## @method string decryptHex(string data, string key)
|
||||
|
@ -116,8 +114,8 @@ sub encryptHex {
|
|||
# @param key optional secondary key
|
||||
# @return decrypted datas in hexadecimal data
|
||||
sub decryptHex {
|
||||
my ($self, $data, $key) = @_;
|
||||
return _cryptHex($self, $data, $key, "decrypt")
|
||||
my ( $self, $data, $key ) = @_;
|
||||
return _cryptHex( $self, $data, $key, "decrypt" );
|
||||
}
|
||||
|
||||
## @method private string _cryptHex (string data, string key, string sub)
|
||||
|
@ -125,18 +123,21 @@ sub decryptHex {
|
|||
# @param data datas to decrypt
|
||||
# @param key secondary key
|
||||
# @param sub may be "encrypt" or "decrypt"
|
||||
# @return decrypted datas in hexadecimal data
|
||||
# @return decrypted datas in hexadecimal data
|
||||
sub _cryptHex {
|
||||
my ($self, $data, $key, $sub) = @_;
|
||||
unless ($data =~ /^([0-9a-fA-F]{2})*$/) {
|
||||
$msg = "Lemonldap::NG::Common::Crypto::${sub}Hex error : data is not hexadecimal";
|
||||
my ( $self, $data, $key, $sub ) = @_;
|
||||
unless ( $data =~ /^([0-9a-fA-F]{2})*$/ ) {
|
||||
$msg =
|
||||
"Lemonldap::NG::Common::Crypto::${sub}Hex error : data is not hexadecimal";
|
||||
return undef;
|
||||
}
|
||||
|
||||
# $data's length must be multiple of 32,
|
||||
# since Rijndael requires data length multiple of 16
|
||||
unless (bytes::length($data) % 32 == 0) {
|
||||
$msg = "Lemonldap::NG::Common::Crypto::${sub}Hex error : data length must be multiple of 32";
|
||||
return undef;
|
||||
unless ( bytes::length($data) % 32 == 0 ) {
|
||||
$msg =
|
||||
"Lemonldap::NG::Common::Crypto::${sub}Hex error : data length must be multiple of 32";
|
||||
return undef;
|
||||
}
|
||||
$data = pack "H*", $data;
|
||||
eval { $data = $self->_getCipher($key)->$sub($data); };
|
||||
|
|
|
@ -89,11 +89,11 @@ SKIP: {
|
|||
ok( scalar(@$lang) == 0, 'extract_lang 1 with void "Accept-language"' );
|
||||
|
||||
my $cgi2;
|
||||
$ENV{SCRIPT_NAME} = '/test.pl';
|
||||
$ENV{SCRIPT_FILENAME} = 't/20-Common-CGI.t';
|
||||
$ENV{REQUEST_METHOD} = 'GET';
|
||||
$ENV{REQUEST_URI} = '/';
|
||||
$ENV{QUERY_STRING} = '';
|
||||
$ENV{SCRIPT_NAME} = '/test.pl';
|
||||
$ENV{SCRIPT_FILENAME} = 't/20-Common-CGI.t';
|
||||
$ENV{REQUEST_METHOD} = 'GET';
|
||||
$ENV{REQUEST_URI} = '/';
|
||||
$ENV{QUERY_STRING} = '';
|
||||
$ENV{HTTP_ACCEPT_LANGUAGE} = 'fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3';
|
||||
ok( ( $cgi2 = Lemonldap::NG::Common::CGI->new() ), 'New CGI' );
|
||||
ok( $lang = $cgi2->extract_lang(), 'extract_lang' );
|
||||
|
|
|
@ -33,11 +33,9 @@ foreach my $i ( 1 .. 17 ) {
|
|||
"Test of base64 encrypting with $i characters string" );
|
||||
}
|
||||
|
||||
my $data = md5_hex(rand);
|
||||
my $data = md5_hex(rand);
|
||||
my $secondKey = md5(rand);
|
||||
ok(
|
||||
$c->decryptHex(
|
||||
$c->encryptHex( $data, $secondKey ),
|
||||
$secondKey ) eq $data,
|
||||
$c->decryptHex( $c->encryptHex( $data, $secondKey ), $secondKey ) eq $data,
|
||||
"Test of hexadecimal encrypting"
|
||||
);
|
||||
|
|
|
@ -25,7 +25,7 @@ require POSIX;
|
|||
use CGI::Util 'expires';
|
||||
use constant SAFEWRAP => ( Safe->can("wrap_code_ref") ? 1 : 0 );
|
||||
use constant UNPROTECT => 1;
|
||||
use constant SKIP => 2;
|
||||
use constant SKIP => 2;
|
||||
|
||||
#inherits Cache::Cache
|
||||
#inherits Apache::Session
|
||||
|
@ -85,9 +85,9 @@ BEGIN {
|
|||
qw( MP OK REDIRECT FORBIDDEN DONE DECLINED SERVER_ERROR
|
||||
$useRedirectOnForbidden $useRedirectOnError )
|
||||
],
|
||||
post => [qw($transform postFilter)],
|
||||
cda => ['$cda'],
|
||||
cookie => [
|
||||
post => [qw($transform postFilter)],
|
||||
cda => ['$cda'],
|
||||
cookie => [
|
||||
qw(
|
||||
$cookieName $https $httpOnly $cookieExpiration
|
||||
$securedCookie $key $cipher
|
||||
|
@ -163,7 +163,7 @@ BEGIN {
|
|||
threads::shared::share($key);
|
||||
threads::shared::share($headerList);
|
||||
};
|
||||
print "eval error: $@" if($@);
|
||||
print "eval error: $@" if ($@);
|
||||
}
|
||||
elsif ( MP() == 1 ) {
|
||||
require Apache;
|
||||
|
@ -280,11 +280,11 @@ sub lmUnsetHeaderIn {
|
|||
my ( $class, $r, @headers ) = splice @_;
|
||||
foreach my $h (@headers) {
|
||||
if ( MP() == 2 ) {
|
||||
$r->headers_in->unset( $h );
|
||||
$r->headers_in->unset($h);
|
||||
}
|
||||
elsif ( MP() == 1 ) {
|
||||
$r->header_in( $h => "" )
|
||||
if ( $r->header_in($h) );
|
||||
if ( $r->header_in($h) );
|
||||
}
|
||||
$class->lmLog( "Unset header $h", 'debug' );
|
||||
}
|
||||
|
@ -656,10 +656,11 @@ sub defaultValuesInit {
|
|||
# Warning: first start of handler load values from MyHanlder.pm
|
||||
# and lemonldap-ng.ini
|
||||
# These values should be erased by global configuration!
|
||||
$cookieName = $args->{cookieName} || $cookieName || 'lemonldap';
|
||||
$securedCookie =
|
||||
defined( $args->{securedCookie} ) ? $args->{securedCookie} :
|
||||
defined($securedCookie) ? $securedCookie : 1;
|
||||
$cookieName = $args->{cookieName} || $cookieName || 'lemonldap';
|
||||
$securedCookie =
|
||||
defined( $args->{securedCookie} ) ? $args->{securedCookie}
|
||||
: defined($securedCookie) ? $securedCookie
|
||||
: 1;
|
||||
$whatToTrace = $args->{whatToTrace} || $whatToTrace || 'uid';
|
||||
$whatToTrace =~ s/\$//g;
|
||||
$https = defined($https) ? $https : $args->{https};
|
||||
|
@ -681,10 +682,11 @@ sub defaultValuesInit {
|
|||
defined($useSafeJail)
|
||||
? $useSafeJail
|
||||
: $args->{useSafeJail};
|
||||
$key ||= 'lemonldap-ng-key';
|
||||
$key ||= 'lemonldap-ng-key';
|
||||
$cipher ||= Lemonldap::NG::Common::Crypto->new($key);
|
||||
if ($args->{key} && ($args->{key} ne $key) ) {
|
||||
$key = $args->{key};
|
||||
|
||||
if ( $args->{key} && ( $args->{key} ne $key ) ) {
|
||||
$key = $args->{key};
|
||||
$cipher = Lemonldap::NG::Common::Crypto->new($key);
|
||||
}
|
||||
1;
|
||||
|
@ -858,14 +860,14 @@ sub goToPortal {
|
|||
# @return Value of the cookie if found, 0 else
|
||||
sub fetchId {
|
||||
my $t = lmHeaderIn( $apacheRequest, 'Cookie' );
|
||||
my $lookForHttpCookie =
|
||||
$securedCookie =~ /^(2|3)$/ && $https->{_} == 0 ;
|
||||
my $value = $lookForHttpCookie ?
|
||||
( $t =~ /${cookieName}http=([^,; ]+)/o ? $1 : 0 ) :
|
||||
( $t =~ /$cookieName=([^,; ]+)/o ? $1 : 0 ) ;
|
||||
my $lookForHttpCookie = $securedCookie =~ /^(2|3)$/ && $https->{_} == 0;
|
||||
my $value =
|
||||
$lookForHttpCookie
|
||||
? ( $t =~ /${cookieName}http=([^,; ]+)/o ? $1 : 0 )
|
||||
: ( $t =~ /$cookieName=([^,; ]+)/o ? $1 : 0 );
|
||||
|
||||
$value = $cipher->decryptHex($value, "http")
|
||||
if ( $value && $lookForHttpCookie && $securedCookie == 3 );
|
||||
$value = $cipher->decryptHex( $value, "http" )
|
||||
if ( $value && $lookForHttpCookie && $securedCookie == 3 );
|
||||
return $value;
|
||||
}
|
||||
|
||||
|
@ -882,7 +884,7 @@ sub retrieveSession {
|
|||
|
||||
# 2. search in the local cache if exists
|
||||
return 1
|
||||
if ( $refLocalStorage and $datas = $refLocalStorage->get($id) );
|
||||
if ( $refLocalStorage and $datas = $refLocalStorage->get($id) );
|
||||
|
||||
# 3. search in the central cache
|
||||
my %h;
|
||||
|
@ -900,7 +902,7 @@ sub retrieveSession {
|
|||
|
||||
# Store the session in local storage
|
||||
$refLocalStorage->set( $id, $datas, "10 minutes" )
|
||||
if ($refLocalStorage);
|
||||
if ($refLocalStorage);
|
||||
|
||||
untie %h;
|
||||
$datasUpdate = time();
|
||||
|
@ -967,19 +969,22 @@ sub run ($$) {
|
|||
}
|
||||
|
||||
my $id;
|
||||
|
||||
# Try to recover cookie and user session
|
||||
if ( $id = $class->fetchId and $class->retrieveSession($id) ) {
|
||||
|
||||
# AUTHENTICATION done
|
||||
|
||||
my $kc = keys %$datas; # in order to detect new local macro
|
||||
my $kc = keys %$datas; # in order to detect new local macro
|
||||
|
||||
# ACCOUNTING (1. Inform Apache)
|
||||
$class->lmSetApacheUser( $apacheRequest, $datas->{$whatToTrace} );
|
||||
|
||||
# AUTHORIZATION
|
||||
return $class->forbidden($uri)
|
||||
unless ( $class->grant($uri) );
|
||||
$class->updateStatus( $datas->{$whatToTrace}, $apacheRequest->uri, 'OK' );
|
||||
unless ( $class->grant($uri) );
|
||||
$class->updateStatus( $datas->{$whatToTrace},
|
||||
$apacheRequest->uri, 'OK' );
|
||||
|
||||
# ACCOUNTING (2. Inform remote application)
|
||||
$class->sendHeaders;
|
||||
|
@ -994,9 +999,8 @@ sub run ($$) {
|
|||
$class->hideCookie;
|
||||
|
||||
# Log
|
||||
$apacheRequest->push_handlers(
|
||||
PerlLogHandler => sub { $class->logGranted( $uri, $datas ); DECLINED },
|
||||
);
|
||||
$apacheRequest->push_handlers( PerlLogHandler =>
|
||||
sub { $class->logGranted( $uri, $datas ); DECLINED }, );
|
||||
|
||||
# Catch POST rules
|
||||
$class->transformUri($uri);
|
||||
|
@ -1005,6 +1009,7 @@ sub run ($$) {
|
|||
}
|
||||
|
||||
elsif ( $protection == UNPROTECT ) {
|
||||
|
||||
# Ignore unprotected URIs
|
||||
$class->lmLog( "No valid session but unprotected access", "debug" );
|
||||
$class->updateStatus( $apacheRequest->connection->remote_ip,
|
||||
|
@ -1015,9 +1020,11 @@ sub run ($$) {
|
|||
}
|
||||
|
||||
else {
|
||||
|
||||
# Redirect user to the portal
|
||||
$class->lmLog( "$class: No cookie found" , 'info' )
|
||||
unless ($id);
|
||||
$class->lmLog( "$class: No cookie found", 'info' )
|
||||
unless ($id);
|
||||
|
||||
# if the cookie was fetched, a log is sent by retrieveSession()
|
||||
$class->updateStatus( $apacheRequest->connection->remote_ip,
|
||||
$apacheRequest->uri, $id ? 'EXPIRED' : 'REDIRECT' );
|
||||
|
@ -1406,7 +1413,7 @@ sub sendHeaders {
|
|||
# that would not be caught if access rule is unprotect or skip
|
||||
sub cleanHeaders {
|
||||
my ($class) = splice @_;
|
||||
$class->lmUnsetHeaderIn( $apacheRequest, @{ $headerList } );
|
||||
$class->lmUnsetHeaderIn( $apacheRequest, @{$headerList} );
|
||||
}
|
||||
|
||||
## @rmethod protected int isUnprotected()
|
||||
|
|
|
@ -150,7 +150,6 @@ sub cleanHeaders {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
## @rmethod protected int isUnprotected()
|
||||
# @return 0 if URI is protected,
|
||||
# UNPROTECT if it is unprotected by "unprotect",
|
||||
|
@ -191,17 +190,17 @@ sub grant {
|
|||
# Get user cookies and search for Lemonldap::NG cookie.
|
||||
# @return Value of the cookie if found, 0 else
|
||||
sub fetchId {
|
||||
my $t = lmHeaderIn( $apacheRequest, 'Cookie' );
|
||||
my $vhost = $apacheRequest->hostname;
|
||||
my $lookForHttpCookie =
|
||||
$securedCookie =~ /^(2|3)$/
|
||||
&& !( defined( $https->{$vhost} ) ? $https->{$vhost} : $https->{_} );
|
||||
my $value = $lookForHttpCookie ?
|
||||
( $t =~ /${cookieName}http=([^,; ]+)/o ? $1 : 0 ) :
|
||||
( $t =~ /$cookieName=([^,; ]+)/o ? $1 : 0 ) ;
|
||||
my $t = lmHeaderIn( $apacheRequest, 'Cookie' );
|
||||
my $vhost = $apacheRequest->hostname;
|
||||
my $lookForHttpCookie = $securedCookie =~ /^(2|3)$/
|
||||
&& !( defined( $https->{$vhost} ) ? $https->{$vhost} : $https->{_} );
|
||||
my $value =
|
||||
$lookForHttpCookie
|
||||
? ( $t =~ /${cookieName}http=([^,; ]+)/o ? $1 : 0 )
|
||||
: ( $t =~ /$cookieName=([^,; ]+)/o ? $1 : 0 );
|
||||
|
||||
$value = $cipher->decryptHex($value, "http")
|
||||
if ( $value && $lookForHttpCookie && $securedCookie == 3 );
|
||||
$value = $cipher->decryptHex( $value, "http" )
|
||||
if ( $value && $lookForHttpCookie && $securedCookie == 3 );
|
||||
return $value;
|
||||
}
|
||||
|
||||
|
|
|
@ -170,8 +170,10 @@ sub confNode {
|
|||
# be translated
|
||||
# 2. if a regexp comment or perl expression
|
||||
# comment exists, it is set as text
|
||||
my $text = /^\(\?#(.*?)\)/ ? $1 :
|
||||
/^(.*?)##(.+)$/ ? $2 : $_ ;
|
||||
my $text =
|
||||
/^\(\?#(.*?)\)/ ? $1
|
||||
: /^(.*?)##(.+)$/ ? $2
|
||||
: $_;
|
||||
|
||||
$res .= $self->li($id)
|
||||
. $self->span(
|
||||
|
|
|
@ -780,12 +780,13 @@ sub extractFormInfo {
|
|||
# IDP list
|
||||
my @list = ();
|
||||
foreach ( keys %{ $self->{_idpList} } ) {
|
||||
push @list, {
|
||||
push @list,
|
||||
{
|
||||
val => $_,
|
||||
name => $self->{_idpList}->{$_}->{name}
|
||||
};
|
||||
};
|
||||
}
|
||||
$self->{list} = \@list;
|
||||
$self->{list} = \@list;
|
||||
|
||||
# Delete existing IDP resolution cookie
|
||||
push @{ $self->{cookie} },
|
||||
|
|
|
@ -76,8 +76,8 @@ sub display {
|
|||
elsif ( $self->{error} == PE_REDIRECT ) {
|
||||
$skinfile = "redirect.tpl";
|
||||
%templateParams = (
|
||||
URL => $self->{urldc},
|
||||
HIDDEN_INPUTS => $self->buildHiddenForm(),
|
||||
URL => $self->{urldc},
|
||||
HIDDEN_INPUTS => $self->buildHiddenForm(),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -92,13 +92,13 @@ sub display {
|
|||
utf8::decode($auth_user);
|
||||
|
||||
%templateParams = (
|
||||
AUTH_USER => $auth_user,
|
||||
AUTOCOMPLETE => $self->{portalAutocomplete},
|
||||
NEWWINDOW => $self->{portalOpenLinkInNewWindow},
|
||||
AUTH_ERROR => $self->error( $self->{menuError} ),
|
||||
AUTH_ERROR_TYPE => $self->error_type( $self->{menuError} ),
|
||||
DISPLAY_TAB => $self->{menuDisplayTab},
|
||||
LOGOUT_URL => "$ENV{SCRIPT_NAME}?logout=1",
|
||||
AUTH_USER => $auth_user,
|
||||
AUTOCOMPLETE => $self->{portalAutocomplete},
|
||||
NEWWINDOW => $self->{portalOpenLinkInNewWindow},
|
||||
AUTH_ERROR => $self->error( $self->{menuError} ),
|
||||
AUTH_ERROR_TYPE => $self->error_type( $self->{menuError} ),
|
||||
DISPLAY_TAB => $self->{menuDisplayTab},
|
||||
LOGOUT_URL => "$ENV{SCRIPT_NAME}?logout=1",
|
||||
REQUIRE_OLDPASSWORD => $self->{portalRequireOldPassword},
|
||||
HIDE_OLDPASSWORD =>
|
||||
0, # Do not hide old password if it is required
|
||||
|
|
|
@ -238,8 +238,7 @@ sub _openIDResponse {
|
|||
$self->info(
|
||||
'<h3>'
|
||||
. sprintf(
|
||||
$self->msg(PM_OPENID_EXCHANGE),
|
||||
$data->{trust_root}
|
||||
$self->msg(PM_OPENID_EXCHANGE), $data->{trust_root}
|
||||
)
|
||||
. "</h3>"
|
||||
);
|
||||
|
|
|
@ -194,9 +194,9 @@ sub issuerForUnAuthUser {
|
|||
|
||||
# Create a back link on SP displayed on login page
|
||||
my $html =
|
||||
"<a href=\"" . $self->referer() . "\">"
|
||||
. $self->msg(PM_BACKTOSP)
|
||||
. "</a>";
|
||||
"<a href=\""
|
||||
. $self->referer() . "\">"
|
||||
. $self->msg(PM_BACKTOSP) . "</a>";
|
||||
$self->loginInfo($html);
|
||||
|
||||
return PE_OK;
|
||||
|
@ -1708,11 +1708,7 @@ sub issuerForAuthUser {
|
|||
. " width=\"0\" height=\"0\" frameborder=\"0\">"
|
||||
. "</iframe>";
|
||||
|
||||
$self->info(
|
||||
"<h3>"
|
||||
. $self->msg(PM_CDC_WRITER)
|
||||
. "</h3>"
|
||||
);
|
||||
$self->info( "<h3>" . $self->msg(PM_CDC_WRITER) . "</h3>" );
|
||||
|
||||
$self->info($cdc_iframe);
|
||||
}
|
||||
|
|
|
@ -91,8 +91,7 @@ sub sregHook {
|
|||
);
|
||||
|
||||
$self->info(
|
||||
'<h3>' . sprintf( $self->msg(PM_OPENID_RPNS), $k ) . '</h3>'
|
||||
);
|
||||
'<h3>' . sprintf( $self->msg(PM_OPENID_RPNS), $k ) . '</h3>' );
|
||||
return ( 0, {} );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -168,20 +168,16 @@ sub userBind {
|
|||
|
||||
# Get expiration warning and graces
|
||||
if ( $resp->grace_authentications_remaining ) {
|
||||
$self->{portal}->info(
|
||||
"<h3>"
|
||||
$self->{portal}->info( "<h3>"
|
||||
. $resp->grace_authentications_remaining . " "
|
||||
. $self->msg(PM_PP_GRACE)
|
||||
. "</h3>"
|
||||
);
|
||||
. "</h3>" );
|
||||
}
|
||||
if ( $resp->time_before_expiration ) {
|
||||
$self->{portal}->info(
|
||||
"<h3>"
|
||||
$self->{portal}->info( "<h3>"
|
||||
. $resp->time_before_expiration . " "
|
||||
. $self->msg(PM_PP_EXP_WARNING)
|
||||
. "</h3>"
|
||||
);
|
||||
. "</h3>" );
|
||||
}
|
||||
|
||||
my $pp_error = $resp->pp_error;
|
||||
|
|
|
@ -2637,8 +2637,7 @@ sub sendLogoutRequestToProviders {
|
|||
|
||||
# Header of the block which will be displayed to the user, if needed.
|
||||
$info .= '<h3>'
|
||||
. $self->msg (Lemonldap::NG::Portal::Simple::PM_SAML_SPLOGOUT)
|
||||
. '</h3>'
|
||||
. $self->msg(Lemonldap::NG::Portal::Simple::PM_SAML_SPLOGOUT) . '</h3>'
|
||||
. '<table class="sloState">';
|
||||
|
||||
# Foreach SP found in session, get it from configuration, and send the
|
||||
|
@ -2746,7 +2745,7 @@ sub checkDestination {
|
|||
|
||||
# Retrieve full URL
|
||||
my $portal = $self->{portal};
|
||||
$portal =~ s#^(https?://[^/]+)/.*#$1#; # remove path of portal URL
|
||||
$portal =~ s#^(https?://[^/]+)/.*#$1#; # remove path of portal URL
|
||||
$url = $portal . $url;
|
||||
|
||||
# Compare Destination and URL
|
||||
|
|
|
@ -16,7 +16,7 @@ our $VERSION = '1.2.0';
|
|||
# @return Message string in the first matching language
|
||||
sub msg {
|
||||
my ( $msg, $lang ) = splice @_;
|
||||
foreach ( @{ $lang } ) {
|
||||
foreach ( @{$lang} ) {
|
||||
if ( __PACKAGE__->can("msg_$_") ) {
|
||||
return &{"msg_$_"}->[$msg];
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ sub msg {
|
|||
sub error {
|
||||
my ( $error, $lang ) = splice @_;
|
||||
$error = 0 if ( $error < 0 );
|
||||
foreach ( @{ $lang } ) {
|
||||
foreach ( @{$lang} ) {
|
||||
if ( __PACKAGE__->can("error_$_") ) {
|
||||
return &{"error_$_"}->[$error];
|
||||
}
|
||||
|
|
|
@ -32,13 +32,13 @@ foreach ( keys %tr_err ) {
|
|||
|
||||
my $p1 = bless {}, 'Lemonldap::NG::Portal::Simple';
|
||||
$p1->{error} = 10;
|
||||
$p1->{lang} = ['en', 'fr'];
|
||||
$p1->{lang} = [ 'en', 'fr' ];
|
||||
my $p2 = bless {}, 'Lemonldap::NG::Portal::Simple';
|
||||
$p2->{error} = 5;
|
||||
$p2->{lang} = [];
|
||||
$p2->{lang} = [];
|
||||
my $p3 = bless {}, 'Lemonldap::NG::Portal::Simple';
|
||||
$p3->{error} = 10;
|
||||
$p3->{lang} = ['fr', 'es', 'en'];
|
||||
$p3->{lang} = [ 'fr', 'es', 'en' ];
|
||||
|
||||
ok( $p1->error() eq $p2->error(10), 'HTTP_ACCEPT_LANGUAGE mechanism 1' );
|
||||
ok( $p1->error() ne $p2->error(), 'HTTP_ACCEPT_LANGUAGE mechanism 2' );
|
||||
|
|
Loading…
Reference in New Issue
Block a user