Checks a given client against labels/owners whitelists.

def CheckClientLabels(client_id,
                      labels_whitelist=None,
                      labels_owners_whitelist=None,
                      token=None):
  """Checks a given client against labels/owners whitelists."""

  labels_whitelist = labels_whitelist or []
  labels_owners_whitelist = labels_owners_whitelist or []

  if data_store.RelationalDBEnabled():
    labels = data_store.REL_DB.ReadClientLabels(str(client_id))
  else:
    with aff4.FACTORY.Open(
        client_id.ToClientURN(), aff4_type=aff4_grr.VFSGRRClient,
        token=token) as fd:
      labels = fd.GetLabels()

  for label in labels:
    if (label.name in labels_whitelist and
        label.owner in labels_owners_whitelist):
      return

  raise access_control.UnauthorizedAccess(
      "Client %s doesn't have necessary labels." % utils.SmartStr(client_id))