From 8d7000e17c41b5a09590202e7ce644c9b86bfe11 Mon Sep 17 00:00:00 2001 From: Jakob Heher Date: Wed, 5 Oct 2022 12:27:07 +0200 Subject: smstan support --- .../gui/composites/MobileBKUEnterTANComposite.java | 99 +++++++--------------- .../gui/composites/MobileBKUQRComposite.java | 7 +- 2 files changed, 33 insertions(+), 73 deletions(-) (limited to 'pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites') diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/MobileBKUEnterTANComposite.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/MobileBKUEnterTANComposite.java index ab5f5962..6b52709e 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/MobileBKUEnterTANComposite.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/MobileBKUEnterTANComposite.java @@ -45,6 +45,7 @@ import com.beust.jcommander.internal.Nullable; import at.asit.pdfover.commons.Constants; import at.asit.pdfover.commons.Messages; +import at.asit.pdfover.gui.bku.OLDmobile.ATrustStatus; import at.asit.pdfover.gui.utils.SWTUtils; import at.asit.pdfover.gui.workflow.states.State; @@ -87,26 +88,7 @@ public class MobileBKUEnterTANComposite extends StateComposite { } MobileBKUEnterTANComposite.this.tan = tan; - MobileBKUEnterTANComposite.this.setUserAck(true); - MobileBKUEnterTANComposite.this.btn_ok.setEnabled(false); - //MobileBKUEnterTANComposite.this.state.updateStateMachine(); - //MobileBKUEnterTANComposite.this.btn_ok.setEnabled(true); - } - } - - /** - * - */ - private final class CancelSelectionListener extends SelectionAdapter { - /** - * Empty constructor - */ - public CancelSelectionListener() { - } - - @Override - public void widgetSelected(SelectionEvent e) { - MobileBKUEnterTANComposite.this.setUserCancel(true); + MobileBKUEnterTANComposite.this.userAck = true; } } @@ -115,16 +97,17 @@ public class MobileBKUEnterTANComposite extends StateComposite { **/ static final Logger log = LoggerFactory.getLogger(MobileBKUEnterTANComposite.class); - Text txt_tan; + private Text txt_tan; - boolean userAck = false; - boolean userCancel = false; + private boolean userAck = false; + private boolean userCancel = false; + private boolean userFido2 = false; private Label lblRefVal; - String refVal; + private String refVal; - URI signatureDataURI; + private URI signatureDataURI; /** * @param signatureData @@ -135,7 +118,7 @@ public class MobileBKUEnterTANComposite extends StateComposite { this.lnk_sig_data.setEnabled(uri != null); } - String tan; + private String tan; private Link lnk_sig_data; @@ -143,22 +126,16 @@ public class MobileBKUEnterTANComposite extends StateComposite { private Label lblRefValLabel; private Label lblTan; - Button btn_ok; - Button btn_cancel; + private Button btn_ok; + private Button btn_cancel; + private Button btn_fido2; - /** - * @return the userAck - */ - public boolean isUserAck() { - return this.userAck; - } + public boolean isDone() { return (this.userAck || this.userCancel || this.userFido2); } + public boolean isUserAck() { return this.userAck; } + public boolean isUserCancel() { return this.userCancel; } + public boolean isUserFido2() { return this.userFido2; } - /** - * @return the userCancel - */ - public boolean isUserCancel() { - return this.userCancel; - } + public void reset() { this.userAck = this.userCancel = this.userFido2 = false; } /** * Set how many tries are left @@ -166,8 +143,12 @@ public class MobileBKUEnterTANComposite extends StateComposite { * @param tries */ public void setTries(int tries) { - this.lblTries.setText(tries == 1 ? Messages.getString("tanEnter.try") : - String.format(Messages.getString("tanEnter.tries"), tries)); + if ((tries > 0) && (tries < ATrustStatus.MOBILE_MAX_TAN_TRIES)) { + if (tries > 1) + SWTUtils.setLocalizedText(lblTries, "tanEnter.try"); + else + SWTUtils.setLocalizedText(lblTries, "tanEnter.tries", tries); + } } /** @@ -182,6 +163,9 @@ public class MobileBKUEnterTANComposite extends StateComposite { Messages.getString("error.Title") + ": " + errorMessage); } + public void setFIDO2Enabled(boolean state) { + this.btn_fido2.setEnabled(state); + } /** * Sets the message @@ -194,22 +178,6 @@ public class MobileBKUEnterTANComposite extends StateComposite { this.lblTries.getParent().layout(true, true); } - /** - * @param userAck - * the userAck to set - */ - public void setUserAck(boolean userAck) { - this.userAck = userAck; - } - - /** - * @param userCancel - * the userCancel to set - */ - public void setUserCancel(boolean userCancel) { - this.userCancel = userCancel; - } - /** * @return the reference value */ @@ -217,13 +185,6 @@ public class MobileBKUEnterTANComposite extends StateComposite { return this.refVal; } - /** - * Enables the submit button - */ - public void enableButton() { - this.btn_ok.setEnabled(true); - } - /** * @param refVal * the reference value to set @@ -347,10 +308,14 @@ public class MobileBKUEnterTANComposite extends StateComposite { this.btn_cancel = new Button(containerComposite, SWT.NATIVE); SWTUtils.anchor(btn_cancel).right(btn_ok, -20).bottom(100, -20); - this.btn_cancel.addSelectionListener(new CancelSelectionListener()); + SWTUtils.addSelectionListener(btn_cancel, (e) -> { this.userCancel = true; }); + + this.btn_fido2 = new Button(containerComposite, SWT.NATIVE); + SWTUtils.anchor(btn_fido2).right(btn_cancel, -20).bottom(100, -20); + SWTUtils.addSelectionListener(btn_fido2, (e) -> { this.userFido2 = true; }); this.lblTries = new Label(containerComposite, SWT.WRAP | SWT.NATIVE); - SWTUtils.anchor(lblTries).right(btn_cancel, -10).bottom(100, -20); + SWTUtils.anchor(lblTries).right(btn_fido2, -10).bottom(100, -20); } @Override diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/MobileBKUQRComposite.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/MobileBKUQRComposite.java index 652baed4..baabc192 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/MobileBKUQRComposite.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/MobileBKUQRComposite.java @@ -16,9 +16,7 @@ package at.asit.pdfover.gui.composites; // Imports -import java.awt.Desktop; import java.io.ByteArrayInputStream; -import java.io.InputStream; import java.net.URI; import java.util.Objects; @@ -28,14 +26,11 @@ import org.eclipse.swt.SWT; import org.eclipse.swt.SWTException; import org.eclipse.swt.events.PaintEvent; import org.eclipse.swt.events.PaintListener; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.graphics.ImageData; import org.eclipse.swt.graphics.Point; import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.layout.FormLayout; -import org.eclipse.swt.program.Program; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Label; @@ -56,7 +51,7 @@ public class MobileBKUQRComposite extends StateComposite { /** * SLF4J Logger instance **/ - static final Logger log = LoggerFactory.getLogger(MobileBKUQRComposite.class); + private static final Logger log = LoggerFactory.getLogger(MobileBKUQRComposite.class); private Label lblQR; -- cgit v1.2.3