summaryrefslogtreecommitdiff
path: root/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku
diff options
context:
space:
mode:
authorJakob Heher <jakob.heher@iaik.tugraz.at>2022-10-05 12:27:07 +0200
committerJakob Heher <jakob.heher@iaik.tugraz.at>2022-10-05 12:27:07 +0200
commit8d7000e17c41b5a09590202e7ce644c9b86bfe11 (patch)
tree7bcda2e8af913d9777a7314ed25f1dcd4ce7260b /pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku
parent4269338d2e11028a880c99eb906c93a397fd0c1f (diff)
downloadpdf-over-8d7000e17c41b5a09590202e7ce644c9b86bfe11.tar.gz
pdf-over-8d7000e17c41b5a09590202e7ce644c9b86bfe11.tar.bz2
pdf-over-8d7000e17c41b5a09590202e7ce644c9b86bfe11.zip
smstan support
Diffstat (limited to 'pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku')
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/MobileBKUConnector.java15
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/OLDMobileBKUConnector.java12
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/ATrustParser.java37
3 files changed, 50 insertions, 14 deletions
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/MobileBKUConnector.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/MobileBKUConnector.java
index 1c07376c..dc2258a1 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/MobileBKUConnector.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/MobileBKUConnector.java
@@ -250,7 +250,7 @@ public class MobileBKUConnector implements BkuSlConnector {
if (html.usernamePasswordBlock != null) {
try {
while ((this.credentials.username == null) || (this.credentials.password == null)) {
- this.state.getCredentialsFromUserTo(this.credentials, null); // TODO error message
+ this.state.getCredentialsFromUserTo(this.credentials, html.usernamePasswordBlock.errorMessage);
}
html.usernamePasswordBlock.setUsernamePassword(this.credentials.username, this.credentials.password);
return buildFormSubmit(html, "#Button_Identification");
@@ -258,6 +258,17 @@ public class MobileBKUConnector implements BkuSlConnector {
return buildFormSubmit(html, "#Button_Cancel");
}
}
+ if (html.smsTanBlock != null) {
+ MobileBKUState.SMSTanResult result = this.state.getSMSTanFromUser(
+ html.smsTanBlock.referenceValue, html.smsTanBlock.triesRemaining,
+ html.signatureDataLink, html.fido2Link != null, html.smsTanBlock.errorMessage);
+
+ switch (result.type) {
+ case TO_FIDO2: if (html.fido2Link != null) return new HttpGet(html.fido2Link);
+ case SMSTAN: html.smsTanBlock.setTAN(result.smsTan); return buildFormSubmit(html, "#SignButton");
+ }
+ return new HttpGet(html.htmlDocument.baseUri());
+ }
if (html.qrCodeBlock != null) {
try (final CloseableHttpClient httpClient = HttpClients.custom().disableRedirectHandling().build()) {
final HttpGet request = new HttpGet(html.qrCodeBlock.pollingURI);
@@ -297,7 +308,7 @@ public class MobileBKUConnector implements BkuSlConnector {
});
try {
longPollThread.start();
- MobileBKUState.QRResult result = this.state.showQRCode(html.qrCodeBlock.referenceValue, html.qrCodeBlock.qrCodeURI, html.signatureDataLink, html.smsTanLink != null, html.fido2Link != null, null);
+ MobileBKUState.QRResult result = this.state.showQRCode(html.qrCodeBlock.referenceValue, html.qrCodeBlock.qrCodeURI, html.signatureDataLink, html.smsTanLink != null, html.fido2Link != null, html.qrCodeBlock.errorMessage);
switch (result) {
case UPDATE: break;
case TO_FIDO2: if (html.fido2Link != null) return new HttpGet(html.fido2Link); break;
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/OLDMobileBKUConnector.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/OLDMobileBKUConnector.java
index 9703e602..8c054e95 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/OLDMobileBKUConnector.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/OLDMobileBKUConnector.java
@@ -176,14 +176,14 @@ public class OLDMobileBKUConnector implements BkuSlConnector {
}
if (enterTAN) {
- // Get TAN
- this.state.checkTAN();
+ try {
+ // Get TAN
+ this.state.OLDcheckTAN();
- if ("cancel".equals(this.state.status.errorMessage))
- throw new SignatureException(new IllegalStateException());
+ if ("cancel".equals(this.state.status.errorMessage))
+ throw new SignatureException(new IllegalStateException());
- // Post TAN
- try {
+ // Post TAN
responseData = handler.postTAN();
log.trace("Response from mobile BKU: " + responseData);
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 16f571a3..90afc834 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
@@ -16,6 +16,8 @@ import org.jsoup.Jsoup;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import at.asit.pdfover.gui.bku.OLDmobile.ATrustStatus;
+
import static at.asit.pdfover.commons.Constants.ISNOTNULL;
public class ATrustParser {
@@ -60,9 +62,9 @@ public class ATrustParser {
public final boolean isRecoverable;
public final @Nonnull String errorText;
- private ErrorBlock(@Nonnull org.jsoup.nodes.Document htmlDocument, @Nonnull URI formTarget, @Nonnull Map<String, String> formOptions) throws ComponentParseFailed {
+ private ErrorBlock(@Nonnull org.jsoup.nodes.Document htmlDocument, @Nonnull Map<String, String> formOptions) throws ComponentParseFailed {
super(htmlDocument, formOptions);
- if (!formTarget.getPath().contains("/error.aspx"))
+ if (!htmlDocument.baseUri().contains("/error.aspx"))
throw new ComponentParseFailed();
this.isRecoverable = (htmlDocument.selectFirst("#Button_Back") != null);
@@ -83,7 +85,7 @@ public class ATrustParser {
formOptions.put(usernameKey, username); formOptions.put(passwordKey, password);
}
- private UsernamePasswordBlock(@Nonnull org.jsoup.nodes.Document htmlDocument, @Nonnull URI formTarget, @Nonnull Map<String, String> formOptions) throws ComponentParseFailed {
+ private UsernamePasswordBlock(@Nonnull org.jsoup.nodes.Document htmlDocument, @Nonnull Map<String, String> formOptions) throws ComponentParseFailed {
super(htmlDocument, formOptions);
abortIfElementMissing("#handynummer");
this.usernameKey = getAttributeEnsureNotNull("#handynummer", "name");
@@ -92,13 +94,33 @@ public class ATrustParser {
}
}
+ public static class SMSTanBlock extends TopLevelFormBlock {
+ private final @Nonnull String tanKey;
+ public final @Nonnull String referenceValue;
+ public final int triesRemaining;
+ public final @CheckForNull String errorMessage;
+
+ public void setTAN(String tan) {
+ formOptions.put(tanKey, tan);
+ }
+
+ private SMSTanBlock(@Nonnull org.jsoup.nodes.Document htmlDocument, @Nonnull Map<String, String> formOptions) throws ComponentParseFailed {
+ super(htmlDocument, formOptions);
+ abortIfElementMissing("#div_tan");
+ this.tanKey = getAttributeEnsureNotNull("#input_tan", "name");
+ this.referenceValue = ISNOTNULL(getElementEnsureNotNull("#vergleichswert").ownText());
+ this.triesRemaining = ATrustStatus.MOBILE_MAX_TAN_TRIES; // TODO
+ this.errorMessage = null;
+ }
+ }
+
public static class QRCodeBlock extends TopLevelFormBlock {
public final @Nonnull String referenceValue;
public final @Nonnull URI qrCodeURI;
public final @Nonnull URI pollingURI;
public final @Nullable String errorMessage;
- private QRCodeBlock(@Nonnull org.jsoup.nodes.Document htmlDocument, @Nonnull URI formTarget, @Nonnull Map<String, String> formOptions) throws ComponentParseFailed {
+ private QRCodeBlock(@Nonnull org.jsoup.nodes.Document htmlDocument, @Nonnull Map<String, String> formOptions) throws ComponentParseFailed {
super(htmlDocument, formOptions);
abortIfElementMissing("#qrimage");
@@ -132,7 +154,7 @@ public class ATrustParser {
public void setFIDOResult(String result) { formOptions.put(credentialResultKey, result); }
- private Fido2Block(@Nonnull org.jsoup.nodes.Document htmlDocument, @Nonnull URI formTarget, @Nonnull Map<String, String> formOptions) throws ComponentParseFailed {
+ private Fido2Block(@Nonnull org.jsoup.nodes.Document htmlDocument, @Nonnull Map<String, String> formOptions) throws ComponentParseFailed {
super(htmlDocument, formOptions);
abortIfElementMissing("#fidoBlock");
this.fidoOptions = getAttributeEnsureNotNull("#credentialOptions", "value");
@@ -155,6 +177,7 @@ public class ATrustParser {
/* top-level blocks (exactly one is not null) */
public final @CheckForNull ErrorBlock errorBlock;
public final @CheckForNull UsernamePasswordBlock usernamePasswordBlock;
+ public final @CheckForNull SMSTanBlock smsTanBlock;
public final @CheckForNull QRCodeBlock qrCodeBlock;
public final @CheckForNull Fido2Block fido2Block;
@@ -163,6 +186,7 @@ public class ATrustParser {
if (errorBlock != null) populated.add("errorBlock");
if (usernamePasswordBlock != null) populated.add("usernamePasswordBlock");
+ if (smsTanBlock != null) populated.add("smsTanBlock");
if (qrCodeBlock != null) populated.add("qrCodeBlock");
if (fido2Block != null) populated.add("fido2Block");
@@ -192,7 +216,7 @@ public class ATrustParser {
*/
private <T extends TopLevelFormBlock> @Nullable T TryParseMainBlock(Class<T> clazz) {
try {
- return clazz.getDeclaredConstructor(org.jsoup.nodes.Document.class, URI.class, Map.class).newInstance(this.htmlDocument, this.formTarget, this.formOptions);
+ return clazz.getDeclaredConstructor(org.jsoup.nodes.Document.class, Map.class).newInstance(this.htmlDocument, this.formOptions);
} catch (NoSuchMethodException | InstantiationException | IllegalAccessException | IllegalArgumentException | SecurityException e) {
log.error("Internal parser error; check your method signatures?", e);
return null;
@@ -245,6 +269,7 @@ public class ATrustParser {
this.errorBlock = TryParseMainBlock(ErrorBlock.class);
this.usernamePasswordBlock = TryParseMainBlock(UsernamePasswordBlock.class);
+ this.smsTanBlock = TryParseMainBlock(SMSTanBlock.class);
this.qrCodeBlock = TryParseMainBlock(QRCodeBlock.class);
this.fido2Block = TryParseMainBlock(Fido2Block.class);