class RepositoryUserAccessService implements UserAccessService {

    @Override
    public User removeAccessFromUser(User user) {
        if(userHasActiveAccessInterval(user)) {
            var latestInterval = user.getLatestAccessInterval()
                    .orElseThrow(() -> new IllegalStateException("No interval instance present!"));
            var previousEndTime = latestInterval.getEndTime();
            latestInterval.setEndTime(LocalDateTime.now(clock));
            intervalRepo.save(latestInterval);

            userAccessEventHandler.onAccessRevoked(user, previousEndTime);
        }

        return user;
    }

    @Autowired public  RepositoryUserAccessService(RepositoryUserService userService,
                                       AccessIntervalRepository intervalRepo,
                                       UserAccessEventHandler userAccessEventHandler,
                                       Clock clock);

}