Temporary patch around unavailable username during websocket failover.
Change-Id: I38f98816e2e9022d07aad49e1184faa2c2174428
Showing
1 changed file
with
7 additions
and
1 deletions
... | @@ -23,6 +23,7 @@ import org.onlab.osgi.ServiceDirectory; | ... | @@ -23,6 +23,7 @@ import org.onlab.osgi.ServiceDirectory; |
23 | 23 | ||
24 | import javax.servlet.ServletException; | 24 | import javax.servlet.ServletException; |
25 | import javax.servlet.http.HttpServletRequest; | 25 | import javax.servlet.http.HttpServletRequest; |
26 | +import java.security.Principal; | ||
26 | import java.util.HashSet; | 27 | import java.util.HashSet; |
27 | import java.util.Iterator; | 28 | import java.util.Iterator; |
28 | import java.util.Set; | 29 | import java.util.Set; |
... | @@ -72,7 +73,9 @@ public class UiWebSocketServlet extends WebSocketServlet { | ... | @@ -72,7 +73,9 @@ public class UiWebSocketServlet extends WebSocketServlet { |
72 | } | 73 | } |
73 | 74 | ||
74 | // FIXME: Replace this with globally shared opaque token to allow secure failover | 75 | // FIXME: Replace this with globally shared opaque token to allow secure failover |
75 | - String userName = request.getUserPrincipal().getName(); | 76 | + Principal p = request.getUserPrincipal(); |
77 | + String userName = p != null ? p.getName() : FAKE_USERNAME; | ||
78 | + | ||
76 | UiWebSocket socket = new UiWebSocket(directory, userName); | 79 | UiWebSocket socket = new UiWebSocket(directory, userName); |
77 | synchronized (sockets) { | 80 | synchronized (sockets) { |
78 | sockets.add(socket); | 81 | sockets.add(socket); |
... | @@ -80,6 +83,9 @@ public class UiWebSocketServlet extends WebSocketServlet { | ... | @@ -80,6 +83,9 @@ public class UiWebSocketServlet extends WebSocketServlet { |
80 | return socket; | 83 | return socket; |
81 | } | 84 | } |
82 | 85 | ||
86 | + // FIXME: This should not be necessary | ||
87 | + private static final String FAKE_USERNAME = "UI-user"; | ||
88 | + | ||
83 | /** | 89 | /** |
84 | * Sends the specified message to all the GUI clients. | 90 | * Sends the specified message to all the GUI clients. |
85 | * | 91 | * | ... | ... |
-
Please register or login to post a comment