@Test public void responseIsNotSentOnMissingSecurityKey() throws IOException { when(connectorTracker.getSeckey(streamVariable)).thenReturn(null); handler.handleRequest(session, request, response); verifyZeroInteractions(responseOutput); }
@Override public boolean handleRequest(VaadinSession session, VaadinRequest request, VaadinResponse response) throws IOException { if (!ServletPortletHelper.isFileUploadRequest(request)) { return false; } String pathInfo = request.getPathInfo(); int startOfData = pathInfo .indexOf(ServletPortletHelper.UPLOAD_URL_PREFIX) + ServletPortletHelper.UPLOAD_URL_PREFIX.length(); String uppUri = pathInfo.substring(startOfData); String[] parts = uppUri.split("/", 4); String uiId = parts[0]; String connectorId = parts[1]; String variableName = parts[2]; ClientConnector source; StreamVariable streamVariable; session.lock(); try { UI uI = session.getUIById(Integer.parseInt(uiId)); UI.setCurrent(uI); streamVariable = uI.getConnectorTracker().getStreamVariable( connectorId, variableName); String secKey = uI.getConnectorTracker().getSeckey(streamVariable); if (secKey == null || !secKey.equals(parts[3])) { return true; } source = uI.getConnectorTracker().getConnector(connectorId); } finally { session.unlock(); } String contentType = request.getContentType(); if (contentType.contains("boundary")) { doHandleSimpleMultipartFileUpload(session, request, response, streamVariable, variableName, source, contentType.split("boundary=")[1]); } else { doHandleXhrFilePost(session, request, response, streamVariable, variableName, source, getContentLength(request)); } return true; }
FileUploadHandler implements RequestHandler { @Override public boolean handleRequest(VaadinSession session, VaadinRequest request, VaadinResponse response) throws IOException { if (!ServletPortletHelper.isFileUploadRequest(request)) { return false; } String pathInfo = request.getPathInfo(); int startOfData = pathInfo .indexOf(ServletPortletHelper.UPLOAD_URL_PREFIX) + ServletPortletHelper.UPLOAD_URL_PREFIX.length(); String uppUri = pathInfo.substring(startOfData); String[] parts = uppUri.split("/", 4); String uiId = parts[0]; String connectorId = parts[1]; String variableName = parts[2]; ClientConnector source; StreamVariable streamVariable; session.lock(); try { UI uI = session.getUIById(Integer.parseInt(uiId)); UI.setCurrent(uI); streamVariable = uI.getConnectorTracker().getStreamVariable( connectorId, variableName); String secKey = uI.getConnectorTracker().getSeckey(streamVariable); if (secKey == null || !secKey.equals(parts[3])) { return true; } source = uI.getConnectorTracker().getConnector(connectorId); } finally { session.unlock(); } String contentType = request.getContentType(); if (contentType.contains("boundary")) { doHandleSimpleMultipartFileUpload(session, request, response, streamVariable, variableName, source, contentType.split("boundary=")[1]); } else { doHandleXhrFilePost(session, request, response, streamVariable, variableName, source, getContentLength(request)); } return true; } }
FileUploadHandler implements RequestHandler { @Override public boolean handleRequest(VaadinSession session, VaadinRequest request, VaadinResponse response) throws IOException { if (!ServletPortletHelper.isFileUploadRequest(request)) { return false; } String pathInfo = request.getPathInfo(); int startOfData = pathInfo .indexOf(ServletPortletHelper.UPLOAD_URL_PREFIX) + ServletPortletHelper.UPLOAD_URL_PREFIX.length(); String uppUri = pathInfo.substring(startOfData); String[] parts = uppUri.split("/", 4); String uiId = parts[0]; String connectorId = parts[1]; String variableName = parts[2]; ClientConnector source; StreamVariable streamVariable; session.lock(); try { UI uI = session.getUIById(Integer.parseInt(uiId)); UI.setCurrent(uI); streamVariable = uI.getConnectorTracker().getStreamVariable( connectorId, variableName); String secKey = uI.getConnectorTracker().getSeckey(streamVariable); if (secKey == null || !secKey.equals(parts[3])) { return true; } source = uI.getConnectorTracker().getConnector(connectorId); } finally { session.unlock(); } String contentType = request.getContentType(); if (contentType.contains("boundary")) { doHandleSimpleMultipartFileUpload(session, request, response, streamVariable, variableName, source, contentType.split("boundary=")[1]); } else { doHandleXhrFilePost(session, request, response, streamVariable, variableName, source, getContentLength(request)); } return true; }  }
FileUploadHandler implements RequestHandler { @Override public boolean handleRequest(VaadinSession session, VaadinRequest request, VaadinResponse response) throws IOException { if (!ServletPortletHelper.isFileUploadRequest(request)) { return false; } String pathInfo = request.getPathInfo(); int startOfData = pathInfo .indexOf(ServletPortletHelper.UPLOAD_URL_PREFIX) + ServletPortletHelper.UPLOAD_URL_PREFIX.length(); String uppUri = pathInfo.substring(startOfData); String[] parts = uppUri.split("/", 4); String uiId = parts[0]; String connectorId = parts[1]; String variableName = parts[2]; ClientConnector source; StreamVariable streamVariable; session.lock(); try { UI uI = session.getUIById(Integer.parseInt(uiId)); UI.setCurrent(uI); streamVariable = uI.getConnectorTracker().getStreamVariable( connectorId, variableName); String secKey = uI.getConnectorTracker().getSeckey(streamVariable); if (secKey == null || !secKey.equals(parts[3])) { return true; } source = uI.getConnectorTracker().getConnector(connectorId); } finally { session.unlock(); } String contentType = request.getContentType(); if (contentType.contains("boundary")) { doHandleSimpleMultipartFileUpload(session, request, response, streamVariable, variableName, source, contentType.split("boundary=")[1]); } else { doHandleXhrFilePost(session, request, response, streamVariable, variableName, source, getContentLength(request)); } return true; }  @Override boolean handleRequest(VaadinSession session, VaadinRequest request,
            VaadinResponse response); }
