* Portal can now been used as 'proxy' for SOAP session storage.
* Session explorer works now with SOAP session storage (very low performances)
This commit is contained in:
parent
a3fb34b90c
commit
8bc0d20afa
|
@ -55,7 +55,7 @@ sub TIEHASH {
|
|||
}
|
||||
else {
|
||||
die "unable to create session"
|
||||
unless ( $self->newsession() );
|
||||
unless ( $self->newSession() );
|
||||
}
|
||||
return $self;
|
||||
}
|
||||
|
@ -124,7 +124,7 @@ sub _connect {
|
|||
if ( $self->{proxyOptions} ) {
|
||||
push @args, %{ $self->{proxyOptions} };
|
||||
}
|
||||
$self->{ns} ||= 'urn:/Lemonldap/NG/Manager/SOAPService/Sessions';
|
||||
$self->{ns} ||= 'urn:Lemonldap/NG/Common/CGI/SOAPService';
|
||||
return $self->{service} = SOAP::Lite->ns( $self->{ns} )->proxy(@args);
|
||||
}
|
||||
|
||||
|
@ -140,7 +140,7 @@ sub _soapCall {
|
|||
print STDERR "SOAP Error: " . $r->fault->{faultstring};
|
||||
return ();
|
||||
}
|
||||
return $self->_connect->$func(@_)->result;
|
||||
return $r->result;
|
||||
}
|
||||
|
||||
## @method hashRef get(string id)
|
||||
|
@ -149,15 +149,17 @@ sub _soapCall {
|
|||
sub get {
|
||||
my $self = shift;
|
||||
my $id = shift;
|
||||
return $self->{data} = $self->_soapCall( "get", $id );
|
||||
my $r = $self->_soapCall( "getAttributes", $id );
|
||||
return 0 unless ( $r or $r->{error} );
|
||||
return $self->{data} = $r->{attributes};
|
||||
}
|
||||
|
||||
## @method hashRef newsession()
|
||||
## @method hashRef newSession()
|
||||
# Build a new Apache::Session session.
|
||||
# @return User datas (just the session ID)
|
||||
sub newsession {
|
||||
sub newSession {
|
||||
my $self = shift;
|
||||
return $self->{data} = $self->_soapCall("newsession");
|
||||
return $self->{data} = $self->_soapCall("newSession");
|
||||
}
|
||||
|
||||
## @method boolean save()
|
||||
|
@ -165,7 +167,7 @@ sub newsession {
|
|||
sub save {
|
||||
my $self = shift;
|
||||
return unless ( $self->{modified} );
|
||||
return $self->_soapCall( "set", $self->{data}->{_session_id},
|
||||
return $self->_soapCall( "setAttributes", $self->{data}->{_session_id},
|
||||
$self->{data} );
|
||||
}
|
||||
|
||||
|
@ -173,7 +175,7 @@ sub save {
|
|||
# Deletes the current session.
|
||||
sub delete {
|
||||
my $self = shift;
|
||||
return $self->_soapCall( "delete", $self->{data}->{_session_id} );
|
||||
return $self->_soapCall( "deleteSession", $self->{data}->{_session_id} );
|
||||
}
|
||||
|
||||
## @method get_key_from_all_sessions()
|
||||
|
@ -182,16 +184,24 @@ sub get_key_from_all_sessions() {
|
|||
my $class = shift;
|
||||
my $args = shift;
|
||||
my $data = shift;
|
||||
my $self = bless {}, $class;
|
||||
foreach (qw(proxy proxyOptions ns)) {
|
||||
$self->{$_} = $args->{$_};
|
||||
}
|
||||
die('proxy is required') unless ( $self->{proxy} );
|
||||
( $user, $password ) = ( $args->{User}, $args->{Password} );
|
||||
if ( ref($data) eq 'CODE' ) {
|
||||
my $r = $class->_soapCall( "get_key_from_all_sessions", $args );
|
||||
my $r = $self->_soapCall( "get_key_from_all_sessions", $args );
|
||||
my $res;
|
||||
if ($r) {
|
||||
foreach my $k ( keys %$r ) {
|
||||
my $tmp = &$data( $r->{$k}, $k );
|
||||
$res->{$k} = $tmp if ( defined($tmp) );
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
return $class->_soapCall( "get_key_from_all_sessions", $args, $data );
|
||||
return $self->_soapCall( "get_key_from_all_sessions", $args, $data );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
package Lemonldap::NG::Manager::SOAPServer;
|
||||
|
||||
use strict;
|
||||
|
||||
die 'This module is now obsolete. You have to use the portal as "proxy".
|
||||
See http://wiki.lemonldap.ow2.org/xwiki/bin/view/NG/DocSOAP';
|
||||
__END__
|
||||
use SOAP::Transport::HTTP;
|
||||
use Lemonldap::NG::Common::Conf; #link protected config Configuration hash reference
|
||||
use UNIVERSAL qw(isa);
|
||||
|
|
|
@ -454,6 +454,43 @@ sub safe {
|
|||
return $safe;
|
||||
}
|
||||
|
||||
##@method private boolean _deleteSession(Apache::Session* h)
|
||||
# Delete an existing session
|
||||
# @param $h tied Apache::Session object
|
||||
sub _deleteSession {
|
||||
my ( $self, $h ) = @_;
|
||||
if ( my $id2 = $h->{_httpSession} ) {
|
||||
my $h2 = $self->getApacheSession($id2);
|
||||
tied(%$h2)->delete();
|
||||
|
||||
# Delete cookie
|
||||
push @{ $self->{cookie} },
|
||||
$self->cookie(
|
||||
-name => $self->{cookieName} . 'http',
|
||||
-value => 0,
|
||||
-domain => $self->{domain},
|
||||
-path => "/",
|
||||
-secure => 0,
|
||||
-expires => '-1d',
|
||||
@_,
|
||||
);
|
||||
}
|
||||
my $r = tied(%$h)->delete();
|
||||
|
||||
# Delete cookie
|
||||
push @{ $self->{cookie} },
|
||||
$self->cookie(
|
||||
-name => $self->{cookieName},
|
||||
-value => 0,
|
||||
-domain => $self->{domain},
|
||||
-path => "/",
|
||||
-secure => 0,
|
||||
-expires => '-1d',
|
||||
@_,
|
||||
);
|
||||
return $r;
|
||||
}
|
||||
|
||||
###############################################################
|
||||
# MAIN subroutine: call all steps until one returns something #
|
||||
# different than PE_OK #
|
||||
|
@ -556,19 +593,7 @@ sub controlExistingSession {
|
|||
if ( $self->param('logout') ) {
|
||||
|
||||
# Delete session in global storage
|
||||
tied(%$h)->delete;
|
||||
|
||||
# Delete cookie
|
||||
push @{ $self->{cookie} },
|
||||
$self->cookie(
|
||||
-name => $self->{cookieName},
|
||||
-value => 0,
|
||||
-domain => $self->{domain},
|
||||
-path => "/",
|
||||
-secure => 0,
|
||||
-expires => '-1d',
|
||||
@_,
|
||||
);
|
||||
$self->_deleteSession($h);
|
||||
$self->{error} = PE_REDIRECT;
|
||||
$self->_sub( 'userNotice',
|
||||
$self->{sessionInfo}->{ $self->{whatToTrace} }
|
||||
|
@ -576,7 +601,7 @@ sub controlExistingSession {
|
|||
$self->_subProcess(qw(autoRedirect));
|
||||
return PE_FIRSTACCESS;
|
||||
}
|
||||
untie(%$h);
|
||||
untie %$h;
|
||||
$self->{id} = $id;
|
||||
|
||||
# A session has been find => calling &existingSession
|
||||
|
@ -736,7 +761,7 @@ sub buildCookie {
|
|||
if ( $self->{securedCookie} == 2 ) {
|
||||
push @{ $self->{cookie} },
|
||||
$self->cookie(
|
||||
-name => $self->{cookieName}."http",
|
||||
-name => $self->{cookieName} . "http",
|
||||
-value => $self->{sessionInfo}->{_httpSession},
|
||||
-domain => $self->{domain},
|
||||
-path => "/",
|
||||
|
|
|
@ -19,7 +19,8 @@ sub startSoapServices {
|
|||
$ENV{PATH_INFO}
|
||||
and my $tmp = {
|
||||
'/sessions' => 'getAttributes',
|
||||
'/adminSessions' => 'setAttributes newSession',
|
||||
'/adminSessions' => 'getAttributes setAttributes '
|
||||
. 'newSession deleteSession get_key_from_all_sessions',
|
||||
'/config' => 'getConfig'
|
||||
}->{ $ENV{PATH_INFO} }
|
||||
)
|
||||
|
@ -118,12 +119,31 @@ sub getAttributes {
|
|||
push @tmp,
|
||||
SOAP::Data->name( attributes =>
|
||||
_buildSoapHash( $h, split /\s+/, $self->{exportedAttr} ) );
|
||||
untie(%$h);
|
||||
untie %$h;
|
||||
}
|
||||
my $res = SOAP::Data->name( session => \SOAP::Data->value(@tmp) );
|
||||
return $res;
|
||||
}
|
||||
|
||||
## @method SOAP::Data setAttributes(string id,hashref args)
|
||||
# Update datas in the session referenced by $id
|
||||
# @param $id Id of the session
|
||||
# @param $args datas to store
|
||||
# @return true if succeed
|
||||
sub setAttributes {
|
||||
my ( $self, $id, $args ) = @_;
|
||||
die 'id is required' unless ($id);
|
||||
my $h = $self->getApacheSession($id);
|
||||
unless ($h) {
|
||||
$self->lmLog( "Session $id does not exists ($@)", 'warn' );
|
||||
return 0;
|
||||
}
|
||||
$self->lmLog( "SOAP request to update session $id", 'debug' );
|
||||
$h->{$_} = $args->{$_} foreach ( keys %{$args} );
|
||||
untie %$h;
|
||||
return 1;
|
||||
}
|
||||
|
||||
##@method SOAP::Data getConfig()
|
||||
# Return Lemonldap::NG configuration. Warning, this is not a well formed
|
||||
# SOAP::Data object so it can be difficult to read by other languages than
|
||||
|
@ -159,5 +179,50 @@ sub _buildSoapHash {
|
|||
return \SOAP::Data->value(@tmp);
|
||||
}
|
||||
|
||||
## @method SOAP::Data newSession(hashref args)
|
||||
# Store a new session.
|
||||
# @return Session datas
|
||||
sub newSession {
|
||||
my ( $self, $args ) = @_;
|
||||
my $h = $self->getApacheSession();
|
||||
if ($@) {
|
||||
$self->lmLog( "Unable to create session", 'error' );
|
||||
return 0;
|
||||
}
|
||||
$h->{$_} = $args->{$_} foreach ( keys %{$args} );
|
||||
$h->{_utime} = time();
|
||||
$args->{$_} = $h->{$_} foreach ( keys %$h );
|
||||
untie %$h;
|
||||
$self->lmLog( "SOAP request to store $args->{_session_id} ($args->{uid})",
|
||||
'debug' );
|
||||
return SOAP::Data->name( attributes => _buildSoapHash($args) );
|
||||
}
|
||||
|
||||
## @method SOAP::Data deleteSession()
|
||||
# Deletes an existing session
|
||||
sub deleteSession {
|
||||
my ( $self, $id ) = @_;
|
||||
die('id parameter is required') unless ($id);
|
||||
my $h = $self->getApacheSession($id);
|
||||
return 0 if ($@);
|
||||
$self->lmLog( "SOAP request to delete session $id", 'debug' );
|
||||
return $self->_deleteSession($h);
|
||||
}
|
||||
|
||||
##@method SOAP::Data getConfig()
|
||||
sub get_key_from_all_sessions {
|
||||
my $self = shift;
|
||||
shift;
|
||||
require Lemonldap::NG::Common::Apache::Session;
|
||||
|
||||
#die $self->{globalStorage};
|
||||
my $tmp = $self->{globalStorage};
|
||||
no strict 'refs';
|
||||
return $self->{globalStorage}
|
||||
->get_key_from_all_sessions( $self->{globalStorageOptions}, @_ );
|
||||
return &{"$tmp\::get_key_from_all_sessions"}( $self->{globalStorage},
|
||||
$self->{globalStorageOptions}, @_ );
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user