if (authentication instanceof CustomUsernamePasswordAuthenticationToken) {
try {
loadedUser = ((CustomJdbcDaoImpl) this.getUserDetailsService())
.loadUserByCaid(authentication.getName());
} catch (DataAccessException repositoryProblem) {
throw new AuthenticationServiceException(repositoryProblem.getMessage(), repositoryProblem);
}
if (loadedUser == null) {
throw new AuthenticationServiceException("AuthenticationDao returned null, which is an interface contract violation");
}
} else {
loadedUser = this.retrieveUser(username, authentication);
}
return loadedUser;