FileUploadHandler implements RequestHandler { @Override public boolean handleRequest(VaadinSession session, VaadinRequest request, VaadinResponse response) throws IOException { if (!ServletPortletHelper.isFileUploadRequest(request)) { return false; } String pathInfo = request.getPathInfo(); int startOfData = pathInfo .indexOf(ServletPortletHelper.UPLOAD_URL_PREFIX) + ServletPortletHelper.UPLOAD_URL_PREFIX.length(); String uppUri = pathInfo.substring(startOfData); String[] parts = uppUri.split("/", 4); String uiId = parts[0]; String connectorId = parts[1]; String variableName = parts[2]; ClientConnector source; StreamVariable streamVariable; session.lock(); try { UI uI = session.getUIById(Integer.parseInt(uiId)); UI.setCurrent(uI); streamVariable = uI.getConnectorTracker().getStreamVariable( connectorId, variableName); String secKey = uI.getConnectorTracker().getSeckey(streamVariable); if (secKey == null || !secKey.equals(parts[3])) { return true; } source = uI.getConnectorTracker().getConnector(connectorId); } finally { session.unlock(); } String contentType = request.getContentType(); if (contentType.contains("boundary")) { doHandleSimpleMultipartFileUpload(session, request, response, streamVariable, variableName, source, contentType.split("boundary=")[1]); } else { doHandleXhrFilePost(session, request, response, streamVariable, variableName, source, getContentLength(request)); } return true; }  @Override boolean handleRequest(VaadinSession session, VaadinRequest request,
            VaadinResponse response); static final int DEFAULT_STREAMING_PROGRESS_EVENT_INTERVAL_MS; }