summaryrefslogtreecommitdiff
path: root/pdf-over-gui/src/main/java/at
diff options
context:
space:
mode:
Diffstat (limited to 'pdf-over-gui/src/main/java/at')
-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()) {