diff options
author | Jakob Heher <jakob.heher@iaik.tugraz.at> | 2022-10-10 12:09:40 +0200 |
---|---|---|
committer | Jakob Heher <jakob.heher@iaik.tugraz.at> | 2022-10-10 12:09:40 +0200 |
commit | f18b651e0d22350df45d7ac71bdadf519cc562d6 (patch) | |
tree | 49c3bbbaa8fe8dc91883a561e3e7f774548e9c1e /pdf-over-gui/src | |
parent | e62af8986381d22aeea52c48276611777632da6c (diff) | |
download | pdf-over-f18b651e0d22350df45d7ac71bdadf519cc562d6.tar.gz pdf-over-f18b651e0d22350df45d7ac71bdadf519cc562d6.tar.bz2 pdf-over-f18b651e0d22350df45d7ac71bdadf519cc562d6.zip |
webauthn -> async
Diffstat (limited to 'pdf-over-gui/src')
-rw-r--r-- | pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/ATrustParser.java | 2 | ||||
-rw-r--r-- | pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/mobilebku/MobileBKUFido2Composite.java | 28 |
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(); + }); }); } |