summaryrefslogtreecommitdiff
path: root/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites
diff options
context:
space:
mode:
authorJakob Heher <jakob.heher@iaik.tugraz.at>2022-10-05 11:39:07 +0200
committerJakob Heher <jakob.heher@iaik.tugraz.at>2022-10-05 11:39:07 +0200
commit4269338d2e11028a880c99eb906c93a397fd0c1f (patch)
treeaf3ab0f0988fe088e81fc946c38cf47fbaf47e07 /pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites
parentd6f4b34eae2e977cdd0339fb17302976fdae0574 (diff)
downloadpdf-over-4269338d2e11028a880c99eb906c93a397fd0c1f.tar.gz
pdf-over-4269338d2e11028a880c99eb906c93a397fd0c1f.tar.bz2
pdf-over-4269338d2e11028a880c99eb906c93a397fd0c1f.zip
FIDO2 support once again
Diffstat (limited to 'pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites')
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/MobileBKUEnterNumberComposite.java7
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/MobileBKUEnterTANComposite.java68
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/MobileBKUFingerprintComposite.java33
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/MobileBKUQRComposite.java185
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/AboutComposite.java59
5 files changed, 65 insertions, 287 deletions
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/MobileBKUEnterNumberComposite.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/MobileBKUEnterNumberComposite.java
index 5f228bcb..6c75b160 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/MobileBKUEnterNumberComposite.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/MobileBKUEnterNumberComposite.java
@@ -72,12 +72,11 @@ public class MobileBKUEnterNumberComposite extends StateComposite {
MobileBKUEnterNumberComposite.this.btn_ok.setEnabled(false);
} catch(InvalidPasswordException ex) {
- log.error("Validating input for Mobile BKU failed!", ex);
+ log.info("Validating input for Mobile BKU failed!", ex);
MobileBKUEnterNumberComposite.this.setErrorMessage(ex.getMessage());
MobileBKUEnterNumberComposite.this.txt_password.setFocus();
- }
- catch (Exception ex) {
- log.error("Validating input for Mobile BKU failed!", ex);
+ } catch (Exception ex) {
+ log.info("Validating input for Mobile BKU failed!", ex);
MobileBKUEnterNumberComposite.this.setErrorMessage(Messages.getString("error.InvalidPhoneNumber"));
MobileBKUEnterNumberComposite.this.txt_number.setFocus();
return;
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 7fe40ffe..ab5f5962 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
@@ -41,6 +41,8 @@ import org.eclipse.swt.widgets.Text;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import com.beust.jcommander.internal.Nullable;
+
import at.asit.pdfover.commons.Constants;
import at.asit.pdfover.commons.Messages;
import at.asit.pdfover.gui.utils.SWTUtils;
@@ -55,11 +57,6 @@ public class MobileBKUEnterTANComposite extends StateComposite {
*
*/
private final class OkSelectionListener extends SelectionAdapter {
- /**
- * Empty constructor
- */
- public OkSelectionListener() {
- }
@Override
public void widgetSelected(SelectionEvent e) {
@@ -127,25 +124,21 @@ public class MobileBKUEnterTANComposite extends StateComposite {
String refVal;
- String signatureData;
-
- /**
- * @return the signatureData
- */
- public String getSignatureData() {
- return this.signatureData;
- }
+ URI signatureDataURI;
/**
* @param signatureData
* the signatureData to set
*/
- public void setSignatureData(String signatureData) {
- this.signatureData = signatureData;
+ public void setSignatureDataURI(@Nullable URI uri) {
+ this.signatureDataURI = uri;
+ this.lnk_sig_data.setEnabled(uri != null);
}
String tan;
+ private Link lnk_sig_data;
+
private Label lblTries;
private Label lblRefValLabel;
private Label lblTan;
@@ -268,36 +261,6 @@ public class MobileBKUEnterTANComposite extends StateComposite {
}
/**
- * Selection Listener for open button
- */
- private final class ShowSignatureDataListener extends SelectionAdapter {
- /**
- * Empty constructor
- */
- public ShowSignatureDataListener() {
- }
-
- @Override
- public void widgetSelected(SelectionEvent e) {
- try {
- String signatureData = MobileBKUEnterTANComposite.this
- .getSignatureData();
- if (signatureData != null && !signatureData.equals("")) {
- log.debug("Trying to open " + signatureData);
- if (Desktop.isDesktopSupported()) {
- Desktop.getDesktop().browse(new URI(signatureData));
- } else {
- log.info("SWT Desktop is not supported on this platform");
- Program.launch(signatureData);
- }
- }
- } catch (Exception ex) {
- log.error("OpenSelectionListener: ", ex);
- }
- }
- }
-
- /**
* Create the composite.
*
* @param parent
@@ -368,27 +331,22 @@ public class MobileBKUEnterTANComposite extends StateComposite {
if (text.length() > 3
&& MobileBKUEnterTANComposite.this.getRefVal()
.startsWith(text.trim())) {
- MobileBKUEnterTANComposite.this.setMessage(Messages
- .getString("error.EnteredReferenceValue"));
+ MobileBKUEnterTANComposite.this.setMessage(Messages.getString("error.EnteredReferenceValue"));
}
}
});
- Link lnk_sig_data = new Link(containerComposite, SWT.NATIVE | SWT.RESIZE);
+ this.lnk_sig_data = new Link(containerComposite, SWT.NATIVE | SWT.RESIZE);
SWTUtils.anchor(lnk_sig_data).right(100,-20).top(0,20);
lnk_sig_data.setEnabled(true);
- lnk_sig_data.addSelectionListener(new ShowSignatureDataListener());
- SWTUtils.setLocalizedText(lnk_sig_data, "mobileBKU.show");
- SWTUtils.setLocalizedToolTipText(lnk_sig_data, "mobileBKU.show_tooltip");
+ SWTUtils.addSelectionListener(lnk_sig_data, (e) -> { SWTUtils.openURL(this.signatureDataURI); });
this.btn_ok = new Button(containerComposite, SWT.NATIVE);
SWTUtils.anchor(btn_ok).right(100,-20).bottom(100,-20);
- SWTUtils.setLocalizedText(btn_ok, "common.Ok");
this.btn_ok.addSelectionListener(new OkSelectionListener());
this.btn_cancel = new Button(containerComposite, SWT.NATIVE);
SWTUtils.anchor(btn_cancel).right(btn_ok, -20).bottom(100, -20);
- SWTUtils.setLocalizedText(btn_cancel, "common.Cancel");
this.btn_cancel.addSelectionListener(new CancelSelectionListener());
this.lblTries = new Label(containerComposite, SWT.WRAP | SWT.NATIVE);
@@ -417,7 +375,11 @@ public class MobileBKUEnterTANComposite extends StateComposite {
*/
@Override
public void reloadResources() {
+ SWTUtils.setLocalizedText(lnk_sig_data, "mobileBKU.show");
+ SWTUtils.setLocalizedToolTipText(lnk_sig_data, "mobileBKU.show_tooltip");
SWTUtils.setLocalizedText(lblRefValLabel, "tanEnter.ReferenceValue");
SWTUtils.setLocalizedText(lblTan, "tanEnter.TAN");
+ SWTUtils.setLocalizedText(btn_cancel, "common.Cancel");
+ SWTUtils.setLocalizedText(btn_ok, "common.Ok");
}
}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/MobileBKUFingerprintComposite.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/MobileBKUFingerprintComposite.java
index af630b8d..afa71f9f 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/MobileBKUFingerprintComposite.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/MobileBKUFingerprintComposite.java
@@ -201,37 +201,6 @@ public class MobileBKUFingerprintComposite extends StateComposite {
}
-
- /**
- * Selection Listener for open button
- */
- private final class ShowSignatureDataListener extends SelectionAdapter {
- /**
- * Empty constructor
- */
- public ShowSignatureDataListener() {
- }
-
- @Override
- public void widgetSelected(SelectionEvent e) {
- try {
- String signatureData = MobileBKUFingerprintComposite.this
- .getSignatureData();
- if (signatureData != null && !signatureData.equals("")) {
- log.debug("Trying to open " + signatureData);
- if (Desktop.isDesktopSupported()) {
- Desktop.getDesktop().browse(new URI(signatureData));
- } else {
- log.info("SWT Desktop is not supported on this platform");
- Program.launch(signatureData);
- }
- }
- } catch (Exception ex) {
- log.error("OpenSelectionListener: ", ex);
- }
- }
- }
-
/**
* Create the composite.
*
@@ -279,7 +248,7 @@ public class MobileBKUFingerprintComposite extends StateComposite {
this.lnk_sig_data = new Link(containerComposite, SWT.NATIVE | SWT.RESIZE);
SWTUtils.anchor(lnk_sig_data).right(100, -20).top(0, 20);
this.lnk_sig_data.setEnabled(true);
- this.lnk_sig_data.addSelectionListener(new ShowSignatureDataListener());
+ SWTUtils.addSelectionListener(lnk_sig_data, (e) -> { SWTUtils.openURL(getSignatureData()); });
this.btn_cancel = new Button(containerComposite, SWT.NATIVE);
SWTUtils.anchor(btn_cancel).right(100, -20).bottom(100, -20);
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 3f1aa04d..652baed4 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
@@ -20,6 +20,9 @@ import java.awt.Desktop;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.net.URI;
+import java.util.Objects;
+
+import javax.annotation.Nullable;
import org.eclipse.swt.SWT;
import org.eclipse.swt.SWTException;
@@ -51,52 +54,16 @@ import at.asit.pdfover.gui.workflow.states.State;
public class MobileBKUQRComposite extends StateComposite {
/**
- *
- */
- private final class SMSSelectionListener extends SelectionAdapter {
- /**
- * Empty constructor
- */
- public SMSSelectionListener() {
- }
-
- @Override
- public void widgetSelected(SelectionEvent e) {
- if(!MobileBKUQRComposite.this.btn_sms.getEnabled()) {
- return;
- }
-
- MobileBKUQRComposite.this.setUserSMS(true);
- MobileBKUQRComposite.this.btn_sms.setEnabled(false);
- }
- }
-
- /**
- *
- */
- private final class CancelSelectionListener extends SelectionAdapter {
- /**
- * Empty constructor
- */
- public CancelSelectionListener() {
- }
-
- @Override
- public void widgetSelected(SelectionEvent e) {
- MobileBKUQRComposite.this.setUserCancel(true);
- }
- }
-
- /**
* SLF4J Logger instance
**/
static final Logger log = LoggerFactory.getLogger(MobileBKUQRComposite.class);
private Label lblQR;
- private boolean userCancel = false;
- private boolean userSMS = false;
- private boolean done = false;
+ private boolean userCancelClicked = false;
+ private boolean userSMSClicked = false;
+ private boolean userFIDO2Clicked = false;
+ private boolean pollingDone = false;
private Label lblRefVal;
@@ -104,52 +71,24 @@ public class MobileBKUQRComposite extends StateComposite {
private ImageData currentQRImage;
- private String signatureData;
-
- /**
- * @return the signatureData
- */
- public String getSignatureData() {
- return this.signatureData;
- }
-
- /**
- * @param signatureData
- * the signatureData to set
- */
- public void setSignatureData(String signatureData) {
- this.signatureData = signatureData;
- }
+ private URI signatureDataURI;
private Label lblError;
private Label lblRefValLabel;
private Label lblQRLabel;
+ private Button btn_fido2;
private Button btn_sms;
private Button btn_cancel;
private Link lnk_sig_data;
- /**
- * @return the userCancel
- */
- public boolean isUserCancel() {
- return this.userCancel;
- }
-
- /**
- * @return the userSMS
- */
- public boolean isUserSMS() {
- return this.userSMS;
- }
-
- /**
- * @return the done
- */
- public boolean isDone() {
- return this.done;
- }
+ public void signalPollingDone() { this.pollingDone = true; getDisplay().wake(); }
+ public boolean isDone() { return (this.userCancelClicked || this.userSMSClicked || this.userFIDO2Clicked || this.pollingDone); }
+ public boolean wasCancelClicked() { return this.userCancelClicked; }
+ public boolean wasSMSClicked() { return this.userSMSClicked; }
+ public boolean wasFIDO2Clicked() { return this.userFIDO2Clicked; }
+ public void reset() { this.userCancelClicked = this.userSMSClicked = this.userFIDO2Clicked = this.pollingDone = false; }
/**
* Set an error message
@@ -163,48 +102,10 @@ public class MobileBKUQRComposite extends StateComposite {
Messages.getString("error.Title") + ": " + errorMessage);
}
- /**
- * @param userCancel
- * the userCancel to set
- */
- public void setUserCancel(boolean userCancel) {
- this.userCancel = userCancel;
- }
-
- /**
- * @param userSMS
- * the userSMS to set
- */
- public void setUserSMS(boolean userSMS) {
- this.userSMS = userSMS;
- }
-
- /**
- * @param done
- * the done to set
- */
- public void setDone(boolean done) {
- this.done = done;
- }
-
- /**
- * @return the reference value
- */
- public String getRefVal() {
- return this.refVal;
- }
-
- /**
- * @param refVal
- * the reference value to set
- */
+ public String getRefVal() { return this.refVal; }
public void setRefVal(String refVal) {
- if (this.refVal != null) {
- this.refVal = refVal.trim();
- this.lblRefVal.setText(this.refVal);
- } else {
- this.lblRefVal.setText("");
- }
+ this.refVal = (refVal != null) ? refVal.trim() : null;
+ this.lblRefVal.setText(Objects.requireNonNullElse(this.refVal, ""));
}
private void updateQRImage() {
@@ -238,34 +139,17 @@ public class MobileBKUQRComposite extends StateComposite {
updateQRImage();
}
- /**
- * Selection Listener for open button
- */
- private final class ShowSignatureDataListener extends SelectionAdapter {
- /**
- * Empty constructor
- */
- public ShowSignatureDataListener() {
- }
+ public void setSMSEnabled(boolean state) {
+ this.btn_sms.setEnabled(state);
+ }
- @Override
- public void widgetSelected(SelectionEvent e) {
- try {
- String signatureData = MobileBKUQRComposite.this
- .getSignatureData();
- if (signatureData != null && !signatureData.equals("")) {
- log.debug("Trying to open " + signatureData);
- if (Desktop.isDesktopSupported()) {
- Desktop.getDesktop().browse(new URI(signatureData));
- } else {
- log.info("SWT Desktop is not supported on this platform");
- Program.launch(signatureData);
- }
- }
- } catch (Exception ex) {
- log.error("OpenSelectionListener: ", ex);
- }
- }
+ public void setFIDO2Enabled(boolean state) {
+ this.btn_fido2.setEnabled(state);
+ }
+
+ public void setSignatureDataURI(@Nullable URI uri) {
+ this.signatureDataURI = uri;
+ this.lnk_sig_data.setEnabled(uri != null);
}
/**
@@ -317,16 +201,20 @@ public class MobileBKUQRComposite extends StateComposite {
this.lnk_sig_data = new Link(containerComposite, SWT.NATIVE | SWT.RESIZE);
SWTUtils.anchor(lnk_sig_data).right(100, -20).top(0, 20);
- this.lnk_sig_data.setEnabled(true);
- this.lnk_sig_data.addSelectionListener(new ShowSignatureDataListener());
+ SWTUtils.addSelectionListener(lnk_sig_data, (e) -> { SWTUtils.openURL(this.signatureDataURI); });
this.btn_cancel = new Button(containerComposite, SWT.NATIVE);
SWTUtils.anchor(btn_cancel).right(100, -20).bottom(100, -5);
- this.btn_cancel.addSelectionListener(new CancelSelectionListener());
+ SWTUtils.addSelectionListener(btn_cancel, (e) -> { this.userCancelClicked = true; });
this.btn_sms = new Button(containerComposite, SWT.NATIVE);
SWTUtils.anchor(btn_sms).right(btn_cancel, -20).bottom(100, -5);
- this.btn_sms.addSelectionListener(new SMSSelectionListener());
+ SWTUtils.addSelectionListener(btn_sms, (e) -> { this.userSMSClicked = true; });
+
+ this.btn_fido2 = new Button(containerComposite, SWT.NATIVE);
+ SWTUtils.anchor(btn_fido2).right(btn_sms, -20).bottom(100, -5);
+ SWTUtils.addSelectionListener(btn_fido2, (e) -> {this.userFIDO2Clicked = true; });
+
SWTUtils.anchor(lblQR).left(50, 10).right(100, -20).top(lblRefVal, 10).bottom(btn_sms, -10);
@@ -364,5 +252,6 @@ public class MobileBKUQRComposite extends StateComposite {
SWTUtils.setLocalizedToolTipText(lnk_sig_data, "mobileBKU.show_tooltip");
SWTUtils.setLocalizedText(btn_cancel, "common.Cancel");
SWTUtils.setLocalizedText(btn_sms, "tanEnter.SMS");
+ SWTUtils.setLocalizedText(btn_fido2, "tanEnter.FIDO2");
}
}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/AboutComposite.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/AboutComposite.java
index 35b73e7b..b4675e2a 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/AboutComposite.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/AboutComposite.java
@@ -47,6 +47,7 @@ public class AboutComposite extends ConfigurationCompositeBase {
this.lnkAbout = new Link(this, SWT.WRAP);
SWTUtils.anchor(lnkAbout).top(0,5).right(100,-5).left(0,5);
SWTUtils.setFontHeight(lnkAbout, Constants.TEXT_SIZE_NORMAL);
+ SWTUtils.addSelectionListener(lnkAbout, (e) -> { SWTUtils.openURL(Messages.getString("config.LicenseURL")); });
this.lblDataProtection = new Label(this, SWT.WRAP);
SWTUtils.anchor(lblDataProtection).top(lnkAbout, 15).left(0,5).right(100,-5);
@@ -56,6 +57,7 @@ public class AboutComposite extends ConfigurationCompositeBase {
this.lnkDataProtection = new Link(this, SWT.WRAP);
SWTUtils.anchor(lnkDataProtection).top(lblDataProtection,10).left(0,5).right(100,-5);
SWTUtils.setFontHeight(lnkDataProtection, Constants.TEXT_SIZE_NORMAL);
+ SWTUtils.addSelectionListener(lnkDataProtection, (e) -> { SWTUtils.openURL(Messages.getString("config.DataProtectionURL")); });
this.lnkUpdateCheckStatus = new Link(this, SWT.NONE);
SWTUtils.anchor(lnkUpdateCheckStatus).bottom(100, -5).left(0,5);
@@ -84,56 +86,13 @@ public class AboutComposite extends ConfigurationCompositeBase {
SWTUtils.reanchor(lnkDataProtection).bottom(btnUpdateCheck,-5);
- this.lnkAbout.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- try {
- URI url = new URI(Messages.getString("config.LicenseURL"));
- log.debug("Trying to open " + url.toString());
- if (Desktop.isDesktopSupported()) {
- Desktop.getDesktop().browse(url);
- } else {
- log.info("AWT Desktop is not supported on this platform");
- Program.launch(url.toString());
- }
- } catch (IOException ex) {
- log.error("AboutComposite: ", ex);
- } catch (URISyntaxException ex) {
- log.error("AboutComposite: ", ex);
- }
- }
- });
-
- this.lnkDataProtection.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- try {
- URI url = new URI(Messages.getString("config.DataProtectionURL"));
- log.debug("Trying to open " + url.toString());
- if (Desktop.isDesktopSupported()) {
- Desktop.getDesktop().browse(url);
- } else {
- log.info("AWT Desktop is not supported on this platform");
- Program.launch(url.toString());
- }
- } catch (IOException ex) {
- log.error("AboutComposite: ", ex);
- } catch (URISyntaxException ex) {
- log.error("AboutComposite: ", ex);
- }
- }
- });
-
- this.btnOpenLogDirectory.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- try
- {
- if (Desktop.isDesktopSupported())
- Desktop.getDesktop().open(new File(Constants.CONFIG_DIRECTORY + File.separator + "logs"));
- } catch (Exception ex) {
- log.warn("Failed to open log directory: ", ex);
- }
+ SWTUtils.addSelectionListener(btnOpenLogDirectory, (e) -> {
+ try
+ {
+ if (Desktop.isDesktopSupported())
+ Desktop.getDesktop().open(new File(Constants.CONFIG_DIRECTORY + File.separator + "logs"));
+ } catch (Exception ex) {
+ log.warn("Failed to open log directory: ", ex);
}
});