Example #1
0
 /**
  * Punto de entrada http al nucleo
  */
 function acceso_servicio()
 {
     try {
         $this->iniciar_contexto_ejecucion();
         //toba_http::headers_standart();
         $item = toba::memoria()->get_item_solicitado();
         if (!isset($item)) {
             //Si no tiene ID (porque axis lo elimina del GET) usar el extra la URL
             $servicio = basename($_SERVER['REQUEST_URI']);
             //Asume que es x.php/id_servicio
             if (strpos($servicio, '?') !== false) {
                 $servicio = substr($servicio, 0, strpos($servicio, '?'));
             }
             //Si es el .php a secas pide un listado de los servicios
             if (basename($servicio, '.php') !== $servicio) {
                 header("HTTP/1.0: 404 Not Found");
                 die;
             }
             $item = array(apex_pa_proyecto, $servicio);
             toba::memoria()->set_item_solicitado($item);
         }
         $this->iniciar_contexto_solicitud($item);
         $this->solicitud = toba_constructor::get_runtime(array('proyecto' => $item[0], 'componente' => $item[1]), 'toba_item');
         if (!$this->solicitud instanceof toba_solicitud_servicio_web) {
             throw new toba_error_seguridad("El item {$item[1]} no es un item de servicio web");
         }
         if (!toba::instalacion()->es_produccion()) {
             if ($xml = file_get_contents('php://input')) {
                 toba::logger_ws()->debug("XML Input: {$xml}");
                 toba::logger_ws()->set_checkpoint();
             }
         }
         $this->solicitud_en_proceso = true;
         $this->solicitud->procesar();
         $this->solicitud->registrar();
         $this->solicitud->finalizar_objetos();
         $this->finalizar_contexto_ejecucion();
     } catch (Exception $e) {
         toba::logger()->crit($e, 'toba');
         echo $e->getMessage() . "\n\n";
     }
     toba::logger()->guardar();
 }
    function ajax__test_configuracion($clave_param, toba_ajax_respuesta $respuesta)
    {
        toba::memoria()->desactivar_reciclado();
        //Recupero la fila del cuadro
        $parametro = toba_ei_cuadro::recuperar_clave_fila('33000078', $clave_param);
        if (is_null($parametro)) {
            //Si no existe la fila informada desde el cliente retorno.
            $respuesta->set('Esta seguro que este es un servicio correcto?');
            return false;
        }
        //Armo el payload para el servicio de eco con el random a testear
        $rnd = xml_encode(md5(rand(1, 435)));
        $payload = <<<XML
<ns1:eco xmlns:ns1="http://siu.edu.ar/toba/serv_pruebas"><texto>{$rnd}</texto></ns1:eco>
XML;
        //---------------------------------------------------------------------//
        try {
            //Lo armo asi porque esta configurado en otro proyecto entonces no puedo usar toba::servicio_web
            $servicio = toba_servicio_web_cliente::conectar($parametro['servicio_web'], array(), $this->s__filtro['proyecto']);
            $respuesta_ws = $servicio->request(new toba_servicio_web_mensaje($payload, array('action' => 'eco')));
        } catch (toba_error_servicio_web $s) {
            //Capturo errores del servicio web
            $respuesta->set('Se produjo un error inesperado en la atención del servicio, comuniquese con el proveedor del mismo. Si es un proyecto toba verifique el log de servicios web de ese proyecto (Ubicado en toba_usuarios > Auditoría > 
Logs de Servicios Web Ofrecidos) y el log general del sistema');
            toba::logger_ws()->debug($s->getMessage());
            return false;
        } catch (toba_error $e) {
            //Capturo cualquier otro error local a la creacion del pedido
            toba::logger()->debug($e->getMessage());
            $respuesta->set('Se produjo un error inesperado en la inicializacion del pedido. Verifique que la URL sea correcta (abrirla en en el navegador y ver que responda bien)');
            return false;
        }
        //Parseo el XML de la respuesta para obtener el dato y comparo con el random que envie
        $xml_rta = new SimpleXMLElement($respuesta_ws->get_payload());
        if ((string) $rnd == (string) $xml_rta->texto) {
            $respuesta->set('Ok. La configuracion es correcta');
        } else {
            toba::logger()->debug("Enviado: {$rnd}");
            toba::logger()->debug('Recibido: ' . $xml_rta->texto);
            $respuesta->set('La configuración no es correcta, o la respuesta (' . (string) $xml_rta->texto . ') no coincide con la esperada ' . $rnd . '). Revise el log');
        }
    }
