class UserRepositoryAuthorizator implements Authorizator {

    @Override
    public AuthorizationState canLoginAsOtherUser(Username userId, Username otherUserId) throws MailboxException {
        try {
            if (!repos.isAdministrator(userId)) {
                return AuthorizationState.NOT_ADMIN;
            }
            if (!repos.contains(otherUserId)) {
                return AuthorizationState.UNKNOWN_USER;
            }
            return AuthorizationState.ALLOWED;
        } catch (UsersRepositoryException e) {
            throw new MailboxException("Unable to access usersRepository", e);
        }
    }

    @Inject public  UserRepositoryAuthorizator(UsersRepository repos);

}