Commit affdc1f5 authored by Xavier Guimard's avatar Xavier Guimard

SOAP configuration access :

* Missing SOAP fonction for config access in Portal/_SOAP.pm (lastCfg)
* Common/Conf/SOAP.pm now reports SOAP errors
* Common/Conf.pm reports an error when lastCfg returns 0
* SOAP namespace error in Common/Conf/SOAP.pm

Other :
* error in logout_sso default value (Handler/Simple.pm)
* bad returned value when configuration was missing in Handler/SharedConf.pm
parent 23805723
......@@ -67,8 +67,8 @@ sub new {
}
return 0 unless $self->prereq;
$self->{mdone}++;
$msg = "$self->{type} loaded";
}
$msg = "$self->{type} loaded";
if ( $self->{localStorage} and not defined( $self->{refLocalStorage} ) ) {
eval "use $self->{localStorage};";
if ($@) {
......@@ -173,6 +173,10 @@ sub getConf {
}
else {
$args->{cfgNum} ||= $self->lastCfg;
unless ( $args->{cfgNum} ) {
$msg = "No configuration available";
return 0;
}
my $r;
unless ( ref( $self->{refLocalStorage} ) ) {
$msg = "get remote configuration (localStorage unavailable)";
......@@ -271,7 +275,8 @@ sub getDBConf {
$re->add($_);
}
$conf->{reVHosts} = $re->as_string;
$self->setLocalConf($conf) if ( $self->{refLocalStorage} and not($args->{noCache}) );
$self->setLocalConf($conf)
if ( $self->{refLocalStorage} and not( $args->{noCache} ) );
return $conf;
}
......
......@@ -11,8 +11,10 @@ our $VERSION = 0.21;
BEGIN {
*Lemonldap::NG::Common::Conf::_soapCall = \&_soapCall;
*Lemonldap::NG::Common::Conf::_connect = \&_connect;
sub SOAP::Transport::HTTP::Client::get_basic_credentials {
return $Lemonldap::NG::Common::Conf::SOAP::username => $Lemonldap::NG::Common::Conf::SOAP::password;
return $Lemonldap::NG::Common::Conf::SOAP::username =>
$Lemonldap::NG::Common::Conf::SOAP::password;
}
}
......@@ -21,7 +23,8 @@ our ( $username, $password ) = ( '', '' );
sub prereq {
my $self = shift;
unless ( $self->{proxy} ) {
$Lemonldap::NG::Common::Conf::msg = '"proxy" parameter is required in "SOAP" configuration type';
$Lemonldap::NG::Common::Conf::msg =
'"proxy" parameter is required in "SOAP" configuration type';
return 0;
}
1;
......@@ -34,7 +37,7 @@ sub _connect {
if ( $self->{proxyOptions} ) {
push @args, %{ $self->{proxyOptions} };
}
$self->{ns} ||= 'urn:/Lemonldap/NG/Manager/SOAPService/Config';
$self->{ns} ||= 'urn:/Lemonldap/NG/Common/CGI/SOAPService';
return $self->{service} = SOAP::Lite->ns( $self->{ns} )->proxy(@args);
}
......@@ -43,7 +46,12 @@ sub _soapCall {
my $func = shift;
$username = $self->{User};
$password = $self->{Password};
return $self->_connect->$func(@_)->result;
my $r = $self->_connect->$func(@_);
if ( $r->fault() ) {
print STDERR "SOAP error : " . $r->fault()->{faultstring};
return ();
}
return $r->result;
}
sub available {
......
......@@ -111,7 +111,7 @@ sub run($$) {
if ( time() - $lastReload > $reloadTime ) {
unless ( my $tmp = $class->testConf(1) == OK ) {
$class->lmLog( "$class: No configuration found", 'error' );
return $tmp;
return SERVER_ERROR;
}
}
return $class->SUPER::run($r);
......
......@@ -503,8 +503,10 @@ sub conditionSub {
return sub { 0 }
if ( $cond =~ /^deny$/i );
if ( $cond =~ /^logout(?:_sso)?(?:\s+(.*))?$/i ) {
my $url = $1 || 'portal()';
return sub { $datas->{_logout} = $url; return 0 }
my $url = $1;
return $url
? sub { $datas->{_logout} = $url; return 0 }
: sub { $datas->{_logout} = portal(); return 0 };
}
if ( MP() == 2 ) {
if ( $cond =~ /^logout_app(?:\s+(.*))?$/i ) {
......
......@@ -28,7 +28,7 @@ sub startSoapServices {
'/sessions' => 'getAttributes',
'/adminSessions' => 'getAttributes setAttributes '
. 'newSession deleteSession get_key_from_all_sessions',
'/config' => 'getConfig'
'/config' => 'getConfig lastCfg'
}->{ $ENV{PATH_INFO} }
)
{
......@@ -163,6 +163,15 @@ sub getConfig {
return $conf;
}
##@method int lastCfg()
# SOAP method that return the last configuration number.
# Call Lemonldap::NG::Common::Conf::lastCfg().
# @return Last configuration number
sub lastCfg {
my $self = shift;
return $self->{lmConf}->lastCfg();
}
##@fn private SOAP::Data _buildSoapHash()
# Serialize a hashref into SOAP::Data. Types are fixed to "string".
# @return SOAP::Data serialized datas
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment