NotebookServer extends WebSocketServlet implements
        NotebookSocketListener, JobListenerFactory, AngularObjectRegistryListener,
        RemoteInterpreterProcessListener { public boolean checkOrigin(HttpServletRequest request, String origin) { try { return SecurityUtils.isValidOrigin(origin, ZeppelinConfiguration.create()); } catch (UnknownHostException e) { LOG.error(e.toString(), e); } catch (URISyntaxException e) { LOG.error(e.toString(), e); } return false; }  @Override void configure(WebSocketServletFactory factory); boolean checkOrigin(HttpServletRequest request, String origin); NotebookSocket doWebSocketConnect(HttpServletRequest req, String protocol); @Override void onOpen(NotebookSocket conn); @Override void onMessage(NotebookSocket conn, String msg); @Override void onClose(NotebookSocket conn, int code, String reason); void unicastNotebookJobInfo(NotebookSocket conn, Message fromMessage); void unicastUpdateNotebookJobInfo(NotebookSocket conn, Message fromMessage); List<Map<String, String>> generateNotebooksInfo(boolean needsReload,
      AuthenticationInfo subject); void broadcastNote(Note note); void broadcastNoteList(AuthenticationInfo subject); void unicastNoteList(NotebookSocket conn, AuthenticationInfo subject); void broadcastReloadedNoteList(AuthenticationInfo subject); @Override void onOutputAppend(String noteId, String paragraphId, String output); @Override void onOutputUpdated(String noteId, String paragraphId, String output); @Override ParagraphJobListener getParagraphJobListener(Note note); @Override void onAdd(String interpreterGroupId, AngularObject object); @Override void onUpdate(String interpreterGroupId, AngularObject object); @Override void onRemove(String interpreterGroupId, String name, String noteId, String paragraphId);  }
@Test public void checkOrigin() throws UnknownHostException { NotebookServer server = new NotebookServer(); String origin = "http: assertTrue("Origin " + origin + " is not allowed. Please check your hostname.", server.checkOrigin(new TestHttpServletRequest(), origin)); }
@Test public void checkInvalidOrigin(){ NotebookServer server = new NotebookServer(); assertFalse(server.checkOrigin(new TestHttpServletRequest(), "http: }