3 declare(strict_types=1);
31 return hash(
"sha256", self::class);
36 return "The NIC key is registered at the ILIAS Open Source society";
46 $http_config = $environment->getConfigFor(
"http");
48 new \ilNICKeyStoredObjective($this->config),
49 new \ilSettingsFactoryExistsObjective(),
50 new \ilHttpConfigStoredObjective($http_config)
56 $factory = $environment->getResource(Setup\Environment::RESOURCE_SETTINGS_FACTORY);
58 $systemfolder_config = $environment->getConfigFor(
"systemfolder");
59 $http_config = $environment->getConfigFor(
"http");
62 throw new Setup\UnachievableException(
63 "CURL extension is required to register NIC." 68 $old_settings =
$GLOBALS[
"ilSetting"] ?? null;
81 if (
$req->getInfo()[
"http_code"] !=
"200") {
83 throw new Setup\UnachievableException(
84 "Could not connect to NIC server at \"" . self::ILIAS_NIC_SERVER .
"\"" 88 $status = explode(
"\n",
$req->getResponseBody());
90 $nic_id = (string) ($status[2] ??
'');
93 throw new Setup\UnachievableException(
94 "Did not receive valid installation id from " .
95 "NIC server (\"" . self::ILIAS_NIC_SERVER .
"\") for URL: $url" .
104 $GLOBALS[
"ilSetting"] = $old_settings;
120 $error_code = trim((
string) ($nic_response_parts[1] ??
''));
123 switch ($error_code) {
125 $message =
"NIC server could not connect to database";
129 $message =
"NIC server could not execute query";
133 $message =
"The installation name was missing in request, please check your " .
134 "configuration (systemfolder.client.name)";
138 $message =
"The http path or contact's lastname was missing in request, please check " .
139 "your configuration (http.path or systemfolder.contact.lastname)";
143 $message =
"The contact's firstname was missing in request, please check your " .
144 "configuration (systemfolder.contact.firstname)";
148 $message =
"The contact's email address was missing in request, please check your " .
149 "configuration (systemfolder.contact.email)";
158 $inst_id = (string)
$settings->get(
'inst_id',
'0');
160 $host_name = parse_url($http_path)[
"host"];
162 $url = self::ILIAS_NIC_SERVER .
164 "&inst_id=" . rawurlencode($inst_id) .
165 "&hostname=" . rawurlencode($host_name) .
166 "&inst_name=" . rawurlencode($systemfolder_config->
getClientName() ??
'') .
168 "&http_path=" . rawurlencode($http_path) .
171 "&contact_email=" . rawurlencode($systemfolder_config->
getContactEMail()) .
172 "&nic_key=" . rawurlencode(
$settings->get(
"nic_key"));
179 $req = new \ilCurlConnection($url);
182 $req->setOpt(CURLOPT_HEADER, 1);
183 $req->setOpt(CURLOPT_RETURNTRANSFER, 1);
184 $req->setOpt(CURLOPT_CONNECTTIMEOUT, self::SOCKET_TIMEOUT);
185 $req->setOpt(CURLOPT_MAXREDIRS, self::MAX_REDIRECTS);
getPreconditions(Setup\Environment $environment)
getRegistrationProblem(array $nic_response_parts)
getCurlConnection(string $url)
catch(\Exception $e) $req
static _isCurlExtensionLoaded()
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
An environment holds resources to be used in the setup process.
isApplicable(Setup\Environment $environment)
achieve(Setup\Environment $environment)
getURLStringForNIC($settings, \ilSystemFolderSetupConfig $systemfolder_config, \ilHttpSetupConfig $http_config)