ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
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 
90  // Add useful complex types. E.g. array("a","b") or array(1,2)
91  $this->server->wsdl->addComplexType(
92  'intArray',
93  'complexType',
94  'array',
95  '',
96  'SOAP-ENC:Array',
97  [],
98  [['ref' => 'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'xsd:int[]']],
99  'xsd:int'
100  );
101 
102 
103  $this->server->wsdl->addComplexType(
104  'stringArray',
105  'complexType',
106  'array',
107  '',
108  'SOAP-ENC:Array',
109  [],
110  [['ref' => 'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'xsd:string[]']],
111  'xsd:string'
112  );
113 
114  // isValidSession()
115  $this->server->register(
116  'isValidSession',
117  [
118  'ext_uid' => 'xsd:string',
119  'soap_pw' => 'xsd:string',
120  'new_user' => 'xsd:boolean'
121  ],
122  [
123  'valid' => 'xsd:boolean',
124  'firstname' => 'xsd:string',
125  'lastname' => 'xsd:string',
126  'email' => 'xsd:string'
127  ],
128  SERVICE_NAMESPACE,
129  SERVICE_NAMESPACE . '#isValidSession',
130  SERVICE_STYLE,
131  SERVICE_USE,
132  'Dummy Session Validation'
133  );
134 
135  return true;
136  }
137 }
Backward compatibility.
Definition: nusoap.php:4600
exit
Definition: login.php:28
$ext_uid
isValidSession(string $ext_uid, string $soap_pw, bool $new_user)
SOAP dummy authentication server.
$soap_pw
$new_user