15 return hash(
"sha256", self::class);
20 return "The NIC key is registered at the ILIAS Open Source society";
30 $http_config = $environment->getConfigFor(
"http");
32 new \ilNICKeyStoredObjective($this->config),
33 new \ilSettingsFactoryExistsObjective(),
34 new \ilHttpConfigStoredObjective($http_config)
40 $factory = $environment->getResource(Setup\Environment::RESOURCE_SETTINGS_FACTORY);
41 $settings =
$factory->settingsFor(
"common");
42 $systemfolder_config = $environment->getConfigFor(
"systemfolder");
43 $http_config = $environment->getConfigFor(
"http");
46 throw new Setup\UnachievableException(
47 "CURL extension is required to register NIC." 52 $old_settings =
$GLOBALS[
"ilSetting"] ?? null;
60 if (
$req->getInfo()[
"http_code"] !=
"200") {
61 $settings->set(
"nic_enabled",
"-1");
62 throw new Setup\UnachievableException(
63 "Could not connect to NIC server at \"" . self::ILIAS_NIC_SERVER .
"\"" 67 $status = explode(
"\n",
$req->getResponseBody());
69 $nic_id = (string) ($status[2] ??
'');
71 $settings->set(
"nic_enabled",
"-1");
72 throw new Setup\UnachievableException(
73 "Did not receive valid installation id from " .
74 "NIC server (\"" . self::ILIAS_NIC_SERVER .
"\") for URL: $url" .
79 $settings->set(
"nic_enabled",
"1");
80 $settings->set(
"inst_id", $status[2]);
82 $GLOBALS[
"ilSetting"] = $old_settings;
97 $error_code = trim((
string) ($nic_response_parts[1] ??
''));
100 switch ($error_code) {
102 $message =
"NIC server could not connect to database";
106 $message =
"NIC server could not execute query";
110 $message =
"The installation name was missing in request, please check your " .
111 "configuration (systemfolder.client.name)";
115 $message =
"The http path or contact's lastname was missing in request, please check " .
116 "your configuration (http.path or systemfolder.contact.lastname)";
120 $message =
"The contact's firstname was missing in request, please check your " .
121 "configuration (systemfolder.contact.firstname)";
125 $message =
"The contact's email address was missing in request, please check your " .
126 "configuration (systemfolder.contact.email)";
135 $inst_id = (string) $settings->get(
'inst_id',
'0');
137 $host_name = parse_url($http_path)[
"host"];
139 $url = self::ILIAS_NIC_SERVER .
141 "&inst_id=" . rawurlencode($inst_id) .
142 "&hostname=" . rawurlencode($host_name) .
143 "&inst_name=" . rawurlencode($systemfolder_config->
getClientName() ??
'') .
145 "&http_path=" . rawurlencode($http_path) .
148 "&contact_email=" . rawurlencode($systemfolder_config->
getContactEMail()) .
149 "&nic_key=" . rawurlencode($settings->get(
"nic_key"));
156 $req = new \ilCurlConnection($url);
159 $req->setOpt(CURLOPT_HEADER, 1);
160 $req->setOpt(CURLOPT_RETURNTRANSFER, 1);
161 $req->setOpt(CURLOPT_CONNECTTIMEOUT, self::SOCKET_TIMEOUT);
162 $req->setOpt(CURLOPT_MAXREDIRS, self::MAX_REDIRECTS);
getPreconditions(Setup\Environment $environment)
getRegistrationProblem(array $nic_response_parts)
getCurlConnection(string $url)
static _isCurlExtensionLoaded()
Check if curl extension is loaded.
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)