@Override
public User authenticate(Authentication authentication)
throws AuthenticationFailedException {
if (UsernamePasswordAuthentication.class
.isAssignableFrom(authentication.getClass())) {
UsernamePasswordAuthentication upAuth =
(UsernamePasswordAuthentication) authentication;
if (TEST_USERNAME.equals(upAuth.getUsername())
&& TEST_PASSWORD.equals(upAuth.getPassword())) {
return testUser;
}
if (anonUser.getName().equals(upAuth.getUsername())) {
return anonUser;
}
} else if (AnonymousAuthentication.class
.isAssignableFrom(authentication.getClass())) {
return anonUser;