private AuthenticatedUser authenticate(String username, String password) throws AuthenticationException { try { String hash = cache.get(username); if (!checkpw(password, hash)) throw new AuthenticationException(String.format("Provided username %s and/or password are incorrect", username)); return new AuthenticatedUser(username); } catch (ExecutionException | UncheckedExecutionException e) { // the credentials were somehow invalid - either a non-existent role, or one without a defined password if (e.getCause() instanceof NoSuchCredentialsException) throw new AuthenticationException(String.format("Provided username %s and/or password are incorrect", username)); // an unanticipated exception occured whilst querying the credentials table if (e.getCause() instanceof RequestExecutionException) { logger.trace("Error performing internal authentication", e); throw new AuthenticationException(String.format("Error during authentication of user %s : %s", username, e.getMessage())); } throw new RuntimeException(e); } }
private AuthenticatedUser authenticate(String username, String password) throws AuthenticationException { try { String hash = cache.get(username); if (!checkpw(password, hash)) throw new AuthenticationException(String.format("Provided username %s and/or password are incorrect", username)); return new AuthenticatedUser(username); } catch (ExecutionException | UncheckedExecutionException e) { // the credentials were somehow invalid - either a non-existent role, or one without a defined password if (e.getCause() instanceof NoSuchCredentialsException) throw new AuthenticationException(String.format("Provided username %s and/or password are incorrect", username)); // an unanticipated exception occured whilst querying the credentials table if (e.getCause() instanceof RequestExecutionException) { logger.trace("Error performing internal authentication", e); throw new AuthenticationException(String.format("Error during authentication of user %s : %s", username, e.getMessage())); } throw new RuntimeException(e); } }
private AuthenticatedUser authenticate(String username, String password) throws AuthenticationException { try { String hash = cache.get(username); if (!checkpw(password, hash)) throw new AuthenticationException(String.format("Provided username %s and/or password are incorrect", username)); return new AuthenticatedUser(username); } catch (ExecutionException | UncheckedExecutionException e) { // the credentials were somehow invalid - either a non-existent role, or one without a defined password if (e.getCause() instanceof NoSuchCredentialsException) throw new AuthenticationException(String.format("Provided username %s and/or password are incorrect", username)); // an unanticipated exception occured whilst querying the credentials table if (e.getCause() instanceof RequestExecutionException) { logger.trace("Error performing internal authentication", e); throw new AuthenticationException(String.format("Error during authentication of user %s : %s", username, e.getMessage())); } throw new RuntimeException(e); } }