Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--jetty-client/src/test/java/org/eclipse/jetty/client/WebSocketUpgradeTest.java1
-rw-r--r--jetty-security/src/main/java/org/eclipse/jetty/security/SecurityHandler.java4
-rw-r--r--jetty-server/src/main/java/org/eclipse/jetty/server/session/HashSessionManager.java24
-rw-r--r--jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnectionD00.java2
-rw-r--r--jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketFactory.java35
-rw-r--r--jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketServlet.java7
-rw-r--r--jetty-websocket/src/test/java/org/eclipse/jetty/websocket/SafariWebsocketDraft0Test.java4
-rw-r--r--jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketLoadD08Test.java3
-rw-r--r--jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketLoadRFC6455Test.java2
-rw-r--r--jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketMessageD00Test.java1
-rw-r--r--jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketMessageD06Test.java1
-rw-r--r--jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketMessageD08Test.java1
-rw-r--r--jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketServletRFCTest.java2
13 files changed, 73 insertions, 14 deletions
diff --git a/jetty-client/src/test/java/org/eclipse/jetty/client/WebSocketUpgradeTest.java b/jetty-client/src/test/java/org/eclipse/jetty/client/WebSocketUpgradeTest.java
index 7947a0beab..108c77a230 100644
--- a/jetty-client/src/test/java/org/eclipse/jetty/client/WebSocketUpgradeTest.java
+++ b/jetty-client/src/test/java/org/eclipse/jetty/client/WebSocketUpgradeTest.java
@@ -214,6 +214,7 @@ public class WebSocketUpgradeTest
return _websocket;
}
};
+ _handler.getWebSocketFactory().setMinVersion(-1);
_server.setHandler(_handler);
_server.start();
diff --git a/jetty-security/src/main/java/org/eclipse/jetty/security/SecurityHandler.java b/jetty-security/src/main/java/org/eclipse/jetty/security/SecurityHandler.java
index 95bcbde894..4f37469028 100644
--- a/jetty-security/src/main/java/org/eclipse/jetty/security/SecurityHandler.java
+++ b/jetty-security/src/main/java/org/eclipse/jetty/security/SecurityHandler.java
@@ -335,18 +335,22 @@ public abstract class SecurityHandler extends HandlerWrapper implements Authenti
if (_identityService==null)
{
+
if (_loginService!=null)
_identityService=_loginService.getIdentityService();
+ System.err.println("Null identity service, trying login service: "+_identityService);
if (_identityService==null)
_identityService=findIdentityService();
+ System.err.println("Finding identity service: "+_identityService);
if (_identityService==null && _realmName!=null)
_identityService=new DefaultIdentityService();
}
if (_loginService!=null)
{
+ System.err.println("LoginService="+_loginService + " identityService="+_identityService);
if (_loginService.getIdentityService()==null)
_loginService.setIdentityService(_identityService);
else if (_loginService.getIdentityService()!=_identityService)
diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/session/HashSessionManager.java b/jetty-server/src/main/java/org/eclipse/jetty/server/session/HashSessionManager.java
index 19ee760a51..f6e380a43a 100644
--- a/jetty-server/src/main/java/org/eclipse/jetty/server/session/HashSessionManager.java
+++ b/jetty-server/src/main/java/org/eclipse/jetty/server/session/HashSessionManager.java
@@ -483,32 +483,40 @@ public class HashSessionManager extends AbstractSessionManager
protected synchronized HashedSession restoreSession(String idInCuster)
{
File file = new File(_storeDir,idInCuster);
+ FileInputStream in = null;
+ Exception error = null;
try
{
if (file.exists())
{
- FileInputStream in = new FileInputStream(file);
+ in = new FileInputStream(file);
HashedSession session = restoreSession(in, null);
- in.close();
addSession(session, false);
session.didActivate();
- file.delete();
return session;
}
}
catch (Exception e)
{
-
- if (isDeleteUnrestorableSessions())
+ error = e;
+ }
+ finally
+ {
+ if (in != null)
+ try {in.close();} catch (Exception x) {__log.ignore(x);}
+
+ if (error != null)
{
- if (file.exists())
+ if (isDeleteUnrestorableSessions() && file.exists())
{
file.delete();
- __log.warn("Deleting file for unrestorable session "+idInCuster, e);
+ __log.warn("Deleting file for unrestorable session "+idInCuster, error);
}
+ else
+ __log.warn("Problem restoring session "+idInCuster, error);
}
else
- __log.warn("Problem restoring session "+idInCuster, e);
+ file.delete(); //delete successfully restored file
}
return null;
diff --git a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnectionD00.java b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnectionD00.java
index dd1ba46b8e..a4e10bd32a 100644
--- a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnectionD00.java
+++ b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnectionD00.java
@@ -123,6 +123,8 @@ public class WebSocketConnectionD00 extends AbstractConnection implements WebSoc
_endp.close();
break;
}
+ else if (filled==0)
+ return this;
}
if (_websocket instanceof OnFrame)
diff --git a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketFactory.java b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketFactory.java
index eca24b73e8..ae01166ed9 100644
--- a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketFactory.java
+++ b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketFactory.java
@@ -81,16 +81,37 @@ public class WebSocketFactory extends AbstractLifeCycle
private int _maxIdleTime = 300000;
private int _maxTextMessageSize = 16 * 1024;
private int _maxBinaryMessageSize = -1;
+ private int _minVersion;
public WebSocketFactory(Acceptor acceptor)
{
- this(acceptor, 64 * 1024);
+ this(acceptor, 64 * 1024, WebSocketConnectionRFC6455.VERSION);
}
public WebSocketFactory(Acceptor acceptor, int bufferSize)
{
+ this(acceptor, bufferSize, WebSocketConnectionRFC6455.VERSION);
+ }
+
+ public WebSocketFactory(Acceptor acceptor, int bufferSize, int minVersion)
+ {
_buffers = new WebSocketBuffers(bufferSize);
_acceptor = acceptor;
+ _minVersion=WebSocketConnectionRFC6455.VERSION;
+ }
+
+ public int getMinVersion()
+ {
+ return _minVersion;
+ }
+
+ /* ------------------------------------------------------------ */
+ /**
+ * @param minVersion The minimum support version (default RCF6455.VERSION == 13 )
+ */
+ public void setMinVersion(int minVersion)
+ {
+ _minVersion = minVersion;
}
/**
@@ -227,6 +248,8 @@ public class WebSocketFactory extends AbstractLifeCycle
}
final WebSocketServletConnection connection;
+ if (draft<_minVersion)
+ draft=Integer.MAX_VALUE;
switch (draft)
{
case -1: // unspecified draft/version
@@ -263,7 +286,15 @@ public class WebSocketFactory extends AbstractLifeCycle
LOG.warn("Unsupported Websocket version: " + draft);
// Per RFC 6455 - 4.4 - Supporting Multiple Versions of WebSocket Protocol
// Using the examples as outlined
- response.setHeader("Sec-WebSocket-Version", "13, 8, 6, 0");
+ String versions="13";
+ if (_minVersion<=8)
+ versions+=", 8";
+ if (_minVersion<=6)
+ versions+=", 6";
+ if (_minVersion<=0)
+ versions+=", 0";
+
+ response.setHeader("Sec-WebSocket-Version", versions);
throw new HttpException(400, "Unsupported websocket version specification: " + draft);
}
}
diff --git a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketServlet.java b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketServlet.java
index 3990ce4ddf..d52c801900 100644
--- a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketServlet.java
+++ b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketServlet.java
@@ -45,6 +45,9 @@ import org.eclipse.jetty.util.log.Logger;
* <p/>
* The initParameter "maxBinaryMessagesSize" can be used to set the size in bytes
* that a websocket may be accept before closing.
+ * <p/>
+ * The initParameter "minVersion" can be used to set the minimum protocol version
+ * accepted. Default is the RFC6455 version (13)
*/
@SuppressWarnings("serial")
public abstract class WebSocketServlet extends HttpServlet implements WebSocketFactory.Acceptor
@@ -76,6 +79,10 @@ public abstract class WebSocketServlet extends HttpServlet implements WebSocketF
max = getInitParameter("maxBinaryMessageSize");
if (max != null)
_webSocketFactory.setMaxBinaryMessageSize(Integer.parseInt(max));
+
+ String min = getInitParameter("minVersion");
+ if (min != null)
+ _webSocketFactory.setMinVersion(Integer.parseInt(min));
}
catch (ServletException x)
{
diff --git a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/SafariWebsocketDraft0Test.java b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/SafariWebsocketDraft0Test.java
index 5e59f32dcb..6706350149 100644
--- a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/SafariWebsocketDraft0Test.java
+++ b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/SafariWebsocketDraft0Test.java
@@ -62,7 +62,9 @@ public class SafariWebsocketDraft0Test
// Serve capture servlet
servlet = new WebSocketCaptureServlet();
- context.addServlet(new ServletHolder(servlet),"/");
+ ServletHolder holder = new ServletHolder(servlet);
+ holder.setInitParameter("minVersion","-1");
+ context.addServlet(holder,"/");
// Start Server
server.start();
diff --git a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketLoadD08Test.java b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketLoadD08Test.java
index d61b1ec666..62500c4548 100644
--- a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketLoadD08Test.java
+++ b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketLoadD08Test.java
@@ -72,6 +72,7 @@ public class WebSocketLoadD08Test
return new EchoWebSocket();
}
};
+ wsHandler.getWebSocketFactory().setMinVersion(8);
wsHandler.setHandler(new DefaultHandler());
_server.setHandler(wsHandler);
@@ -196,7 +197,7 @@ public class WebSocketLoadD08Test
"Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==\r\n"+
"Sec-WebSocket-Origin: http://example.com\r\n"+
"Sec-WebSocket-Protocol: onConnect\r\n" +
- "Sec-WebSocket-Version: 7\r\n"+
+ "Sec-WebSocket-Version: 8\r\n"+
"\r\n");
output.flush();
diff --git a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketLoadRFC6455Test.java b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketLoadRFC6455Test.java
index d119a13db0..514ce75412 100644
--- a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketLoadRFC6455Test.java
+++ b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketLoadRFC6455Test.java
@@ -194,7 +194,7 @@ public class WebSocketLoadRFC6455Test
"Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==\r\n"+
"Sec-WebSocket-Origin: http://example.com\r\n"+
"Sec-WebSocket-Protocol: onConnect\r\n" +
- "Sec-WebSocket-Version: 7\r\n"+
+ "Sec-WebSocket-Version: 13\r\n"+
"\r\n");
output.flush();
diff --git a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketMessageD00Test.java b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketMessageD00Test.java
index f3ab2e71c6..1042978974 100644
--- a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketMessageD00Test.java
+++ b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketMessageD00Test.java
@@ -80,6 +80,7 @@ public class WebSocketMessageD00Test
return __serverWebSocket;
}
};
+ wsHandler.getWebSocketFactory().setMinVersion(-1);
wsHandler.setHandler(new DefaultHandler());
__server.setHandler(wsHandler);
__server.start();
diff --git a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketMessageD06Test.java b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketMessageD06Test.java
index 45f7791f72..2ce05d1c92 100644
--- a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketMessageD06Test.java
+++ b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketMessageD06Test.java
@@ -66,6 +66,7 @@ public class WebSocketMessageD06Test
return _serverWebSocket;
}
};
+ wsHandler.getWebSocketFactory().setMinVersion(6);
wsHandler.getWebSocketFactory().setBufferSize(8192);
wsHandler.getWebSocketFactory().setMaxIdleTime(1000);
wsHandler.setHandler(new DefaultHandler());
diff --git a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketMessageD08Test.java b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketMessageD08Test.java
index e43e30deb2..971f26f479 100644
--- a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketMessageD08Test.java
+++ b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketMessageD08Test.java
@@ -77,6 +77,7 @@ public class WebSocketMessageD08Test
return __serverWebSocket;
}
};
+ wsHandler.getWebSocketFactory().setMinVersion(8);
wsHandler.getWebSocketFactory().setBufferSize(8192);
wsHandler.getWebSocketFactory().setMaxIdleTime(1000);
wsHandler.setHandler(new DefaultHandler());
diff --git a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketServletRFCTest.java b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketServletRFCTest.java
index 8296b1a9b2..f03aba618b 100644
--- a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketServletRFCTest.java
+++ b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketServletRFCTest.java
@@ -180,7 +180,7 @@ public class WebSocketServletRFCTest
// System.out.println("RESPONSE: " + respHeader);
Assert.assertThat("Response Code",respHeader,startsWith("HTTP/1.1 400 Unsupported websocket version specification"));
- Assert.assertThat("Response Header Versions",respHeader,containsString("Sec-WebSocket-Version: 13, 8, 6, 0\r\n"));
+ Assert.assertThat("Response Header Versions",respHeader,containsString("Sec-WebSocket-Version: 13\r\n"));
}
finally
{

Back to the top