ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
ilNICKeyRegisteredObjective Class Reference
+ Inheritance diagram for ilNICKeyRegisteredObjective:
+ Collaboration diagram for ilNICKeyRegisteredObjective:

Public Member Functions

 getHash ()
 
 getLabel ()
 
 isNotable ()
 
 getPreconditions (Setup\Environment $environment)
 
 achieve (Setup\Environment $environment)
 
- Public Member Functions inherited from ilSetupObjective
 __construct (\ilSetupConfig $config)
 

Data Fields

const MAX_REDIRECTS = 5
 
const SOCKET_TIMEOUT = 5
 
const ILIAS_NIC_SERVER = "https://nic.ilias.de/index.php"
 

Protected Member Functions

 getURLStringForNIC ($settings, \ilSystemFolderSetupConfig $systemfolder_config, \ilHttpSetupConfig $http_config)
 
 getCurlConnection (string $url)
 

Additional Inherited Members

- Protected Attributes inherited from ilSetupObjective
 $config
 

Detailed Description

Definition at line 7 of file class.ilNICKeyRegisteredObjective.php.

Member Function Documentation

◆ achieve()

ilNICKeyRegisteredObjective::achieve ( Setup\Environment  $environment)

Definition at line 38 of file class.ilNICKeyRegisteredObjective.php.

References $factory, $GLOBALS, XapiProxy\$req, $response, $url, ilCurlConnection\_isCurlExtensionLoaded(), getCurlConnection(), and getURLStringForNIC().

38  : Setup\Environment
39  {
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");
44 
46  throw new Setup\UnachievableException(
47  "CURL extension is required to register NIC."
48  );
49  }
50 
51  //ATTENTION: This makes ilProxySettings work. It uses global ilSetting...
52  $old_settings = $GLOBALS["ilSetting"] ?? null;
53  $GLOBALS["ilSetting"] = $settings;
54 
55  $url = $this->getURLStringForNIC($settings, $systemfolder_config, $http_config);
56  $req = $this->getCurlConnection($url);
57  $response = $req->exec();
58  $req->parseResponse($response);
59 
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 . "\""
64  );
65  }
66 
67  $status = explode("\n", $req->getResponseBody());
68  $settings->set("nic_enabled", "1");
69  $settings->set("inst_id", $status[2]);
70 
71  $GLOBALS["ilSetting"] = $old_settings;
72 
73  return $environment;
74  }
static _isCurlExtensionLoaded()
Check if curl extension is loaded.
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
$url
$response
$factory
Definition: metadata.php:58
getURLStringForNIC($settings, \ilSystemFolderSetupConfig $systemfolder_config, \ilHttpSetupConfig $http_config)
+ Here is the call graph for this function:

◆ getCurlConnection()

ilNICKeyRegisteredObjective::getCurlConnection ( string  $url)
protected

Definition at line 97 of file class.ilNICKeyRegisteredObjective.php.

References XapiProxy\$req.

Referenced by achieve().

98  {
99  $req = new \ilCurlConnection($url);
100  $req->init();
101 
102  $req->setOpt(CURLOPT_HEADER, 1);
103  $req->setOpt(CURLOPT_RETURNTRANSFER, 1);
104  $req->setOpt(CURLOPT_CONNECTTIMEOUT, self::SOCKET_TIMEOUT);
105  $req->setOpt(CURLOPT_MAXREDIRS, self::MAX_REDIRECTS);
106 
107  return $req;
108  }
$url
+ Here is the caller graph for this function:

◆ getHash()

ilNICKeyRegisteredObjective::getHash ( )

Definition at line 13 of file class.ilNICKeyRegisteredObjective.php.

13  : string
14  {
15  return hash("sha256", self::class);
16  }

◆ getLabel()

ilNICKeyRegisteredObjective::getLabel ( )

Definition at line 18 of file class.ilNICKeyRegisteredObjective.php.

18  : string
19  {
20  return "The NIC key is registered at the ILIAS Open Source society";
21  }

◆ getPreconditions()

ilNICKeyRegisteredObjective::getPreconditions ( Setup\Environment  $environment)

Definition at line 28 of file class.ilNICKeyRegisteredObjective.php.

28  : array
29  {
30  $http_config = $environment->getConfigFor("http");
31  return [
32  new \ilNICKeyStoredObjective($this->config),
33  new \ilSettingsFactoryExistsObjective(),
34  new \ilHttpConfigStoredObjective($http_config)
35  ];
36  }

◆ getURLStringForNIC()

ilNICKeyRegisteredObjective::getURLStringForNIC (   $settings,
\ilSystemFolderSetupConfig  $systemfolder_config,
\ilHttpSetupConfig  $http_config 
)
protected

Definition at line 76 of file class.ilNICKeyRegisteredObjective.php.

References $url, ilSystemFolderSetupConfig\getClientDescription(), ilSystemFolderSetupConfig\getClientName(), ilSystemFolderSetupConfig\getContactEMail(), ilSystemFolderSetupConfig\getContactFirstname(), ilSystemFolderSetupConfig\getContactLastname(), and ilHttpSetupConfig\getHttpPath().

Referenced by achieve().

76  : string
77  {
78  $inst_id = $settings->get("inst_id", 0);
79  $http_path = $http_config->getHttpPath();
80  $host_name = parse_url($http_path)["host"];
81 
82  $url = self::ILIAS_NIC_SERVER .
83  "?cmd=getid" .
84  "&inst_id=" . rawurlencode($inst_id) .
85  "&hostname=" . rawurlencode($host_name) .
86  "&inst_name=" . rawurlencode($systemfolder_config->getClientName()) .
87  "&inst_info=" . rawurlencode($systemfolder_config->getClientDescription()) .
88  "&http_path=" . rawurlencode($http_path) .
89  "&contact_firstname=" . rawurlencode($systemfolder_config->getContactFirstname()) .
90  "&contact_lastname=" . rawurlencode($systemfolder_config->getContactLastname()) .
91  "&contact_email=" . rawurlencode($systemfolder_config->getContactEMail()) .
92  "&nic_key=" . rawurlencode($settings->get("nic_key"));
93 
94  return $url;
95  }
$url
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isNotable()

ilNICKeyRegisteredObjective::isNotable ( )

Definition at line 23 of file class.ilNICKeyRegisteredObjective.php.

23  : bool
24  {
25  return true;
26  }

Field Documentation

◆ ILIAS_NIC_SERVER

const ilNICKeyRegisteredObjective::ILIAS_NIC_SERVER = "https://nic.ilias.de/index.php"

Definition at line 11 of file class.ilNICKeyRegisteredObjective.php.

◆ MAX_REDIRECTS

const ilNICKeyRegisteredObjective::MAX_REDIRECTS = 5

Definition at line 9 of file class.ilNICKeyRegisteredObjective.php.

◆ SOCKET_TIMEOUT

const ilNICKeyRegisteredObjective::SOCKET_TIMEOUT = 5

Definition at line 10 of file class.ilNICKeyRegisteredObjective.php.


The documentation for this class was generated from the following file: