Changeset 51b96ce in prototipo_portal_2018
- Timestamp:
- Jul 13, 2015, 11:27:23 AM (9 years ago)
- Branches:
- master
- Children:
- f490416, d76b369
- Parents:
- f24ec26
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
WebContent/index.html
rf24ec26 r51b96ce 216 216 217 217 $.ajax({ 218 //url: "https://192.168.12.125:8443/Murachi/murachi/archivos", 219 //url: "https://172.16.137.11:8443/Murachi/murachi/archivos", 220 //url: "https://172.16.137.11:8443/JAXRS-Murachi/murachi/archivos", 218 //url: "https://192.168.12.125:8443/Murachi/0.1/archivos", 221 219 url: "https://murachi.cenditel.gob.ve/Murachi/0.1/archivos", 222 220 type: "post", … … 259 257 type: 'POST', 260 258 contentType: 'application/json', 261 //url:"https://192.168.12.125:8443/Murachi/murachi/archivos/pdfs", 262 //url:"https://172.16.137.11:8443/Murachi/murachi/archivos/pdfs", 259 //url:"https://192.168.12.125:8443/Murachi/0.1/archivos/pdfs", 263 260 url:"https://murachi.cenditel.gob.ve/Murachi/0.1/archivos/pdfs", 264 261 dataType: "json", … … 283 280 type: 'POST', 284 281 contentType: 'application/json', 285 //url:"https://192.168.12.125:8443/Murachi/murachi/archivos/pdfs/resenas", 286 //url:"https://172.16.137.11:8443/Murachi/murachi/archivos/pdfs/resenas", 282 //url:"https://192.168.12.125:8443/Murachi/0.1/archivos/pdfs/resenas", 287 283 url:"https://murachi.cenditel.gob.ve/Murachi/0.1/archivos/pdfs/resenas", 288 284 dataType: 'json', … … 297 293 298 294 alert("ver respuesta"); 299 //var linkToDownload = "<a href=\"https://192.168.12.125:8443/Murachi/ murachi/archivos/descargas/" + data['signedFileId'] +"\">descargar archivo firmado</a>";295 //var linkToDownload = "<a href=\"https://192.168.12.125:8443/Murachi/0.1/archivos/descargas/" + data['signedFileId'] +"\">descargar archivo firmado</a>"; 300 296 //var linkToDownload = "<a href=\"https://172.16.137.11:8443/Murachi/murachi/archivos/descargas/" + data['signedFileId'] +"\">descargar archivo firmado</a>"; 301 297 var linkToDownload = "<a href=\"https://murachi.cenditel.gob.ve/Murachi/0.1/archivos/descargas/" + data['signedFileId'] +"\">descargar archivo firmado</a>"; … … 369 365 }); 370 366 </script> 371 372 367 368 369 <!-- Prueba de firma de BDOC --> 370 <!-- 371 <script> 372 $(function(){ 373 $("#firmar").on("submit", function(e){ 374 e.preventDefault(); 375 var f = $(this); 376 377 //alert("se presiono firmar") 378 379 //var formData = new FormData(document.getElementById("verificar")); 380 var formData = new FormData(); 381 382 //formData.append("dato", "valor"); 383 formData.append("upload", $("#file-sign")[0].files[0]); 384 //formData.append(f.attr("name"), $(this)[0].files[0]); 385 386 $.ajax({ 387 url: "https://192.168.12.125:8443/Murachi/0.1/archivos", 388 //url: "https://172.16.137.11:8443/Murachi/murachi/archivos", 389 //url: "https://172.16.137.11:8443/JAXRS-Murachi/murachi/archivos", 390 //url: "https://murachi.cenditel.gob.ve/Murachi/0.1/archivos", 391 type: "post", 392 dataType: "json", 393 data: formData, 394 cache: false, 395 contentType: false, 396 processData: false, 397 success: function(response) { 398 //alert(JSON.stringify(response)); 399 var html = manejoJsonPDF(JSON.stringify(response)); 400 //alert(html); 401 //alert("ver respuesta") 402 document.getElementById("respuesta").innerHTML = html; 403 404 // identificador del archivo en el servidor 405 var fileId = response.fileId.toString(); 406 alert("fileId: "+ fileId); 407 408 409 // seleccionar certificado del firmante 410 alert("va a seleccionar certificado"); 411 var cert; 412 window.hwcrypto.getCertificate({lang: "en"}).then(function(response) { 413 var cert = response; 414 //log_text("Using certificate:\n" + hexToPem(response.hex)); 415 416 //alert("cert: "+ cert.hex); 417 418 var parameters = JSON.stringify({ 419 "fileId":fileId, 420 "certificate":cert.hex, 421 "city":"Merida", 422 "state":"Merida", 423 "postalCode":"5101", 424 "country":"Venezuela", 425 "role":"Desarrollador", 426 "addSignature":false 427 }); 428 429 // ahora llamar al ajax de obtener la resena del bdoc 430 $.ajax({ 431 type: 'POST', 432 contentType: 'application/json', 433 url:"https://192.168.12.125:8443/Murachi/0.1/archivos/bdocs", 434 //url:"https://172.16.137.11:8443/Murachi/murachi/archivos/pdfs", 435 //url:"https://murachi.cenditel.gob.ve/Murachi/0.1/archivos/pdfs", 436 dataType: "json", 437 data: parameters, 438 success: function(data, textStatus, jqXHR){ 439 var json_x = data; 440 var hash = json_x['hash']; 441 //alert("hash recibido del servidor "+hash); 442 443 var hashtype = "SHA-256"; 444 var lang = "eng"; 445 446 window.hwcrypto.sign(cert, {type: hashtype, hex: hash}, {lang: lang}).then(function(signature) { 447 448 //var signature = response.hex.match(/.{1,64}/g).join("\n"); 449 //log_text("Generated signature:\n" + response.hex.match(/.{1,64}/g).join("\n")); 450 //log_text("Generated signature:\n" + signature.hex); 451 452 alert("valor de la firma: " + signature.hex); 453 454 455 $.ajax({ 456 type: 'POST', 457 contentType: 'application/json', 458 url:"https://192.168.12.125:8443/Murachi/0.1/archivos/bdocs/resenas", 459 //url:"https://172.16.137.11:8443/Murachi/murachi/archivos/pdfs/resenas", 460 //url:"https://murachi.cenditel.gob.ve/Murachi/0.1/archivos/pdfs/resenas", 461 dataType: 'json', 462 data: JSON.stringify({"signature":signature.hex}), 463 success: function(data, textStatus, jqXHR){ 464 /* 465 var json_x = data; 466 var msg = json_x['message']; 467 alert('Archivo firmado en el servidor: ' + msg); 468 */ 469 alert('Archivo firmado correctamente: ' + data['signedFileId']); 470 471 alert("ver respuesta"); 472 var linkToDownload = "<a href=\"https://192.168.12.125:8443/Murachi/0.1/archivos/descargas/" + data['signedFileId'] +"\">descargar archivo firmado</a>"; 473 //var linkToDownload = "<a href=\"https://172.16.137.11:8443/Murachi/murachi/archivos/descargas/" + data['signedFileId'] +"\">descargar archivo firmado</a>"; 474 //var linkToDownload = "<a href=\"https://murachi.cenditel.gob.ve/Murachi/0.1/archivos/descargas/" + data['signedFileId'] +"\">descargar archivo firmado</a>"; 475 //alert(linkToDownload); 476 document.getElementById("respuesta").innerHTML = linkToDownload; 477 478 479 //descargar el archivo 480 /* 481 //var urlToDownload = "https://192.168.12.125:8443/Murachi/murachi/archivos/descargas/" + data['signedFileId']; 482 $.ajax({ 483 type: 'GET', 484 contentType: false, 485 url: "https://192.168.12.125:8443/Murachi/murachi/archivos/descargas/" + data['signedFileId'], 486 dataType: false, 487 data: false, 488 success: function(data, textStatus, jqXHR){ 489 alert("descargo el archivo"); 490 }, 491 error: function(jqXHR, textStatus, errorThrown){ 492 alert('error en descarga de archivo: ' + textStatus); 493 $("#respuesta").html("error en descarga de archivo: " + textStatus); 494 } 495 }); 496 */ 497 // fin de descarga de archivo 498 499 500 }, 501 error: function(jqXHR, textStatus, errorThrown){ 502 alert('error en /bdocs/resenas: ' + textStatus); 503 $("#respuesta").html("error en /bdocs/resenas: " + textStatus); 504 } 505 }); 506 507 }, function(err) { 508 log_text("sign() failed: " + err); 509 alert("sign() failed: " + err); 510 $("#respuesta").html("sign() failed: " + err); 511 }); 512 513 }, 514 error: function(jqXHR, textStatus, errorThrown){ 515 //alert('error: ' + textStatus); 516 //var responseText = jQuery.parseJSON(jqXHR.responseText); 517 alert('ajax error function: ' + jqXHR.responseText); 518 $("#respuesta").html("error function: " + jqXHR.responseText); 519 } 520 521 522 }); 523 524 525 526 }, function(err) { 527 log_text("getCertificate() failed: " + err); 528 alert("getCertificate() failed: " + err); 529 $("#respuesta").html("getCertificate() failed: " + err); 530 }); 531 532 533 534 }, 535 error: function(response) { 536 //Que se ejecuta cuando finalice la petición de con error 537 $("#respuesta").html('Error...!!!'); 538 alert("ocurrio un error") 539 } 540 }); 541 }); 542 }); 543 </script> 544 --> 545 373 546 374 547 <!-- Función que se conecta se servicio web de verificación de la firma electrónica
Note: See TracChangeset
for help on using the changeset viewer.