@Test public void testProvenanceInputContentDownload() throws Exception { final HttpServletRequest request = mock(HttpServletRequest.class); when(request.isSecure()).thenReturn(true); when(request.getParameter(OtpAuthenticationFilter.ACCESS_TOKEN)).thenReturn(DOWNLOAD_TOKEN); when(request.getContextPath()).thenReturn("/nifi-api"); when(request.getPathInfo()).thenReturn("/provenance-events/0/content/input"); final OtpAuthenticationRequestToken result = (OtpAuthenticationRequestToken) otpAuthenticationFilter.attemptAuthentication(request); assertEquals(DOWNLOAD_TOKEN, result.getToken()); assertTrue(result.isDownloadToken()); }
@Override public Authentication attemptAuthentication(final HttpServletRequest request) { if (!request.isSecure()) { return null; } final String accessToken = request.getParameter(ACCESS_TOKEN); if (accessToken == null) { return null; } else { if (request.getContextPath().equals("/nifi-api")) { if (isDownloadRequest(request.getPathInfo())) { return new OtpAuthenticationRequestToken(accessToken, true, request.getRemoteAddr()); } } else { return new OtpAuthenticationRequestToken(accessToken, false, request.getRemoteAddr()); } return null; } }
OtpAuthenticationFilter extends NiFiAuthenticationFilter { @Override public Authentication attemptAuthentication(final HttpServletRequest request) { if (!request.isSecure()) { return null; } final String accessToken = request.getParameter(ACCESS_TOKEN); if (accessToken == null) { return null; } else { if (request.getContextPath().equals("/nifi-api")) { if (isDownloadRequest(request.getPathInfo())) { return new OtpAuthenticationRequestToken(accessToken, true, request.getRemoteAddr()); } } else { return new OtpAuthenticationRequestToken(accessToken, false, request.getRemoteAddr()); } return null; } } }
OtpAuthenticationFilter extends NiFiAuthenticationFilter { @Override public Authentication attemptAuthentication(final HttpServletRequest request) { if (!request.isSecure()) { return null; } final String accessToken = request.getParameter(ACCESS_TOKEN); if (accessToken == null) { return null; } else { if (request.getContextPath().equals("/nifi-api")) { if (isDownloadRequest(request.getPathInfo())) { return new OtpAuthenticationRequestToken(accessToken, true, request.getRemoteAddr()); } } else { return new OtpAuthenticationRequestToken(accessToken, false, request.getRemoteAddr()); } return null; } }  }
OtpAuthenticationFilter extends NiFiAuthenticationFilter { @Override public Authentication attemptAuthentication(final HttpServletRequest request) { if (!request.isSecure()) { return null; } final String accessToken = request.getParameter(ACCESS_TOKEN); if (accessToken == null) { return null; } else { if (request.getContextPath().equals("/nifi-api")) { if (isDownloadRequest(request.getPathInfo())) { return new OtpAuthenticationRequestToken(accessToken, true, request.getRemoteAddr()); } } else { return new OtpAuthenticationRequestToken(accessToken, false, request.getRemoteAddr()); } return null; } }  @Override Authentication attemptAuthentication(final HttpServletRequest request); }
OtpAuthenticationFilter extends NiFiAuthenticationFilter { @Override public Authentication attemptAuthentication(final HttpServletRequest request) { if (!request.isSecure()) { return null; } final String accessToken = request.getParameter(ACCESS_TOKEN); if (accessToken == null) { return null; } else { if (request.getContextPath().equals("/nifi-api")) { if (isDownloadRequest(request.getPathInfo())) { return new OtpAuthenticationRequestToken(accessToken, true, request.getRemoteAddr()); } } else { return new OtpAuthenticationRequestToken(accessToken, false, request.getRemoteAddr()); } return null; } }  @Override Authentication attemptAuthentication(final HttpServletRequest request);  }