Index: terepaima-0.4.16/data.json
===================================================================
--- terepaima-0.4.16/data.json	(revision 63dadfc95c45ecbd4c1d2a21904654fa1351e6d3)
+++ terepaima-0.4.16/data.json	(revision 5de5cc7fd793955be5b71ca140092237ef3e9d04)
@@ -1,1 +1,1 @@
-{"fileId":"c73efabb-d771-4328-be4f-36b11c4add57","certificate":"3082053030820318a003020102020131300d06092a864886f70d01010b05003081aa310b3009060355040613025645310f300d060355040813064d6572696461310f300d060355040713064d65726964613111300f060355040a130843454e444954454c310e300c060355040b13054749445349312e302c06035504030c254175746f7269646164206465204365727469666963616369c3b36e2064656c2047494453493126302406092a864886f70d0109011617616367696473694063656e646974656c2e676f622e7665301e170d3137313132373135303630305a170d3230313132373135303630305a30819a310b3009060355040613025645310f300d060355040813064d6572696461310f300d060355040713064d65726964613111300f060355040a130843454e444954454c31133011060355040b130a4465736172726f6c6c6f311730150603550403130e506564726f20427569747261676f3128302606092a864886f70d010901161970627569747261676f4063656e646974656c2e676f622e766530820122300d06092a864886f70d01010105000382010f003082010a0282010100b80698119b52c78721cf0baaeab51c71c40796af92276213ca835e94ddf22a20947c1ce96f7eaa22121b35825b141cb2a27e15c4fef23ea05d1b6348ef24cc0deed7c8fd297f066ba0ede56527233b720753edcb6ef62f4496760b6c78767933757e0f1d8df5e66f8eee5c1ecb094df16ae5cefbb771abadd8b591114501bca845eaa0963a962c7e618ea66b976a2679885d3895f83c878084182e88523f5fe429567c33c7be29bb3a687bfe0a286989c6fe823ff8aaa38a2583089701ad75485d5446e0d52d57a38d028ce928c65d628f1c1f98cbfcd226ff9e6616fef8d993c5eeaa8081770550af77aa926b50c49a70e7c0c94e2374aeab34f603c83aa3850203010001a36f306d300c0603551d130101ff04023000301d0603551d0e041604147fdfa8be9ea6a85551b5f33cc44b61ca4c89f730300b0603551d0f0404030204f0301106096086480186f84201010404030205a0301e06096086480186f842010d0411160f786361206365727469666963617465300d06092a864886f70d01010b0500038202010043d82a437657e47ceb6ea950c943153d6e515593a056b50b4aa3d0faa497043065236020dedbceddcc8a5be2b1049a0909bcd275f94ecd49f91930fced82ce6bb8f1d5568b1c7d5e5677faf3833fc276302f89193f36391bfee7569114cf05c0ba2bb4aa5e99fa695f846c8df8f0278f3d6aae31a8d1f075d7ef756d2c59e5651ce66d944720ad4b7c1e9896191d9ad13d8d181c9b70f4302add36175b9354f53619f35e691b59eacee48e1efd66d9025a0e919ad9cf8e23c98e2a4b54cad7bb158097ee84575f5fb6f9ac724c1fb28bac424d88b4661e06129ef53a22c01323d41c0d5763f7db7d9a2640eb07d6dc82158471f0b8acf78436be2f61d370428831af248a0820582244d650533e4fbc42973339acf903b0fed76fb43d75f17f6450f1ef0fc8314640220d6172d4e98955cbd760d6c2914960c1431d7ce0258cc31d1d5ef80a93c663f8577dc42980b987aaa3ada3e93f783595c803ff50f667d01af3d52c49c6913564bc134dcde956723184ecd26ba92af0050e811d79038bdf8c5424ef662c70dc355b58ad9c5377218ec97feed4a703072d7df117ca7525e772b88cad3b40f8a60cfa3207a02765e374a4a9fb248e2d14dbe9b30dc9398f456d9a5960b982407f4469a0f1338e965b1152b24b08ba29c9b99a00df8b4d408403cc165153f09bb091968e852b01680fa488433266af3fa2ee2e086b335a32a2","reason":"Certificado", "location":"CENDITEL", "contact":"582746574336","signatureVisible":"true","signaturePage":"1","xPos":"10","yPos":"10","lastSignature":"false" }
+{"fileId":"8dd41d79-c3c8-4490-944b-3a246422ab6c","certificate":"","reason":"Certificado", "location":"CENDITEL", "contact":"582746574336","signatureVisible":"true","signaturePage":"1","xPos":"10","yPos":"10","lastSignature":"false" }
Index: terepaima-0.4.16/sources/mainwindow.cpp
===================================================================
--- terepaima-0.4.16/sources/mainwindow.cpp	(revision 63dadfc95c45ecbd4c1d2a21904654fa1351e6d3)
+++ terepaima-0.4.16/sources/mainwindow.cpp	(revision 5de5cc7fd793955be5b71ca140092237ef3e9d04)
@@ -53,4 +53,7 @@
 #include <QNetworkRequest>
 #include <QUrlQuery>
