ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
class.ilSoapDummyAuthServer.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /******************************************************************************
6  *
7  * This file is part of ILIAS, a powerful learning management system.
8  *
9  * ILIAS is licensed with the GPL-3.0, you should have received a copy
10  * of said license along with the source code.
11  *
12  * If this is not the case or you just want to try ILIAS, you'll find
13  * us at:
14  * https://www.ilias.de
15  * https://github.com/ILIAS-eLearning
16  *
17  *****************************************************************************/
18 
25 include_once './webservice/soap/lib/nusoap.php';
26 
27 function isValidSession(string $ext_uid, string $soap_pw, bool $new_user): array
28 {
29  $ret = [
30  "firstname" => "",
31  "lastname" => "",
32  "email" => ""
33  ];
34 
35  // generate some dummy values
36  if ($new_user) {
37  $ret["firstname"] = "first " . $ext_uid;
38  $ret["lastname"] = "last " . $ext_uid;
39  $ret["email"] = $ext_uid . "@de.de";
40  }
41 
42  // return valid authentication if user id equals soap password
43  if ($ext_uid === $soap_pw) {
44  $ret["valid"] = true;
45  } else {
46  $ret["valid"] = false;
47  }
48 
49  return $ret;
50 }
51 
53 {
54  public ?soap_server $server = null;
55 
56 
57  public function __construct($a_use_wsdl = true)
58  {
59  define('SERVICE_NAME', 'ILIAS SOAP Dummy Authentication Server');
60  define('SERVICE_NAMESPACE', 'urn:ilSoapDummyAuthServer');
61  define('SERVICE_STYLE', 'rpc');
62  define('SERVICE_USE', 'encoded');
63 
64  $this->server = new soap_server();
65 
66  if ($a_use_wsdl) {
67  $this->enableWSDL();
68  }
69 
70  $this->registerMethods();
71  }
72 
73  public function start(): void
74  {
75  $postdata = file_get_contents("php://input");
76  $this->server->service($postdata);
77  exit();
78  }
79 
80  public function enableWSDL(): bool
81  {
82  $this->server->configureWSDL(SERVICE_NAME, SERVICE_NAMESPACE);
83 
84  return true;
85  }
86 
87  public function registerMethods(): bool
88  {
89  // Add useful complex types. E.g. array("a","b") or array(1,2)
90  $this->server->wsdl->addComplexType(
91  'intArray',
92  'complexType',
93  'array',
94  '',
95  'SOAP-ENC:Array',
96  [],
97  [['ref' => 'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'xsd:int[]']],
98  'xsd:int'
99  );
100 
101 
102  $this->server->wsdl->addComplexType(
103  'stringArray',
104  'complexType',
105  'array',
106  '',
107  'SOAP-ENC:Array',
108  [],
109  [['ref' => 'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'xsd:string[]']],
110  'xsd:string'
111  );
112 
113  // isValidSession()
114  $this->server->register(
115  'isValidSession',
116  [
117  'ext_uid' => 'xsd:string',
118  'soap_pw' => 'xsd:string',
119  'new_user' => 'xsd:boolean'
120  ],
121  [
122  'valid' => 'xsd:boolean',
123  'firstname' => 'xsd:string',
124  'lastname' => 'xsd:string',
125  'email' => 'xsd:string'
126  ],
127  SERVICE_NAMESPACE,
128  SERVICE_NAMESPACE . '#isValidSession',
129  SERVICE_STYLE,
130  SERVICE_USE,
131  'Dummy Session Validation'
132  );
133 
134  return true;
135  }
136 }
Backward compatibility.
Definition: nusoap.php:4598
exit
Definition: login.php:29
$ext_uid
isValidSession(string $ext_uid, string $soap_pw, bool $new_user)
SOAP dummy authentication server.
$soap_pw
$new_user