summaryrefslogtreecommitdiff
path: root/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow
diff options
context:
space:
mode:
Diffstat (limited to 'pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow')
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/MobileBKUState.java92
1 files changed, 91 insertions, 1 deletions
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 5d97262c..bd88b48d 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
@@ -15,6 +15,10 @@
*/
package at.asit.pdfover.gui.workflow.states;
+import java.io.InputStream;
+import java.util.Timer;
+import java.util.TimerTask;
+
// Imports
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Display;
@@ -32,6 +36,7 @@ import at.asit.pdfover.gui.bku.mobile.MobileBKUHandler;
import at.asit.pdfover.gui.bku.mobile.MobileBKUStatus;
import at.asit.pdfover.gui.composites.MobileBKUEnterNumberComposite;
import at.asit.pdfover.gui.composites.MobileBKUEnterTANComposite;
+import at.asit.pdfover.gui.composites.MobileBKUQRComposite;
import at.asit.pdfover.gui.composites.WaitingComposite;
import at.asit.pdfover.gui.controls.Dialog.BUTTONS;
import at.asit.pdfover.gui.controls.ErrorDialog;
@@ -70,7 +75,7 @@ public class MobileBKUState extends State {
/**
* SLF4J Logger instance
**/
- private static final Logger log = LoggerFactory
+ static final Logger log = LoggerFactory
.getLogger(MobileBKUState.class);
SigningState signingState;
@@ -85,6 +90,8 @@ public class MobileBKUState extends State {
MobileBKUEnterTANComposite mobileBKUEnterTANComposite = null;
+ MobileBKUQRComposite mobileBKUQRComposite = null;
+
WaitingComposite waitingComposite = null;
WaitingComposite getWaitingComposite() {
@@ -106,6 +113,16 @@ public class MobileBKUState extends State {
return this.mobileBKUEnterTANComposite;
}
+ MobileBKUQRComposite getMobileBKUQRComposite() {
+ if (this.mobileBKUQRComposite == null) {
+ this.mobileBKUQRComposite = getStateMachine()
+ .getGUIProvider().createComposite(
+ MobileBKUQRComposite.class, SWT.RESIZE, this);
+ }
+
+ return this.mobileBKUQRComposite;
+ }
+
MobileBKUEnterNumberComposite getMobileBKUEnterNumberComposite() {
if (this.mobileBKUEnterNumberComposite == null) {
this.mobileBKUEnterNumberComposite = getStateMachine()
@@ -311,6 +328,79 @@ public class MobileBKUState extends State {
});
}
+ /**
+ * Show QR code
+ */
+ public void showQR() {
+ final ATrustStatus status = (ATrustStatus) this.getStatus();
+ final ATrustHandler handler = (ATrustHandler) this.getHandler();
+
+ final Timer checkDone = new Timer(true);
+ 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); //$NON-NLS-1$
+ getMobileBKUQRComposite().setDone(true);
+ Display display = getStateMachine().getGUIProvider().
+ getMainShell().getDisplay();
+ display.wake();
+ }
+ Display.getDefault().wake();
+ } catch (Exception e) {
+ log.error("Error getting signature page", e); //$NON-NLS-1$
+ }
+ }
+ }, 0, 5000);
+ Display.getDefault().syncExec(new Runnable() {
+ @Override
+ public void run() {
+ MobileBKUQRComposite qr = getMobileBKUQRComposite();
+
+ qr.setRefVal(status.getRefVal());
+ qr.setSignatureData(status.getSignatureDataURL());
+ qr.setErrorMessage(status.getErrorMessage());
+ InputStream qrcode = handler.getQRCode();
+ if (qrcode == null) {
+ MobileBKUState.this.threadException = new Exception(
+ Messages.getString("error.FailedToLoadQRCode")); //$NON-NLS-1$
+ }
+ qr.setQR(qrcode);
+ getStateMachine().getGUIProvider().display(qr);
+
+ Display display = getStateMachine().getGUIProvider().getMainShell().getDisplay();
+ while (!qr.isUserCancel() && !qr.isUserSMS() && !qr.isDone()) {
+ if (!display.readAndDispatch()) {
+ display.sleep();
+ }
+ }
+ checkDone.cancel();
+
+ if (qr.isUserCancel()) {
+ qr.setUserCancel(false);
+ status.setErrorMessage("cancel"); //$NON-NLS-1$
+ return;
+ }
+
+ if (qr.isUserSMS()) {
+ qr.setUserSMS(false);
+ status.setQRCode(null);
+ }
+
+ if (qr.isDone())
+ qr.setDone(false);
+
+ // show waiting composite
+ getStateMachine().getGUIProvider().display(
+ MobileBKUState.this.getWaitingComposite());
+ }
+ });
+ }
+
/*
* (non-Javadoc)
*