ILIAS  release_8 Revision v8.24
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)
 
 isApplicable (Setup\Environment $environment)
 @inheritDoc More...
 
- Public Member Functions inherited from ilSetupObjective
 __construct (Setup\Config $config)
 

Data Fields

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

Protected Member Functions

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

Additional Inherited Members

- Protected Attributes inherited from ilSetupObjective
Setup Config $config
 

Detailed Description

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

Member Function Documentation

◆ achieve()

ilNICKeyRegisteredObjective::achieve ( Setup\Environment  $environment)

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

54 : Setup\Environment
55 {
56 $factory = $environment->getResource(Setup\Environment::RESOURCE_SETTINGS_FACTORY);
57 $settings = $factory->settingsFor("common");
58 $systemfolder_config = $environment->getConfigFor("systemfolder");
59 $http_config = $environment->getConfigFor("http");
60
62 throw new Setup\UnachievableException(
63 "CURL extension is required to register NIC."
64 );
65 }
66
67 //ATTENTION: This makes ilProxySettings work. It uses global ilSetting...
68 $old_settings = $GLOBALS["ilSetting"] ?? null;
69 $GLOBALS["ilSetting"] = $settings;
70
71 $old_DIC = $GLOBALS["DIC"];
72 $GLOBALS["DIC"] = new ILIAS\DI\Container();
73 $GLOBALS["DIC"]["ilSetting"] = $GLOBALS["ilSetting"];
74
75 $url = $this->getURLStringForNIC($settings, $systemfolder_config, $http_config);
76 $req = $this->getCurlConnection($url);
77 $response = $req->exec();
78 $req->parseResponse($response);
79
80
81 if ($req->getInfo()["http_code"] != "200") {
82 $settings->set("nic_enabled", "-1");
83 throw new Setup\UnachievableException(
84 "Could not connect to NIC server at \"" . self::ILIAS_NIC_SERVER . "\""
85 );
86 }
87
88 $status = explode("\n", $req->getResponseBody());
89
90 $nic_id = (string) ($status[2] ?? '');
91 if ($nic_id === '') {
92 $settings->set("nic_enabled", "-1");
93 throw new Setup\UnachievableException(
94 "Did not receive valid installation id from " .
95 "NIC server (\"" . self::ILIAS_NIC_SERVER . "\") for URL: $url" .
96 $this->getRegistrationProblem($status)
97 );
98 }
99
100 $settings->set("nic_enabled", "1");
101 $settings->set("inst_id", $status[2]);
102
103 $GLOBALS["DIC"] = $old_DIC;
104 $GLOBALS["ilSetting"] = $old_settings;
105
106
107 return $environment;
108 }
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
Customizing of pimple-DIC for ILIAS.
Definition: Container.php:32
getURLStringForNIC($settings, \ilSystemFolderSetupConfig $systemfolder_config, \ilHttpSetupConfig $http_config)
getRegistrationProblem(array $nic_response_parts)
$factory
Definition: metadata.php:75
array $settings
Setting values (LTI parameters, custom parameters and local parameters).
Definition: System.php:200
catch(\Exception $e) $req
Definition: xapiproxy.php:93
$url
$response

References $factory, $GLOBALS, XapiProxy\$req, $response, ILIAS\LTI\ToolProvider\$settings, $url, ilCurlConnection\_isCurlExtensionLoaded(), getCurlConnection(), getRegistrationProblem(), and getURLStringForNIC().

+ Here is the call graph for this function:

◆ getCurlConnection()

ilNICKeyRegisteredObjective::getCurlConnection ( string  $url)
protected

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

178 {
179 $req = new \ilCurlConnection($url);
180 $req->init();
181
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);
186
187 return $req;
188 }

References XapiProxy\$req, and $url.

Referenced by achieve().

+ Here is the caller graph for this function:

◆ getHash()

ilNICKeyRegisteredObjective::getHash ( )

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

29 : string
30 {
31 return hash("sha256", self::class);
32 }

◆ getLabel()

ilNICKeyRegisteredObjective::getLabel ( )

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

34 : string
35 {
36 return "The NIC key is registered at the ILIAS Open Source society";
37 }

◆ getPreconditions()

ilNICKeyRegisteredObjective::getPreconditions ( Setup\Environment  $environment)

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

44 : array
45 {
46 $http_config = $environment->getConfigFor("http");
47 return [
48 new \ilNICKeyStoredObjective($this->config),
49 new \ilSettingsFactoryExistsObjective(),
50 new \ilHttpConfigStoredObjective($http_config)
51 ];
52 }

◆ getRegistrationProblem()

ilNICKeyRegisteredObjective::getRegistrationProblem ( array  $nic_response_parts)
protected

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

118 : string
119 {
120 $error_code = trim((string) ($nic_response_parts[1] ?? ''));
121 $message = 'Unknown reason';
122
123 switch ($error_code) {
124 case 'INIC-F-01':
125 $message = "NIC server could not connect to database";
126 break;
127
128 case 'INIC-F-04':
129 $message = "NIC server could not execute query";
130 break;
131
132 case 'INIC-E-04':
133 $message = "The installation name was missing in request, please check your " .
134 "configuration (systemfolder.client.name)";
135 break;
136
137 case 'INIC-E-08':
138 $message = "The http path or contact's lastname was missing in request, please check " .
139 "your configuration (http.path or systemfolder.contact.lastname)";
140 break;
141
142 case 'INIC-E-09':
143 $message = "The contact's firstname was missing in request, please check your " .
144 "configuration (systemfolder.contact.firstname)";
145 break;
146
147 case 'INIC-E-15':
148 $message = "The contact's email address was missing in request, please check your " .
149 "configuration (systemfolder.contact.email)";
150 break;
151 }
152
153 return 'Reason: ' . $message;
154 }
$message
Definition: xapiexit.php:32

References $message.

Referenced by achieve().

+ Here is the caller graph for this function:

◆ getURLStringForNIC()

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

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

156 : string
157 {
158 $inst_id = (string) $settings->get('inst_id', '0');
159 $http_path = $http_config->getHttpPath();
160 $host_name = parse_url($http_path)["host"];
161
162 $url = self::ILIAS_NIC_SERVER .
163 "?cmd=getid" .
164 "&inst_id=" . rawurlencode($inst_id) .
165 "&hostname=" . rawurlencode($host_name) .
166 "&inst_name=" . rawurlencode($systemfolder_config->getClientName() ?? '') .
167 "&inst_info=" . rawurlencode($systemfolder_config->getClientDescription() ?? '') .
168 "&http_path=" . rawurlencode($http_path) .
169 "&contact_firstname=" . rawurlencode($systemfolder_config->getContactFirstname()) .
170 "&contact_lastname=" . rawurlencode($systemfolder_config->getContactLastname()) .
171 "&contact_email=" . rawurlencode($systemfolder_config->getContactEMail()) .
172 "&nic_key=" . rawurlencode($settings->get("nic_key"));
173
174 return $url;
175 }

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

Referenced by achieve().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isApplicable()

ilNICKeyRegisteredObjective::isApplicable ( Setup\Environment  $environment)

@inheritDoc

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

113 : bool
114 {
115 return true;
116 }

◆ isNotable()

ilNICKeyRegisteredObjective::isNotable ( )

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

39 : bool
40 {
41 return true;
42 }

Field Documentation

◆ ILIAS_NIC_SERVER

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

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

◆ MAX_REDIRECTS

const ilNICKeyRegisteredObjective::MAX_REDIRECTS = 5

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

◆ SOCKET_TIMEOUT

const ilNICKeyRegisteredObjective::SOCKET_TIMEOUT = 5

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


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