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


Python config.SPConfig类代码示例

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


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

示例1: test_wayf

def test_wayf():
    c = SPConfig().load_file("server_conf")
    c.context = "sp"

    idps = c.metadata.with_descriptor("idpsso")
    ent = idps.values()[0]
    assert name(ent) == 'Example Co.'
    assert name(ent, "se") == 'Exempel AB'

    c.setup_logger()

    assert root_logger.level != logging.NOTSET
    assert root_logger.level == logging.INFO
    assert len(root_logger.handlers) == 1
    assert isinstance(root_logger.handlers[0],
                        logging.handlers.RotatingFileHandler)
    handler = root_logger.handlers[0]
    assert handler.backupCount == 5
    try:
        assert handler.maxBytes == 100000
    except AssertionError:
        assert handler.maxBytes == 500000
    assert handler.mode == "a"
    assert root_logger.name == "saml2"
    assert root_logger.level == 20
开发者ID:mlepine,项目名称:pysaml2,代码行数:25,代码来源:test_31_config.py

示例2: get_saml2_config

def get_saml2_config(module_path):

    module = imp.load_source('saml2_settings', module_path)

    conf = SPConfig()
    conf.load(module.SAML_CONFIG)
    return conf
开发者ID:Ratler,项目名称:eduid-dashboard,代码行数:7,代码来源:utils.py

示例3: test

def test():
    with closing(Server(config_file=dotname("idp_all_conf"))) as idp:
        conf = SPConfig()
        conf.load_file(dotname("servera_conf"))
        sp = Saml2Client(conf)

        srvs = sp.metadata.single_sign_on_service(idp.config.entityid,
                                                  BINDING_HTTP_REDIRECT)

        destination = srvs[0]["location"]
        req_id, req = sp.create_authn_request(destination, id="id1")

        try:
            key = sp.sec.key
        except AttributeError:
            key = import_rsa_key_from_file(sp.sec.key_file)

        info = http_redirect_message(req, destination, relay_state="RS",
                                     typ="SAMLRequest", sigalg=SIG_RSA_SHA1,
                                     key=key)

        verified_ok = False

        for param, val in info["headers"]:
            if param == "Location":
                _dict = parse_qs(val.split("?")[1])
                _certs = idp.metadata.certs(sp.config.entityid, "any", "signing")
                for cert in _certs:
                    if verify_redirect_signature(_dict, cert):
                        verified_ok = True

        assert verified_ok
开发者ID:ParthDesai,项目名称:pysaml2,代码行数:32,代码来源:test_70_redirect_signing.py

示例4: test_conf_syslog

def test_conf_syslog():
    c = SPConfig().load_file("server_conf_syslog")
    c.context = "sp"

    # otherwise the logger setting is not changed
    root_logger.level = logging.NOTSET
    root_logger.handlers = []
    
    print c.logger
    c.setup_logger()

    assert root_logger.level != logging.NOTSET
    assert root_logger.level == logging.INFO
    assert len(root_logger.handlers) == 1
    assert isinstance(root_logger.handlers[0],
                        logging.handlers.SysLogHandler)
    handler = root_logger.handlers[0]
    print handler.__dict__
    assert handler.facility == "local3"
    assert handler.address == ('localhost', 514)
    if sys.version >= (2, 7):
        assert handler.socktype == 2
    else:
        pass
    assert root_logger.name == "saml2"
    assert root_logger.level == 20
开发者ID:paulftw,项目名称:pysaml2,代码行数:26,代码来源:test_31_config.py

示例5: test_conf_syslog

def test_conf_syslog():
    c = SPConfig().load_file("server_conf_syslog")
    c.context = "sp"

    # otherwise the logger setting is not changed
    root_logger.level = logging.NOTSET
    while root_logger.handlers:
        handler = root_logger.handlers[-1]
        root_logger.removeHandler(handler)
        handler.flush()
        handler.close()

    print(c.logger)
    c.setup_logger()

    assert root_logger.level != logging.NOTSET
    assert root_logger.level == logging.INFO
    assert len(root_logger.handlers) == 1
    assert isinstance(root_logger.handlers[0],
                      logging.handlers.SysLogHandler)
    handler = root_logger.handlers[0]
    print(handler.__dict__)
    assert handler.facility == "local3"
    assert handler.address == ('localhost', 514)
    if ((sys.version_info.major == 2 and sys.version_info.minor >= 7) or
        sys.version_info.major > 2):
        assert handler.socktype == 2
    else:
        pass
    assert root_logger.name == "saml2"
    assert root_logger.level == 20
开发者ID:SUNET,项目名称:pysaml2,代码行数:31,代码来源:test_31_config.py

示例6: setup_class

    def setup_class(self):
        self.server = FakeIDP("idp_all_conf")

        conf = SPConfig()
        conf.load_file("servera_conf")
        self.client = Saml2Client(conf)

        self.client.send = self.server.receive
开发者ID:daryllstrauss,项目名称:pysaml2,代码行数:8,代码来源:test_51_client.py

示例7: config_settings_loader

def config_settings_loader(request=None):
    """Utility function to load the pysaml2 configuration.

    This is also the default config loader.
    """
    conf = SPConfig()
    conf.load(copy.deepcopy(settings.SAML_CONFIG))
    return conf
开发者ID:BetterWorks,项目名称:djangosaml2,代码行数:8,代码来源:conf.py

示例8: make_entity

def make_entity(sp, **kw_args):
    try:
        conf = SPConfig().load(kw_args["spconf"][sp])
    except KeyError:
        logging.warning("known SP configs: {}".format(kw_args["spconf"].keys()))
        raise

    conf.metadata = kw_args['metadata']

    return Saml2Client(config=conf)
