diff options
author | Jakob Heher <jakob.heher@iaik.tugraz.at> | 2022-07-06 11:31:01 +0200 |
---|---|---|
committer | Jakob Heher <jakob.heher@iaik.tugraz.at> | 2022-07-06 11:31:01 +0200 |
commit | 9a1263c3ccb75285fe7b8a08b39c5b8a9433d1cd (patch) | |
tree | 27c56842e3633c424e28fa49962a555c3207d0d1 | |
parent | c598f60380077e4e156f3ad4424eb42ec8aa0f28 (diff) | |
download | pdf-over-9a1263c3ccb75285fe7b8a08b39c5b8a9433d1cd.tar.gz pdf-over-9a1263c3ccb75285fe7b8a08b39c5b8a9433d1cd.tar.bz2 pdf-over-9a1263c3ccb75285fe7b8a08b39c5b8a9433d1cd.zip |
YAGNI? YAGNI.
12 files changed, 220 insertions, 717 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 4ea96f04..c1b30add 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 @@ -71,7 +71,7 @@ public class MobileBKUConnector implements BkuSlConnector { handler.handleSLRequestResponse(responseData);
} catch (Exception ex) {
log.error("Error in PostSLRequestThread", ex); //$NON-NLS-1$
- this.state.setThreadException(ex);
+ this.state.threadException = ex;
this.state.displayError(ex);
throw new SignatureException(ex);
}
@@ -80,8 +80,8 @@ public class MobileBKUConnector implements BkuSlConnector { // Check if credentials are available, get them from user if not
this.state.checkCredentials();
- if (this.state.status.getErrorMessage() != null &&
- this.state.status.getErrorMessage().equals("cancel")) //$NON-NLS-1$
+ if (this.state.status.errorMessage != null &&
+ this.state.status.errorMessage.equals("cancel")) //$NON-NLS-1$
throw new SignatureException(new IllegalStateException());
// Post credentials
@@ -92,11 +92,11 @@ public class MobileBKUConnector implements BkuSlConnector { // handle polling
this.state.showOpenAppMessageWithSMSandCancel();
- if (((ATrustStatus) this.state.status).isSmsTan()) {
+ if (((ATrustStatus) this.state.status).isSMSTan) {
ATrustHandler aHandler = (ATrustHandler) handler;
String response = aHandler.postSMSRequest();
aHandler.handleCredentialsResponse(response);
- } else if (handleErrorMessage()) {
+ } else if (consumeCancelError()) {
throw new SignatureException(new IllegalStateException());
}
} else {
@@ -108,10 +108,10 @@ public class MobileBKUConnector implements BkuSlConnector { } catch (Exception ex) {
log.error("Error in PostCredentialsThread", ex); //$NON-NLS-1$
- this.state.setThreadException(new IllegalStateException());
+ this.state.threadException = new IllegalStateException();
throw new SignatureException(new IllegalStateException());
}
- } while(this.state.status.getErrorMessage() != null);
+ } while(this.state.status.errorMessage != null);
// Check if response is already available
if (signingState.hasSignatureResponse()) {
@@ -127,19 +127,19 @@ public class MobileBKUConnector implements BkuSlConnector { if (status instanceof ATrustStatus) {
ATrustStatus aStatus = (ATrustStatus) status;
ATrustHandler aHandler = (ATrustHandler) handler;
- if (aStatus.getQRCodeURL() != null) {
+ if (aStatus.qrCodeURL != null) {
this.state.showQR();
- if (this.state.status.getErrorMessage() != null &&
- this.state.status.getErrorMessage().equals("cancel")) //$NON-NLS-1$
+ if (this.state.status.errorMessage != null &&
+ this.state.status.errorMessage.equals("cancel")) //$NON-NLS-1$
throw new SignatureException(new IllegalStateException());
- if (aStatus.getQRCodeURL() == null) {
+ if (aStatus.qrCodeURL == null) {
try {
String response = aHandler.postSMSRequest();
log.trace("Response from mobile BKU: " + response); //$NON-NLS-1$
handler.handleCredentialsResponse(response);
} catch (Exception ex) {
log.error("Error in PostCredentialsThread", ex); //$NON-NLS-1$
- this.state.setThreadException(new IllegalStateException());
+ this.state.threadException = new IllegalStateException();
throw new SignatureException(new IllegalStateException());
}
} else {
@@ -150,12 +150,12 @@ public class MobileBKUConnector implements BkuSlConnector { try {
this.state.showFingerPrintInformation();
- if (this.state.status.getErrorMessage() != null &&
- this.state.status.getErrorMessage().equals("cancel")) //$NON-NLS-1$
+ if (this.state.status.errorMessage != null &&
+ this.state.status.errorMessage.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(new IllegalStateException());
+ this.state.threadException = new IllegalStateException();
//this.state.displayError(ex);
throw new SignatureException(new IllegalStateException());
}
@@ -167,7 +167,7 @@ public class MobileBKUConnector implements BkuSlConnector { handler.handleCredentialsResponse(response);
} catch (Exception e) {
log.error("Error in PostCredentialsThread", e); //$NON-NLS-1$
- this.state.setThreadException(e);
+ this.state.threadException = e;
this.state.displayError(e);
throw new SignatureException(e);
}
@@ -183,8 +183,8 @@ public class MobileBKUConnector implements BkuSlConnector { this.state.checkTAN();
- if (this.state.status.getErrorMessage() != null &&
- this.state.status.getErrorMessage().equals("cancel")) //$NON-NLS-1$
+ if (this.state.status.errorMessage != null &&
+ this.state.status.errorMessage.equals("cancel")) //$NON-NLS-1$
throw new SignatureException(new IllegalStateException());
// Post TAN
@@ -196,26 +196,25 @@ public class MobileBKUConnector implements BkuSlConnector { handler.handleTANResponse(responseData);
} catch (Exception ex) {
log.error("Error in PostTanThread", ex); //$NON-NLS-1$
- this.state.setThreadException(ex);
+ this.state.threadException = ex;
this.state.displayError(ex);
throw new SignatureException(ex);
}
}
- } while (this.state.status.getErrorMessage() != null);
- if (this.state.status.getTanTries() == -1)
+ } while (this.state.status.errorMessage != null);
+ if (this.state.status.tanTries == -1)
throw new SignatureException(new IllegalStateException());
- } while (this.state.status.getTanTries() == -2);
+ } while (this.state.status.tanTries == -2);
return signingState.getSignatureResponse();
}
- private boolean handleErrorMessage() {
+ private boolean consumeCancelError() {
if (this.state.status instanceof ATrustStatus) {
- ATrustStatus aStatus = (ATrustStatus)this.state.status ;
- if (aStatus.getErrorMessage() != null &&
- aStatus.getErrorMessage().equals("cancel")) { //$NON-NLS-1$
- ((ATrustStatus)this.state.status).setErrorMessage(null);
+ if (this.state.status.errorMessage != null &&
+ this.state.status.errorMessage.equals("cancel")) { //$NON-NLS-1$
+ this.state.status.errorMessage = null;
return true;
}
}
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 d5353b3e..1e996b21 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 @@ -117,14 +117,14 @@ public class ATrustHandler extends MobileBKUHandler { log.info("viewState: " + viewState); //$NON-NLS-1$
log.info("eventValidation: " + eventValidation); //$NON-NLS-1$
- status.setSessionID(sessionID);
- status.setViewstate(viewState);
- status.setEventvalidation(eventValidation);
- if (viewstateGenerator != null ) { status.setViewStateGenerator(viewstateGenerator); }
- status.setDynAttrPhonenumber(dynamicAttrPhonenumber);
- status.setDynAttrPassword(dynamicAttrPassword);
- status.setDynAttrBtnId(dynamicAttrButtonId);
- status.setDynAttrTan(dynamicAttrTan);
+ status.sessionID = sessionID;
+ status.viewState = viewState;
+ status.eventValidation = eventValidation;
+ if (viewstateGenerator != null ) { status.viewStateGenerator = viewstateGenerator; }
+ status.dynAttrPhoneNumber = dynamicAttrPhonenumber;
+ status.dynAttrPassword = dynamicAttrPassword;
+ status.dynAttrBtnId = dynamicAttrButtonId;
+ status.dynAttrTan = dynamicAttrTan;
}
/* (non-Javadoc)
@@ -137,14 +137,14 @@ public class ATrustHandler extends MobileBKUHandler { MobileBKUHelper.registerTrustedSocketFactory();
HttpClient client = MobileBKUHelper.getHttpClient(getStatus());
- PostMethod post = new PostMethod(status.getBaseURL() + "/identification.aspx?sid=" + status.getSessionID()); //$NON-NLS-1$
+ PostMethod post = new PostMethod(status.baseURL + "/identification.aspx?sid=" + status.sessionID); //$NON-NLS-1$
post.getParams().setContentCharset("utf-8"); //$NON-NLS-1$
- post.addParameter("__VIEWSTATE", status.getViewstate()); //$NON-NLS-1$
- post.addParameter("__VIEWSTATEGENERATOR", status.getViewstateGenerator() ); //$NON-NLS-1$
- post.addParameter("__EVENTVALIDATION", status.getEventvalidation()); //$NON-NLS-1$
- post.addParameter(status.getDynAttrPhonenumber(), status.getPhoneNumber());
- post.addParameter(status.getDynAttrPassword(), status.getMobilePassword());
- post.addParameter(status.getDynAttrBtnId(), "Identifizieren"); //$NON-NLS-1$
+ post.addParameter("__VIEWSTATE", status.viewState); //$NON-NLS-1$
+ post.addParameter("__VIEWSTATEGENERATOR", status.viewStateGenerator); //$NON-NLS-1$
+ post.addParameter("__EVENTVALIDATION", status.eventValidation); //$NON-NLS-1$
+ post.addParameter(status.dynAttrPhoneNumber, status.phoneNumber);
+ post.addParameter(status.dynAttrPassword, status.mobilePassword);
+ post.addParameter(status.dynAttrBtnId, "Identifizieren"); //$NON-NLS-1$
return executePost(client, post);
}
@@ -155,17 +155,17 @@ public class ATrustHandler extends MobileBKUHandler { @Override
public void handleCredentialsResponse(String responseData) throws Exception {
ATrustStatus status = getStatus();
- String viewState = status.getViewstate();
- String eventValidation = status.getEventvalidation();
- String sessionID = status.getSessionID();
+ String viewState = status.viewState;
+ String eventValidation = status.eventValidation;
+ String sessionID = status.sessionID;
String refVal = null;
String signatureDataURL = null;
String qrCode = null;
String tanField = null;
String tanTextTan = null;
- String viewstateGenerator = status.getViewstateGenerator();
+ String viewstateGenerator = status.viewStateGenerator;
- status.setErrorMessage(null);
+ status.errorMessage = null;
if (responseData.contains("ExpiresInfo.aspx?sid=")) { //$NON-NLS-1$
// Certificate expiration interstitial - skip
@@ -205,7 +205,7 @@ public class ATrustHandler extends MobileBKUHandler { MobileBKUHelper.registerTrustedSocketFactory();
HttpClient client = MobileBKUHelper.getHttpClient(getStatus());
- PostMethod post = new PostMethod(status.getBaseURL() + "/ExpiresInfo.aspx?sid=" + t_sessionID); //$NON-NLS-1$
+ PostMethod post = new PostMethod(status.baseURL + "/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$
@@ -225,7 +225,7 @@ public class ATrustHandler extends MobileBKUHandler { MobileBKUHelper.registerTrustedSocketFactory();
HttpClient client = MobileBKUHelper.getHttpClient(getStatus());
- PostMethod post = new PostMethod(status.getBaseURL() + "/tanAppInfo.aspx?sid=" + t_sessionID); //$NON-NLS-1$
+ PostMethod post = new PostMethod(status.baseURL + "/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$
@@ -242,28 +242,28 @@ public class ATrustHandler extends MobileBKUHandler { 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$
+ signatureDataURL = status.baseURL + "/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.setQRCodeURL(qrCode);
+ status.qrCodeURL = 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);
- status.setDynAttrTan(MobileBKUHelper.getDynamicNameAttribute(responseData, Constants.LABEL_TAN));
- status.setDynAttrSignButton(MobileBKUHelper.getDynamicNameAttribute(responseData, Constants.LABEL_SIGN_BTN));
+ status.dynAttrTan = MobileBKUHelper.getDynamicNameAttribute(responseData, Constants.LABEL_TAN);
+ status.dynAttrSignButton = MobileBKUHelper.getDynamicNameAttribute(responseData, Constants.LABEL_SIGN_BTN);
} 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);
- status.setDynAttrTan(MobileBKUHelper.getDynamicNameAttribute(responseData, Constants.LABEL_TAN));
- status.setDynAttrSignButton(MobileBKUHelper.getDynamicNameAttribute(responseData, Constants.LABEL_SIGN_BTN));
+ status.dynAttrTan = MobileBKUHelper.getDynamicNameAttribute(responseData, Constants.LABEL_TAN);
+ status.dynAttrSignButton = MobileBKUHelper.getDynamicNameAttribute(responseData, Constants.LABEL_SIGN_BTN);
}catch (Exception e) {
log.debug("No text_tan tag"); //$NON-NLS-1$
}
@@ -271,27 +271,27 @@ public class ATrustHandler extends MobileBKUHandler { } 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));
+ getSigningState().setSignatureResponse(new SLResponse(responseData, getStatus().server, null, null));
return;
} else if (responseData.contains("undecided.aspx?sid=")) { //$NON-NLS-1$
// skip intermediate page
log.debug("Page Undecided"); //$NON-NLS-1$
- getSigningState().setSignatureResponse(new SLResponse(responseData, getStatus().getServer(), null, null));
- status.setErrorMessage("waiting..."); //$NON-NLS-1$
+ getSigningState().setSignatureResponse(new SLResponse(responseData, getStatus().server, null, null));
+ status.errorMessage = "waiting..."; //$NON-NLS-1$
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);
+ status.errorMessage = 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);
+ status.mobilePassword = null;
}
log.debug("sessionID: " + sessionID);
@@ -300,12 +300,12 @@ public class ATrustHandler extends MobileBKUHandler { log.debug("eventValidation: " + eventValidation);
log.debug("signatureDataURL: " + signatureDataURL);
- status.setSessionID(sessionID);
- status.setRefVal(refVal);
- status.setViewstate(viewState);
- status.setEventvalidation(eventValidation);
- status.setSignatureDataURL(signatureDataURL);
- status.setViewStateGenerator(viewstateGenerator);
+ status.sessionID = sessionID;
+ status.refVal = refVal;
+ status.viewState = viewState;
+ status.eventValidation = eventValidation;
+ status.signatureDataURL = signatureDataURL;
+ status.viewStateGenerator = viewstateGenerator;
}
/* (non-Javadoc)
@@ -318,14 +318,14 @@ public class ATrustHandler extends MobileBKUHandler { MobileBKUHelper.registerTrustedSocketFactory();
HttpClient client = MobileBKUHelper.getHttpClient(getStatus());
- PostMethod post = new PostMethod(status.getBaseURL()
- + "/signature.aspx?sid=" + status.getSessionID()); //$NON-NLS-1$
+ PostMethod post = new PostMethod(status.baseURL
+ + "/signature.aspx?sid=" + status.sessionID); //$NON-NLS-1$
post.getParams().setContentCharset("utf-8"); //$NON-NLS-1$
- post.addParameter("__VIEWSTATE", status.getViewstate()); //$NON-NLS-1$
+ post.addParameter("__VIEWSTATE", status.viewState); //$NON-NLS-1$
post.addParameter(
- "__EVENTVALIDATION", status.getEventvalidation()); //$NON-NLS-1$
- post.addParameter(status.getDynAttrTan(), status.getTan());
- post.addParameter(status.getDynAttrSignButton(), "Signieren"); //$NON-NLS-1$
+ "__EVENTVALIDATION", status.eventValidation); //$NON-NLS-1$
+ post.addParameter(status.dynAttrTan, status.tan);
+ post.addParameter(status.dynAttrSignButton, "Signieren"); //$NON-NLS-1$
post.addParameter("Button1", "Identifizieren"); //$NON-NLS-1$ //$NON-NLS-2$
return executePost(client, post);
@@ -336,38 +336,40 @@ public class ATrustHandler extends MobileBKUHandler { */
@Override
public void handleTANResponse(String responseData) {
- getStatus().setErrorMessage(null);
+ getStatus().errorMessage = 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));
+ new SLResponse(responseData, getStatus().server, 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$
+ getStatus().tanTries = Integer.parseInt(tries.trim());
+ getStatus().errorMessage = "mobileBKU.wrong_tan";
} catch (Exception e) {
- getStatus().setTanTries(getStatus().getTanTries() - 1);
+ getStatus().tanTries = (getStatus().tanTries - 1);
log.debug("Error parsing TAN response", e); //$NON-NLS-1$
}
- if (getStatus().getTanTries() <= 0) {
- getStatus().setErrorMessage(null);
+ if (getStatus().tanTries <= 0) {
+ getStatus().errorMessage = 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);
+
+ // TODO: THIS IS A COLOSSAL HACK
if (dialog.open() == SWT.CANCEL) {
// Go back to BKU Selection
- getStatus().setTanTries(-1);
+ getStatus().tanTries = -1;
} else {
// Start signature process over
- getStatus().setTanTries(-2);
+ getStatus().tanTries = -2;
}
}
});
@@ -386,8 +388,8 @@ public class ATrustHandler extends MobileBKUHandler { MobileBKUHelper.registerTrustedSocketFactory();
HttpClient client = MobileBKUHelper.getHttpClient(getStatus());
- GetMethod get = new GetMethod(status.getBaseURL()
- + "/sendsms.aspx?sid=" + status.getSessionID()); //$NON-NLS-1$
+ GetMethod get = new GetMethod(status.baseURL
+ + "/sendsms.aspx?sid=" + status.sessionID);
get.getParams().setContentCharset("utf-8"); //$NON-NLS-1$
return executeGet(client, get);
@@ -405,8 +407,7 @@ public class ATrustHandler extends MobileBKUHandler { MobileBKUHelper.registerTrustedSocketFactory();
HttpClient client = MobileBKUHelper.getHttpClient(getStatus());
- GetMethod get = new GetMethod(status.getBaseURL() + "/" + //$NON-NLS-1$
- status.getQRCodeURL());
+ GetMethod get = new GetMethod(status.baseURL + "/" + status.qrCodeURL);
try {
log.debug("Getting " + get.getURI()); //$NON-NLS-1$
@@ -437,8 +438,8 @@ public class ATrustHandler extends MobileBKUHandler { //TODO check
//String baseURL = "https://www.a-trust.at/mobile/https-security-layer-request";
- GetMethod get = new GetMethod(status.getBaseURL()
- + "/signature.aspx?sid=" + status.getSessionID()); //$NON-NLS-1$
+ GetMethod get = new GetMethod(status.baseURL
+ + "/signature.aspx?sid=" + status.sessionID); //$NON-NLS-1$
return executeGet(client, get);
}
@@ -449,7 +450,7 @@ public class ATrustHandler extends MobileBKUHandler { */
public Boolean handleWaitforAppResponse(String responseData) {
- getStatus().setErrorMessage(null);
+ getStatus().errorMessage = null;
if (!responseData.toLowerCase().contains("Bitte starten Sie Ihre Handy-Signatur App!".toLowerCase())/* || //$NON-NLS-1$
responseData.toLowerCase().contains("TAN (Handy-Signatur App)".toLowerCase())*/) { //$NON-NLS-1$
@@ -464,13 +465,13 @@ public class ATrustHandler extends MobileBKUHandler { * @return whether a SL response was received
*/
public boolean handleQRResponse(String responseData) {
- getStatus().setErrorMessage(null);
+ getStatus().errorMessage = 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));
+ new SLResponse(responseData, getStatus().server, null, null));
return true;
}
return false;
@@ -506,11 +507,9 @@ public class ATrustHandler extends MobileBKUHandler { try {
do {
client = MobileBKUHelper.getHttpClient(getStatus());
- String uri = status.getBaseURL() + "/UndecidedPolling.aspx?sid=" + status.getSessionID();
+ String uri = status.baseURL + "/UndecidedPolling.aspx?sid=" + status.sessionID;
GetMethod get = new GetMethod(uri);
- status.getBaseURL();
-
//client.setTimeout(35000);
//client.setConnectionTimeout(35000);
get.addRequestHeader("Accept", "application/json, text/javascript");
@@ -537,7 +536,7 @@ public class ATrustHandler extends MobileBKUHandler { return true;
}
//else error
- status.setErrorMessage("Server reponded ERROR during polling"); //$NON-NLS-1$
+ status.errorMessage = "Server reponded ERROR during polling";
log.error("Server reponded ERROR during polling"); //$NON-NLS-1$
throw new ATrustConnectionException();
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 9994d522..138549d4 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 @@ -25,7 +25,7 @@ import at.asit.pdfover.gui.workflow.config.ConfigProvider; /**
* A-Trust MobileBKUStatus implementation
*/
-public class ATrustStatus extends AbstractMobileBKUStatusImpl {
+public class ATrustStatus extends MobileBKUStatus {
/**
* SLF4J Logger instance
**/
@@ -36,40 +36,26 @@ public class ATrustStatus extends AbstractMobileBKUStatusImpl { /** Maximum number of TAN tries */
public static final int MOBILE_MAX_TAN_TRIES = 3;
- private String viewstate;
- private String eventvalidation;
- private String qrcode = null;
+ public String viewState;
+ public String eventValidation;
+ public String qrCodeURL = null;
private boolean tanField = false;
private boolean isAPPTan = false;
- private String viewstateGenerator;
- private String dynAttrPhonenumber;
- private String dynAttrPassword;
- private String dynAttrBtnId;
- private String dynAttrTan;
- private String dynAttrSignButton;
- private boolean smsTan = false;
+ public String viewStateGenerator;
+ public String dynAttrPhoneNumber;
+ public String dynAttrPassword;
+ public String dynAttrBtnId;
+ public String dynAttrTan;
+ public String dynAttrSignButton;
+ public boolean isSMSTan = false;
/**
* Constructor
* @param provider the ConfigProvider
*/
public ATrustStatus(ConfigProvider provider) {
- setPhoneNumber(provider.getDefaultMobileNumber());
- setMobilePassword(provider.getDefaultMobilePassword());
- }
-
- /**
- * @return the dynAttrTan
- */
- public String getDynAttrTan() {
- return this.dynAttrTan;
- }
-
- /**
- * @param dynAttrTan the dynAttrTan to set
- */
- public void setDynAttrTan(String dynAttrTan) {
- this.dynAttrTan = dynAttrTan;
+ this.phoneNumber = provider.getDefaultMobileNumber();
+ this.mobilePassword = provider.getDefaultMobilePassword();
}
/* (non-Javadoc)
@@ -79,50 +65,6 @@ public class ATrustStatus extends AbstractMobileBKUStatusImpl { 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 getQRCodeURL() {
- return this.qrcode;
- }
-
- /**
- * @param qrcode
- * the QR code to set
- */
- public void setQRCodeURL(String qrcode) {
- this.qrcode = qrcode;
- }
/**
* @param tanField
@@ -151,108 +93,9 @@ public class ATrustStatus extends AbstractMobileBKUStatusImpl { public boolean getIsAPPTan() {
return this.isAPPTan;
}
-
- /**
- * @param viewstateGenerator
- */
- public void setViewStateGenerator(String viewstateGenerator) {
- this.viewstateGenerator = viewstateGenerator;
- }
-
- /**
- * @return
- */
- public String getViewstateGenerator() {
- return this.viewstateGenerator;
- }
-
- /* (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;
- }
-
-
-
- /**
- * @return the dynAttrPhonenumber
- */
- public String getDynAttrPhonenumber() {
- return this.dynAttrPhonenumber;
- }
-
- /**
- * @param dynAttrPhonenumber the dynAttrPhonenumber to set
- */
- public void setDynAttrPhonenumber(String dynAttrPhonenumber) {
- this.dynAttrPhonenumber = dynAttrPhonenumber;
+ public String ensureSessionID(String url) {
+ return url;
}
-
- /**
- * @return the dynAttrPassword
- */
- public String getDynAttrPassword() {
- return this.dynAttrPassword;
- }
-
- /**
- * @param dynAttrPassword the dynAttrPassword to set
- */
- public void setDynAttrPassword(String dynAttrPassword) {
- this.dynAttrPassword = dynAttrPassword;
- }
-
- /**
- * @return the dynAttrBtnId
- */
- public String getDynAttrBtnId() {
- return this.dynAttrBtnId;
- }
-
- /**
- * @param dynAttrBtnId the dynAttrBtnId to set
- */
- public void setDynAttrBtnId(String dynAttrBtnId) {
- this.dynAttrBtnId = dynAttrBtnId;
- }
-
- /**
- * @return the dynAttrSignButton
- */
- public String getDynAttrSignButton() {
- return this.dynAttrSignButton;
- }
-
- /**
- * @param dynAttrSignButton the dynAttrSignButton to set
- */
- public void setDynAttrSignButton(String dynAttrSignButton) {
- this.dynAttrSignButton = dynAttrSignButton;
- }
-
- /**
- * @return the smsTan
- */
- public boolean isSmsTan() {
- return this.smsTan;
- }
-
- /**
- * @param smsTan the smsTan to set
- */
- public void setSmsTan(boolean smsTan) {
- this.smsTan = smsTan;
- }
-
}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/AbstractMobileBKUStatusImpl.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/AbstractMobileBKUStatusImpl.java deleted file mode 100644 index e27fda6a..00000000 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/AbstractMobileBKUStatusImpl.java +++ /dev/null @@ -1,138 +0,0 @@ -/* - * Copyright 2012 by A-SIT, Secure Information Technology Center Austria - * - * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by - * the European Commission - subsequent versions of the EUPL (the "Licence"); - * You may not use this work except in compliance with the Licence. - * You may obtain a copy of the Licence at: - * http://joinup.ec.europa.eu/software/page/eupl - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the Licence is distributed on an "AS IS" basis, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the Licence for the specific language governing permissions and - * limitations under the Licence. - */ -package at.asit.pdfover.gui.bku.mobile; - -/** - * Basic implementation of a MobileBKUStatus - */ -public abstract class AbstractMobileBKUStatusImpl implements MobileBKUStatus { - - private String sessionID; - private String phoneNumber; - private String mobilePassword; - private String baseURL; - private String refVal; - private String errorMessage; - private String tan; - private String server; - private String signatureDataURL; - private int tanTries = getMaxTanTries(); - - @Override - public int getTanTries() { - return this.tanTries; - } - - @Override - public void setTanTries(int tries) { - this.tanTries = tries; - } - - @Override - public String getTan() { - return this.tan; - } - - @Override - public void setTan(String tan) { - this.tan = tan; - } - - @Override - public String getErrorMessage() { - return this.errorMessage; - } - - @Override - public void setErrorMessage(String errorMessage) { - this.errorMessage = errorMessage; - } - - @Override - public String getRefVal() { - return this.refVal; - } - - @Override - public void setRefVal(String refVal) { - this.refVal = refVal; - } - - @Override - public String getBaseURL() { - return this.baseURL; - } - - @Override - public void setBaseURL(String baseURL) { - this.baseURL = baseURL; - } - - @Override - public String getPhoneNumber() { - return this.phoneNumber; - } - - @Override - public void setPhoneNumber(String phoneNumber) { - this.phoneNumber = phoneNumber; - } - - @Override - public String getMobilePassword() { - return this.mobilePassword; - } - - @Override - public void setMobilePassword(String mobilePassword) { - this.mobilePassword = mobilePassword; - } - - @Override - public String getSessionID() { - return this.sessionID; - } - - @Override - public void setSessionID(String sessionID) { - this.sessionID = sessionID; - } - - @Override - public String getServer() { - return this.server; - } - - @Override - public void setServer(String server) { - this.server = server; - } - - @Override - public String getSignatureDataURL() { - return this.signatureDataURL; - } - - @Override - public void setSignatureDataURL(String signatureDataURL) { - this.signatureDataURL = signatureDataURL; - } - - @Override - public String ensureSessionID(String url) { - return url; - } -}
\ No newline at end of file diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/IAIKHandler.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/IAIKHandler.java index ec1c7c66..cbf0ee03 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/IAIKHandler.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/IAIKHandler.java @@ -69,7 +69,7 @@ public class IAIKHandler extends MobileBKUHandler { // Extract infos:
String credentialURL = MobileBKUHelper.extractValueFromTagWithParam(responseData,
"form", "name", "userCredLogon", "action"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- URL baseURL = new URL(status.getBaseURL());
+ URL baseURL = new URL(status.baseURL);
credentialURL = MobileBKUHelper.getQualifiedURL(credentialURL, baseURL);
String viewState = MobileBKUHelper.extractValueFromTagWithParam(
@@ -80,16 +80,16 @@ public class IAIKHandler extends MobileBKUHandler { if (si != -1)
sessionID = credentialURL.substring(si + 11);
else
- sessionID = status.getSessionID();
+ sessionID = status.sessionID;
log.info("credentialURL: " + credentialURL); //$NON-NLS-1$
log.info("sessionID: " + sessionID); //$NON-NLS-1$
log.info("viewState: " + viewState); //$NON-NLS-1$
- status.setBaseURL(credentialURL);
+ status.baseURL = credentialURL;
if (sessionID != null)
- status.setSessionID(sessionID);
- status.setViewState(viewState);
+ status.sessionID = sessionID;
+ status.viewState = viewState;
}
/* (non-Javadoc)
@@ -102,11 +102,11 @@ public class IAIKHandler extends MobileBKUHandler { MobileBKUHelper.registerTrustedSocketFactory();
HttpClient client = MobileBKUHelper.getHttpClient(status);
- PostMethod post = new PostMethod(status.ensureSessionID(status.getBaseURL()));
+ PostMethod post = new PostMethod(status.ensureSessionID(status.baseURL));
post.getParams().setContentCharset("utf-8"); //$NON-NLS-1$
- post.addParameter("javax.faces.ViewState", status.getViewState()); //$NON-NLS-1$
- post.addParameter("userCredLogon:phoneNr", status.getPhoneNumber()); //$NON-NLS-1$
- post.addParameter("userCredLogon:pwd", status.getMobilePassword()); //$NON-NLS-1$
+ post.addParameter("javax.faces.ViewState", status.viewState);
+ post.addParameter("userCredLogon:phoneNr", status.phoneNumber);
+ post.addParameter("userCredLogon:pwd", status.mobilePassword);
post.addParameter("userCredLogon:logonButton", "userCredLogon:logonButton"); //$NON-NLS-1$ //$NON-NLS-2$
post.addParameter("javax.faces.partial.ajax", "true"); //$NON-NLS-1$ //$NON-NLS-2$
post.addParameter("javax.faces.source", "userCredLogon:logonButton"); //$NON-NLS-1$ //$NON-NLS-2$
@@ -128,7 +128,7 @@ public class IAIKHandler extends MobileBKUHandler { String refVal = null;
String signatureDataURL = null;
- status.setErrorMessage(null);
+ status.errorMessage = null;
if (!responseData.contains("redirection_url")) { //$NON-NLS-1$
// Assume that an error occurred
@@ -139,10 +139,10 @@ public class IAIKHandler extends MobileBKUHandler { } catch (Exception e) {
errorMessage = Messages.getString("error.Unexpected"); //$NON-NLS-1$
}
- status.setErrorMessage(errorMessage);
+ status.errorMessage = errorMessage;
// force UI again!
- status.setMobilePassword(null);
+ status.mobilePassword = null;
return;
}
@@ -151,7 +151,7 @@ public class IAIKHandler extends MobileBKUHandler { String redirectURL = MobileBKUHelper.extractSubstring(responseData,
"\"redirection_url\":\"", "\""); //$NON-NLS-1$ //$NON-NLS-2$
- URL baseURL = new URL(status.getBaseURL());
+ URL baseURL = new URL(status.baseURL);
redirectURL = MobileBKUHelper.getQualifiedURL(redirectURL, baseURL);
redirectURL = status.ensureSessionID(redirectURL);
@@ -160,7 +160,7 @@ public class IAIKHandler extends MobileBKUHandler { if (responseData.contains("sl:InfoboxReadResponse")) { //$NON-NLS-1$
// credentials ok! InfoboxReadResponse
getSigningState().setSignatureResponse(
- new SLResponse(responseData, status.getServer(), null, null));
+ new SLResponse(responseData, status.server, null, null));
return;
}
@@ -184,9 +184,9 @@ public class IAIKHandler extends MobileBKUHandler { if (errorMessage.contains("<br />")) //$NON-NLS-1$
errorMessage = errorMessage.substring(0, errorMessage.indexOf("<br />")); //$NON-NLS-1$
errorMessage.replace("\n", " "); //$NON-NLS-1$ //$NON-NLS-2$
- status.setErrorMessage(errorMessage);
+ status.errorMessage = errorMessage;
- status.setMobilePassword(null);
+ status.mobilePassword = null;
return;
}
@@ -195,7 +195,7 @@ public class IAIKHandler extends MobileBKUHandler { String viewState = MobileBKUHelper.extractValueFromTagWithParam(
responseData, "input", "name", "javax.faces.ViewState", "value"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- status.setViewState(viewState);
+ status.viewState = viewState;
if (!responseData.contains("tanCodeLogon.jsf")) { //$NON-NLS-1$
// Assume that we need to confirm reference value dialog
@@ -210,22 +210,22 @@ public class IAIKHandler extends MobileBKUHandler { post.addParameter("javax.faces.partial.execute", "@all"); //$NON-NLS-1$ //$NON-NLS-2$
post.addParameter("j_idt5:yesButton", "j_idt5:yesButton"); //$NON-NLS-1$ //$NON-NLS-2$
post.addParameter("j_idt5", "j_idt5"); //$NON-NLS-1$ //$NON-NLS-2$
- post.addParameter("javax.faces.ViewState", status.getViewState()); //$NON-NLS-1$
+ post.addParameter("javax.faces.ViewState", status.viewState); //$NON-NLS-1$
responseData = executePost(client, post);
log.debug("Response: " + responseData); //$NON-NLS-1$
if (responseData.contains("/error")) { //$NON-NLS-1$
// Error response - try again
String errorMessage = Messages.getString("error.Unexpected"); //$NON-NLS-1$
- status.setErrorMessage(errorMessage);
+ status.errorMessage = errorMessage;
- status.setMobilePassword(null);
+ status.mobilePassword = null;
return;
}
redirectURL = MobileBKUHelper.extractSubstring(responseData,
"redirect url=\"", "\""); //$NON-NLS-1$ //$NON-NLS-2$
- baseURL = new URL(status.getBaseURL());
+ baseURL = new URL(status.baseURL);
redirectURL = MobileBKUHelper.getQualifiedURL(redirectURL, baseURL);
redirectURL = status.ensureSessionID(redirectURL);
@@ -233,19 +233,19 @@ public class IAIKHandler extends MobileBKUHandler { viewState = MobileBKUHelper.extractValueFromTagWithParam(
responseData, "input", "name", "javax.faces.ViewState", "value"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- status.setViewState(viewState);
+ status.viewState = viewState;
}
- signatureDataURL = status.getBaseURL();
+ signatureDataURL = status.baseURL;
signatureDataURL = signatureDataURL.substring(0, signatureDataURL.lastIndexOf('/') + 1);
signatureDataURL += "viewer.jsf" + //$NON-NLS-1$
MobileBKUHelper.extractSubstring(responseData, "viewer.jsf", "\""); //$NON-NLS-1$ //$NON-NLS-2$
signatureDataURL += (signatureDataURL.contains("?") ? "&" : "?") + //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- "pdfoversessionid=" + status.getSessionID(); //$NON-NLS-1$
+ "pdfoversessionid=" + status.sessionID; //$NON-NLS-1$
String tanURL = MobileBKUHelper.extractValueFromTagWithParam(responseData,
"form", "name", "tanCodeLogon", "action"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- baseURL = new URL(status.getBaseURL());
+ baseURL = new URL(status.baseURL);
tanURL = MobileBKUHelper.getQualifiedURL(tanURL, baseURL);
tanURL = status.ensureSessionID(tanURL);
@@ -254,9 +254,9 @@ public class IAIKHandler extends MobileBKUHandler { log.debug("tanURL: " + tanURL); //$NON-NLS-1$
log.debug("viewState: " + viewState); //$NON-NLS-1$
- status.setRefVal(refVal);
- status.setSignatureDataURL(signatureDataURL);
- status.setBaseURL(tanURL);
+ status.refVal = refVal;
+ status.signatureDataURL = signatureDataURL;
+ status.baseURL = tanURL;
}
/* (non-Javadoc)
@@ -269,13 +269,13 @@ public class IAIKHandler extends MobileBKUHandler { MobileBKUHelper.registerTrustedSocketFactory();
HttpClient client = MobileBKUHelper.getHttpClient(status);
- PostMethod post = new PostMethod(status.getBaseURL());
+ PostMethod post = new PostMethod(status.baseURL);
post.getParams().setContentCharset("utf-8"); //$NON-NLS-1$
- post.addParameter("javax.faces.ViewState", status.getViewState()); //$NON-NLS-1$
+ post.addParameter("javax.faces.ViewState", status.viewState); //$NON-NLS-1$
post.addParameter("tanCodeLogon", "tanCodeLogon"); //$NON-NLS-1$ //$NON-NLS-2$
post.addParameter("tanCodeLogon:signButton", ""); //$NON-NLS-1$ //$NON-NLS-2$
- post.addParameter("tanCodeLogon:authCode", status.getTan()); //$NON-NLS-1$
- post.addParameter("referenceValue", status.getRefVal()); //$NON-NLS-1$
+ post.addParameter("tanCodeLogon:authCode", status.tan); //$NON-NLS-1$
+ post.addParameter("referenceValue", status.refVal); //$NON-NLS-1$
return executePost(client, post);
}
@@ -286,23 +286,23 @@ public class IAIKHandler extends MobileBKUHandler { @Override
public void handleTANResponse(String responseData) throws Exception {
final IAIKStatus status = getStatus();
- status.setErrorMessage(null);
+ status.errorMessage = null;
if (responseData.contains("sl:CreateCMSSignatureResponse xmlns:sl")) { //$NON-NLS-1$
// success
getSigningState().setSignatureResponse(
- new SLResponse(responseData, status.getServer(), null, null));
+ new SLResponse(responseData, status.server, null, null));
} else {
try {
String errorMessage = MobileBKUHelper.extractContentFromTagWithParam(
responseData, "p", "class", "ui-messages-error ui-messages-error-signing"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- status.setErrorMessage(errorMessage);
+ status.errorMessage = errorMessage;
log.error(errorMessage);
//Go back to TAN entry
MobileBKUHelper.registerTrustedSocketFactory();
HttpClient client = MobileBKUHelper.getHttpClient(status);
- PostMethod post = new PostMethod(status.getBaseURL());
+ PostMethod post = new PostMethod(status.baseURL);
post.getParams().setContentCharset("utf-8"); //$NON-NLS-1$
post.addParameter("javax.faces.partial.ajax", "true"); //$NON-NLS-1$ //$NON-NLS-2$
post.addParameter("javax.faces.source", "tanCodeLogon:backbutton"); //$NON-NLS-1$ //$NON-NLS-2$
@@ -310,7 +310,7 @@ public class IAIKHandler extends MobileBKUHandler { post.addParameter("javax.faces.partial.render", "tanCodeLogon:tanCodeLogonPanel"); //$NON-NLS-1$ //$NON-NLS-2$
post.addParameter("tanCodeLogon:backbutton", "tanCodeLogon:backbutton"); //$NON-NLS-1$ //$NON-NLS-2$
post.addParameter("tanCodeLogon", "tanCodeLogon"); //$NON-NLS-1$ //$NON-NLS-2$
- post.addParameter("javax.faces.ViewState", status.getViewState()); //$NON-NLS-1$
+ post.addParameter("javax.faces.ViewState", status.viewState); //$NON-NLS-1$
executePost(client, post);
} catch (Exception e) {
@@ -321,12 +321,13 @@ public class IAIKHandler extends MobileBKUHandler { Dialog dialog = new Dialog(IAIKHandler.this.shell, Messages.getString("common.warning"), //$NON-NLS-1$
Messages.getString("mobileBKU.tan_tries_exceeded"), //$NON-NLS-1$
BUTTONS.OK_CANCEL, ICON.QUESTION);
+ // TODO: ALSO A COLOSSAL HACK HERE
if (dialog.open() == SWT.CANCEL) {
// Go back to BKU Selection
- status.setTanTries(-1);
+ status.tanTries = -1;
} else {
// Start signature process over
- status.setTanTries(-2);
+ status.tanTries = -2;
}
}
});
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/IAIKStatus.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/IAIKStatus.java index 92e88c77..808df7d4 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/IAIKStatus.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/IAIKStatus.java @@ -25,7 +25,7 @@ import at.asit.pdfover.gui.workflow.config.ConfigProvider; /** * IAIK MobileBKUStatus implementation */ -public class IAIKStatus extends AbstractMobileBKUStatusImpl { +public class IAIKStatus extends MobileBKUStatus { /** * SLF4J Logger instance **/ @@ -34,15 +34,15 @@ public class IAIKStatus extends AbstractMobileBKUStatusImpl { /** Maximum number of TAN tries */ public static final int MOBILE_MAX_TAN_TRIES = 3; - private String viewState; + public String viewState; /** * Constructor * @param provider the ConfigProvider */ public IAIKStatus(ConfigProvider provider) { - setPhoneNumber(provider.getDefaultMobileNumber()); - setMobilePassword(provider.getDefaultMobilePassword()); + this.phoneNumber = provider.getDefaultMobileNumber(); + this.mobilePassword = provider.getDefaultMobilePassword(); } /* (non-Javadoc) @@ -53,53 +53,14 @@ public class IAIKStatus extends AbstractMobileBKUStatusImpl { 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; - } - - - /* (non-Javadoc) - * @see at.asit.pdfover.gui.bku.mobile.MobileBKUStatus#parseCookies(org.apache.commons.httpclient.Cookie[]) - */ - @Override - public void parseCookies(Cookie[] cookies) { - for (Cookie cookie : cookies) { - if (cookie.getName().equals("JSESSIONID")) { //$NON-NLS-1$ - log.debug("Got session ID: " + cookie.toExternalForm()); //$NON-NLS-1$ - setSessionID(cookie.getValue()); - } - } - } - - /* (non-Javadoc) - * @see at.asit.pdfover.gui.bku.mobile.MobileBKUStatus#getCookies() - */ - @Override - public Cookie[] getCookies() { - // Currently not used - return null; - } - @Override public String ensureSessionID(String url) { if (url.contains("jsessionid=")) //$NON-NLS-1$ return url; - String sid = getSessionID(); - if (sid != null) - url += ";jsessionid=" + sid; //$NON-NLS-1$ + if (this.sessionID != null) + url += ";jsessionid=" + this.sessionID; //$NON-NLS-1$ return url; } } diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/MobileBKUHandler.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/MobileBKUHandler.java index 1ada0337..200ca54e 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/MobileBKUHandler.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/MobileBKUHandler.java @@ -99,8 +99,7 @@ public abstract class MobileBKUHandler { }
log.trace("SL Request: " + sl_request); //$NON-NLS-1$
- state.status.setBaseURL(
- MobileBKUHelper.stripQueryString(mobileBKUUrl));
+ state.status.baseURL = MobileBKUHelper.stripQueryString(mobileBKUUrl);
return executePost(client, post);
}
@@ -252,12 +251,10 @@ public abstract class MobileBKUHandler { }
} while (redirectLocation != null);
- getStatus().setServer(server);
+ getStatus().server = server;
if (server != null)
log.info("Server: " + server); //$NON-NLS-1$
- getStatus().parseCookies(client.getState().getCookies());
-
return responseData;
}
@@ -336,12 +333,10 @@ public abstract class MobileBKUHandler { }
} while (redirectLocation != null);
- getStatus().setServer(server);
+ getStatus().server = server;
if (server != null)
log.info("Server: " + server); //$NON-NLS-1$
- getStatus().parseCookies(client.getState().getCookies());
-
return responseData;
}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/MobileBKUHelper.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/MobileBKUHelper.java index de0b3a2c..9466fecb 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/MobileBKUHelper.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/MobileBKUHelper.java @@ -297,16 +297,7 @@ public class MobileBKUHelper { * @return the HttpClient */ public static HttpClient getHttpClient(MobileBKUStatus status) { - HttpClient client = BKUHelper.getHttpClient(true); - Cookie[] cookies = status.getCookies(); - if (cookies != null) { - HttpState state = new HttpState(); - for (Cookie cookie : cookies) { - state.addCookie(cookie); - } - client.setState(state); - } - return client; + return BKUHelper.getHttpClient(true); } /*** diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/MobileBKUStatus.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/MobileBKUStatus.java index 2a5bb4e7..7db04b68 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/MobileBKUStatus.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/MobileBKUStatus.java @@ -20,135 +20,28 @@ import org.apache.commons.httpclient.Cookie; /** * */ -public interface MobileBKUStatus { - /** - * @return the identification_url - */ - public String getSessionID(); - - /** - * @param sessionID the identification_url to set - */ - public void setSessionID(String sessionID); - - /** - * @return the phoneNumber - */ - public String getPhoneNumber(); - - /** - * @param phoneNumber the phoneNumber to set - */ - public void setPhoneNumber(String phoneNumber); - - /** - * @return the mobilePassword - */ - public String getMobilePassword(); - - /** - * @param mobilePassword the mobilePassword to set - */ - public void setMobilePassword(String mobilePassword); - - /** - * @return the reference value - */ - public String getRefVal(); - - /** - * @param refVal the reference value to set - */ - public void setRefVal(String refVal); - - /** - * @return the tan - */ - public String getTan(); - - /** - * @param tan the tan to set - */ - public void setTan(String tan); +public abstract class MobileBKUStatus { + public String sessionID; + public String phoneNumber; + public String mobilePassword; + public String baseURL; + public String refVal; + public String errorMessage; + public String tan; + public String server; + public String signatureDataURL; + public int tanTries = getMaxTanTries(); /** * Get maximum number of TAN tries * @return the maximum number of TAN tries */ - public int getMaxTanTries(); - - /** - * Get number of TAN tries left - * @return the number of TAN tries left - */ - public int getTanTries(); - - /** - * Set number of TAN tries left - * @param tries the number of TAN tries left - */ - public void setTanTries(int tries); - - /** - * @return the errorMessage - */ - public String getErrorMessage(); - - /** - * @param errorMessage the errorMessage to set - */ - public void setErrorMessage(String errorMessage); - - /** - * @return the baseURL - */ - public String getBaseURL(); - - /** - * @param baseURL - */ - public void setBaseURL(String baseURL); - - /** - * Return the SL request server - * @return the SL request server - */ - public String getServer(); - - /** - * Set the SL request server - * @param server the SL request server - */ - public void setServer(String server); - - /** - * Get the signature data URL - * @return the signature data URL - */ - public String getSignatureDataURL(); - - /** - * Set the signature data URL - * @param signatureDataURL the signature data URL - */ - public void setSignatureDataURL(String signatureDataURL); - - /** - * Parse the cookies set by the SL request server - * @param cookies the cookies - */ - void parseCookies(Cookie[] cookies); - - /** - * Get the cookies to set during a request to the SL server - * @return the cookies to set - */ - public Cookie[] getCookies(); + public abstract int getMaxTanTries(); /** * Ensure that given URL contains a session ID (if necessary) * @param url URL to check for session ID * @return resulting URL */ - public String ensureSessionID(String url); + public abstract String ensureSessionID(String url); } diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/MobileBKUEnterNumberComposite.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/MobileBKUEnterNumberComposite.java index 0e6da9ff..cf722d35 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/MobileBKUEnterNumberComposite.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/MobileBKUEnterNumberComposite.java @@ -75,7 +75,7 @@ public class MobileBKUEnterNumberComposite extends StateComposite { MobileBKUHelper.validatePassword(password);
MobileBKUEnterNumberComposite.this.mobilePassword = password;
- MobileBKUEnterNumberComposite.this.setUserAck(true);
+ MobileBKUEnterNumberComposite.this.userAck = true;
MobileBKUEnterNumberComposite.this.btn_ok.setEnabled(false);
@@ -101,7 +101,7 @@ public class MobileBKUEnterNumberComposite extends StateComposite { private final SelectionListener cancelListener = new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
- MobileBKUEnterNumberComposite.this.setUserCancel(true);
+ MobileBKUEnterNumberComposite.this.userCancel = true;
}
};
@@ -116,38 +116,8 @@ public class MobileBKUEnterNumberComposite extends StateComposite { String errorMessage = null;
- boolean userAck = false;
- boolean userCancel = false;
-
- /**
- * @return the userAck
- */
- public boolean isUserAck() {
- return this.userAck;
- }
-
- /**
- * @param userAck
- * the userAck to set
- */
- public void setUserAck(boolean userAck) {
- this.userAck = userAck;
- }
-
- /**
- * @return the userCancel
- */
- public boolean isUserCancel() {
- return this.userCancel;
- }
-
- /**
- * @param userCancel
- * the userCancel to set
- */
- public void setUserCancel(boolean userCancel) {
- this.userCancel = userCancel;
- }
+ public boolean userAck = false;
+ public boolean userCancel = false;
private Label lbl_error;
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 247a8c3e..a838c635 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 @@ -57,7 +57,7 @@ public class MobileBKUState extends State { SigningState signingState;
- Exception threadException = null;
+ public Exception threadException = null;
public final MobileBKUStatus status;
public final MobileBKUHandler handler;
@@ -68,15 +68,12 @@ public class MobileBKUState extends State { switch(provider.getMobileBKUType()) {
case A_TRUST:
this.status = new ATrustStatus(provider);
- this.handler = new ATrustHandler(this,
- stateMachine.getGUIProvider().getMainShell(),
- provider.getMobileBKUBase64());
+ 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());
+ this.handler = new IAIKHandler(this, stateMachine.getGUIProvider().getMainShell());
break;
default:
@@ -129,7 +126,7 @@ public class MobileBKUState extends State { MobileBKUEnterNumberComposite getMobileBKUEnterNumberComposite() {
if (this.mobileBKUEnterNumberComposite == null) {
this.mobileBKUEnterNumberComposite = getStateMachine().getGUIProvider()
- .createComposite(MobileBKUEnterNumberComposite.class, SWT.RESIZE, this);
+ .createComposite(MobileBKUEnterNumberComposite.class, SWT.RESIZE, this);
}
return this.mobileBKUEnterNumberComposite;
@@ -139,7 +136,7 @@ public class MobileBKUState extends State { MobileBKUFingerprintComposite getMobileBKUFingerprintComposite() {
if (this.mobileBKUFingerprintComposite == null) {
this.mobileBKUFingerprintComposite = getStateMachine().getGUIProvider()
- .createComposite(MobileBKUFingerprintComposite.class, SWT.RESIZE, this);
+ .createComposite(MobileBKUFingerprintComposite.class, SWT.RESIZE, this);
}
return this.mobileBKUFingerprintComposite;
@@ -161,14 +158,6 @@ public class MobileBKUState extends State { }
/**
- * @param threadException
- * the threadException to set
- */
- public void setThreadException(Exception threadException) {
- this.threadException = threadException;
- }
-
- /**
* Display an error message
*
* @param e
@@ -207,8 +196,8 @@ public class MobileBKUState extends State { public void checkCredentials() {
final MobileBKUStatus mobileStatus = this.status;
// check if we have everything we need!
- if (mobileStatus.getPhoneNumber() != null && !mobileStatus.getPhoneNumber().isEmpty() &&
- mobileStatus.getMobilePassword() != null && !mobileStatus.getMobilePassword().isEmpty())
+ if (mobileStatus.phoneNumber != null && !mobileStatus.phoneNumber.isEmpty() &&
+ mobileStatus.mobilePassword != null && !mobileStatus.mobilePassword.isEmpty())
return;
Display.getDefault().syncExec(new Runnable() {
@@ -217,13 +206,13 @@ public class MobileBKUState extends State { MobileBKUEnterNumberComposite ui = MobileBKUState.this
.getMobileBKUEnterNumberComposite();
- if (!ui.isUserAck()) {
+ if (!ui.userAck) {
// We need number and password => show UI!
- if (mobileStatus.getErrorMessage() != null
- && !mobileStatus.getErrorMessage().isEmpty()) {
+ if (mobileStatus.errorMessage != null
+ && !mobileStatus.errorMessage.isEmpty()) {
// set possible error message
- ui.setErrorMessage(mobileStatus.getErrorMessage());
- mobileStatus.setErrorMessage(null);
+ ui.setErrorMessage(mobileStatus.errorMessage);
+ mobileStatus.errorMessage = null;
} else if (mobileStatus instanceof ATrustStatus) {
ui.setErrorMessage(Messages.getString("mobileBKU.aTrustDisclaimer")); //$NON-NLS-1$
}
@@ -231,37 +220,37 @@ public class MobileBKUState extends State { if (ui.getMobileNumber() == null
|| ui.getMobileNumber().isEmpty()) {
// set possible phone number
- ui.setMobileNumber(mobileStatus.getPhoneNumber());
+ ui.setMobileNumber(mobileStatus.phoneNumber);
}
if (ui.getMobilePassword() == null
|| ui.getMobilePassword().isEmpty()) {
// set possible password
- ui.setMobilePassword(mobileStatus.getMobilePassword());
+ ui.setMobilePassword(mobileStatus.mobilePassword);
}
ui.enableButton();
getStateMachine().getGUIProvider().display(ui);
Display display = getStateMachine().getGUIProvider().getMainShell().getDisplay();
- while (!ui.isUserAck() && !ui.isUserCancel()) {
+ while (!ui.userAck && !ui.userCancel) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
}
- if (ui.isUserCancel()) {
- ui.setUserCancel(false);
- mobileStatus.setErrorMessage("cancel"); //$NON-NLS-1$
+ if (ui.userCancel) {
+ ui.userCancel = false;
+ mobileStatus.errorMessage = "cancel"; //$NON-NLS-1$
return;
}
// user hit ok
- ui.setUserAck(false);
+ ui.userAck = false;
// get number and password from UI
- mobileStatus.setPhoneNumber(ui.getMobileNumber());
- mobileStatus.setMobilePassword(ui.getMobilePassword());
+ mobileStatus.phoneNumber = ui.getMobileNumber();
+ mobileStatus.mobilePassword = ui.getMobilePassword();
// show waiting composite
getStateMachine().getGUIProvider().display(
@@ -284,15 +273,15 @@ public class MobileBKUState extends State { 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) {
+ tan.setRefVal(mobileStatus.refVal);
+ tan.setSignatureData(mobileStatus.signatureDataURL);
+ tan.setErrorMessage(mobileStatus.errorMessage);
+ if (mobileStatus.tanTries < mobileStatus.getMaxTanTries()
+ && mobileStatus.tanTries > 0) {
// show warning message x tries left!
// overrides error message
- tan.setTries(mobileStatus.getTanTries());
+ tan.setTries(mobileStatus.tanTries);
}
tan.enableButton();
getStateMachine().getGUIProvider().display(tan);
@@ -307,14 +296,14 @@ public class MobileBKUState extends State { if (tan.isUserCancel()) {
tan.setUserCancel(false);
- mobileStatus.setErrorMessage("cancel"); //$NON-NLS-1$
+ mobileStatus.errorMessage = "cancel";
return;
}
// user hit ok!
tan.setUserAck(false);
- mobileStatus.setTan(tan.getTan());
+ mobileStatus.tan = tan.getTan();
// show waiting composite
getStateMachine().getGUIProvider().display(
@@ -356,9 +345,9 @@ public class MobileBKUState extends State { Display.getDefault().syncExec(() -> {
MobileBKUQRComposite qr = getMobileBKUQRComposite();
- qr.setRefVal(status.getRefVal());
- qr.setSignatureData(status.getSignatureDataURL());
- qr.setErrorMessage(status.getErrorMessage());
+ qr.setRefVal(status.refVal);
+ qr.setSignatureData(status.signatureDataURL);
+ qr.setErrorMessage(status.errorMessage);
InputStream qrcode = handler.getQRCode();
if (qrcode == null) {
MobileBKUState.this.threadException = new Exception(
@@ -378,13 +367,13 @@ public class MobileBKUState extends State { if (qr.isUserCancel()) {
qr.setUserCancel(false);
- status.setErrorMessage("cancel"); //$NON-NLS-1$
+ status.errorMessage = "cancel";
return;
}
if (qr.isUserSMS()) {
qr.setUserSMS(false);
- status.setQRCodeURL(null);
+ status.qrCodeURL = null;
}
if (qr.isDone())
@@ -434,15 +423,15 @@ public class MobileBKUState extends State { if (waitingForAppcomposite.getUserCancel()) {
waitingForAppcomposite.setUserCancel(false);
- status.setErrorMessage("cancel"); //$NON-NLS-1$
+ status.errorMessage = "cancel";
return;
}
if (waitingForAppcomposite.getUserSMS()) {
- status.setQRCodeURL(null);
+ status.qrCodeURL = null;
waitingForAppcomposite.setUserSMS(false);
- status.setErrorMessage("sms"); //$NON-NLS-1$
- status.setSmsTan(true);
+ status.errorMessage = "sms";
+ status.isSMSTan = true;
// show waiting composite
getStateMachine().getGUIProvider().display(MobileBKUState.this.getWaitingComposite());
return;
@@ -454,8 +443,8 @@ public class MobileBKUState extends State { if (!(System.nanoTime() < timeoutTime)) {
log.warn("The undecided polling got a timeout");
- status.setQRCodeURL(null);
- status.setErrorMessage("Polling Timeout");
+ status.qrCodeURL = null;
+ status.errorMessage = "Polling Timeout";
}
@@ -514,9 +503,9 @@ public class MobileBKUState extends State { Display.getDefault().syncExec(() -> {
MobileBKUFingerprintComposite fingerprintComposite = getMobileBKUFingerprintComposite();
- fingerprintComposite.setRefVal(status.getRefVal());
- fingerprintComposite.setSignatureData(status.getSignatureDataURL());
- fingerprintComposite.setErrorMessage(status.getErrorMessage());
+ fingerprintComposite.setRefVal(status.refVal);
+ fingerprintComposite.setSignatureData(status.signatureDataURL);
+ fingerprintComposite.setErrorMessage(status.errorMessage);
getStateMachine().getGUIProvider().display(fingerprintComposite);
Display display = getStateMachine().getGUIProvider().getMainShell().getDisplay();
@@ -529,13 +518,13 @@ public class MobileBKUState extends State { if (fingerprintComposite.isUserCancel()) {
fingerprintComposite.setUserCancel(false);
- status.setErrorMessage("cancel"); //$NON-NLS-1$
+ status.errorMessage = "cancel";
return;
}
if (fingerprintComposite.isUserSMS()) {
// fingerprintComposite.setUserSMS(false);
- status.setQRCodeURL(null);
+ status.qrCodeURL = null;
}
if (fingerprintComposite.isDone())
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/SigningState.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/SigningState.java index bc6793ec..4b329b47 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/SigningState.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/SigningState.java @@ -97,7 +97,7 @@ public class SigningState extends State { // this is a bit of a hack... if (status.getPreviousState() instanceof MobileBKUState) { - String mobileBkuError = ((MobileBKUState)status.getPreviousState()).status.getErrorMessage(); + String mobileBkuError = ((MobileBKUState)status.getPreviousState()).status.errorMessage; if ((mobileBkuError != null) && mobileBkuError.equals("cancel")) this.threadException = new SignatureException(new IllegalStateException()); } |