summaryrefslogtreecommitdiff
path: root/smccSTAL/src/main/java/at/gv
diff options
context:
space:
mode:
authortkellner <tkellner@8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4>2012-10-02 19:37:33 +0000
committertkellner <tkellner@8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4>2012-10-02 19:37:33 +0000
commitd06952f807b754359f994d684c2490eb4a731bbb (patch)
tree5451162237646020dd03f025046a1ba3fd8caa8d /smccSTAL/src/main/java/at/gv
parentc208df1ff87e72f20e318b584d6ab011881ebf4e (diff)
downloadmocca-d06952f807b754359f994d684c2490eb4a731bbb.tar.gz
mocca-d06952f807b754359f994d684c2490eb4a731bbb.tar.bz2
mocca-d06952f807b754359f994d684c2490eb4a731bbb.zip
Set InfoBoxReadRequest error messages
git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@1142 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4
Diffstat (limited to 'smccSTAL/src/main/java/at/gv')
-rw-r--r--smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/InfoBoxReadRequestHandler.java31
1 files changed, 17 insertions, 14 deletions
diff --git a/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/InfoBoxReadRequestHandler.java b/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/InfoBoxReadRequestHandler.java
index eb24100b..5bb3fde4 100644
--- a/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/InfoBoxReadRequestHandler.java
+++ b/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/InfoBoxReadRequestHandler.java
@@ -53,6 +53,14 @@ public class InfoBoxReadRequestHandler extends AbstractRequestHandler {
// protected PINProviderFactory pinProviderFactory;
+ private ErrorResponse errorResponse(int errorCode, String errorMessage, Exception e)
+ {
+ log.error(errorMessage, e);
+ ErrorResponse err = new ErrorResponse(errorCode);
+ err.setErrorMessage(errorMessage + (e == null ? "" : " " + e));
+ return err;
+ }
+
@Override
public STALResponse handleRequest(STALRequest request) throws InterruptedException {
if (request instanceof InfoboxReadRequest) {
@@ -72,8 +80,7 @@ public class InfoBoxReadRequestHandler extends AbstractRequestHandler {
resp = DomainIdConverter.convertDomainId(resp, infoBox
.getDomainIdentifier());
} catch (Exception e) {
- log.error("Cannot convert domain specific id.", e);
- return new ErrorResponse(1000);
+ return errorResponse(1000, "Cannot convert domain specific id.", e);
}
}
InfoboxReadResponse stalResp = new InfoboxReadResponse();
@@ -92,7 +99,7 @@ public class InfoBoxReadRequestHandler extends AbstractRequestHandler {
resp = card.getCertificate(SignatureCard.KeyboxName.SECURE_SIGNATURE_KEYPAIR, new VerifyPINGUI(gui));
}
if (resp == null) {
- return new ErrorResponse(6001);
+ return errorResponse(6001, "Could not get certificate", null);
}
// Check certificate validity
@@ -124,39 +131,35 @@ public class InfoBoxReadRequestHandler extends AbstractRequestHandler {
new VerifyPINGUI(gui),
infoBox.getDomainIdentifier());
if (resp == null) {
- return new ErrorResponse(6001);
+ return errorResponse(6001, "Could not read infobox", null);
}
InfoboxReadResponse stalResp = new InfoboxReadResponse();
stalResp.setInfoboxValue(resp);
return stalResp;
}
} catch (IllegalArgumentException e) {
- log.info("Infobox {} not supported.", infoBox.getInfoboxIdentifier());
- return new ErrorResponse(4002);
+ return errorResponse(4002, "Infobox " + infoBox.getInfoboxIdentifier() + " not supported.", e);
} catch (NotActivatedException e) {
log.info("Citizen card not activated.", e);
gui.showErrorDialog(BKUGUIFacade.ERR_CARD_NOTACTIVATED, null, this, null);
waitForAction();
gui.showMessageDialog(BKUGUIFacade.TITLE_WAIT,
BKUGUIFacade.MESSAGE_WAIT);
- return new ErrorResponse(6001);
+ return errorResponse(6001, "Citizen card not activated.", e);
} catch (LockedException e) {
log.info("Citizen card locked.", e);
gui.showErrorDialog(BKUGUIFacade.ERR_CARD_LOCKED, null, this, null);
waitForAction();
gui.showMessageDialog(BKUGUIFacade.TITLE_WAIT,
BKUGUIFacade.MESSAGE_WAIT);
- return new ErrorResponse(6001);
+ return errorResponse(6001, "Citizen card locked.", e);
} catch (CancelledException cx) {
- log.debug("User cancelled request.", cx);
- return new ErrorResponse(6001);
+ return errorResponse(6001, "User cancelled request.", cx);
} catch (SignatureCardException e) {
- log.info("Error while reading infobox. " + e);
- return new ErrorResponse(4000);
+ return errorResponse(4000, "Error while reading infobox. ", e);
}
} else {
- log.error("Got unexpected STAL request: {}.", request);
- return new ErrorResponse(1000);
+ return errorResponse(1000, "Got unexpected STAL request: " + request, null);
}
}