ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilSoapDummyAuthServer.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21require_once __DIR__ . '/../../soap/lib/nusoap.php';
22
23function isValidSession(string $ext_uid, string $soap_pw, bool $new_user): array
24{
25 $ret = [
26 'firstname' => '',
27 'lastname' => '',
28 'email' => ''
29 ];
30
31 // generate some dummy values
32 if ($new_user) {
33 $ret['firstname'] = 'first ' . $ext_uid;
34 $ret['lastname'] = 'last ' . $ext_uid;
35 $ret['email'] = $ext_uid . '@de.de';
36 }
37
38 // return valid authentication if user id equals soap password
39 if ($ext_uid === $soap_pw) {
40 $ret['valid'] = true;
41 } else {
42 $ret['valid'] = false;
43 }
44
45 return $ret;
46}
47
49{
50 public ?soap_server $server = null;
51
52 public function __construct(bool $a_use_wsdl = true)
53 {
54 define('SERVICE_NAME', 'ILIAS SOAP Dummy Authentication Server');
55 define('SERVICE_NAMESPACE', 'urn:ilSoapDummyAuthServer');
56 define('SERVICE_STYLE', 'rpc');
57 define('SERVICE_USE', 'encoded');
58
59 $this->server = new soap_server();
60
61 if ($a_use_wsdl) {
62 $this->enableWSDL();
63 }
64
65 $this->registerMethods();
66 }
67
68 public function start(): void
69 {
70 $postdata = file_get_contents('php://input');
71 $this->server->service($postdata);
72 exit();
73 }
74
75 public function enableWSDL(): bool
76 {
77 $this->server->configureWSDL(SERVICE_NAME, SERVICE_NAMESPACE);
78
79 return true;
80 }
81
82 public function registerMethods(): bool
83 {
84 // Add useful complex types. E.g. array("a","b") or array(1,2)
85 $this->server->wsdl->addComplexType(
86 'intArray',
87 'complexType',
88 'array',
89 '',
90 'SOAP-ENC:Array',
91 [],
92 [['ref' => 'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'xsd:int[]']],
93 'xsd:int'
94 );
95
96
97 $this->server->wsdl->addComplexType(
98 'stringArray',
99 'complexType',
100 'array',
101 '',
102 'SOAP-ENC:Array',
103 [],
104 [['ref' => 'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'xsd:string[]']],
105 'xsd:string'
106 );
107
108 $this->server->register(
109 'isValidSession',
110 [
111 'ext_uid' => 'xsd:string',
112 'soap_pw' => 'xsd:string',
113 'new_user' => 'xsd:boolean'
114 ],
115 [
116 'valid' => 'xsd:boolean',
117 'firstname' => 'xsd:string',
118 'lastname' => 'xsd:string',
119 'email' => 'xsd:string'
120 ],
121 SERVICE_NAMESPACE,
122 SERVICE_NAMESPACE . '#isValidSession',
123 SERVICE_STYLE,
124 SERVICE_USE,
125 'Dummy Session Validation'
126 );
127
128 return true;
129 }
130}
isValidSession(string $ext_uid, string $soap_pw, bool $new_user)
__construct(bool $a_use_wsdl=true)
Backward compatibility.
Definition: nusoap.php:4567
$soap_pw
exit
$ext_uid
$new_user