I'm using SparkJava and I'm conserned when dealing with Passwords. The idea is to pass the password (in plain text) to the server (under https obviously), then hash and salt server side, and store the salt and hash on the server for the user. However according to this post the plain text password should never be stored as a String in memory for security reasons.
However when accessing the http protocol body from a POST request using SparkJava, the API returns a String, which has the plaintext password.
Route post = (request, response) -> {
String dataWithPassword = request.body();
// ^-- Stays in memory until GC kicks in
}
How should I do to make sure that the plaintext password that was received from a client is not stored as a String serverside, so this might never be a potential security hole? Or is there something else I can do to make sure that the memory is cleared and the plaintext password doesn't linger in memory?