2009-02-05 18:05:18 +01:00
|
|
|
## @file
|
|
|
|
# SOAP wrapper used to restrict exported functions
|
|
|
|
|
|
|
|
## @class
|
|
|
|
# SOAP wrapper used to restrict exported functions
|
|
|
|
package Lemonldap::NG::Common::CGI::SOAPService;
|
|
|
|
|
2009-02-08 18:12:42 +01:00
|
|
|
require SOAP::Lite;
|
|
|
|
|
2016-03-17 23:19:44 +01:00
|
|
|
our $VERSION = '2.0.0';
|
2009-06-08 18:29:13 +02:00
|
|
|
|
2009-02-05 18:05:18 +01:00
|
|
|
## @cmethod Lemonldap::NG::Common::CGI::SOAPService new(object obj,string @func)
|
|
|
|
# Constructor
|
|
|
|
# @param $obj object which will be called for SOAP authorizated methods
|
2009-02-17 16:22:42 +01:00
|
|
|
# @param @func authorizated methods
|
2009-02-05 18:05:18 +01:00
|
|
|
# @return Lemonldap::NG::Common::CGI::SOAPService object
|
|
|
|
sub new {
|
2010-03-01 21:32:28 +01:00
|
|
|
my ( $class, $obj, @func ) = @_;
|
|
|
|
s/.*::// foreach (@func);
|
|
|
|
return bless { obj => $obj, func => \@func }, $class;
|
2009-02-05 18:05:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
## @method datas AUTOLOAD()
|
|
|
|
# Call the wanted function with the object given to the constructor.
|
|
|
|
# AUTOLOAD() is a magic method called by Perl interpreter fon non existent
|
|
|
|
# functions. Here, we use it to call the wanted function (given by $AUTOLOAD)
|
|
|
|
# if it is authorizated
|
|
|
|
# @return datas provided by the exported function
|
|
|
|
sub AUTOLOAD {
|
|
|
|
my $self = shift;
|
|
|
|
$AUTOLOAD =~ s/.*:://;
|
2010-03-01 21:32:28 +01:00
|
|
|
if ( grep { $_ eq $AUTOLOAD } @{ $self->{func} } ) {
|
2009-02-08 18:12:42 +01:00
|
|
|
my $tmp = $self->{obj}->$AUTOLOAD(@_);
|
2010-03-01 21:32:28 +01:00
|
|
|
unless ( ref($tmp) and ref($tmp) eq 'SOAP::Data' ) {
|
2009-02-08 18:12:42 +01:00
|
|
|
$tmp = SOAP::Data->name( result => $tmp );
|
|
|
|
}
|
|
|
|
return $tmp;
|
2009-02-05 18:05:18 +01:00
|
|
|
}
|
2010-03-01 21:32:28 +01:00
|
|
|
elsif ( $AUTOLOAD ne 'DESTROY' ) {
|
2009-04-04 09:36:42 +02:00
|
|
|
die "$AUTOLOAD is not an authorizated function";
|
2009-02-05 18:05:18 +01:00
|
|
|
}
|
|
|
|
1;
|
|
|
|
}
|
|
|
|
|
|
|
|
1;
|