summaryrefslogtreecommitdiff
path: root/pdf-over-gui/src/main/java/at/asit/pdfover/gui
diff options
context:
space:
mode:
authorJakob Heher <jakob.heher@iaik.tugraz.at>2022-11-03 14:08:28 +0100
committerJakob Heher <jakob.heher@iaik.tugraz.at>2022-11-03 14:08:28 +0100
commit612e0044b3a2529c85e3f2b0224f43c7590b5898 (patch)
tree393306de36ac3ebffa1f3213bfe54074ac33dce7 /pdf-over-gui/src/main/java/at/asit/pdfover/gui
parent6cc72b5a50be9b1ae68d446da10f6a5f9f2ce2a2 (diff)
downloadpdf-over-612e0044b3a2529c85e3f2b0224f43c7590b5898.tar.gz
pdf-over-612e0044b3a2529c85e3f2b0224f43c7590b5898.tar.bz2
pdf-over-612e0044b3a2529c85e3f2b0224f43c7590b5898.zip
autostart fido2 authentication process
Diffstat (limited to 'pdf-over-gui/src/main/java/at/asit/pdfover/gui')
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/mobilebku/MobileBKUFido2Composite.java44
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/MobileBKUState.java1
2 files changed, 23 insertions, 22 deletions
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/mobilebku/MobileBKUFido2Composite.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/mobilebku/MobileBKUFido2Composite.java
index 826eed95..70439527 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/mobilebku/MobileBKUFido2Composite.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/mobilebku/MobileBKUFido2Composite.java
@@ -1,8 +1,5 @@
package at.asit.pdfover.gui.composites.mobilebku;
-import java.util.concurrent.CompletableFuture;
-import java.util.concurrent.Future;
-
import javax.annotation.Nonnull;
import org.eclipse.swt.SWT;
@@ -23,7 +20,6 @@ import at.asit.pdfover.gui.workflow.states.State;
import at.asit.webauthn.PublicKeyCredential;
import at.asit.webauthn.PublicKeyCredentialRequestOptions;
import at.asit.webauthn.WebAuthN;
-import at.asit.webauthn.exceptions.WebAuthNOperationFailed;
import at.asit.webauthn.exceptions.WebAuthNUserCancelled;
import at.asit.webauthn.responsefields.AuthenticatorAssertionResponse;
@@ -50,6 +46,27 @@ public class MobileBKUFido2Composite extends StateComposite {
public boolean wasUserCancelClicked() { return userCancel; }
public boolean wasUserSMSClicked() { return userSms; }
+ public void beginAuthentication() {
+ if (!btn_authenticate.isEnabled()) return;
+
+ SWTUtils.setLocalizedText(btn_authenticate, "common.working");
+ btn_authenticate.setEnabled(false);
+ new Thread(() -> {
+ try {
+ this.credential = PublicKeyCredentialRequestOptions.FromJSONString(this.fido2OptionsString).get("https://service.a-trust.at");
+ } catch (Throwable t) {
+ if (t instanceof WebAuthNUserCancelled) {
+ this.userCancel = true;
+ } else {
+ log.warn("webauthn operation failed", t);
+ }
+ } finally {
+ this.getDisplay().syncExec(() -> { btn_authenticate.setEnabled(true); this.reloadResources(); });
+ this.getDisplay().wake();
+ }
+ }).start();
+ }
+
public MobileBKUFido2Composite(Composite parent, int style, State state) {
super(parent, style, state);
setLayout(new FormLayout());
@@ -79,24 +96,7 @@ public class MobileBKUFido2Composite extends StateComposite {
this.btn_authenticate = new Button(containerComposite, SWT.NATIVE);
SWTUtils.anchor(btn_authenticate).top(50, -10).left(0, 90).right(100, -90);
- SWTUtils.addSelectionListener(btn_authenticate, () -> {
- SWTUtils.setLocalizedText(btn_authenticate, "common.working");
- btn_authenticate.setEnabled(false);
- new Thread(() -> {
- try {
- this.credential = PublicKeyCredentialRequestOptions.FromJSONString(this.fido2OptionsString).get("https://service.a-trust.at");
- } catch (Throwable t) {
- if (t instanceof WebAuthNUserCancelled) {
- this.userCancel = true;
- } else {
- log.warn("webauthn operation failed", t);
- }
- } finally {
- this.getDisplay().syncExec(() -> { btn_authenticate.setEnabled(true); this.reloadResources(); });
- this.getDisplay().wake();
- }
- }).start();
- });
+ SWTUtils.addSelectionListener(btn_authenticate, this::beginAuthentication);
}
@Override protected void checkSubclass() {}
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 4ddededf..d615d710 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
@@ -563,6 +563,7 @@ public class MobileBKUState extends State {
// TODO signature data, sms tan support
getStateMachine().display(fido2);
+ fido2.beginAuthentication();
Display display = fido2.getDisplay();
while (!fido2.isDone()) {