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


Python validate.valid_instance函数代码示例

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


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

示例1: _loads

    def _loads(self, xmldata, binding=None, origdoc=None):
        # own copy
        self.xmlstr = xmldata[:]
        logger.info("xmlstr: %s" % (self.xmlstr,))
        try:
            self.message = self.signature_check(xmldata, origdoc=origdoc)
        except TypeError:
            raise
        except Exception as excp:
            logger.info("EXCEPTION: %s", excp)
    
        if not self.message:
            logger.error("Response was not correctly signed")
            logger.info(xmldata)
            raise IncorrectlySigned()

        logger.info("request: %s" % (self.message,))

        try:
            valid_instance(self.message)
        except NotValid as exc:
            logger.error("Not valid request: %s" % exc.args[0])
            raise
        
        return self
开发者ID:rohe,项目名称:pysaml2-3,代码行数:25,代码来源:request.py

示例2: __init__

    def __init__(self, cargs, kwargs):
        self.nspair = {"xs": "http://www.w3.org/2001/XMLSchema"}

        _cnf = kwargs['conf']
        res = read_multi_conf(_cnf, True)
        eds = []
        for key, cnf in res.items():
            eds.append(entity_descriptor(cnf))

        valid_for = 0

        """
            Setting things to None here that are now unused, but might be useful someday
        """
        conf = Config()
        conf.key_file = None
        conf.cert_file = None
        conf.debug = 1
        conf.xmlsec_binary = None
        args_name = None
        args_id = None
        args_sign = None
        secc = security_context(conf)

        desc, xmldoc = entities_descriptor(eds, valid_for, args_name, args_id,
                                           args_sign, secc)
        valid_instance(desc)

        self.desc = desc
        self.xmldoc = xmldoc
开发者ID:identinetics,项目名称:saml2test2,代码行数:30,代码来源:metadata.py

示例3: verify

 def verify(self, keys=None):
     try:
         valid_instance(self.response)
     except NotValid as exc:
         logger.error("Not valid response: %s" % exc.args[0])
         raise
     return self
开发者ID:helmus,项目名称:pysaml2,代码行数:7,代码来源:response.py

示例4: _loads

    def _loads(self, xmldata, binding=None, origdoc=None, must=None,
               only_valid_cert=False):
        if binding == BINDING_HTTP_REDIRECT:
            pass

        # own copy
        self.xmlstr = xmldata[:]
        logger.debug("xmlstr: %s" % (self.xmlstr,))
        try:
            self.message = self.signature_check(xmldata, origdoc=origdoc,
                                                must=must,
                                                only_valid_cert=only_valid_cert)
        except TypeError:
            raise
        except Exception as excp:
            logger.info("EXCEPTION: %s", excp)

        if not self.message:
            logger.error("Response was not correctly signed")
            logger.info(xmldata)
            raise IncorrectlySigned()

        logger.info("request: %s" % (self.message,))

        try:
            valid_instance(self.message)
        except NotValid as exc:
            logger.error("Not valid request: %s" % exc.args[0])
            raise

        return self
开发者ID:SpamapS,项目名称:pysaml2,代码行数:31,代码来源:request.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

            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

示例6: 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

示例7: create_metadata_string

def create_metadata_string(configfile, config=None, valid=None, cert=None,
                           keyfile=None, mid=None, name=None, sign=None):
    valid_for = 0
    nspair = {"xs": "http://www.w3.org/2001/XMLSchema"}
    # paths = [".", "/opt/local/bin"]

    if valid:
        valid_for = int(valid)  # Hours

    eds = []
    if config is None:
        if configfile.endswith(".py"):
            configfile = configfile[:-3]
        config = Config().load_file(configfile, metadata_construction=True)
    eds.append(entity_descriptor(config))

    conf = Config()
    conf.key_file = config.key_file or keyfile
    conf.cert_file = config.cert_file or cert
    conf.debug = 1
    conf.xmlsec_binary = config.xmlsec_binary
    secc = security_context(conf)

    if mid:
        eid, xmldoc = entities_descriptor(eds, valid_for, name, mid,
                                          sign, secc)
    else:
        eid = eds[0]
        if sign:
            eid, xmldoc = sign_entity_descriptor(eid, mid, secc)
        else:
            xmldoc = None

    valid_instance(eid)
    return metadata_tostring_fix(eid, nspair, xmldoc)
开发者ID:Lefford,项目名称:pysaml2,代码行数:35,代码来源:metadata.py

示例8: _postamble

    def _postamble(self):
        if not self.response:
            logger.error("Response was not correctly signed")
            if self.xmlstr:
                logger.info(self.xmlstr)
            raise IncorrectlySigned()

        logger.debug("response: %s" % (self.response,))

        try:
            valid_instance(self.response)
        except NotValid, exc:
            logger.error("Not valid response: %s" % exc.args[0])
            self._clear()
            return self
开发者ID:taizo,项目名称:pysaml2,代码行数:15,代码来源:response.py

示例9: write_metadata

def write_metadata(sp_configs):
    """
    Generate SAML XML metadata from the pysaml2 JSON format.
    :param base: base url of the svs node
    :return: dictionary with the config for the two SP's
    """

    for _, config in sp_configs.iteritems():
        cnf = Config().load(config, metadata_construction=True)
        eid = entity_descriptor(cnf)
        valid_instance(eid)
        nspair = {"xs": "http://www.w3.org/2001/XMLSchema"}
        xmldoc = metadata_tostring_fix(eid, nspair, None)

        entity_id = config["entityid"]
        path = urlparse.urlparse(entity_id).path
        filename = os.path.basename(path)
        with open(filename, "w") as output_file:
            output_file.write(xmldoc)
