Skip to content

Commit

Permalink
[TP] update to Eclipse 4.30 and latest versions of other dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
HannesWell committed Dec 28, 2023
1 parent f3b12d7 commit 86fd54f
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 90 deletions.
3 changes: 2 additions & 1 deletion org.eclipse.m2e.tests.common/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@ MavenArtifact-GroupId: org.eclipse.m2e
MavenArtifact-ArtifactId: org.eclipse.m2e.tests.common
Export-Package: org.eclipse.m2e.tests.common;x-friends:="org.eclipse.m2e.tests,org.eclipse.m2e.core.tests,org.eclipse.m2e.jdt.tests,org.eclipse.m2e.core.ui.tests,org.eclipse.m2e.wtp.tests"
Import-Package: javax.servlet;version="3.1.0",
javax.servlet.http;version="3.1.0"
javax.servlet.http;version="3.1.0",
org.eclipse.jetty.io;version="12.0.0"
Automatic-Module-Name: org.eclipse.m2e.tests.common
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,29 @@
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.Base64;
import java.util.Collection;
import java.util.Collections;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.TreeMap;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.eclipse.jetty.http.HttpField;
import org.eclipse.jetty.http.HttpHeader;
import org.eclipse.jetty.http.HttpMethod;
import org.eclipse.jetty.http.HttpStatus;
import org.eclipse.jetty.http.HttpVersion;
import org.eclipse.jetty.security.ConstraintMapping;
import org.eclipse.jetty.security.ConstraintSecurityHandler;
import org.eclipse.jetty.io.Content;
import org.eclipse.jetty.security.Authenticator;
import org.eclipse.jetty.security.Constraint;
import org.eclipse.jetty.security.Constraint.Authorization;
import org.eclipse.jetty.security.HashLoginService;
import org.eclipse.jetty.security.SecurityHandler;
import org.eclipse.jetty.security.authentication.BasicAuthenticator;
Expand All @@ -48,14 +50,14 @@
import org.eclipse.jetty.server.HttpConnectionFactory;
import org.eclipse.jetty.server.NetworkConnector;
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.Response;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.ServerConnector;
import org.eclipse.jetty.server.SslConnectionFactory;
import org.eclipse.jetty.server.handler.AbstractHandler;
import org.eclipse.jetty.server.handler.DefaultHandler;
import org.eclipse.jetty.server.handler.HandlerList;
import org.eclipse.jetty.util.Callback;
import org.eclipse.jetty.util.URIUtil;
import org.eclipse.jetty.util.security.Constraint;
import org.eclipse.jetty.util.resource.PathResourceFactory;
import org.eclipse.jetty.util.ssl.SslContextFactory;


Expand Down Expand Up @@ -276,15 +278,15 @@ public HttpServer setProxyAuth(String username, String password) {
}

