diff --git a/modules/lemonldap-ng-manager/lib/Lemonldap/NG/Manager.pm b/modules/lemonldap-ng-manager/lib/Lemonldap/NG/Manager.pm
index b44e4605a..c8c83b175 100644
--- a/modules/lemonldap-ng-manager/lib/Lemonldap/NG/Manager.pm
+++ b/modules/lemonldap-ng-manager/lib/Lemonldap/NG/Manager.pm
@@ -73,6 +73,14 @@ sub new {
$self->quit();
}
+ # URL upload
+ elsif ( my $rurl = $self->rparam('url') ) {
+
+ require Lemonldap::NG::Manager::Uploader; #inherits
+ $self->urlUpload('url');
+ $self->quit();
+ }
+
# Else load conf
require Lemonldap::NG::Manager::Downloader; #inherits
$self->{cfgNum} =
diff --git a/modules/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Uploader.pm b/modules/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Uploader.pm
index 2807295cc..f5f129271 100644
--- a/modules/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Uploader.pm
+++ b/modules/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Uploader.pm
@@ -10,6 +10,7 @@ use XML::LibXML;
use XML::LibXSLT;
use MIME::Base64;
use JSON;
+use LWP::Simple;
# TODO
use Data::Dumper;
@@ -299,6 +300,41 @@ sub fileUpload {
$self->quit();
}
+## @method public void fileUpload (fieldname)
+# Retrieve a file from an URL, and return it. This function is for
+# some functionnalities into the SAML2 modules of the manager, accessing
+# to data through Ajax requests.
+# @param $fieldname The name of the html input field that contains the URL.
+sub urlUpload {
+ my $self = shift;
+ my $fieldname = shift;
+
+ # Get the URL
+ my $url = ${$self->rparam($fieldname)};
+
+ # Get contents from URL
+ print STDERR "---> " . $url . "\n";
+ my $content = get $url;
+ $content = '' unless(defined $content);
+ $content =~ s!!>!g;
+
+ # Build JSON reponse
+ my $json = new JSON();
+ $json = $json->allow_nonref(['1']);
+ $json = $json->utf8(['1']);
+ my $json_content = $json->encode($content);
+ my $buf = '{"status":"OK", "content":' . $json_content . '}';
+
+ # Send JSON response
+ # text/html is recommended header for JSON data retrieved by JQuery.
+ print $self->header(
+ -type => 'text/html',
+ -Content_Length => length($buf)
+ ) . $buf;
+ $self->quit();
+}
+
## @method protected array applyTest(void* test,string value)
# Apply the test to the value and return the result and an optional message
# returned by the test if the sub ref.