diff options
author | Jakob Heher <jakob.heher@iaik.tugraz.at> | 2022-10-05 13:58:26 +0200 |
---|---|---|
committer | Jakob Heher <jakob.heher@iaik.tugraz.at> | 2022-10-05 13:58:26 +0200 |
commit | f180a7e254d204aaa645ff4fd4e5fff7b1d7c47b (patch) | |
tree | 5b9efa1428db8bd599c981a7a1f0b2d175ed5ef2 /pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile | |
parent | 8d7000e17c41b5a09590202e7ce644c9b86bfe11 (diff) | |
download | pdf-over-f180a7e254d204aaa645ff4fd4e5fff7b1d7c47b.tar.gz pdf-over-f180a7e254d204aaa645ff4fd4e5fff7b1d7c47b.tar.bz2 pdf-over-f180a7e254d204aaa645ff4fd4e5fff7b1d7c47b.zip |
add waiting-for-app support
(starting to rip some old stuff out)
Diffstat (limited to 'pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile')
-rw-r--r-- | pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/ATrustParser.java | 48 |
1 files changed, 33 insertions, 15 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 90afc834..1fb3b8d6 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 @@ -56,6 +56,24 @@ public class ATrustParser { throw new ComponentParseFailed(); } } + protected @Nonnull URI getLongPollURI() throws ComponentParseFailed { + var pollingScriptElm = getElementEnsureNotNull("#jsLongPoll script"); + String pollingScript = pollingScriptElm.data(); + int startIdx = pollingScript.indexOf("qrpoll(\""); + if (startIdx < 0) { log.warn("Failed to find 'qrpoll(\"' in jsLongPoll script:\n{}", pollingScript); throw new ComponentParseFailed(); } + startIdx += 8; + + int endIdx = pollingScript.indexOf("\");", startIdx); + if (endIdx < 0) { log.warn("Failed to find qrpoll terminator '\");' in jsLongPoll script:\n{}", pollingScript); throw new ComponentParseFailed(); } + + String pollingUriString = pollingScript.substring(startIdx, endIdx); + try { + return ISNOTNULL(new URI(pollingScriptElm.baseUri()).resolve(pollingUriString)); + } catch (URISyntaxException e) { + log.warn("Long-poll URI '{}' could not be parsed", pollingUriString); + throw new ComponentParseFailed(); + } + } } public static class ErrorBlock extends TopLevelFormBlock { @@ -126,25 +144,22 @@ public class ATrustParser { this.referenceValue = ISNOTNULL(getElementEnsureNotNull("#vergleichswert").ownText()); this.qrCodeURI = getURIAttributeEnsureNotNull("#qrimage", "abs:src"); + this.pollingURI = getLongPollURI(); - var pollingScriptElm = getElementEnsureNotNull("#jsLongPoll script"); - String pollingScript = pollingScriptElm.data(); - int startIdx = pollingScript.indexOf("qrpoll(\""); - if (startIdx < 0) { log.warn("Failed to find 'qrpoll(\"' in jsLongPoll script:\n{}", pollingScript); throw new ComponentParseFailed(); } - startIdx += 8; + this.errorMessage = null; + } + } - int endIdx = pollingScript.indexOf("\");", startIdx); - if (endIdx < 0) { log.warn("Failed to find qrpoll terminator '\");' in jsLongPoll script:\n{}", pollingScript); throw new ComponentParseFailed(); } + public static class WaitingForAppBlock extends TopLevelFormBlock { + public final @Nonnull String referenceValue; + public final @Nonnull URI pollingURI; - String pollingUriString = pollingScript.substring(startIdx, endIdx); - try { - this.pollingURI = ISNOTNULL(new URI(pollingScriptElm.baseUri()).resolve(pollingUriString)); - } catch (URISyntaxException e) { - log.warn("URI '{}' could not be parsed", pollingUriString); - throw new ComponentParseFailed(); - } + private WaitingForAppBlock(@Nonnull org.jsoup.nodes.Document htmlDocument, @Nonnull Map<String, String> formOptions) throws ComponentParseFailed { + super(htmlDocument, formOptions); + abortIfElementMissing("#smartphoneAnimation"); - this.errorMessage = null; + this.referenceValue = ISNOTNULL(getElementEnsureNotNull("#vergleichswert").ownText()); + this.pollingURI = getLongPollURI(); } } @@ -179,6 +194,7 @@ public class ATrustParser { public final @CheckForNull UsernamePasswordBlock usernamePasswordBlock; public final @CheckForNull SMSTanBlock smsTanBlock; public final @CheckForNull QRCodeBlock qrCodeBlock; + public final @CheckForNull WaitingForAppBlock waitingForAppBlock; public final @CheckForNull Fido2Block fido2Block; private void validate() { @@ -188,6 +204,7 @@ public class ATrustParser { if (usernamePasswordBlock != null) populated.add("usernamePasswordBlock"); if (smsTanBlock != null) populated.add("smsTanBlock"); if (qrCodeBlock != null) populated.add("qrCodeBlock"); + if (waitingForAppBlock != null) populated.add("waitingForAppBlock"); if (fido2Block != null) populated.add("fido2Block"); switch (populated.size()) { @@ -271,6 +288,7 @@ public class ATrustParser { this.usernamePasswordBlock = TryParseMainBlock(UsernamePasswordBlock.class); this.smsTanBlock = TryParseMainBlock(SMSTanBlock.class); this.qrCodeBlock = TryParseMainBlock(QRCodeBlock.class); + this.waitingForAppBlock = TryParseMainBlock(WaitingForAppBlock.class); this.fido2Block = TryParseMainBlock(Fido2Block.class); validate(); |