use of org.openecard.binding.tctoken.ex.FatalActivationError in project open-ecard by ecsec.
the class ActivateAction method processTcToken.
/**
* Process the tcTokenURL or the activation object and perform a authentication.
*
* @param params Parameters of the request.
* @return A {@link BindingResult} representing the result of the authentication.
*/
private BindingResult processTcToken(Map<String, String> params) {
BindingResult response;
DynamicContext dynCtx = DynamicContext.getInstance(TR03112Keys.INSTANCE_KEY);
dynCtx.put(TR03112Keys.COOKIE_MANAGER, new CookieManager());
try {
TCTokenRequest tcTokenRequest = null;
try {
tcTokenRequest = TCTokenRequest.convert(params, ctx);
response = tokenHandler.handleActivate(tcTokenRequest);
// Show success message. If we get here we have a valid StartPAOSResponse and a valid refreshURL
showFinishMessage((TCTokenResponse) response);
} catch (ActivationError ex) {
if (ex instanceof NonGuiException) {
// error already displayed to the user so do not repeat it here
} else {
if (ex.getMessage().equals("Invalid HTTP message received.")) {
showErrorMessage(lang.translationForKey(ACTIVATION_INVALID_REFRESH_ADDRESS));
} else {
showErrorMessage(ex.getLocalizedMessage());
}
}
LOG.error(ex.getMessage());
// stack trace only in debug level
LOG.debug(ex.getMessage(), ex);
LOG.debug("Returning result: \n{}", ex.getBindingResult());
if (ex instanceof FatalActivationError) {
LOG.info("Authentication failed, displaying error in Browser.");
} else {
LOG.info("Authentication failed, redirecting to with errors attached to the URL.");
}
response = ex.getBindingResult();
} finally {
if (tcTokenRequest != null && tcTokenRequest.getTokenContext() != null) {
// close connection to tctoken server in case PAOS didn't already perform this action
tcTokenRequest.getTokenContext().closeStream();
}
}
} catch (RuntimeException e) {
response = new BindingResult(BindingResultCode.INTERNAL_ERROR);
LOG.error(e.getMessage(), e);
}
return response;
}
Aggregations