protected Handler newProxyHandler() {
return new AbstractHandler() {
return new Handler.Abstract() {
@Override
public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) {
String auth = request.getHeader("Proxy-Authorization");
public boolean handle(Request request, Response response, Callback callback) throws Exception {
String auth = request.getHeaders().get(HttpHeader.PROXY_AUTHORIZATION);
if(auth != null) {
auth = auth.substring(auth.indexOf(' ') + 1).trim();
auth = new String(Base64.getDecoder().decode(auth));

}
return false;
}
};
}
Expand All @@ -302,19 +304,19 @@ public HttpServer setRedirectToHttps(boolean redirectToHttps) {
}

protected Handler newSslRedirectHandler() {
return new AbstractHandler() {
return new Handler.Abstract() {
@Override
public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) {
public boolean handle(Request request, Response response, Callback callback) throws Exception {
int httpsPort = getHttpsPort();
if(!((Request) request).isHandled() && request.getServerPort() != httpsPort) {
String url = "https://" + request.getServerName() + ":" + httpsPort + request.getRequestURI();

response.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY);
response.setHeader("Location", url);
((Request) request).setHandled(true);
if(Request.getServerPort(request) != httpsPort) {
String url = "https://" + Request.getServerName(request) + ":" + httpsPort + request.getHttpURI().getPath();
response.setStatus(HttpStatus.MOVED_PERMANENTLY_301);
response.getHeaders().put(HttpHeader.LOCATION, url);
callback.succeeded();
return true;
}
return false;
}

};
}

Expand Down Expand Up @@ -347,21 +349,12 @@ public HttpServer addSecuredRealm(String pathSpec, String... roles) {
}

protected SecurityHandler newSecurityHandler() {
List<ConstraintMapping> mappings = new ArrayList<>();
SecurityHandler.PathMapped securityHandler = new SecurityHandler.PathMapped();

for(String pathSpec : securedRealms.keySet()) {
String[] roles = securedRealms.get(pathSpec);

Constraint constraint = new Constraint();
constraint.setName(Constraint.__BASIC_AUTH);
constraint.setRoles(roles);
constraint.setAuthenticate(true);

ConstraintMapping constraintMapping = new ConstraintMapping();
constraintMapping.setConstraint(constraint);
constraintMapping.setPathSpec(pathSpec);

mappings.add(constraintMapping);
Constraint constraint = Constraint.from(Authenticator.BASIC_AUTH, Authorization.SPECIFIC_ROLE, roles);
securityHandler.put(pathSpec, constraint);
}

Properties p = new Properties();
Expand All @@ -384,13 +377,12 @@ protected SecurityHandler newSecurityHandler() {
fail("Unable to create users properties file");
}

HashLoginService userRealm = new HashLoginService("TestRealm", "target/users.properties");
HashLoginService userRealm = new HashLoginService("TestRealm",
new PathResourceFactory().newClassLoaderResource("target/users.properties"));
server.addBean(userRealm);

ConstraintSecurityHandler securityHandler = new ConstraintSecurityHandler();
securityHandler.setAuthenticator(new BasicAuthenticator());
securityHandler.setLoginService(userRealm);
securityHandler.setConstraintMappings(mappings);

return securityHandler;
}
Expand Down Expand Up @@ -488,9 +480,8 @@ public HttpServer setLatency(long millis) {
}

protected Handler newSleepHandler(final long millis) {
return new AbstractHandler() {
@Override
public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) {
return new Handler.Abstract() {
public boolean handle(Request request, Response response, Callback callback) throws Exception {
if(millis >= 0) {
try {
Thread.sleep(millis);
Expand All @@ -506,8 +497,8 @@ public void handle(String target, Request baseRequest, HttpServletRequest reques
}
}
}
return false;
}

};
}

Expand All @@ -534,7 +525,7 @@ public HttpServer start() throws Exception {
connectors.add(newHttpsConnector());
}

HandlerList handlerList = new HandlerList();
Handler.Sequence handlerList = new Handler.Sequence();
if(!recordedPatterns.isEmpty()) {
handlerList.addHandler(new RecordingHandler());
}
Expand Down Expand Up @@ -645,58 +636,57 @@ public void stop() {
}
}

class ResHandler extends AbstractHandler {

@Override

public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response)
throws IOException {
private class ResHandler extends Handler.Abstract {

String uri = request.getRequestURI();
public boolean handle(Request request, Response response, Callback callback) throws Exception {
String uri = request.getHttpURI().getPath();

for(String contextRoot : resourceDirs.keySet()) {
String path = URIUtil.decodePath(trimContextRoot(uri, contextRoot));
if(path != null) {
File basedir = resourceDirs.get(contextRoot);
File file = new File(basedir, path);

if(HttpMethod.HEAD.equals(request.getMethod())) {
if(file.exists())
response.setStatus(HttpServletResponse.SC_OK);
else
response.setStatus(HttpServletResponse.SC_NOT_FOUND);
((Request) request).setHandled(true);
return;
} else if(HttpMethod.PUT.equals(request.getMethod()) || HttpMethod.POST.equals(request.getMethod())) {
HttpMethod requestMethod = HttpMethod.fromString(request.getMethod());
if(HttpMethod.HEAD == requestMethod) {
if(file.exists()) {
response.setStatus(HttpStatus.OK_200);
} else {
response.setStatus(HttpStatus.NOT_FOUND_404);
}
callback.succeeded();
return true;
} else if(HttpMethod.PUT == requestMethod || HttpMethod.POST == requestMethod) {
file.getParentFile().mkdirs();

try (var input = request.getInputStream()) {
try (var input = Content.Source.asInputStream(request)) {
Files.copy(input, file.toPath());
}

response.setStatus(HttpServletResponse.SC_CREATED);
((Request) request).setHandled(true);
response.setStatus(HttpStatus.CREATED_201);
callback.succeeded();
return true;
} else if(file.isFile()) {

try (var outputStream = response.getOutputStream()) {
String filterEncoding = getFilterEncoding(path, resourceFilters.get(contextRoot));
if(filterEncoding == null) {
Files.copy(file.toPath(), outputStream);
} else {
String text = Files.readString(file.toPath(), Charset.forName(filterEncoding));
text = filter(text, filterTokens);
outputStream.write(text.getBytes(filterEncoding));
}
String filterEncoding = getFilterEncoding(path, resourceFilters.get(contextRoot));
byte[] bytes;
if(filterEncoding == null) {
bytes = Files.readAllBytes(file.toPath());
} else {
String text = Files.readString(file.toPath(), Charset.forName(filterEncoding));
text = filter(text, filterTokens);
bytes = text.getBytes(filterEncoding);
}
response.write(true, ByteBuffer.wrap(bytes), callback);

response.setStatus(HttpServletResponse.SC_OK);
((Request) request).setHandled(true);
response.setStatus(HttpStatus.OK_200);
callback.succeeded();
return true;
}

break;
return false;
}
}

return false;
}

private String getExtension(String path) {
Expand Down Expand Up @@ -727,11 +717,11 @@ private String filter(String str, Map<String, String> tokens) {

}

class RecordingHandler extends AbstractHandler {
private class RecordingHandler extends Handler.Abstract {

@Override
public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) {
String uri = request.getRequestURI();
public boolean handle(Request request, Response response, Callback callback) throws Exception {
String uri = request.getHttpURI().getPath();

for(String pattern : recordedPatterns) {
if(uri.matches(pattern)) {
Expand All @@ -740,14 +730,13 @@ public void handle(String target, Request baseRequest, HttpServletRequest reques

Map<String, String> headers = new HashMap<>();
recordedHeaders.put(uri, headers);
for(Enumeration<String> h = request.getHeaderNames(); h.hasMoreElements();) {
String headername = h.nextElement();
headers.put(headername, request.getHeader(headername));
for(HttpField field : request.getHeaders()) {
headers.put(field.getName(), field.getValue());
}
}
}
return false;
}

}

private static String normalizeContextRoot(String contextRoot) {
Expand Down
18 changes: 10 additions & 8 deletions target-platform/target-platform.target
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,38 @@
<targetJRE path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17"/>
<locations>
<location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="true" type="InstallableUnit">
<repository location="https://download.eclipse.org/eclipse/updates/4.29/"/>
<repository location="https://download.eclipse.org/eclipse/updates/4.30/"/>
<unit id="org.eclipse.sdk.feature.group" version="0.0.0"/>
<unit id="org.eclipse.equinox.p2.discovery.feature.feature.group" version="0.0.0"/>
<unit id="org.eclipse.ui.tests.harness" version="0.0.0"/>
<unit id="org.eclipse.equinox.executable.feature.group" version="0.0.0"/>
<unit id="org.mockito.mockito-core" version="0.0.0"/>
<unit id="jakarta.inject.jakarta.inject-api" version="1.0.5"/>
<unit id="jakarta.annotation-api" version="1.3.5"/>
</location>
<location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="true" type="InstallableUnit">
<repository location="https://download.eclipse.org/tools/orbit/simrel/orbit-aggregation/2023-12/"/>
<repository location="https://download.eclipse.org/tools/orbit/simrel/orbit-aggregation/2024-03/"/>
<unit id="org.jdom2" version="0.0.0"/>
</location>
<location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="true" type="InstallableUnit">
<repository location="https://download.eclipse.org/egit/updates-6.7/"/>
<repository location="https://download.eclipse.org/egit/updates-6.8/"/>
<unit id="org.eclipse.jgit" version="0.0.0"/>
</location>
<location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="true" type="InstallableUnit">
<repository location="https://download.eclipse.org/modeling/emf/emf/builds/release/2.35.0"/>
<repository location="https://download.eclipse.org/modeling/emf/emf/builds/release/2.36.0"/>
<unit id="org.eclipse.emf.edit.ui.feature.group" version="0.0.0"/>
<unit id="org.eclipse.emf.ecore.edit.feature.group" version="0.0.0"/>
</location>
<location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="true" type="InstallableUnit">
<repository location="https://download.eclipse.org/webtools/downloads/drops/R3.31.0/R-3.31.0-20230903090456/repository/"/>
<repository location="https://download.eclipse.org/webtools/downloads/drops/R3.32.0/R-3.32.0-20231114230950/repository/"/>
<unit id="org.eclipse.wst.common.uriresolver" version="0.0.0"/>
<unit id="org.eclipse.wst.common.emf" version="0.0.0"/>
<unit id="org.eclipse.wst.xsd.core" version="0.0.0"/>
</location>
<location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="true" type="InstallableUnit">
<repository location="https://download.eclipse.org/wildwebdeveloper/releases/1.3.3/"/>
<repository location="https://download.eclipse.org/tm4e/releases/0.8.1/"/>
<repository location="https://download.eclipse.org/lsp4e/releases/0.24.3/"/>
<repository location="https://download.eclipse.org/lsp4e/releases/0.24.5/"/>
<repository location="https://download.eclipse.org/lsp4j/updates/releases/0.21.1/"/>
<unit id="org.eclipse.wildwebdeveloper.xml.feature.feature.group" version="0.0.0"/>
<unit id="org.eclipse.lsp4e" version="0.0.0"/>
Expand Down Expand Up @@ -63,7 +65,7 @@
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.4.11</version>
<version>1.4.14</version>
<type>jar</type>
</dependency>
<dependency>
Expand Down Expand Up @@ -109,7 +111,7 @@
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.13.0</version>
<version>3.14.0</version>
<type>jar</type>
</dependency>
</dependencies>
Expand Down

0 comments on commit 86fd54f

Please sign in to comment.