throw new AuthenticationException("The requested password check mode '" + pmode_plain + "' is not a valid mode. Possible values are " + mode_values); CharSequence user = credentials.get(USERNAME_KEY); if (null == user) throw new AuthenticationException("Authentication request was missing the required key '" + USERNAME_KEY + "'"); else CharSequence pass = credentials.get(PASSWORD_KEY); if (null == pass) throw new AuthenticationException("Authentication request was missing the required key '" + PASSWORD_KEY + "'"); else throw new AuthenticationException(authenticationErrorMessage(mode, username)); switch (mode) throw new AuthenticationException(authenticationErrorMessage(mode, username));
public AuthenticatedUser getAuthenticatedUser() throws AuthenticationException { if (!complete) throw new AuthenticationException("SASL negotiation not complete"); return authenticate(username, password); }
public AuthenticatedUser getAuthenticatedUser() throws AuthenticationException { if (!complete) throw new AuthenticationException("SASL negotiation not complete"); return authenticate(username, password); }
public AuthenticatedUser getAuthenticatedUser() throws AuthenticationException { if (!complete) throw new AuthenticationException("SASL negotiation not complete"); return authenticate(username, password); }
public AuthenticatedUser legacyAuthenticate(Map<String, String> credentials) throws AuthenticationException { String username = credentials.get(USERNAME_KEY); if (username == null) throw new AuthenticationException(String.format("Required key '%s' is missing", USERNAME_KEY)); String password = credentials.get(PASSWORD_KEY); if (password == null) throw new AuthenticationException(String.format("Required key '%s' is missing for provided username %s", PASSWORD_KEY, username)); return authenticate(username, password); }
public AuthenticatedUser legacyAuthenticate(Map<String, String> credentials) throws AuthenticationException { String username = credentials.get(USERNAME_KEY); if (username == null) throw new AuthenticationException(String.format("Required key '%s' is missing", USERNAME_KEY)); String password = credentials.get(PASSWORD_KEY); if (password == null) throw new AuthenticationException(String.format("Required key '%s' is missing for provided username %s", PASSWORD_KEY, username)); return authenticate(username, password); }
public AuthenticatedUser legacyAuthenticate(Map<String, String> credentials) throws AuthenticationException { String username = credentials.get(USERNAME_KEY); if (username == null) throw new AuthenticationException(String.format("Required key '%s' is missing", USERNAME_KEY)); String password = credentials.get(PASSWORD_KEY); if (password == null) throw new AuthenticationException(String.format("Required key '%s' is missing for provided username %s", PASSWORD_KEY, username)); return authenticate(username, password); }
throw new AuthenticationException("Password must not be null"); if (user == null) throw new AuthenticationException("Authentication ID must not be null");
throw new AuthenticationException("Password must not be null"); if (user == null) throw new AuthenticationException("Authentication ID must not be null");
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); } }
private void authenticate() { if (!StorageService.instance.isAuthSetupComplete()) throw new AuthenticationException("Cannot login as server authentication setup is not yet completed"); IAuthenticator authenticator = DatabaseDescriptor.getAuthenticator(); Map<String, String> credentials = new HashMap<>(); credentials.put(PasswordAuthenticator.USERNAME_KEY, username); credentials.put(PasswordAuthenticator.PASSWORD_KEY, String.valueOf(password)); AuthenticatedUser user = authenticator.legacyAuthenticate(credentials); // Only actual users should be allowed to authenticate for JMX if (user.isAnonymous() || user.isSystem()) throw new AuthenticationException(String.format("Invalid user %s", user.getName())); // The LOGIN privilege is required to authenticate - c.f. ClientState::login if (!DatabaseDescriptor.getRoleManager().canLogin(user.getPrimaryRole())) throw new AuthenticationException(user.getName() + " is not permitted to log in"); }
private void authenticate() { if (!StorageService.instance.isAuthSetupComplete()) throw new AuthenticationException("Cannot login as server authentication setup is not yet completed"); IAuthenticator authenticator = DatabaseDescriptor.getAuthenticator(); Map<String, String> credentials = new HashMap<>(); credentials.put(PasswordAuthenticator.USERNAME_KEY, username); credentials.put(PasswordAuthenticator.PASSWORD_KEY, String.valueOf(password)); AuthenticatedUser user = authenticator.legacyAuthenticate(credentials); // Only actual users should be allowed to authenticate for JMX if (user.isAnonymous() || user.isSystem()) throw new AuthenticationException(String.format("Invalid user %s", user.getName())); // The LOGIN privilege is required to authenticate - c.f. ClientState::login if (!DatabaseDescriptor.getRoleManager().canLogin(user.getPrimaryRole())) throw new AuthenticationException(user.getName() + " is not permitted to log in"); }
private void authenticate() { if (!StorageService.instance.isAuthSetupComplete()) throw new AuthenticationException("Cannot login as server authentication setup is not yet completed"); IAuthenticator authenticator = DatabaseDescriptor.getAuthenticator(); Map<String, String> credentials = new HashMap<>(); credentials.put(PasswordAuthenticator.USERNAME_KEY, username); credentials.put(PasswordAuthenticator.PASSWORD_KEY, String.valueOf(password)); AuthenticatedUser user = authenticator.legacyAuthenticate(credentials); // Only actual users should be allowed to authenticate for JMX if (user.isAnonymous() || user.isSystem()) throw new AuthenticationException(String.format("Invalid user %s", user.getName())); // The LOGIN privilege is required to authenticate - c.f. ClientState::login if (!DatabaseDescriptor.getRoleManager().canLogin(user.getPrimaryRole())) throw new AuthenticationException(user.getName() + " is not permitted to log in"); }
/** * Attempts to login the given user. */ public void login(AuthenticatedUser user) throws AuthenticationException { if (!user.isAnonymous() && !Auth.isExistingUser(user.getName())) throw new AuthenticationException(String.format("User %s doesn't exist - create it with CREATE USER query first", user.getName())); this.user = user; }
/** * Attempts to login the given user. */ public void login(AuthenticatedUser user) throws AuthenticationException { // Login privilege is not inherited via granted roles, so just // verify that the role with the credentials that were actually // supplied has it if (user.isAnonymous() || DatabaseDescriptor.getRoleManager().canLogin(user.getPrimaryRole())) this.user = user; else throw new AuthenticationException(String.format("%s is not permitted to log in", user.getName())); }
/** * Attempts to login the given user. */ public void login(AuthenticatedUser user) throws AuthenticationException { // Login privilege is not inherited via granted roles, so just // verify that the role with the credentials that were actually // supplied has it if (user.isAnonymous() || DatabaseDescriptor.getRoleManager().canLogin(user.getPrimaryRole())) this.user = user; else throw new AuthenticationException(String.format("%s is not permitted to log in", user.getName())); }
public AuthenticatedUser authenticate(Map<String, String> credentials) throws AuthenticationException { String username = credentials.get(USERNAME_KEY); if (username == null) throw new AuthenticationException(String.format("Required key '%s' is missing", USERNAME_KEY)); String password = credentials.get(PASSWORD_KEY); if (password == null) throw new AuthenticationException(String.format("Required key '%s' is missing", PASSWORD_KEY)); UntypedResultSet result; try { ResultMessage.Rows rows = authenticateStatement.execute(QueryState.forInternalCalls(), QueryOptions.forInternalCalls(consistencyForUser(username), Lists.newArrayList(ByteBufferUtil.bytes(username)))); result = UntypedResultSet.create(rows.result); } catch (RequestValidationException e) { throw new AssertionError(e); // not supposed to happen } catch (RequestExecutionException e) { throw new AuthenticationException(e.toString()); } if (result.isEmpty() || !BCrypt.checkpw(password, result.one().getString(SALTED_HASH))) throw new AuthenticationException("Username and/or password are incorrect"); return new AuthenticatedUser(username); }
/** * Attempts to login the given user. */ public void login(AuthenticatedUser user) throws AuthenticationException { // Login privilege is not inherited via granted roles, so just // verify that the role with the credentials that were actually // supplied has it if (user.isAnonymous() || DatabaseDescriptor.getRoleManager().canLogin(user.getPrimaryRole())) this.user = user; else throw new AuthenticationException(String.format("%s is not permitted to log in", user.getName())); }