Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to Jetty12 #2911

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cnf/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,8 @@
<!-- Apache Felix HTTP Service -->
<!-- Changelog: https://github.com/apache/felix-dev/commits/master/http -->
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.http.jetty</artifactId>
<version>5.1.26</version>
<artifactId>org.apache.felix.http.jetty12</artifactId>
<version>1.0.18</version>
</dependency>
<dependency>
<!-- Apache Felix Servlet API -->
Expand Down
2 changes: 1 addition & 1 deletion io.openems.backend.b2brest/bnd.bnd
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Bundle-Version: 1.0.0.${tstamp}
Java-WebSocket,\
io.openems.backend.common,\
io.openems.common,\
org.apache.felix.http.jetty,\
org.apache.felix.http.jetty12,\
org.apache.felix.http.servlet-api,\

-testpath: \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;

import org.eclipse.jetty.server.Handler;
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.handler.AbstractHandler;
import org.eclipse.jetty.server.Response;
import org.eclipse.jetty.util.Callback;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -32,7 +34,7 @@
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

public class RestHandler extends AbstractHandler {
public class RestHandler extends Handler.Abstract {

private final Logger log = LoggerFactory.getLogger(RestHandler.class);

Expand All @@ -43,11 +45,10 @@ public RestHandler(Backend2BackendRest parent) {
}

@Override
public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response)
throws IOException {
public boolean handle(Request request, Response resposne, Callback callback) throws Exception {
try {
var user = this.authenticate(request);

List<String> targets = Arrays.asList(//
target.substring(1) // remove leading '/'
.split("/"));
Expand All @@ -74,8 +75,8 @@ public void handle(String target, Request baseRequest, HttpServletRequest reques
* @return the {@link User}
* @throws OpenemsNamedException on error
*/
private User authenticate(HttpServletRequest request) throws OpenemsNamedException {
var authHeader = request.getHeader("Authorization");
private User authenticate(Request request) throws OpenemsNamedException {
var authHeader = request.getHeaders().get("Authorization");
if (authHeader != null) {
var st = new StringTokenizer(authHeader);
if (st.hasMoreTokens()) {
Expand Down
Loading