From 65dbb73e8fe163a7e38df1a55f90ccb95624ac1c Mon Sep 17 00:00:00 2001 From: Andreas Abraham Date: Mon, 5 Aug 2019 12:51:50 +0200 Subject: dynamic attributes names for TAN implemented --- .../src/main/java/at/asit/pdfover/gui/Constants.java | 8 +++++--- .../java/at/asit/pdfover/gui/bku/MobileBKUConnector.java | 3 ++- .../java/at/asit/pdfover/gui/bku/mobile/ATrustHandler.java | 14 +++++++++----- 3 files changed, 16 insertions(+), 9 deletions(-) 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 129c8aee..c3485971 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 @@ -84,8 +84,8 @@ public class Constants { public static final String LOCAL_BKU_URL = "http://127.0.0.1:3495/http-security-layer-request"; //$NON-NLS-1$ /** 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://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$ /** Default Mobile BKU type */ public static final MobileBKUs DEFAULT_MOBILE_BKU_TYPE = MobileBKUs.A_TRUST; @@ -350,7 +350,9 @@ public class Constants { /** Download URL for accepted certificates */ - public static final String CERTIFICATE_DOWNLOAD_XML_URL = "https://www.buergerkarte.at/trust/"; + public static final String CERTIFICATE_DOWNLOAD_XML_URL = "https://www.buergerkarte.at/trust/"; //$NON-NLS-1$ public static final String CERTIFICATE_XML_FILE = "certificates.xml"; //$NON-NLS-1$ + + public static final String LABEL_TAN = "input_tan"; //$NON-NLS-1$ } diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/MobileBKUConnector.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/MobileBKUConnector.java index ba59d16a..a67ea019 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/MobileBKUConnector.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/MobileBKUConnector.java @@ -91,7 +91,7 @@ public class MobileBKUConnector implements BkuSlConnector { try { String responseData = handler.postCredentials(); - if (responseData.contains(/*"page_undecided"*/"undecided.aspx?sid=")) { //$NON-NLS-1$ + if (responseData.contains("undecided.aspx?sid=")) { //$NON-NLS-1$ // handle polling this.state.showOpenAppMessage(); @@ -181,6 +181,7 @@ public class MobileBKUConnector implements BkuSlConnector { if (enterTAN) { // Get TAN this.state.checkTAN(); + if (this.state.getStatus().getErrorMessage() != null && this.state.getStatus().getErrorMessage().equals("cancel")) //$NON-NLS-1$ 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 02af7686..0a92f553 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 @@ -43,6 +43,8 @@ import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonParser; +import at.asit.pdfover.gui.Constants; +import at.asit.pdfover.gui.bku.BKUHelper; import at.asit.pdfover.gui.controls.Dialog; import at.asit.pdfover.gui.controls.Dialog.BUTTONS; import at.asit.pdfover.gui.controls.Dialog.ICON; @@ -125,8 +127,8 @@ public class ATrustHandler extends MobileBKUHandler { status.setDynAttrPhonenumber(dynamicAttrPhonenumber); status.setDynAttrPassword(dynamicAttrPassword); status.setDynAttrBtnId(dynamicAttrButtonId); - status.setDynAttrTan(dynamicAttrTan); - + //status.setDynAttrTan(dynamicAttrTan); + status.setDynAttrTan("ctl00$content$input_tan"); } /* (non-Javadoc) @@ -222,7 +224,7 @@ public class ATrustHandler extends MobileBKUHandler { String t_sessionID = MobileBKUHelper.extractSubstring(responseData, "tanAppInfo.aspx?sid=", "\""); //$NON-NLS-1$ //$NON-NLS-2$ String t_viewState = MobileBKUHelper.extractValueFromTagWithParam(responseData, "", "id", "__VIEWSTATE", "value"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ String t_eventValidation = MobileBKUHelper.extractValueFromTagWithParam(responseData, "", "id", "__EVENTVALIDATION", "value"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ - + // Post again to skip MobileBKUHelper.registerTrustedSocketFactory(); HttpClient client = MobileBKUHelper.getHttpClient(getStatus()); @@ -256,12 +258,14 @@ public class ATrustHandler extends MobileBKUHandler { try { tanField = MobileBKUHelper.extractValueFromTagWithParam(responseData, "label", "id", "label_for_input_tan", "for"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ status.setTanField(tanField); + status.setDynAttrTan(MobileBKUHelper.getNameAttribute(responseData, Constants.LABEL_TAN)); } catch (Exception e) { log.debug("No tan field found"); //$NON-NLS-1$ } try { tanTextTan = tanField = MobileBKUHelper.extractContentFromTagWithParam(responseData, "span", "id", "text_tan"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ status.setIsAPPTan(tanTextTan); + status.setDynAttrTan(MobileBKUHelper.getNameAttribute(responseData, Constants.LABEL_TAN)); }catch (Exception e) { log.debug("No text_tan tag"); //$NON-NLS-1$ } @@ -271,7 +275,7 @@ public class ATrustHandler extends MobileBKUHandler { log.debug("Credentials accepted - Response given"); //$NON-NLS-1$ getSigningState().setSignatureResponse(new SLResponse(responseData, getStatus().getServer(), null, null)); return; - } else if (responseData.contains(/*page_undecided*/"undecided.aspx?sid=")) { //$NON-NLS-1$ + } else if (responseData.contains("undecided.aspx?sid=")) { //$NON-NLS-1$ // skip intermediate page log.debug("Page Undecided"); //$NON-NLS-1$ getSigningState().setSignatureResponse(new SLResponse(responseData, getStatus().getServer(), null, null)); @@ -323,7 +327,7 @@ public class ATrustHandler extends MobileBKUHandler { post.addParameter( "__EVENTVALIDATION", status.getEventvalidation()); //$NON-NLS-1$ post.addParameter(status.getDynAttrTan(), status.getTan()); //$NON-NLS-1$ - post.addParameter("SignButton", "Signieren"); //$NON-NLS-1$ //$NON-NLS-2$ + post.addParameter(/*button name: "SignButton"*/"ctl00$content$SignButton", "Signieren"); //$NON-NLS-1$ //$NON-NLS-2$ post.addParameter("Button1", "Identifizieren"); //$NON-NLS-1$ //$NON-NLS-2$ return executePost(client, post); -- cgit v1.2.3