summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/ATrustParser.java2
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/mobilebku/MobileBKUFido2Composite.java28
2 files changed, 19 insertions, 11 deletions
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/ATrustParser.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/ATrustParser.java
index 1d0b6406..03ddd0c3 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/ATrustParser.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/ATrustParser.java
@@ -308,7 +308,7 @@ public class ATrustParser {
this.signatureDataLink = getHrefIfExists("#LinkList a[href*=\"ShowSigobj.aspx\"]"); /* grr, they didn't give it an ID */
this.smsTanLink = getHrefIfExists("#SmsButton");
- this.fido2Link = getHrefIfExists("#FidoButton");
+ this.fido2Link = getHrefIfExists("#FidoButton"); // TODO hide the button if unsupported?
this.interstitialBlock = TryParseMainBlock(InterstitialBlock.class);
this.errorBlock = TryParseMainBlock(ErrorBlock.class);
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 f303d6c3..6a824345 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,5 +1,8 @@
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;
@@ -79,16 +82,21 @@ public class MobileBKUFido2Composite extends StateComposite {
SWTUtils.addSelectionListener(btn_authenticate, () -> {
SWTUtils.setLocalizedText(btn_authenticate, "common.working");
btn_authenticate.setEnabled(false);
- try {
- /* let the click process first so we don't steal back focus from the fido2 popup */
- try { Thread.sleep(10); } catch (InterruptedException e) {}
- this.credential = PublicKeyCredentialRequestOptions.FromJSONString(this.fido2OptionsString).get("https://service.a-trust.at");
- } catch (WebAuthNUserCancelled e) {
- this.userCancel = true;
- } catch (WebAuthNOperationFailed e) {
- // TODO
- log.error("webauthn fail", e);
- } finally { btn_authenticate.setEnabled(true); reloadResources(); }
+ PublicKeyCredentialRequestOptions.FromJSONString(this.fido2OptionsString).asyncGet("https://service.a-trust.at")
+ .thenAccept((PublicKeyCredential<AuthenticatorAssertionResponse> result) -> {
+ this.credential = result;
+ }).exceptionally((Throwable e) -> {
+ if (e instanceof WebAuthNUserCancelled) {
+ this.userCancel = true;
+ } else {
+ log.error("webauthn fail", e);
+ }
+ return null;
+ }).thenRun(() -> {
+ btn_authenticate.setEnabled(true);
+ reloadResources();
+ this.getDisplay().wake();
+ });
});
}