This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace Skautis\Wsdl; |
||
4 | |||
5 | use Skautis\EventDispatcher\EventDispatcherInterface; |
||
6 | use Skautis\Config; |
||
7 | use Skautis\User; |
||
8 | |||
9 | /** |
||
10 | * Třída pro správu webových služeb SkautISu |
||
11 | */ |
||
12 | class WsdlManager |
||
13 | { |
||
14 | |||
15 | /** |
||
16 | * @var WebServiceFactoryInterface |
||
17 | */ |
||
18 | protected $webServiceFactory; |
||
19 | |||
20 | /** |
||
21 | * @var Config |
||
22 | */ |
||
23 | protected $config; |
||
24 | |||
25 | /** |
||
26 | * Aliasy webových služeb pro rychlý přístup |
||
27 | * |
||
28 | * @var array |
||
29 | */ |
||
30 | protected $aliases = [ |
||
31 | "user" => "UserManagement", |
||
32 | "usr" => "UserManagement", |
||
33 | "org" => "OrganizationUnit", |
||
34 | "app" => "ApplicationManagement", |
||
35 | "event" => "Events", |
||
36 | "events" => "Events", |
||
37 | ]; |
||
38 | |||
39 | /** |
||
40 | * Dostupné webové služby SkautISu |
||
41 | * |
||
42 | * @var array |
||
43 | */ |
||
44 | protected $supportedWebServices = [ |
||
45 | "ApplicationManagement", |
||
46 | "ContentManagement", |
||
47 | "DocumentStorage", |
||
48 | "Evaluation", |
||
49 | "Events", |
||
50 | "Exports", |
||
51 | "GoogleApps", |
||
52 | "Grants", |
||
53 | "Insurance", |
||
54 | "Journal", |
||
55 | "Material", |
||
56 | "Message", |
||
57 | "OrganizationUnit", |
||
58 | "Power", |
||
59 | "Reports", |
||
60 | "Summary", |
||
61 | "Task", |
||
62 | "Telephony", |
||
63 | "UserManagement", |
||
64 | "Vivant", |
||
65 | "Welcome", |
||
66 | ]; |
||
67 | |||
68 | /** |
||
69 | * @var array |
||
70 | */ |
||
71 | protected $webServiceListeners = []; |
||
72 | |||
73 | /** |
||
74 | * Pole aktivních webových služeb |
||
75 | * |
||
76 | * @var array |
||
77 | */ |
||
78 | protected $webServices = []; |
||
79 | |||
80 | |||
81 | /** |
||
82 | * @param WebServiceFactoryInterface $webServiceFactory továrna pro vytváření objektů webových služeb |
||
83 | * @param Config $config |
||
84 | */ |
||
85 | 3 | public function __construct(WebServiceFactoryInterface $webServiceFactory, Config $config) |
|
86 | { |
||
87 | 3 | $this->webServiceFactory = $webServiceFactory; |
|
88 | 3 | $this->config = $config; |
|
89 | 3 | } |
|
90 | |||
91 | /** |
||
92 | * @return Config |
||
93 | */ |
||
94 | public function getConfig() |
||
95 | { |
||
96 | return $this->config; |
||
97 | } |
||
98 | |||
99 | /** |
||
100 | * Získá objekt webové služby |
||
101 | * |
||
102 | * @param string $name jméno nebo alias webové služby |
||
103 | * @param string|null $loginId skautIS login token |
||
104 | * @return WebServiceInterface |
||
105 | */ |
||
106 | 1 | public function getWebService($name, $loginId = null) |
|
107 | { |
||
108 | 1 | $name = $this->getWebServiceName($name); |
|
109 | 1 | $key = $loginId . '_' . $name . ($this->config->isTestMode() ? '_Test' : ''); |
|
110 | |||
111 | 1 | if (!isset($this->webServices[$key])) { |
|
112 | 1 | $options = $this->config->getSoapOptions(); |
|
113 | 1 | $options[User::ID_LOGIN] = $loginId; |
|
114 | 1 | $this->webServices[$key] = $this->createWebService($name, $options); |
|
115 | 1 | } |
|
116 | |||
117 | 1 | return $this->webServices[$key]; |
|
118 | } |
||
119 | |||
120 | /** |
||
121 | * Vytváří objekt webové služby |
||
122 | * |
||
123 | * @param string $name jméno webové služby |
||
124 | * @param array $options volby pro SoapClient |
||
125 | * @return WebService|mixed |
||
126 | */ |
||
127 | 1 | public function createWebService($name, array $options = []) |
|
128 | { |
||
129 | 1 | $webService = $this->webServiceFactory->createWebService($this->getWebServiceUrl($name), $options); |
|
130 | |||
131 | 1 | if ($webService instanceof EventDispatcherInterface) { |
|
132 | // Zaregistruj listenery na vytvořeném objektu webové služby, pokud je to podporováno |
||
133 | foreach ($this->webServiceListeners as $listener) { |
||
134 | $webService->subscribe($listener['eventName'], $listener['callback']); |
||
135 | } |
||
136 | } |
||
137 | |||
138 | 1 | return $webService; |
|
139 | } |
||
140 | |||
141 | /** |
||
142 | * Vrací celé jméno webové služby |
||
143 | * |
||
144 | * @param string $name jméno nebo alias webové služby |
||
145 | * @return string |
||
146 | * @throws WsdlException |
||
147 | */ |
||
148 | 1 | protected function getWebServiceName($name) |
|
149 | { |
||
150 | 1 | if (in_array($name, $this->supportedWebServices)) { |
|
151 | // služba s daným jménem existuje |
||
152 | 1 | return $name; |
|
153 | } |
||
154 | if (array_key_exists($name, $this->aliases) && in_array($this->aliases[$name], $this->supportedWebServices)) { |
||
155 | // je definovaný alias pro tuto službu |
||
156 | return $this->aliases[$name]; |
||
157 | } |
||
158 | throw new WsdlException("Web service '$name' not found."); |
||
159 | } |
||
160 | |||
161 | /** |
||
162 | * Vrací URL webové služby podle jejího jména |
||
163 | * |
||
164 | * @param string $name celé jméno webové služby |
||
165 | * @return string |
||
166 | */ |
||
167 | 1 | protected function getWebServiceUrl($name) |
|
168 | { |
||
169 | 1 | return $this->config->getBaseUrl() . "JunakWebservice/" . rawurlencode($name) . ".asmx?WSDL"; |
|
170 | } |
||
171 | |||
172 | /** |
||
173 | * Vrací seznam webových služeb, které podporuje |
||
174 | * |
||
175 | * @return array |
||
176 | */ |
||
177 | 1 | public function getSupportedWebServices() |
|
178 | { |
||
179 | 1 | return $this->supportedWebServices; |
|
180 | } |
||
181 | |||
182 | /** |
||
183 | * @return bool |
||
184 | */ |
||
185 | public function isMaintenance() |
||
186 | { |
||
187 | $headers = get_headers($this->getWebServiceUrl("UserManagement")); |
||
188 | return !$headers || !in_array('HTTP/1.1 200 OK', $headers); |
||
0 ignored issues
–
show
|
|||
189 | } |
||
190 | |||
191 | /** |
||
192 | * Přidá listener na spravovaných vytvářených webových služeb. |
||
193 | * |
||
194 | * @param string $eventName |
||
195 | * @param callable $callback |
||
196 | */ |
||
197 | public function addWebServiceListener($eventName, callable $callback) |
||
198 | { |
||
199 | $this->webServiceListeners[] = [ |
||
200 | 'eventName' => $eventName, |
||
201 | 'callback' => $callback, |
||
202 | ]; |
||
203 | } |
||
204 | } |
||
205 |
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using
empty(..)
or! empty(...)
instead.