WSCOMUN  2.0.0
Web Services Comunes para PHP/GVHidra
WSClientAutentica.php
1 <?php
13 
15 {
16 
29  public function autenticaUsuarioWS ($user, $pass)
30  {
31  try
32  {
33  $this->__clienteOn(self::KEYCLIENTE_AUTENTICA, true);
34  $clienteWS = $this->v_clienteWS[self::KEYCLIENTE_AUTENTICA];
35 
36 
37  $autenticaUsuarioWSRequest = new ArrayObject();
38  $autenticaUsuarioWSRequest->append(new SoapVar($user,XSD_STRING,null,null,'usuarioLDAP', self::$NAMESPACE_GVA));
39  $autenticaUsuarioWSRequest->append(new SoapVar($pass,XSD_STRING,null,null,'pwdLDAP', self::$NAMESPACE_GVA));
40  $miSoapRQ = new SoapVar($autenticaUsuarioWSRequest, SOAP_ENC_OBJECT,null,null,'autenticaUsuarioWSRequest', self::$NAMESPACE_GVA);
41  $token = $clienteWS->autenticaUsuarioWS($miSoapRQ);
42 
43  if ($this->getDebugMode())
44  {
45  $this->addDebugInfo(__CLASS__.':'.__METHOD__.'['.__FILE__.'-'.__LINE__.']'."\n");
46  if (is_object($clienteWS))
47  {
48  $this->addDebugInfo("RqH:\n ".$clienteWS->__getLastRequestHeaders());
49  $this->addDebugInfo("Rq:\n ".$clienteWS->__getLastRequest());
50  $this->addDebugInfo("RsH:\n ".$clienteWS->__getLastResponse());
51  $this->addDebugInfo("Rs:\n ".$clienteWS->__getLastResponseHeaders());
52  }
53  }
54 
55  if (is_object($token))
56  if (property_exists($token, 'token'))
57  if (!empty($token->token))
58  return $token;
59 
60  if ($this->getDebugMode())
61  {
62  $this->addDebugInfo(__CLASS__.':'.__METHOD__.'['.__FILE__.'-'.__LINE__.']'.'. Token vacío');
63  }
64 
65  return null;
66  }
67  catch (Exception $e)
68  {
69  if ($this->getDebugMode())
70  {
71  $this->addDebugInfo(__CLASS__.':'.__METHOD__.'['.__FILE__.'-'.__LINE__.']'."\n");
72  if (is_object($clienteWS))
73  {
74  $this->addDebugInfo("RqH:\n ".$clienteWS->__getLastRequestHeaders());
75  $this->addDebugInfo("Rq:\n ".$clienteWS->__getLastRequest());
76  $this->addDebugInfo("RsH:\n ".$clienteWS->__getLastResponse());
77  $this->addDebugInfo("Rs:\n ".$clienteWS->__getLastResponseHeaders());
78  }
79  throw $e;
80  }
81  else throw $e;
82  }
83  }//autenticaUsuarioWS
84 
85 
86 
99  public function autenticaUsuarioLDAPWS ($user, $pass)
100  {
101  try
102  {
103  $this->__clienteOn(self::KEYCLIENTE_AUTENTICA, true);
104  $clienteWS = $this->v_clienteWS[self::KEYCLIENTE_AUTENTICA];
105 
106  $autenticaUsuarioLDAPWSRequest = new ArrayObject();
107  $autenticaUsuarioLDAPWSRequest->append(new SoapVar($user,XSD_STRING,null,null,'usuarioLDAP', self::$NAMESPACE_GVA));
108  $autenticaUsuarioLDAPWSRequest->append(new SoapVar($pass,XSD_STRING,null,null,'pwdLDAP', self::$NAMESPACE_GVA));
109  $miSoapRQ = new SoapVar($autenticaUsuarioLDAPWSRequest, SOAP_ENC_OBJECT,null,null,'autenticaUsuarioLDAPWSRequest', self::$NAMESPACE_GVA);
110  $token = $clienteWS->autenticaUsuarioLDAPWS($miSoapRQ);
111 
112  if ($this->getDebugMode())
113  {
114  $this->addDebugInfo(__CLASS__.':'.__METHOD__.'['.__FILE__.'-'.__LINE__.']'."\n");
115  if (is_object($clienteWS))
116  {
117  $this->addDebugInfo("RqH:\n ".$clienteWS->__getLastRequestHeaders());
118  $this->addDebugInfo("Rq:\n ".$clienteWS->__getLastRequest());
119  $this->addDebugInfo("RsH:\n ".$clienteWS->__getLastResponse());
120  $this->addDebugInfo("Rs:\n ".$clienteWS->__getLastResponseHeaders());
121  }
122  }
123 
124  if (is_object($token))
125  if (property_exists($token, 'token'))
126  if (!empty($token->token))
127  return $token;
128 
129  if ($this->getDebugMode())
130  {
131  $this->addDebugInfo(__CLASS__.':'.__METHOD__.'['.__FILE__.'-'.__LINE__.']'.'. Token vacío');
132  }
133 
134  return null;
135  }
136  catch (Exception $e)
137  {
138  if ($this->getDebugMode())
139  {
140  $this->addDebugInfo(__CLASS__.':'.__METHOD__.'['.__FILE__.'-'.__LINE__.']'."\n");
141  if (is_object($clienteWS))
142  {
143  $this->addDebugInfo("RqH:\n ".$clienteWS->__getLastRequestHeaders());
144  $this->addDebugInfo("Rq:\n ".$clienteWS->__getLastRequest());
145  $this->addDebugInfo("RsH:\n ".$clienteWS->__getLastResponse());
146  $this->addDebugInfo("Rs:\n ".$clienteWS->__getLastResponseHeaders());
147  }
148  throw $e;
149  }
150  else throw $e;
151  }
152  }//Fin autenticaUsuarioLDAPWS
153 
154 
167  public function autenticaConFirmaWS ($firmaB64, $codigoEntidad = null)
168  {
169  try
170  {
171  $this->__clienteOn(self::KEYCLIENTE_AUTENTICA);
172  $clienteWS = $this->v_clienteWS[self::KEYCLIENTE_AUTENTICA];
173  $autenticaConFirmaWSRequest = new ArrayObject();
174  $autenticaConFirmaWSRequest->append(new SoapVar($firmaB64, XSD_STRING,null,null,'firma', self::$NAMESPACE_GVA));
175  $autenticaConFirmaWSRequest->append(new SoapVar($codigoEntidad,XSD_STRING,null,null,'codigoEntidad', self::$NAMESPACE_GVA));
176  $miSoapRQ = new SoapVar($autenticaConFirmaWSRequest, SOAP_ENC_OBJECT,null,null,'autenticaConFirmaWSRequest', self::$NAMESPACE_GVA);
177  $token = $clienteWS->autenticaConFirmaWS($miSoapRQ);
178  return ($token);
179  }
180  catch (Exception $e)
181  {
182  if ($this->getDebugMode())
183  {
184  $this->addDebugInfo(__CLASS__.':'.__METHOD__.'['.__FILE__.'-'.__LINE__.']'."\n");
185  if (is_object($clienteWS))
186  {
187  $this->addDebugInfo("RqH:\n ".$clienteWS->__getLastRequestHeaders());
188  $this->addDebugInfo("Rq:\n ".$clienteWS->__getLastRequest());
189  $this->addDebugInfo("RsH:\n ".$clienteWS->__getLastResponse());
190  $this->addDebugInfo("Rs:\n ".$clienteWS->__getLastResponseHeaders());
191  }
192  throw $e;
193  }
194  else throw $e;
195  }
196  }//Fin autenticaConFirmaWS
197 
198 
199 
219  public function getInformacionWS ($token)
220  {
221  if (empty($token))
222  {
223  if ($this->getDebugMode())
224  $this->addDebugInfo(__CLASS__.':'.__METHOD__.'['.__FILE__.'-'.__LINE__.']'.'. Token vacío');
225 
226  throw new Exception (
227  __CLASS__.':'.__METHOD__.'['.__FILE__.'-'.__LINE__.']'.
228  '. Token vacío'
229  );
230  }
231 
232  try
233  {
234  $this->__clienteOn(self::KEYCLIENTE_AUTENTICA);
235  $clienteWS = $this->v_clienteWS[self::KEYCLIENTE_AUTENTICA];
236  $resultado = $clienteWS->getInformacionWS($token);
237  return $resultado;
238  }
239  catch (Exception $e)
240  {
241  if ($this->getDebugMode())
242  {
243  $this->addDebugInfo(__CLASS__.':'.__METHOD__.'['.__FILE__.'-'.__LINE__.']'."\n");
244  if (is_object($clienteWS))
245  {
246  $this->addDebugInfo("RqH:\n ".$clienteWS->__getLastRequestHeaders());
247  $this->addDebugInfo("Rq:\n ".$clienteWS->__getLastRequest());
248  $this->addDebugInfo("RsH:\n ".$clienteWS->__getLastResponse());
249  $this->addDebugInfo("Rs:\n ".$clienteWS->__getLastResponseHeaders());
250  }
251  }
252  throw $e;
253  }
254  }//Fin getInformacionWS
255 
256 
271  public function getInformacionLDAP ($user, $pass)
272  {
273  $resultado = null;
274  try //Autenticación
275  {
276  $token = $this->autenticaUsuarioLDAPWS($user, $pass);
277 
278  if (!is_object($token))//Si no es un objeto
279  {
280  if ($this->getDebugMode())
281  {
282  $this->addDebugInfo(__CLASS__.':'.__METHOD__.'['.__FILE__.'-'.__LINE__.']'.'. Token vacío. No es objeto');
283  }
284  return null;
285  }
286  else
287  {
288  if (!property_exists($token, 'token'))//No existe la property
289  {
290  if ($this->getDebugMode())
291  {
292  $this->addDebugInfo(__CLASS__.':'.__METHOD__.'['.__FILE__.'-'.__LINE__.']'.'. Token vacío. No hay propiedad');
293  }
294  return null;
295  }
296  else
297  {
298  if (empty($token->token)) //La propiedad no tiene valor
299  {
300  if ($this->getDebugMode())
301  {
302  $this->addDebugInfo(__CLASS__.':'.__METHOD__.'['.__FILE__.'-'.__LINE__.']'.'. Token vacío. Propiedad vacía');
303  }
304  return null;
305  }
306  }
307  }
308  }
309  catch (Exception $e)
310  {
311  if ($this->getDebugMode())
312  $this->addDebugInfo(__CLASS__.':'.__METHOD__.'['.__FILE__.'-'.__LINE__.']'."\n");
313  throw $e;
314  }
315 
316  try //Información
317  {
318  $resultado = $this->getInformacionWS($token);
319  }
320  catch (Exception $e)
321  {
322  if ($this->getDebugMode())
323  $this->addDebugInfo(__CLASS__.':'.__METHOD__.'['.__FILE__.'-'.__LINE__.']'."\n");
324  throw $e;
325  }
326  return $resultado;
327  }//Fin getInformacionLDAP
328 
329 
344  public function getInformacionHDFI ($user, $pass)
345  {
346  $resultado = null;
347  try //Autenticación
348  {
349  $token = $this->autenticaUsuarioWS($user, $pass);
350 
351  if (!is_object($token))//Si no es un objeto
352  {
353  if ($this->getDebugMode())
354  {
355  $this->addDebugInfo(__CLASS__.':'.__METHOD__.'['.__FILE__.'-'.__LINE__.']'.'. Token vacío. No es objeto');
356  }
357  return null;
358  }
359  else
360  {
361  if (!property_exists($token, 'token'))//No existe la property
362  {
363  if ($this->getDebugMode())
364  {
365  $this->addDebugInfo(__CLASS__.':'.__METHOD__.'['.__FILE__.'-'.__LINE__.']'.'. Token vacío. No hay propiedad');
366  }
367  return null;
368  }
369  else
370  {
371  if (empty($token->token)) //La propiedad no tiene valor
372  {
373  if ($this->getDebugMode())
374  {
375  $this->addDebugInfo(__CLASS__.':'.__METHOD__.'['.__FILE__.'-'.__LINE__.']'.'. Token vacío. Propiedad vacía');
376  }
377  return null;
378  }
379  }
380  }
381  }
382  catch (Exception $e)
383  {
384  if ($this->getDebugMode())
385  $this->addDebugInfo(__CLASS__.':'.__METHOD__.'['.__FILE__.'-'.__LINE__.']'."\n");
386  throw $e;
387  }
388 
389  try //Información
390  {
391  $resultado = $this->getInformacionWS($token);
392  }
393  catch (Exception $e)
394  {
395  if ($this->getDebugMode())
396  $this->addDebugInfo(__CLASS__.':'.__METHOD__.'['.__FILE__.'-'.__LINE__.']'."\n");
397  throw $e;
398  }
399  return $resultado;
400  }//Fin getInformacionHDFI
401 
402 }
403 
404 ?>
autenticaUsuarioLDAPWS($user, $pass)
autenticaConFirmaWS($firmaB64, $codigoEntidad=null)
__clienteOn($tipo, $trazabilidadPai=true, $opcionesClienteWS=null)
getInformacionLDAP($user, $pass)
autenticaUsuarioWS($user, $pass)
getInformacionHDFI($user, $pass)