From f449eee2e42c73a066475fe7c9dcbbe4fcdc0bb9 Mon Sep 17 00:00:00 2001 From: Andreas Abraham Date: Tue, 19 Jan 2021 15:35:18 +0100 Subject: changed urlconnection to apache http client, new pdf-as version added, a-trust url changed --- pdf-over-gui/pom.xml | 2 +- .../main/java/at/asit/pdfover/gui/Constants.java | 3 +- .../asit/pdfover/gui/bku/mobile/ATrustHandler.java | 47 ++++++++++++++++-- .../gui/workflow/states/MobileBKUState.java | 57 ++++++++++------------ pdf-over-signer/pdf-over-sigpdfas4/pom.xml | 7 ++- 5 files changed, 78 insertions(+), 38 deletions(-) diff --git a/pdf-over-gui/pom.xml b/pdf-over-gui/pom.xml index 73964384..3fd6bd71 100644 --- a/pdf-over-gui/pom.xml +++ b/pdf-over-gui/pom.xml @@ -642,7 +642,7 @@ 1.4 ${ks-file} - a-sit-3 + code_signing ${ks-pass} ${ks-pass} diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/Constants.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/Constants.java index 105eedd5..fe631614 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/Constants.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/Constants.java @@ -94,7 +94,8 @@ public class Constants { /** Default Mobile BKU URL */ //public static final String DEFAULT_MOBILE_BKU_URL = "https://test1.a-trust.at/mobile2/https-security-layer-request/default.aspx";//"https://www.a-trust.at/mobile/https-security-layer-request/default.aspx"; //$NON-NLS-1$ - public static final String DEFAULT_MOBILE_BKU_URL = "https://www.a-trust.at/mobile/https-security-layer-request/default.aspx"; //$NON-NLS-1$ + //public static final String DEFAULT_MOBILE_BKU_URL = "https://www.a-trust.at/mobile/https-security-layer-request/default.aspx"; //$NON-NLS-1$ + public static final String DEFAULT_MOBILE_BKU_URL = "https://www.handy-signatur.at/mobile/https-security-layer-request/default.aspx"; //$NON-NLS-1$ /** Default Mobile BKU type */ public static final MobileBKUs DEFAULT_MOBILE_BKU_TYPE = MobileBKUs.A_TRUST; diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/ATrustHandler.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/ATrustHandler.java index 7d3f986a..613af38f 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/ATrustHandler.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/ATrustHandler.java @@ -504,13 +504,49 @@ public class ATrustHandler extends MobileBKUHandler { Status serverStatus = null; int waits = 0; final String ERROR = "Error: Server is not responding"; //$NON-NLS-1$ - + HttpClient client; + + //Connection: keep-alive try { do { - urlconnection = new URL(status.getBaseURL() + "/UndecidedPolling.aspx?sid=" + status.getSessionID()) //$NON-NLS-1$ - .openConnection(); - InputStream in = new BufferedInputStream(urlconnection.getInputStream()); + + String baseURL = "https://www.handy-signatur.at/mobile/https-security-layer-request"; + + client = MobileBKUHelper.getHttpClient(getStatus()); + String uri = status.getBaseURL() + "/UndecidedPolling.aspx?sid=" + status.getSessionID(); + GetMethod get = new GetMethod(uri); + + status.getBaseURL(); + //urlconnection = new URL(status.getBaseURL() + "/UndecidedPolling.aspx?sid=" + status.getSessionID()) //$NON-NLS-1$ + // .openConnection(); + + + // GET /mobile/https-security-layer-request/UndecidedPolling.aspx?sid=A3_RFOOXWTJGFOQXHZSXIWQPSZQCHBA&_=1610983069567 HTTP/2 + // Host: www.handy-signatur.at + // User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:84.0) Gecko/20100101 Firefox/84.0 + // Accept: application/json, text/javascript, */*; q=0.01 + // Accept-Language: de,en-US;q=0.7,en;q=0.3 + // Accept-Encoding: gzip, deflate, br + // DNT: 1 + // Connection: keep-alive + // Referer: https://www.handy-signatur.at/mobile/https-security-layer-request/undecided.aspx?sid=A3_RFOOXWTJGFOQXHZSXIWQPSZQCHBA + // Cookie: ASP.NET_SessionId=hbplnlm1l5gv25rgknfqc3zt + // TE: Trailers + + client.setTimeout(35000); + client.setConnectionTimeout(35000); + get.addRequestHeader("Accept", "application/json, text/javascript"); + get.addRequestHeader("Connection", "keep-alive"); + get.addRequestHeader("Referer", uri); + System.out.println("URL" + uri); + System.out.println("Cookies " + getStatus().getCookies()); + + + int returnValue = client.executeMethod(get); + System.out.println("retVal" + returnValue); + //InputStream in = new BufferedInputStream(urlconnection.getInputStream()); + InputStream in = new BufferedInputStream(get.getResponseBodyAsStream()); isReady = IOUtils.toString(in, "utf-8"); //$NON-NLS-1$ serverStatus = new Status(isReady); @@ -535,7 +571,8 @@ public class ATrustHandler extends MobileBKUHandler { } catch (Exception e) { log.error("handle polling failed" + e.getMessage()); //$NON-NLS-1$ - throw new ATrustConnectionException(); + //throw new ATrustConnectionException(); + return false; } } diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/MobileBKUState.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/MobileBKUState.java index 116d5bb2..8a416676 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/MobileBKUState.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/MobileBKUState.java @@ -542,42 +542,39 @@ public class MobileBKUState extends State { } } }, 0, 5000); - Display.getDefault().syncExec(new Runnable() { - @Override - public void run() { - MobileBKUFingerprintComposite fingerprintComposite = getMobileBKUFingerprintComposite(); - - fingerprintComposite.setRefVal(status.getRefVal()); - fingerprintComposite.setSignatureData(status.getSignatureDataURL()); - fingerprintComposite.setErrorMessage(status.getErrorMessage()); - getStateMachine().getGUIProvider().display(fingerprintComposite); - - Display display = getStateMachine().getGUIProvider().getMainShell().getDisplay(); - while (!fingerprintComposite.isUserCancel() && !fingerprintComposite.isUserSMS() && !fingerprintComposite.isDone()) { - if (!display.readAndDispatch()) { - display.sleep(); - } + Display.getDefault().syncExec(() -> { + MobileBKUFingerprintComposite fingerprintComposite = getMobileBKUFingerprintComposite(); + + fingerprintComposite.setRefVal(status.getRefVal()); + fingerprintComposite.setSignatureData(status.getSignatureDataURL()); + fingerprintComposite.setErrorMessage(status.getErrorMessage()); + getStateMachine().getGUIProvider().display(fingerprintComposite); + + Display display = getStateMachine().getGUIProvider().getMainShell().getDisplay(); + while (!fingerprintComposite.isUserCancel() && !fingerprintComposite.isUserSMS() && !fingerprintComposite.isDone()) { + if (!display.readAndDispatch()) { + display.sleep(); } - checkDone.cancel(); + } + checkDone.cancel(); - if (fingerprintComposite.isUserCancel()) { - fingerprintComposite.setUserCancel(false); - status.setErrorMessage("cancel"); //$NON-NLS-1$ - return; - } + if (fingerprintComposite.isUserCancel()) { + fingerprintComposite.setUserCancel(false); + status.setErrorMessage("cancel"); //$NON-NLS-1$ + return; + } - if (fingerprintComposite.isUserSMS()) { + if (fingerprintComposite.isUserSMS()) { // fingerprintComposite.setUserSMS(false); - status.setQRCode(null); - } + status.setQRCode(null); + } - if (fingerprintComposite.isDone()) - fingerprintComposite.setDone(false); + if (fingerprintComposite.isDone()) + fingerprintComposite.setDone(false); - // show waiting composite - getStateMachine().getGUIProvider().display( - MobileBKUState.this.getWaitingComposite()); - } + // show waiting composite + getStateMachine().getGUIProvider().display( + MobileBKUState.this.getWaitingComposite()); }); } diff --git a/pdf-over-signer/pdf-over-sigpdfas4/pom.xml b/pdf-over-signer/pdf-over-sigpdfas4/pom.xml index ed1cfe6c..17e7c311 100644 --- a/pdf-over-signer/pdf-over-sigpdfas4/pom.xml +++ b/pdf-over-signer/pdf-over-sigpdfas4/pom.xml @@ -10,7 +10,7 @@ PDF-Over PDF-AS 4 Signer ${project.basedir}/../.. - 4.1.6 + 4.1.7-SNAPSHOT @@ -70,5 +70,10 @@ local-repo file://${project.maindir}/repo + + EGIZ SNAPSHOT Repo + EGIZ SNAPSHOT Maven Repository + https://apps.egiz.gv.at/snapshots/ + -- cgit v1.2.3