@Test public void testUiExtensionPath() throws Exception { final OtpAuthenticationRequestToken request = new OtpAuthenticationRequestToken(UI_EXTENSION_TOKEN, false, null); final NiFiAuthenticationToken result = (NiFiAuthenticationToken) otpAuthenticationProvider.authenticate(request); final NiFiUserDetails details = (NiFiUserDetails) result.getPrincipal(); assertEquals(UI_EXTENSION_AUTHENTICATED_USER, details.getUsername()); verify(otpService, times(1)).getAuthenticationFromUiExtensionToken(UI_EXTENSION_TOKEN); verify(otpService, never()).getAuthenticationFromDownloadToken(anyString()); }
@Override public Authentication authenticate(Authentication authentication) throws AuthenticationException { final OtpAuthenticationRequestToken request = (OtpAuthenticationRequestToken) authentication; try { final String otpPrincipal; if (request.isDownloadToken()) { otpPrincipal = otpService.getAuthenticationFromDownloadToken(request.getToken()); } else { otpPrincipal = otpService.getAuthenticationFromUiExtensionToken(request.getToken()); } final NiFiUser user = new StandardNiFiUser(mapIdentity(otpPrincipal), request.getClientAddress()); return new NiFiAuthenticationToken(new NiFiUserDetails(user)); } catch (OtpAuthenticationException e) { throw new InvalidAuthenticationException(e.getMessage(), e); } }
OtpAuthenticationProvider extends NiFiAuthenticationProvider { @Override public Authentication authenticate(Authentication authentication) throws AuthenticationException { final OtpAuthenticationRequestToken request = (OtpAuthenticationRequestToken) authentication; try { final String otpPrincipal; if (request.isDownloadToken()) { otpPrincipal = otpService.getAuthenticationFromDownloadToken(request.getToken()); } else { otpPrincipal = otpService.getAuthenticationFromUiExtensionToken(request.getToken()); } final NiFiUser user = new StandardNiFiUser(mapIdentity(otpPrincipal), request.getClientAddress()); return new NiFiAuthenticationToken(new NiFiUserDetails(user)); } catch (OtpAuthenticationException e) { throw new InvalidAuthenticationException(e.getMessage(), e); } } }
OtpAuthenticationProvider extends NiFiAuthenticationProvider { @Override public Authentication authenticate(Authentication authentication) throws AuthenticationException { final OtpAuthenticationRequestToken request = (OtpAuthenticationRequestToken) authentication; try { final String otpPrincipal; if (request.isDownloadToken()) { otpPrincipal = otpService.getAuthenticationFromDownloadToken(request.getToken()); } else { otpPrincipal = otpService.getAuthenticationFromUiExtensionToken(request.getToken()); } final NiFiUser user = new StandardNiFiUser(mapIdentity(otpPrincipal), request.getClientAddress()); return new NiFiAuthenticationToken(new NiFiUserDetails(user)); } catch (OtpAuthenticationException e) { throw new InvalidAuthenticationException(e.getMessage(), e); } } OtpAuthenticationProvider(OtpService otpService, NiFiProperties nifiProperties); }
OtpAuthenticationProvider extends NiFiAuthenticationProvider { @Override public Authentication authenticate(Authentication authentication) throws AuthenticationException { final OtpAuthenticationRequestToken request = (OtpAuthenticationRequestToken) authentication; try { final String otpPrincipal; if (request.isDownloadToken()) { otpPrincipal = otpService.getAuthenticationFromDownloadToken(request.getToken()); } else { otpPrincipal = otpService.getAuthenticationFromUiExtensionToken(request.getToken()); } final NiFiUser user = new StandardNiFiUser(mapIdentity(otpPrincipal), request.getClientAddress()); return new NiFiAuthenticationToken(new NiFiUserDetails(user)); } catch (OtpAuthenticationException e) { throw new InvalidAuthenticationException(e.getMessage(), e); } } OtpAuthenticationProvider(OtpService otpService, NiFiProperties nifiProperties); @Override Authentication authenticate(Authentication authentication); @Override boolean supports(Class<?> authentication); }
OtpAuthenticationProvider extends NiFiAuthenticationProvider { @Override public Authentication authenticate(Authentication authentication) throws AuthenticationException { final OtpAuthenticationRequestToken request = (OtpAuthenticationRequestToken) authentication; try { final String otpPrincipal; if (request.isDownloadToken()) { otpPrincipal = otpService.getAuthenticationFromDownloadToken(request.getToken()); } else { otpPrincipal = otpService.getAuthenticationFromUiExtensionToken(request.getToken()); } final NiFiUser user = new StandardNiFiUser(mapIdentity(otpPrincipal), request.getClientAddress()); return new NiFiAuthenticationToken(new NiFiUserDetails(user)); } catch (OtpAuthenticationException e) { throw new InvalidAuthenticationException(e.getMessage(), e); } } OtpAuthenticationProvider(OtpService otpService, NiFiProperties nifiProperties); @Override Authentication authenticate(Authentication authentication); @Override boolean supports(Class<?> authentication);  }