当前位置: 首页>>代码示例>>Python>>正文


Python ident.code函数代码示例

本文整理汇总了Python中saml2.ident.code函数的典型用法代码示例。如果您正苦于以下问题:Python code函数的具体用法?Python code怎么用?Python code使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了code函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: set

    def set(self, name_id, entity_id, info, not_on_or_after=0):
        """ Stores session information in the cache. Assumes that the name_id
        is unique within the context of the Service Provider.

        :param name_id: The subject identifier, a NameID instance
        :param entity_id: The identifier of the entity_id/receiver of an
            assertion
        :param info: The session info, the assertion is part of this
        :param not_on_or_after: A time after which the assertion is not valid.
        """
        info = dict(info)
        if 'name_id' in info and not isinstance(info['name_id'], six.string_types):
            # make friendly to (JSON) serialization
            info['name_id'] = code(name_id)

        cni = code(name_id)
        if cni not in self._db:
            self._db[cni] = {}

        self._db[cni][entity_id] = (not_on_or_after, info)
        if self._sync:
            try:
                self._db.sync()
            except AttributeError:
                pass
开发者ID:SUNET,项目名称:pysaml2,代码行数:25,代码来源:cache.py

示例2: store_assertion

 def store_assertion(self, assertion, to_sign):
     self.assertion[assertion.id] = (assertion, to_sign)
     key = sha1(code(assertion.subject.name_id)).hexdigest()
     try:
         self.authn[key].append(assertion.authn_statement)
     except KeyError:
         self.authn[key] = [assertion.authn_statement]
开发者ID:Haufe-Lexware,项目名称:hl.pas.samlplugin,代码行数:7,代码来源:sdb.py

示例3: get_authn_statements

    def get_authn_statements(self, name_id=None, key="", session_index=None,
                             requested_context=None):
        """

        :param name_id: One of name_id or key can be used to get the authn
            statement
        :param key:
        :param session_index:
        :param requested_context:
        :return:
        """
        result = []
        key = sha1(code(name_id)).hexdigest()
        try:
            statements = [from_dict(t, ONTS, True) for t in self.authn[key]]
        except KeyError:
            logger.info("Unknown subject %s" % name_id)
            return []

        for statement in statements:
            if session_index:
                if statement.session_index != session_index:
                    continue
            if requested_context:
                if not context_match(requested_context,
                                     statement.authn_context):
                    continue
            result.append(statement)

        return result
开发者ID:caustin,项目名称:pysaml2,代码行数:30,代码来源:sdb.py

示例4: test_extend_person

    def test_extend_person(self):
        session_info = {
            "name_id": nid,
            "issuer": IDP_OTHER,
            "not_on_or_after": in_a_while(minutes=15),
            "ava": {
                "eduPersonEntitlement": "Anka"
            }
        }
        
        self.population.add_information_about_person(session_info)
        
        issuers = self.population.issuers_of_info(nid)
        assert _eq(issuers, [IDP_ONE, IDP_OTHER])
        subjects = [code(c) for c in self.population.subjects()]
        assert subjects == [cnid]
        # Are any of the sources gone stale
        stales = self.population.stale_sources_for_person(nid)
        assert stales == []
        # are any of the possible sources not used or gone stale
        possible = [IDP_ONE, IDP_OTHER]
        stales = self.population.stale_sources_for_person(nid, possible)
        assert stales == []

        (identity, stale) = self.population.get_identity(nid)
        assert stale == []
        assert identity == {'mail': '[email protected]', 
                            'givenName': 'Anders', 
                            'surName': 'Andersson',
                            "eduPersonEntitlement": "Anka"}

        info = self.population.get_info_from(nid, IDP_OTHER)
        assert _eq(list(info.keys()), ["not_on_or_after", "name_id", "ava"])
        assert info["name_id"] == nid
        assert info["ava"] == {"eduPersonEntitlement": "Anka"}
开发者ID:lvanderree,项目名称:pysaml2-3,代码行数:35,代码来源:test_34_population.py

示例5: get_assertions_by_subject

    def get_assertions_by_subject(self, name_id=None, session_index=None,
                                  requested_context=None):
        """

        :param name_id: One of name_id or key can be used to get the authn
            statement
        :param session_index: If match against a session index should be done
        :param requested_context: Authn statements should match a specific
            authn context
        :return:
        """
        result = []
        key = sha1(code(name_id)).hexdigest()
        for item in self.assertion.find({"name_id_key": key}):
            assertion = from_dict(item["assertion"], ONTS, True)
            if session_index or requested_context:
                for statement in assertion.authn_statement:
                    if session_index:
                        if statement.session_index == session_index:
                            result.append(assertion)
                            break
                    if requested_context:
                        if context_match(requested_context,
                                         statement.authn_context):
                            result.append(assertion)
                            break
            else:
                result.append(assertion)
        return result
开发者ID:18600597055,项目名称:hue,代码行数:29,代码来源:mongo_store.py