开发者ID:SvHu,项目名称:svs,代码行数:19,代码来源:sp_metadata.py

示例10: _make_metadata

def _make_metadata(config_dict, option):
    """
    Creates metadata from the given idp config

    :type config_dict: dict[str, Any]
    :type option: vopaas.metadata_creation.make_vopaas_metadata.MetadataOption
    :rtype: str

    :param config_dict: config
    :param option: metadata creation settings
    :return: A xml string
    """
    eds = []
    cnf = Config()
    cnf.load(copy.deepcopy(config_dict), metadata_construction=True)

    if option.valid:
        cnf.valid_for = option.valid
    eds.append(entity_descriptor(cnf))

    conf = Config()
    conf.key_file = option.keyfile
    conf.cert_file = option.cert
    conf.debug = 1
    conf.xmlsec_binary = option.xmlsec
    secc = security_context(conf)

    if option.id:
        desc, xmldoc = entities_descriptor(eds, option.valid, option.name, option.id, option.sign, secc)
        valid_instance(desc)
        print(desc.to_string(NSPAIR))
    else:
        for eid in eds:
            if option.sign:
                assert conf.key_file
                assert conf.cert_file
                eid, xmldoc = sign_entity_descriptor(eid, option.id, secc)
            else:
                xmldoc = None

            valid_instance(eid)
            xmldoc = metadata_tostring_fix(eid, NSPAIR, xmldoc).decode()
            return xmldoc
开发者ID:borgand,项目名称:SATOSA,代码行数:43,代码来源:make_satosa_saml_metadata.py

示例11: _postamble

    def _postamble(self):
        if not self.response:
            if self.log:
                self.log.error("Response was not correctly signed")
                if self.xmlstr:
                    self.log.info(self.xmlstr)
            raise IncorrectlySigned()
    
        if self.debug:
            self.log.info("response: %s" % (self.response,))

        try:
            valid_instance(self.response)
        except NotValid, exc:
            if self.log:
                self.log.error("Not valid response: %s" % exc.args[0])
            else:
                print >> sys.stderr, "Not valid response: %s" % exc.args[0]
        
            self._clear()
            return self
开发者ID:FluidReview,项目名称:saml2,代码行数:21,代码来源:response.py

示例12: 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

示例13: create_metadata_string

def create_metadata_string(configfile, config, valid, cert, keyfile, id, name,
                           sign):
    valid_for = 0
    nspair = {"xs": "http://www.w3.org/2001/XMLSchema"}
    #paths = [".", "/opt/local/bin"]

    if valid:
        valid_for = int(valid)  # Hours

    eds = []
    if config is not None:
        eds.append(entity_descriptor(config))
    else:
        if configfile.endswith(".py"):
            configfile = configfile[:-3]
        config = Config().load_file(configfile, metadata_construction=True)
        eds.append(entity_descriptor(config))

    conf = Config()
    conf.key_file = keyfile
    conf.cert_file = cert
    conf.debug = 1
    conf.xmlsec_binary = config.xmlsec_binary
    secc = security_context(conf)

    if id:
        desc = entities_descriptor(eds, valid_for, name, id,
                                   sign, secc)
        valid_instance(desc)

        return metadata_tostring_fix(desc, nspair)
    else:
        for eid in eds:
            if sign:
                desc = sign_entity_descriptor(eid, id, secc)
            else:
                desc = eid
            valid_instance(desc)
            return metadata_tostring_fix(desc, nspair)
开发者ID:Ry4an,项目名称:pysaml2,代码行数:39,代码来源:metadata.py

示例14: create_signed_entities_descriptor

def create_signed_entities_descriptor(entity_descriptors, security_context, valid_for=None):
    """
    :param entity_descriptors: the entity descriptors to put in in an EntitiesDescriptor tag and sign
    :param security_context: security context for the signature
    :param valid_for: number of hours the metadata should be valid
    :return: the signed XML document

    :type entity_descriptors: Sequence[saml2.md.EntityDescriptor]]
    :type security_context: saml2.sigver.SecurityContext
    :type valid_for: Optional[int]
    """
    entities_desc, xmldoc = entities_descriptor(entity_descriptors, valid_for=valid_for, name=None, ident=None,
                                                sign=True, secc=security_context)
    if not valid_instance(entities_desc):
        raise ValueError("Could not construct valid EntitiesDescriptor tag")

    return xmldoc
开发者ID:SUNET,项目名称:SATOSA,代码行数:17,代码来源:saml_metadata.py

示例15: create_signed_entity_descriptor

def create_signed_entity_descriptor(entity_descriptor, security_context, valid_for=None):
    """
    :param entity_descriptor: the entity descriptor to sign
    :param security_context: security context for the signature
    :param valid_for: number of hours the metadata should be valid
    :return: the signed XML document

    :type entity_descriptor: saml2.md.EntityDescriptor]
    :type security_context: saml2.sigver.SecurityContext
    :type valid_for: Optional[int]
    """
    if valid_for:
        entity_descriptor.valid_until = in_a_while(hours=valid_for)

    entity_desc, xmldoc = sign_entity_descriptor(entity_descriptor, None, security_context)

    if not valid_instance(entity_desc):
        raise ValueError("Could not construct valid EntityDescriptor tag")

    return xmldoc
开发者ID:SUNET,项目名称:SATOSA,代码行数:20,代码来源:saml_metadata.py


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