diff options
author | Andreas Abraham <andreas.abraham@egiz.gv.at> | 2019-11-04 15:41:43 +0100 |
---|---|---|
committer | Andreas Abraham <andreas.abraham@egiz.gv.at> | 2019-11-04 15:41:43 +0100 |
commit | 2e542bf894651cd02a38f28215e7a11c0c018b7a (patch) | |
tree | 4117e6910de07e5690fb3b6e4082f2f4cf45a155 /pdf-over-gui/src | |
parent | b8eae80f420f8bf97f45a78df521d60960a8ffdb (diff) | |
download | pdf-over-2e542bf894651cd02a38f28215e7a11c0c018b7a.tar.gz pdf-over-2e542bf894651cd02a38f28215e7a11c0c018b7a.tar.bz2 pdf-over-2e542bf894651cd02a38f28215e7a11c0c018b7a.zip |
request sms tan in waiting screen
Diffstat (limited to 'pdf-over-gui/src')
6 files changed, 191 insertions, 47 deletions
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 a67ea019..19def107 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 @@ -94,8 +94,20 @@ public class MobileBKUConnector implements BkuSlConnector { if (responseData.contains("undecided.aspx?sid=")) { //$NON-NLS-1$
// handle polling
- this.state.showOpenAppMessage();
- handler.handlePolling(responseData);
+ //this.state.showOpenAppMessage();
+ this.state.showOpenAppMessageWithSMSandCancel();
+
+ if (((ATrustStatus) this.state.getStatus()).isSmsTan()) {
+ //((ATrustStatus)this.state.getStatus()).setSmsTan(false);
+ ATrustHandler aHandler = (ATrustHandler) handler;
+ String response = aHandler.postSMSRequest();
+ aHandler.handleCredentialsResponse(response);
+ ((ATrustStatus)this.state.getStatus()).setIsAPPTan("sms"); //$NON-NLS-1$
+ this.state.checkTAN();
+ } else {
+ handler.handlePolling(responseData);
+ }
+
} else {
@@ -146,7 +158,7 @@ public class MobileBKUConnector implements BkuSlConnector { enterTAN = false;
}
}
- if (enterTAN && !aStatus.getTanField()) {
+ if (enterTAN && !aStatus.getTanField() && !aStatus.isSmsTan()) {
try {
this.state.showFingerPrintInformation();
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 e95121b2..2c6f0e55 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 @@ -444,6 +444,22 @@ public class ATrustHandler extends MobileBKUHandler { return executeGet(client, get);
}
+
+ /**
+ * @param responseData
+ * @return a boolean
+ */
+ public Boolean handleWaitforAppResponse(String responseData) {
+
+ getStatus().setErrorMessage(null);
+ if (!responseData.contains("Bitte starten Sie Ihre")) { //$NON-NLS-1$
+ //getSigningState().setSignatureResponse(
+ // new SLResponse(responseData, getStatus().getServer(), null, null));
+ return true;
+
+ }
+ return false;
+ }
/**
* Parse QR code response
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/ATrustStatus.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/ATrustStatus.java index b34322b8..4c8b42e8 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/ATrustStatus.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/ATrustStatus.java @@ -47,6 +47,7 @@ public class ATrustStatus extends AbstractMobileBKUStatusImpl { private String dynAttrBtnId;
private String dynAttrTan;
private String dynAttrSignButton;
+ private boolean smsTan = false;
/**
* Constructor
@@ -240,4 +241,18 @@ public class ATrustStatus extends AbstractMobileBKUStatusImpl { this.dynAttrSignButton = dynAttrSignButton;
}
+ /**
+ * @return the smsTan
+ */
+ public boolean isSmsTan() {
+ return smsTan;
+ }
+
+ /**
+ * @param smsTan the smsTan to set
+ */
+ public void setSmsTan(boolean smsTan) {
+ this.smsTan = smsTan;
+ }
+
}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/WaitingForAppComposite.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/WaitingForAppComposite.java index 360786d4..14d257bd 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/WaitingForAppComposite.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/WaitingForAppComposite.java @@ -26,12 +26,33 @@ import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.ProgressBar;
import at.asit.pdfover.gui.utils.Messages;
import at.asit.pdfover.gui.workflow.states.State;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
/**
*
*/
public class WaitingForAppComposite extends StateComposite {
private Label lbl_description;
+ private Button btn_sms;
+ private Boolean isUserSMS = false;
+ private Boolean userCancel = false;
+ private Boolean isDone = false;
+
+ /**
+ * @return the isDone
+ */
+ public Boolean getIsDone() {
+ return isDone;
+ }
+
+ /**
+ * @param isDone the isDone to set
+ */
+ public void setIsDone(Boolean isDone) {
+ this.isDone = isDone;
+ }
/**
* Create the composite.
@@ -60,9 +81,40 @@ public class WaitingForAppComposite extends StateComposite { fd_progressBar.right = new FormAttachment(50, +100);
progressBar.setLayoutData(fd_progressBar);
+ this.btn_sms = new Button(this, SWT.NONE);
+ this.btn_sms.addSelectionListener(new SMSSelectionListener());
+
+ FormData fd_btnNewButton = new FormData();
+ fd_btnNewButton.bottom = new FormAttachment(100, -26);
+ fd_btnNewButton.right = new FormAttachment(100, -40);
+ this.btn_sms.setLayoutData(fd_btnNewButton);
+ this.btn_sms.setText(Messages.getString("SMS tan")); //$NON-NLS-1$
+
reloadResources();
}
+
+ private final class SMSSelectionListener extends SelectionAdapter {
+ /**
+ * Empty constructor
+ */
+ public SMSSelectionListener() {
+ }
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ if(!WaitingForAppComposite.this.btn_sms.getEnabled()) {
+ return;
+ }
+
+ WaitingForAppComposite.this.setUserSMS(true);
+ WaitingForAppComposite.this.btn_sms.setEnabled(false);
+ }
+ }
+
+ public void setUserSMS(boolean b) {
+ this.isUserSMS = b;
+ }
@Override
protected void checkSubclass() {
@@ -83,5 +135,28 @@ public class WaitingForAppComposite extends StateComposite { @Override
public void reloadResources() {
this.lbl_description.setText(Messages.getString("waiting_for_app.message")); //$NON-NLS-1$
+ this.btn_sms.setText("SMS tan"); //$NON-NLS-1$
+ }
+
+ /**
+ * @return
+ */
+ public boolean getUserCancel() {
+ return userCancel;
+ }
+
+ /**
+ * @param b
+ */
+ public void setUserCancel(boolean b) {
+ userCancel = b;
+
+ }
+
+ /**
+ * @return
+ */
+ public boolean getUserSMS() {
+ return this.isUserSMS;
}
}
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 9d2fb32f..cf107b58 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 @@ -445,49 +445,74 @@ public class MobileBKUState extends State { }
-// /**
-// *
-// */
-// public void showOpenAppMessageWithSMSandCancel() {
-//
-// final ATrustStatus status = (ATrustStatus) this.getStatus();
-// final ATrustHandler handler = (ATrustHandler) this.getHandler();
-//
-// Display.getDefault().syncExec(new Runnable() {
-// @Override
-// public void run() {
-// WaitingForAppComposite waitingForAppcomposite = getWaitingForAppComposite();
-// getStateMachine().getGUIProvider().display(waitingForAppcomposite);
-//
-// Display display = getStateMachine().getGUIProvider().getMainShell().getDisplay();
-// while (!waitingForAppcomposite.getUserCancel() && !waitingForAppcomposite.getUserSMS() && !waitingForAppcomposite.getDone()) {
-// if (!display.readAndDispatch()) {
-// display.sleep();
-// }
-// }
-//
-// if (waitingForAppcomposite.getUserCancel()) {
-// waitingForAppcomposite.setUserCancel(false);
-// status.setErrorMessage("cancel"); //$NON-NLS-1$
-// return;
-// }
-//
-// if (waitingForAppcomposite.getUserSMS()) {
-// status.setQRCode(null);
-// status.setErrorMessage(null);
-// return;
-//
-// }
-//
-// if (waitingForAppcomposite.getDone())
-// waitingForAppcomposite.setDone(false);
-//
-// // show waiting composite
-// getStateMachine().getGUIProvider().display(
-// MobileBKUState.this.getWaitingComposite());
-// }
-// });
-// }
+ /**
+ *
+ */
+ public void showOpenAppMessageWithSMSandCancel() {
+
+ final ATrustStatus status = (ATrustStatus) this.getStatus();
+ final ATrustHandler handler = (ATrustHandler) this.getHandler();
+
+ final Timer checkDone = new Timer(true);
+ checkDone.scheduleAtFixedRate(new TimerTask() {
+
+ @Override
+ public void run() {
+ // ping signature page to see if code has been scanned
+ try {
+ String resp = handler.getSignaturePage();
+ if (handler.handleWaitforAppResponse(resp)) {
+ log.debug("Signature page response: " + resp); //$NON-NLS-1$
+ getWaitingForAppComposite().setIsDone(true);
+ Display display = getStateMachine().getGUIProvider().getMainShell().getDisplay();
+ display.wake();
+ }
+ Display.getDefault().wake();
+ } catch (Exception e) {
+ log.error("Error getting signature page", e); //$NON-NLS-1$
+ }
+ }
+ }, 0, 5000);
+
+ Display.getDefault().syncExec(new Runnable() {
+ @Override
+ public void run() {
+ WaitingForAppComposite waitingForAppcomposite = MobileBKUState.this.getWaitingForAppComposite();// getWaitingForAppComposite();
+ getStateMachine().getGUIProvider().display(waitingForAppcomposite);
+
+ Display display = getStateMachine().getGUIProvider().getMainShell().getDisplay();
+ while (!waitingForAppcomposite.getUserCancel() && !waitingForAppcomposite.getUserSMS()
+ && !waitingForAppcomposite.getIsDone()) {
+ if (!display.readAndDispatch()) {
+ display.sleep();
+ }
+ }
+
+ if (waitingForAppcomposite.getUserCancel()) {
+ waitingForAppcomposite.setUserCancel(false);
+ status.setErrorMessage("cancel"); //$NON-NLS-1$
+ return;
+ }
+
+ if (waitingForAppcomposite.getUserSMS()) {
+ status.setQRCode(null);
+ waitingForAppcomposite.setUserSMS(false);
+ status.setErrorMessage("sms"); //$NON-NLS-1$
+ status.setSmsTan(true);
+ // show waiting composite
+ getStateMachine().getGUIProvider().display(MobileBKUState.this.getWaitingComposite());
+ return;
+
+ }
+
+ if (waitingForAppcomposite.getIsDone())
+ waitingForAppcomposite.setIsDone(false);
+
+ // show waiting composite
+ getStateMachine().getGUIProvider().display(MobileBKUState.this.getWaitingComposite());
+ }
+ });
+ }
/**
* when fingerprint or faceid is selected in the app
diff --git a/pdf-over-gui/src/main/resources/at/asit/pdfover/gui/messages.properties b/pdf-over-gui/src/main/resources/at/asit/pdfover/gui/messages.properties index 4e0d101b..7d6b625f 100644 --- a/pdf-over-gui/src/main/resources/at/asit/pdfover/gui/messages.properties +++ b/pdf-over-gui/src/main/resources/at/asit/pdfover/gui/messages.properties @@ -1,5 +1,5 @@ #Eclipse messages class
-#Thu Aug 01 14:54:36 CEST 2019
+#Wed Oct 30 13:33:54 CET 2019
BKU.KS=Keystore
BKU.LOCAL=Local CCE
BKU.MOBILE=Mobile CCE
@@ -7,6 +7,7 @@ BKU.NONE=no default BKUSelectionComposite.btnMobile.text=MOBILE
TrustedSocketFactory.FailedToCreateSecureConnection=Failed to create secure network connection
WaitingForAppComposite.btnCancel_1.text=Cancel
+WaitingForAppComposite.btnNewButton.text=New Button
WaitingForAppComposite.btnRequestSms.text=Request SMS
WaitingForAppComposite.lblNewLabel.text=New Label
advanced_config.AutoPosition=Automatic positioning
|