Menu applications can now be requested trought SOAP (#25)

environments/ppa-mbqj77/deployments/1
Clément Oudot 15 years ago
parent 0a0c13a1b9
commit 6ddf9774c5
  1. 1
      modules/lemonldap-ng-portal/MANIFEST
  2. 52
      modules/lemonldap-ng-portal/example/scripts/buildPortalWSDL
  3. 28
      modules/lemonldap-ng-portal/example/soaptest.pl
  4. 6
      modules/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Simple.pm
  5. 46
      modules/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/_SOAP.pm

@ -156,6 +156,7 @@ example/skins/pastel/openidform.tpl
example/skins/pastel/password.tpl
example/skins/pastel/standardform.tpl
example/slavePortal.pl
example/soaptest.pl
lib/Lemonldap/NG/Portal.pm
lib/Lemonldap/NG/Portal/_CAS.pm
lib/Lemonldap/NG/Portal/_Choice.pm

@ -156,6 +156,13 @@ print Lemonldap::NG::Common::BuildWSDL->new->buildWSDL(<<EOT);
<wsdl:part name="result" type="xsd:boolean" />
</wsdl:message>
<wsdl:message name="getMenuApplicationsRequest">
<wsdl:part name="id" type="xsd:string" />
</wsdl:message>
<wsdl:message name="getMenuApplicationsResponse">
<wsdl:part name="result" type="xsd:anyType" />
</wsdl:message>
<wsdl:portType name="sessionsPortType">
<wsdl:operation name="getAttributes" parameterOrder="id">
<wsdl:input message="impl:getAttributesRequest" name="getAttributesRequest" />
@ -165,6 +172,10 @@ print Lemonldap::NG::Common::BuildWSDL->new->buildWSDL(<<EOT);
<wsdl:input message="impl:isAuthorizedURIRequest" name="isAuthorizedURIRequest" />
<wsdl:output message="impl:isAuthorizedURIResponse" name="isAuthorizedURIResponse" />
</wsdl:operation>
<wsdl:operation name="getMenuApplications" parameterOrder="id">
<wsdl:input message="impl:getMenuApplicationsRequest" name="getMenuApplicationsRequest" />
<wsdl:output message="impl:getMenuApplicationsResponse" name="getMenuApplicationsResponse" />
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="sessionsBinding" type="impl:sessionsPortType">
@ -187,46 +198,21 @@ print Lemonldap::NG::Common::BuildWSDL->new->buildWSDL(<<EOT);
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:Lemonldap/NG/Common/CGI/SOAPService" use="encoded" />
</wsdl:output>
</wdsl:operation>
</wsdl:binding>
<wsdl:service name="sessionsService">
<wsdl:port binding="impl:sessionsBinding" name="sessionsPort">
<wsdlsoap:address location="__PORTAL__/sessions" />
</wsdl:port>
</wsdl:service>
<!-- configuration service -->
<wsdl:message name="getXmlMenuRequest">
<wsdl:part name="file" type="xsd:string" />
</wsdl:message>
<wsdl:message name="getXmlMenuResponse">
<wsdl:part name="result" type="xsd:string" />
</wsdl:message>
<wsdl:portType name="configPortType">
<wsdl:operation name="getXmlMenu" parameterOrder="file">
<wsdl:input message="impl:getXmlMenuRequest" name="getXmlMenuRequest" />
<wsdl:output message="impl:getXmlMenuResponse" name="getXmlMenuResponse" />
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="configBinding" type="impl:configPortType">
<wsdlsoap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="getXmlMenu">
<wdsl:operation name="getMenuApplications">
<wsdlsoap:operation soapAction="" />
<wsdl:input name="getXmlMenuRequest">
<wsdl:input name="getMenuApplicationsRequest">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:Lemonldap/NG/Common/CGI/SOAPService" use="encoded" />
</wsdl:input>
<wsdl:output name="getXmlMenuResponse">
<wsdl:output name="getMenuApplicationsResponse">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:Lemonldap/NG/Common/CGI/SOAPService" use="encoded" />
</wsdl:output>
</wsdl:operation>
</wdsl:operation>
</wsdl:binding>
<wsdl:service name="configService">
<wsdl:port binding="impl:configBinding" name="configPort">
<wsdlsoap:address location="__PORTAL__/config" />
<wsdl:service name="sessionsService">
<wsdl:port binding="impl:sessionsBinding" name="sessionsPort">
<wsdlsoap:address location="__PORTAL__/sessions" />
</wsdl:port>
</wsdl:service>

@ -0,0 +1,28 @@
#!/usr/bin/perl
#==============================================================================
#
# Simple script to test LemonLDAP::NG SOAP services
#
#==============================================================================
use strict;
use SOAP::Lite;
use Data::Dumper;
# Session ID (first parameter)
my $session_id = shift @ARGV;
# Service
my $soap = SOAP::Lite->new( proxy => 'http://auth.example.com/index.pl/sessions');
$soap->default_ns('urn:Lemonldap/NG/Common/CGI/SOAPService');
# Call some SOAP methods
my $attributes = $soap->call( 'getAttributes', $session_id)->result();
print Dumper $attributes;
my $applications = $soap->call( 'getMenuApplications', $session_id)->result();
print Dumper $applications;
exit;

@ -205,6 +205,9 @@ sub new {
unless ( $self->{domain} );
$self->{domain} =~ s/^([^\.])/.$1/;
# Load Menu functions
$self->loadModule('Lemonldap::NG::Portal::Menu');
# Rules to allow redirection
$self->{mustRedirect} = (
( $ENV{REQUEST_METHOD} eq 'POST' and not $self->param('newpassword') )
@ -364,9 +367,6 @@ sub new {
. ')';
}
# Load Menu functions
$self->loadModule('Lemonldap::NG::Portal::Menu');
return $self;
}

@ -18,22 +18,21 @@ our @ISA = qw(Lemonldap::NG::Portal::_LibAccess);
## @method void startSoapServices()
# Check the URI requested (PATH_INFO environment variable) and launch the
# corresponding SOAP methods using soapTest().
# If "soapOnly" is set, reject otehr request. Else, simply return.
# If "soapOnly" is set, reject other request. Else, simply return.
sub startSoapServices {
my $self = shift;
$self->{CustomSOAPServices} ||= {};
# TODO: insert here the SAML SOAP functions
$self->{CustomSOAPServices}->{'/SAMLAuthority'} = ''
if ( $self->{SAMLIssuer} );
# Load SOAP services
$self->{CustomSOAPServices} ||= {};
if (
$ENV{PATH_INFO}
and my $tmp = {
%{ $self->{CustomSOAPServices} },
'/sessions' => 'getAttributes isAuthorizedURI',
'/sessions' =>
'getCookies getAttributes isAuthorizedURI getMenuApplications',
'/adminSessions' => 'getAttributes setAttributes isAuthorizedURI '
. 'newSession deleteSession get_key_from_all_sessions',
'/config' => 'getConfig lastCfg getXmlMenu'
'/config' => 'getConfig lastCfg'
}->{ $ENV{PATH_INFO} }
)
{
@ -240,7 +239,7 @@ _RETURN $isAuthorizedURIResponse Response
=cut
## @method boolean isAuthorizedURI (int id, string uri)
## @method boolean isAuthorizedURI (string id, string uri)
# Check user's authorization for uri.
# @param $id Id of the session
# @param $uri URL string
@ -265,29 +264,32 @@ sub isAuthorizedURI {
=begin WSDL
_IN file $string Menu XML file complete path
_RETURN $getXmlMenuResponse Response
_IN id $string Cookie value
_RETURN $getMenuApplicationsResponse Response
=end WSDL
=cut
##@method SOAP::Data getXmlMenu(string file)
#@param file
##@method SOAP::Data getMenuApplications(string id)
# @param $id Id of the session
#@return SOAP::Data
sub getXmlMenu {
my $self = shift;
my ($file) = @_;
die 'file is required' unless ($file);
die 'file cannot be read' unless ( -r $file );
sub getMenuApplications {
my ( $self, $id ) = splice @_;
die 'id is required' unless ($id);
# Load XML::Simple
use XML::Simple;
$self->lmLog( "SOAP getMenuApplications request for id $id", 'debug' );
# Get XML content
my $xml = new XML::Simple( ForceArray => '1' );
# Get user session.
my $h = $self->getApacheSession( $id, 1 );
unless ($h) {
$self->lmLog( "Session $id does not exists ($@)", 'warn' );
return 0;
}
$self->{sessionInfo} = $h;
return _buildSoapHash( { menu => $self->appslist() } );
return _buildSoapHash( $xml->XMLin($file) );
}
#######################

Loading…
Cancel
Save