ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilSOAPAuth.php
Go to the documentation of this file.
1 <?php
2 
18 declare(strict_types=1);
19 
20 include_once("./webservice/soap/lib/nusoap.php");
21 
23 {
24  public static function testConnection(string $a_ext_uid, string $a_soap_pw, bool $a_new_user): string
25  {
26  global $ilSetting;
27 
28  $settings = $ilSetting->getAll();
29 
30  $server_hostname = (string) ($settings["soap_auth_server"] ?? '');
31  $server_port = (int) ($settings["soap_auth_port"] ?? 0);
32  $server_uri = (string) ($settings["soap_auth_uri"] ?? '');
33  $namespace = (string) ($settings["soap_auth_namespace"] ?? '');
34  $use_dotnet = (bool) ($settings["soap_auth_use_dotnet"] ?? false);
35  $uri = "http://";
36  if (isset($settings["soap_auth_use_https"]) && $settings["soap_auth_use_https"]) {
37  $uri = "https://";
38  }
39 
40  $uri .= $server_hostname;
41 
42  if ($server_port > 0) {
43  $uri .= ":" . $server_port;
44  }
45 
46  if ($server_uri !== "") {
47  $uri .= "/" . $server_uri;
48  }
49 
50  require_once './webservice/soap/lib/nusoap.php';
51  $soap_client = new nusoap_client($uri);
52  if ($err = $soap_client->getError()) {
53  return "SOAP Authentication Initialisation Error: " . $err;
54  }
55 
56  $soapAction = "";
57  $nspref = "";
58  if ($use_dotnet) {
59  $soapAction = $namespace . "/isValidSession";
60  $nspref = "ns1:";
61  }
62 
63  $valid = $soap_client->call(
64  'isValidSession',
65  [
66  $nspref . 'ext_uid' => $a_ext_uid,
67  $nspref . 'soap_pw' => $a_soap_pw,
68  $nspref . 'new_user' => $a_new_user
69  ],
70  $namespace,
71  $soapAction
72  );
73 
74  return
75  "<br>== Request ==" .
76  '<br><pre>' . htmlspecialchars(str_replace("\" ", "\"\n ", str_replace(">", ">\n", $soap_client->request)), ENT_QUOTES) . '</pre><br>' .
77  "<br>== Response ==" .
78  "<br>Valid: -" . $valid["valid"] . "-" .
79  '<br><pre>' . htmlspecialchars(str_replace("\" ", "\"\n ", str_replace(">", ">\n", $soap_client->response)), ENT_QUOTES) . '</pre>';
80  }
81 }
if($err=$client->getError()) $namespace
array $settings
Setting values (LTI parameters, custom parameters and local parameters).
Definition: System.php:200
$valid
[nu]soapclient higher level class for easy usage.
Definition: nusoap.php:7205
static testConnection(string $a_ext_uid, string $a_soap_pw, bool $a_new_user)
global $ilSetting
Definition: privfeed.php:17