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


Python time_util.valid函数代码示例

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


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

示例1: import_metadata

 def import_metadata(self, xml_str, source):
     """ Import information; organization distinguish name, location and
     certificates from a metadata file.
     
     :param xml_str: The metadata as a XML string.
     :param source: A name by which this source should be known, has to be
         unique within this session.
     """
     
     # now = time.gmtime()
     #print >> sys.stderr, "Loading %s" % (source,)
     
     entities_descr = md.entities_descriptor_from_string(xml_str)
     if not entities_descr:
         entity_descr = md.entity_descriptor_from_string(xml_str)
         if entity_descr:
             self.do_entity_descriptor(entity_descr, source)
     else:
         try:
             valid_instance(entities_descr)
         except NotValid, exc:
             print >> sys.stderr, exc.args[0]
             return
     
         try:
             valid(entities_descr.valid_until)
         except AttributeError:
             pass
     
         for entity_descr in entities_descr.entity_descriptor:
             self.do_entity_descriptor(entity_descr, source, 
                                         entities_descr.valid_until)
开发者ID:FluidReview,项目名称:saml2,代码行数:32,代码来源:metadata.py

示例2: test_valid

def test_valid():
    assert valid("2000-01-12T00:00:00Z") == False
    current_year = datetime.datetime.today().year
    assert valid("%d-01-12T00:00:00Z" % (current_year + 1)) == True
    this_instance = instant()
    time.sleep(1)
    assert valid(this_instance) == False  # unless on a very fast machine :-)
    soon = in_a_while(seconds=10)
    assert valid(soon) == True
开发者ID:lvanderree,项目名称:pysaml2-3,代码行数:9,代码来源:test_10_time_util.py

示例3: parse

    def parse(self, xmlstr):
        self.entities_descr = md.entities_descriptor_from_string(xmlstr)

        if not self.entities_descr:
            self.entity_descr = md.entity_descriptor_from_string(xmlstr)
            if self.entity_descr:
                self.do_entity_descriptor(self.entity_descr)
        else:
            try:
                valid_instance(self.entities_descr)
            except NotValid, exc:
                logger.error(exc.args[0])
                return

            if self.check_validity:
                try:
                    if not valid(self.entities_descr.valid_until):
                        raise ToOld(
                            "Metadata not valid anymore, it's after %s" % (
                                self.entities_descr.valid_until,))
                except AttributeError:
                    pass

            for entity_descr in self.entities_descr.entity_descriptor:
                self.do_entity_descriptor(entity_descr)
开发者ID:jakew1ll,项目名称:pysaml2,代码行数:25,代码来源:mdstore.py

示例4: keep_updated

def keep_updated(func, self=None, entity_id=None, *args, **kwargs):
    #print "In keep_updated"
    try:
        if "valid_until" in self.entity[entity_id]:
            try:
                if not valid(self.entity[entity_id]["valid_until"]):
                    self.reload_entity(entity_id)
            except KeyError:
                pass
    except KeyError: # Unknown entity, handle downstream
        pass
    return func(self, entity_id, *args, **kwargs)
开发者ID:FluidReview,项目名称:saml2,代码行数:12,代码来源:metadata.py

示例5: parse

    def parse(self, xmlstr):
        self.entities_descr = md.entities_descriptor_from_string(xmlstr)

        if not self.entities_descr:
            self.entity_descr = md.entity_descriptor_from_string(xmlstr)
            if self.entity_descr:
                self.do_entity_descriptor(self.entity_descr)
        else:
            try:
                valid_instance(self.entities_descr)
            except NotValid, exc:
                logger.error(exc.args[0])
                return

            try:
                valid(self.entities_descr.valid_until)
            except AttributeError:
                pass

            for entity_descr in self.entities_descr.entity_descriptor:
                self.do_entity_descriptor(entity_descr)
开发者ID:hufman,项目名称:pysaml2,代码行数:21,代码来源:mdstore.py

示例6: do_entity_descriptor

    def do_entity_descriptor(self, entity_descr):
        if self.check_validity:
            try:
                if not valid(entity_descr.valid_until):
                    logger.error("Entity descriptor (entity id:%s) to old",
                                 entity_descr.entity_id)
                    self.to_old.append(entity_descr.entity_id)
                    return
            except AttributeError:
                pass

        # have I seen this entity_id before ? If so if log: ignore it
        if entity_descr.entity_id in self.entity:
            print("Duplicated Entity descriptor (entity id: '%s')" %
                  entity_descr.entity_id, file=sys.stderr)
            return

        _ent = to_dict(entity_descr, metadata_modules())
        flag = 0
        # verify support for SAML2
        for descr in ["spsso", "idpsso", "role", "authn_authority",
                      "attribute_authority", "pdp", "affiliation"]:
            _res = []
            try:
                _items = _ent["%s_descriptor" % descr]
            except KeyError:
                continue

            if descr == "affiliation":  # Not protocol specific
                flag += 1
                continue

            for item in _items:
                for prot in item["protocol_support_enumeration"].split(" "):
                    if prot == samlp.NAMESPACE:
                        item["protocol_support_enumeration"] = prot
                        _res.append(item)
                        break
            if not _res:
                del _ent["%s_descriptor" % descr]
            else:
                flag += 1

        if self.filter:
            _ent = self.filter(_ent)
            if not _ent:
                flag = 0

        if flag:
            self.entity[entity_descr.entity_id] = _ent
开发者ID:Amli,项目名称:pysaml2,代码行数:50,代码来源:mdstore.py

示例7: do_entity_descriptor

 def do_entity_descriptor(self, entity_descr, source, valid_until=0):
     try:
         if not valid(entity_descr.valid_until):
             if self.log:
                 self.log.info(
                     "Entity descriptor (entity id:%s) to old" % \
                     entity_descr.entity_id)
             else:
                 print >> sys.stderr, \
                     "Entity descriptor (entity id:%s) to old" % \
                     entity_descr.entity_id
             return 
     except AttributeError,e:
         pass
开发者ID:FluidReview,项目名称:saml2,代码行数:14,代码来源:metadata.py

示例8: test_timeout

def test_timeout():
    soon = in_a_while(seconds=1)
    time.sleep(2)
    assert valid(soon) == False
开发者ID:lvanderree,项目名称:pysaml2-3,代码行数:4,代码来源:test_10_time_util.py


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