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

How to add a org.eclipse.jetty.ee8.security.ConstraintSecurityHandler to a org.eclipse.jetty.server.Handler.Collection #12804

Closed
msohn opened this issue Feb 18, 2025 · 2 comments
Labels

Comments

@msohn
Copy link

msohn commented Feb 18, 2025

Jetty Version
12.0.16
Jetty Environment
ee8

Java Version
17

Question
Since Gerrit Code Review can't yet update from servlet API 4 to 6 it is currently stuck to
use JGit 6.10. Since Gerrit wants to benefit from all the new stuff in JGit master and JGit
doesn't want new features on its stable-6.10 branch I am trying to downgrade JGit master
on the servlet-4 branch from servlet API 6.1.0 to 4.0.4 in this change:
https://eclipse.gerrithub.io/c/eclipse-jgit/jgit/+/1208599

I am stuck with a compile error on line 339 of the class org.eclipse.jgit.junit.http.AppServer
since I can't figure out how to add a org.eclipse.jetty.ee8.security.ConstraintSecurityHandler to a org.eclipse.jetty.server.Handler.Collection.
Looks like I am lost in Jetty class hierarchies.

@msohn msohn added the Question label Feb 18, 2025
@Spikhalskiy
Copy link

Spikhalskiy commented Feb 19, 2025

org.eclipse.jetty.ee8.webapp.WebAppContext and its ancestor org.eclipse.jetty.ee8.servlet.ServletContextHandler accept org.eclipse.jetty.ee8.security.SecurityHandler as a constructor parameter.
org.eclipse.jetty.ee8.security.ConstraintSecurityHandler is a subclass of org.eclipse.jetty.ee8.security.SecurityHandler.

This may be also helpful:

@msohn
Copy link
Author

msohn commented Feb 20, 2025

Thanks a lot, your hint helped to find the fix.

Instead of wrapping the ServletContextHandler with a ConstraintSecurityHandler
we need to set the ServletContextHandler's security handler using ServletContextHandler.setSecurityHandler(ConstraintSecurityHandler).

See https://eclipse.gerrithub.io/c/eclipse-jgit/jgit/+/1208599/2..3/org.eclipse.jgit.junit.http/src/org/eclipse/jgit/junit/http/AppServer.java#339

@msohn msohn closed this as completed Feb 20, 2025
eclipse-jgit-bot pushed a commit to eclipse-jgit/jgit that referenced this issue Feb 20, 2025
Gerrit cannot yet update to servlet-api 6.x hence downgrade it to 4.0.4.
Instead of Jetty ee10 environment supporting servlet 6 use the ee8
environment supporting servlet 4.

See
https://jetty.org/docs/jetty/12/programming-guide/server/http.html#handler-use-servlet
jetty/jetty.project#12804

Change-Id: I545fe34aa9b18642b437af41716035176759a614
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants