Revert "Bump jetty from 9.3.24 to 9.4.11 to match karaf 4.2.1" This reverts commit 84df4c582f95e37115280ed90fd0191107f5480c.
Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/278f286c Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/278f286c Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/278f286c Branch: refs/heads/master Commit: 278f286cdda4aaa9f6eb7f6d12124260fc023beb Parents: dbe3a50 Author: Paul Campbell <paul.campb...@cloudsoft.io> Authored: Mon Oct 8 13:35:25 2018 +0100 Committer: Paul Campbell <paul.campb...@cloudsoft.io> Committed: Mon Oct 8 13:35:25 2018 +0100 ---------------------------------------------------------------------- .../apache/brooklyn/core/test/HttpService.java | 31 +++++++------------- .../launcher/WebAppContextProvider.java | 5 ++-- pom.xml | 2 +- 3 files changed, 14 insertions(+), 24 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/278f286c/core/src/test/java/org/apache/brooklyn/core/test/HttpService.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/brooklyn/core/test/HttpService.java b/core/src/test/java/org/apache/brooklyn/core/test/HttpService.java index 2cb53e8..b2ff422 100644 --- a/core/src/test/java/org/apache/brooklyn/core/test/HttpService.java +++ b/core/src/test/java/org/apache/brooklyn/core/test/HttpService.java @@ -28,7 +28,10 @@ import java.io.InputStream; import java.net.InetAddress; import java.security.KeyStore; -import org.eclipse.jetty.security.*; +import org.eclipse.jetty.security.ConstraintMapping; +import org.eclipse.jetty.security.ConstraintSecurityHandler; +import org.eclipse.jetty.security.HashLoginService; +import org.eclipse.jetty.security.SecurityHandler; import org.eclipse.jetty.security.authentication.BasicAuthenticator; import org.eclipse.jetty.server.Connector; import org.eclipse.jetty.server.Server; @@ -89,8 +92,11 @@ public class HttpService { * Enables basic HTTP authentication on the server. */ public HttpService basicAuthentication(String username, String password) { - final String userRole = "user"; - Constraint constraint = new Constraint(Constraint.__BASIC_AUTH, userRole); + HashLoginService l = new HashLoginService(); + l.putUser(username, Credential.getCredential(password), new String[]{"user"}); + l.setName("test-realm"); + + Constraint constraint = new Constraint(Constraint.__BASIC_AUTH, "user"); constraint.setAuthenticate(true); ConstraintMapping constraintMapping = new ConstraintMapping(); @@ -99,30 +105,15 @@ public class HttpService { ConstraintSecurityHandler csh = new ConstraintSecurityHandler(); csh.setAuthenticator(new BasicAuthenticator()); - final String realmName = "test-realm"; - csh.setRealmName(realmName); + csh.setRealmName("test-realm"); csh.addConstraintMapping(constraintMapping); - csh.setLoginService(createLoginService(realmName, username, password, new String[]{userRole})); + csh.setLoginService(l); this.securityHandler = Optional.of(csh); return this; } - private LoginService createLoginService( - final String serviceName, final String username, final String password, final String[] roles) { - final HashLoginService loginService = new HashLoginService(); - loginService.setName(serviceName); - loginService.setUserStore(createUserStore(username, password, roles)); - return loginService; - } - - private UserStore createUserStore(final String username, final String password, final String[] roles) { - final UserStore userStore = new UserStore(); - userStore.addUser(username, Credential.getCredential(password), roles); - return userStore; - } - public HttpService start() throws Exception { TestResourceUnavailableException.throwIfResourceUnavailable(getClass(), ROOT_WAR_PATH); http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/278f286c/launcher/src/main/java/org/apache/brooklyn/launcher/WebAppContextProvider.java ---------------------------------------------------------------------- diff --git a/launcher/src/main/java/org/apache/brooklyn/launcher/WebAppContextProvider.java b/launcher/src/main/java/org/apache/brooklyn/launcher/WebAppContextProvider.java index 236bf75..840e541 100644 --- a/launcher/src/main/java/org/apache/brooklyn/launcher/WebAppContextProvider.java +++ b/launcher/src/main/java/org/apache/brooklyn/launcher/WebAppContextProvider.java @@ -31,6 +31,7 @@ import org.apache.brooklyn.util.core.ResourceUtils; import org.apache.brooklyn.util.exceptions.Exceptions; import org.apache.brooklyn.util.os.Os; import org.apache.brooklyn.util.text.Identifiers; +import org.eclipse.jetty.server.SessionManager; import org.eclipse.jetty.webapp.WebAppContext; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -75,9 +76,7 @@ public class WebAppContextProvider { // it might be better to make this brooklyn-only or base on the management-plane ID; // but i think it actually *is* per-server instance, since we don't cache sessions server-side, // so i think this is write. [Alex 2015-09] - final String sessionCookieProperty = "org.eclipse.jetty.servlet.SessionCookie"; - final String cookieValue = "JSESSIONID_BROOKLYN" + Identifiers.makeRandomId(6); - context.setInitParameter(sessionCookieProperty, cookieValue); + context.setInitParameter(SessionManager.__SessionCookieProperty, SessionManager.__DefaultSessionCookie + "_" + "BROOKLYN" + Identifiers.makeRandomId(6)); context.setInitParameter("org.eclipse.jetty.servlet.Default.dirAllowed", "false"); context.setAttribute(BrooklynServiceAttributes.BROOKLYN_MANAGEMENT_CONTEXT, managementContext); for (Map.Entry<String, Object> attributeEntry : attributes.entrySet()) { http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/278f286c/pom.xml ---------------------------------------------------------------------- diff --git a/pom.xml b/pom.xml index 26dfbb9..df69f6f 100644 --- a/pom.xml +++ b/pom.xml @@ -165,7 +165,7 @@ <karaf.version>4.2.1</karaf.version> <karaf.plugin.version>4.1.4</karaf.plugin.version><!-- held back for KARAF-5932 - fixed in 4.2.2 --> <felix.framework.version>5.6.10</felix.framework.version> - <jetty.version>9.4.11.v20180605</jetty.version> + <jetty.version>9.3.24.v20180605</jetty.version> <!-- Transitive dependencies, declared explicitly to avoid version mismatch --> <clojure.version>1.4.0</clojure.version>