Lemonldap::NG::Common::Conf::SOAP - Perl extension written to access to


Lemonldap-NG-Common documentation Contained in the Lemonldap-NG-Common distribution.

Index


Code Index:

NAME

Top

Lemonldap::NG::Common::Conf::SOAP - Perl extension written to access to Lemonldap::NG Web-SSO configuration via SOAP.

SYNOPSIS

Top

Client side

Area protection (Apache handler)

  package My::Package;

  use base Lemonldap::NG::Handler::SharedConf;

  __PACKAGE__->init ( {
      localStorage        => "Cache::FileCache",
      localStorageOptions => {
                'namespace'          => 'MyNamespace',
                'default_expires_in' => 600,
      },
      configStorage       => {
                type     => 'SOAP',
                proxy    => 'http://auth.example.com/index.pl/config',
                # If soapserver is protected by HTTP Basic:
                User     => 'http-user',
                Password => 'pass',
      },
      https               => 0,
  } );

Authentication portal

  use Lemonldap::NG::Portal::SharedConf;

  my $portal = Lemonldap::NG::Portal::SharedConf->new ( {
          configStorage => {
                  type    => 'SOAP',
                  proxy    => 'http://auth.example.com/index.pl/config',
                  # If soapserver is protected by HTTP Basic:
                  User     => 'http-user',
                  Password => 'pass',
          }
  });
  # Next as usual... See Lemonldap::NG::Portal(3)
  if($portal->process()) {
    ...

Manager

  use Lemonldap::NG::Manager;

  my $m=new Lemonldap::NG::Manager(
       {
           configStorage=>{
                  type  => 'SOAP',
                  proxy    => 'http://auth.example.com/index.pl/config',
                  # If soapserver is protected by HTTP Basic:
                  User     => 'http-user',
                  Password => 'pass',
           },
            dhtmlXTreeImageLocation=> "/imgs/",
        }
  ) or die "Unable to start manager";

  $m->doall();

Server side

You just have to set "Soap => 1" in your portal. See HTML documentation for more.

DESCRIPTION

Top

Lemonldap::NG::Common::Conf provides a simple interface to access to Lemonldap::NG Web-SSO configuration. It is used by Lemonldap::NG::Handler, Lemonldap::NG::Portal and Lemonldap::NG::Manager.

Lemonldap::NG::Common::Conf::SOAP provides the "SOAP" target used to access configuration via SOAP.

SECURITY

As Lemonldap::NG::Common::Conf::SOAP use SOAP::Lite, you have to see SOAP::Transport to know arguments that can be passed to proxyOptions. Lemonldap::NG provides a system for HTTP basic authentication.

Examples :

* HTTP Basic authentication
  package My::Package;

  use base Lemonldap::NG::Handler::SharedConf;

  __PACKAGE__->init ( {
      localStorage        => "Cache::FileCache",
      localStorageOptions => {
                'namespace'          => 'MyNamespace',
                'default_expires_in' => 600,
      },
      configStorage       => {
                type  => 'SOAP',
                proxy => 'http://auth.example.com/index.pl/config',
                User     => 'http-user',
                Password => 'pass',
      },
      https               => 1,
  } );

* SSL Authentication

SOAP::transport provides a simple way to use SSL certificate: you've just to set environment variables.

  package My::Package;

  use base Lemonldap::NG::Handler::SharedConf;

  # AUTHENTICATION
  $ENV{HTTPS_CERT_FILE} = 'client-cert.pem';
  $ENV{HTTPS_KEY_FILE}  = 'client-key.pem';

  __PACKAGE__->init ( {
      localStorage        => "Cache::FileCache",
      localStorageOptions => {
                'namespace'          => 'MyNamespace',
                'default_expires_in' => 600,
      },
      configStorage       => {
                type  => 'SOAP',
                proxy => 'http://auth.example.com/index.pl/config',
      },
      https               => 1,
  } );

SEE ALSO

Top

Lemonldap::NG::Common::Conf::SOAP, Lemonldap::NG::Handler, Lemonldap::NG::Portal, http://lemonldap-ng.org/

AUTHOR

Top

Xavier Guimard, <x.guimard@free.fr>

BUG REPORT

Top

Use OW2 system to report bug or ask for features: http://jira.ow2.org

DOWNLOAD

Top

Lemonldap::NG is available at http://forge.objectweb.org/project/showfiles.php?group_id=274

COPYRIGHT AND LICENSE

Top


Lemonldap-NG-Common documentation Contained in the Lemonldap-NG-Common distribution.

package Lemonldap::NG::Common::Conf::SOAP;

use strict;
use SOAP::Lite;

our $VERSION = '1.0.0';

#parameter proxy Url of SOAP service
#parameter proxyOptions SOAP::Lite parameters

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;
    }
}

our ( $username, $password ) = ( '', '' );

sub prereq {
    my $self = shift;
    unless ( $self->{proxy} ) {
        $Lemonldap::NG::Common::Conf::msg =
          '"proxy" parameter is required in "SOAP" configuration type';
        return 0;
    }
    1;
}

sub _connect {
    my $self = shift;
    return $self->{service} if ( $self->{service} );
    my @args = ( $self->{proxy} );
    if ( $self->{proxyOptions} ) {
        push @args, %{ $self->{proxyOptions} };
    }
    $self->{ns} ||= 'urn:/Lemonldap/NG/Common/CGI/SOAPService';
    return $self->{service} = SOAP::Lite->ns( $self->{ns} )->proxy(@args);
}

sub _soapCall {
    my $self = shift;
    my $func = shift;
    $username = $self->{User};
    $password = $self->{Password};
    my $r = $self->_connect->$func(@_);
    if ( $r->fault() ) {
        print STDERR "SOAP error : " . $r->fault()->{faultstring};
        return ();
    }
    return $r->result;
}

sub available {
    my $self = shift;
    return @{ $self->_soapCall( 'available', @_ ) };
}

sub lastCfg {
    my $self = shift;
    return $self->_soapCall( 'lastCfg', @_ );
}

sub lock {
    my $self = shift;
    return $self->_soapCall( 'lock', @_ );
}

# unlock is not needed here since real unlock is called by store
#sub unlock {
#    my $self = shift;
#    return $self->_soapCall( 'unlock', @_ );
#}

sub isLocked {
    my $self = shift;
    return $self->_soapCall( 'isLocked', @_ );
}

sub store {
    my $self = shift;
    return $self->_soapCall( 'store', @_ );
}

sub load {
    my $self = shift;
    return $self->_soapCall( 'getConfig', @_ );
}

1;
__END__