diff options
5 files changed, 47 insertions, 20 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 98f6fe3f..e80d23a3 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 @@ -52,7 +52,7 @@ public class MobileBKUState extends State { switch(this.stateMachine.getConfigProvider().getMobileBKUType()) { case A_TRUST: this.status = new ATrustStatus(this.stateMachine.getConfigProvider()); - this.handler = new ATrustHandler(this); + this.handler = new ATrustHandler(this, this.stateMachine.getGUIProvider().getMainShell()); break; case IAIK: @@ -204,6 +204,7 @@ public class MobileBKUState extends State { new PostSLRequestThread(this)); postSLRequestThread.start(); break; + case POST_NUMBER: // Check if number and password is set ... // if not show UI @@ -269,6 +270,7 @@ public class MobileBKUState extends State { } } break; + case POST_TAN: // Get TAN from UI @@ -303,11 +305,15 @@ public class MobileBKUState extends State { tan.enableButton(); this.stateMachine.getGUIProvider().display(tan); } - break; + case FINAL: this.setNextState(new SigningState(this.stateMachine)); break; + + case CANCEL: + this.setNextState(new BKUSelectionState(this.stateMachine)); + break; } } diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/mobilebku/ATrustHandler.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/mobilebku/ATrustHandler.java index dcab0641..0ce95c4e 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/mobilebku/ATrustHandler.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/mobilebku/ATrustHandler.java @@ -21,9 +21,16 @@ import java.io.IOException; import org.apache.commons.httpclient.HttpClient; import org.apache.commons.httpclient.methods.PostMethod; import org.apache.commons.httpclient.protocol.Protocol; +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Shell; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import at.asit.pdfover.gui.controls.Dialog; +import at.asit.pdfover.gui.controls.Dialog.BUTTONS; +import at.asit.pdfover.gui.controls.Dialog.ICON; +import at.asit.pdfover.gui.utils.Messages; import at.asit.pdfover.gui.workflow.states.LocalBKUState; import at.asit.pdfover.gui.workflow.states.MobileBKUState; import at.asit.pdfover.signator.SLResponse; @@ -32,11 +39,15 @@ import at.asit.pdfover.signator.SLResponse; * A-Trust mobile BKU handler */ public class ATrustHandler extends MobileBKUHandler { + Shell shell; + /** * @param state + * @param shell */ - public ATrustHandler(MobileBKUState state) { + public ATrustHandler(MobileBKUState state, Shell shell) { super(state); + this.shell = shell; } /** @@ -196,8 +207,21 @@ public class ATrustHandler extends MobileBKUHandler { } if (getStatus().getTanTries() <= 0) { - // move to POST_REQUEST - getState().setCommunicationState(MobileBKUCommunicationState.POST_REQUEST); + Display.getDefault().syncExec(new Runnable() { + @Override + public void run() { + Dialog dialog = new Dialog(ATrustHandler.this.shell, Messages.getString("common.warning"), //$NON-NLS-1$ + Messages.getString("mobileBKU.tan_tries_exceeded"), //$NON-NLS-1$ + BUTTONS.OK_CANCEL, ICON.QUESTION); + if (dialog.open() == SWT.CANCEL) { + // Cancel + getState().setCommunicationState(MobileBKUCommunicationState.CANCEL); + } else { + // move to POST_REQUEST again + getState().setCommunicationState(MobileBKUCommunicationState.POST_REQUEST); + } + } + }); } } } diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/mobilebku/MobileBKUCommunicationState.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/mobilebku/MobileBKUCommunicationState.java index 339f2db3..de6e777c 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/mobilebku/MobileBKUCommunicationState.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/mobilebku/MobileBKUCommunicationState.java @@ -20,23 +20,18 @@ package at.asit.pdfover.gui.workflow.states.mobilebku; */ public enum MobileBKUCommunicationState { - /** - * POST SL Request to A-Trust BKU - */ + /** POST SL Request to A-Trust BKU */ POST_REQUEST, - /** - * POST User informations (number, password) to A-Trust BKU - */ + /** POST User informations (number, password) to A-Trust BKU */ POST_NUMBER, - /** - * POST tan to A-Trust BKU and retrieve SL Response - */ + /** POST tan to A-Trust BKU and retrieve SL Response */ POST_TAN, - /** - * Final state - */ - FINAL + /** Final state */ + FINAL, + + /** Cancel state */ + CANCEL } diff --git a/pdf-over-gui/src/main/resources/at/asit/pdfover/gui/messages.properties b/pdf-over-gui/src/main/resources/at/asit/pdfover/gui/messages.properties index b9fe3348..caf3bddf 100644 --- a/pdf-over-gui/src/main/resources/at/asit/pdfover/gui/messages.properties +++ b/pdf-over-gui/src/main/resources/at/asit/pdfover/gui/messages.properties @@ -101,7 +101,8 @@ main.title=PDF-Over mobileBKU.number=Number: mobileBKU.password=Password: mobileBKU.show=<a>Show signature data</a> -mobileBKU.show_tooltip=Show signature data +mobileBKU.show_tooltip=Shows the data to be signed +mobileBKU.tan_tries_exceeded=TAN tries exceeded, request a new TAN? output.file_ask_overwrite=File %s already exists, do you want to overwrite it? output.link_open_message=You can open the signed file <a>here</a> output.link_save_message=You can save the signed file diff --git a/pdf-over-gui/src/main/resources/at/asit/pdfover/gui/messages_de.properties b/pdf-over-gui/src/main/resources/at/asit/pdfover/gui/messages_de.properties index 5b59ccca..bba26c83 100644 --- a/pdf-over-gui/src/main/resources/at/asit/pdfover/gui/messages_de.properties +++ b/pdf-over-gui/src/main/resources/at/asit/pdfover/gui/messages_de.properties @@ -101,7 +101,8 @@ main.title=PDF-Over mobileBKU.number=Nummer: mobileBKU.password=Passwort: mobileBKU.show=<a>Signaturdaten anzeigen</a> -mobileBKU.show_tooltip=Zeigt die Signaturdaten an +mobileBKU.show_tooltip=Zeigt die zu signierenden Daten an +mobileBKU.tan_tries_exceeded=Zu viele TAN-Versuche, neue TAN anfordern? output.file_ask_overwrite=Datei %s existiert bereits, wollen Sie sie überschreiben? output.link_open_message=Sie können das signierte Dokument <a>hier</a> öffnen output.link_save_message=Sie können das signierte Dokument speichern |