|
21 | 21 | import java.net.URI;
|
22 | 22 | import java.util.Map;
|
23 | 23 |
|
24 |
| -import org.apache.activemq.transport.http.BlockingQueueTransport; |
25 | 24 | import org.apache.activemq.util.InetAddressUtil;
|
26 | 25 | import org.apache.activemq.util.IntrospectionSupport;
|
27 |
| -import org.eclipse.jetty.security.ConstraintMapping; |
28 |
| -import org.eclipse.jetty.security.ConstraintSecurityHandler; |
| 26 | +import org.eclipse.jetty.ee9.nested.ServletConstraint; |
| 27 | +import org.eclipse.jetty.ee9.security.ConstraintMapping; |
| 28 | +import org.eclipse.jetty.ee9.security.ConstraintSecurityHandler; |
29 | 29 | import org.eclipse.jetty.server.Connector;
|
30 | 30 | import org.eclipse.jetty.server.Server;
|
31 |
| -import org.eclipse.jetty.util.resource.Resource; |
32 |
| -import org.eclipse.jetty.util.security.Constraint; |
| 31 | +import org.eclipse.jetty.util.resource.ResourceFactory; |
33 | 32 | import org.eclipse.jetty.xml.XmlConfiguration;
|
34 | 33 | import org.slf4j.Logger;
|
35 | 34 | import org.slf4j.LoggerFactory;
|
@@ -57,13 +56,13 @@ private <T> void setConnectorProperty(String name, Class<T> type, T value) throw
|
57 | 56 | protected void createServer() {
|
58 | 57 | LOG.info("Starting Jetty server");
|
59 | 58 | if (jettyOptions.getConfig() != null) {
|
60 |
| - try { |
| 59 | + try (ResourceFactory.Closeable resourceFactory = ResourceFactory.closeable()) { |
61 | 60 | LOG.info("Configuring Jetty server using {}", jettyOptions.getConfig());
|
62 | 61 | File file = new File(jettyOptions.getConfig());
|
63 | 62 | if (!file.exists()) {
|
64 | 63 | throw new IllegalArgumentException("Jetty XML not found: " + file.getAbsolutePath());
|
65 | 64 | }
|
66 |
| - XmlConfiguration xmlConfiguration = new XmlConfiguration(Resource.newResource(file)); |
| 65 | + XmlConfiguration xmlConfiguration = new XmlConfiguration(resourceFactory.newResource(file.getPath())); |
67 | 66 | server = (Server) xmlConfiguration.configure();
|
68 | 67 | } catch (Throwable t) {
|
69 | 68 | throw new IllegalStateException("Jetty configuration can't be loaded", t);
|
@@ -111,12 +110,17 @@ public URI bind() throws Exception {
|
111 | 110 |
|
112 | 111 | protected void configureTraceMethod(ConstraintSecurityHandler securityHandler,
|
113 | 112 | boolean enableTrace) {
|
114 |
| - Constraint constraint = new Constraint(); |
115 |
| - constraint.setName("trace-security"); |
| 113 | + |
| 114 | + ServletConstraint servletConstraint; |
116 | 115 | //If enableTrace is true, then we want to set authenticate to false to allow it
|
117 |
| - constraint.setAuthenticate(!enableTrace); |
| 116 | + if(enableTrace) { |
| 117 | + servletConstraint = new ServletConstraint("trace-security", ServletConstraint.ANY_AUTH); |
| 118 | + } else { |
| 119 | + servletConstraint = new ServletConstraint("trace-security", ServletConstraint.ANY_ROLE); |
| 120 | + } |
| 121 | + |
118 | 122 | ConstraintMapping mapping = new ConstraintMapping();
|
119 |
| - mapping.setConstraint(constraint); |
| 123 | + mapping.setConstraint(servletConstraint); |
120 | 124 | mapping.setMethod("TRACE");
|
121 | 125 | mapping.setPathSpec("/");
|
122 | 126 | securityHandler.addConstraintMapping(mapping);
|
|
0 commit comments