From 74c5d46f5ec06418fed47a0b9e99d15a0e07abc8 Mon Sep 17 00:00:00 2001 From: dseurotech Date: Wed, 5 Jun 2024 18:11:24 +0200 Subject: [PATCH] :heavy_minus_sign: breaking the dependency between job-engine app and job-client Signed-off-by: dseurotech --- .../job/engine/IsJobRunningResponse.java | 1 - .../job/engine}/SessionInfoHttpHeaders.java | 4 +-- job-engine/app/core/pom.xml | 4 --- .../app/core/filter/RebuildSessionFilter.java | 26 +++++++++---------- .../client/filter/SessionInfoFilter.java | 11 +++++--- 5 files changed, 22 insertions(+), 24 deletions(-) rename job-engine/{client/src/main/java/org/eclipse/kapua/job/engine/client/filter => api/src/main/java/org/eclipse/kapua/job/engine}/SessionInfoHttpHeaders.java (86%) diff --git a/job-engine/api/src/main/java/org/eclipse/kapua/job/engine/IsJobRunningResponse.java b/job-engine/api/src/main/java/org/eclipse/kapua/job/engine/IsJobRunningResponse.java index 68bc4ff16a4..0131975ed8c 100644 --- a/job-engine/api/src/main/java/org/eclipse/kapua/job/engine/IsJobRunningResponse.java +++ b/job-engine/api/src/main/java/org/eclipse/kapua/job/engine/IsJobRunningResponse.java @@ -20,7 +20,6 @@ import org.eclipse.kapua.model.id.KapuaIdAdapter; @XmlRootElement(name = "isJobRunningResponse") - public class IsJobRunningResponse { private KapuaId jobId; diff --git a/job-engine/client/src/main/java/org/eclipse/kapua/job/engine/client/filter/SessionInfoHttpHeaders.java b/job-engine/api/src/main/java/org/eclipse/kapua/job/engine/SessionInfoHttpHeaders.java similarity index 86% rename from job-engine/client/src/main/java/org/eclipse/kapua/job/engine/client/filter/SessionInfoHttpHeaders.java rename to job-engine/api/src/main/java/org/eclipse/kapua/job/engine/SessionInfoHttpHeaders.java index 820ba258b97..3233cb4fb65 100644 --- a/job-engine/client/src/main/java/org/eclipse/kapua/job/engine/client/filter/SessionInfoHttpHeaders.java +++ b/job-engine/api/src/main/java/org/eclipse/kapua/job/engine/SessionInfoHttpHeaders.java @@ -10,10 +10,10 @@ * Contributors: * Eurotech - initial API and implementation *******************************************************************************/ -package org.eclipse.kapua.job.engine.client.filter; +package org.eclipse.kapua.job.engine; /** - * List of headers name used by the {@link SessionInfoFilter} + * List of headers name used by the job engine client * * @since 1.5.0 */ diff --git a/job-engine/app/core/pom.xml b/job-engine/app/core/pom.xml index 144a6281231..0422b15b586 100644 --- a/job-engine/app/core/pom.xml +++ b/job-engine/app/core/pom.xml @@ -29,10 +29,6 @@ javax.servlet javax.servlet-api - - org.eclipse.kapua - kapua-job-engine-client - org.eclipse.kapua kapua-job-engine-jbatch diff --git a/job-engine/app/core/src/main/java/org/eclipse/kapua/job/engine/app/core/filter/RebuildSessionFilter.java b/job-engine/app/core/src/main/java/org/eclipse/kapua/job/engine/app/core/filter/RebuildSessionFilter.java index 78a06080562..f8580ee59f7 100644 --- a/job-engine/app/core/src/main/java/org/eclipse/kapua/job/engine/app/core/filter/RebuildSessionFilter.java +++ b/job-engine/app/core/src/main/java/org/eclipse/kapua/job/engine/app/core/filter/RebuildSessionFilter.java @@ -12,18 +12,18 @@ *******************************************************************************/ package org.eclipse.kapua.job.engine.app.core.filter; +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; +import javax.servlet.http.HttpServletRequest; + import org.eclipse.kapua.app.api.core.auth.KapuaTokenAuthenticationFilter; import org.eclipse.kapua.commons.security.KapuaSecurityUtils; import org.eclipse.kapua.commons.security.KapuaSession; -import org.eclipse.kapua.job.engine.client.filter.SessionInfoHttpHeaders; +import org.eclipse.kapua.job.engine.SessionInfoHttpHeaders; import org.eclipse.kapua.locator.KapuaLocator; import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.model.id.KapuaIdFactory; -import javax.servlet.ServletRequest; -import javax.servlet.ServletResponse; -import javax.servlet.http.HttpServletRequest; - public class RebuildSessionFilter extends KapuaTokenAuthenticationFilter { private final KapuaIdFactory kapuaIdFactory = KapuaLocator.getInstance().getFactory(KapuaIdFactory.class); @@ -33,14 +33,14 @@ protected boolean onAccessDenied(ServletRequest request, ServletResponse respons HttpServletRequest httpRequest = (HttpServletRequest) request; String authMode = httpRequest.getHeader(SessionInfoHttpHeaders.AUTH_MODE); switch (authMode) { - case "trusted": - KapuaId scopeId = kapuaIdFactory.newKapuaId(httpRequest.getHeader(SessionInfoHttpHeaders.SCOPE_ID_HTTP_HEADER)); - KapuaId userId = kapuaIdFactory.newKapuaId(httpRequest.getHeader(SessionInfoHttpHeaders.USER_ID_HTTP_HEADER)); - KapuaSecurityUtils.setSession(KapuaSession.createFrom(scopeId, userId)); - return true; - case "access_token": - default: - return super.onAccessDenied(request, response); + case "trusted": + KapuaId scopeId = kapuaIdFactory.newKapuaId(httpRequest.getHeader(SessionInfoHttpHeaders.SCOPE_ID_HTTP_HEADER)); + KapuaId userId = kapuaIdFactory.newKapuaId(httpRequest.getHeader(SessionInfoHttpHeaders.USER_ID_HTTP_HEADER)); + KapuaSecurityUtils.setSession(KapuaSession.createFrom(scopeId, userId)); + return true; + case "access_token": + default: + return super.onAccessDenied(request, response); } } diff --git a/job-engine/client/src/main/java/org/eclipse/kapua/job/engine/client/filter/SessionInfoFilter.java b/job-engine/client/src/main/java/org/eclipse/kapua/job/engine/client/filter/SessionInfoFilter.java index 0ac80a56b01..f3bf63a513b 100644 --- a/job-engine/client/src/main/java/org/eclipse/kapua/job/engine/client/filter/SessionInfoFilter.java +++ b/job-engine/client/src/main/java/org/eclipse/kapua/job/engine/client/filter/SessionInfoFilter.java @@ -12,16 +12,19 @@ *******************************************************************************/ package org.eclipse.kapua.job.engine.client.filter; -import com.google.common.net.HttpHeaders; +import java.io.IOException; + +import javax.ws.rs.client.ClientRequestContext; +import javax.ws.rs.client.ClientRequestFilter; + import org.eclipse.kapua.commons.security.KapuaSecurityUtils; import org.eclipse.kapua.commons.security.KapuaSession; +import org.eclipse.kapua.job.engine.SessionInfoHttpHeaders; import org.eclipse.kapua.job.engine.client.settings.JobEngineClientSetting; import org.eclipse.kapua.job.engine.client.settings.JobEngineClientSettingKeys; import org.eclipse.kapua.locator.KapuaLocator; -import javax.ws.rs.client.ClientRequestContext; -import javax.ws.rs.client.ClientRequestFilter; -import java.io.IOException; +import com.google.common.net.HttpHeaders; /** * {@link ClientRequestFilter} used to populate HTTP request headers with information about the current {@link KapuaSession}.