class EnvironmentAccessChecker {

    public EnvironmentAccessRights hasAccess(String memberCrn, Optional<String> requestId) {
        requireNonNull(memberCrn, "memberCrn is null");
        requireNonNull(requestId, "requestId is null");

        try {
            List<Boolean> hasRights = grpcUmsClient.hasRights(INTERNAL_ACTOR_CRN, memberCrn, rightChecks, requestId);
            return new EnvironmentAccessRights(hasRights.get(0), hasRights.get(1));
        } catch (StatusRuntimeException e) {
            // NOT_FOUND errors indicate that a user/machineUser has been deleted after we have
            // retrieved the list of users/machineUsers from the UMS. Treat these users as if
            // they do not have the right to access this environment and belong to no groups.
            if (e.getStatus().getCode() == Code.NOT_FOUND) {
                LOGGER.warn("Member CRN {} not found in UMS. Treating as if member has no rights to environment {}: {}",
                        memberCrn, environmentCrn, e.getLocalizedMessage());
                return new EnvironmentAccessRights(false, false);
            } else {
                throw e;
            }

        }
    }

    public  EnvironmentAccessChecker(GrpcUmsClient grpcUmsClient, String environmentCrn, List<RightCheck> rightChecks);

}