Models core user information retrieved by a {@link UserDetailsService}.
Developers may use this class directly, subclass it, or write their own {@link UserDetails} implementation fromscratch.
{@code equals} and {@code hashcode} implementations are based on the {@code username} property only, as theintention is that lookups of the same user principal object (in a user registry, for example) will match where the objects represent the same user, not just when all the properties (authorities, password for example) are the same.
Note that this implementation is not immutable. It implements the {@code CredentialsContainer} interface, in orderto allow the password to be erased after authentication. This may cause side-effects if you are storing instances in-memory and reusing them. If so, make sure you return a copy from your {@code UserDetailsService} each time it isinvoked.
@author Ben Alex
@author Luke Taylor