diff --git a/kura/org.eclipse.kura.http.server.manager/src/main/java/org/eclipse/kura/http/server/manager/JettyServerHolder.java b/kura/org.eclipse.kura.http.server.manager/src/main/java/org/eclipse/kura/http/server/manager/JettyServerHolder.java index 4446f0cf43..86c8f38761 100644 --- a/kura/org.eclipse.kura.http.server.manager/src/main/java/org/eclipse/kura/http/server/manager/JettyServerHolder.java +++ b/kura/org.eclipse.kura.http.server.manager/src/main/java/org/eclipse/kura/http/server/manager/JettyServerHolder.java @@ -15,14 +15,19 @@ import java.io.File; import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; import java.security.KeyStore; import java.security.cert.PKIXRevocationChecker; +import java.util.Comparator; import java.util.EnumSet; import java.util.EventListener; import java.util.LinkedList; import java.util.List; import java.util.Optional; import java.util.Set; +import java.util.stream.Collectors; +import java.util.stream.Stream; import java.util.zip.Deflater; import org.eclipse.jetty.ee10.servlet.ServletContextHandler; @@ -66,7 +71,8 @@ public class JettyServerHolder { true); private final HttpServiceOptions options; - private Server server; + private final Server server; + private final File workDir; public JettyServerHolder(final HttpServiceOptions options, final Optional keystoreService, final HttpServlet httpServlet, final EventListener eventListener) { @@ -77,6 +83,11 @@ public JettyServerHolder(final HttpServiceOptions options, final Optional blockedMethods; + private final Set blockedMethods; public BlockHttpMethods(Set methods) { - this.blockedMethods = methods; + this.blockedMethods = methods.stream().map(m -> m.toString().toLowerCase()).collect(Collectors.toSet()); } @Override public Request customize(Request request, Mutable responseHeaders) { - if (this.blockedMethods.contains(HttpMethod.TRACE)) { + if (this.blockedMethods.contains(request.getMethod().toLowerCase())) { return new ErrorRequest(request, HttpStatus.METHOD_NOT_ALLOWED_405, "Method now allowed.", null); } @@ -303,6 +312,12 @@ public void stop() { } catch (Exception e) { logger.warn("Unable to stop the Jetty server", e); } + + try (final Stream stream = Files.walk(this.workDir.toPath())) { + stream.map(Path::toFile).sorted(Comparator.reverseOrder()).forEach(File::delete); + } catch (Exception e) { + logger.warn("Unable to cleanp jetty workdir", e); + } } } diff --git a/kura/org.eclipse.kura.web2/META-INF/MANIFEST.MF b/kura/org.eclipse.kura.web2/META-INF/MANIFEST.MF index 9f3180fb67..ef7c516f9c 100644 --- a/kura/org.eclipse.kura.web2/META-INF/MANIFEST.MF +++ b/kura/org.eclipse.kura.web2/META-INF/MANIFEST.MF @@ -49,6 +49,7 @@ Import-Package: com.eclipsesource.json;version="0.9.5", org.eclipse.kura.identity;version="[1.0,2.0)", org.eclipse.kura.internal.wire.asset;version="[1.0,2.0)", org.eclipse.kura.log;version="[1.1,1.2)", + org.eclipse.kura.log.listener;version="[1.0,2.0)", org.eclipse.kura.marshalling;version="[1.0,2.0)", org.eclipse.kura.net;version="[2.1,3.0)", org.eclipse.kura.net.admin;version="[1.6,3.0)";resolution:=optional, diff --git a/kura/org.eclipse.kura.web2/OSGI-INF/web.xml b/kura/org.eclipse.kura.web2/OSGI-INF/web.xml index bf34bba34f..bf9ca32e51 100644 --- a/kura/org.eclipse.kura.web2/OSGI-INF/web.xml +++ b/kura/org.eclipse.kura.web2/OSGI-INF/web.xml @@ -26,7 +26,6 @@ - diff --git a/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/client/Login.java b/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/client/Login.java index 2df2683cc1..b43b3c7b58 100644 --- a/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/client/Login.java +++ b/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/client/Login.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2019, 2020 Eurotech and/or its affiliates and others + * Copyright (c) 2024 Eurotech and/or its affiliates and others * * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 @@ -12,40 +12,16 @@ *******************************************************************************/ package org.eclipse.kura.web.client; -import java.util.List; - import org.eclipse.kura.web.client.ui.login.LoginUi; -import org.eclipse.kura.web.shared.model.GwtClientExtensionBundle; -import org.eclipse.kura.web.shared.service.GwtExtensionService; -import org.eclipse.kura.web.shared.service.GwtExtensionServiceAsync; import com.google.gwt.core.client.EntryPoint; import com.google.gwt.core.client.GWT; -import com.google.gwt.core.client.ScriptInjector; -import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.ui.RootPanel; public class Login implements EntryPoint { - private final GwtExtensionServiceAsync gwtExtensionService = GWT.create(GwtExtensionService.class); - @Override public void onModuleLoad() { - this.gwtExtensionService.getLoginExtensions(new AsyncCallback>() { - - @Override - public void onFailure(Throwable caught) { - // do nothing - } - - @Override - public void onSuccess(List result) { - - for (final GwtClientExtensionBundle extension : result) { - ScriptInjector.fromUrl(extension.getEntryPointUrl()).inject(); - } - } - }); RootPanel.get().add(GWT.create(LoginUi.class)); } diff --git a/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/client/denali.java b/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/client/denali.java index 30b0a18413..5b6e7a1323 100644 --- a/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/client/denali.java +++ b/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/client/denali.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011, 2021 Eurotech and/or its affiliates and others + * Copyright (c) 2024 Eurotech and/or its affiliates and others * * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 @@ -17,7 +17,6 @@ import org.eclipse.kura.web.client.ui.EntryClassUi; import org.eclipse.kura.web.client.util.FailureHandler; -import org.eclipse.kura.web.shared.model.GwtClientExtensionBundle; import org.eclipse.kura.web.shared.model.GwtGroupedNVPair; import org.eclipse.kura.web.shared.model.GwtSecurityCapabilities; import org.eclipse.kura.web.shared.model.GwtSession; @@ -25,8 +24,6 @@ import org.eclipse.kura.web.shared.model.GwtXSRFToken; import org.eclipse.kura.web.shared.service.GwtDeviceService; import org.eclipse.kura.web.shared.service.GwtDeviceServiceAsync; -import org.eclipse.kura.web.shared.service.GwtExtensionService; -import org.eclipse.kura.web.shared.service.GwtExtensionServiceAsync; import org.eclipse.kura.web.shared.service.GwtSecurityService; import org.eclipse.kura.web.shared.service.GwtSecurityServiceAsync; import org.eclipse.kura.web.shared.service.GwtSecurityTokenService; @@ -36,7 +33,6 @@ import com.google.gwt.core.client.EntryPoint; import com.google.gwt.core.client.GWT; -import com.google.gwt.core.client.ScriptInjector; import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.ui.RootPanel; @@ -49,7 +45,6 @@ public class denali implements EntryPoint { private final GwtSecurityTokenServiceAsync gwtXSRFService = GWT.create(GwtSecurityTokenService.class); private final GwtDeviceServiceAsync gwtDeviceService = GWT.create(GwtDeviceService.class); private final GwtSecurityServiceAsync gwtSecurityService = GWT.create(GwtSecurityService.class); - private final GwtExtensionServiceAsync gwtExtensionService = GWT.create(GwtExtensionService.class); private final GwtSessionServiceAsync gwtSessionService = GWT.create(GwtSessionService.class); @Override @@ -137,22 +132,6 @@ public void onSuccess(final GwtSecurityCapabilities result) { RootPanel.get().add(entryUi); entryUi.init(); - gwtExtensionService - .getConsoleExtensions(new AsyncCallback>() { - - @Override - public void onFailure(Throwable caught) { - FailureHandler.handle(caught); - } - - @Override - public void onSuccess(List result) { - - for (final GwtClientExtensionBundle extension : result) { - ScriptInjector.fromUrl(extension.getEntryPointUrl()).inject(); - } - } - }); } }); } diff --git a/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/shared/service/GwtExtensionService.java b/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/shared/service/GwtExtensionService.java deleted file mode 100644 index 6ce69d3218..0000000000 --- a/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/shared/service/GwtExtensionService.java +++ /dev/null @@ -1,30 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2019, 2020 Eurotech and/or its affiliates and others - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Eurotech - *******************************************************************************/ -package org.eclipse.kura.web.shared.service; - -import java.util.List; - -import org.eclipse.kura.web.shared.GwtKuraException; -import org.eclipse.kura.web.shared.model.GwtClientExtensionBundle; - -import com.google.gwt.user.client.rpc.RemoteService; -import com.google.gwt.user.client.rpc.RemoteServiceRelativePath; - -@RemoteServiceRelativePath("extension") -public interface GwtExtensionService extends RemoteService { - - public List getConsoleExtensions() throws GwtKuraException; - - public List getLoginExtensions() throws GwtKuraException; - -}