示例6: set

 def set(self, name_id, entity_id, info, *args, **kwargs):
     try:
         name_id = info['name_id']
     except KeyError:
         pass
     else:
         info = dict(info)
         info['name_id'] = code(name_id)
     return super(IdentityCache, self).set(name_id, entity_id, info, *args, **kwargs)
开发者ID:18600597055,项目名称:hue,代码行数:9,代码来源:cache.py

示例7: entities

    def entities(self, name_id):
        """ Returns all the entities of assertions for a subject, disregarding
        whether the assertion still is valid or not.

        :param name_id: The subject identifier, a NameID instance
        :return: A possibly empty list of entity identifiers
        """
        cni = code(name_id)
        return list(self._db[cni].keys())
开发者ID:SUNET,项目名称:pysaml2,代码行数:9,代码来源:cache.py

示例8: _construct_identity

    def _construct_identity(self, session_info):
        cni = code(session_info["name_id"])
        identity = {
            "login": cni,
            "password": "",
            'repoze.who.userid': cni,
            "user": session_info["ava"],
        }
        logger.debug("Identity: %s" % identity)

        return identity
开发者ID:5monkeys,项目名称:pysaml2,代码行数:11,代码来源:sp.py

示例9: _set_name_id

def _set_name_id(session, name_id):
    """
    Store SAML2 name id info.

    :param session: The current session object
    :param name_id: saml2.saml.NameID object
    :return: None

    :type name_id: saml2.saml.NameID
    """
    session['_saml2_session_name_id'] = code(name_id)
开发者ID:digideskio,项目名称:eduid-dashboard,代码行数:11,代码来源:views.py

示例10: store_assertion

    def store_assertion(self, assertion, to_sign):
        name_id = assertion.subject.name_id
        nkey = sha1(code(name_id)).hexdigest()

        doc = {
            "name_id_key": nkey,
            "assertion_id": assertion.id,
            "assertion": to_dict(assertion, ONTS.values(), True),
            "to_sign": to_sign
        }

        _ = self.assertion.insert(doc)
开发者ID:18600597055,项目名称:hue,代码行数:12,代码来源:mongo_store.py

示例11: delete

    def delete(self, name_id):
        """

        :param name_id: The subject identifier, a NameID instance
        """
        del self._db[code(name_id)]

        if self._sync:
            try:
                self._db.sync()
            except AttributeError:
                pass
开发者ID:SUNET,项目名称:pysaml2,代码行数:12,代码来源:cache.py

示例12: add_information_about_person

    def add_information_about_person(self, session_info):
        """If there already are information from this source in the cache
        this function will overwrite that information"""

        name_id = session_info["name_id"]
        # make friendly to (JSON) serialization
        session_info['name_id'] = code(name_id)
        issuer = session_info["issuer"]
        del session_info["issuer"]
        self.cache.set(name_id, issuer, session_info,
                       session_info["not_on_or_after"])
        return name_id
开发者ID:Legrandin,项目名称:pysaml2,代码行数:12,代码来源:population.py

示例13: store_authn_statement

    def store_authn_statement(self, authn_statement, name_id):
        """

        :param authn_statement:
        :param name_id:
        :return:
        """
        logger.debug("store authn about: %s" % name_id)
        nkey = sha1(code(name_id)).hexdigest()
        logger.debug("Store authn_statement under key: %s" % nkey)
        try:
            self.authn[nkey].append(authn_statement)
        except KeyError:
            self.authn[nkey] = [authn_statement]

        return nkey
开发者ID:caustin,项目名称:pysaml2,代码行数:16,代码来源:sdb.py

示例14: get

    def get(self, name_id, entity_id, check_not_on_or_after=True):
        """ Get session information about a subject gotten from a
        specified IdP/AA.

        :param name_id: The subject identifier, a NameID instance
        :param entity_id: The identifier of the entity_id
        :param check_not_on_or_after: if True it will check if this
             subject is still valid or if it is too old. Otherwise it
             will not check this. True by default.
        :return: The session information
        """
        cni = code(name_id)
        (timestamp, info) = self._db[cni][entity_id]
        if check_not_on_or_after and time_util.after(timestamp):
            raise ToOld("past %s" % timestamp)

        return info or None
开发者ID:18600597055,项目名称:hue,代码行数:17,代码来源:cache.py

示例15: login_action

def login_action(session_info, user):

    logger.info("User {!r} logging in (eduPersonPrincipalName: {!r})".format(
        user.user_id,
        user.eppn))
    session['_saml2_session_name_id'] = code(session_info['name_id'])
    session['eduPersonPrincipalName'] = user.eppn
    loa = get_loa(current_app.config.get('AVAILABLE_LOA'), session_info)
    session['eduPersonAssurance'] = loa
    session.persist()

    # redirect the user to the view where he came from
    relay_state = request.form.get('RelayState', '/')
    logger.debug('Redirecting to the RelayState: ' + relay_state)
    response = redirect(location=relay_state)
    session.set_cookie(response)
    return response
开发者ID:digideskio,项目名称:eduid-webapp,代码行数:17,代码来源:acs_actions.py


注:本文中的saml2.ident.code函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。