Simon Hunt

Temporary patch around unavailable username during websocket failover.

Change-Id: I38f98816e2e9022d07aad49e1184faa2c2174428
......@@ -23,6 +23,7 @@ import org.onlab.osgi.ServiceDirectory;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import java.security.Principal;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
......@@ -72,7 +73,9 @@ public class UiWebSocketServlet extends WebSocketServlet {
}
// FIXME: Replace this with globally shared opaque token to allow secure failover
String userName = request.getUserPrincipal().getName();
Principal p = request.getUserPrincipal();
String userName = p != null ? p.getName() : FAKE_USERNAME;
UiWebSocket socket = new UiWebSocket(directory, userName);
synchronized (sockets) {
sockets.add(socket);
......@@ -80,6 +83,9 @@ public class UiWebSocketServlet extends WebSocketServlet {
return socket;
}
// FIXME: This should not be necessary
private static final String FAKE_USERNAME = "UI-user";
/**
* Sends the specified message to all the GUI clients.
*
......