开发者ID:identinetics,项目名称:saml2test2,代码行数:10,代码来源:common.py

示例9: create_logout_request

def create_logout_request(subject_id, destination, issuer_entity_id,
        req_entity_id, sign=True):
    config = SPConfig()
    config.load(sp_config)
    sp_client = Saml2Client(config=config)
    # construct a request
    logout_request = samlp.LogoutRequest(
        id='a123456',
        version=VERSION,
        destination=destination,
        issuer=saml.Issuer(text=req_entity_id,
            format=saml.NAMEID_FORMAT_ENTITY),
        name_id=saml.NameID(text=subject_id))
    return logout_request
开发者ID:dellintosh,项目名称:flask_pysaml2,代码行数:14,代码来源:test_saml.py

示例10: test_2

def test_2():
    c = SPConfig().load(sp2)
    c.context = "sp"

    print c
    assert c.endpoints
    assert c.idp
    assert c.optional_attributes
    assert c.name
    assert c.required_attributes

    assert len(c.idp) == 1
    assert c.idp.keys() == [""]
    assert c.idp.values() == ["https://example.com/saml2/idp/SSOService.php"]
    assert c.only_use_keys_in_metadata is None
开发者ID:ganeshcmohan,项目名称:pysaml,代码行数:15,代码来源:test_31_config.py

示例11: test_2

def test_2():
    c = SPConfig().load(sp2)
    c.context = "sp"

    print(c)
    assert c._sp_endpoints
    assert c.getattr("endpoints", "sp")
    assert c._sp_idp
    assert c._sp_optional_attributes
    assert c.name
    assert c._sp_required_attributes

    assert len(c._sp_idp) == 1
    assert list(c._sp_idp.keys()) == [""]
    assert list(c._sp_idp.values()) == ["https://example.com/saml2/idp/SSOService.php"]
    assert c.only_use_keys_in_metadata is True
开发者ID:rohe,项目名称:pysaml2-3,代码行数:16,代码来源:test_31_config.py

示例12: _saml2_config

 def _saml2_config(self):
     if self._v_config is None:
         sp_config = self._saml2_config_template()
         sp_config['metadata']['local'] = [self.saml2_idp_configfile]
         sp_config['entityid'] = self.saml2_sp_entityid
         sp_config['service']['sp']['name'] = self.saml2_sp_entityid
         sp_config['service']['sp']['url'] = self.saml2_sp_url
         sp_config['service']['sp']['endpoints']['assertion_consumer_service'] = [self.saml2_sp_url,]
         sp_config['service']['sp']['endpoints']['single_logout_service'] = ['%s/logout' % self.saml2_sp_url, BINDING_HTTP_REDIRECT]
         sp_config['service']['sp']['url'] = self.saml2_sp_url
         sp_config['xmlsec_binary'] = self.saml2_xmlsec
         config = SPConfig()
         conf=sp_config.copy()
         config.load(conf)
         self._v_config = config
     return self._v_config
开发者ID:saromba,项目名称:hl.pas.samlplugin,代码行数:16,代码来源:plugin.py

示例13: test_1

def test_1():
    c = SPConfig().load(sp1)
    c.context = "sp"
    print c
    assert c._sp_endpoints
    assert c._sp_name
    assert c._sp_idp
    md = c.metadata
    assert isinstance(md, MetaData)

    assert len(c._sp_idp) == 1
    assert c._sp_idp.keys() == ["urn:mace:example.com:saml:roland:idp"]
    assert c._sp_idp.values() == [{'single_sign_on_service':
        {'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect':
         'http://localhost:8088/sso/'}}]

    assert c.only_use_keys_in_metadata
开发者ID:paulftw,项目名称:pysaml2,代码行数:17,代码来源:test_31_config.py

示例14: test_minimum

def test_minimum():
    minimum = {
        "entityid": "urn:mace:example.com:saml:roland:sp",
        "service": {
            "sp": {
                "endpoints": {"assertion_consumer_service": ["http://sp.example.org/"]},
                "name": "test",
                "idp": {"": "https://example.com/idp/SSOService.php"},
            }
        },
        # "xmlsec_binary" : "/usr/local/bin/xmlsec1",
    }

    c = SPConfig().load(minimum)
    c.context = "sp"

    assert c is not None
开发者ID:rohe,项目名称:pysaml2-3,代码行数:17,代码来源:test_31_config.py

示例15: get_auth_response

    def get_auth_response(self, samlfrontend, context, internal_response, sp_conf, idp_metadata_str):
        sp_config = SPConfig().load(sp_conf, metadata_construction=False)
        resp_args = {
            "name_id_policy": NameIDPolicy(format=NAMEID_FORMAT_TRANSIENT),
            "in_response_to": None,
            "destination": sp_config.endpoint("assertion_consumer_service", binding=BINDING_HTTP_REDIRECT)[0],
            "sp_entity_id": sp_conf["entityid"],
            "binding": BINDING_HTTP_REDIRECT
        }
        request_state = samlfrontend._create_state_data(context, resp_args, "")
        context.state[samlfrontend.name] = request_state

        resp = samlfrontend.handle_authn_response(context, internal_response)

        sp_conf["metadata"]["inline"].append(idp_metadata_str)
        fakesp = FakeSP(sp_config)
        resp_dict = parse_qs(urlparse(resp.message).query)
        return fakesp.parse_authn_request_response(resp_dict["SAMLResponse"][0], BINDING_HTTP_REDIRECT)
开发者ID:SUNET,项目名称:SATOSA,代码行数:18,代码来源:test_saml2.py


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