class CustomUserService extends DefaultUserService {

    @Override
    public User getAuthenticatedUser() {
        Authentication authentication = SecurityContextHolder.getContext().getAuthentication();

        if (authentication != null && authentication.getPrincipal() instanceof User) {
            return (User) authentication.getPrincipal();
        } else {
            throw new SecurityException("Could not get the authenticated user!");
        }
    }

    @Autowired public  CustomUserService(UserRepository userRepository,
                             PageRepository pageRepository,
                             WidgetRepository widgetRepository,
                             PageTemplateRepository pageTemplateRepository,
                             CategoryRepository categoryRepository,
                             PersonRepository personRepository);

}