@Test(expected = BadCredentialsException.class) public void shouldThrowWithInvalidUsernamePassword() { when(gatewaySecurityService.login(USER, INVALID_PASSWORD)).thenReturn(Optional.empty()); Authentication auth = new UsernamePasswordAuthenticationToken(USER, INVALID_PASSWORD); gatewayLoginProvider.authenticate(auth); }
@Override public Authentication authenticate(Authentication authentication) { String username = authentication.getPrincipal().toString(); Optional<String> token = gatewaySecurityService.login(username, authentication.getCredentials().toString()); if (!token.isPresent()) { throw new BadCredentialsException("Username or password are invalid."); } TokenAuthentication tokenAuthentication = new TokenAuthentication(username, token.get()); tokenAuthentication.setAuthenticated(true); return tokenAuthentication; }
GatewayLoginProvider implements AuthenticationProvider { @Override public Authentication authenticate(Authentication authentication) { String username = authentication.getPrincipal().toString(); Optional<String> token = gatewaySecurityService.login(username, authentication.getCredentials().toString()); if (!token.isPresent()) { throw new BadCredentialsException("Username or password are invalid."); } TokenAuthentication tokenAuthentication = new TokenAuthentication(username, token.get()); tokenAuthentication.setAuthenticated(true); return tokenAuthentication; } }
GatewayLoginProvider implements AuthenticationProvider { @Override public Authentication authenticate(Authentication authentication) { String username = authentication.getPrincipal().toString(); Optional<String> token = gatewaySecurityService.login(username, authentication.getCredentials().toString()); if (!token.isPresent()) { throw new BadCredentialsException("Username or password are invalid."); } TokenAuthentication tokenAuthentication = new TokenAuthentication(username, token.get()); tokenAuthentication.setAuthenticated(true); return tokenAuthentication; }  }
GatewayLoginProvider implements AuthenticationProvider { @Override public Authentication authenticate(Authentication authentication) { String username = authentication.getPrincipal().toString(); Optional<String> token = gatewaySecurityService.login(username, authentication.getCredentials().toString()); if (!token.isPresent()) { throw new BadCredentialsException("Username or password are invalid."); } TokenAuthentication tokenAuthentication = new TokenAuthentication(username, token.get()); tokenAuthentication.setAuthenticated(true); return tokenAuthentication; }  @Override Authentication authenticate(Authentication authentication); @Override boolean supports(Class<?> auth); }
GatewayLoginProvider implements AuthenticationProvider { @Override public Authentication authenticate(Authentication authentication) { String username = authentication.getPrincipal().toString(); Optional<String> token = gatewaySecurityService.login(username, authentication.getCredentials().toString()); if (!token.isPresent()) { throw new BadCredentialsException("Username or password are invalid."); } TokenAuthentication tokenAuthentication = new TokenAuthentication(username, token.get()); tokenAuthentication.setAuthenticated(true); return tokenAuthentication; }  @Override Authentication authenticate(Authentication authentication); @Override boolean supports(Class<?> auth);  }