'Validate and normalize scope data.'

def _validate_and_normalize_scope_data(self):

    if ('scope' not in self.auth):
        return
    if (sum([('project' in self.auth['scope']), ('domain' in self.auth['scope']), ('unscoped' in self.auth['scope']), ('OS-TRUST:trust' in self.auth['scope'])]) != 1):
        raise exception.ValidationError(attribute='project,    domain,    OS-TRUST:trust    or    unscoped', target='scope')
    if ('unscoped' in self.auth['scope']):
        self._scope_data = (None, None, None, 'unscoped')
        return
    if ('project' in self.auth['scope']):
        project_ref = self._lookup_project(self.auth['scope']['project'])
        self._scope_data = (None, project_ref['id'], None, None)
    elif ('domain' in self.auth['scope']):
        domain_ref = self._lookup_domain(self.auth['scope']['domain'])
        self._scope_data = (domain_ref['id'], None, None, None)
    elif ('OS-TRUST:trust' in self.auth['scope']):
        if (not CONF.trust.enabled):
            raise exception.Forbidden('Trusts    are    disabled.')
        trust_ref = self._lookup_trust(self.auth['scope']['OS-TRUST:trust'])
        if (trust_ref.get('project_id') is not None):
            project_ref = self._lookup_project({'id': trust_ref['project_id']})
            self._scope_data = (None, project_ref['id'], trust_ref, None)
        else:
            self._scope_data = (None, None, trust_ref, None)