+#include <QJsonDocument>
+#include <QNetworkCookieJar>
+
 
 #if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
@@ -312,5 +315,6 @@
 MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent),
     m_outlineView(0),
-    m_thumbnailsView(0)
+    m_thumbnailsView(0),
+    manager(NULL)
 {
     if(s_settings == 0)
@@ -3973,6 +3977,6 @@
 
    // QString version = executeRest("https://murachi.cenditel.gob.ve/Murachi/0.1/archivos/version","admin","admin");
-    QString fileid = "c73efabb-d771-4328-be4f-36b11c4add57";
-
+    //QString fileid = "c73efabb-d771-4328-be4f-36b11c4add57";
+    QString fileid = "8dd41d79-c3c8-4490-944b-3a246422ab6c";
    QUrlQuery postData;
     //postData.addQueryItem("fileId", fileid);
@@ -4026,11 +4030,21 @@
     //QUrlQuery postData1;
 
-    QString newverify =  executeRest("https://murachi.cenditel.gob.ve/Murachi/0.1/archivos/pdfs","admin","admin"
+    QString newhash =  executeRest("https://murachi.cenditel.gob.ve/Murachi/0.1/archivos/pdfs","admin","admin"
                                      ,parameters);
 
+    qDebug(".....................*Verify: newhash %s", qPrintable(newhash));
+
+    QJsonDocument d = QJsonDocument::fromJson(newhash.toUtf8());
+          QJsonObject sett2 = d.object();
+          QJsonValue value = sett2.value(QString("hash"));
+
+    currentHash = value.toString();
+    qDebug(".....................****currentHash: |%s|", qPrintable(currentHash));
+
+
+    on_signature();
     //QString verify  = privateExecuteRest("https://murachi.cenditel.gob.ve/Murachi/0.1/archivos/aee1a794-5fc7-4008-ac6d-de2e79583074.pdf",
     //                                     "admin","admin",method="post",postData);
 
-    qDebug(".....................*Verify: newverify %s", qPrintable(newverify));
 
  //   qDebug("Version: %s", qPrintable(version));
@@ -4049,4 +4063,5 @@
     qDebug("** on_windowPIN **");
 
+    qDebug("**CALLING TEST on_windowPIN **");
     m_pin = new QDialog;
     close_PIN = "falso";
@@ -4101,12 +4116,30 @@
     m_pin->accept();
     m_nct = new CryptoToken();
-    QString hash("cdbc23b0c23e164225acd0dbf8afecc420ca61ded483a0a43d88d4a76916cc04");
+    //QString hash("e4b820914010e65a578435fd6839f8dfe1037915d39130902970355a272ce3b3");
+    //currentHash = hash;
 
     try {
-        std::vector<unsigned char> result = m_nct->signHash(hash, m_campoContrasenia->text(), certSelect);
+        qDebug("Resultado Firma hash: |%s|", qPrintable(currentHash));
+        if (currentHash.isEmpty()) {
+            QMessageBox msgBox;
+            msgBox.setText("Hash esta vacio!");
+            msgBox.exec();
+            return;
+        }
+        QString pass = m_campoContrasenia->text();
+        qDebug("Resultado Firma pass: |%s|", qPrintable(pass));
+        std::vector<unsigned char> result = m_nct->signHash(currentHash, pass, certSelect);
         qDebug("** signature: ");
-        qDebug("Resultado %s", m_nct->toHex(result));
+        QString newsignature = QString(m_nct->toHex(result));
+        qDebug("Resultado Firma en HEX: |%s|", qPrintable(newsignature));
         open("/home/pbuitrago/Cenditel/Seguridad/POA-2015/Portal_verificacion_firma/reconocimientoMurachi-signed.pdf"); // para refrescar el archivo al firmado
         m_detailsSignatureView->setModel(view_table_verify_signature()); // refresca la table de verificación de firma electrónica
+        QString resenas = QString("{\"signature\":\"%1\"}").arg(newsignature);
+
+        qDebug("..............(1).......resenas: |%s|", qPrintable(resenas));
+
+        QString newcompleted =  executeRest("https://murachi.cenditel.gob.ve/Murachi/0.1/archivos/pdfs/resenas","admin","admin",resenas);
+
+        qDebug("..............(2).......resenas: |%s|", qPrintable(newcompleted));
         QMessageBox msgBox;
         msgBox.setText("El archivo se firmo con exitos..!");
@@ -4247,5 +4280,13 @@
     qDebug("Executing Executing...Rest...1");
 
-    QNetworkAccessManager *manager = new QNetworkAccessManager(this);
+    if (manager == NULL) {
+            qDebug("Executing Executing..MANAGER new");
+            manager = new QNetworkAccessManager(this);
+            cookiesJar = new QNetworkCookieJar(this);
+            manager->setCookieJar(cookiesJar);
+    }
+
+
+
 
     qDebug("Executing Executing...Rest...2");
@@ -4264,4 +4305,10 @@
     request.setSslConfiguration(conf);
 
+   // if (url.endsWith("pdfs") ) {
+        qDebug("Credentials is TRUE, maybe");
+        //request.setAttribute(QNetworkRequest::CookieLoadControlAttribute, QVariant(QNetworkRequest::Manual));
+       // request.setAttribute(QNetworkRequest::CookieSaveControlAttribute, QVariant(QNetworkRequest::Manual));
+       // request.setAttribute(QNetworkRequest::AuthenticationReuseAttribute, QVariant(QNetworkRequest::Manual));
+   // }
     qDebug("Executing Rest...4");
 
@@ -4283,5 +4330,4 @@
       //QNetworkReply *reply = manager->get(QNetworkRequest(QUrl("http://127.0.0.1:8000")));
       request.setHeader(QNetworkRequest::ContentTypeHeader,
-       //  "application/x-www-form-urlencoded");
       "application/json");
 
@@ -4290,4 +4336,6 @@
       QString headerData = QString("Basic YWRtaW46YWRtaW4=");
       request.setRawHeader("Authorization", headerData.toUtf8());
+
+      request.setRawHeader("xhrFields", "{ withCredentials:true }");
 
       //QNetworkReply *reply = manager->post(request, postData.encodedQuery());
Index: terepaima-0.4.16/sources/mainwindow.h
===================================================================
--- terepaima-0.4.16/sources/mainwindow.h	(revision 63dadfc95c45ecbd4c1d2a21904654fa1351e6d3)
+++ terepaima-0.4.16/sources/mainwindow.h	(revision 5de5cc7fd793955be5b71ca140092237ef3e9d04)
@@ -559,4 +559,8 @@
     QString close_PIN;
 
+    QString currentHash;
+    QNetworkCookieJar *cookiesJar;
+
+    QNetworkAccessManager *manager;
     //_______________________________________________________________________
     bool m_bookmarksMenuIsDirty;
