Scrap the assertions received from a IdP or an AA about a special
        subject.

        :param subject_id: The subjects identifier
        :param entity_id: The identifier of the entity_id of the assertion
        :return:
191780
def reset(self, subject_id, entity_id):
        
        if not self._cache.set(_key(subject_id, entity_id), {}, 0):
            raise CacheError("reset failed")
475587
def get_subject(self):
        
        assert self.assertion.subject
        subject = self.assertion.subject
        subjconf = []

        if not self.verify_attesting_entity(subject.subject_confirmation):
            raise VerificationError("No valid attesting address")

        for subject_confirmation in subject.subject_confirmation:
            _data = subject_confirmation.subject_confirmation_data

            if subject_confirmation.method == SCM_BEARER:
                if not self._bearer_confirmed(_data):
                    continue
            elif subject_confirmation.method == SCM_HOLDER_OF_KEY:
                if not self._holder_of_key_confirmed(_data):
                    continue
            elif subject_confirmation.method == SCM_SENDER_VOUCHES:
                pass
            else:
                raise ValueError("Unknown subject confirmation method: %s" % (
                    subject_confirmation.method,))

            _recip = _data.recipient
            if not _recip or not self.verify_recipient(_recip):
                raise VerificationError("No valid recipient")

            subjconf.append(subject_confirmation)

        if not subjconf:
            raise VerificationError("No valid subject confirmation")

        subject.subject_confirmation = subjconf

        # The subject may contain a name_id

        if subject.name_id:
            self.name_id = subject.name_id
        elif subject.encrypted_id:
            # decrypt encrypted ID
            _name_id_str = self.sec.decrypt(
                subject.encrypted_id.encrypted_data.to_string())
            _name_id = saml.name_id_from_string(_name_id_str)
            self.name_id = _name_id

        logger.info("Subject NameID: %s", self.name_id)
        return self.name_id
311110
def get_authentication_statement(self, subject, ticket):
        
        authentication_statement = etree.Element('AuthenticationStatement')
        authentication_statement.set('AuthenticationInstant',
                                     self.instant(instant=ticket.consumed))
        authentication_statement.set('AuthenticationMethod',
                                     self.authn_method_password)
        authentication_statement.append(subject)
        return authentication_statement
201085
def get_remembered_identity(self, subject_context):
        
        rmm = self.remember_me_manager
        if rmm is not None:
            try:
                return rmm.get_remembered_identifiers(subject_context)
            except Exception as ex:
                msg = ("Delegate RememberMeManager instance of type [" +
                       rmm.__class__.__name__ + "] raised an exception during "
                       "get_remembered_identifiers().")
                logger.warning(msg, exc_info=True)
        return None
1065113
def create_access_token(self, authorization_request, subject_identifier, scope=None):
        # type: (oic.oic.message.AuthorizationRequest, str, Optional[List[str]]) -> se_leg_op.access_token.AccessToken
        
        if not self._is_valid_subject_identifier(subject_identifier):
            raise InvalidSubjectIdentifier('{} unknown'.format(subject_identifier))

        scope = scope or authorization_request['scope']

        return self._create_access_token(subject_identifier, authorization_request.to_dict(), ' '.join(scope))
377222
def merge_identity(self, subject):
        
        current_identifiers = None

        if subject.is_run_as:
            # avoid the other steps of attribute access when referencing by
            # property by referencing the underlying attribute directly:
            current_identifiers = subject._identifiers

        if not current_identifiers:
            # if direct attribute access did not work, use the property-
            # decorated attribute access method:
            current_identifiers = subject.identifiers

        session = subject.get_session(False)

        if not session:
            to_set = []

            if current_identifiers or subject.authenticated:
                session = subject.get_session()

                to_set.append([self.dsc_isk, current_identifiers])
                to_set.append([self.dsc_ask, True])

                msg = ('merge_identity _DID NOT_ find a session for current subject '
                       'and so created a new one (session_id: {0}). Now merging '
                       'internal attributes: {1}'.format(session.session_id, to_set))
                logger.debug(msg)
                session.set_internal_attributes(to_set)
        else:
            self.merge_identity_with_session(current_identifiers, subject, session)
331205
def userinfo_in_id_token_claims(endpoint_context, session, def_itc=None):
    
    if def_itc:
        itc = def_itc
    else:
        itc = {}

    itc.update(id_token_claims(session))

    if not itc:
        return None

    _claims = by_schema(endpoint_context.id_token_schema, **itc)

    if _claims:
        return collect_user_info(endpoint_context, session, _claims)
    else:
        return None
1215715
def _process_for_id(cls, response_raw):
        

        json = response_raw.body_bytes.decode()
        obj = converter.json_to_class(dict, json)
        id_ = converter.deserialize(
            Id,
            cls._unwrap_response_single(obj, cls._FIELD_ID)
        )

        return client.BunqResponse(id_.id_, response_raw.headers)
301363
def dispatch_event(event, subject='id'):
    
    def wrapper(method):
        def inner_wrapper(*args, **kwargs):
            resource = method(*args, **kwargs)
            if isinstance(resource, dict):
                subject_ = resource.get(subject)
                data = resource
            else:
                subject_ = getattr(resource, subject)
                data = resource.__dict__
            event(subject_, data).dispatch()
            return resource
        return inner_wrapper
    return wrapper
1218400
def rdf_find_subject(id)
      return nil unless rdf_valid?
      rdf.each_subject do |s|
        return s if s.to_s =~ Regexp.new(id, Regexp::IGNORECASE)
      end
      nil
    end
19045
def schema_is_registered_for_subject(self, subject, schema):
        
        data = json.dumps({'schema': json.dumps(schema)})
        res = requests.post(self._url('/subjects/{}', subject), data=data, headers=HEADERS)
        if res.status_code == 404:
            return False
        raise_if_failed(res)
        return True
845487
def subject_id(self):
        

        if "subject" in self.message.keys():
            _subj = self.message.subject
            if "base_id" in _subj.keys() and _subj.base_id:
                return _subj.base_id
            elif _subj.name_id:
                return _subj.name_id
        else:
            if "base_id" in self.message.keys() and self.message.base_id:
                return self.message.base_id
            elif self.message.name_id:
                return self.message.name_id
            else:  # EncryptedID
                pass
591111
def remove_commented_topic(self, topic_id):
        
        return [self.remove_comment(topic_id, item['id']) for item in self.list_user_comments(topic_id)]
148710
def _marshal_claims(self, query_claims):
        
        claims = reduce_claims(query_claims)
        # self.data['claimq'] = query_claims
        self.data['claims'] = claims

        entities = set()
        for eid in claims:
            if self.user_labels:
                if eid in self.user_labels or eid == 'P31':
                    entities.add(eid)  # P (property)
                else:
                    continue  # get only wanted entities
            else:
                entities.add(eid)  # P (property)

            for val in claims[eid]:
                if utils.is_text(val) and re.match(r'^Q\d+$', val):
                    entities.add(val)  # Q (item)

        self.data['entities'] = list(entities)
58276
def get_assessment_taken_id(self):
        
        # Implemented from template for osid.learning.Activity.get_objective_id
        if not bool(self._my_map['assessmentTakenId']):
            raise errors.IllegalState('assessment_taken empty')
        return Id(self._my_map['assessmentTakenId'])
680455
def verifyAccount(self, subject, vendorSpecific=None):
        
        response = self.verifyAccountResponse(subject, vendorSpecific)
        return self._read_boolean_response(response)
765054
def individual(self, ind_id=None):
        
        for ind_obj in self.individuals:
            if ind_obj.ind_id == ind_id:
                return ind_obj
        return None