summaryrefslogtreecommitdiff
path: root/pdf-over-gui/src
diff options
context:
space:
mode:
Diffstat (limited to 'pdf-over-gui/src')
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/MobileBKUConnector.java138
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/OLDMobileBKUConnector.java11
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/OLDmobile/ATrustHandler.java6
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/ATrustParser.java48
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/WaitingForAppComposite.java192
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/AboutComposite.java5
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/mobilebku/MobileBKUEnterNumberComposite.java (renamed from pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/MobileBKUEnterNumberComposite.java)578
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/mobilebku/MobileBKUEnterTANComposite.java (renamed from pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/MobileBKUEnterTANComposite.java)699
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/mobilebku/MobileBKUFingerprintComposite.java (renamed from pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/MobileBKUFingerprintComposite.java)588
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/mobilebku/MobileBKUQRComposite.java (renamed from pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/MobileBKUQRComposite.java)504
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/mobilebku/WaitingForAppComposite.java121
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/MobileBKUState.java187
-rw-r--r--pdf-over-gui/src/main/resources/logback.xml1
13 files changed, 1483 insertions, 1595 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 dc2258a1..1748f631 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
@@ -13,18 +13,14 @@ import java.util.regex.Pattern;
import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
-import javax.swing.text.html.HTML.Tag;
import org.apache.hc.client5.http.classic.methods.HttpGet;
import org.apache.hc.client5.http.classic.methods.HttpPost;
-import org.apache.hc.client5.http.config.RequestConfig;
import org.apache.hc.client5.http.entity.UrlEncodedFormEntity;
import org.apache.hc.client5.http.entity.mime.MultipartEntityBuilder;
import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse;
import org.apache.hc.client5.http.impl.classic.HttpClients;
-import org.apache.hc.client5.http.impl.classic.RequestFailedException;
import org.apache.hc.core5.http.ClassicHttpRequest;
import org.apache.hc.core5.http.ContentType;
import org.apache.hc.core5.http.Header;
@@ -228,6 +224,67 @@ public class MobileBKUConnector implements BkuSlConnector {
return post;
}
+ private static class LongPollThread extends Thread implements AutoCloseable {
+
+ private final CloseableHttpClient httpClient = HttpClients.createDefault();
+ private final HttpGet request;
+ private final Runnable signal;
+ private boolean done = false;
+
+ @Override
+ public void run() {
+ long timeout = System.nanoTime() + (300l * 1000l * 1000l * 1000l); /* a-trust timeout is 5 minutes */
+ log.debug("longPollThread hello");
+ while (!done) {
+ try (final CloseableHttpResponse response = httpClient.execute(request)) {
+ JSONObject jsonResponse = new JSONObject(EntityUtils.toString(response.getEntity()));
+ if (jsonResponse.getBoolean("Fin"))
+ signal.run();
+ else if (jsonResponse.getBoolean("Wait"))
+ {
+ log.debug("longPollThread continue...");
+ continue;
+ }
+ else if (jsonResponse.getBoolean("Error"))
+ signal.run(); /* will trigger reload and find error; this is the same thing a-trust does */
+ else {
+ log.warn("Unknown long poll response:\n{}", jsonResponse.toString(2));
+ break;
+ }
+ } catch (NoHttpResponseException e) {
+ if (timeout <= System.nanoTime())
+ signal.run(); /* reload to find the timeout error */
+ continue; /* httpclient timeout */
+ } catch (IOException | ParseException | IllegalStateException e) {
+ if (done) break;
+ log.warn("QR code long polling exception", e);
+ /* sleep so we don't hammer a-trust too hard in case this goes wrong */
+ try { Thread.sleep(5000); } catch (InterruptedException e2) {}
+ }
+ }
+ log.debug("longPollThread goodbye");
+ }
+
+ public LongPollThread(URI uri, Runnable signal) {
+ this.request = new HttpGet(uri);
+ this.signal = signal;
+ }
+
+ @Override
+ public void close() {
+ done = true;
+ if (this.request != null)
+ this.request.abort();
+
+ if (this.isAlive())
+ try { this.join(1000); } catch (InterruptedException e) {}
+
+ if (this.httpClient != null)
+ try { this.httpClient.close(); } catch (IOException e) { log.warn("Auto-close of long-poll HTTP client threw exception", e); }
+ }
+
+ }
+
/**
* Main lifting function for MobileBKU UX
* @return the next request to make, or null if the current response should be returned
@@ -270,58 +327,29 @@ public class MobileBKUConnector implements BkuSlConnector {
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);
- boolean[] done = new boolean[1];
- done[0] = false;
- Thread longPollThread = new Thread(() -> {
- long timeout = System.nanoTime() + (300l * 1000l * 1000l * 1000l); /* a-trust timeout is 5 minutes */
- log.debug("longPollThread hello");
- while (!done[0]) {
- try (final CloseableHttpResponse response = httpClient.execute(request)) {
- JSONObject jsonResponse = new JSONObject(EntityUtils.toString(response.getEntity()));
- if (jsonResponse.getBoolean("Fin"))
- state.signalQRScanned();
- else if (jsonResponse.getBoolean("Wait"))
- {
- log.debug("longPollThread continue...");
- continue;
- }
- else if (jsonResponse.getBoolean("Error"))
- state.signalQRScanned(); /* will trigger reload and find error; this is the same thing a-trust does */
- else {
- log.warn("Unknown long poll response:\n{}", jsonResponse.toString(2));
- break;
- }
- } catch (NoHttpResponseException e) {
- if (timeout <= System.nanoTime())
- state.signalQRScanned(); /* reload to find the timeout error */
- continue; /* httpclient timeout */
- } catch (IOException | ParseException | IllegalStateException e) {
- if (done[0]) break;
- log.warn("QR code long polling exception", e);
- /* sleep so we don't hammer a-trust too hard in case this goes wrong */
- try { Thread.sleep(5000); } catch (InterruptedException e2) {}
- }
- }
- log.debug("longPollThread goodbye");
- });
- try {
- longPollThread.start();
- 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;
- case TO_SMS: if (html.smsTanLink != null) return new HttpGet(html.smsTanLink); break;
- }
- return new HttpGet(html.htmlDocument.baseUri());
- } finally {
- done[0] = true;
- request.abort();
- try { longPollThread.join(1000); } catch (InterruptedException e) {}
+ try (LongPollThread longPollThread = new LongPollThread(html.qrCodeBlock.pollingURI, () -> { this.state.signalQRScanned(); })) {
+ this.state.showQRCode(html.qrCodeBlock.referenceValue, html.qrCodeBlock.qrCodeURI, html.signatureDataLink, html.smsTanLink != null, html.fido2Link != null, html.qrCodeBlock.errorMessage);
+ longPollThread.start();
+ var result = this.state.waitForQRCodeResult();
+ switch (result) {
+ case UPDATE: break;
+ case TO_FIDO2: if (html.fido2Link != null) return new HttpGet(html.fido2Link); break;
+ case TO_SMS: if (html.smsTanLink != null) return new HttpGet(html.smsTanLink); break;
+ }
+ return new HttpGet(html.htmlDocument.baseUri());
+ }
+ }
+ if (html.waitingForAppBlock != null) {
+ try (LongPollThread longPollThread = new LongPollThread(html.waitingForAppBlock.pollingURI, () -> { this.state.signalAppOpened(); })) {
+ this.state.showWaitingForApp(html.waitingForAppBlock.referenceValue, html.signatureDataLink, html.smsTanLink != null, html.fido2Link != null);
+ longPollThread.start();
+ var result = this.state.waitForAppOpen();
+ switch (result) {
+ case UPDATE: break;
+ case TO_FIDO2: if (html.fido2Link != null) return new HttpGet(html.fido2Link); break;
+ case TO_SMS: if (html.smsTanLink != null) return new HttpGet(html.smsTanLink); break;
}
- } catch (IOException e) {
- log.warn("closing long-polling HttpClient threw exception", e);
+ return new HttpGet(html.htmlDocument.baseUri());
}
}
if (html.fido2Block != null) {
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 8c054e95..c9ab164b 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
@@ -15,9 +15,6 @@
*/
package at.asit.pdfover.gui.bku;
-import java.io.IOException;
-import java.net.URISyntaxException;
-
// Imports
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -90,7 +87,7 @@ public class OLDMobileBKUConnector implements BkuSlConnector {
if (responseData.contains("undecided.aspx?sid=")) {
// handle polling
- this.state.showOpenAppMessageWithSMSandCancel();
+ //this.state.showOpenAppMessageWithSMSandCancel();
if (this.state.status.isSMSTan) {
String response = handler.postSMSRequest();
@@ -124,11 +121,11 @@ public class OLDMobileBKUConnector implements BkuSlConnector {
boolean enterTAN = true;
String responseData = null;
if (status.qrCodeURL != null) {
- try {
+ /*try {
this.state.OLDshowQR();
} catch (IOException | URISyntaxException e) {
throw new SignatureException(e);
- }
+ }*/
if ("cancel".equals(this.state.status.errorMessage))
throw new SignatureException(new IllegalStateException());
if (status.qrCodeURL == null) {
@@ -178,7 +175,7 @@ public class OLDMobileBKUConnector implements BkuSlConnector {
if (enterTAN) {
try {
// Get TAN
- this.state.OLDcheckTAN();
+ //this.state.OLDcheckTAN();
if ("cancel".equals(this.state.status.errorMessage))
throw new SignatureException(new IllegalStateException());
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/OLDmobile/ATrustHandler.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/OLDmobile/ATrustHandler.java
index ab85645b..e22db900 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/OLDmobile/ATrustHandler.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/OLDmobile/ATrustHandler.java
@@ -16,12 +16,10 @@
package at.asit.pdfover.gui.bku.OLDmobile;
// Imports
-import java.awt.Desktop;
import java.io.BufferedInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
-import java.net.URI;
import java.net.URL;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -38,12 +36,8 @@ import org.apache.commons.httpclient.methods.multipart.Part;
import org.apache.commons.httpclient.methods.multipart.StringPart;
import org.apache.commons.io.IOUtils;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.program.Program;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
-import org.jsoup.Jsoup;
-import org.jsoup.nodes.Document;
-import org.jsoup.nodes.Element;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
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();
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/WaitingForAppComposite.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/WaitingForAppComposite.java
deleted file mode 100644
index ecdece98..00000000
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/WaitingForAppComposite.java
+++ /dev/null
@@ -1,192 +0,0 @@
-/*
- * Copyright 2012 by A-SIT, Secure Information Technology Center Austria
- *
- * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
- * the European Commission - subsequent versions of the EUPL (the "Licence");
- * You may not use this work except in compliance with the Licence.
- * You may obtain a copy of the Licence at:
- * http://joinup.ec.europa.eu/software/page/eupl
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the Licence is distributed on an "AS IS" basis,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the Licence for the specific language governing permissions and
- * limitations under the Licence.
- */
-package at.asit.pdfover.gui.composites;
-
-
-// Imports
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.FormAttachment;
-import org.eclipse.swt.layout.FormData;
-import org.eclipse.swt.layout.FormLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.ProgressBar;
-import at.asit.pdfover.gui.utils.SWTUtils;
-import at.asit.pdfover.gui.workflow.states.State;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-
-/**
- *
- */
-public class WaitingForAppComposite extends StateComposite {
- private Label lbl_description;
- private Button btn_sms;
- private Button btn_cancel;
- private Boolean isUserSMS = false;
- private Boolean userCancel = false;
- private Boolean isDone = false;
-
- /**
- * @return the isDone
- */
- public Boolean getIsDone() {
- return this.isDone;
- }
-
- /**
- * @param isDone the isDone to set
- */
- public void setIsDone(Boolean isDone) {
- this.isDone = isDone;
- }
-
- /**
- * Create the composite.
- * @param parent
- * @param style
- * @param state
- */
- public WaitingForAppComposite(Composite parent, int style, State state) {
- super(parent, style, state);
- setLayout(new FormLayout());
-
- this.lbl_description = new Label(this, SWT.NATIVE);
- FormData fd_lbl_description = new FormData();
- fd_lbl_description.bottom = new FormAttachment(50, -10);
- fd_lbl_description.left = new FormAttachment(0, +10);
- fd_lbl_description.right = new FormAttachment(100, -10);
- this.lbl_description.setLayoutData(fd_lbl_description);
- this.lbl_description.setAlignment(SWT.CENTER);
- SWTUtils.setLocalizedText(lbl_description, "waiting_for_app.message");
-
- ProgressBar progressBar = new ProgressBar(this, SWT.HORIZONTAL | SWT.INDETERMINATE);
- FormData fd_progressBar = new FormData();
- fd_progressBar.top = new FormAttachment(50, +10);
- fd_progressBar.bottom = new FormAttachment(50, +40);
- fd_progressBar.left = new FormAttachment(50, -100);
- fd_progressBar.right = new FormAttachment(50, +100);
- progressBar.setLayoutData(fd_progressBar);
-
- this.btn_sms = new Button(this, SWT.NONE);
- this.btn_sms.addSelectionListener(new SMSSelectionListener());
-
- FormData fd_btnSMS = new FormData();
- fd_btnSMS.top = new FormAttachment(progressBar, 24);
- fd_btnSMS.right = new FormAttachment(progressBar, 0, SWT.RIGHT);
- this.btn_sms.setLayoutData(fd_btnSMS);
- SWTUtils.setLocalizedText(btn_sms, "SMS tan");
-
- this.btn_cancel = new Button(this, SWT.NONE);
- this.btn_cancel.addSelectionListener(new CancelSelectionListener());
- FormData fd_btnCancel = new FormData();
- fd_btnCancel.top = new FormAttachment(btn_sms, 0, SWT.TOP);
- fd_btnCancel.right = new FormAttachment(btn_sms, -6);
- this.btn_cancel.setLayoutData(fd_btnCancel);
- SWTUtils.setLocalizedText(btn_cancel, "WaitingForAppComposite.btnCancel.text");
-
- reloadResources();
-
- }
-
- /**
- *
- */
- private final class CancelSelectionListener extends SelectionAdapter {
- /**
- * Empty constructor
- */
- public CancelSelectionListener() {
- }
-
- @Override
- public void widgetSelected(SelectionEvent e) {
- WaitingForAppComposite.this.setUserCancel(true);
- WaitingForAppComposite.this.btn_cancel.setEnabled(false);
- WaitingForAppComposite.this.btn_sms.setEnabled(false);
- }
- }
-
- private final class SMSSelectionListener extends SelectionAdapter {
- /**
- * Empty constructor
- */
- public SMSSelectionListener() {
- }
-
- @Override
- public void widgetSelected(SelectionEvent e) {
- if(!WaitingForAppComposite.this.btn_sms.getEnabled()) {
- return;
- }
-
- WaitingForAppComposite.this.setUserSMS(true);
- WaitingForAppComposite.this.btn_sms.setEnabled(false);
- WaitingForAppComposite.this.btn_cancel.setEnabled(false);
- }
- }
-
- public void setUserSMS(boolean b) {
- this.isUserSMS = b;
- }
-
- @Override
- protected void checkSubclass() {
- // Disable the check that prevents subclassing of SWT components
- }
-
- /* (non-Javadoc)
- * @see at.asit.pdfover.gui.composites.StateComposite#doLayout()
- */
- @Override
- public void doLayout() {
- // Nothing to do here
- }
-
- /* (non-Javadoc)
- * @see at.asit.pdfover.gui.composites.StateComposite#reloadResources()
- */
- @Override
- public void reloadResources() {
- SWTUtils.setLocalizedText(lbl_description, "waiting_for_app.message");
- SWTUtils.setLocalizedText(btn_sms, "tanEnter.SMS");
- SWTUtils.setLocalizedText(btn_cancel, "common.Cancel");
- SWTUtils.setLocalizedText(btn_sms, "tanEnter.SMS");
- }
-
- /**
- * @return
- */
- public boolean getUserCancel() {
- return this.userCancel;
- }
-
- /**
- * @param b
- */
- public void setUserCancel(boolean b) {
- this.userCancel = b;
-
- }
-
- /**
- * @return
- */
- public boolean getUserSMS() {
- return this.isUserSMS;
- }
-}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/AboutComposite.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/AboutComposite.java
index b4675e2a..07b62421 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/AboutComposite.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/AboutComposite.java
@@ -2,13 +2,8 @@ package at.asit.pdfover.gui.composites.configuration;
import java.awt.Desktop;
import java.io.File;
-import java.io.IOException;
-import java.net.URI;
-import java.net.URISyntaxException;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.program.Program;
import org.eclipse.swt.widgets.Button;
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/MobileBKUEnterNumberComposite.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/mobilebku/MobileBKUEnterNumberComposite.java
index 6c75b160..575c2ad7 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/MobileBKUEnterNumberComposite.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/mobilebku/MobileBKUEnterNumberComposite.java
@@ -1,289 +1,289 @@
-/*
- * Copyright 2012 by A-SIT, Secure Information Technology Center Austria
- *
- * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
- * the European Commission - subsequent versions of the EUPL (the "Licence");
- * You may not use this work except in compliance with the Licence.
- * You may obtain a copy of the Licence at:
- * http://joinup.ec.europa.eu/software/page/eupl
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the Licence is distributed on an "AS IS" basis,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the Licence for the specific language governing permissions and
- * limitations under the Licence.
- */
-package at.asit.pdfover.gui.composites;
-
-// Imports
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.ImageData;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.layout.FormLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Text;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import at.asit.pdfover.commons.Constants;
-import at.asit.pdfover.gui.bku.OLDmobile.MobileBKUHelper;
-import at.asit.pdfover.gui.exceptions.InvalidPasswordException;
-import at.asit.pdfover.gui.utils.SWTUtils;
-import at.asit.pdfover.commons.Messages;
-import at.asit.pdfover.gui.workflow.states.State;
-
-/**
- * Composite for entering the phone number for the mobile BKU
- */
-public class MobileBKUEnterNumberComposite extends StateComposite {
- /**
- * SLF4J Logger instance
- **/
- static final Logger log = LoggerFactory.getLogger(MobileBKUEnterNumberComposite.class);
-
- /**
- *
- */
- private final SelectionListener okListener = new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- if (!MobileBKUEnterNumberComposite.this.btn_ok.isEnabled()) {
- return;
- }
-
- try {
- String number = MobileBKUEnterNumberComposite.this.txt_number.getText();
-
- MobileBKUEnterNumberComposite.this.setMobileNumber(number);
-
- String password = MobileBKUEnterNumberComposite.this.txt_password.getText();
-
- MobileBKUHelper.validatePassword(password);
-
- MobileBKUEnterNumberComposite.this.mobilePassword = password;
- MobileBKUEnterNumberComposite.this.userAck = true;
-
- MobileBKUEnterNumberComposite.this.btn_ok.setEnabled(false);
-
- } catch(InvalidPasswordException ex) {
- log.info("Validating input for Mobile BKU failed!", ex);
- MobileBKUEnterNumberComposite.this.setErrorMessage(ex.getMessage());
- MobileBKUEnterNumberComposite.this.txt_password.setFocus();
- } catch (Exception ex) {
- log.info("Validating input for Mobile BKU failed!", ex);
- MobileBKUEnterNumberComposite.this.setErrorMessage(Messages.getString("error.InvalidPhoneNumber"));
- MobileBKUEnterNumberComposite.this.txt_number.setFocus();
- return;
- }
- }
- };
-
- /**
- *
- */
- private final SelectionListener cancelListener = new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- MobileBKUEnterNumberComposite.this.userCancel = true;
- }
- };
-
-
- String mobileNumber;
-
- String mobilePassword;
-
- Text txt_number;
-
- Text txt_password;
-
- String errorMessage = null;
-
- public boolean userAck = false;
- public boolean userCancel = false;
-
-
- private Label lbl_error;
- private Label lbl_password;
- private Label lbl_number;
-
- Button btn_ok;
- Button btn_cancel;
- Button btn_remember;
-
- /**
- * @return the errorMessage
- */
- public String getErrorMessage() {
- return this.errorMessage;
- }
-
- /**
- * @param errorMessage
- * the errorMessage to set
- */
- public void setErrorMessage(String errorMessage) {
- this.errorMessage = errorMessage;
-
- if (this.errorMessage != null) {
- this.lbl_error.setText(this.errorMessage);
- } else {
- this.lbl_error.setText("");
- }
- }
-
- public boolean isRememberPassword() { return this.btn_remember.getSelection(); }
- public void setRememberPassword(boolean state) { this.btn_remember.setSelection(state); }
-
- /**
- * Create the composite.
- *
- * @param parent
- * @param style
- * @param state
- */
- public MobileBKUEnterNumberComposite(Composite parent, int style, State state) {
- super(parent, style, state);
- setLayout(new FormLayout());
-
- final Composite containerComposite = new Composite(this, SWT.NATIVE);
- containerComposite.addPaintListener(e -> {
- Rectangle clientArea = containerComposite.getClientArea();
-
- //e.gc.setForeground();
- e.gc.setForeground(Constants.MAINBAR_ACTIVE_BACK_DARK);
- e.gc.setLineWidth(3);
- e.gc.setLineStyle(SWT.LINE_SOLID);
- e.gc.drawRoundRectangle(clientArea.x,
- clientArea.y, clientArea.width - 2, clientArea.height - 2,
- 10, 10);
- });
- containerComposite.setLayout(new FormLayout());
- SWTUtils.anchor(containerComposite).top(50, -120).bottom(50, 120).left(50, -200).right(50, 200);
-
- this.txt_number = new Text(containerComposite, SWT.SINGLE | SWT.NATIVE | SWT.BORDER);
- SWTUtils.anchor(txt_number).bottom(50, -10).left(50, 10).right(100, -20);
- this.txt_number.setEditable(true);
-
- this.lbl_number = new Label(containerComposite, SWT.NATIVE);
- this.lbl_number.setAlignment(SWT.RIGHT);
- SWTUtils.anchor(lbl_number).bottom(50, -10).right(50, -10);
-
- ImageData mobileIconData = new ImageData(this.getClass().getResourceAsStream(Constants.RES_IMG_MOBILE));
- Image mobileIcon = new Image(getDisplay(), mobileIconData);
-
- Label lbl_image = new Label(containerComposite, SWT.NATIVE);
- SWTUtils.anchor(lbl_image).top(20, -1 * (mobileIconData.width / 2)).bottom(20, mobileIconData.width / 2).left(0, 10).width(mobileIconData.width);
- lbl_image.setImage(mobileIcon);
-
- this.txt_password = new Text(containerComposite, SWT.SINGLE | SWT.PASSWORD | SWT.BORDER | SWT.NATIVE);
- SWTUtils.anchor(txt_password).top(50, 10).left(50, 10).right(100, -20);
- this.txt_password.setEditable(true);
-
- this.lbl_password = new Label(containerComposite, SWT.NATIVE);
- SWTUtils.anchor(lbl_password).top(50, 10).right(50, -10);
- this.lbl_password.setAlignment(SWT.RIGHT);
-
- this.btn_ok = new Button(containerComposite, SWT.NATIVE);
- SWTUtils.anchor(btn_ok).bottom(100, -20).right(100, -20);
- this.btn_ok.addSelectionListener(this.okListener);
-
- this.btn_cancel = new Button(containerComposite, SWT.NATIVE);
- SWTUtils.anchor(btn_cancel).bottom(100, -20).right(btn_ok, -10);
- this.btn_cancel.addSelectionListener(this.cancelListener);
-
- this.lbl_error = new Label(containerComposite, SWT.WRAP | SWT.NATIVE );
- SWTUtils.anchor(lbl_error).bottom(103, -20).left(5, 0).right(btn_cancel, -10);
-
- this.btn_remember = new Button(containerComposite, SWT.CHECK);
- SWTUtils.anchor(btn_remember).right(100, -10).top(0, 5);
- }
-
- @Override
- protected void checkSubclass() {
- // Disable the check that prevents subclassing of SWT components
- }
-
- /**
- * enables submit button
- */
- public void enableButton() {
- this.btn_ok.setEnabled(true);
- }
-
- /**
- * (non-Javadoc)
- *
- * @see at.asit.pdfover.gui.composites.StateComposite#doLayout()
- */
- @Override
- public void doLayout() {
- getShell().setDefaultButton(this.btn_ok);
- }
-
- /**
- * @return the mobileNumber
- */
- public String getMobileNumber() {
- return this.mobileNumber;
- }
-
- /**
- * @param mobileNumber
- * the mobileNumber to set
- */
- public void setMobileNumber(String mobileNumber) {
- this.mobileNumber = mobileNumber;
-
- if (this.mobileNumber != null && !this.mobileNumber.isEmpty()) {
- this.txt_number.setText(this.mobileNumber);
- this.txt_password.setFocus();
- } else {
- this.txt_number.setText("");
- }
- }
-
- /**
- * @return the mobilePassword
- */
- public String getMobilePassword() {
- return this.mobilePassword;
- }
-
-
-
- /**
- * @param mobilePassword
- * the mobilePassword to set
- */
- public void setMobilePassword(String mobilePassword) {
- this.mobilePassword = mobilePassword;
-
- if (this.mobilePassword != null) {
- this.txt_password.setText(this.mobilePassword);
- } else {
- this.txt_password.setText("");
- }
- }
-
- /** (non-Javadoc)
- * @see at.asit.pdfover.gui.composites.StateComposite#reloadResources()
- */
- @Override
- public void reloadResources() {
- SWTUtils.setLocalizedText(lbl_number, "mobileBKU.number");
- SWTUtils.setLocalizedText(lbl_password, "mobileBKU.password");
- SWTUtils.setLocalizedText(btn_remember, "mobileBKU.rememberPassword");
- SWTUtils.setLocalizedText(btn_ok, "common.Ok");
- SWTUtils.setLocalizedText(btn_cancel, "common.Cancel");
-
- SWTUtils.setLocalizedToolTipText(btn_remember, "mobileBKU.rememberPasswordNote");
- }
-
-}
+/*
+ * Copyright 2012 by A-SIT, Secure Information Technology Center Austria
+ *
+ * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
+ * the European Commission - subsequent versions of the EUPL (the "Licence");
+ * You may not use this work except in compliance with the Licence.
+ * You may obtain a copy of the Licence at:
+ * http://joinup.ec.europa.eu/software/page/eupl
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the Licence is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the Licence for the specific language governing permissions and
+ * limitations under the Licence.
+ */
+package at.asit.pdfover.gui.composites;
+
+// Imports
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.ImageData;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.layout.FormLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import at.asit.pdfover.commons.Constants;
+import at.asit.pdfover.gui.bku.OLDmobile.MobileBKUHelper;
+import at.asit.pdfover.gui.exceptions.InvalidPasswordException;
+import at.asit.pdfover.gui.utils.SWTUtils;
+import at.asit.pdfover.commons.Messages;
+import at.asit.pdfover.gui.workflow.states.State;
+
+/**
+ * Composite for entering the phone number for the mobile BKU
+ */
+public class MobileBKUEnterNumberComposite extends StateComposite {
+ /**
+ * SLF4J Logger instance
+ **/
+ static final Logger log = LoggerFactory.getLogger(MobileBKUEnterNumberComposite.class);
+
+ /**
+ *
+ */
+ private final SelectionListener okListener = new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ if (!MobileBKUEnterNumberComposite.this.btn_ok.isEnabled()) {
+ return;
+ }
+
+ try {
+ String number = MobileBKUEnterNumberComposite.this.txt_number.getText();
+
+ MobileBKUEnterNumberComposite.this.setMobileNumber(number);
+
+ String password = MobileBKUEnterNumberComposite.this.txt_password.getText();
+
+ MobileBKUHelper.validatePassword(password);
+
+ MobileBKUEnterNumberComposite.this.mobilePassword = password;
+ MobileBKUEnterNumberComposite.this.userAck = true;
+
+ MobileBKUEnterNumberComposite.this.btn_ok.setEnabled(false);
+
+ } catch(InvalidPasswordException ex) {
+ log.info("Validating input for Mobile BKU failed!", ex);
+ MobileBKUEnterNumberComposite.this.setErrorMessage(ex.getMessage());
+ MobileBKUEnterNumberComposite.this.txt_password.setFocus();
+ } catch (Exception ex) {
+ log.info("Validating input for Mobile BKU failed!", ex);
+ MobileBKUEnterNumberComposite.this.setErrorMessage(Messages.getString("error.InvalidPhoneNumber"));
+ MobileBKUEnterNumberComposite.this.txt_number.setFocus();
+ return;
+ }
+ }
+ };
+
+ /**
+ *
+ */
+ private final SelectionListener cancelListener = new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ MobileBKUEnterNumberComposite.this.userCancel = true;
+ }
+ };
+
+
+ String mobileNumber;
+
+ String mobilePassword;
+
+ Text txt_number;
+
+ Text txt_password;
+
+ String errorMessage = null;
+
+ public boolean userAck = false;
+ public boolean userCancel = false;
+
+
+ private Label lbl_error;
+ private Label lbl_password;
+ private Label lbl_number;
+
+ Button btn_ok;
+ Button btn_cancel;
+ Button btn_remember;
+
+ /**
+ * @return the errorMessage
+ */
+ public String getErrorMessage() {
+ return this.errorMessage;
+ }
+
+ /**
+ * @param errorMessage
+ * the errorMessage to set
+ */
+ public void setErrorMessage(String errorMessage) {
+ this.errorMessage = errorMessage;
+
+ if (this.errorMessage != null) {
+ this.lbl_error.setText(this.errorMessage);
+ } else {
+ this.lbl_error.setText("");
+ }
+ }
+
+ public boolean isRememberPassword() { return this.btn_remember.getSelection(); }
+ public void setRememberPassword(boolean state) { this.btn_remember.setSelection(state); }
+
+ /**
+ * Create the composite.
+ *
+ * @param parent
+ * @param style
+ * @param state
+ */
+ public MobileBKUEnterNumberComposite(Composite parent, int style, State state) {
+ super(parent, style, state);
+ setLayout(new FormLayout());
+
+ final Composite containerComposite = new Composite(this, SWT.NATIVE);
+ containerComposite.addPaintListener(e -> {
+ Rectangle clientArea = containerComposite.getClientArea();
+
+ //e.gc.setForeground();
+ e.gc.setForeground(Constants.MAINBAR_ACTIVE_BACK_DARK);
+ e.gc.setLineWidth(3);
+ e.gc.setLineStyle(SWT.LINE_SOLID);
+ e.gc.drawRoundRectangle(clientArea.x,
+ clientArea.y, clientArea.width - 2, clientArea.height - 2,
+ 10, 10);
+ });
+ containerComposite.setLayout(new FormLayout());
+ SWTUtils.anchor(containerComposite).top(50, -120).bottom(50, 120).left(50, -200).right(50, 200);
+
+ this.txt_number = new Text(containerComposite, SWT.SINGLE | SWT.NATIVE | SWT.BORDER);
+ SWTUtils.anchor(txt_number).bottom(50, -10).left(50, 10).right(100, -20);
+ this.txt_number.setEditable(true);
+
+ this.lbl_number = new Label(containerComposite, SWT.NATIVE);
+ this.lbl_number.setAlignment(SWT.RIGHT);
+ SWTUtils.anchor(lbl_number).bottom(50, -10).right(50, -10);
+
+ ImageData mobileIconData = new ImageData(this.getClass().getResourceAsStream(Constants.RES_IMG_MOBILE));
+ Image mobileIcon = new Image(getDisplay(), mobileIconData);
+
+ Label lbl_image = new Label(containerComposite, SWT.NATIVE);
+ SWTUtils.anchor(lbl_image).top(20, -1 * (mobileIconData.width / 2)).bottom(20, mobileIconData.width / 2).left(0, 10).width(mobileIconData.width);
+ lbl_image.setImage(mobileIcon);
+
+ this.txt_password = new Text(containerComposite, SWT.SINGLE | SWT.PASSWORD | SWT.BORDER | SWT.NATIVE);
+ SWTUtils.anchor(txt_password).top(50, 10).left(50, 10).right(100, -20);
+ this.txt_password.setEditable(true);
+
+ this.lbl_password = new Label(containerComposite, SWT.NATIVE);
+ SWTUtils.anchor(lbl_password).top(50, 10).right(50, -10);
+ this.lbl_password.setAlignment(SWT.RIGHT);
+
+ this.btn_ok = new Button(containerComposite, SWT.NATIVE);
+ SWTUtils.anchor(btn_ok).bottom(100, -20).right(100, -20);
+ this.btn_ok.addSelectionListener(this.okListener);
+
+ this.btn_cancel = new Button(containerComposite, SWT.NATIVE);
+ SWTUtils.anchor(btn_cancel).bottom(100, -20).right(btn_ok, -10);
+ this.btn_cancel.addSelectionListener(this.cancelListener);
+
+ this.lbl_error = new Label(containerComposite, SWT.WRAP | SWT.NATIVE );
+ SWTUtils.anchor(lbl_error).bottom(103, -20).left(5, 0).right(btn_cancel, -10);
+
+ this.btn_remember = new Button(containerComposite, SWT.CHECK);
+ SWTUtils.anchor(btn_remember).right(100, -10).top(0, 5);
+ }
+
+ @Override
+ protected void checkSubclass() {
+ // Disable the check that prevents subclassing of SWT components
+ }
+
+ /**
+ * enables submit button
+ */
+ public void enableButton() {
+ this.btn_ok.setEnabled(true);
+ }
+
+ /**
+ * (non-Javadoc)
+ *
+ * @see at.asit.pdfover.gui.composites.StateComposite#doLayout()
+ */
+ @Override
+ public void doLayout() {
+ getShell().setDefaultButton(this.btn_ok);
+ }
+
+ /**
+ * @return the mobileNumber
+ */
+ public String getMobileNumber() {
+ return this.mobileNumber;
+ }
+
+ /**
+ * @param mobileNumber
+ * the mobileNumber to set
+ */
+ public void setMobileNumber(String mobileNumber) {
+ this.mobileNumber = mobileNumber;
+
+ if (this.mobileNumber != null && !this.mobileNumber.isEmpty()) {
+ this.txt_number.setText(this.mobileNumber);
+ this.txt_password.setFocus();
+ } else {
+ this.txt_number.setText("");
+ }
+ }
+
+ /**
+ * @return the mobilePassword
+ */
+ public String getMobilePassword() {
+ return this.mobilePassword;
+ }
+
+
+
+ /**
+ * @param mobilePassword
+ * the mobilePassword to set
+ */
+ public void setMobilePassword(String mobilePassword) {
+ this.mobilePassword = mobilePassword;
+
+ if (this.mobilePassword != null) {
+ this.txt_password.setText(this.mobilePassword);
+ } else {
+ this.txt_password.setText("");
+ }
+ }
+
+ /** (non-Javadoc)
+ * @see at.asit.pdfover.gui.composites.StateComposite#reloadResources()
+ */
+ @Override
+ public void reloadResources() {
+ SWTUtils.setLocalizedText(lbl_number, "mobileBKU.number");
+ SWTUtils.setLocalizedText(lbl_password, "mobileBKU.password");
+ SWTUtils.setLocalizedText(btn_remember, "mobileBKU.rememberPassword");
+ SWTUtils.setLocalizedText(btn_ok, "common.Ok");
+ SWTUtils.setLocalizedText(btn_cancel, "common.Cancel");
+
+ SWTUtils.setLocalizedToolTipText(btn_remember, "mobileBKU.rememberPasswordNote");
+ }
+
+}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/MobileBKUEnterTANComposite.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/mobilebku/MobileBKUEnterTANComposite.java
index 6b52709e..83913c74 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/MobileBKUEnterTANComposite.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/mobilebku/MobileBKUEnterTANComposite.java
@@ -1,350 +1,349 @@
-/*
- * Copyright 2012 by A-SIT, Secure Information Technology Center Austria
- *
- * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
- * the European Commission - subsequent versions of the EUPL (the "Licence");
- * You may not use this work except in compliance with the Licence.
- * You may obtain a copy of the Licence at:
- * http://joinup.ec.europa.eu/software/page/eupl
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the Licence is distributed on an "AS IS" basis,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the Licence for the specific language governing permissions and
- * limitations under the Licence.
- */
-package at.asit.pdfover.gui.composites;
-
-// Imports
-import java.awt.Desktop;
-import java.net.URI;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.PaintEvent;
-import org.eclipse.swt.events.PaintListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.TraverseEvent;
-import org.eclipse.swt.events.TraverseListener;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.ImageData;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.layout.FormLayout;
-import org.eclipse.swt.program.Program;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Link;
-import org.eclipse.swt.widgets.Text;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.beust.jcommander.internal.Nullable;
-
-import at.asit.pdfover.commons.Constants;
-import at.asit.pdfover.commons.Messages;
-import at.asit.pdfover.gui.bku.OLDmobile.ATrustStatus;
-import at.asit.pdfover.gui.utils.SWTUtils;
-import at.asit.pdfover.gui.workflow.states.State;
-
-/**
- * Composite for entering the TAN for the mobile BKU
- */
-public class MobileBKUEnterTANComposite extends StateComposite {
-
- /**
- *
- */
- private final class OkSelectionListener extends SelectionAdapter {
-
- @Override
- public void widgetSelected(SelectionEvent e) {
- if(!MobileBKUEnterTANComposite.this.btn_ok.getEnabled()) {
- return;
- }
-
- String tan = MobileBKUEnterTANComposite.this.txt_tan.getText();
-
- tan = tan.trim();
-
- if (tan.isEmpty()) {
- MobileBKUEnterTANComposite.this.setMessage(Messages
- .getString("error.NoTan"));
- return;
- }
-
- if (MobileBKUEnterTANComposite.this.refVal.startsWith(tan)) {
- MobileBKUEnterTANComposite.this.setMessage(Messages
- .getString("error.EnteredReferenceValue"));
- return;
- }
-
- if (tan.length() > 6) {
- MobileBKUEnterTANComposite.this.setMessage(Messages
- .getString("error.TanTooLong"));
- return;
- }
-
- MobileBKUEnterTANComposite.this.tan = tan;
- MobileBKUEnterTANComposite.this.userAck = true;
- }
- }
-
- /**
- * SLF4J Logger instance
- **/
- static final Logger log = LoggerFactory.getLogger(MobileBKUEnterTANComposite.class);
-
- private Text txt_tan;
-
- private boolean userAck = false;
- private boolean userCancel = false;
- private boolean userFido2 = false;
-
- private Label lblRefVal;
-
- private String refVal;
-
- private URI signatureDataURI;
-
- /**
- * @param signatureData
- * the signatureData to set
- */
- public void setSignatureDataURI(@Nullable URI uri) {
- this.signatureDataURI = uri;
- this.lnk_sig_data.setEnabled(uri != null);
- }
-
- private String tan;
-
- private Link lnk_sig_data;
-
- private Label lblTries;
- private Label lblRefValLabel;
- private Label lblTan;
-
- private Button btn_ok;
- private Button btn_cancel;
- private Button btn_fido2;
-
- public boolean isDone() { return (this.userAck || this.userCancel || this.userFido2); }
- public boolean isUserAck() { return this.userAck; }
- public boolean isUserCancel() { return this.userCancel; }
- public boolean isUserFido2() { return this.userFido2; }
-
- public void reset() { this.userAck = this.userCancel = this.userFido2 = false; }
-
- /**
- * Set how many tries are left
- *
- * @param tries
- */
- public void setTries(int tries) {
- if ((tries > 0) && (tries < ATrustStatus.MOBILE_MAX_TAN_TRIES)) {
- if (tries > 1)
- SWTUtils.setLocalizedText(lblTries, "tanEnter.try");
- else
- SWTUtils.setLocalizedText(lblTries, "tanEnter.tries", tries);
- }
- }
-
- /**
- * Set an error message
- * @param errorMessage the error message
- */
- public void setErrorMessage(String errorMessage) {
- if (errorMessage == null)
- this.lblTries.setText("");
- else
- this.lblTries.setText(
- Messages.getString("error.Title") + ": " + errorMessage);
- }
-
- public void setFIDO2Enabled(boolean state) {
- this.btn_fido2.setEnabled(state);
- }
-
- /**
- * Sets the message
- *
- * @param msg
- */
- public void setMessage(String msg) {
- this.lblTries.setText(msg);
- this.lblTries.redraw();
- this.lblTries.getParent().layout(true, true);
- }
-
- /**
- * @return the reference value
- */
- public String getRefVal() {
- return this.refVal;
- }
-
- /**
- * @param refVal
- * the reference value to set
- */
- public void setRefVal(String refVal) {
- this.refVal = refVal.trim();
-
- if (this.refVal != null) {
- this.lblRefVal.setText(this.refVal);
- } else {
- this.lblRefVal.setText("");
- }
-
- }
-
- /**
- * @return the tan
- */
- public String getTan() {
- return this.tan;
- }
-
- /**
- * @param tan
- * the tan to set
- */
- public void setTan(String tan) {
- this.tan = tan;
-
- if (this.tan == null) {
- this.txt_tan.setText("");
- } else {
- this.txt_tan.setText(this.tan);
- }
- }
-
- /**
- * Create the composite.
- *
- * @param parent
- * @param style
- * @param state
- */
- public MobileBKUEnterTANComposite(Composite parent, int style, State state) {
- super(parent, style, state);
- setLayout(new FormLayout());
-
- final Composite containerComposite = new Composite(this, SWT.NATIVE);
- containerComposite.addPaintListener(new PaintListener() {
- @Override
- public void paintControl(PaintEvent e) {
- Rectangle clientArea = containerComposite.getClientArea();
-
- // e.gc.setForeground();
- e.gc.setForeground(Constants.MAINBAR_ACTIVE_BACK_DARK);
- e.gc.setLineWidth(3);
- e.gc.setLineStyle(SWT.LINE_SOLID);
- e.gc.drawRoundRectangle(clientArea.x, clientArea.y,
- clientArea.width - 2, clientArea.height - 2, 10, 10);
- }
- });
- containerComposite.setLayout(new FormLayout());
- SWTUtils.anchor(containerComposite).top(50, -120).bottom(50, 120).left(50, -200).right(50, 200);
-
- this.lblRefValLabel = new Label(containerComposite, SWT.NATIVE);
- SWTUtils.anchor(lblRefValLabel).right(50, -10).bottom(50,-10);
- SWTUtils.setLocalizedText(lblRefValLabel, "tanEnter.ReferenceValue");
- this.lblRefValLabel.setAlignment(SWT.RIGHT);
-
- ImageData mobileIcon = new ImageData(this.getClass().getResourceAsStream(Constants.RES_IMG_MOBILE));
- Label lbl_image = new Label(containerComposite, SWT.NATIVE);
- SWTUtils.anchor(lbl_image).top(50, -1 * (mobileIcon.width / 2)).bottom(50, mobileIcon.width / 2).left(0, 10).width(mobileIcon.width);
- lbl_image.setImage(new Image(getDisplay(), mobileIcon));
-
- this.lblRefVal = new Label(containerComposite, SWT.NATIVE);
- SWTUtils.anchor(lblRefVal).left(50,10).right(100,-20).bottom(50,-10);
- this.lblRefVal.setText("");
-
- this.lblTan = new Label(containerComposite, SWT.NATIVE);
- SWTUtils.anchor(lblTan).right(50,-10).top(50,10);
- SWTUtils.setLocalizedText(lblTan, "tanEnter.TAN");
- this.lblTan.setAlignment(SWT.RIGHT);
-
- this.txt_tan = new Text(containerComposite, SWT.BORDER | SWT.NATIVE);
- SWTUtils.anchor(txt_tan).left(50,10).right(100,-20).top(50,10);
- this.txt_tan.setEditable(true);
-
- this.txt_tan.addTraverseListener(new TraverseListener() {
- @Override
- public void keyTraversed(TraverseEvent e) {
- if (e.detail == SWT.TRAVERSE_RETURN) {
- if(MobileBKUEnterTANComposite.this.btn_ok.isEnabled()) {
- (new OkSelectionListener()).widgetSelected(null);
- }
- }
- }
- });
-
- this.txt_tan.addModifyListener(new ModifyListener() {
- @Override
- public void modifyText(ModifyEvent e) {
-
- String text = MobileBKUEnterTANComposite.this.txt_tan.getText();
- //log.debug("Current TAN: " + text);
- if (text.length() > 3
- && MobileBKUEnterTANComposite.this.getRefVal()
- .startsWith(text.trim())) {
- MobileBKUEnterTANComposite.this.setMessage(Messages.getString("error.EnteredReferenceValue"));
- }
- }
- });
-
- this.lnk_sig_data = new Link(containerComposite, SWT.NATIVE | SWT.RESIZE);
- SWTUtils.anchor(lnk_sig_data).right(100,-20).top(0,20);
- lnk_sig_data.setEnabled(true);
- SWTUtils.addSelectionListener(lnk_sig_data, (e) -> { SWTUtils.openURL(this.signatureDataURI); });
-
- this.btn_ok = new Button(containerComposite, SWT.NATIVE);
- SWTUtils.anchor(btn_ok).right(100,-20).bottom(100,-20);
- this.btn_ok.addSelectionListener(new OkSelectionListener());
-
- this.btn_cancel = new Button(containerComposite, SWT.NATIVE);
- SWTUtils.anchor(btn_cancel).right(btn_ok, -20).bottom(100, -20);
- SWTUtils.addSelectionListener(btn_cancel, (e) -> { this.userCancel = true; });
-
- this.btn_fido2 = new Button(containerComposite, SWT.NATIVE);
- SWTUtils.anchor(btn_fido2).right(btn_cancel, -20).bottom(100, -20);
- SWTUtils.addSelectionListener(btn_fido2, (e) -> { this.userFido2 = true; });
-
- this.lblTries = new Label(containerComposite, SWT.WRAP | SWT.NATIVE);
- SWTUtils.anchor(lblTries).right(btn_fido2, -10).bottom(100, -20);
- }
-
- @Override
- protected void checkSubclass() {
- // Disable the check that prevents subclassing of SWT components
- }
-
- /*
- * (non-Javadoc)
- *
- * @see at.asit.pdfover.gui.composites.StateComposite#doLayout()
- */
- @Override
- public void doLayout() {
- // Nothing to do
- }
-
- /*
- * (non-Javadoc)
- *
- * @see at.asit.pdfover.gui.composites.StateComposite#reloadResources()
- */
- @Override
- public void reloadResources() {
- SWTUtils.setLocalizedText(lnk_sig_data, "mobileBKU.show");
- SWTUtils.setLocalizedToolTipText(lnk_sig_data, "mobileBKU.show_tooltip");
- SWTUtils.setLocalizedText(lblRefValLabel, "tanEnter.ReferenceValue");
- SWTUtils.setLocalizedText(lblTan, "tanEnter.TAN");
- SWTUtils.setLocalizedText(btn_cancel, "common.Cancel");
- SWTUtils.setLocalizedText(btn_ok, "common.Ok");
- }
-}
+/*
+ * Copyright 2012 by A-SIT, Secure Information Technology Center Austria
+ *
+ * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
+ * the European Commission - subsequent versions of the EUPL (the "Licence");
+ * You may not use this work except in compliance with the Licence.
+ * You may obtain a copy of the Licence at:
+ * http://joinup.ec.europa.eu/software/page/eupl
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the Licence is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the Licence for the specific language governing permissions and
+ * limitations under the Licence.
+ */
+package at.asit.pdfover.gui.composites;
+
+// Imports
+import java.net.URI;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.PaintEvent;
+import org.eclipse.swt.events.PaintListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.TraverseEvent;
+import org.eclipse.swt.events.TraverseListener;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.ImageData;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.layout.FormLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Link;
+import org.eclipse.swt.widgets.Text;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.beust.jcommander.internal.Nullable;
+
+import at.asit.pdfover.commons.Constants;
+import at.asit.pdfover.commons.Messages;
+import at.asit.pdfover.gui.bku.OLDmobile.ATrustStatus;
+import at.asit.pdfover.gui.utils.SWTUtils;
+import at.asit.pdfover.gui.workflow.states.State;
+
+/**
+ * Composite for entering the TAN for the mobile BKU
+ */
+public class MobileBKUEnterTANComposite extends StateComposite {
+
+ /**
+ *
+ */
+ private final class OkSelectionListener extends SelectionAdapter {
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ if(!MobileBKUEnterTANComposite.this.btn_ok.getEnabled()) {
+ return;
+ }
+
+ String tan = MobileBKUEnterTANComposite.this.txt_tan.getText();
+
+ tan = tan.trim();
+
+ if (tan.isEmpty()) {
+ MobileBKUEnterTANComposite.this.setMessage(Messages
+ .getString("error.NoTan"));
+ return;
+ }
+
+ if (MobileBKUEnterTANComposite.this.refVal.startsWith(tan)) {
+ MobileBKUEnterTANComposite.this.setMessage(Messages
+ .getString("error.EnteredReferenceValue"));
+ return;
+ }
+
+ if (tan.length() > 6) {
+ MobileBKUEnterTANComposite.this.setMessage(Messages
+ .getString("error.TanTooLong"));
+ return;
+ }
+
+ MobileBKUEnterTANComposite.this.tan = tan;
+ MobileBKUEnterTANComposite.this.userAck = true;
+ }
+ }
+
+ /**
+ * SLF4J Logger instance
+ **/
+ static final Logger log = LoggerFactory.getLogger(MobileBKUEnterTANComposite.class);
+
+ private Text txt_tan;
+
+ private boolean userAck = false;
+ private boolean userCancel = false;
+ private boolean userFido2 = false;
+
+ private Label lblRefVal;
+
+ private String refVal;
+
+ private URI signatureDataURI;
+
+ /**
+ * @param signatureData
+ * the signatureData to set
+ */
+ public void setSignatureDataURI(@Nullable URI uri) {
+ this.signatureDataURI = uri;
+ this.lnk_sig_data.setEnabled(uri != null);
+ }
+
+ private String tan;
+
+ private Link lnk_sig_data;
+
+ private Label lblTries;
+ private Label lblRefValLabel;
+ private Label lblTan;
+
+ private Button btn_ok;
+ private Button btn_cancel;
+ private Button btn_fido2;
+
+ public boolean isDone() { return (this.userAck || this.userCancel || this.userFido2); }
+ public boolean isUserAck() { return this.userAck; }
+ public boolean isUserCancel() { return this.userCancel; }
+ public boolean isUserFido2() { return this.userFido2; }
+
+ public void reset() { this.userAck = this.userCancel = this.userFido2 = false; }
+
+ /**
+ * Set how many tries are left
+ *
+ * @param tries
+ */
+ public void setTries(int tries) {
+ if ((tries > 0) && (tries < ATrustStatus.MOBILE_MAX_TAN_TRIES)) {
+ if (tries > 1)
+ SWTUtils.setLocalizedText(lblTries, "tanEnter.try");
+ else
+ SWTUtils.setLocalizedText(lblTries, "tanEnter.tries", tries);
+ }
+ }
+
+ /**
+ * Set an error message
+ * @param errorMessage the error message
+ */
+ public void setErrorMessage(String errorMessage) {
+ if (errorMessage == null)
+ this.lblTries.setText("");
+ else
+ this.lblTries.setText(
+ Messages.getString("error.Title") + ": " + errorMessage);
+ }
+
+ public void setFIDO2Enabled(boolean state) {
+ this.btn_fido2.setEnabled(state);
+ }
+
+ /**
+ * Sets the message
+ *
+ * @param msg
+ */
+ public void setMessage(String msg) {
+ this.lblTries.setText(msg);
+ this.lblTries.redraw();
+ this.lblTries.getParent().layout(true, true);
+ }
+
+ /**
+ * @return the reference value
+ */
+ public String getRefVal() {
+ return this.refVal;
+ }
+
+ /**
+ * @param refVal
+ * the reference value to set
+ */
+ public void setRefVal(String refVal) {
+ this.refVal = refVal.trim();
+
+ if (this.refVal != null) {
+ this.lblRefVal.setText(this.refVal);
+ } else {
+ this.lblRefVal.setText("");
+ }
+
+ }
+
+ /**
+ * @return the tan
+ */
+ public String getTan() {
+ return this.tan;
+ }
+
+ /**
+ * @param tan
+ * the tan to set
+ */
+ public void setTan(String tan) {
+ this.tan = tan;
+
+ if (this.tan == null) {
+ this.txt_tan.setText("");
+ } else {
+ this.txt_tan.setText(this.tan);
+ }
+ }
+
+ /**
+ * Create the composite.
+ *
+ * @param parent
+ * @param style
+ * @param state
+ */
+ public MobileBKUEnterTANComposite(Composite parent, int style, State state) {
+ super(parent, style, state);
+ setLayout(new FormLayout());
+
+ final Composite containerComposite = new Composite(this, SWT.NATIVE);
+ containerComposite.addPaintListener(new PaintListener() {
+ @Override
+ public void paintControl(PaintEvent e) {
+ Rectangle clientArea = containerComposite.getClientArea();
+
+ // e.gc.setForeground();
+ e.gc.setForeground(Constants.MAINBAR_ACTIVE_BACK_DARK);
+ e.gc.setLineWidth(3);
+ e.gc.setLineStyle(SWT.LINE_SOLID);
+ e.gc.drawRoundRectangle(clientArea.x, clientArea.y,
+ clientArea.width - 2, clientArea.height - 2, 10, 10);
+ }
+ });
+ containerComposite.setLayout(new FormLayout());
+ SWTUtils.anchor(containerComposite).top(50, -120).bottom(50, 120).left(50, -200).right(50, 200);
+
+ this.lblRefValLabel = new Label(containerComposite, SWT.NATIVE);
+ SWTUtils.anchor(lblRefValLabel).right(50, -10).bottom(50,-10);
+ SWTUtils.setLocalizedText(lblRefValLabel, "tanEnter.ReferenceValue");
+ this.lblRefValLabel.setAlignment(SWT.RIGHT);
+
+ ImageData mobileIcon = new ImageData(this.getClass().getResourceAsStream(Constants.RES_IMG_MOBILE));
+ Label lbl_image = new Label(containerComposite, SWT.NATIVE);
+ SWTUtils.anchor(lbl_image).top(50, -1 * (mobileIcon.width / 2)).bottom(50, mobileIcon.width / 2).left(0, 10).width(mobileIcon.width);
+ lbl_image.setImage(new Image(getDisplay(), mobileIcon));
+
+ this.lblRefVal = new Label(containerComposite, SWT.NATIVE);
+ SWTUtils.anchor(lblRefVal).left(50,10).right(100,-20).bottom(50,-10);
+ this.lblRefVal.setText("");
+
+ this.lblTan = new Label(containerComposite, SWT.NATIVE);
+ SWTUtils.anchor(lblTan).right(50,-10).top(50,10);
+ SWTUtils.setLocalizedText(lblTan, "tanEnter.TAN");
+ this.lblTan.setAlignment(SWT.RIGHT);
+
+ this.txt_tan = new Text(containerComposite, SWT.BORDER | SWT.NATIVE);
+ SWTUtils.anchor(txt_tan).left(50,10).right(100,-20).top(50,10);
+ this.txt_tan.setEditable(true);
+
+ this.txt_tan.addTraverseListener(new TraverseListener() {
+ @Override
+ public void keyTraversed(TraverseEvent e) {
+ if (e.detail == SWT.TRAVERSE_RETURN) {
+ if(MobileBKUEnterTANComposite.this.btn_ok.isEnabled()) {
+ (new OkSelectionListener()).widgetSelected(null);
+ }
+ }
+ }
+ });
+
+ this.txt_tan.addModifyListener(new ModifyListener() {
+ @Override
+ public void modifyText(ModifyEvent e) {
+
+ String text = MobileBKUEnterTANComposite.this.txt_tan.getText();
+ //log.debug("Current TAN: " + text);
+ if (text.length() > 3
+ && MobileBKUEnterTANComposite.this.getRefVal()
+ .startsWith(text.trim())) {
+ MobileBKUEnterTANComposite.this.setMessage(Messages.getString("error.EnteredReferenceValue"));
+ }
+ }
+ });
+
+ this.lnk_sig_data = new Link(containerComposite, SWT.NATIVE | SWT.RESIZE);
+ SWTUtils.anchor(lnk_sig_data).right(100,-20).top(0,20);
+ lnk_sig_data.setEnabled(true);
+ SWTUtils.addSelectionListener(lnk_sig_data, (e) -> { SWTUtils.openURL(this.signatureDataURI); });
+
+ this.btn_ok = new Button(containerComposite, SWT.NATIVE);
+ SWTUtils.anchor(btn_ok).right(100,-20).bottom(100,-20);
+ this.btn_ok.addSelectionListener(new OkSelectionListener());
+
+ this.btn_cancel = new Button(containerComposite, SWT.NATIVE);
+ SWTUtils.anchor(btn_cancel).right(btn_ok, -20).bottom(100, -20);
+ SWTUtils.addSelectionListener(btn_cancel, (e) -> { this.userCancel = true; });
+
+ this.btn_fido2 = new Button(containerComposite, SWT.NATIVE);
+ SWTUtils.anchor(btn_fido2).right(btn_cancel, -20).bottom(100, -20);
+ SWTUtils.addSelectionListener(btn_fido2, (e) -> { this.userFido2 = true; });
+
+ this.lblTries = new Label(containerComposite, SWT.WRAP | SWT.NATIVE);
+ SWTUtils.anchor(lblTries).right(btn_fido2, -10).bottom(100, -20);
+ }
+
+ @Override
+ protected void checkSubclass() {
+ // Disable the check that prevents subclassing of SWT components
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see at.asit.pdfover.gui.composites.StateComposite#doLayout()
+ */
+ @Override
+ public void doLayout() {
+ // Nothing to do
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see at.asit.pdfover.gui.composites.StateComposite#reloadResources()
+ */
+ @Override
+ public void reloadResources() {
+ SWTUtils.setLocalizedText(lnk_sig_data, "mobileBKU.show");
+ SWTUtils.setLocalizedToolTipText(lnk_sig_data, "mobileBKU.show_tooltip");
+ SWTUtils.setLocalizedText(lblRefValLabel, "tanEnter.ReferenceValue");
+ SWTUtils.setLocalizedText(lblTan, "tanEnter.TAN");
+ SWTUtils.setLocalizedText(btn_cancel, "common.Cancel");
+ SWTUtils.setLocalizedText(btn_ok, "common.Ok");
+ SWTUtils.setLocalizedText(btn_fido2, "tanEnter.FIDO2");
+ }
+}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/MobileBKUFingerprintComposite.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/mobilebku/MobileBKUFingerprintComposite.java
index afa71f9f..c0561fe4 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/MobileBKUFingerprintComposite.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/mobilebku/MobileBKUFingerprintComposite.java
@@ -1,296 +1,292 @@
-/*
- * Copyright 2012 by A-SIT, Secure Information Technology Center Austria
- *
- * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
- * the European Commission - subsequent versions of the EUPL (the "Licence");
- * You may not use this work except in compliance with the Licence.
- * You may obtain a copy of the Licence at:
- * http://joinup.ec.europa.eu/software/page/eupl
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the Licence is distributed on an "AS IS" basis,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the Licence for the specific language governing permissions and
- * limitations under the Licence.
- */
-package at.asit.pdfover.gui.composites;
-
-// Imports
-import java.awt.Desktop;
-import java.net.URI;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.PaintEvent;
-import org.eclipse.swt.events.PaintListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.ImageData;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.layout.FormLayout;
-import org.eclipse.swt.program.Program;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Link;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import at.asit.pdfover.commons.Constants;
-import at.asit.pdfover.commons.Messages;
-import at.asit.pdfover.gui.utils.SWTUtils;
-import at.asit.pdfover.gui.workflow.states.State;
-
-/**
- * Composite for displaying the QR code for the mobile BKU
- */
-public class MobileBKUFingerprintComposite extends StateComposite {
-
- /**
- *
- */
- private final class SMSSelectionListener extends SelectionAdapter {
- /**
- * Empty constructor
- */
- public SMSSelectionListener() {
- }
-
- @Override
- public void widgetSelected(SelectionEvent e) {
- if(!MobileBKUFingerprintComposite.this.btn_sms.getEnabled()) {
- return;
- }
-
- MobileBKUFingerprintComposite.this.setUserSMS(true);
- MobileBKUFingerprintComposite.this.btn_sms.setEnabled(false);
- }
- }
-
- /**
- *
- */
- private final class CancelSelectionListener extends SelectionAdapter {
- /**
- * Empty constructor
- */
- public CancelSelectionListener() {
- }
-
- @Override
- public void widgetSelected(SelectionEvent e) {
- MobileBKUFingerprintComposite.this.setUserCancel(true);
- }
- }
-
- /**
- * SLF4J Logger instance
- **/
- static final Logger log = LoggerFactory.getLogger(MobileBKUFingerprintComposite.class);
-
- boolean userCancel = false;
- boolean userSMS = false;
- boolean done = false;
-
- private Label lblRefVal;
-
- String refVal;
-
- String signatureData;
-
- /**
- * @return the signatureData
- */
- public String getSignatureData() {
- return this.signatureData;
- }
-
- /**
- * @param signatureData
- * the signatureData to set
- */
- public void setSignatureData(String signatureData) {
- this.signatureData = signatureData;
- }
-
- private Label lblError;
- private Label lblRefValLabel;
- private Label lblFPLabel;
-
- Button btn_sms;
- Button btn_cancel;
-
- Link lnk_sig_data;
-
- /**
- * @return the userCancel
- */
- public boolean isUserCancel() {
- return this.userCancel;
- }
-
- /**
- * @return the userSMS
- */
- public boolean isUserSMS() {
- return this.userSMS;
- }
-
- /**
- * @return the done
- */
- public boolean isDone() {
- return this.done;
- }
-
- /**
- * Set an error message
- * @param errorMessage the error message
- */
- public void setErrorMessage(String errorMessage) {
- if (errorMessage == null)
- this.lblError.setText("");
- else
- this.lblError.setText(
- Messages.getString("error.Title") + ": " + errorMessage);
- }
-
- /**
- * @param userCancel
- * the userCancel to set
- */
- public void setUserCancel(boolean userCancel) {
- this.userCancel = userCancel;
- }
-
- /**
- * @param userSMS
- * the userSMS to set
- */
- public void setUserSMS(boolean userSMS) {
- this.userSMS = userSMS;
- }
-
- /**
- * @param done
- * the done to set
- */
- public void setDone(boolean done) {
- this.done = done;
- }
-
- /**
- * @return the reference value
- */
- public String getRefVal() {
- return this.refVal;
- }
-
- /**
- * @param refVal
- * the reference value to set
- */
- public void setRefVal(String refVal) {
-
- if (this.refVal != null) {
- this.refVal = refVal.trim();
- this.lblRefVal.setText(this.refVal);
- } else {
- this.lblRefVal.setText("");
- }
-
- }
-
- /**
- * Create the composite.
- *
- * @param parent
- * @param style
- * @param state
- */
- public MobileBKUFingerprintComposite(Composite parent, int style, State state) {
- super(parent, style, state);
- setLayout(new FormLayout());
-
- final Composite containerComposite = new Composite(this, SWT.NATIVE);
- containerComposite.addPaintListener(new PaintListener() {
- @Override
- public void paintControl(PaintEvent e) {
- Rectangle clientArea = containerComposite.getClientArea();
-
- // e.gc.setForeground();
- e.gc.setForeground(Constants.MAINBAR_ACTIVE_BACK_DARK);
- e.gc.setLineWidth(3);
- e.gc.setLineStyle(SWT.LINE_SOLID);
- e.gc.drawRoundRectangle(clientArea.x, clientArea.y,
- clientArea.width - 2, clientArea.height - 2, 10, 10);
- }
- });
- containerComposite.setLayout(new FormLayout());
- SWTUtils.anchor(containerComposite).top(50, -140).bottom(50, 140).left(50, -200).right(50, 200);
-
- this.lblRefValLabel = new Label(containerComposite, SWT.NATIVE);
- SWTUtils.anchor(lblRefValLabel).right(50, -10).top(30, -10);
- this.lblRefValLabel.setAlignment(SWT.RIGHT);
-
- ImageData mobileIcon = new ImageData(this.getClass().getResourceAsStream(Constants.RES_IMG_MOBILE));
- Label lbl_image = new Label(containerComposite, SWT.NATIVE);
- SWTUtils.anchor(lbl_image).top(50, -1 * (mobileIcon.width / 2)).bottom(50, mobileIcon.width / 2).left(0, 10).width(mobileIcon.width);
- lbl_image.setImage(new Image(getDisplay(), mobileIcon));
-
- this.lblRefVal = new Label(containerComposite, SWT.NATIVE);
- SWTUtils.anchor(lblRefVal).left(50, 10).right(100, -20).top(30, -10);
-
- this.lblFPLabel = new Label(containerComposite, SWT.NATIVE);
- SWTUtils.anchor(lblFPLabel).left(25, 10).top(lblRefValLabel, 10);
- this.lblFPLabel.setAlignment(SWT.LEFT);
-
- this.lnk_sig_data = new Link(containerComposite, SWT.NATIVE | SWT.RESIZE);
- SWTUtils.anchor(lnk_sig_data).right(100, -20).top(0, 20);
- this.lnk_sig_data.setEnabled(true);
- SWTUtils.addSelectionListener(lnk_sig_data, (e) -> { SWTUtils.openURL(getSignatureData()); });
-
- this.btn_cancel = new Button(containerComposite, SWT.NATIVE);
- SWTUtils.anchor(btn_cancel).right(100, -20).bottom(100, -20);
- this.btn_cancel.addSelectionListener(new CancelSelectionListener());
-
- this.btn_sms = new Button(containerComposite, SWT.NATIVE);
- SWTUtils.anchor(btn_sms).right(btn_cancel, -20).bottom(100, -20);
- this.btn_sms.addSelectionListener(new SMSSelectionListener());
-
- this.lblError = new Label(containerComposite, SWT.WRAP | SWT.NATIVE);
- SWTUtils.anchor(lblError).right(btn_sms, -10).bottom(100, -20);
-
- reloadResources();
- }
-
- @Override
- protected void checkSubclass() {
- // Disable the check that prevents subclassing of SWT components
- }
-
- /*
- * (non-Javadoc)
- *
- * @see at.asit.pdfover.gui.composites.StateComposite#doLayout()
- */
- @Override
- public void doLayout() {
- // Nothing to do
- }
-
- /*
- * (non-Javadoc)
- *
- * @see at.asit.pdfover.gui.composites.StateComposite#reloadResources()
- */
- @Override
- public void reloadResources() {
- SWTUtils.setLocalizedText(lblRefValLabel, "tanEnter.ReferenceValue");
- SWTUtils.setLocalizedText(lblFPLabel, "tanEnter.FP");
- SWTUtils.setLocalizedText(lnk_sig_data, "mobileBKU.show");
- SWTUtils.setLocalizedToolTipText(lnk_sig_data, "mobileBKU.show_tooltip");
- SWTUtils.setLocalizedText(btn_cancel, "common.Cancel");
- SWTUtils.setLocalizedText(btn_sms, "tanEnter.SMS");
- }
-}
+/*
+ * Copyright 2012 by A-SIT, Secure Information Technology Center Austria
+ *
+ * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
+ * the European Commission - subsequent versions of the EUPL (the "Licence");
+ * You may not use this work except in compliance with the Licence.
+ * You may obtain a copy of the Licence at:
+ * http://joinup.ec.europa.eu/software/page/eupl
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the Licence is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the Licence for the specific language governing permissions and
+ * limitations under the Licence.
+ */
+package at.asit.pdfover.gui.composites;
+
+// Imports
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.PaintEvent;
+import org.eclipse.swt.events.PaintListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.ImageData;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.layout.FormLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Link;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import at.asit.pdfover.commons.Constants;
+import at.asit.pdfover.commons.Messages;
+import at.asit.pdfover.gui.utils.SWTUtils;
+import at.asit.pdfover.gui.workflow.states.State;
+
+/**
+ * Composite for displaying the QR code for the mobile BKU
+ */
+public class MobileBKUFingerprintComposite extends StateComposite {
+
+ /**
+ *
+ */
+ private final class SMSSelectionListener extends SelectionAdapter {
+ /**
+ * Empty constructor
+ */
+ public SMSSelectionListener() {
+ }
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ if(!MobileBKUFingerprintComposite.this.btn_sms.getEnabled()) {
+ return;
+ }
+
+ MobileBKUFingerprintComposite.this.setUserSMS(true);
+ MobileBKUFingerprintComposite.this.btn_sms.setEnabled(false);
+ }
+ }
+
+ /**
+ *
+ */
+ private final class CancelSelectionListener extends SelectionAdapter {
+ /**
+ * Empty constructor
+ */
+ public CancelSelectionListener() {
+ }
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ MobileBKUFingerprintComposite.this.setUserCancel(true);
+ }
+ }
+
+ /**
+ * SLF4J Logger instance
+ **/
+ static final Logger log = LoggerFactory.getLogger(MobileBKUFingerprintComposite.class);
+
+ boolean userCancel = false;
+ boolean userSMS = false;
+ boolean done = false;
+
+ private Label lblRefVal;
+
+ String refVal;
+
+ String signatureData;
+
+ /**
+ * @return the signatureData
+ */
+ public String getSignatureData() {
+ return this.signatureData;
+ }
+
+ /**
+ * @param signatureData
+ * the signatureData to set
+ */
+ public void setSignatureData(String signatureData) {
+ this.signatureData = signatureData;
+ }
+
+ private Label lblError;
+ private Label lblRefValLabel;
+ private Label lblFPLabel;
+
+ Button btn_sms;
+ Button btn_cancel;
+
+ Link lnk_sig_data;
+
+ /**
+ * @return the userCancel
+ */
+ public boolean isUserCancel() {
+ return this.userCancel;
+ }
+
+ /**
+ * @return the userSMS
+ */
+ public boolean isUserSMS() {
+ return this.userSMS;
+ }
+
+ /**
+ * @return the done
+ */
+ public boolean isDone() {
+ return this.done;
+ }
+
+ /**
+ * Set an error message
+ * @param errorMessage the error message
+ */
+ public void setErrorMessage(String errorMessage) {
+ if (errorMessage == null)
+ this.lblError.setText("");
+ else
+ this.lblError.setText(
+ Messages.getString("error.Title") + ": " + errorMessage);
+ }
+
+ /**
+ * @param userCancel
+ * the userCancel to set
+ */
+ public void setUserCancel(boolean userCancel) {
+ this.userCancel = userCancel;
+ }
+
+ /**
+ * @param userSMS
+ * the userSMS to set
+ */
+ public void setUserSMS(boolean userSMS) {
+ this.userSMS = userSMS;
+ }
+
+ /**
+ * @param done
+ * the done to set
+ */
+ public void setDone(boolean done) {
+ this.done = done;
+ }
+
+ /**
+ * @return the reference value
+ */
+ public String getRefVal() {
+ return this.refVal;
+ }
+
+ /**
+ * @param refVal
+ * the reference value to set
+ */
+ public void setRefVal(String refVal) {
+
+ if (this.refVal != null) {
+ this.refVal = refVal.trim();
+ this.lblRefVal.setText(this.refVal);
+ } else {
+ this.lblRefVal.setText("");
+ }
+
+ }
+
+ /**
+ * Create the composite.
+ *
+ * @param parent
+ * @param style
+ * @param state
+ */
+ public MobileBKUFingerprintComposite(Composite parent, int style, State state) {
+ super(parent, style, state);
+ setLayout(new FormLayout());
+
+ final Composite containerComposite = new Composite(this, SWT.NATIVE);
+ containerComposite.addPaintListener(new PaintListener() {
+ @Override
+ public void paintControl(PaintEvent e) {
+ Rectangle clientArea = containerComposite.getClientArea();
+
+ // e.gc.setForeground();
+ e.gc.setForeground(Constants.MAINBAR_ACTIVE_BACK_DARK);
+ e.gc.setLineWidth(3);
+ e.gc.setLineStyle(SWT.LINE_SOLID);
+ e.gc.drawRoundRectangle(clientArea.x, clientArea.y,
+ clientArea.width - 2, clientArea.height - 2, 10, 10);
+ }
+ });
+ containerComposite.setLayout(new FormLayout());
+ SWTUtils.anchor(containerComposite).top(50, -140).bottom(50, 140).left(50, -200).right(50, 200);
+
+ this.lblRefValLabel = new Label(containerComposite, SWT.NATIVE);
+ SWTUtils.anchor(lblRefValLabel).right(50, -10).top(30, -10);
+ this.lblRefValLabel.setAlignment(SWT.RIGHT);
+
+ ImageData mobileIcon = new ImageData(this.getClass().getResourceAsStream(Constants.RES_IMG_MOBILE));
+ Label lbl_image = new Label(containerComposite, SWT.NATIVE);
+ SWTUtils.anchor(lbl_image).top(50, -1 * (mobileIcon.width / 2)).bottom(50, mobileIcon.width / 2).left(0, 10).width(mobileIcon.width);
+ lbl_image.setImage(new Image(getDisplay(), mobileIcon));
+
+ this.lblRefVal = new Label(containerComposite, SWT.NATIVE);
+ SWTUtils.anchor(lblRefVal).left(50, 10).right(100, -20).top(30, -10);
+
+ this.lblFPLabel = new Label(containerComposite, SWT.NATIVE);
+ SWTUtils.anchor(lblFPLabel).left(25, 10).top(lblRefValLabel, 10);
+ this.lblFPLabel.setAlignment(SWT.LEFT);
+
+ this.lnk_sig_data = new Link(containerComposite, SWT.NATIVE | SWT.RESIZE);
+ SWTUtils.anchor(lnk_sig_data).right(100, -20).top(0, 20);
+ this.lnk_sig_data.setEnabled(true);
+ SWTUtils.addSelectionListener(lnk_sig_data, (e) -> { SWTUtils.openURL(getSignatureData()); });
+
+ this.btn_cancel = new Button(containerComposite, SWT.NATIVE);
+ SWTUtils.anchor(btn_cancel).right(100, -20).bottom(100, -20);
+ this.btn_cancel.addSelectionListener(new CancelSelectionListener());
+
+ this.btn_sms = new Button(containerComposite, SWT.NATIVE);
+ SWTUtils.anchor(btn_sms).right(btn_cancel, -20).bottom(100, -20);
+ this.btn_sms.addSelectionListener(new SMSSelectionListener());
+
+ this.lblError = new Label(containerComposite, SWT.WRAP | SWT.NATIVE);
+ SWTUtils.anchor(lblError).right(btn_sms, -10).bottom(100, -20);
+
+ reloadResources();
+ }
+
+ @Override
+ protected void checkSubclass() {
+ // Disable the check that prevents subclassing of SWT components
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see at.asit.pdfover.gui.composites.StateComposite#doLayout()
+ */
+ @Override
+ public void doLayout() {
+ // Nothing to do
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see at.asit.pdfover.gui.composites.StateComposite#reloadResources()
+ */
+ @Override
+ public void reloadResources() {
+ SWTUtils.setLocalizedText(lblRefValLabel, "tanEnter.ReferenceValue");
+ SWTUtils.setLocalizedText(lblFPLabel, "tanEnter.FP");
+ SWTUtils.setLocalizedText(lnk_sig_data, "mobileBKU.show");
+ SWTUtils.setLocalizedToolTipText(lnk_sig_data, "mobileBKU.show_tooltip");
+ SWTUtils.setLocalizedText(btn_cancel, "common.Cancel");
+ SWTUtils.setLocalizedText(btn_sms, "tanEnter.SMS");
+ }
+}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/MobileBKUQRComposite.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/mobilebku/MobileBKUQRComposite.java
index baabc192..91765610 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/MobileBKUQRComposite.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/mobilebku/MobileBKUQRComposite.java
@@ -1,252 +1,252 @@
-/*
- * Copyright 2012 by A-SIT, Secure Information Technology Center Austria
- *
- * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
- * the European Commission - subsequent versions of the EUPL (the "Licence");
- * You may not use this work except in compliance with the Licence.
- * You may obtain a copy of the Licence at:
- * http://joinup.ec.europa.eu/software/page/eupl
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the Licence is distributed on an "AS IS" basis,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the Licence for the specific language governing permissions and
- * limitations under the Licence.
- */
-package at.asit.pdfover.gui.composites;
-
-// Imports
-import java.io.ByteArrayInputStream;
-import java.net.URI;
-import java.util.Objects;
-
-import javax.annotation.Nullable;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.SWTException;
-import org.eclipse.swt.events.PaintEvent;
-import org.eclipse.swt.events.PaintListener;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.ImageData;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.layout.FormLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Link;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import at.asit.pdfover.commons.Constants;
-import at.asit.pdfover.commons.Messages;
-import at.asit.pdfover.gui.utils.SWTUtils;
-import at.asit.pdfover.gui.workflow.states.State;
-
-/**
- * Composite for displaying the QR code for the mobile BKU
- */
-public class MobileBKUQRComposite extends StateComposite {
-
- /**
- * SLF4J Logger instance
- **/
- private static final Logger log = LoggerFactory.getLogger(MobileBKUQRComposite.class);
-
- private Label lblQR;
-
- private boolean userCancelClicked = false;
- private boolean userSMSClicked = false;
- private boolean userFIDO2Clicked = false;
- private boolean pollingDone = false;
-
- private Label lblRefVal;
-
- private String refVal;
-
- private ImageData currentQRImage;
-
- private URI signatureDataURI;
-
- private Label lblError;
- private Label lblRefValLabel;
- private Label lblQRLabel;
-
- private Button btn_fido2;
- private Button btn_sms;
- private Button btn_cancel;
-
- private Link lnk_sig_data;
-
- public void signalPollingDone() { this.pollingDone = true; getDisplay().wake(); }
- public boolean isDone() { return (this.userCancelClicked || this.userSMSClicked || this.userFIDO2Clicked || this.pollingDone); }
- public boolean wasCancelClicked() { return this.userCancelClicked; }
- public boolean wasSMSClicked() { return this.userSMSClicked; }
- public boolean wasFIDO2Clicked() { return this.userFIDO2Clicked; }
- public void reset() { this.userCancelClicked = this.userSMSClicked = this.userFIDO2Clicked = this.pollingDone = false; }
-
- /**
- * Set an error message
- * @param errorMessage the error message
- */
- public void setErrorMessage(String errorMessage) {
- if (errorMessage == null)
- this.lblError.setText("");
- else
- this.lblError.setText(
- Messages.getString("error.Title") + ": " + errorMessage);
- }
-
- public String getRefVal() { return this.refVal; }
- public void setRefVal(String refVal) {
- this.refVal = (refVal != null) ? refVal.trim() : null;
- this.lblRefVal.setText(Objects.requireNonNullElse(this.refVal, ""));
- }
-
- private void updateQRImage() {
- if (this.currentQRImage == null)
- return;
-
- Point availableSize = this.lblQR.getSize();
- int targetSize = Math.min(availableSize.x, availableSize.y);
- if (targetSize <= 0)
- return;
-
- this.lblQR.setImage(new Image(this.lblQR.getDisplay(), this.currentQRImage.scaledTo(targetSize, targetSize)));
- }
-
- /**
- * @param qrcode
- * the qrcode to set
- */
- public void setQR(byte[] qrcode) {
- if (qrcode == null) {
- setErrorMessage(Messages.getString("error.FailedToLoadQRCode"));
- return;
- }
- try {
- this.currentQRImage = new ImageData(new ByteArrayInputStream(qrcode));
- } catch (SWTException e) {
- log.warn("Failed to load QR code", e);
- setErrorMessage(Messages.getString("error.FailedToLoadQRCode"));
- return;
- }
- updateQRImage();
- }
-
- public void setSMSEnabled(boolean state) {
- this.btn_sms.setEnabled(state);
- }
-
- public void setFIDO2Enabled(boolean state) {
- this.btn_fido2.setEnabled(state);
- }
-
- public void setSignatureDataURI(@Nullable URI uri) {
- this.signatureDataURI = uri;
- this.lnk_sig_data.setEnabled(uri != null);
- }
-
- /**
- * Create the composite.
- *
- * @param parent
- * @param style
- * @param state
- */
- public MobileBKUQRComposite(Composite parent, int style, State state) {
- super(parent, style, state);
- setLayout(new FormLayout());
-
- final Composite containerComposite = new Composite(this, SWT.NATIVE);
- SWTUtils.anchor(containerComposite).top(50, -140).bottom(50, 140).left(50, -200).right(50, 200);
- containerComposite.addPaintListener(new PaintListener() {
- @Override
- public void paintControl(PaintEvent e) {
- Rectangle clientArea = containerComposite.getClientArea();
-
- // e.gc.setForeground();
- e.gc.setForeground(Constants.MAINBAR_ACTIVE_BACK_DARK);
- e.gc.setLineWidth(3);
- e.gc.setLineStyle(SWT.LINE_SOLID);
- e.gc.drawRoundRectangle(clientArea.x, clientArea.y,
- clientArea.width - 2, clientArea.height - 2, 10, 10);
- }
- });
- containerComposite.setLayout(new FormLayout());
-
- this.lblRefValLabel = new Label(containerComposite, SWT.NATIVE);
- SWTUtils.anchor(lblRefValLabel).right(50, -10).top(30, -10);
- this.lblRefValLabel.setAlignment(SWT.RIGHT);
-
- ImageData mobileIcon = new ImageData(this.getClass().getResourceAsStream(Constants.RES_IMG_MOBILE));
- Label lbl_image = new Label(containerComposite, SWT.NATIVE);
- SWTUtils.anchor(lbl_image).top(50, -1 * (mobileIcon.width / 2)).bottom(50, mobileIcon.width / 2).left(0, 10).width(mobileIcon.width);
- lbl_image.setImage(new Image(getDisplay(), mobileIcon));
-
- this.lblRefVal = new Label(containerComposite, SWT.NATIVE);
- SWTUtils.anchor(lblRefVal).left(50, 10).right(100, -20).top(30, -10);
-
- this.lblQRLabel = new Label(containerComposite, SWT.NATIVE);
- SWTUtils.anchor(lblQRLabel).right(50, -10).top(lblRefValLabel, 10);
- this.lblQRLabel.setAlignment(SWT.RIGHT);
-
- this.lblQR = new Label(containerComposite, SWT.NATIVE);
- this.lblQR.addListener(SWT.Resize, (e) -> { updateQRImage(); });
-
- this.lnk_sig_data = new Link(containerComposite, SWT.NATIVE | SWT.RESIZE);
- SWTUtils.anchor(lnk_sig_data).right(100, -20).top(0, 20);
- SWTUtils.addSelectionListener(lnk_sig_data, (e) -> { SWTUtils.openURL(this.signatureDataURI); });
-
- this.btn_cancel = new Button(containerComposite, SWT.NATIVE);
- SWTUtils.anchor(btn_cancel).right(100, -20).bottom(100, -5);
- SWTUtils.addSelectionListener(btn_cancel, (e) -> { this.userCancelClicked = true; });
-
- this.btn_sms = new Button(containerComposite, SWT.NATIVE);
- SWTUtils.anchor(btn_sms).right(btn_cancel, -20).bottom(100, -5);
- SWTUtils.addSelectionListener(btn_sms, (e) -> { this.userSMSClicked = true; });
-
- this.btn_fido2 = new Button(containerComposite, SWT.NATIVE);
- SWTUtils.anchor(btn_fido2).right(btn_sms, -20).bottom(100, -5);
- SWTUtils.addSelectionListener(btn_fido2, (e) -> {this.userFIDO2Clicked = true; });
-
-
- SWTUtils.anchor(lblQR).left(50, 10).right(100, -20).top(lblRefVal, 10).bottom(btn_sms, -10);
-
- this.lblError = new Label(containerComposite, SWT.WRAP | SWT.NATIVE);
- SWTUtils.anchor(lblError).right(btn_sms, -10).bottom(100, -20);
-
- reloadResources();
- }
-
- @Override
- protected void checkSubclass() {
- // Disable the check that prevents subclassing of SWT components
- }
-
- /*
- * (non-Javadoc)
- *
- * @see at.asit.pdfover.gui.composites.StateComposite#doLayout()
- */
- @Override
- public void doLayout() {
- // Nothing to do
- }
-
- /*
- * (non-Javadoc)
- *
- * @see at.asit.pdfover.gui.composites.StateComposite#reloadResources()
- */
- @Override
- public void reloadResources() {
- SWTUtils.setLocalizedText(lblRefValLabel, "tanEnter.ReferenceValue");
- SWTUtils.setLocalizedText(lblQRLabel, "tanEnter.QR");
- SWTUtils.setLocalizedText(lnk_sig_data, "mobileBKU.show");
- SWTUtils.setLocalizedToolTipText(lnk_sig_data, "mobileBKU.show_tooltip");
- SWTUtils.setLocalizedText(btn_cancel, "common.Cancel");
- SWTUtils.setLocalizedText(btn_sms, "tanEnter.SMS");
- SWTUtils.setLocalizedText(btn_fido2, "tanEnter.FIDO2");
- }
-}
+/*
+ * Copyright 2012 by A-SIT, Secure Information Technology Center Austria
+ *
+ * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
+ * the European Commission - subsequent versions of the EUPL (the "Licence");
+ * You may not use this work except in compliance with the Licence.
+ * You may obtain a copy of the Licence at:
+ * http://joinup.ec.europa.eu/software/page/eupl
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the Licence is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the Licence for the specific language governing permissions and
+ * limitations under the Licence.
+ */
+package at.asit.pdfover.gui.composites;
+
+// Imports
+import java.io.ByteArrayInputStream;
+import java.net.URI;
+import java.util.Objects;
+
+import javax.annotation.Nullable;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.SWTException;
+import org.eclipse.swt.events.PaintEvent;
+import org.eclipse.swt.events.PaintListener;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.ImageData;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.layout.FormLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Link;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import at.asit.pdfover.commons.Constants;
+import at.asit.pdfover.commons.Messages;
+import at.asit.pdfover.gui.utils.SWTUtils;
+import at.asit.pdfover.gui.workflow.states.State;
+
+/**
+ * Composite for displaying the QR code for the mobile BKU
+ */
+public class MobileBKUQRComposite extends StateComposite {
+
+ /**
+ * SLF4J Logger instance
+ **/
+ private static final Logger log = LoggerFactory.getLogger(MobileBKUQRComposite.class);
+
+ private Label lblQR;
+
+ private boolean userCancelClicked = false;
+ private boolean userSMSClicked = false;
+ private boolean userFIDO2Clicked = false;
+ private boolean pollingDone = false;
+
+ private Label lblRefVal;
+
+ private String refVal;
+
+ private ImageData currentQRImage;
+
+ private URI signatureDataURI;
+
+ private Label lblError;
+ private Label lblRefValLabel;
+ private Label lblQRLabel;
+
+ private Button btn_fido2;
+ private Button btn_sms;
+ private Button btn_cancel;
+
+ private Link lnk_sig_data;
+
+ public void signalPollingDone() { this.pollingDone = true; getDisplay().wake(); }
+ public boolean isDone() { return (this.userCancelClicked || this.userSMSClicked || this.userFIDO2Clicked || this.pollingDone); }
+ public boolean wasCancelClicked() { return this.userCancelClicked; }
+ public boolean wasSMSClicked() { return this.userSMSClicked; }
+ public boolean wasFIDO2Clicked() { return this.userFIDO2Clicked; }
+ public void reset() { this.userCancelClicked = this.userSMSClicked = this.userFIDO2Clicked = this.pollingDone = false; }
+
+ /**
+ * Set an error message
+ * @param errorMessage the error message
+ */
+ public void setErrorMessage(String errorMessage) {
+ if (errorMessage == null)
+ this.lblError.setText("");
+ else
+ this.lblError.setText(
+ Messages.getString("error.Title") + ": " + errorMessage);
+ }
+
+ public String getRefVal() { return this.refVal; }
+ public void setRefVal(String refVal) {
+ this.refVal = (refVal != null) ? refVal.trim() : null;
+ this.lblRefVal.setText(Objects.requireNonNullElse(this.refVal, ""));
+ }
+
+ private void updateQRImage() {
+ if (this.currentQRImage == null)
+ return;
+
+ Point availableSize = this.lblQR.getSize();
+ int targetSize = Math.min(availableSize.x, availableSize.y);
+ if (targetSize <= 0)
+ return;
+
+ this.lblQR.setImage(new Image(this.lblQR.getDisplay(), this.currentQRImage.scaledTo(targetSize, targetSize)));
+ }
+
+ /**
+ * @param qrcode
+ * the qrcode to set
+ */
+ public void setQR(byte[] qrcode) {
+ if (qrcode == null) {
+ setErrorMessage(Messages.getString("error.FailedToLoadQRCode"));
+ return;
+ }
+ try {
+ this.currentQRImage = new ImageData(new ByteArrayInputStream(qrcode));
+ } catch (SWTException e) {
+ log.warn("Failed to load QR code", e);
+ setErrorMessage(Messages.getString("error.FailedToLoadQRCode"));
+ return;
+ }
+ updateQRImage();
+ }
+
+ public void setSMSEnabled(boolean state) {
+ this.btn_sms.setEnabled(state);
+ }
+
+ public void setFIDO2Enabled(boolean state) {
+ this.btn_fido2.setEnabled(state);
+ }
+
+ public void setSignatureDataURI(@Nullable URI uri) {
+ this.signatureDataURI = uri;
+ this.lnk_sig_data.setEnabled(uri != null);
+ }
+
+ /**
+ * Create the composite.
+ *
+ * @param parent
+ * @param style
+ * @param state
+ */
+ public MobileBKUQRComposite(Composite parent, int style, State state) {
+ super(parent, style, state);
+ setLayout(new FormLayout());
+
+ final Composite containerComposite = new Composite(this, SWT.NATIVE);
+ SWTUtils.anchor(containerComposite).top(50, -140).bottom(50, 140).left(50, -200).right(50, 200);
+ containerComposite.addPaintListener(new PaintListener() {
+ @Override
+ public void paintControl(PaintEvent e) {
+ Rectangle clientArea = containerComposite.getClientArea();
+
+ // e.gc.setForeground();
+ e.gc.setForeground(Constants.MAINBAR_ACTIVE_BACK_DARK);
+ e.gc.setLineWidth(3);
+ e.gc.setLineStyle(SWT.LINE_SOLID);
+ e.gc.drawRoundRectangle(clientArea.x, clientArea.y,
+ clientArea.width - 2, clientArea.height - 2, 10, 10);
+ }
+ });
+ containerComposite.setLayout(new FormLayout());
+
+ this.lblRefValLabel = new Label(containerComposite, SWT.NATIVE);
+ SWTUtils.anchor(lblRefValLabel).right(50, -10).top(30, -10);
+ this.lblRefValLabel.setAlignment(SWT.RIGHT);
+
+ ImageData mobileIcon = new ImageData(this.getClass().getResourceAsStream(Constants.RES_IMG_MOBILE));
+ Label lbl_image = new Label(containerComposite, SWT.NATIVE);
+ SWTUtils.anchor(lbl_image).top(50, -1 * (mobileIcon.width / 2)).bottom(50, mobileIcon.width / 2).left(0, 10).width(mobileIcon.width);
+ lbl_image.setImage(new Image(getDisplay(), mobileIcon));
+
+ this.lblRefVal = new Label(containerComposite, SWT.NATIVE);
+ SWTUtils.anchor(lblRefVal).left(50, 10).right(100, -20).top(30, -10);
+
+ this.lblQRLabel = new Label(containerComposite, SWT.NATIVE);
+ SWTUtils.anchor(lblQRLabel).right(50, -10).top(lblRefValLabel, 10);
+ this.lblQRLabel.setAlignment(SWT.RIGHT);
+
+ this.lblQR = new Label(containerComposite, SWT.NATIVE);
+ this.lblQR.addListener(SWT.Resize, (e) -> { updateQRImage(); });
+
+ this.lnk_sig_data = new Link(containerComposite, SWT.NATIVE | SWT.RESIZE);
+ SWTUtils.anchor(lnk_sig_data).right(100, -20).top(0, 20);
+ SWTUtils.addSelectionListener(lnk_sig_data, (e) -> { SWTUtils.openURL(this.signatureDataURI); });
+
+ this.btn_cancel = new Button(containerComposite, SWT.NATIVE);
+ SWTUtils.anchor(btn_cancel).right(100, -20).bottom(100, -5);
+ SWTUtils.addSelectionListener(btn_cancel, (e) -> { this.userCancelClicked = true; });
+
+ this.btn_sms = new Button(containerComposite, SWT.NATIVE);
+ SWTUtils.anchor(btn_sms).right(btn_cancel, -20).bottom(100, -5);
+ SWTUtils.addSelectionListener(btn_sms, (e) -> { this.userSMSClicked = true; });
+
+ this.btn_fido2 = new Button(containerComposite, SWT.NATIVE);
+ SWTUtils.anchor(btn_fido2).right(btn_sms, -20).bottom(100, -5);
+ SWTUtils.addSelectionListener(btn_fido2, (e) -> {this.userFIDO2Clicked = true; });
+
+
+ SWTUtils.anchor(lblQR).left(50, 10).right(100, -20).top(lblRefVal, 10).bottom(btn_sms, -10);
+
+ this.lblError = new Label(containerComposite, SWT.WRAP | SWT.NATIVE);
+ SWTUtils.anchor(lblError).right(btn_sms, -10).bottom(100, -20);
+
+ reloadResources();
+ }
+
+ @Override
+ protected void checkSubclass() {
+ // Disable the check that prevents subclassing of SWT components
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see at.asit.pdfover.gui.composites.StateComposite#doLayout()
+ */
+ @Override
+ public void doLayout() {
+ // Nothing to do
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see at.asit.pdfover.gui.composites.StateComposite#reloadResources()
+ */
+ @Override
+ public void reloadResources() {
+ SWTUtils.setLocalizedText(lblRefValLabel, "tanEnter.ReferenceValue");
+ SWTUtils.setLocalizedText(lblQRLabel, "tanEnter.QR");
+ SWTUtils.setLocalizedText(lnk_sig_data, "mobileBKU.show");
+ SWTUtils.setLocalizedToolTipText(lnk_sig_data, "mobileBKU.show_tooltip");
+ SWTUtils.setLocalizedText(btn_cancel, "common.Cancel");
+ SWTUtils.setLocalizedText(btn_sms, "tanEnter.SMS");
+ SWTUtils.setLocalizedText(btn_fido2, "tanEnter.FIDO2");
+ }
+}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/mobilebku/WaitingForAppComposite.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/mobilebku/WaitingForAppComposite.java
new file mode 100644
index 00000000..7d5b4dfd
--- /dev/null
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/mobilebku/WaitingForAppComposite.java
@@ -0,0 +1,121 @@
+/*
+ * Copyright 2012 by A-SIT, Secure Information Technology Center Austria
+ *
+ * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
+ * the European Commission - subsequent versions of the EUPL (the "Licence");
+ * You may not use this work except in compliance with the Licence.
+ * You may obtain a copy of the Licence at:
+ * http://joinup.ec.europa.eu/software/page/eupl
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the Licence is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the Licence for the specific language governing permissions and
+ * limitations under the Licence.
+ */
+package at.asit.pdfover.gui.composites;
+
+
+// Imports
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.FormLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.ProgressBar;
+import at.asit.pdfover.gui.utils.SWTUtils;
+import at.asit.pdfover.gui.workflow.states.State;
+import org.eclipse.swt.widgets.Button;
+
+/**
+ *
+ */
+public class WaitingForAppComposite extends StateComposite {
+ private Label lbl_description;
+ private Button btn_sms;
+ private Button btn_cancel;
+ private Button btn_fido2;
+ private boolean userSMSClicked = false;
+ private boolean userCancelClicked = false;
+ private boolean userFIDO2Clicked = false;
+ private boolean pollingDone = false;
+
+ /**
+ * @return the isDone
+ */
+ public Boolean getIsDone() {
+ return this.pollingDone;
+ }
+
+ public void signalPollingDone() { this.pollingDone = true; getDisplay().wake(); }
+ public boolean isDone() { return (this.userCancelClicked || this.userSMSClicked || this.userFIDO2Clicked || this.pollingDone); }
+ public boolean wasCancelClicked() { return this.userCancelClicked; }
+ public boolean wasSMSClicked() { return this.userSMSClicked; }
+ public boolean wasFIDO2Clicked() { return this.userFIDO2Clicked; }
+ public void reset() { this.userCancelClicked = this.userSMSClicked = this.userFIDO2Clicked = this.pollingDone = false; }
+
+ public void setSMSEnabled(boolean state) {
+ this.btn_sms.setEnabled(state);
+ }
+
+ public void setFIDO2Enabled(boolean state) {
+ this.btn_fido2.setEnabled(state);
+ }
+
+ /**
+ * Create the composite.
+ * @param parent
+ * @param style
+ * @param state
+ */
+ public WaitingForAppComposite(Composite parent, int style, State state) {
+ super(parent, style, state);
+ setLayout(new FormLayout());
+
+ this.lbl_description = new Label(this, SWT.NATIVE);
+ SWTUtils.anchor(lbl_description).bottom(50, -1).left(0, 10).right(100, -10);
+ this.lbl_description.setAlignment(SWT.CENTER);
+ SWTUtils.setLocalizedText(lbl_description, "waiting_for_app.message");
+
+ ProgressBar progressBar = new ProgressBar(this, SWT.HORIZONTAL | SWT.INDETERMINATE);
+ SWTUtils.anchor(progressBar).top(50, 10).bottom(50, 40).left(50,-100).right(50,100);
+
+ this.btn_sms = new Button(this, SWT.NONE);
+ SWTUtils.anchor(btn_sms).top(progressBar, 24).right(progressBar, 0, SWT.RIGHT);
+ SWTUtils.addSelectionListener(btn_sms, (e) -> { this.userSMSClicked = true; });
+
+ this.btn_cancel = new Button(this, SWT.NONE);
+ SWTUtils.anchor(btn_cancel).top(btn_sms, 0, SWT.TOP).right(btn_sms, -6);
+ SWTUtils.addSelectionListener(btn_cancel, (e) -> { this.userCancelClicked = true; });
+
+ this.btn_fido2 = new Button(this, SWT.NONE);
+ SWTUtils.anchor(btn_fido2).top(btn_cancel, 0, SWT.TOP).right(btn_cancel, -6);
+ SWTUtils.addSelectionListener(btn_fido2, (e) -> { this.userFIDO2Clicked = true; });
+
+ reloadResources();
+
+ }
+
+ @Override
+ protected void checkSubclass() {
+ // Disable the check that prevents subclassing of SWT components
+ }
+
+ /* (non-Javadoc)
+ * @see at.asit.pdfover.gui.composites.StateComposite#doLayout()
+ */
+ @Override
+ public void doLayout() {
+ // Nothing to do here
+ }
+
+ /* (non-Javadoc)
+ * @see at.asit.pdfover.gui.composites.StateComposite#reloadResources()
+ */
+ @Override
+ public void reloadResources() {
+ SWTUtils.setLocalizedText(lbl_description, "waiting_for_app.message");
+ SWTUtils.setLocalizedText(btn_sms, "tanEnter.SMS");
+ SWTUtils.setLocalizedText(btn_fido2, "tanEnter.FIDO2");
+ SWTUtils.setLocalizedText(btn_cancel, "common.Cancel");
+ }
+}
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 8a0c95df..48415ab5 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
@@ -18,7 +18,6 @@ package at.asit.pdfover.gui.workflow.states;
import java.io.IOException;
import java.net.ConnectException;
import java.net.URI;
-import java.net.URISyntaxException;
import java.net.UnknownHostException;
import java.util.Timer;
import java.util.TimerTask;
@@ -28,8 +27,6 @@ import javax.annotation.Nonnull;
import javax.annotation.Nullable;
// Imports
-import at.asit.pdfover.gui.exceptions.ATrustConnectionException;
-import at.asit.pdfover.signer.SignatureException;
import at.asit.pdfover.signer.UserCancelledException;
import at.asit.pdfover.signer.pdfas.PdfAs4SigningState;
@@ -364,40 +361,9 @@ public class MobileBKUState extends State {
}
/**
- * Make sure TAN is set in the MobileBKUStatus
- */
- public void OLDcheckTAN() throws URISyntaxException {
- final ATrustStatus mobileStatus = this.status;
-
- try {
- SMSTanResult result = getSMSTanFromUser(mobileStatus.refVal, mobileStatus.tanTries, new URI(mobileStatus.signatureDataURL), false, mobileStatus.errorMessage);
- if (result.type == SMSTanResult.ResultType.SMSTAN) {
- mobileStatus.tan = result.smsTan;
- }
- } catch (UserCancelledException e) {
- clearRememberedPassword();
- mobileStatus.errorMessage = "cancel";
- }
- }
-
- public enum QRResult {
- /* the user has pressed the FIDO2 button */
- TO_FIDO2,
- /* the user has pressed the SMS button */
- TO_SMS,
- /* signalQRScanned has been called; this indicates that we should refresh the page */
- UPDATE
- };
-
- /**
* start showing the QR code at the indicated URI
- * this method will block until the QR code state completes
- * (due to QR code being scanned, or the user pressing a button)
- * <p>
- * it is the responsibility of the caller to perform AJAX long polling
- * @return
- */
- public QRResult showQRCode(final @Nonnull String referenceValue, @Nonnull URI qrCodeURI, @Nullable URI signatureDataURI, final boolean showSmsTan, final boolean showFido2, final @Nullable String errorMessage) throws UserCancelledException {
+ * this method will return immediately */
+ public void showQRCode(final @Nonnull String referenceValue, @Nonnull URI qrCodeURI, @Nullable URI signatureDataURI, final boolean showSmsTan, final boolean showFido2, final @Nullable String errorMessage) {
byte[] qrCode;
try (final CloseableHttpClient httpClient = HttpClients.createDefault()) {
try (final CloseableHttpResponse response = httpClient.execute(new HttpGet(qrCodeURI))) {
@@ -409,7 +375,7 @@ public class MobileBKUState extends State {
}
final byte[] qrCodeCopy = qrCode; /* because java is silly */
- return Display.getDefault().syncCall(() -> {
+ Display.getDefault().syncExec(() -> {
MobileBKUQRComposite qr = getMobileBKUQRComposite();
qr.reset();
@@ -420,6 +386,21 @@ public class MobileBKUState extends State {
qr.setSMSEnabled(showSmsTan);
qr.setFIDO2Enabled(showFido2);
getStateMachine().display(qr);
+ });
+ }
+
+ public enum QRResult {
+ /* the user has pressed the FIDO2 button */
+ TO_FIDO2,
+ /* the user has pressed the SMS button */
+ TO_SMS,
+ /* signalQRScanned has been called; this indicates that we should refresh the page */
+ UPDATE
+ };
+
+ public QRResult waitForQRCodeResult() throws UserCancelledException {
+ return Display.getDefault().syncCall(() -> {
+ MobileBKUQRComposite qr = getMobileBKUQRComposite();
Display display = getStateMachine().getMainShell().getDisplay();
while (!qr.isDone()) {
@@ -447,117 +428,69 @@ public class MobileBKUState extends State {
/**
* indicate that the long polling operation completed
- * (any ongoing showQRCode call will then return)
+ * (any ongoing waitForQRCodeResult call will then return)
*/
public void signalQRScanned() {
getMobileBKUQRComposite().signalPollingDone();
}
/**
- * Show QR code
- * @throws URISyntaxException
- * @throws UserCancelledException
- * @throws IOException
- */
- public void OLDshowQR() throws IOException, UserCancelledException, URISyntaxException {
- final ATrustStatus status = this.status;
- final ATrustHandler handler = this.handler;
-
- final Timer checkDone = new Timer();
- checkDone.scheduleAtFixedRate(new TimerTask() {
- @Override
- public void run() {
- // ping signature page to see if code has been scanned
- try {
- String resp = handler.getSignaturePage();
- if (handler.handleQRResponse(resp)) {
- log.debug("Signature page response: " + resp);
- checkDone.cancel();
- signalQRScanned();
- }
- Display.getDefault().wake();
- } catch (Exception e) {
- log.error("Error getting signature page", e);
- }
- }
- }, 0, 5000);
+ * start showing the "waiting for app" screen
+ * this method will return immediately */
+ public void showWaitingForApp(final @Nonnull String referenceValue, @Nullable URI signatureDataURI, final boolean showSmsTan, final boolean showFido2) {
+ Display.getDefault().syncExec(() -> {
+ WaitingForAppComposite wfa = getWaitingForAppComposite();
+ wfa.reset();
- QRResult result = showQRCode(status.refVal, new URI(status.baseURL).resolve(status.qrCodeURL), new URI(status.baseURL).resolve(status.signatureDataURL), true, false, status.errorMessage);
- checkDone.cancel();
- if (result == QRResult.TO_SMS)
- status.qrCodeURL = null;
+ // TODO composite does not currently support: refval, signature data
+ wfa.setSMSEnabled(showSmsTan);
+ wfa.setFIDO2Enabled(showFido2);
+ getStateMachine().display(wfa);
+ });
}
- /**
- * This composite notifies the user to open the signature-app
- */
- public void showOpenAppMessageWithSMSandCancel() throws SignatureException {
-
- final ATrustStatus status = this.status;
-
- Display.getDefault().syncExec(() -> {
- WaitingForAppComposite waitingForAppcomposite = this.getWaitingForAppComposite();
- getStateMachine().display(waitingForAppcomposite);
+ public enum AppOpenResult {
+ /* the user has pressed the FIDO2 button */
+ TO_FIDO2,
+ /* the user has pressed the SMS button */
+ TO_SMS,
+ /* signalAppOpened has been called; this indicates that we should refresh the page */
+ UPDATE
+ };
- Display display = getStateMachine().getMainShell().getDisplay();
- undecidedPolling();
- long timeoutTime = System.nanoTime() + (300 * ((long)1e9));
+ public AppOpenResult waitForAppOpen() throws UserCancelledException {
+ return Display.getDefault().syncCall(() -> {
+ WaitingForAppComposite wfa = getWaitingForAppComposite();
- while (!waitingForAppcomposite.getUserCancel() && !waitingForAppcomposite.getUserSMS()
- && !waitingForAppcomposite.getIsDone() && (System.nanoTime() < timeoutTime)) {
- if (!display.readAndDispatch()) {
+ Display display = wfa.getDisplay();
+ while (!wfa.isDone()) {
+ if (!display.readAndDispatch())
display.sleep();
- }
- }
-
- if (waitingForAppcomposite.getUserCancel()) {
- waitingForAppcomposite.setUserCancel(false);
- status.errorMessage = "cancel";
- return;
}
- if (waitingForAppcomposite.getUserSMS()) {
- status.qrCodeURL = null;
- waitingForAppcomposite.setUserSMS(false);
- status.errorMessage = "sms";
- status.isSMSTan = true;
- // show waiting composite
- getStateMachine().display(this.getWaitingComposite());
- return;
+ getStateMachine().display(this.getWaitingComposite());
+ if (wfa.wasCancelClicked()) {
+ clearRememberedPassword();
+ throw new UserCancelledException();
}
- if (waitingForAppcomposite.getIsDone())
- waitingForAppcomposite.setIsDone(false);
-
- if (!(System.nanoTime() < timeoutTime)) {
- log.warn("The undecided polling got a timeout");
- status.qrCodeURL = null;
- status.errorMessage = "Polling Timeout";
-
+ if (wfa.wasSMSClicked())
+ return AppOpenResult.TO_SMS;
+
+ if (wfa.wasFIDO2Clicked())
+ return AppOpenResult.TO_FIDO2;
- }
+ return AppOpenResult.UPDATE;
});
}
- private void undecidedPolling(){
- final ATrustHandler handler = this.handler;
-
- Thread pollingThread = new Thread(() -> {
- try {
- if (handler.handlePolling()){
- String response = handler.getSignaturePage();
- handler.handleCredentialsResponse(response);
- Display.getDefault().syncExec(() ->
- getWaitingForAppComposite().setIsDone(true));
- }
- } catch (ATrustConnectionException e) {
- log.error("Error when calling polling endpoint");
- } catch (Exception e) {
- log.error("Exception occurred during calling polling endpoint");
- }
- });
- pollingThread.start();
+ /**
+ * indicate that the long polling operation completed
+ * (any ongoing waitForAppOpen call will then return)
+ */
+ public void signalAppOpened() {
+ getWaitingForAppComposite().signalPollingDone();
}
/**
diff --git a/pdf-over-gui/src/main/resources/logback.xml b/pdf-over-gui/src/main/resources/logback.xml
index 4e33264a..866a82f7 100644
--- a/pdf-over-gui/src/main/resources/logback.xml
+++ b/pdf-over-gui/src/main/resources/logback.xml
@@ -22,7 +22,6 @@
</triggeringPolicy>
</appender>
<logger name="at.asit.pdfover" level="INFO"/>
- <logger name="at.asit.pdfover.gui.bku" level="TRACE"/>
<root level="WARN">
<appender-ref ref="STDOUT"/>
<appender-ref ref="LOGFILE"/>