diff --git a/examples/embedded/pom.xml b/examples/embedded/pom.xml index ae55acd9ff5..fb2eed394d5 100644 --- a/examples/embedded/pom.xml +++ b/examples/embedded/pom.xml @@ -155,6 +155,18 @@ + + + + org.apache.maven.plugins + maven-surefire-plugin + + false + + + + + jdk9 diff --git a/examples/embedded/src/main/java/org/eclipse/jetty/embedded/OneWebAppWithJsp.java b/examples/embedded/src/main/java/org/eclipse/jetty/embedded/OneWebAppWithJsp.java index 3e3d5bd9132..87175b015a8 100644 --- a/examples/embedded/src/main/java/org/eclipse/jetty/embedded/OneWebAppWithJsp.java +++ b/examples/embedded/src/main/java/org/eclipse/jetty/embedded/OneWebAppWithJsp.java @@ -89,9 +89,11 @@ public class OneWebAppWithJsp // its own we register it as a bean with the Jetty server object so it // can be started and stopped according to the lifecycle of the server // itself. - URL realmProps = OneWebAppWithJsp.class.getClassLoader().getResource("realm.properties"); + String realmResourceName = "etc/realm.properties"; + ClassLoader classLoader = OneWebAppWithJsp.class.getClassLoader(); + URL realmProps = classLoader.getResource(realmResourceName); if (realmProps == null) - throw new FileNotFoundException("Unable to find realm.properties"); + throw new FileNotFoundException("Unable to find " + realmResourceName); HashLoginService loginService = new HashLoginService(); loginService.setName("Test Realm"); diff --git a/examples/embedded/src/main/java/org/eclipse/jetty/embedded/SecuredHelloHandler.java b/examples/embedded/src/main/java/org/eclipse/jetty/embedded/SecuredHelloHandler.java index 50e53c3c700..1f339b33fa2 100644 --- a/examples/embedded/src/main/java/org/eclipse/jetty/embedded/SecuredHelloHandler.java +++ b/examples/embedded/src/main/java/org/eclipse/jetty/embedded/SecuredHelloHandler.java @@ -48,10 +48,11 @@ public class SecuredHelloHandler // started and stopped according to the lifecycle of the server itself. // In this example the name can be whatever you like since we are not // dealing with webapp realms. + String realmResourceName = "etc/realm.properties"; ClassLoader classLoader = SecuredHelloHandler.class.getClassLoader(); - URL realmProps = classLoader.getResource("realm.properties"); + URL realmProps = classLoader.getResource(realmResourceName); if (realmProps == null) - throw new FileNotFoundException("Unable to find realm.properties"); + throw new FileNotFoundException("Unable to find " + realmResourceName); LoginService loginService = new HashLoginService("MyRealm", realmProps.toExternalForm()); diff --git a/examples/embedded/src/main/java/org/eclipse/jetty/embedded/ServerWithAnnotations.java b/examples/embedded/src/main/java/org/eclipse/jetty/embedded/ServerWithAnnotations.java index 3c8d2a96c7a..e7a71deecf0 100644 --- a/examples/embedded/src/main/java/org/eclipse/jetty/embedded/ServerWithAnnotations.java +++ b/examples/embedded/src/main/java/org/eclipse/jetty/embedded/ServerWithAnnotations.java @@ -76,10 +76,11 @@ public class ServerWithAnnotations server.addBean(new NamingDump()); // Configure a LoginService + String realmResourceName = "etc/realm.properties"; ClassLoader classLoader = ServerWithAnnotations.class.getClassLoader(); - URL realmProps = classLoader.getResource("realm.properties"); + URL realmProps = classLoader.getResource(realmResourceName); if (realmProps == null) - throw new FileNotFoundException("Unable to find realm.properties"); + throw new FileNotFoundException("Unable to find " + realmResourceName); HashLoginService loginService = new HashLoginService(); loginService.setName("Test Realm"); diff --git a/examples/embedded/src/main/java/org/eclipse/jetty/embedded/WebSocketJsrServer.java b/examples/embedded/src/main/java/org/eclipse/jetty/embedded/WebSocketJsrServer.java index 8d901dcb5c8..1f67d7852ae 100644 --- a/examples/embedded/src/main/java/org/eclipse/jetty/embedded/WebSocketJsrServer.java +++ b/examples/embedded/src/main/java/org/eclipse/jetty/embedded/WebSocketJsrServer.java @@ -18,8 +18,6 @@ package org.eclipse.jetty.embedded; -import javax.servlet.ServletException; -import javax.websocket.DeploymentException; import javax.websocket.OnMessage; import javax.websocket.Session; import javax.websocket.server.ServerEndpoint; @@ -28,7 +26,6 @@ import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.handler.DefaultHandler; import org.eclipse.jetty.server.handler.HandlerList; import org.eclipse.jetty.servlet.ServletContextHandler; -import org.eclipse.jetty.websocket.jsr356.server.ServerContainer; import org.eclipse.jetty.websocket.jsr356.server.deploy.WebSocketServerContainerInitializer; /** @@ -49,23 +46,24 @@ public class WebSocketJsrServer } } - public static Server createServer(int port) throws DeploymentException, ServletException + public static Server createServer(int port) { Server server = new Server(port); HandlerList handlers = new HandlerList(); - ServletContextHandler context = new ServletContextHandler( - ServletContextHandler.SESSIONS); + ServletContextHandler context = new ServletContextHandler(); context.setContextPath("/"); handlers.addHandler(context); // Enable javax.websocket configuration for the context - ServerContainer wsContainer = WebSocketServerContainerInitializer - .configureContext(context); - - // Add your websockets to the container - wsContainer.addEndpoint(EchoJsrSocket.class); + WebSocketServerContainerInitializer.configure(context, + (servletContext, serverContainer) -> + { + // Add your websocket to the javax.websocket.server.ServerContainer + serverContainer.addEndpoint(EchoJsrSocket.class); + } + ); handlers.addHandler(new DefaultHandler()); diff --git a/examples/embedded/src/main/resources/etc/realm.properties b/examples/embedded/src/main/resources/etc/realm.properties new file mode 100644 index 00000000000..f4b3490e910 --- /dev/null +++ b/examples/embedded/src/main/resources/etc/realm.properties @@ -0,0 +1,20 @@ +# +# This file defines users passwords and roles for a HashUserRealm +# +# The format is +# : [, ...] +# +# Passwords may be clear text, obfuscated or checksummed. The class +# org.eclipse.jetty.util.security.Password should be used to generate obfuscated +# passwords or password checksums +# +# If DIGEST Authentication is used, the password must be in a recoverable +# format, either plain text or OBF:. +# +jetty:MD5:164c88b302622e17050af52c89945d44,user +admin:CRYPT:adpexzg3FUZAk,server-administrator,content-administrator,admin,user +other:OBF:1xmk1w261u9r1w1c1xmq,user +plain:plain,user +user:password,user +# This entry is for digest auth. The credential is a MD5 hash of username:realmname:password +digest:MD5:6e120743ad67abfbc385bc2bb754e297,user