Question

I would like to support more than one user in my realm.
How can this be done?

Was it helpful?

Solution

The following methods should be override as follows:

    @Override
    protected String getPassword(String username)
    {
        if(username.equals(_firstUser))
            return _firstUserPassword;
        else if(username.equals(_secondUser))
            return _secondUserPassword;
        //etc with your other users
    }

    @Override
    protected Principal getPrincipal(String username)
    {
        if(username.equals(_firstUser))
        {
            return new GenericPrincipal(username, _firstUserPassword, _roles);
        }
        else if(username.equals(_secondUser)
        {
            return new GenericPrincipal(username, _secondUserPassword, _roles);
        }
        //etc with your other users
    }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top