summaryrefslogtreecommitdiff
path: root/pdf-over-gui/src/main/java/at/asit
diff options
context:
space:
mode:
authorAndreas Abraham <andreas.abraham@egiz.gv.at>2018-08-07 16:18:08 +0200
committerAndreas Abraham <andreas.abraham@egiz.gv.at>2018-08-07 16:18:08 +0200
commite7e98e908d4b71e875e9ff6d31dea052e5c9f3b8 (patch)
treef1ac2a92ad7ee77eb9ebed4918bee73bc50747bd /pdf-over-gui/src/main/java/at/asit
parenta449f6dddc8ee3ed55fccc0396600ccefc8d6834 (diff)
downloadpdf-over-e7e98e908d4b71e875e9ff6d31dea052e5c9f3b8.tar.gz
pdf-over-e7e98e908d4b71e875e9ff6d31dea052e5c9f3b8.tar.bz2
pdf-over-e7e98e908d4b71e875e9ff6d31dea052e5c9f3b8.zip
pdf-over support for fingerprint and faceid implemented
Diffstat (limited to 'pdf-over-gui/src/main/java/at/asit')
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/MobileBKUConnector.java36
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/ATrustHandler.java869
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/ATrustStatus.java270
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/MobileBKUEnterTANComposite.java968
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/MobileBKUFingerprintComposite.java10
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/MobileBKUState.java1066
6 files changed, 1691 insertions, 1528 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 1a5c822b..b9f77a45 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
@@ -15,6 +15,8 @@
*/
package at.asit.pdfover.gui.bku;
+import java.io.IOException;
+
// Imports
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -88,8 +90,6 @@ public class MobileBKUConnector implements BkuSlConnector {
try {
String responseData = handler.postCredentials();
- //TODO check the response data to determine authentication method
-
// Now we have received some data lets check it:
log.trace("Response from mobile BKU: " + responseData); //$NON-NLS-1$
@@ -136,8 +136,38 @@ public class MobileBKUConnector implements BkuSlConnector {
enterTAN = false;
}
}
+ if (enterTAN) {
+ try {
+ this.state.showFingerPrintInformation();
+ if (this.state.getStatus().getErrorMessage() != null &&
+ this.state.getStatus().getErrorMessage().equals("cancel")) //$NON-NLS-1$
+ throw new SignatureException(new IllegalStateException());
+ } catch (Exception ex) {
+ log.error("Error in PostCredentialsThread", ex); //$NON-NLS-1$
+ this.state.setThreadException(ex);
+ this.state.displayError(ex);
+ throw new SignatureException(ex);
+ }
+
+ if (this.state.getSMSStatus()) {
+ String response;
+ try {
+ response = aHandler.postSMSRequest();
+ handler.handleCredentialsResponse(response);
+ } catch (Exception e) {
+ log.error("Error in PostCredentialsThread", e); //$NON-NLS-1$
+ this.state.setThreadException(e);
+ this.state.displayError(e);
+ throw new SignatureException(e);
+ }
+ }
+ else {
+ enterTAN = false;
+ }
+ }
}
- if (enterTAN) {
+
+ if (enterTAN || this.state.getSMSStatus()) {
// Get TAN
this.state.checkTAN();
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/ATrustHandler.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/ATrustHandler.java
index 5e65f81e..eaa0327a 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/ATrustHandler.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/ATrustHandler.java
@@ -1,427 +1,442 @@
-/*
- * 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.bku.mobile;
-
-// Imports
-import java.awt.Desktop;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URI;
-
-import org.apache.commons.httpclient.HttpClient;
-import org.apache.commons.httpclient.HttpStatus;
-import org.apache.commons.httpclient.methods.GetMethod;
-import org.apache.commons.httpclient.methods.PostMethod;
-import org.apache.commons.lang3.StringEscapeUtils;
-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.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.MobileBKUState;
-import at.asit.pdfover.signator.SLResponse;
-import at.asit.pdfover.signator.SignatureException;
-
-/**
- * A-Trust mobile BKU handler
- */
-public class ATrustHandler extends MobileBKUHandler {
- Shell shell;
-
- /**
- * @param state
- * @param shell
- * @param useBase64
- */
- public ATrustHandler(MobileBKUState state, Shell shell, boolean useBase64) {
- super(state);
- this.shell = shell;
- this.useBase64 = useBase64;
- }
-
- /**
- * SLF4J Logger instance
- **/
- static final Logger log = LoggerFactory
- .getLogger(ATrustHandler.class);
-
- private static boolean expiryNoticeDisplayed = false;
-
- private static final String ACTIVATION_URL = "https://www.handy-signatur.at/"; //$NON-NLS-1$
-
- private boolean useBase64 = false;
-
- /* (non-Javadoc)
- * @see at.asit.pdfover.gui.workflow.states.mobilebku.MobileBKUHandler#handleSLRequestResponse(java.lang.String)
- */
- @Override
- public void handleSLRequestResponse(String responseData) throws Exception {
- ATrustStatus status = getStatus();
-
- if (responseData.contains("<sl:ErrorResponse")) { //$NON-NLS-1$
- String errorCode = MobileBKUHelper.extractSubstring(responseData,
- "<sl:ErrorCode>", "</sl:ErrorCode>"); //$NON-NLS-1$ //$NON-NLS-2$
- String errorMsg = MobileBKUHelper.extractSubstring(responseData,
- "<sl:Info>", "</sl:Info>"); //$NON-NLS-1$ //$NON-NLS-2$
- throw new Exception("Error from mobile BKU: " + //$NON-NLS-1$
- errorCode + " - " + errorMsg); //$NON-NLS-1$
- }
-
- // Extract infos:
- String sessionID = MobileBKUHelper.extractSubstring(responseData,
- "identification.aspx?sid=", "\""); //$NON-NLS-1$ //$NON-NLS-2$
-
- String viewState = MobileBKUHelper.extractValueFromTagWithParam(
- responseData, "", "id", "__VIEWSTATE", "value"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
-
- String eventValidation = MobileBKUHelper.extractValueFromTagWithParam(
- responseData, "", "id", "__EVENTVALIDATION", "value"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
-
- log.info("sessionID: " + sessionID); //$NON-NLS-1$
- log.info("viewState: " + viewState); //$NON-NLS-1$
- log.info("eventValidation: " + eventValidation); //$NON-NLS-1$
-
- status.setSessionID(sessionID);
-
- status.setViewstate(viewState);
-
- status.setEventvalidation(eventValidation);
- }
-
- /* (non-Javadoc)
- * @see at.asit.pdfover.gui.workflow.states.mobilebku.MobileBKUHandler#postCredentials()
- */
- @Override
- public String postCredentials() throws Exception {
- ATrustStatus status = getStatus();
-
- MobileBKUHelper.registerTrustedSocketFactory();
- HttpClient client = MobileBKUHelper.getHttpClient(getStatus());
-
- PostMethod post = new PostMethod(status.getBaseURL() + "/identification.aspx?sid=" + status.getSessionID()); //$NON-NLS-1$
- post.getParams().setContentCharset("utf-8"); //$NON-NLS-1$
- post.addParameter("__VIEWSTATE", status.getViewstate()); //$NON-NLS-1$
- post.addParameter("__EVENTVALIDATION", status.getEventvalidation()); //$NON-NLS-1$
- post.addParameter("handynummer", status.getPhoneNumber()); //$NON-NLS-1$
- post.addParameter("signaturpasswort", status.getMobilePassword()); //$NON-NLS-1$
- post.addParameter("Button_Identification", "Identifizieren"); //$NON-NLS-1$ //$NON-NLS-2$
-
- return executePost(client, post);
- }
-
- /* (non-Javadoc)
- * @see at.asit.pdfover.gui.workflow.states.mobilebku.MobileBKUHandler#handleCredentialsResponse(java.lang.String)
- */
- @Override
- public void handleCredentialsResponse(String responseData) throws Exception {
- ATrustStatus status = getStatus();
- String viewState = status.getViewstate();
- String eventValidation = status.getEventvalidation();
- String sessionID = status.getSessionID();
- String refVal = null;
- String signatureDataURL = null;
- String qrCode = null;
-
- status.setErrorMessage(null);
-
- if (responseData.contains("ExpiresInfo.aspx?sid=")) { //$NON-NLS-1$
- // Certificate expiration interstitial - skip
- String notice = Messages.getString("mobileBKU.notice") + " " + //$NON-NLS-1$ //$NON-NLS-2$
- StringEscapeUtils.unescapeHtml4(MobileBKUHelper.extractContentFromTagWithParam(responseData, "span", "id", "Label2")) //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- .replaceAll("\\<.*?\\>", ""); //$NON-NLS-1$ //$NON-NLS-2$
- log.info(notice);
-
- if (!expiryNoticeDisplayed) {
- Display.getDefault().syncExec(new Runnable() {
- @Override
- public void run() {
- Dialog d = new Dialog(ATrustHandler.this.shell, Messages.getString("common.info"), Messages.getString("mobileBKU.certExpiresSoon"), BUTTONS.YES_NO, ICON.WARNING); //$NON-NLS-1$ //$NON-NLS-2$
- if (d.open() == SWT.YES) {
- log.debug("Trying to open " + ACTIVATION_URL); //$NON-NLS-1$
- if (Desktop.isDesktopSupported()) {
- try {
- Desktop.getDesktop().browse(new URI(ACTIVATION_URL));
- return;
- } catch (Exception e) {
- log.debug("Error opening URL", e); //$NON-NLS-1$
- }
- }
- log.info("SWT Desktop is not supported on this platform"); //$NON-NLS-1$
- Program.launch(ACTIVATION_URL);
- }
- }
- });
- expiryNoticeDisplayed = true;
- }
-
- String t_sessionID = MobileBKUHelper.extractSubstring(responseData, "ExpiresInfo.aspx?sid=", "\""); //$NON-NLS-1$ //$NON-NLS-2$
- String t_viewState = MobileBKUHelper.extractValueFromTagWithParam(responseData, "", "id", "__VIEWSTATE", "value"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- String t_eventValidation = MobileBKUHelper.extractValueFromTagWithParam(responseData, "", "id", "__EVENTVALIDATION", "value"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
-
- // Post again to skip
- MobileBKUHelper.registerTrustedSocketFactory();
- HttpClient client = MobileBKUHelper.getHttpClient(getStatus());
-
- PostMethod post = new PostMethod(status.getBaseURL() + "/ExpiresInfo.aspx?sid=" + t_sessionID); //$NON-NLS-1$
- post.getParams().setContentCharset("utf-8"); //$NON-NLS-1$
- post.addParameter("__VIEWSTATE", t_viewState); //$NON-NLS-1$
- post.addParameter("__EVENTVALIDATION", t_eventValidation); //$NON-NLS-1$
- post.addParameter("Button_Next", "Weiter"); //$NON-NLS-1$ //$NON-NLS-2$
-
- responseData = executePost(client, post);
- log.trace("Response from mobile BKU: " + responseData); //$NON-NLS-1$
- } else if (responseData.contains("tanAppInfo.aspx?sid=")) { //$NON-NLS-1$
- // App info interstitial - skip
- log.info("Skipping tan app interstitial"); //$NON-NLS-1$
-
- String t_sessionID = MobileBKUHelper.extractSubstring(responseData, "tanAppInfo.aspx?sid=", "\""); //$NON-NLS-1$ //$NON-NLS-2$
- String t_viewState = MobileBKUHelper.extractValueFromTagWithParam(responseData, "", "id", "__VIEWSTATE", "value"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- String t_eventValidation = MobileBKUHelper.extractValueFromTagWithParam(responseData, "", "id", "__EVENTVALIDATION", "value"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
-
- // Post again to skip
- MobileBKUHelper.registerTrustedSocketFactory();
- HttpClient client = MobileBKUHelper.getHttpClient(getStatus());
-
- PostMethod post = new PostMethod(status.getBaseURL() + "/tanAppInfo.aspx?sid=" + t_sessionID); //$NON-NLS-1$
- post.getParams().setContentCharset("utf-8"); //$NON-NLS-1$
- post.addParameter("__VIEWSTATE", t_viewState); //$NON-NLS-1$
- post.addParameter("__EVENTVALIDATION", t_eventValidation); //$NON-NLS-1$
- post.addParameter("NextBtn", "Weiter"); //$NON-NLS-1$ //$NON-NLS-2$
-
- responseData = executePost(client, post);
- log.trace("Response from mobile BKU: " + responseData); //$NON-NLS-1$
- }
-
- if (responseData.contains("signature.aspx?sid=")) { //$NON-NLS-1$
- // credentials ok! TAN entry
- log.debug("Credentials accepted - TAN required"); //$NON-NLS-1$
- sessionID = MobileBKUHelper.extractSubstring(responseData, "signature.aspx?sid=", "\""); //$NON-NLS-1$ //$NON-NLS-2$
- viewState = MobileBKUHelper.extractValueFromTagWithParam(responseData, "", "id", "__VIEWSTATE", "value"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- eventValidation = MobileBKUHelper.extractValueFromTagWithParam(responseData, "", "id", "__EVENTVALIDATION", "value"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- refVal = MobileBKUHelper.extractSubstring(responseData, "id='vergleichswert'><b>Vergleichswert:</b>", "</div>"); //$NON-NLS-1$ //$NON-NLS-2$
- signatureDataURL = status.getBaseURL() + "/ShowSigobj.aspx" + //$NON-NLS-1$
- MobileBKUHelper.extractSubstring(responseData, "ShowSigobj.aspx", "'"); //$NON-NLS-1$ //$NON-NLS-2$
- try {
- qrCode = MobileBKUHelper.extractValueFromTagWithParam(responseData, "img", "class", "qrcode", "src"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- log.debug("QR Code found: " + qrCode); //$NON-NLS-1$
- status.setQRCode(qrCode);
- } catch (Exception e) {
- log.debug("No QR Code found"); //$NON-NLS-1$
- }
- } else if (responseData.contains("sl:InfoboxReadResponse")) { //$NON-NLS-1$
- // credentials ok! InfoboxReadResponse
- log.debug("Credentials accepted - Response given"); //$NON-NLS-1$
- getSigningState().setSignatureResponse(
- new SLResponse(responseData, getStatus().getServer(), null, null));
- return;
- } else {
- // error page
- // extract error text!
- try {
- String errorMessage = MobileBKUHelper.extractContentFromTagWithParam(responseData, "span", "class", "ErrorClass"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- status.setErrorMessage(errorMessage);
- } catch (Exception e) {
- throw new SignatureException(MobileBKUHelper.extractSubstring(responseData, "<sl:ErrorCode>", "</sl:ErrorCode>") + ": " + //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- MobileBKUHelper.extractSubstring(responseData, "<sl:Info>", "</sl:Info>")); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- // force UI again!
- status.setMobilePassword(null);
- }
-
- log.info("sessionID: " + sessionID); //$NON-NLS-1$
- log.info("Vergleichswert: " + refVal); //$NON-NLS-1$
- log.info("viewState: " + viewState); //$NON-NLS-1$
- log.info("eventValidation: " + eventValidation); //$NON-NLS-1$
- log.info("signatureDataURL: " + signatureDataURL); //$NON-NLS-1$
-
- status.setSessionID(sessionID);
- status.setRefVal(refVal);
- status.setViewstate(viewState);
- status.setEventvalidation(eventValidation);
- status.setSignatureDataURL(signatureDataURL);
- }
-
- /* (non-Javadoc)
- * @see at.asit.pdfover.gui.workflow.states.mobilebku.MobileBKUHandler#postTAN()
- */
- @Override
- public String postTAN() throws IOException {
- ATrustStatus status = getStatus();
-
- MobileBKUHelper.registerTrustedSocketFactory();
- HttpClient client = MobileBKUHelper.getHttpClient(getStatus());
-
- PostMethod post = new PostMethod(status.getBaseURL()
- + "/signature.aspx?sid=" + status.getSessionID()); //$NON-NLS-1$
- post.getParams().setContentCharset("utf-8"); //$NON-NLS-1$
- post.addParameter("__VIEWSTATE", status.getViewstate()); //$NON-NLS-1$
- post.addParameter(
- "__EVENTVALIDATION", status.getEventvalidation()); //$NON-NLS-1$
- post.addParameter("input_tan", status.getTan()); //$NON-NLS-1$
- post.addParameter("SignButton", "Signieren"); //$NON-NLS-1$ //$NON-NLS-2$
- post.addParameter("Button1", "Identifizieren"); //$NON-NLS-1$ //$NON-NLS-2$
-
- return executePost(client, post);
- }
-
- /* (non-Javadoc)
- * @see at.asit.pdfover.gui.workflow.states.mobilebku.MobileBKUHandler#handleTANResponse(java.lang.String)
- */
- @Override
- public void handleTANResponse(String responseData) {
- getStatus().setErrorMessage(null);
- if (responseData.contains("sl:CreateXMLSignatureResponse xmlns:sl") || //$NON-NLS-1$
- responseData.contains("sl:CreateCMSSignatureResponse xmlns:sl")) { //$NON-NLS-1$
- // success !!
-
- getSigningState().setSignatureResponse(
- new SLResponse(responseData, getStatus().getServer(), null, null));
- } else {
- try {
- String tries = MobileBKUHelper.extractSubstring(
- responseData, "Sie haben noch", "Versuch"); //$NON-NLS-1$ //$NON-NLS-2$
- getStatus().setTanTries(Integer.parseInt(tries.trim()));
- getStatus().setErrorMessage("mobileBKU.wrong_tan"); //$NON-NLS-1$
- } catch (Exception e) {
- getStatus().setTanTries(getStatus().getTanTries() - 1);
- log.debug("Error parsing TAN response", e); //$NON-NLS-1$
- }
-
- if (getStatus().getTanTries() <= 0) {
- getStatus().setErrorMessage(null);
- 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) {
- // Go back to BKU Selection
- getStatus().setTanTries(-1);
- } else {
- // Start signature process over
- getStatus().setTanTries(-2);
- }
- }
- });
- }
- }
- }
-
- /**
- * Cancel QR process, request SMS TAN
- * @return the response
- * @throws IOException Error during posting
- */
- public String postSMSRequest() throws IOException {
- ATrustStatus status = getStatus();
-
- MobileBKUHelper.registerTrustedSocketFactory();
- HttpClient client = MobileBKUHelper.getHttpClient(getStatus());
-
- GetMethod get = new GetMethod(status.getBaseURL()
- + "/sendsms.aspx?sid=" + status.getSessionID()); //$NON-NLS-1$
- get.getParams().setContentCharset("utf-8"); //$NON-NLS-1$
-
- return executeGet(client, get);
- }
-
- /**
- * Get the QR code image
- * @return the QR code image as a String
- */
- public InputStream getQRCode() {
- //TODO: Update HTTPClient here
-
- ATrustStatus status = getStatus();
-
- MobileBKUHelper.registerTrustedSocketFactory();
- HttpClient client = MobileBKUHelper.getHttpClient(getStatus());
-
- GetMethod get = new GetMethod(status.getBaseURL() + "/" + //$NON-NLS-1$
- status.getQRCode());
-
- try {
- log.debug("Getting " + get.getURI()); //$NON-NLS-1$
- int returnCode = client.executeMethod(get);
-
- if (returnCode != HttpStatus.SC_OK) {
- log.error("Error getting QR code"); //$NON-NLS-1$
- return null;
- }
-
- return get.getResponseBodyAsStream();
- } catch (Exception e) {
- log.error("Error getting QR code", e); //$NON-NLS-1$
- return null;
- }
- }
-
- /**
- * Get Signature page after scanning QR code
- * @return the response
- * @throws IOException Error during get
- */
- public String getSignaturePage() throws IOException {
- ATrustStatus status = getStatus();
-
- MobileBKUHelper.registerTrustedSocketFactory();
- HttpClient client = MobileBKUHelper.getHttpClient(getStatus());
-
- GetMethod get = new GetMethod(status.getBaseURL()
- + "/signature.aspx?sid=" + status.getSessionID()); //$NON-NLS-1$
-
- return executeGet(client, get);
- }
-
- /**
- * Parse QR code response
- * @param responseData
- * @return whether a SL response was received
- */
- public boolean handleQRResponse(String responseData) {
- getStatus().setErrorMessage(null);
- if (responseData.contains("sl:CreateXMLSignatureResponse xmlns:sl") || //$NON-NLS-1$
- responseData.contains("sl:CreateCMSSignatureResponse xmlns:sl")) { //$NON-NLS-1$
- // success !!
-
- getSigningState().setSignatureResponse(
- new SLResponse(responseData, getStatus().getServer(), null, null));
- return true;
- }
- return false;
- }
-
- @Override
- public ATrustStatus getStatus() {
- return (ATrustStatus) getState().getStatus();
- }
-
- /* (non-Javadoc)
- * @see at.asit.pdfover.gui.bku.mobile.MobileBKUHandler#useBase64Request()
- */
- @Override
- public boolean useBase64Request() {
- return this.useBase64;
- }
-}
+/*
+ * 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.bku.mobile;
+
+// Imports
+import java.awt.Desktop;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URI;
+
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.HttpStatus;
+import org.apache.commons.httpclient.methods.GetMethod;
+import org.apache.commons.httpclient.methods.PostMethod;
+import org.apache.commons.lang3.StringEscapeUtils;
+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.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.MobileBKUState;
+import at.asit.pdfover.signator.SLResponse;
+import at.asit.pdfover.signator.SignatureException;
+
+/**
+ * A-Trust mobile BKU handler
+ */
+public class ATrustHandler extends MobileBKUHandler {
+ Shell shell;
+
+ /**
+ * @param state
+ * @param shell
+ * @param useBase64
+ */
+ public ATrustHandler(MobileBKUState state, Shell shell, boolean useBase64) {
+ super(state);
+ this.shell = shell;
+ this.useBase64 = useBase64;
+ }
+
+ /**
+ * SLF4J Logger instance
+ **/
+ static final Logger log = LoggerFactory
+ .getLogger(ATrustHandler.class);
+
+ private static boolean expiryNoticeDisplayed = false;
+
+ private static final String ACTIVATION_URL = "https://www.handy-signatur.at/"; //$NON-NLS-1$
+
+ private boolean useBase64 = false;
+
+ /* (non-Javadoc)
+ * @see at.asit.pdfover.gui.workflow.states.mobilebku.MobileBKUHandler#handleSLRequestResponse(java.lang.String)
+ */
+ @Override
+ public void handleSLRequestResponse(String responseData) throws Exception {
+ ATrustStatus status = getStatus();
+
+ if (responseData.contains("<sl:ErrorResponse")) { //$NON-NLS-1$
+ String errorCode = MobileBKUHelper.extractSubstring(responseData,
+ "<sl:ErrorCode>", "</sl:ErrorCode>"); //$NON-NLS-1$ //$NON-NLS-2$
+ String errorMsg = MobileBKUHelper.extractSubstring(responseData,
+ "<sl:Info>", "</sl:Info>"); //$NON-NLS-1$ //$NON-NLS-2$
+ throw new Exception("Error from mobile BKU: " + //$NON-NLS-1$
+ errorCode + " - " + errorMsg); //$NON-NLS-1$
+ }
+
+ // Extract infos:
+ String sessionID = MobileBKUHelper.extractSubstring(responseData,
+ "identification.aspx?sid=", "\""); //$NON-NLS-1$ //$NON-NLS-2$
+
+ String viewState = MobileBKUHelper.extractValueFromTagWithParam(
+ responseData, "", "id", "__VIEWSTATE", "value"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+
+ String eventValidation = MobileBKUHelper.extractValueFromTagWithParam(
+ responseData, "", "id", "__EVENTVALIDATION", "value"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+
+ log.info("sessionID: " + sessionID); //$NON-NLS-1$
+ log.info("viewState: " + viewState); //$NON-NLS-1$
+ log.info("eventValidation: " + eventValidation); //$NON-NLS-1$
+
+ status.setSessionID(sessionID);
+
+ status.setViewstate(viewState);
+
+ status.setEventvalidation(eventValidation);
+ }
+
+ /* (non-Javadoc)
+ * @see at.asit.pdfover.gui.workflow.states.mobilebku.MobileBKUHandler#postCredentials()
+ */
+ @Override
+ public String postCredentials() throws Exception {
+ ATrustStatus status = getStatus();
+
+ MobileBKUHelper.registerTrustedSocketFactory();
+ HttpClient client = MobileBKUHelper.getHttpClient(getStatus());
+
+ PostMethod post = new PostMethod(status.getBaseURL() + "/identification.aspx?sid=" + status.getSessionID()); //$NON-NLS-1$
+ post.getParams().setContentCharset("utf-8"); //$NON-NLS-1$
+ post.addParameter("__VIEWSTATE", status.getViewstate()); //$NON-NLS-1$
+ post.addParameter("__EVENTVALIDATION", status.getEventvalidation()); //$NON-NLS-1$
+ post.addParameter("handynummer", status.getPhoneNumber()); //$NON-NLS-1$
+ post.addParameter("signaturpasswort", status.getMobilePassword()); //$NON-NLS-1$
+ post.addParameter("Button_Identification", "Identifizieren"); //$NON-NLS-1$ //$NON-NLS-2$
+
+ return executePost(client, post);
+ }
+
+ /* (non-Javadoc)
+ * @see at.asit.pdfover.gui.workflow.states.mobilebku.MobileBKUHandler#handleCredentialsResponse(java.lang.String)
+ */
+ @Override
+ public void handleCredentialsResponse(String responseData) throws Exception {
+ ATrustStatus status = getStatus();
+ String viewState = status.getViewstate();
+ String eventValidation = status.getEventvalidation();
+ String sessionID = status.getSessionID();
+ String refVal = null;
+ String signatureDataURL = null;
+ String qrCode = null;
+ String tanField = null;
+ String tanTextTan = null;
+
+ status.setErrorMessage(null);
+
+ if (responseData.contains("ExpiresInfo.aspx?sid=")) { //$NON-NLS-1$
+ // Certificate expiration interstitial - skip
+ String notice = Messages.getString("mobileBKU.notice") + " " + //$NON-NLS-1$ //$NON-NLS-2$
+ StringEscapeUtils.unescapeHtml4(MobileBKUHelper.extractContentFromTagWithParam(responseData, "span", "id", "Label2")) //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ .replaceAll("\\<.*?\\>", ""); //$NON-NLS-1$ //$NON-NLS-2$
+ log.info(notice);
+
+ if (!expiryNoticeDisplayed) {
+ Display.getDefault().syncExec(new Runnable() {
+ @Override
+ public void run() {
+ Dialog d = new Dialog(ATrustHandler.this.shell, Messages.getString("common.info"), Messages.getString("mobileBKU.certExpiresSoon"), BUTTONS.YES_NO, ICON.WARNING); //$NON-NLS-1$ //$NON-NLS-2$
+ if (d.open() == SWT.YES) {
+ log.debug("Trying to open " + ACTIVATION_URL); //$NON-NLS-1$
+ if (Desktop.isDesktopSupported()) {
+ try {
+ Desktop.getDesktop().browse(new URI(ACTIVATION_URL));
+ return;
+ } catch (Exception e) {
+ log.debug("Error opening URL", e); //$NON-NLS-1$
+ }
+ }
+ log.info("SWT Desktop is not supported on this platform"); //$NON-NLS-1$
+ Program.launch(ACTIVATION_URL);
+ }
+ }
+ });
+ expiryNoticeDisplayed = true;
+ }
+
+ String t_sessionID = MobileBKUHelper.extractSubstring(responseData, "ExpiresInfo.aspx?sid=", "\""); //$NON-NLS-1$ //$NON-NLS-2$
+ String t_viewState = MobileBKUHelper.extractValueFromTagWithParam(responseData, "", "id", "__VIEWSTATE", "value"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ String t_eventValidation = MobileBKUHelper.extractValueFromTagWithParam(responseData, "", "id", "__EVENTVALIDATION", "value"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+
+ // Post again to skip
+ MobileBKUHelper.registerTrustedSocketFactory();
+ HttpClient client = MobileBKUHelper.getHttpClient(getStatus());
+
+ PostMethod post = new PostMethod(status.getBaseURL() + "/ExpiresInfo.aspx?sid=" + t_sessionID); //$NON-NLS-1$
+ post.getParams().setContentCharset("utf-8"); //$NON-NLS-1$
+ post.addParameter("__VIEWSTATE", t_viewState); //$NON-NLS-1$
+ post.addParameter("__EVENTVALIDATION", t_eventValidation); //$NON-NLS-1$
+ post.addParameter("Button_Next", "Weiter"); //$NON-NLS-1$ //$NON-NLS-2$
+
+ responseData = executePost(client, post);
+ log.trace("Response from mobile BKU: " + responseData); //$NON-NLS-1$
+ } else if (responseData.contains("tanAppInfo.aspx?sid=")) { //$NON-NLS-1$
+ // App info interstitial - skip
+ log.info("Skipping tan app interstitial"); //$NON-NLS-1$
+
+ String t_sessionID = MobileBKUHelper.extractSubstring(responseData, "tanAppInfo.aspx?sid=", "\""); //$NON-NLS-1$ //$NON-NLS-2$
+ String t_viewState = MobileBKUHelper.extractValueFromTagWithParam(responseData, "", "id", "__VIEWSTATE", "value"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ String t_eventValidation = MobileBKUHelper.extractValueFromTagWithParam(responseData, "", "id", "__EVENTVALIDATION", "value"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+
+ // Post again to skip
+ MobileBKUHelper.registerTrustedSocketFactory();
+ HttpClient client = MobileBKUHelper.getHttpClient(getStatus());
+
+ PostMethod post = new PostMethod(status.getBaseURL() + "/tanAppInfo.aspx?sid=" + t_sessionID); //$NON-NLS-1$
+ post.getParams().setContentCharset("utf-8"); //$NON-NLS-1$
+ post.addParameter("__VIEWSTATE", t_viewState); //$NON-NLS-1$
+ post.addParameter("__EVENTVALIDATION", t_eventValidation); //$NON-NLS-1$
+ post.addParameter("NextBtn", "Weiter"); //$NON-NLS-1$ //$NON-NLS-2$
+
+ responseData = executePost(client, post);
+ log.trace("Response from mobile BKU: " + responseData); //$NON-NLS-1$
+ }
+
+ if (responseData.contains("signature.aspx?sid=")) { //$NON-NLS-1$
+ // credentials ok! TAN entry
+ log.debug("Credentials accepted - TAN required"); //$NON-NLS-1$
+ sessionID = MobileBKUHelper.extractSubstring(responseData, "signature.aspx?sid=", "\""); //$NON-NLS-1$ //$NON-NLS-2$
+ viewState = MobileBKUHelper.extractValueFromTagWithParam(responseData, "", "id", "__VIEWSTATE", "value"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ eventValidation = MobileBKUHelper.extractValueFromTagWithParam(responseData, "", "id", "__EVENTVALIDATION", "value"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ refVal = MobileBKUHelper.extractSubstring(responseData, "id='vergleichswert'><b>Vergleichswert:</b>", "</div>"); //$NON-NLS-1$ //$NON-NLS-2$
+ signatureDataURL = status.getBaseURL() + "/ShowSigobj.aspx" + //$NON-NLS-1$
+ MobileBKUHelper.extractSubstring(responseData, "ShowSigobj.aspx", "'"); //$NON-NLS-1$ //$NON-NLS-2$
+ try {
+ qrCode = MobileBKUHelper.extractValueFromTagWithParam(responseData, "img", "class", "qrcode", "src"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ log.debug("QR Code found: " + qrCode); //$NON-NLS-1$
+ status.setQRCode(qrCode);
+ } catch (Exception e) {
+ log.debug("No QR Code found"); //$NON-NLS-1$
+ }
+ try {
+ tanField = MobileBKUHelper.extractValueFromTagWithParam(responseData, "label", "id", "label_for_input_tan", "for"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ status.setTanField(tanField);
+ } catch (Exception e) {
+ log.debug("No tan field found"); //$NON-NLS-1$
+ }
+ try {
+ tanTextTan = tanField = MobileBKUHelper.extractContentFromTagWithParam(responseData, "span", "id", "text_tan"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ status.setIsAPPTan(tanTextTan);
+ }catch (Exception e) {
+ log.debug("No text_tan tag"); //$NON-NLS-1$
+ }
+
+ } else if (responseData.contains("sl:InfoboxReadResponse")) { //$NON-NLS-1$
+ // credentials ok! InfoboxReadResponse
+ log.debug("Credentials accepted - Response given"); //$NON-NLS-1$
+ getSigningState().setSignatureResponse(
+ new SLResponse(responseData, getStatus().getServer(), null, null));
+ return;
+ } else {
+ // error page
+ // extract error text!
+ try {
+ String errorMessage = MobileBKUHelper.extractContentFromTagWithParam(responseData, "span", "class", "ErrorClass"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ status.setErrorMessage(errorMessage);
+ } catch (Exception e) {
+ throw new SignatureException(MobileBKUHelper.extractSubstring(responseData, "<sl:ErrorCode>", "</sl:ErrorCode>") + ": " + //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ MobileBKUHelper.extractSubstring(responseData, "<sl:Info>", "</sl:Info>")); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ // force UI again!
+ status.setMobilePassword(null);
+ }
+
+ log.info("sessionID: " + sessionID); //$NON-NLS-1$
+ log.info("Vergleichswert: " + refVal); //$NON-NLS-1$
+ log.info("viewState: " + viewState); //$NON-NLS-1$
+ log.info("eventValidation: " + eventValidation); //$NON-NLS-1$
+ log.info("signatureDataURL: " + signatureDataURL); //$NON-NLS-1$
+
+ status.setSessionID(sessionID);
+ status.setRefVal(refVal);
+ status.setViewstate(viewState);
+ status.setEventvalidation(eventValidation);
+ status.setSignatureDataURL(signatureDataURL);
+ }
+
+ /* (non-Javadoc)
+ * @see at.asit.pdfover.gui.workflow.states.mobilebku.MobileBKUHandler#postTAN()
+ */
+ @Override
+ public String postTAN() throws IOException {
+ ATrustStatus status = getStatus();
+
+ MobileBKUHelper.registerTrustedSocketFactory();
+ HttpClient client = MobileBKUHelper.getHttpClient(getStatus());
+
+ PostMethod post = new PostMethod(status.getBaseURL()
+ + "/signature.aspx?sid=" + status.getSessionID()); //$NON-NLS-1$
+ post.getParams().setContentCharset("utf-8"); //$NON-NLS-1$
+ post.addParameter("__VIEWSTATE", status.getViewstate()); //$NON-NLS-1$
+ post.addParameter(
+ "__EVENTVALIDATION", status.getEventvalidation()); //$NON-NLS-1$
+ post.addParameter("input_tan", status.getTan()); //$NON-NLS-1$
+ post.addParameter("SignButton", "Signieren"); //$NON-NLS-1$ //$NON-NLS-2$
+ post.addParameter("Button1", "Identifizieren"); //$NON-NLS-1$ //$NON-NLS-2$
+
+ return executePost(client, post);
+ }
+
+ /* (non-Javadoc)
+ * @see at.asit.pdfover.gui.workflow.states.mobilebku.MobileBKUHandler#handleTANResponse(java.lang.String)
+ */
+ @Override
+ public void handleTANResponse(String responseData) {
+ getStatus().setErrorMessage(null);
+ if (responseData.contains("sl:CreateXMLSignatureResponse xmlns:sl") || //$NON-NLS-1$
+ responseData.contains("sl:CreateCMSSignatureResponse xmlns:sl")) { //$NON-NLS-1$
+ // success !!
+
+ getSigningState().setSignatureResponse(
+ new SLResponse(responseData, getStatus().getServer(), null, null));
+ } else {
+ try {
+ String tries = MobileBKUHelper.extractSubstring(
+ responseData, "Sie haben noch", "Versuch"); //$NON-NLS-1$ //$NON-NLS-2$
+ getStatus().setTanTries(Integer.parseInt(tries.trim()));
+ getStatus().setErrorMessage("mobileBKU.wrong_tan"); //$NON-NLS-1$
+ } catch (Exception e) {
+ getStatus().setTanTries(getStatus().getTanTries() - 1);
+ log.debug("Error parsing TAN response", e); //$NON-NLS-1$
+ }
+
+ if (getStatus().getTanTries() <= 0) {
+ getStatus().setErrorMessage(null);
+ 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) {
+ // Go back to BKU Selection
+ getStatus().setTanTries(-1);
+ } else {
+ // Start signature process over
+ getStatus().setTanTries(-2);
+ }
+ }
+ });
+ }
+ }
+ }
+
+ /**
+ * Cancel QR process, request SMS TAN
+ * @return the response
+ * @throws IOException Error during posting
+ */
+ public String postSMSRequest() throws IOException {
+ ATrustStatus status = getStatus();
+
+ MobileBKUHelper.registerTrustedSocketFactory();
+ HttpClient client = MobileBKUHelper.getHttpClient(getStatus());
+
+ GetMethod get = new GetMethod(status.getBaseURL()
+ + "/sendsms.aspx?sid=" + status.getSessionID()); //$NON-NLS-1$
+ get.getParams().setContentCharset("utf-8"); //$NON-NLS-1$
+
+ return executeGet(client, get);
+ }
+
+ /**
+ * Get the QR code image
+ * @return the QR code image as a String
+ */
+ public InputStream getQRCode() {
+ //TODO: Update HTTPClient here
+
+ ATrustStatus status = getStatus();
+
+ MobileBKUHelper.registerTrustedSocketFactory();
+ HttpClient client = MobileBKUHelper.getHttpClient(getStatus());
+
+ GetMethod get = new GetMethod(status.getBaseURL() + "/" + //$NON-NLS-1$
+ status.getQRCode());
+
+ try {
+ log.debug("Getting " + get.getURI()); //$NON-NLS-1$
+ int returnCode = client.executeMethod(get);
+
+ if (returnCode != HttpStatus.SC_OK) {
+ log.error("Error getting QR code"); //$NON-NLS-1$
+ return null;
+ }
+
+ return get.getResponseBodyAsStream();
+ } catch (Exception e) {
+ log.error("Error getting QR code", e); //$NON-NLS-1$
+ return null;
+ }
+ }
+
+ /**
+ * Get Signature page after scanning QR code
+ * @return the response
+ * @throws IOException Error during get
+ */
+ public String getSignaturePage() throws IOException {
+ ATrustStatus status = getStatus();
+
+ MobileBKUHelper.registerTrustedSocketFactory();
+ HttpClient client = MobileBKUHelper.getHttpClient(getStatus());
+
+ GetMethod get = new GetMethod(status.getBaseURL()
+ + "/signature.aspx?sid=" + status.getSessionID()); //$NON-NLS-1$
+
+ return executeGet(client, get);
+ }
+
+ /**
+ * Parse QR code response
+ * @param responseData
+ * @return whether a SL response was received
+ */
+ public boolean handleQRResponse(String responseData) {
+ getStatus().setErrorMessage(null);
+ if (responseData.contains("sl:CreateXMLSignatureResponse xmlns:sl") || //$NON-NLS-1$
+ responseData.contains("sl:CreateCMSSignatureResponse xmlns:sl")) { //$NON-NLS-1$
+ // success !!
+
+ getSigningState().setSignatureResponse(
+ new SLResponse(responseData, getStatus().getServer(), null, null));
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ public ATrustStatus getStatus() {
+ return (ATrustStatus) getState().getStatus();
+ }
+
+ /* (non-Javadoc)
+ * @see at.asit.pdfover.gui.bku.mobile.MobileBKUHandler#useBase64Request()
+ */
+ @Override
+ public boolean useBase64Request() {
+ return this.useBase64;
+ }
+}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/ATrustStatus.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/ATrustStatus.java
index ecfd9f2b..b81e15be 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/ATrustStatus.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/ATrustStatus.java
@@ -1,120 +1,150 @@
-/*
- * 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.bku.mobile;
-
-// Imports
-import org.apache.commons.httpclient.Cookie;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import at.asit.pdfover.gui.workflow.config.ConfigProvider;
-
-/**
- * A-Trust MobileBKUStatus implementation
- */
-public class ATrustStatus extends AbstractMobileBKUStatusImpl {
- /**
- * SLF4J Logger instance
- **/
- @SuppressWarnings("unused")
- private static final Logger log = LoggerFactory
- .getLogger(ATrustStatus.class);
-
- /** Maximum number of TAN tries */
- public static final int MOBILE_MAX_TAN_TRIES = 3;
-
- private String viewstate;
- private String eventvalidation;
- private String qrcode = null;
-
- /**
- * Constructor
- * @param provider the ConfigProvider
- */
- public ATrustStatus(ConfigProvider provider) {
- setPhoneNumber(provider.getDefaultMobileNumber());
- setMobilePassword(provider.getDefaultMobilePassword());
- }
-
- /* (non-Javadoc)
- * @see at.asit.pdfover.gui.workflow.states.mobilebku.MobileBKUStatus#getMaxTanTries()
- */
- @Override
- public int getMaxTanTries() {
- return MOBILE_MAX_TAN_TRIES;
- }
-
- /**
- * @return the viewstate
- */
- public String getViewstate() {
- return this.viewstate;
- }
-
- /**
- * @param viewstate
- * the viewstate to set
- */
- public void setViewstate(String viewstate) {
- this.viewstate = viewstate;
- }
-
- /**
- * @return the eventvalidation
- */
- public String getEventvalidation() {
- return this.eventvalidation;
- }
-
- /**
- * @param eventvalidation the eventvalidation to set
- */
- public void setEventvalidation(String eventvalidation) {
- this.eventvalidation = eventvalidation;
- }
-
- /**
- * @return the QR code
- */
- public String getQRCode() {
- return this.qrcode;
- }
-
- /**
- * @param qrcode
- * the QR code to set
- */
- public void setQRCode(String qrcode) {
- this.qrcode = qrcode;
- }
-
- /* (non-Javadoc)
- * @see at.asit.pdfover.gui.bku.mobile.MobileBKUStatus#parseCookies(org.apache.commons.httpclient.Cookie[])
- */
- @Override
- public void parseCookies(Cookie[] cookies) {
- //not needed yet
- }
-
- /* (non-Javadoc)
- * @see at.asit.pdfover.gui.bku.mobile.MobileBKUStatus#getCookies()
- */
- @Override
- public Cookie[] getCookies() {
- //not needed yet
- return null;
- }
-}
+/*
+ * 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.bku.mobile;
+
+// Imports
+import org.apache.commons.httpclient.Cookie;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import at.asit.pdfover.gui.workflow.config.ConfigProvider;
+
+/**
+ * A-Trust MobileBKUStatus implementation
+ */
+public class ATrustStatus extends AbstractMobileBKUStatusImpl {
+ /**
+ * SLF4J Logger instance
+ **/
+ @SuppressWarnings("unused")
+ private static final Logger log = LoggerFactory
+ .getLogger(ATrustStatus.class);
+
+ /** Maximum number of TAN tries */
+ public static final int MOBILE_MAX_TAN_TRIES = 3;
+
+ private String viewstate;
+ private String eventvalidation;
+ private String qrcode = null;
+ private boolean tanField = false;
+ private boolean isAPPTan = false;
+
+ /**
+ * Constructor
+ * @param provider the ConfigProvider
+ */
+ public ATrustStatus(ConfigProvider provider) {
+ setPhoneNumber(provider.getDefaultMobileNumber());
+ setMobilePassword(provider.getDefaultMobilePassword());
+ }
+
+ /* (non-Javadoc)
+ * @see at.asit.pdfover.gui.workflow.states.mobilebku.MobileBKUStatus#getMaxTanTries()
+ */
+ @Override
+ public int getMaxTanTries() {
+ return MOBILE_MAX_TAN_TRIES;
+ }
+
+ /**
+ * @return the viewstate
+ */
+ public String getViewstate() {
+ return this.viewstate;
+ }
+
+ /**
+ * @param viewstate
+ * the viewstate to set
+ */
+ public void setViewstate(String viewstate) {
+ this.viewstate = viewstate;
+ }
+
+ /**
+ * @return the eventvalidation
+ */
+ public String getEventvalidation() {
+ return this.eventvalidation;
+ }
+
+ /**
+ * @param eventvalidation the eventvalidation to set
+ */
+ public void setEventvalidation(String eventvalidation) {
+ this.eventvalidation = eventvalidation;
+ }
+
+ /**
+ * @return the QR code
+ */
+ public String getQRCode() {
+ return this.qrcode;
+ }
+
+ /**
+ * @param qrcode
+ * the QR code to set
+ */
+ public void setQRCode(String qrcode) {
+ this.qrcode = qrcode;
+ }
+
+ /**
+ * @param tanField
+ */
+ public void setTanField(String tanField) {
+ this.tanField = tanField.equals("input_tan"); //$NON-NLS-1$
+ }
+
+ /**
+ * @return boolean if response contained tan field
+ */
+ public boolean getTanField() {
+ return this.tanField;
+ }
+
+ /**
+ * @param tanString the tan string from the response
+ */
+ public void setIsAPPTan(String tanString) {
+ this.isAPPTan = !tanString.toLowerCase().contains("sms"); //$NON-NLS-1$
+ }
+
+ /**
+ * @return true if the user receives the tan via app
+ */
+ public boolean getIsAPPTan() {
+ return this.isAPPTan;
+ }
+
+ /* (non-Javadoc)
+ * @see at.asit.pdfover.gui.bku.mobile.MobileBKUStatus#parseCookies(org.apache.commons.httpclient.Cookie[])
+ */
+ @Override
+ public void parseCookies(Cookie[] cookies) {
+ //not needed yet
+ }
+
+ /* (non-Javadoc)
+ * @see at.asit.pdfover.gui.bku.mobile.MobileBKUStatus#getCookies()
+ */
+ @Override
+ public Cookie[] getCookies() {
+ //not needed yet
+ return null;
+ }
+}
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/MobileBKUEnterTANComposite.java
index 7bda7fc4..d34f89dc 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/MobileBKUEnterTANComposite.java
@@ -1,484 +1,484 @@
-/*
- * 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.FormAttachment;
-import org.eclipse.swt.layout.FormData;
-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 at.asit.pdfover.gui.Constants;
-import at.asit.pdfover.gui.utils.Messages;
-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 {
- /**
- * Empty constructor
- */
- public OkSelectionListener() {
- }
-
- @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")); //$NON-NLS-1$
- return;
- }
-
- if (MobileBKUEnterTANComposite.this.refVal.startsWith(tan)) {
- MobileBKUEnterTANComposite.this.setMessage(Messages
- .getString("error.EnteredReferenceValue")); //$NON-NLS-1$
- return;
- }
-
- if (tan.length() > 6) {
- MobileBKUEnterTANComposite.this.setMessage(Messages
- .getString("error.TanTooLong")); //$NON-NLS-1$
- return;
- }
-
- MobileBKUEnterTANComposite.this.tan = tan;
- MobileBKUEnterTANComposite.this.setUserAck(true);
- MobileBKUEnterTANComposite.this.btn_ok.setEnabled(false);
- //MobileBKUEnterTANComposite.this.state.updateStateMachine();
- //MobileBKUEnterTANComposite.this.btn_ok.setEnabled(true);
- }
- }
-
- /**
- *
- */
- private final class CancelSelectionListener extends SelectionAdapter {
- /**
- * Empty constructor
- */
- public CancelSelectionListener() {
- }
-
- @Override
- public void widgetSelected(SelectionEvent e) {
- MobileBKUEnterTANComposite.this.setUserCancel(true);
- }
- }
-
- /**
- * SLF4J Logger instance
- **/
- static final Logger log = LoggerFactory
- .getLogger(MobileBKUEnterTANComposite.class);
-
- Text txt_tan;
-
- boolean userAck = false;
- boolean userCancel = 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;
- }
-
- String tan;
-
- private Label lblTries;
- private Label lblRefValLabel;
- private Label lblTan;
-
- Button btn_ok;
- Button btn_cancel;
-
- /**
- * @return the userAck
- */
- public boolean isUserAck() {
- return this.userAck;
- }
-
- /**
- * @return the userCancel
- */
- public boolean isUserCancel() {
- return this.userCancel;
- }
-
- /**
- * Set how many tries are left
- *
- * @param tries
- */
- public void setTries(int tries) {
- this.lblTries.setText(tries == 1 ? Messages.getString("tanEnter.try") : //$NON-NLS-1$
- String.format(Messages.getString("tanEnter.tries"), tries)); //$NON-NLS-1$
- }
-
- /**
- * Set an error message
- * @param errorMessage the error message
- */
- public void setErrorMessage(String errorMessage) {
- if (errorMessage == null)
- this.lblTries.setText(""); //$NON-NLS-1$
- else
- this.lblTries.setText(
- Messages.getString("error.Title") + ": " + errorMessage); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
-
- /**
- * Sets the message
- *
- * @param msg
- */
- public void setMessage(String msg) {
- this.lblTries.setText(msg);
- this.lblTries.redraw();
- this.lblTries.getParent().layout(true, true);
- }
-
- /**
- * @param userAck
- * the userAck to set
- */
- public void setUserAck(boolean userAck) {
- this.userAck = userAck;
- }
-
- /**
- * @param userCancel
- * the userCancel to set
- */
- public void setUserCancel(boolean userCancel) {
- this.userCancel = userCancel;
- }
-
- /**
- * @return the reference value
- */
- public String getRefVal() {
- return this.refVal;
- }
-
- /**
- * Enables the submit button
- */
- public void enableButton() {
- this.btn_ok.setEnabled(true);
- }
-
- /**
- * @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(""); //$NON-NLS-1$
- }
-
- }
-
- /**
- * @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(""); //$NON-NLS-1$
- } else {
- this.txt_tan.setText(this.tan);
- }
- }
-
- /**
- * Selection Listener for open button
- */
- private final class ShowSignatureDataListener extends SelectionAdapter {
- /**
- * Empty constructor
- */
- public ShowSignatureDataListener() {
- }
-
- @Override
- public void widgetSelected(SelectionEvent e) {
- try {
- String signatureData = MobileBKUEnterTANComposite.this
- .getSignatureData();
- if (signatureData != null && !signatureData.equals("")) { //$NON-NLS-1$
- log.debug("Trying to open " + signatureData); //$NON-NLS-1$
- if (Desktop.isDesktopSupported()) {
- Desktop.getDesktop().browse(new URI(signatureData));
- } else {
- log.info("SWT Desktop is not supported on this platform"); //$NON-NLS-1$
- Program.launch(signatureData);
- }
- }
- } catch (Exception ex) {
- log.error("OpenSelectionListener: ", ex); //$NON-NLS-1$
- }
- }
- }
-
- /**
- * 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());
- FormData fd_containerComposite = new FormData();
- fd_containerComposite.top = new FormAttachment(50, -120);
- fd_containerComposite.bottom = new FormAttachment(50, 120);
- fd_containerComposite.left = new FormAttachment(50, -200);
- fd_containerComposite.right = new FormAttachment(50, 200);
- containerComposite.setLayoutData(fd_containerComposite);
-
- this.lblRefValLabel = new Label(containerComposite, SWT.NATIVE);
- this.lblRefValLabel.setAlignment(SWT.RIGHT);
- FormData fd_lblRefValLabel = new FormData();
- // fd_lblRefValLabel.left = new FormAttachment(0, 20);
- fd_lblRefValLabel.right = new FormAttachment(50, -10);
- // fd_lblRefValLabel.top = new FormAttachment(30, -15);
- fd_lblRefValLabel.bottom = new FormAttachment(50, -10);
- this.lblRefValLabel.setLayoutData(fd_lblRefValLabel);
- this.lblRefValLabel.setText(Messages
- .getString("tanEnter.ReferenceValue")); //$NON-NLS-1$
-
- Label lbl_image = new Label(containerComposite, SWT.NATIVE);
-
- ImageData data = new ImageData(this.getClass().getResourceAsStream(
- Constants.RES_IMG_MOBILE));
- Image mobile = new Image(getDisplay(), data);
-
- FormData fd_lbl_image = new FormData();
- fd_lbl_image.top = new FormAttachment(50, -1 * (data.width / 2));
- fd_lbl_image.bottom = new FormAttachment(50, data.width / 2);
- fd_lbl_image.left = new FormAttachment(0, 10);
- fd_lbl_image.width = data.width;
- lbl_image.setLayoutData(fd_lbl_image);
- lbl_image.setImage(mobile);
-
- this.lblRefVal = new Label(containerComposite, SWT.NATIVE);
- FormData fd_lblRefVal = new FormData();
- fd_lblRefVal.left = new FormAttachment(50, 10);
- fd_lblRefVal.right = new FormAttachment(100, -20);
- // fd_lblRefVal.top = new FormAttachment(30, -15);
- fd_lblRefVal.bottom = new FormAttachment(50, -10);
- this.lblRefVal.setLayoutData(fd_lblRefVal);
- this.lblRefVal.setText(""); //$NON-NLS-1$
-
- this.lblTan = new Label(containerComposite, SWT.NATIVE);
- this.lblTan.setAlignment(SWT.RIGHT);
- FormData fd_lblTan = new FormData();
- // fd_lblTan.left = new FormAttachment(0, 20);
- fd_lblTan.right = new FormAttachment(50, -10);
- fd_lblTan.top = new FormAttachment(50, 10);
- // fd_lblTan.bottom = new FormAttachment(50, 15);
- this.lblTan.setLayoutData(fd_lblTan);
- this.lblTan.setText(Messages.getString("tanEnter.TAN")); //$NON-NLS-1$
-
- this.txt_tan = new Text(containerComposite, SWT.BORDER | SWT.NATIVE);
- FormData fd_text = new FormData();
- fd_text.left = new FormAttachment(50, 10);
- fd_text.right = new FormAttachment(100, -20);
- fd_text.top = new FormAttachment(50, 10);
- this.txt_tan.setEditable(true);
- this.txt_tan.setLayoutData(fd_text);
-
- 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); //$NON-NLS-1$
- if (text.length() > 3
- && MobileBKUEnterTANComposite.this.getRefVal()
- .startsWith(text.trim())) {
- MobileBKUEnterTANComposite.this.setMessage(Messages
- .getString("error.EnteredReferenceValue")); //$NON-NLS-1$
- }
- }
- });
-
- Link lnk_sig_data = new Link(containerComposite, SWT.NATIVE | SWT.RESIZE);
-
- FormData fd_lnk_data = new FormData();
- fd_lnk_data.right = new FormAttachment(100, -20);
- fd_lnk_data.top = new FormAttachment(0, 20);
- lnk_sig_data.setEnabled(true);
- lnk_sig_data.setLayoutData(fd_lnk_data);
- lnk_sig_data.addSelectionListener(new ShowSignatureDataListener());
- lnk_sig_data.setText(Messages.getString("mobileBKU.show")); //$NON-NLS-1$
- lnk_sig_data.setToolTipText(Messages.getString("mobileBKU.show_tooltip")); //$NON-NLS-1$
-
- this.btn_ok = new Button(containerComposite, SWT.NATIVE);
- this.btn_cancel = new Button(containerComposite, SWT.NATIVE);
-
- this.lblTries = new Label(containerComposite, SWT.WRAP | SWT.NATIVE);
- FormData fd_lbl_tries = new FormData();
- // fd_lbl_tries.left = new FormAttachment(15, 5);
- fd_lbl_tries.right = new FormAttachment(this.btn_cancel, -10);
- // fd_lbl_tries.top = new FormAttachment(70, -15);
- fd_lbl_tries.bottom = new FormAttachment(100, -20);
- this.lblTries.setLayoutData(fd_lbl_tries);
-
- FormData fd_btn_ok = new FormData();
- // fd_btn_ok.left = new FormAttachment(95, 0);
- fd_btn_ok.right = new FormAttachment(100, -20);
- //fd_btn_ok.left = new FormAttachment(100, -70);
- fd_btn_ok.bottom = new FormAttachment(100, -20);
-
- this.btn_ok.setLayoutData(fd_btn_ok);
- this.btn_ok.setText(Messages.getString("common.Ok")); //$NON-NLS-1$
- this.btn_ok.addSelectionListener(new OkSelectionListener());
-
- FormData fd_btn_cancel = new FormData();
- // fd_btn_cancel.left = new FormAttachment(95, 0);
- fd_btn_cancel.right = new FormAttachment(this.btn_ok, -20);
- //fd_btn_cancel.left = new FormAttachment(100, -70);
- fd_btn_cancel.bottom = new FormAttachment(100, -20);
-
- this.btn_cancel.setLayoutData(fd_btn_cancel);
- this.btn_cancel.setText(Messages.getString("common.Cancel")); //$NON-NLS-1$
- this.btn_cancel.addSelectionListener(new CancelSelectionListener());
- }
-
- @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() {
- this.lblRefValLabel.setText(Messages
- .getString("tanEnter.ReferenceValue")); //$NON-NLS-1$
- this.lblTan.setText(Messages.getString("tanEnter.TAN")); //$NON-NLS-1$
- }
-}
+/*
+ * 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.FormAttachment;
+import org.eclipse.swt.layout.FormData;
+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 at.asit.pdfover.gui.Constants;
+import at.asit.pdfover.gui.utils.Messages;
+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 {
+ /**
+ * Empty constructor
+ */
+ public OkSelectionListener() {
+ }
+
+ @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")); //$NON-NLS-1$
+ return;
+ }
+
+ if (MobileBKUEnterTANComposite.this.refVal.startsWith(tan)) {
+ MobileBKUEnterTANComposite.this.setMessage(Messages
+ .getString("error.EnteredReferenceValue")); //$NON-NLS-1$
+ return;
+ }
+
+ if (tan.length() > 6) {
+ MobileBKUEnterTANComposite.this.setMessage(Messages
+ .getString("error.TanTooLong")); //$NON-NLS-1$
+ return;
+ }
+
+ MobileBKUEnterTANComposite.this.tan = tan;
+ MobileBKUEnterTANComposite.this.setUserAck(true);
+ MobileBKUEnterTANComposite.this.btn_ok.setEnabled(false);
+ //MobileBKUEnterTANComposite.this.state.updateStateMachine();
+ //MobileBKUEnterTANComposite.this.btn_ok.setEnabled(true);
+ }
+ }
+
+ /**
+ *
+ */
+ private final class CancelSelectionListener extends SelectionAdapter {
+ /**
+ * Empty constructor
+ */
+ public CancelSelectionListener() {
+ }
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ MobileBKUEnterTANComposite.this.setUserCancel(true);
+ }
+ }
+
+ /**
+ * SLF4J Logger instance
+ **/
+ static final Logger log = LoggerFactory
+ .getLogger(MobileBKUEnterTANComposite.class);
+
+ Text txt_tan;
+
+ boolean userAck = false;
+ boolean userCancel = 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;
+ }
+
+ String tan;
+
+ private Label lblTries;
+ private Label lblRefValLabel;
+ private Label lblTan;
+
+ Button btn_ok;
+ Button btn_cancel;
+
+ /**
+ * @return the userAck
+ */
+ public boolean isUserAck() {
+ return this.userAck;
+ }
+
+ /**
+ * @return the userCancel
+ */
+ public boolean isUserCancel() {
+ return this.userCancel;
+ }
+
+ /**
+ * Set how many tries are left
+ *
+ * @param tries
+ */
+ public void setTries(int tries) {
+ this.lblTries.setText(tries == 1 ? Messages.getString("tanEnter.try") : //$NON-NLS-1$
+ String.format(Messages.getString("tanEnter.tries"), tries)); //$NON-NLS-1$
+ }
+
+ /**
+ * Set an error message
+ * @param errorMessage the error message
+ */
+ public void setErrorMessage(String errorMessage) {
+ if (errorMessage == null)
+ this.lblTries.setText(""); //$NON-NLS-1$
+ else
+ this.lblTries.setText(
+ Messages.getString("error.Title") + ": " + errorMessage); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+
+ /**
+ * Sets the message
+ *
+ * @param msg
+ */
+ public void setMessage(String msg) {
+ this.lblTries.setText(msg);
+ this.lblTries.redraw();
+ this.lblTries.getParent().layout(true, true);
+ }
+
+ /**
+ * @param userAck
+ * the userAck to set
+ */
+ public void setUserAck(boolean userAck) {
+ this.userAck = userAck;
+ }
+
+ /**
+ * @param userCancel
+ * the userCancel to set
+ */
+ public void setUserCancel(boolean userCancel) {
+ this.userCancel = userCancel;
+ }
+
+ /**
+ * @return the reference value
+ */
+ public String getRefVal() {
+ return this.refVal;
+ }
+
+ /**
+ * Enables the submit button
+ */
+ public void enableButton() {
+ this.btn_ok.setEnabled(true);
+ }
+
+ /**
+ * @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(""); //$NON-NLS-1$
+ }
+
+ }
+
+ /**
+ * @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(""); //$NON-NLS-1$
+ } else {
+ this.txt_tan.setText(this.tan);
+ }
+ }
+
+ /**
+ * Selection Listener for open button
+ */
+ private final class ShowSignatureDataListener extends SelectionAdapter {
+ /**
+ * Empty constructor
+ */
+ public ShowSignatureDataListener() {
+ }
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ try {
+ String signatureData = MobileBKUEnterTANComposite.this
+ .getSignatureData();
+ if (signatureData != null && !signatureData.equals("")) { //$NON-NLS-1$
+ log.debug("Trying to open " + signatureData); //$NON-NLS-1$
+ if (Desktop.isDesktopSupported()) {
+ Desktop.getDesktop().browse(new URI(signatureData));
+ } else {
+ log.info("SWT Desktop is not supported on this platform"); //$NON-NLS-1$
+ Program.launch(signatureData);
+ }
+ }
+ } catch (Exception ex) {
+ log.error("OpenSelectionListener: ", ex); //$NON-NLS-1$
+ }
+ }
+ }
+
+ /**
+ * 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());
+ FormData fd_containerComposite = new FormData();
+ fd_containerComposite.top = new FormAttachment(50, -120);
+ fd_containerComposite.bottom = new FormAttachment(50, 120);
+ fd_containerComposite.left = new FormAttachment(50, -200);
+ fd_containerComposite.right = new FormAttachment(50, 200);
+ containerComposite.setLayoutData(fd_containerComposite);
+
+ this.lblRefValLabel = new Label(containerComposite, SWT.NATIVE);
+ this.lblRefValLabel.setAlignment(SWT.RIGHT);
+ FormData fd_lblRefValLabel = new FormData();
+ // fd_lblRefValLabel.left = new FormAttachment(0, 20);
+ fd_lblRefValLabel.right = new FormAttachment(50, -10);
+ // fd_lblRefValLabel.top = new FormAttachment(30, -15);
+ fd_lblRefValLabel.bottom = new FormAttachment(50, -10);
+ this.lblRefValLabel.setLayoutData(fd_lblRefValLabel);
+ this.lblRefValLabel.setText(Messages
+ .getString("tanEnter.ReferenceValue")); //$NON-NLS-1$
+
+ Label lbl_image = new Label(containerComposite, SWT.NATIVE);
+
+ ImageData data = new ImageData(this.getClass().getResourceAsStream(
+ Constants.RES_IMG_MOBILE));
+ Image mobile = new Image(getDisplay(), data);
+
+ FormData fd_lbl_image = new FormData();
+ fd_lbl_image.top = new FormAttachment(50, -1 * (data.width / 2));
+ fd_lbl_image.bottom = new FormAttachment(50, data.width / 2);
+ fd_lbl_image.left = new FormAttachment(0, 10);
+ fd_lbl_image.width = data.width;
+ lbl_image.setLayoutData(fd_lbl_image);
+ lbl_image.setImage(mobile);
+
+ this.lblRefVal = new Label(containerComposite, SWT.NATIVE);
+ FormData fd_lblRefVal = new FormData();
+ fd_lblRefVal.left = new FormAttachment(50, 10);
+ fd_lblRefVal.right = new FormAttachment(100, -20);
+ // fd_lblRefVal.top = new FormAttachment(30, -15);
+ fd_lblRefVal.bottom = new FormAttachment(50, -10);
+ this.lblRefVal.setLayoutData(fd_lblRefVal);
+ this.lblRefVal.setText(""); //$NON-NLS-1$
+
+ this.lblTan = new Label(containerComposite, SWT.NATIVE);
+ this.lblTan.setAlignment(SWT.RIGHT);
+ FormData fd_lblTan = new FormData();
+ // fd_lblTan.left = new FormAttachment(0, 20);
+ fd_lblTan.right = new FormAttachment(50, -10);
+ fd_lblTan.top = new FormAttachment(50, 10);
+ // fd_lblTan.bottom = new FormAttachment(50, 15);
+ this.lblTan.setLayoutData(fd_lblTan);
+ this.lblTan.setText(Messages.getString("tanEnter.TAN")); //$NON-NLS-1$
+
+ this.txt_tan = new Text(containerComposite, SWT.BORDER | SWT.NATIVE);
+ FormData fd_text = new FormData();
+ fd_text.left = new FormAttachment(50, 10);
+ fd_text.right = new FormAttachment(100, -20);
+ fd_text.top = new FormAttachment(50, 10);
+ this.txt_tan.setEditable(true);
+ this.txt_tan.setLayoutData(fd_text);
+
+ 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); //$NON-NLS-1$
+ if (text.length() > 3
+ && MobileBKUEnterTANComposite.this.getRefVal()
+ .startsWith(text.trim())) {
+ MobileBKUEnterTANComposite.this.setMessage(Messages
+ .getString("error.EnteredReferenceValue")); //$NON-NLS-1$
+ }
+ }
+ });
+
+ Link lnk_sig_data = new Link(containerComposite, SWT.NATIVE | SWT.RESIZE);
+
+ FormData fd_lnk_data = new FormData();
+ fd_lnk_data.right = new FormAttachment(100, -20);
+ fd_lnk_data.top = new FormAttachment(0, 20);
+ lnk_sig_data.setEnabled(true);
+ lnk_sig_data.setLayoutData(fd_lnk_data);
+ lnk_sig_data.addSelectionListener(new ShowSignatureDataListener());
+ lnk_sig_data.setText(Messages.getString("mobileBKU.show")); //$NON-NLS-1$
+ lnk_sig_data.setToolTipText(Messages.getString("mobileBKU.show_tooltip")); //$NON-NLS-1$
+
+ this.btn_ok = new Button(containerComposite, SWT.NATIVE);
+ this.btn_cancel = new Button(containerComposite, SWT.NATIVE);
+
+ this.lblTries = new Label(containerComposite, SWT.WRAP | SWT.NATIVE);
+ FormData fd_lbl_tries = new FormData();
+ // fd_lbl_tries.left = new FormAttachment(15, 5);
+ fd_lbl_tries.right = new FormAttachment(this.btn_cancel, -10);
+ // fd_lbl_tries.top = new FormAttachment(70, -15);
+ fd_lbl_tries.bottom = new FormAttachment(100, -20);
+ this.lblTries.setLayoutData(fd_lbl_tries);
+
+ FormData fd_btn_ok = new FormData();
+ // fd_btn_ok.left = new FormAttachment(95, 0);
+ fd_btn_ok.right = new FormAttachment(100, -20);
+ //fd_btn_ok.left = new FormAttachment(100, -70);
+ fd_btn_ok.bottom = new FormAttachment(100, -20);
+
+ this.btn_ok.setLayoutData(fd_btn_ok);
+ this.btn_ok.setText(Messages.getString("common.Ok")); //$NON-NLS-1$
+ this.btn_ok.addSelectionListener(new OkSelectionListener());
+
+ FormData fd_btn_cancel = new FormData();
+ // fd_btn_cancel.left = new FormAttachment(95, 0);
+ fd_btn_cancel.right = new FormAttachment(this.btn_ok, -20);
+ //fd_btn_cancel.left = new FormAttachment(100, -70);
+ fd_btn_cancel.bottom = new FormAttachment(100, -20);
+
+ this.btn_cancel.setLayoutData(fd_btn_cancel);
+ this.btn_cancel.setText(Messages.getString("common.Cancel")); //$NON-NLS-1$
+ this.btn_cancel.addSelectionListener(new CancelSelectionListener());
+ }
+
+ @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() {
+ this.lblRefValLabel.setText(Messages
+ .getString("tanEnter.ReferenceValue")); //$NON-NLS-1$
+ this.lblTan.setText(Messages.getString("tanEnter.TAN")); //$NON-NLS-1$
+ }
+}
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/MobileBKUFingerprintComposite.java
index 3544c7f8..eb4771ba 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/MobileBKUFingerprintComposite.java
@@ -90,8 +90,6 @@ public class MobileBKUFingerprintComposite extends StateComposite {
static final Logger log = LoggerFactory
.getLogger(MobileBKUFingerprintComposite.class);
-// private Label lblFP;
-
boolean userCancel = false;
boolean userSMS = false;
boolean done = false;
@@ -304,16 +302,10 @@ public class MobileBKUFingerprintComposite extends StateComposite {
this.lblFPLabel = new Label(containerComposite, SWT.NATIVE);
this.lblFPLabel.setAlignment(SWT.LEFT);
FormData fd_lblFPLabel = new FormData();
- fd_lblFPLabel.left = new FormAttachment(0, 0);
+ fd_lblFPLabel.left = new FormAttachment(25, 10);
fd_lblFPLabel.top = new FormAttachment(this.lblRefValLabel, 10);
this.lblFPLabel.setLayoutData(fd_lblFPLabel);
-// this.lblFP = new Label(containerComposite, SWT.NATIVE);
-// FormData fd_lblFP = new FormData();
-// fd_lblFP.left = new FormAttachment(50, 10);
-// fd_lblFP.right = new FormAttachment(100, -20);
-// fd_lblFP.top = new FormAttachment(this.lblRefVal, 10);
-// this.lblFP.setLayoutData(fd_lblFP);
this.lnk_sig_data = new Link(containerComposite, SWT.NATIVE | SWT.RESIZE);
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 2b9bbe06..cbb0af41 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
@@ -1,485 +1,581 @@
-/*
- * 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.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;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import at.asit.pdfover.gui.MainWindow.Buttons;
-import at.asit.pdfover.gui.MainWindowBehavior;
-import at.asit.pdfover.gui.bku.MobileBKUConnector;
-import at.asit.pdfover.gui.bku.mobile.ATrustHandler;
-import at.asit.pdfover.gui.bku.mobile.ATrustStatus;
-import at.asit.pdfover.gui.bku.mobile.IAIKHandler;
-import at.asit.pdfover.gui.bku.mobile.IAIKStatus;
-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;
-import at.asit.pdfover.gui.utils.Messages;
-import at.asit.pdfover.gui.workflow.StateMachine;
-import at.asit.pdfover.gui.workflow.config.ConfigProvider;
-import at.asit.pdfover.signator.SigningState;
-
-/**
- * Logical state for performing the BKU Request to the A-Trust Mobile BKU
- */
-public class MobileBKUState extends State {
- /**
- * @param stateMachine
- */
- public MobileBKUState(StateMachine stateMachine) {
- super(stateMachine);
- ConfigProvider provider = stateMachine.getConfigProvider();
- switch(provider.getMobileBKUType()) {
- case A_TRUST:
- this.status = new ATrustStatus(provider);
- this.handler = new ATrustHandler(this,
- stateMachine.getGUIProvider().getMainShell(),
- provider.getMobileBKUBase64());
- break;
-
- case IAIK:
- this.status = new IAIKStatus(provider);
- this.handler = new IAIKHandler(this,
- stateMachine.getGUIProvider().getMainShell());
- break;
- }
-
- }
-
- /**
- * SLF4J Logger instance
- **/
- static final Logger log = LoggerFactory
- .getLogger(MobileBKUState.class);
-
- SigningState signingState;
-
- Exception threadException = null;
-
- MobileBKUStatus status = null;
-
- MobileBKUHandler handler = null;
-
- MobileBKUEnterNumberComposite mobileBKUEnterNumberComposite = null;
-
- MobileBKUEnterTANComposite mobileBKUEnterTANComposite = null;
-
- MobileBKUQRComposite mobileBKUQRComposite = null;
-
- WaitingComposite waitingComposite = null;
-
- WaitingComposite getWaitingComposite() {
- if (this.waitingComposite == null) {
- this.waitingComposite = getStateMachine().getGUIProvider()
- .createComposite(WaitingComposite.class, SWT.RESIZE, this);
- }
-
- return this.waitingComposite;
- }
-
- MobileBKUEnterTANComposite getMobileBKUEnterTANComposite() {
- if (this.mobileBKUEnterTANComposite == null) {
- this.mobileBKUEnterTANComposite = getStateMachine()
- .getGUIProvider().createComposite(
- MobileBKUEnterTANComposite.class, SWT.RESIZE, this);
- }
-
- 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()
- .getGUIProvider().createComposite(
- MobileBKUEnterNumberComposite.class, SWT.RESIZE,
- this);
- }
-
- return this.mobileBKUEnterNumberComposite;
- }
-
- /**
- * Get the MobileBKUStatus
- * @return the MobileBKUStatus
- */
- public MobileBKUStatus getStatus() {
- return this.status;
- }
-
- /**
- * Get the MobileBKUHandler
- * @return the MobileBKUHandler
- */
- public MobileBKUHandler getHandler() {
- return this.handler;
- }
-
- /**
- * Get the mobile BKU URL
- * @return the mobile BKU URL
- */
- public String getURL() {
- return getStateMachine().getConfigProvider().getMobileBKUURL();
- }
-
- /**
- * @return the signingState
- */
- public SigningState getSigningState() {
- return this.signingState;
- }
-
- /**
- * @param threadException
- * the threadException to set
- */
- public void setThreadException(Exception threadException) {
- this.threadException = threadException;
- }
-
- /**
- * Display an error message
- *
- * @param e
- * the exception
- */
- public void displayError(Exception e) {
- String message = Messages.getString("error.Unexpected"); //$NON-NLS-1$
- log.error(message, e);
- String errormsg = e.getLocalizedMessage();
- if (errormsg != null && !errormsg.isEmpty())
- message += ": " + errormsg; //$NON-NLS-1$
- displayError(message);
- }
-
- /**
- * Display an error message
- *
- * @param message
- * the error message
- */
- public void displayError(final String message) {
- log.error(message);
- Display.getDefault().syncExec(new Runnable() {
- @Override
- public void run() {
- ErrorDialog error = new ErrorDialog(getStateMachine().getGUIProvider()
- .getMainShell(), message, BUTTONS.OK);
- error.open();
- }
- });
- }
-
- /**
- * Make sure phone number and password are set in the MobileBKUStatus
- */
- public void checkCredentials() {
- final MobileBKUStatus mobileStatus = this.getStatus();
- // check if we have everything we need!
- if (mobileStatus.getPhoneNumber() != null && !mobileStatus.getPhoneNumber().isEmpty() &&
- mobileStatus.getMobilePassword() != null && !mobileStatus.getMobilePassword().isEmpty())
- return;
-
- Display.getDefault().syncExec(new Runnable() {
- @Override
- public void run() {
- MobileBKUEnterNumberComposite ui = MobileBKUState.this
- .getMobileBKUEnterNumberComposite();
-
- if (!ui.isUserAck()) {
- // We need number and password => show UI!
- if (mobileStatus.getErrorMessage() != null
- && !mobileStatus.getErrorMessage().isEmpty()) {
- // set possible error message
- ui.setErrorMessage(mobileStatus.getErrorMessage());
- mobileStatus.setErrorMessage(null);
- } else if (mobileStatus instanceof ATrustStatus) {
- ui.setErrorMessage(Messages.getString("mobileBKU.aTrustDisclaimer")); //$NON-NLS-1$
- }
-
- if (ui.getMobileNumber() == null
- || ui.getMobileNumber().isEmpty()) {
- // set possible phone number
- ui.setMobileNumber(mobileStatus.getPhoneNumber());
- }
-
- if (ui.getMobilePassword() == null
- || ui.getMobilePassword().isEmpty()) {
- // set possible password
- ui.setMobilePassword(mobileStatus.getMobilePassword());
- }
- ui.enableButton();
- getStateMachine().getGUIProvider().display(ui);
-
- Display display = getStateMachine().getGUIProvider().getMainShell().getDisplay();
- while (!ui.isUserAck() && !ui.isUserCancel()) {
- if (!display.readAndDispatch()) {
- display.sleep();
- }
- }
- }
-
- if (ui.isUserCancel()) {
- ui.setUserCancel(false);
- mobileStatus.setErrorMessage("cancel"); //$NON-NLS-1$
- return;
- }
-
- // user hit ok
- ui.setUserAck(false);
-
- // get number and password from UI
- mobileStatus.setPhoneNumber(ui.getMobileNumber());
- mobileStatus.setMobilePassword(ui.getMobilePassword());
-
- // show waiting composite
- getStateMachine().getGUIProvider().display(
- MobileBKUState.this.getWaitingComposite());
- }
- });
- }
-
- /**
- * Make sure TAN is set in the MobileBKUStatus
- */
- public void checkTAN() {
- final MobileBKUStatus mobileStatus = this.getStatus();
-
- Display.getDefault().syncExec(new Runnable() {
- @Override
- public void run() {
- MobileBKUEnterTANComposite tan = MobileBKUState.this
- .getMobileBKUEnterTANComposite();
-
- if (!tan.isUserAck()) {
- // we need the TAN
- tan.setRefVal(mobileStatus.getRefVal());
- tan.setSignatureData(mobileStatus.getSignatureDataURL());
- tan.setErrorMessage(mobileStatus.getErrorMessage());
- if (mobileStatus.getTanTries() < mobileStatus.getMaxTanTries()
- && mobileStatus.getTanTries() > 0) {
- // show warning message x tries left!
- // overrides error message
-
- tan.setTries(mobileStatus.getTanTries());
- }
- tan.enableButton();
- getStateMachine().getGUIProvider().display(tan);
-
- Display display = getStateMachine().getGUIProvider().getMainShell().getDisplay();
- while (!tan.isUserAck() && !tan.isUserCancel()) {
- if (!display.readAndDispatch()) {
- display.sleep();
- }
- }
- }
-
- if (tan.isUserCancel()) {
- tan.setUserCancel(false);
- mobileStatus.setErrorMessage("cancel"); //$NON-NLS-1$
- return;
- }
-
- // user hit ok!
- tan.setUserAck(false);
-
- mobileStatus.setTan(tan.getTan());
-
- // show waiting composite
- getStateMachine().getGUIProvider().display(
- MobileBKUState.this.getWaitingComposite());
- }
- });
- }
-
- /**
- * 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)
- *
- * @see
- * at.asit.pdfover.gui.workflow.WorkflowState#update(at.asit.pdfover.gui
- * .workflow.Workflow)
- */
- @Override
- public void run() {
- this.signingState = getStateMachine().getStatus().getSigningState();
-
- this.signingState.setBKUConnector(new MobileBKUConnector(this));
- log.debug("Setting base64 request to " + this.handler.useBase64Request()); //$NON-NLS-1$
- this.signingState.setUseBase64Request(this.handler.useBase64Request());
-
- if (this.threadException != null) {
- String message = Messages.getString("error.Unexpected"); //$NON-NLS-1$
- log.error(message, this.threadException);
- String errormsg = this.threadException.getLocalizedMessage();
- if (errormsg != null && !errormsg.isEmpty())
- message += ": " + errormsg; //$NON-NLS-1$
- ErrorDialog error = new ErrorDialog(
- getStateMachine().getGUIProvider().getMainShell(),
- message, BUTTONS.OK);
- // error.setException(this.threadException);
- // this.setNextState(error);
- error.open();
- getStateMachine().exit();
- return;
- }
-
- getStateMachine().getGUIProvider().display(
- this.getWaitingComposite());
-
- this.setNextState(new at.asit.pdfover.gui.workflow.states.SigningState(getStateMachine()));
- }
-
- /*
- * (non-Javadoc)
- *
- * @see at.asit.pdfover.gui.workflow.states.State#cleanUp()
- */
- @Override
- public void cleanUp() {
- if (this.mobileBKUEnterNumberComposite != null)
- this.mobileBKUEnterNumberComposite.dispose();
- if (this.mobileBKUEnterTANComposite != null)
- this.mobileBKUEnterTANComposite.dispose();
- if (this.waitingComposite != null)
- this.waitingComposite.dispose();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see at.asit.pdfover.gui.workflow.states.State#setMainWindowBehavior()
- */
- @Override
- public void updateMainWindowBehavior() {
- MainWindowBehavior behavior = getStateMachine().getStatus()
- .getBehavior();
- behavior.reset();
- behavior.setActive(Buttons.OPEN, true);
- behavior.setActive(Buttons.POSITION, true);
- behavior.setActive(Buttons.SIGN, true);
- behavior.setEnabled(Buttons.OPEN, true);
- behavior.setEnabled(Buttons.POSITION, true);
- //behavior.setEnabled(Buttons.SIGN, true);
- }
-
- @Override
- public String toString() {
- return this.getClass().getName();
- }
-
- /**
- * invoke state machine update in main thread
- */
- public void invokeUpdate() {
- getStateMachine().invokeUpdate();
- }
-}
+/*
+ * 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.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;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import at.asit.pdfover.gui.MainWindow.Buttons;
+import at.asit.pdfover.gui.MainWindowBehavior;
+import at.asit.pdfover.gui.bku.MobileBKUConnector;
+import at.asit.pdfover.gui.bku.mobile.ATrustHandler;
+import at.asit.pdfover.gui.bku.mobile.ATrustStatus;
+import at.asit.pdfover.gui.bku.mobile.IAIKHandler;
+import at.asit.pdfover.gui.bku.mobile.IAIKStatus;
+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.MobileBKUFingerprintComposite;
+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;
+import at.asit.pdfover.gui.utils.Messages;
+import at.asit.pdfover.gui.workflow.StateMachine;
+import at.asit.pdfover.gui.workflow.config.ConfigProvider;
+import at.asit.pdfover.signator.SigningState;
+
+/**
+ * Logical state for performing the BKU Request to the A-Trust Mobile BKU
+ */
+public class MobileBKUState extends State {
+ /**
+ * @param stateMachine
+ */
+ public MobileBKUState(StateMachine stateMachine) {
+ super(stateMachine);
+ ConfigProvider provider = stateMachine.getConfigProvider();
+ switch(provider.getMobileBKUType()) {
+ case A_TRUST:
+ this.status = new ATrustStatus(provider);
+ this.handler = new ATrustHandler(this,
+ stateMachine.getGUIProvider().getMainShell(),
+ provider.getMobileBKUBase64());
+ break;
+
+ case IAIK:
+ this.status = new IAIKStatus(provider);
+ this.handler = new IAIKHandler(this,
+ stateMachine.getGUIProvider().getMainShell());
+ break;
+ }
+
+ }
+
+ /**
+ * SLF4J Logger instance
+ **/
+ static final Logger log = LoggerFactory
+ .getLogger(MobileBKUState.class);
+
+ SigningState signingState;
+
+ Exception threadException = null;
+
+ MobileBKUStatus status = null;
+
+ MobileBKUHandler handler = null;
+
+ MobileBKUEnterNumberComposite mobileBKUEnterNumberComposite = null;
+
+ MobileBKUEnterTANComposite mobileBKUEnterTANComposite = null;
+
+ MobileBKUQRComposite mobileBKUQRComposite = null;
+
+ MobileBKUFingerprintComposite mobileBKUFingerprintComposite = null;
+
+ WaitingComposite waitingComposite = null;
+
+ WaitingComposite getWaitingComposite() {
+ if (this.waitingComposite == null) {
+ this.waitingComposite = getStateMachine().getGUIProvider()
+ .createComposite(WaitingComposite.class, SWT.RESIZE, this);
+ }
+
+ return this.waitingComposite;
+ }
+
+ MobileBKUEnterTANComposite getMobileBKUEnterTANComposite() {
+ if (this.mobileBKUEnterTANComposite == null) {
+ this.mobileBKUEnterTANComposite = getStateMachine()
+ .getGUIProvider().createComposite(
+ MobileBKUEnterTANComposite.class, SWT.RESIZE, this);
+ }
+
+ 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()
+ .getGUIProvider().createComposite(
+ MobileBKUEnterNumberComposite.class, SWT.RESIZE,
+ this);
+ }
+
+ return this.mobileBKUEnterNumberComposite;
+ }
+
+
+
+
+ MobileBKUFingerprintComposite getMobileBKUFingerprintComposite() {
+ if (this.mobileBKUFingerprintComposite == null) {
+ this.mobileBKUFingerprintComposite = getStateMachine()
+ .getGUIProvider().createComposite(
+ MobileBKUFingerprintComposite.class, SWT.RESIZE,
+ this);
+ }
+
+ return this.mobileBKUFingerprintComposite;
+ }
+
+
+ /**
+ * Get the MobileBKUStatus
+ * @return the MobileBKUStatus
+ */
+ public MobileBKUStatus getStatus() {
+ return this.status;
+ }
+
+ /**
+ * Get the MobileBKUHandler
+ * @return the MobileBKUHandler
+ */
+ public MobileBKUHandler getHandler() {
+ return this.handler;
+ }
+
+ /**
+ * Get the mobile BKU URL
+ * @return the mobile BKU URL
+ */
+ public String getURL() {
+ return getStateMachine().getConfigProvider().getMobileBKUURL();
+ }
+
+ /**
+ * @return the signingState
+ */
+ public SigningState getSigningState() {
+ return this.signingState;
+ }
+
+ /**
+ * @param threadException
+ * the threadException to set
+ */
+ public void setThreadException(Exception threadException) {
+ this.threadException = threadException;
+ }
+
+ /**
+ * Display an error message
+ *
+ * @param e
+ * the exception
+ */
+ public void displayError(Exception e) {
+ String message = Messages.getString("error.Unexpected"); //$NON-NLS-1$
+ log.error(message, e);
+ String errormsg = e.getLocalizedMessage();
+ if (errormsg != null && !errormsg.isEmpty())
+ message += ": " + errormsg; //$NON-NLS-1$
+ displayError(message);
+ }
+
+ /**
+ * Display an error message
+ *
+ * @param message
+ * the error message
+ */
+ public void displayError(final String message) {
+ log.error(message);
+ Display.getDefault().syncExec(new Runnable() {
+ @Override
+ public void run() {
+ ErrorDialog error = new ErrorDialog(getStateMachine().getGUIProvider()
+ .getMainShell(), message, BUTTONS.OK);
+ error.open();
+ }
+ });
+ }
+
+ /**
+ * Make sure phone number and password are set in the MobileBKUStatus
+ */
+ public void checkCredentials() {
+ final MobileBKUStatus mobileStatus = this.getStatus();
+ // check if we have everything we need!
+ if (mobileStatus.getPhoneNumber() != null && !mobileStatus.getPhoneNumber().isEmpty() &&
+ mobileStatus.getMobilePassword() != null && !mobileStatus.getMobilePassword().isEmpty())
+ return;
+
+ Display.getDefault().syncExec(new Runnable() {
+ @Override
+ public void run() {
+ MobileBKUEnterNumberComposite ui = MobileBKUState.this
+ .getMobileBKUEnterNumberComposite();
+
+ if (!ui.isUserAck()) {
+ // We need number and password => show UI!
+ if (mobileStatus.getErrorMessage() != null
+ && !mobileStatus.getErrorMessage().isEmpty()) {
+ // set possible error message
+ ui.setErrorMessage(mobileStatus.getErrorMessage());
+ mobileStatus.setErrorMessage(null);
+ } else if (mobileStatus instanceof ATrustStatus) {
+ ui.setErrorMessage(Messages.getString("mobileBKU.aTrustDisclaimer")); //$NON-NLS-1$
+ }
+
+ if (ui.getMobileNumber() == null
+ || ui.getMobileNumber().isEmpty()) {
+ // set possible phone number
+ ui.setMobileNumber(mobileStatus.getPhoneNumber());
+ }
+
+ if (ui.getMobilePassword() == null
+ || ui.getMobilePassword().isEmpty()) {
+ // set possible password
+ ui.setMobilePassword(mobileStatus.getMobilePassword());
+ }
+ ui.enableButton();
+ getStateMachine().getGUIProvider().display(ui);
+
+ Display display = getStateMachine().getGUIProvider().getMainShell().getDisplay();
+ while (!ui.isUserAck() && !ui.isUserCancel()) {
+ if (!display.readAndDispatch()) {
+ display.sleep();
+ }
+ }
+ }
+
+ if (ui.isUserCancel()) {
+ ui.setUserCancel(false);
+ mobileStatus.setErrorMessage("cancel"); //$NON-NLS-1$
+ return;
+ }
+
+ // user hit ok
+ ui.setUserAck(false);
+
+ // get number and password from UI
+ mobileStatus.setPhoneNumber(ui.getMobileNumber());
+ mobileStatus.setMobilePassword(ui.getMobilePassword());
+
+ // show waiting composite
+ getStateMachine().getGUIProvider().display(
+ MobileBKUState.this.getWaitingComposite());
+ }
+ });
+ }
+
+ /**
+ * Make sure TAN is set in the MobileBKUStatus
+ */
+ public void checkTAN() {
+ final MobileBKUStatus mobileStatus = this.getStatus();
+
+ Display.getDefault().syncExec(new Runnable() {
+ @Override
+ public void run() {
+ MobileBKUEnterTANComposite tan = MobileBKUState.this
+ .getMobileBKUEnterTANComposite();
+
+ if (!tan.isUserAck()) {
+ // we need the TAN
+ tan.setRefVal(mobileStatus.getRefVal());
+ tan.setSignatureData(mobileStatus.getSignatureDataURL());
+ tan.setErrorMessage(mobileStatus.getErrorMessage());
+ if (mobileStatus.getTanTries() < mobileStatus.getMaxTanTries()
+ && mobileStatus.getTanTries() > 0) {
+ // show warning message x tries left!
+ // overrides error message
+
+ tan.setTries(mobileStatus.getTanTries());
+ }
+ tan.enableButton();
+ getStateMachine().getGUIProvider().display(tan);
+
+ Display display = getStateMachine().getGUIProvider().getMainShell().getDisplay();
+ while (!tan.isUserAck() && !tan.isUserCancel()) {
+ if (!display.readAndDispatch()) {
+ display.sleep();
+ }
+ }
+ }
+
+ if (tan.isUserCancel()) {
+ tan.setUserCancel(false);
+ mobileStatus.setErrorMessage("cancel"); //$NON-NLS-1$
+ return;
+ }
+
+ // user hit ok!
+ tan.setUserAck(false);
+
+ mobileStatus.setTan(tan.getTan());
+
+ // show waiting composite
+ getStateMachine().getGUIProvider().display(
+ MobileBKUState.this.getWaitingComposite());
+ }
+ });
+ }
+
+ /**
+ * 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());
+ }
+ });
+ }
+
+
+ /**
+ * when fingerprint or faceid is selected in the app
+ * this information is shown
+ */
+ public void showFingerPrintInformation() {
+ 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$
+ getMobileBKUFingerprintComposite().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() {
+ MobileBKUFingerprintComposite fingerprintComposite = getMobileBKUFingerprintComposite();
+
+ fingerprintComposite.setRefVal(status.getRefVal());
+ fingerprintComposite.setSignatureData(status.getSignatureDataURL());
+ fingerprintComposite.setErrorMessage(status.getErrorMessage());
+ getStateMachine().getGUIProvider().display(fingerprintComposite);
+
+ Display display = getStateMachine().getGUIProvider().getMainShell().getDisplay();
+ while (!fingerprintComposite.isUserCancel() && !fingerprintComposite.isUserSMS() && !fingerprintComposite.isDone()) {
+ if (!display.readAndDispatch()) {
+ display.sleep();
+ }
+ }
+ checkDone.cancel();
+
+ if (fingerprintComposite.isUserCancel()) {
+ fingerprintComposite.setUserCancel(false);
+ status.setErrorMessage("cancel"); //$NON-NLS-1$
+ return;
+ }
+
+ if (fingerprintComposite.isUserSMS()) {
+// fingerprintComposite.setUserSMS(false);
+ status.setQRCode(null);
+ }
+
+ if (fingerprintComposite.isDone())
+ fingerprintComposite.setDone(false);
+
+ // show waiting composite
+ getStateMachine().getGUIProvider().display(
+ MobileBKUState.this.getWaitingComposite());
+ }
+ });
+ }
+
+ /**
+ * @return a boolean true if the user has pressed the sms tan button
+ */
+ public boolean getSMSStatus() {
+
+ return this.getMobileBKUFingerprintComposite().isUserSMS();
+ }
+
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * at.asit.pdfover.gui.workflow.WorkflowState#update(at.asit.pdfover.gui
+ * .workflow.Workflow)
+ */
+ @Override
+ public void run() {
+ this.signingState = getStateMachine().getStatus().getSigningState();
+
+ this.signingState.setBKUConnector(new MobileBKUConnector(this));
+ log.debug("Setting base64 request to " + this.handler.useBase64Request()); //$NON-NLS-1$
+ this.signingState.setUseBase64Request(this.handler.useBase64Request());
+
+ if (this.threadException != null) {
+ String message = Messages.getString("error.Unexpected"); //$NON-NLS-1$
+ log.error(message, this.threadException);
+ String errormsg = this.threadException.getLocalizedMessage();
+ if (errormsg != null && !errormsg.isEmpty())
+ message += ": " + errormsg; //$NON-NLS-1$
+ ErrorDialog error = new ErrorDialog(
+ getStateMachine().getGUIProvider().getMainShell(),
+ message, BUTTONS.OK);
+ // error.setException(this.threadException);
+ // this.setNextState(error);
+ error.open();
+ getStateMachine().exit();
+ return;
+ }
+
+ getStateMachine().getGUIProvider().display(
+ this.getWaitingComposite());
+
+ this.setNextState(new at.asit.pdfover.gui.workflow.states.SigningState(getStateMachine()));
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see at.asit.pdfover.gui.workflow.states.State#cleanUp()
+ */
+ @Override
+ public void cleanUp() {
+ if (this.mobileBKUEnterNumberComposite != null)
+ this.mobileBKUEnterNumberComposite.dispose();
+ if (this.mobileBKUEnterTANComposite != null)
+ this.mobileBKUEnterTANComposite.dispose();
+ if (this.waitingComposite != null)
+ this.waitingComposite.dispose();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see at.asit.pdfover.gui.workflow.states.State#setMainWindowBehavior()
+ */
+ @Override
+ public void updateMainWindowBehavior() {
+ MainWindowBehavior behavior = getStateMachine().getStatus()
+ .getBehavior();
+ behavior.reset();
+ behavior.setActive(Buttons.OPEN, true);
+ behavior.setActive(Buttons.POSITION, true);
+ behavior.setActive(Buttons.SIGN, true);
+ behavior.setEnabled(Buttons.OPEN, true);
+ behavior.setEnabled(Buttons.POSITION, true);
+ //behavior.setEnabled(Buttons.SIGN, true);
+ }
+
+ @Override
+ public String toString() {
+ return this.getClass().getName();
+ }
+
+ /**
+ * invoke state machine update in main thread
+ */
+ public void invokeUpdate() {
+ getStateMachine().invokeUpdate();
+ }
+}