package com.github.noxan.aves.auth.storage;

import java.util.HashMap;
import java.util.Map;

import com.github.noxan.aves.auth.accessor.UsernamePasswordAccessor;

public class InMemoryUsernamePasswordStorage {
    private Map<String, String> users;

    public InMemoryUsernamePasswordStorage() {
        users = new HashMap<String, String>();
    }

    public void addUser(String username, String password) {
        users.put(username, password);
    }

    public String requestUser(UsernamePasswordAccessor accessor) {
        if (accessor.checkPassword(users.get(accessor.getUsername()))) {
            return accessor.getUsername();
        }
        return null;
    }
}

@@ -87,16 +87,65 @@
 l.Map;%0A%0A
+import com.github.noxan.aves.auth.AuthException;%0A
 import c
@@ -564,16 +564,37 @@
 ccessor)
+ throws AuthException
  %7B%0A     
@@ -726,19 +726,72 @@
     
-return null
+throw new AuthException(%22Invalid password or unknown username.%22)
 ;%0A  

throw authexception instead of returning null in request user in storage