Skip to content

Commit

Permalink
➖ breaking the dependency between job-engine app and job-client
Browse files Browse the repository at this point in the history
Signed-off-by: dseurotech <[email protected]>
  • Loading branch information
dseurotech committed Jun 11, 2024
1 parent 294daab commit 74c5d46
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import org.eclipse.kapua.model.id.KapuaIdAdapter;

@XmlRootElement(name = "isJobRunningResponse")

public class IsJobRunningResponse {

private KapuaId jobId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
4 changes: 0 additions & 4 deletions job-engine/app/core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.kapua</groupId>
<artifactId>kapua-job-engine-client</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.kapua</groupId>
<artifactId>kapua-job-engine-jbatch</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}.
Expand Down

0 comments on commit 74c5d46

Please sign in to comment.