From e5cfa24420c147132b8f57f004db14d4f1d1bcbf Mon Sep 17 00:00:00 2001 From: Thomas Lenz Date: Mon, 5 Aug 2019 12:44:32 +0200 Subject: add AbstractLocaleAuthServletTask.java into EAAF-core move a misplaced log message change maven repo paths to one single egiz repo --- .../eaaf/core/impl/idp/auth/RequestStorage.java | 7 +-- .../tasks/AbstractLocaleAuthServletTask.java | 70 ++++++++++++++++++++++ .../gv/egiz/eaaf/core/api/data/EAAFConstants.java | 2 + .../gv/egiz/eaaf/core/api/data/EAAFEventCodes.java | 5 ++ eaaf_modules/eaaf_module_pvp2_core/pom.xml | 25 +------- pom.xml | 2 +- 6 files changed, 82 insertions(+), 29 deletions(-) create mode 100644 eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/controller/tasks/AbstractLocaleAuthServletTask.java create mode 100644 eaaf_core_api/src/main/java/at/gv/egiz/eaaf/core/api/data/EAAFEventCodes.java diff --git a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/RequestStorage.java b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/RequestStorage.java index 9758e258..e1598b8f 100644 --- a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/RequestStorage.java +++ b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/RequestStorage.java @@ -176,7 +176,8 @@ public class RequestStorage implements IRequestStorage{ //generate new pendingReqId and get internalPendingReqId - final String newRequestID = pendingReqIdGenerationStrategy.generateExternalPendingRequestId(); + final String newRequestID = pendingReqIdGenerationStrategy.generateExternalPendingRequestId(); + log.debug("Change pendingRequestID from " + pendingRequest.getPendingRequestId() + " to " + newRequestID); ((RequestImpl)pendingRequest).setPendingRequestId(newRequestID); String newInternalPendingRequestId = null; @@ -189,9 +190,7 @@ public class RequestStorage implements IRequestStorage{ } - //change Key in cache - log.debug("Change pendingRequestID from " + pendingRequest.getPendingRequestId() - + " to " + newRequestID); + //change Key in cache transactionStorage.changeKey(oldInternalRequestID, newInternalPendingRequestId, pendingRequest); //only delete oldRequestID, no change. diff --git a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/controller/tasks/AbstractLocaleAuthServletTask.java b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/controller/tasks/AbstractLocaleAuthServletTask.java new file mode 100644 index 00000000..e80a63e9 --- /dev/null +++ b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/controller/tasks/AbstractLocaleAuthServletTask.java @@ -0,0 +1,70 @@ +package at.gv.egiz.eaaf.core.impl.idp.controller.tasks; + +import java.io.Serializable; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.text.StringEscapeUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import at.gv.egiz.eaaf.core.api.data.EAAFConstants; +import at.gv.egiz.eaaf.core.api.data.EAAFEventCodes; +import at.gv.egiz.eaaf.core.api.idp.process.ExecutionContext; +import at.gv.egiz.eaaf.core.exceptions.EAAFException; +import at.gv.egiz.eaaf.core.exceptions.TaskExecutionException; +import at.gv.egiz.eaaf.core.impl.idp.auth.modules.AbstractAuthServletTask; + +public abstract class AbstractLocaleAuthServletTask extends AbstractAuthServletTask { + private static final Logger log = LoggerFactory.getLogger(AbstractLocaleAuthServletTask.class); + + public static final String PROP_REQ_PARAM_LOCALE = "lang"; + + @Override + public final void execute(ExecutionContext executionContext, HttpServletRequest request, HttpServletResponse response) + throws TaskExecutionException { + + final Serializable changeLangFlag = executionContext.get(EAAFConstants.PROCESSCONTEXT_SWITCH_LANGUAGE); + final String localeParam = StringEscapeUtils.escapeHtml4(request.getParameter(PROP_REQ_PARAM_LOCALE)); + if (StringUtils.isNotEmpty(localeParam) && + (changeLangFlag == null || !((Boolean)changeLangFlag)) ) { + log.debug("Find {} parameter. Reload last task with new locale: {}", PROP_REQ_PARAM_LOCALE, localeParam); + executionContext.put(EAAFConstants.PROCESSCONTEXT_SWITCH_LANGUAGE, true); + + + + } else { + log.trace("Find {} parameter. Processing this task ... ",PROP_REQ_PARAM_LOCALE); + executionContext.remove(EAAFConstants.PROCESSCONTEXT_SWITCH_LANGUAGE); + + final String stopAuthFlag = request.getParameter(EAAFConstants.PARAM_HTTP_STOP_PROCESS); + if (StringUtils.isNotEmpty(stopAuthFlag) && Boolean.parseBoolean(stopAuthFlag)) { + try { + log.info("Authentication process WAS stopped by entity. Stopping auth. process ... "); + revisionsLogger.logEvent(pendingReq, EAAFEventCodes.PROCESS_STOPPED_BY_USER); + pendingReq.setAbortedByUser(true); + pendingReq.setAuthenticated(false); + performRedirectToProtocolFinialization(executionContext, pendingReq, request, response); + + } catch (final EAAFException e) { + throw new TaskExecutionException(pendingReq, e.getMessage(), e); + + } catch (final Exception e) { + log.warn("Stopping auth.process FAILED", e); + throw new TaskExecutionException(pendingReq, e.getMessage(), e); + + } + + } else + executeWithLocale(executionContext, request, response); + + } + + } + + protected abstract void executeWithLocale(ExecutionContext executionContext, HttpServletRequest request, + HttpServletResponse response) throws TaskExecutionException; + +} diff --git a/eaaf_core_api/src/main/java/at/gv/egiz/eaaf/core/api/data/EAAFConstants.java b/eaaf_core_api/src/main/java/at/gv/egiz/eaaf/core/api/data/EAAFConstants.java index b29e9843..2397ef0a 100644 --- a/eaaf_core_api/src/main/java/at/gv/egiz/eaaf/core/api/data/EAAFConstants.java +++ b/eaaf_core_api/src/main/java/at/gv/egiz/eaaf/core/api/data/EAAFConstants.java @@ -34,6 +34,7 @@ public class EAAFConstants { //http request parameters for process management public static final String PARAM_HTTP_TARGET_PENDINGREQUESTID = "pendingid"; public static final String PARAM_HTTP_ERROR_CODE = "errorid"; + public static final String PARAM_HTTP_STOP_PROCESS = "stopAuthProcess"; public static final String EIDAS_LOA_PREFIX = "http://eidas.europa.eu/LoA/"; @@ -70,6 +71,7 @@ public class EAAFConstants { public static final String PROCESSCONTEXT_SP_CONFIG = PROCESS_ENGINE_PREFIX + "spConfig"; public static final String PROCESS_ENGINE_REQUIRES_NO_POSTAUTH_REDIRECT = PROCESS_ENGINE_PREFIX + "requireNoPostAuthRedirect"; + public static final String PROCESSCONTEXT_SWITCH_LANGUAGE = "changeLanguage"; public static final int ALLOWED_TIME_JITTER = 5; //minutes public static final String COUNTRYCODE_AUSTRIA = "AT"; diff --git a/eaaf_core_api/src/main/java/at/gv/egiz/eaaf/core/api/data/EAAFEventCodes.java b/eaaf_core_api/src/main/java/at/gv/egiz/eaaf/core/api/data/EAAFEventCodes.java new file mode 100644 index 00000000..5ee6eb90 --- /dev/null +++ b/eaaf_core_api/src/main/java/at/gv/egiz/eaaf/core/api/data/EAAFEventCodes.java @@ -0,0 +1,5 @@ +package at.gv.egiz.eaaf.core.api.data; + +public class EAAFEventCodes { + public static final int PROCESS_STOPPED_BY_USER = 4102; +} diff --git a/eaaf_modules/eaaf_module_pvp2_core/pom.xml b/eaaf_modules/eaaf_module_pvp2_core/pom.xml index de7d6981..a00d3f6a 100644 --- a/eaaf_modules/eaaf_module_pvp2_core/pom.xml +++ b/eaaf_modules/eaaf_module_pvp2_core/pom.xml @@ -13,30 +13,7 @@ UTF-8 - - - + at.gv.egiz.eaaf diff --git a/pom.xml b/pom.xml index 3065bd4f..e22f6d92 100644 --- a/pom.xml +++ b/pom.xml @@ -90,7 +90,7 @@ egiz-commons - https://demo.egiz.gv.at/int-repo/ + https://apps.egiz.gv.at/maven/ true -- cgit v1.2.3