32 public function obtenerContexto($codApp, $tokenSSO, $ip=null, $agent=null, $vParametros=null)
37 $clienteWS = $this->
__getClient(self::KEYCLIENTE_GVLOGIN);
41 if (($ip == null) || empty($ip))
43 $ip = $this->getAgentIP();
45 if (($agent == null) || empty($agent))
47 $agent = $this->getUserAgent();
52 $origenWS = new \ArrayObject();
53 $origenWS->append(
new \
SoapVar($ip, XSD_STRING, null, null,
'ip', self::$NAMESPACE_LOGIN));
54 $origenWS->append(
new \
SoapVar($agent, XSD_STRING, null, null,
'agent', self::$NAMESPACE_LOGIN));
56 $mainWS = new \ArrayObject();
57 $mainWS->append(
new \
SoapVar($codApp, XSD_STRING, null, null,
'aplicacion', self::$NAMESPACE_LOGIN));
58 $mainWS->append(
new \
SoapVar($tokenSSO, XSD_STRING, null, null,
'tokenSSO', self::$NAMESPACE_LOGIN));
59 $mainWS->append(
new \
SoapVar($origenWS, SOAP_ENC_OBJECT,null,null,
'origen', self::$NAMESPACE_LOGIN));
62 if (is_array($vParametros))
65 foreach ($vParametros as $clave => $valor)
67 $parametro[] = new \SoapVar($clave, XSD_STRING, null, null,
'nombreParametro', self::$NAMESPACE_LOGIN);
68 $parametro[] = new \SoapVar($valor, XSD_STRING, null, null,
'valorParametro', self::$NAMESPACE_LOGIN);
70 $vParametro = new \SoapVar($parametro, SOAP_ENC_OBJECT, null, null,
'parametro', self::$NAMESPACE_LOGIN);
71 $mainWS->append(
new \
SoapVar(array($vParametro), SOAP_ENC_OBJECT, null, null,
'parametros', self::$NAMESPACE_LOGIN));
73 $miSoapRQ = new \SoapVar($mainWS, SOAP_ENC_OBJECT,null,null,
'obtenerContexto', self::$NAMESPACE_LOGIN);
74 $respuesta = $clienteWS->obtenerContexto($miSoapRQ);
81 return $this->tratarInnerException($clienteWS, $e);
104 $this->
__clienteOn(self::KEYCLIENTE_GVLOGIN,
true);
105 $clienteWS = $this->
__getClient(self::KEYCLIENTE_GVLOGIN);
109 if (($ip == null) || empty($ip))
111 $ip = $this->getAgentIP();
113 if (($agent == null) || empty($agent))
115 $agent = $this->getUserAgent();
119 $origenWS = new \ArrayObject();
120 $origenWS->append(
new \
SoapVar($ip, XSD_STRING, null, null,
'ip', self::$NAMESPACE_LOGIN));
121 $origenWS->append(
new \
SoapVar($agent, XSD_STRING, null, null,
'agent', self::$NAMESPACE_LOGIN));
123 $mainWS = new \ArrayObject();
124 $mainWS->append(
new \
SoapVar($tokenSSO, XSD_STRING, null, null,
'tokenSSO', self::$NAMESPACE_LOGIN));
125 $mainWS->append(
new \
SoapVar($origenWS, SOAP_ENC_OBJECT,null,null,
'origen', self::$NAMESPACE_LOGIN));
127 $miSoapRQ = new \SoapVar($mainWS, SOAP_ENC_OBJECT,null,null,
'verificarContexto', self::$NAMESPACE_LOGIN);
128 $respuesta = $clienteWS->verificarContexto($miSoapRQ);
132 $this->
addDebugInfo(__CLASS__.
':'.__METHOD__.
'['.__FILE__.
'-'.__LINE__.
']'.
"\n");
133 if (is_object($clienteWS))
135 $this->
addDebugInfo(
"RqH:\n ".$clienteWS->__getLastRequestHeaders());
136 $this->
addDebugInfo(
"Rq:\n ".$clienteWS->__getLastRequest());
137 $this->
addDebugInfo(
"RsH:\n ".$clienteWS->__getLastResponse());
138 $this->
addDebugInfo(
"Rs:\n ".$clienteWS->__getLastResponseHeaders());
147 return $this->tratarInnerException($clienteWS, $e);
164 $this->
__clienteOn(self::KEYCLIENTE_GVLOGIN,
true);
165 $clienteWS = $this->
__getClient(self::KEYCLIENTE_GVLOGIN);
167 $mainWS = new \ArrayObject();
168 $mainWS->append(
new \
SoapVar($tokenSSO, XSD_STRING, null, null,
'tokenSSO', self::$NAMESPACE_LOGIN));
170 $miSoapRQ = new \SoapVar($mainWS, SOAP_ENC_OBJECT,null,null,
'logout', self::$NAMESPACE_LOGIN);
171 $respuesta = $clienteWS->logout($miSoapRQ);
178 return $this->tratarInnerException($clienteWS, $e);
191 private function tratarInnerException($clienteWS, $e)
194 $mensaje = $e->getMessage();
195 $mensaje = trim(strtolower($mensaje));
198 case 'looks like we got no xml document' :
200 $response = $clienteWS->__getLastResponse();
206 $this->tratarExcepcionEstandar($e, $clienteWS);
217 private function getUserAgent()
219 if (isset($_SERVER[
'HTTP_X_USER_AGENT']))
220 return $_SERVER[
'HTTP_X_USER_AGENT'];
221 return $_SERVER[
'HTTP_USER_AGENT'];
229 private function getAgentIP()
232 if (getenv(
'HTTP_CLIENT_IP'))
234 $ip = getenv(
'HTTP_CLIENT_IP');
236 else if(getenv(
'HTTP_X_FORWARDED_FOR'))
238 $ip = getenv(
'HTTP_X_FORWARDED_FOR');
240 else if (getenv(
'HTTP_X_FORWARDED'))
242 $ip = getenv(
'HTTP_X_FORWARDED');
244 else if(getenv(
'HTTP_FORWARDED_FOR'))
246 $ip = getenv(
'HTTP_FORWARDED_FOR');
248 else if(getenv(
'HTTP_FORWARDED'))
250 $ip = getenv(
'HTTP_FORWARDED');
252 else if(getenv(
'REMOTE_ADDR'))
254 $ip = getenv(
'REMOTE_ADDR');
268 private function getServerIP()
271 $ip = $_SERVER[
'SERVER_ADDR'];
273 if (in_array(PHP_OS, array(
'WINNT',
'WIN32',
'Windows')))
275 $ip = getHostByName(getHostName());
277 elseif (in_array(PHP_OS, array(
'Linux',
'Unix')))
279 $command=
"/sbin/ifconfig";
281 exec($command, $output);
283 $pattern =
'/inet addr:?([^ ]+)/';
286 foreach ($output as $subject)
288 $subpattern = array();
289 $result = preg_match_all($pattern, $subject, $subpattern);
292 if ($subpattern[1][0] !=
"127.0.0.1")
294 $ip = $subpattern[1][0];
311 private $resultado =
false;
312 private $error = null;
315 private $nombre = null;
316 private $apellido1 = null;
317 private $apellido2 = null;
318 private $mail = null;
320 private $vParamInfoAmpliada = null;
321 private $vRoles = null;
331 return $this->resultado;
343 return is_null($this->error);
378 return $this->nombre;
389 return $this->apellido1;
400 return $this->apellido2;
435 if (is_null($this->vParamInfoAmpliada))
439 return sizeof($this->vParamInfoAmpliada);
451 return $this->vParamInfoAmpliada[$index];
475 if (is_null($this->vRoles))
479 return sizeof($this->vRoles);
491 return $this->vRoles[$index];
504 $this->resultado = $response->resultado;
506 if (($this->resultado ==
true) && isset($response->datos))
509 $datos = $response->datos;
512 if (isset($datos->dni))
514 $this->dni = $datos->dni;
516 if (isset($datos->nombre))
518 $this->nombre = $datos->nombre;
520 if (isset($datos->apellido1))
522 $this->apellido1 = $datos->apellido1;
524 if (isset($datos->apellido2))
526 $this->apellido2 = $datos->apellido2;
528 if (isset($datos->mail))
530 $this->mail = $datos->mail;
534 if (isset($datos->infoAmpliada) && isset($datos->infoAmpliada->parametro))
537 $vParamInfoAmpliada = $datos->infoAmpliada->parametro;
538 if (!is_array($vParamInfoAmpliada)) $vParamInfoAmpliada = array($vParamInfoAmpliada);
541 for ($iParam=0; $iParam <
sizeof($vParamInfoAmpliada); $iParam++)
543 $param = $vParamInfoAmpliada[$iParam];
544 $this->vParamInfoAmpliada[] =
new LoginParametro($param->nombreParametro, $param->valorParametro);
549 if (isset($datos->roles) && isset($datos->roles->role))
552 $vRoles = $datos->roles->role;
553 if (!is_array($vRoles)) $vRoles = array($vRoles);
556 $this->vRoles = array();
557 for ($iRol=0; $iRol <
sizeof($vRoles); $iRol++)
559 $this->vRoles[] =
new LoginRol( $vRoles[$iRol] );
565 if (!empty($response->error))
567 $this->error =
new BasicError($response->error);
576 private $nombre = null;
577 private $valor = null;
586 return $this->nombre;
607 $this->nombre = $nombre;
608 $this->valor = $valor;
615 private $codigo = null;
616 private $vParametro = null;
625 return $this->codigo;
646 if (is_null($this->vParametro)) {
649 return sizeof($this->vParametro);
660 return $this->vParametro[$index];
672 if (isset($datos->codigo)) {
673 $this->codigo = $datos->codigo;
677 if (isset($datos->parametros) && isset($datos->parametros->parametro)) {
679 $vParam = $datos->parametros->parametro;
680 if (!is_array($vParam)) $vParam = array($vParam);
683 $this->vParametro = array();
685 for ($iParam=0; $iParam <
sizeof($vParam); $iParam++) {
686 $param = $vParam[$iParam];
687 $this->vParametro[] =
new LoginParametro($param->nombreParametro, $param->valorParametro);
715 const TOKEN_NO_EXISTENTE =
'001';
716 const APLICACION_NO_EXISTENTE =
'002';
717 const TOKEN_CADUCADO =
'003';
718 const USUARIO_NO_EXISTE_EN_CLAU =
'004';
719 const ORIGEN_NO_ESPERADO =
'005';
720 const COMPONENTE_PROSPROCESAMIENTO_NO_ENCONTRADO =
'006';
721 const USUARIO_NO_ACTIVO_EN_CLAU =
'007';
722 const COMPONENTE_AUTORIZACION_NO_ENCONTRADO =
'008';
723 const USUARIO_NO_AUTORIZADO_BOPERIT =
'009';
724 const ERROR_INVOCANDO_AUTORIZACION =
'010';
725 const USUARIO_SIN_ROLES =
'011';
726 const ERROR_INVOCANDO_POSTPROCESAMIENTO =
'012';
727 const APLICION_NO_CUMPLE_SEGURIDAD_MINIMA =
'013';
728 const ERROR_INESPERADO =
'999';
731 private $codigoError =
'';
732 private $mensajeError =
'';
735 public function getCodigoError()
737 return $this->codigoError;
739 public function getMensajeError()
741 return $this->mensajeError;
746 public function __construct($objError)
748 $this->codigoError = $objError->codigoError;
749 $this->mensajeError = $objError->mensajeError;
752 public function __toString()
754 return __CLASS__ .
": [{$this->codigoError}] {$this->mensajeError}\n";
tratarMTOMEstandar($response, $itemToReturn=null)
verificarContexto($tokenSSO, $ip=null, $agent=null)
__construct($nombre, $valor)
__clienteOn($tipo, $trazabilidadPai=true, $opcionesClienteWS=null)
obtenerContexto($codApp, $tokenSSO, $ip=null, $agent=null, $vParametros=null)