summaryrefslogtreecommitdiff
path: root/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/LocalBKUState.java
diff options
context:
space:
mode:
authortkellner <tkellner@174cde9d-5d70-4d2a-aa98-46368bc2aaf7>2013-04-10 18:57:50 +0000
committertkellner <tkellner@174cde9d-5d70-4d2a-aa98-46368bc2aaf7>2013-04-10 18:57:50 +0000
commit0708bf4d1e1a9046c82c221170b3dd3709e71141 (patch)
tree386515c4dc318da9b466580301e39164ea8eea65 /pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/LocalBKUState.java
parentfdc0f9a9dfc7dabdc96bb830a079a353f160395c (diff)
downloadpdf-over-0708bf4d1e1a9046c82c221170b3dd3709e71141.tar.gz
pdf-over-0708bf4d1e1a9046c82c221170b3dd3709e71141.tar.bz2
pdf-over-0708bf4d1e1a9046c82c221170b3dd3709e71141.zip
Removed Error State and replaced it with ErrorDialog
To get a stable user experience in case of an error. ErrorDialog was improved to let the user decide if he wants to retry an action. git-svn-id: https://joinup.ec.europa.eu/svn/pdf-over/trunk@58 174cde9d-5d70-4d2a-aa98-46368bc2aaf7
Diffstat (limited to 'pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/LocalBKUState.java')
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/LocalBKUState.java81
1 files changed, 43 insertions, 38 deletions
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/LocalBKUState.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/LocalBKUState.java
index 9962d968..58e957b9 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/LocalBKUState.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/LocalBKUState.java
@@ -37,32 +37,32 @@ import at.asit.pdfover.signator.SLResponse;
* Logical state for performing the BKU Request to a local BKU
*/
public class LocalBKUState extends State {
-
+
/**
* HTTP Response server HEADER
*/
public final static String BKU_REPSONE_HEADER_SERVER = "server"; //$NON-NLS-1$
-
+
/**
* HTTP Response user-agent HEADER
*/
public final static String BKU_REPSONE_HEADER_USERAGENT = "user-agent"; //$NON-NLS-1$
-
+
/**
* HTTP Response SignatureLayout HEADER
*/
public final static String BKU_REPSONE_HEADER_SIGNATURE_LAYOUT = "SignatureLayout"; //$NON-NLS-1$
-
+
/**
* TODO: move to a better location ...
*/
public static final String PDF_OVER_USER_AGENT_STRING = "PDF-Over 4.0"; //$NON-NLS-1$
-
+
/**
*
*/
private final class SignLocalBKUThread implements Runnable {
-
+
private LocalBKUState state;
/**
@@ -81,44 +81,45 @@ public class LocalBKUState extends State {
String sl_request = request.getBase64Request();
HttpClient client = new HttpClient();
-
PostMethod method = new PostMethod(
"http://127.0.0.1:3495/http-security-layer-request"); //$NON-NLS-1$
-
+
log.debug("SL REQUEST: " + sl_request); //$NON-NLS-1$
-
+
method.addParameter("XMLRequest", sl_request); //$NON-NLS-1$
-
+
int returnCode = client.executeMethod(method);
-
- if(returnCode == HttpStatus.SC_OK)
- {
+
+ if (returnCode == HttpStatus.SC_OK) {
String server = ""; //$NON-NLS-1$
String userAgent = ""; //$NON-NLS-1$
String signatureLayout = ""; //$NON-NLS-1$
-
- if(method.getResponseHeader(BKU_REPSONE_HEADER_SERVER) != null)
- {
- server = method.getResponseHeader(BKU_REPSONE_HEADER_SERVER).getValue();
+
+ if (method.getResponseHeader(BKU_REPSONE_HEADER_SERVER) != null) {
+ server = method.getResponseHeader(
+ BKU_REPSONE_HEADER_SERVER).getValue();
}
-
- if(method.getResponseHeader(BKU_REPSONE_HEADER_USERAGENT) != null)
- {
- userAgent = method.getResponseHeader(BKU_REPSONE_HEADER_USERAGENT).getValue();
+
+ if (method.getResponseHeader(BKU_REPSONE_HEADER_USERAGENT) != null) {
+ userAgent = method.getResponseHeader(
+ BKU_REPSONE_HEADER_USERAGENT).getValue();
}
-
- if(method.getResponseHeader(BKU_REPSONE_HEADER_SIGNATURE_LAYOUT) != null)
- {
- signatureLayout = method.getResponseHeader(BKU_REPSONE_HEADER_SIGNATURE_LAYOUT).getValue();
+
+ if (method
+ .getResponseHeader(BKU_REPSONE_HEADER_SIGNATURE_LAYOUT) != null) {
+ signatureLayout = method.getResponseHeader(
+ BKU_REPSONE_HEADER_SIGNATURE_LAYOUT).getValue();
}
-
+
String response = method.getResponseBodyAsString();
log.debug("SL Response: " + response); //$NON-NLS-1$
- SLResponse slResponse = new SLResponse(response, server, userAgent, signatureLayout);
+ SLResponse slResponse = new SLResponse(response, server,
+ userAgent, signatureLayout);
this.state.signingState.setSignatureResponse(slResponse);
} else {
- this.state.threadException = new HttpException(method.getResponseBodyAsString());
+ this.state.threadException = new HttpException(
+ method.getResponseBodyAsString());
}
} catch (Exception e) {
@@ -141,13 +142,12 @@ public class LocalBKUState extends State {
/**
* SLF4J Logger instance
**/
- static final Logger log = LoggerFactory
- .getLogger(LocalBKUState.class);
+ static final Logger log = LoggerFactory.getLogger(LocalBKUState.class);
at.asit.pdfover.signator.SigningState signingState;
Exception threadException = null;
-
+
/*
* (non-Javadoc)
*
@@ -161,22 +161,27 @@ public class LocalBKUState extends State {
this.signingState = status.getSigningState();
- if (!this.signingState.hasSignatureResponse() &&
- this.threadException == null
- ) {
+ if (!this.signingState.hasSignatureResponse()
+ && this.threadException == null) {
Thread t = new Thread(new SignLocalBKUThread(this));
t.start();
return;
}
- if(this.threadException != null) {
- ErrorDialog dialog = new ErrorDialog(Display.getCurrent().getActiveShell(), SWT.NONE, "Please check if a local BKU is running", this.threadException);
- dialog.open();
+ if (this.threadException != null) {
+ ErrorDialog dialog = new ErrorDialog(
+ this.stateMachine.getGUIProvider().getMainShell(), SWT.NONE,
+ "Please check if a local BKU is running",
+ this.threadException, true);
+ if (!dialog.open()) {
+ this.stateMachine.exit();
+ return;
+ }
this.threadException = null;
this.run();
return;
}
-
+
// OK
this.setNextState(new SigningState(this.stateMachine));
}