LEMONLDAP::NG : now the portal can be called by browser or by SOAP

environments/ppa-mbqj77/deployments/1
Xavier Guimard 17 years ago
parent 68d447b422
commit b9ba2337e4
  1. 11
      modules/lemonldap-ng-common/lib/Lemonldap/NG/Common/CGI.pm
  2. 3
      modules/lemonldap-ng-portal/example/index_simple.pl
  3. 1
      modules/lemonldap-ng-portal/example/index_skin.pl
  4. 40
      modules/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Simple.pm

@ -17,16 +17,15 @@ our $VERSION = '0.3';
use base qw(CGI);
sub new {
my $class = shift;
my $args = shift;
my $self = $class->SUPER::new();
sub soapTest {
my $self = shift;
my $soapFunctions = shift || $self->{SOAPFunctions};
# If non form encoded datas are posted, we call SOAP Services
if ( $ENV{HTTP_SOAPACTION} ) {
my @func = ();
foreach ( split /\s+/, $args->{SOAPFunctions} ) {
$_ = "${class}::$_" unless (/::/);
foreach ( ref($soapFunctions) ? @$soapFunctions : split /\s+/, $soapFunctions ) {
$_ = ref($self) . "::$_" unless (/::/);
push @func, $_;
}
Lemonldap::NG::Common::CGI::SOAPServer->dispatch_to(@func)

@ -8,6 +8,9 @@ my $portal = Lemonldap::NG::Portal::SharedConf->new(
type => 'File',
dirName => '__CONFDIR__',
},
#ldapPpolicyControl => 1, # Remove comment to use LDAP Password Policy
#storePassword => 1, # Remove comment to store password in session (use with caution)
#Soap => 1, # Remove comment to activate SOAP Function getCookies(user,pwd)
}
);

@ -18,6 +18,7 @@ my $portal = Lemonldap::NG::Portal::SharedConf->new(
existingSession => sub { PE_DONE }, # Required to display the menu to a connected user
#ldapPpolicyControl => 1, # Remove comment to use LDAP Password Policy
#storePassword => 1, # Remove comment to store password in session (use with caution)
#Soap => 1, # Remove comment to activate SOAP Function getCookies(user,pwd)
}
);

@ -85,7 +85,8 @@ our $self; # Safe cannot share a variable declared with my
sub new {
binmode( STDOUT, ":utf8" );
my $class = shift;
my $self = $class->SUPER::new();
return $class if ( ref($class) );
our $self = $class->SUPER::new();
$self->getConf(@_)
or $self->abort( "Configuration error",
"Unable to get configuration: $Lemonldap::NG::Common::Conf::msg" );
@ -129,6 +130,10 @@ sub new {
if ( $self->{notification} ) {
require Lemonldap::NG::Common::Notification;
}
if ( $self->{Soap} ) {
require SOAP::Lite;
$self->soapTest("${class}::getCookies");
}
return $self;
}
@ -321,6 +326,7 @@ sub _subProcess {
my $err = undef;
foreach my $sub (@subs) {
print STDERR "$sub\n";
if ( $self->{$sub} ) {
last if ( $err = &{ $self->{$sub} }($self) );
}
@ -377,6 +383,38 @@ sub process {
return ( ( $self->{error} > 0 ) ? 0 : 1 );
}
##@method string SOAPResponse getCookies($user,$password)
# Called in SOAP context, returns cookies in an array
#@param user uid
#@param password password
#@return session => { error => code , cookies => { cookieName1 => value ,... } }
sub getCookies {
my $class = shift;
$self->{error} = PE_OK;
( $self->{user}, $self->{password} ) = @_;
unless ( $self->{user} && $self->{password} ) {
$self->{error} = PE_FORMEMPTY;
}
else {
$self->{error} = $self->_subProcess(
qw(authInit userDBInit getUser setAuthSessionInfo setSessionInfo
setMacros setGroups authenticate store buildCookie log)
);
}
my @tmp = ();
push @tmp, SOAP::Data->name( error => $self->{error} );
unless ( $self->{error} ) {
push @tmp,
SOAP::Data->name(
cookies => \SOAP::Data->value(
SOAP::Data->name( $self->{cookieName} => $self->{id} ),
)
);
}
my $res = SOAP::Data->name( session => \SOAP::Data->value(@tmp) );
return $res;
}
## @method error_code checkNotifBack()
# 1) Checks if a message has to be notified to the connected user.
# @return error code

Loading…
Cancel
Save