ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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 55 of file class.ilNICKeyRegisteredObjective.php.

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

References $GLOBALS, XapiProxy\$req, $response, $url, ilCurlConnection\_isCurlExtensionLoaded(), getCurlConnection(), getRegistrationProblem(), ILIAS\Setup\Environment\getResource(), and getURLStringForNIC().

+ Here is the call graph for this function:

◆ getCurlConnection()

ilNICKeyRegisteredObjective::getCurlConnection ( string  $url)
protected

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

180 {
181 $req = new \ilCurlConnection($url);
182 $req->init();
183
184 $req->setOpt(CURLOPT_HEADER, 1);
185 $req->setOpt(CURLOPT_RETURNTRANSFER, 1);
186 $req->setOpt(CURLOPT_CONNECTTIMEOUT, self::SOCKET_TIMEOUT);
187 $req->setOpt(CURLOPT_MAXREDIRS, self::MAX_REDIRECTS);
188
189 return $req;
190 }

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 new ilInstIdDefaultStoredObjective($this->config)
52 ];
53 }

◆ getRegistrationProblem()

ilNICKeyRegisteredObjective::getRegistrationProblem ( array  $nic_response_parts)
protected

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

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

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 158 of file class.ilNICKeyRegisteredObjective.php.

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

References $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 $factory = $environment->getResource(Setup\Environment::RESOURCE_SETTINGS_FACTORY);
116 $settings = $factory->settingsFor("common");
117 return ($settings->get("inst_id") === '0') && $this->config->getRegisterNIC();
118 }

◆ 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: