本文整理汇总了Python中saml2.entity.Entity类的典型用法代码示例。如果您正苦于以下问题:Python Entity类的具体用法?Python Entity怎么用?Python Entity使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Entity类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, config=None, identity_cache=None, state_cache=None,
virtual_organization="", config_file=""):
"""
:param config: A saml2.config.Config instance
:param identity_cache: Where the class should store identity information
:param state_cache: Where the class should keep state information
:param virtual_organization: A specific virtual organization
"""
Entity.__init__(self, "sp", config, config_file, virtual_organization)
self.users = Population(identity_cache)
self.lock = threading.Lock()
# for server state storage
if state_cache is None:
self.state = {} # in memory storage
else:
self.state = state_cache
self.logout_requests_signed = False
self.allow_unsolicited = False
self.authn_requests_signed = False
self.want_assertions_signed = False
self.want_response_signed = False
for attribute in ["allow_unsolicited", "authn_requests_signed",
"logout_requests_signed", "want_assertions_signed",
"want_response_signed"]:
v = self.config.getattr(attribute, "sp")
if v is True or v == 'true':
setattr(self, attribute, True)
self.artifact2response = {}
示例2: __init__
def __init__(self, config=None, identity_cache=None, state_cache=None,
virtual_organization="", config_file=""):
"""
:param config: A saml2.config.Config instance
:param identity_cache: Where the class should store identity information
:param state_cache: Where the class should keep state information
:param virtual_organization: A specific virtual organization
"""
Entity.__init__(self, "sp", config, config_file, virtual_organization)
self.users = Population(identity_cache)
# for server state storage
if state_cache is None:
self.state = {} # in memory storage
else:
self.state = state_cache
for foo in ["allow_unsolicited", "authn_requests_signed",
"logout_requests_signed"]:
if self.config.getattr(foo, "sp") == 'true':
setattr(self, foo, True)
else:
setattr(self, foo, False)
self.artifact2response = {}
示例3: __init__
def __init__(self, config_file="", config=None, _cache="", stype="idp"):
Entity.__init__(self, stype, config, config_file)
self.init_config(stype)
self._cache = _cache
self.ticket = {}
self.authn = {}
self.assertion = {}
self.user2uid = {}
self.uid2user = {}
self.session_db = SessionStorage()
示例4: __init__
def __init__(self, config=None, identity_cache=None, state_cache=None,
virtual_organization="", config_file="", msg_cb=None):
"""
:param config: A saml2.config.Config instance
:param identity_cache: Where the class should store identity information
:param state_cache: Where the class should keep state information
:param virtual_organization: A specific virtual organization
"""
Entity.__init__(self, "sp", config, config_file, virtual_organization,
msg_cb=msg_cb)
self.users = Population(identity_cache)
self.lock = threading.Lock()
# for server state storage
if state_cache is None:
self.state = {} # in memory storage
else:
self.state = state_cache
attribute_defaults = {
"logout_requests_signed": False,
"allow_unsolicited": False,
"authn_requests_signed": False,
"want_assertions_signed": False,
"want_response_signed": True,
"want_assertions_or_response_signed" : False
}
for attr, val_default in attribute_defaults.items():
val_config = self.config.getattr(attr, "sp")
if val_config is None:
val = val_default
else:
val = val_config
if val == 'true':
val = True
setattr(self, attr, val)
if self.entity_type == "sp" and not any(
[
self.want_assertions_signed,
self.want_response_signed,
self.want_assertions_or_response_signed,
]
):
logger.warning(
"The SAML service provider accepts unsigned SAML Responses "
"and Assertions. This configuration is insecure."
)
self.artifact2response = {}
示例5: __init__
def __init__(self, config_file="", config=None, cache=None, stype="idp",
symkey=""):
Entity.__init__(self, stype, config, config_file)
self.init_config(stype)
self.cache = cache
self.ticket = {}
#
self.session_db = self.choose_session_storage()
# Needed for
self.symkey = symkey
self.seed = rndstr()
self.iv = os.urandom(16)
self.eptid = None
示例6: __init__
def __init__(self, user, passwd, sp="", idp=None, metadata_file=None,
xmlsec_binary=None, verbose=0, ca_certs="",
disable_ssl_certificate_validation=True, key_file=None,
cert_file=None, config=None):
"""
:param user: user name
:param passwd: user password
:param sp: The SP URL
:param idp: The IdP PAOS endpoint
:param metadata_file: Where the metadata file is if used
:param xmlsec_binary: Where the xmlsec1 binary can be found (*)
:param verbose: Chatty or not
:param ca_certs: is the path of a file containing root CA certificates
for SSL server certificate validation (*)
:param disable_ssl_certificate_validation: If
disable_ssl_certificate_validation is true, SSL cert validation
will not be performed (*)
:param key_file: Private key filename (*)
:param cert_file: Certificate filename (*)
:param config: Config() instance, overrides all the parameters marked
with an asterisk (*) above
"""
if not config:
config = Config()
config.disable_ssl_certificate_validation = \
disable_ssl_certificate_validation
config.key_file = key_file
config.cert_file = cert_file
config.ca_certs = ca_certs
config.xmlsec_binary = xmlsec_binary
Entity.__init__(self, "sp", config)
self._idp = idp
self._sp = sp
self.user = user
self.passwd = passwd
self._verbose = verbose
if metadata_file:
self._metadata = MetadataStore([saml, samlp], None, config)
self._metadata.load("local", metadata_file)
logger.debug("Loaded metadata from '%s'" % metadata_file)
else:
self._metadata = None
self.metadata = self._metadata
self.cookie_handler = None
self.done_ecp = False
self.cookie_jar = cookielib.LWPCookieJar()
示例7: urlhandler_acs_post
def urlhandler_acs_post(self, sh, environ, local_webenv, path, start_response, tester, webio):
formdata = get_post(environ).decode('utf8')
resp = dict([(k, v[0]) for k, v in parse_qs(formdata).items()])
try:
test_id = sh['conv'].test_id
except KeyError as err:
test_id = None
if not test_id:
"""
Do we have been initialized already, or is the user just on the wrong page ?
"""
if not resp:
return tester.display_test_list()
"""
In other words: we've been contacted by robobrowser and are in a different environment now, than the
code expects us to be. .... Hopefully, trickery and recreating of the environment will lead mostly
to more intended effects than unintended ones.
This is unfinished business: You can add other bindings here, to expand what RB can be used to test.
"""
try:
txt = resp['SAMLResponse']
xmlstr = Entity.unravel(txt, BINDING_HTTP_POST)
except Exception as e:
msg = 'Decoding not supported in the SP'
raise Exception(msg)
rsp = samlp.any_response_from_string(xmlstr)
original_request_id = rsp.in_response_to
requester_session = self.session_store.get_session_by_conv_id(original_request_id)
# recreating the environment. lets hope it is somewhat reentrant resistant
sh = requester_session
webio = WebIO(session=sh, **local_webenv)
webio.environ = environ
webio.start_response = start_response
tester = Tester(webio, sh, **local_webenv)
profile_handler = local_webenv['profile_handler']
_sh = profile_handler(sh)
# filename = self.webenv['profile_handler'](sh).log_path(test_id)
# _sh.session.update({'conv': 'foozbar'})
logfilename = _sh.log_path(test_id)
content = do_next(tester, resp, sh, webio, logfilename, path)
return content
示例8: __init__
def __init__(self, config=None, config_file=""):
Entity.__init__(self, "disco", config, config_file)