From 3c36480c8d06bf712c2bba65119432fe3454420c Mon Sep 17 00:00:00 2001 From: Thomas Lenz Date: Thu, 21 Nov 2019 12:10:08 +0100 Subject: set process-canceled flag in case of user stops authprocess change log-level for some exceptions --- .../services/ProtocolAuthenticationService.java | 32 +++++++++++++++++----- .../tasks/AbstractLocaleAuthServletTask.java | 5 +++- 2 files changed, 29 insertions(+), 8 deletions(-) diff --git a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/services/ProtocolAuthenticationService.java b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/services/ProtocolAuthenticationService.java index 090ea501..2edf8a75 100644 --- a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/services/ProtocolAuthenticationService.java +++ b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/services/ProtocolAuthenticationService.java @@ -25,6 +25,8 @@ package at.gv.egiz.eaaf.core.impl.idp.auth.services; import java.io.IOException; import java.io.PrintWriter; import java.io.StringWriter; +import java.util.Arrays; +import java.util.List; import javax.naming.ConfigurationException; import javax.servlet.http.HttpServletRequest; @@ -61,7 +63,6 @@ import at.gv.egiz.eaaf.core.api.idp.auth.services.IProtocolAuthenticationService import at.gv.egiz.eaaf.core.api.idp.slo.SLOInformationInterface; import at.gv.egiz.eaaf.core.api.logging.IRevisionLogger; import at.gv.egiz.eaaf.core.api.logging.IStatisticLogger; -import at.gv.egiz.eaaf.core.api.storage.ITransactionStorage; import at.gv.egiz.eaaf.core.api.utils.IPendingRequestIdGenerationStrategy; import at.gv.egiz.eaaf.core.exceptions.AuthnRequestValidatorException; import at.gv.egiz.eaaf.core.exceptions.EAAFAuthenticationException; @@ -79,8 +80,12 @@ import at.gv.egiz.eaaf.core.impl.utils.HTTPUtils; public class ProtocolAuthenticationService implements IProtocolAuthenticationService { private static final Logger log = LoggerFactory.getLogger(ProtocolAuthenticationService.class); + private static final List ERROR_LOGGER_ON_INFO_LEVEL = + Arrays.asList( + IStatusMessenger.CODES_INTERNAL_ERROR_AUTH_USERSTOP + ); + @Autowired(required=true) private ApplicationContext applicationContext; - @Autowired(required=true) private ITransactionStorage transactionStorage; @Autowired(required=true) private IAuthenticationManager authmanager; @Autowired(required=true) private IAuthenticationDataBuilder authDataBuilder; @Autowired(required=true) private IGUIBuilderConfigurationFactory guiConfigFactory; @@ -368,13 +373,26 @@ public class ProtocolAuthenticationService implements IProtocolAuthenticationSer log.error("Receive an internal error: Message=" + loggedException.getMessage(), loggedException); } else { - if (log.isDebugEnabled() || log.isTraceEnabled()) { - log.warn(loggedException.getMessage(), loggedException); + if (loggedException instanceof EAAFAuthenticationException && + ERROR_LOGGER_ON_INFO_LEVEL.contains( + ((EAAFAuthenticationException) loggedException).getErrorId())) { + if (log.isDebugEnabled() || log.isTraceEnabled()) { + log.info(loggedException.getMessage(), loggedException); + + } else { + log.info(loggedException.getMessage()); + + } + + } else { + if (log.isDebugEnabled() || log.isTraceEnabled()) { + log.warn(loggedException.getMessage(), loggedException); - } else { - log.warn(loggedException.getMessage()); + } else { + log.warn(loggedException.getMessage()); - } + } + } } } 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 index 84290ad0..69b13d1d 100644 --- 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 @@ -57,6 +57,9 @@ public abstract class AbstractLocaleAuthServletTask extends AbstractAuthServletT pendingReq.setAuthenticated(false); performRedirectToProtocolFinialization(executionContext, pendingReq, request, response); + log.trace("Set process-cancelation flag"); + executionContext.setCanceleProcessFlag(); + } catch (final EAAFException e) { throw new TaskExecutionException(pendingReq, e.getMessage(), e); @@ -69,7 +72,7 @@ public abstract class AbstractLocaleAuthServletTask extends AbstractAuthServletT } protected boolean parseFlagFromHttpRequest(HttpServletRequest httpReq, String httpParamName, boolean defaultValue) { - String flag = httpReq.getParameter(httpParamName); + final String flag = httpReq.getParameter(httpParamName); log.trace("Get httpParam: {} with value: {}", httpParamName, flag); if (StringUtils.isNotEmpty(httpParamName)) { return Boolean.parseBoolean(flag); -- cgit v1.2.3