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;
|
|
|
|
|
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
|
|
|
|
# @param @fung authorizated methods
|
|
|
|
# @return Lemonldap::NG::Common::CGI::SOAPService object
|
|
|
|
sub new {
|
|
|
|
my($class, $obj, @func) = @_;
|
|
|
|
s/.*::// foreach(@func);
|
|
|
|
return bless {obj=>$obj,func=>\@func}, $class;
|
|
|
|
}
|
|
|
|
|
|
|
|
## @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/.*:://;
|
|
|
|
if(grep {$_ eq $AUTOLOAD} @{$self->{func}}){
|
2009-02-08 18:12:42 +01:00
|
|
|
my $tmp = $self->{obj}->$AUTOLOAD(@_);
|
|
|
|
unless(ref($tmp) and ref($tmp) eq 'SOAP::Data') {
|
|
|
|
$tmp = SOAP::Data->name( result => $tmp );
|
|
|
|
}
|
|
|
|
return $tmp;
|
2009-02-05 18:05:18 +01:00
|
|
|
}
|
|
|
|
elsif($AUTOLOAD ne 'DESTROY') {
|
2009-02-08 18:12:42 +01:00
|
|
|
die "$AUTOLOAD is not an authorizated function";use Data::Dumper;
|
2009-02-05 18:05:18 +01:00
|
|
|
}
|
|
|
|
1;
|
|
|
|
}
|
|
|
|
|
|
|
|
1;
|
|
|
|
|