Example #3
0
 function validar_certificado_cliente()
 {
     $cert = $this->get_certificado_cliente();
     $cert_decodificado = base64_decode($cert);
     $fingerprint = sha1($cert_decodificado);
     //Verifica si existe fingerprint
     toba::logger_ws()->debug("Fingerprint recibida: {$fingerprint}");
     toba::logger()->debug("Fingerprint recibida: {$fingerprint}");
     if (!isset(self::$mapeo_firmas[$fingerprint])) {
         throw new toba_error_servicio_web('El mensaje no es válido o no fue posible procesar su firma correctamente');
     }
     //Valida el certificado completo
     if (self::decodificar_certificado(self::$mapeo_firmas[$fingerprint]['archivo']) !== $cert_decodificado) {
         throw new toba_error_seguridad('Error verificando firma del mensaje, tiene mismo fingerprint pero difiere en el contenido');
     }
     $this->id_cliente = self::$mapeo_firmas[$fingerprint]['id'];
     toba::logger_ws()->debug("ID Cliente: " . print_r($this->id_cliente, true));
     toba::logger_ws()->set_checkpoint();
     toba::logger()->debug("ID Cliente: " . print_r($this->id_cliente, true));
 }
Example #4
0
 function configurar_logger_ws()
 {
     if (defined('apex_pa_log_archivo_nivel')) {
         toba::logger_ws()->set_nivel(apex_pa_log_archivo_nivel);
     } else {
         toba::logger_ws()->set_nivel($this->memoria['log_archivo_nivel']);
     }
     if (!defined('apex_pa_log_archivo') && !$this->memoria['log_archivo'] || defined('apex_pa_log_archivo') && !apex_pa_log_archivo) {
         toba::logger_ws()->desactivar();
     }
 }
 function procesar()
 {
     toba::logger_ws()->debug('Servicio Llamado: ' . $this->info['basica']['item']);
     toba::logger_ws()->set_checkpoint();
     set_error_handler('toba_logger_ws::manejador_errores_recuperables', E_ALL);
     $this->validar_componente();
     //-- Pide los datos para construir el componente, WSF no soporta entregar objetos creados
     $clave = array();
     $clave['proyecto'] = $this->info['objetos'][0]['objeto_proyecto'];
     $clave['componente'] = $this->info['objetos'][0]['objeto'];
     list($tipo, $clase, $datos) = toba_constructor::get_runtime_clase_y_datos($clave, $this->info['objetos'][0]['clase'], false);
     agregar_dir_include_path(toba_dir() . '/php/3ros/wsf');
     $opciones_extension = toba_servicio_web::_get_opciones($this->info['basica']['item'], $clase);
     $wsdl = strpos($_SERVER['REQUEST_URI'], "?wsdl") !== false;
     $sufijo = 'op__';
     $metodos = array();
     $reflexion = new ReflectionClass($clase);
     foreach ($reflexion->getMethods() as $metodo) {
         if (strpos($metodo->name, $sufijo) === 0) {
             $servicio = substr($metodo->name, strlen($sufijo));
             $prefijo = $wsdl ? '' : '_';
             $metodos[$servicio] = $prefijo . $metodo->name;
         }
     }
     $opciones = array();
     $opciones['serviceName'] = $this->info['basica']['item'];
     $opciones['classes'][$clase]['operations'] = $metodos;
     $opciones = array_merge($opciones, $opciones_extension);
     $this->log->debug("Opciones del servidor: " . var_export($opciones, true), 'toba');
     $opciones['classes'][$clase]['args'] = array($datos);
     toba::logger_ws()->set_checkpoint();
     $service = new WSService($opciones);
     $service->reply();
     $this->log->debug("Fin de servicio web", 'toba');
 }