_id
stringlengths
2
7
title
stringlengths
1
88
partition
stringclasses
3 values
text
stringlengths
75
19.8k
language
stringclasses
1 value
meta_information
dict
q36300
Etcd3Client.snapshot
train
def snapshot(self, file_obj): """Take a snapshot of the database. :param file_obj: A file-like object to write the database contents in. """ snapshot_request = etcdrpc.SnapshotRequest() snapshot_response = self.maintenancestub.Snapshot( snapshot_request, ...
python
{ "resource": "" }
q36301
PixelClassifier.extract_pixels
train
def extract_pixels(X): """ Extract pixels from array X :param X: Array of images to be classified. :type X: numpy array, shape = [n_images, n_pixels_y, n_pixels_x, n_bands] :return: Reshaped 2D array :rtype: numpy array, [n_samples*n_pixels_y*n_pixels_x,n_bands] :raises:...
python
{ "resource": "" }
q36302
PixelClassifier.image_predict
train
def image_predict(self, X): """ Predicts class label for the entire image. :param X: Array of images to be classified. :type X: numpy array, shape = [n_images, n_pixels_y, n_pixels_x, n_bands] :return: raster classification map :rtype: numpy array, [n_samples, n_pixels_...
python
{ "resource": "" }
q36303
PixelClassifier.image_predict_proba
train
def image_predict_proba(self, X): """ Predicts class probabilities for the entire image. :param X: Array of images to be classified. :type X: numpy array, shape = [n_images, n_pixels_y, n_pixels_x, n_bands] :return: classification probability map :rtype: numpy array, [n...
python
{ "resource": "" }
q36304
CloudMaskRequest._prepare_ogc_request_params
train
def _prepare_ogc_request_params(self): """ Method makes sure that correct parameters will be used for download of S-2 bands. """ self.ogc_request.image_format = MimeType.TIFF_d32f if self.ogc_request.custom_url_params is None: self.ogc_request.custom_url_params = {} s...
python
{ "resource": "" }
q36305
CloudMaskRequest._set_band_and_valid_mask
train
def _set_band_and_valid_mask(self): """ Downloads band data and valid mask. Sets parameters self.bands, self.valid_data """ data = np.asarray(self.ogc_request.get_data()) self.bands = data[..., :-1] self.valid_data = (data[..., -1] == 1.0).astype(np.bool)
python
{ "resource": "" }
q36306
CloudMaskRequest.get_probability_masks
train
def get_probability_masks(self, non_valid_value=0): """ Get probability maps of areas for each available date. The pixels without valid data are assigned non_valid_value. :param non_valid_value: Value to be assigned to non valid data pixels :type non_valid_value: float :...
python
{ "resource": "" }
q36307
CloudMaskRequest.get_cloud_masks
train
def get_cloud_masks(self, threshold=None, non_valid_value=False): """ The binary cloud mask is computed on the fly. Be cautious. The pixels without valid data are assigned non_valid_value. :param threshold: A float from [0,1] specifying threshold :type threshold: float :param no...
python
{ "resource": "" }
q36308
Base.add_vo_information_about_user
train
def add_vo_information_about_user(self, name_id): """ Add information to the knowledge I have about the user. This is for Virtual organizations. :param name_id: The subject identifier :return: A possibly extended knowledge. """ ava = {} try: (ava, _)...
python
{ "resource": "" }
q36309
Base.create_attribute_query
train
def create_attribute_query(self, destination, name_id=None, attribute=None, message_id=0, consent=None, extensions=None, sign=False, sign_prepare=False, sign_alg=None, digest_alg=None, **kwargs): """ Constructs an AttributeQuery :param destination: To who...
python
{ "resource": "" }
q36310
Base.create_authz_decision_query
train
def create_authz_decision_query(self, destination, action, evidence=None, resource=None, subject=None, message_id=0, consent=None, extensions=None, sign=None, sign_alg=None, digest_alg=None, **kwargs): """ Creates an authz decision query. :param destination: The IdP ...
python
{ "resource": "" }
q36311
Base.create_authz_decision_query_using_assertion
train
def create_authz_decision_query_using_assertion(self, destination, assertion, action=None, resource=None, subject=None, message_id=0, consent=None, extensions=None, sign=False, nsprefix=None): """ Makes an authz decision query based on a pr...
python
{ "resource": "" }
q36312
Base.parse_authn_request_response
train
def parse_authn_request_response(self, xmlstr, binding, outstanding=None, outstanding_certs=None, conv_info=None): """ Deal with an AuthnResponse :param xmlstr: The reply as a xml string :param binding: Which binding that was used for the transport :...
python
{ "resource": "" }
q36313
Base.create_discovery_service_request
train
def create_discovery_service_request(url, entity_id, **kwargs): """ Created the HTTP redirect URL needed to send the user to the discovery service. :param url: The URL of the discovery service :param entity_id: The unique identifier of the service provider :param return:...
python
{ "resource": "" }
q36314
Base.parse_discovery_service_response
train
def parse_discovery_service_response(url="", query="", returnIDParam="entityID"): """ Deal with the response url from a Discovery Service :param url: the url the user was redirected back to or :param query: just the query part of the URL. :param returnIDParam: This i...
python
{ "resource": "" }
q36315
filter_on_demands
train
def filter_on_demands(ava, required=None, optional=None): """ Never return more than is needed. Filters out everything the server is prepared to return but the receiver doesn't ask for :param ava: Attribute value assertion as a dictionary :param required: Required attributes :param optional: Option...
python
{ "resource": "" }
q36316
filter_attribute_value_assertions
train
def filter_attribute_value_assertions(ava, attribute_restrictions=None): """ Will weed out attribute values and values according to the rules defined in the attribute restrictions. If filtering results in an attribute without values, then the attribute is removed from the assertion. :param ava: The...
python
{ "resource": "" }
q36317
Policy.compile
train
def compile(self, restrictions): """ This is only for IdPs or AAs, and it's about limiting what is returned to the SP. In the configuration file, restrictions on which values that can be returned are specified with the help of regular expressions. This function goes through and p...
python
{ "resource": "" }
q36318
Policy.conditions
train
def conditions(self, sp_entity_id): """ Return a saml.Condition instance :param sp_entity_id: The SP entity ID :return: A saml.Condition instance """ return factory(saml.Conditions, not_before=instant(), # How long might depend on wh...
python
{ "resource": "" }
q36319
Assertion.construct
train
def construct(self, sp_entity_id, attrconvs, policy, issuer, farg, authn_class=None, authn_auth=None, authn_decl=None, encrypt=None, sec_context=None, authn_decl_ref=None, authn_instant="", subject_locality="", authn_statem=None, name_id=None, sess...
python
{ "resource": "" }
q36320
Assertion.apply_policy
train
def apply_policy(self, sp_entity_id, policy, metadata=None): """ Apply policy to the assertion I'm representing :param sp_entity_id: The SP entity ID :param policy: The policy :param metadata: Metadata to use :return: The resulting AVA after the policy is applied """ ...
python
{ "resource": "" }
q36321
application
train
def application(environ, start_response): """ The main WSGI application. Dispatch the current request to the functions from above. If nothing matches, call the `not_found` function. :param environ: The HTTP application environment :param start_response: The application to run when the handling...
python
{ "resource": "" }
q36322
Service.soap
train
def soap(self): """ Single log out using HTTP_SOAP binding """ logger.debug("- SOAP -") _dict = self.unpack_soap() logger.debug("_dict: %s", _dict) return self.operation(_dict, BINDING_SOAP)
python
{ "resource": "" }
q36323
SSO._pick_idp
train
def _pick_idp(self, came_from): """ If more than one idp and if none is selected, I have to do wayf or disco """ _cli = self.sp logger.debug("[_pick_idp] %s", self.environ) if "HTTP_PAOS" in self.environ: if self.environ["HTTP_PAOS"] == PAOS_HEADER_I...
python
{ "resource": "" }
q36324
valid_any_uri
train
def valid_any_uri(item): """very simplistic, ...""" try: part = urlparse(item) except Exception: raise NotValid("AnyURI") if part[0] == "urn" and part[1] == "": # A urn return True # elif part[1] == "localhost" or part[1] == "127.0.0.1": # raise NotValid("AnyURI") ...
python
{ "resource": "" }
q36325
valid_anytype
train
def valid_anytype(val): """ Goes through all known type validators :param val: The value to validate :return: True is value is valid otherwise an exception is raised """ for validator in VALIDATOR.values(): if validator == valid_anytype: # To hinder recursion continue t...
python
{ "resource": "" }
q36326
load_maps
train
def load_maps(dirspec): """ load the attribute maps :param dirspec: a directory specification :return: a dictionary with the name of the map as key and the map as value. The map itself is a dictionary with two keys: "to" and "fro". The values for those keys are the actual mapping. """ ...
python
{ "resource": "" }
q36327
ac_factory
train
def ac_factory(path=""): """Attribute Converter factory :param path: The path to a directory where the attribute maps are expected to reside. :return: A AttributeConverter instance """ acs = [] if path: if path not in sys.path: sys.path.insert(0, path) for ...
python
{ "resource": "" }
q36328
AttributeConverter.adjust
train
def adjust(self): """ If one of the transformations is not defined it is expected to be the mirror image of the other. """ if self._fro is None and self._to is not None: self._fro = dict( [(value.lower(), key) for key, value in self._to.items()]) if s...
python
{ "resource": "" }
q36329
AttributeConverter.from_dict
train
def from_dict(self, mapdict): """ Import the attribute map from a dictionary :param mapdict: The dictionary """ self.name_format = mapdict["identifier"] try: self._fro = dict( [(k.lower(), v) for k, v in mapdict["fro"].items()]) except KeyEr...
python
{ "resource": "" }
q36330
AttributeConverter.lcd_ava_from
train
def lcd_ava_from(self, attribute): """ If nothing else works, this should :param attribute: an Attribute instance :return: """ name = attribute.name.strip() values = [ (value.text or '').strip() for value in attribute.attribute_value] ...
python
{ "resource": "" }
q36331
AttributeConverter.fail_safe_fro
train
def fail_safe_fro(self, statement): """ In case there is not formats defined or if the name format is undefined :param statement: AttributeStatement instance :return: A dictionary with names and values """ result = {} for attribute in statement.attribute: ...
python
{ "resource": "" }
q36332
AttributeConverter.fro
train
def fro(self, statement): """ Get the attributes and the attribute values. :param statement: The AttributeStatement. :return: A dictionary containing attributes and values """ if not self.name_format: return self.fail_safe_fro(statement) result = {} ...
python
{ "resource": "" }
q36333
AttributeConverter.to_format
train
def to_format(self, attr): """ Creates an Attribute instance with name, name_format and friendly_name :param attr: The local name of the attribute :return: An Attribute instance """ try: _attr = self._to[attr] except KeyError: try: ...
python
{ "resource": "" }
q36334
my_request_classifier
train
def my_request_classifier(environ): """ Returns one of the classifiers 'dav', 'xmlpost', or 'browser', depending on the imperative logic below""" request_method = REQUEST_METHOD(environ) if request_method in _DAV_METHODS: return "dav" useragent = USER_AGENT(environ) if useragent: ...
python
{ "resource": "" }
q36335
_localized_name
train
def _localized_name(val, klass): """If no language is defined 'en' is the default""" try: (text, lang) = val return klass(text=text, lang=lang) except ValueError: return klass(text=val, lang="en")
python
{ "resource": "" }
q36336
do_contact_person_info
train
def do_contact_person_info(ava): """Create a ContactPerson instance from configuration information.""" cper = md.ContactPerson() cper.loadd(ava) if not cper.contact_type: cper.contact_type = "technical" return cper
python
{ "resource": "" }
q36337
do_pdp_descriptor
train
def do_pdp_descriptor(conf, cert=None, enc_cert=None): """ Create a Policy Decision Point descriptor """ pdp = md.PDPDescriptor() pdp.protocol_support_enumeration = samlp.NAMESPACE endps = conf.getattr("endpoints", "pdp") if endps: for (endpoint, instlist) in do_endpoints(endps, ...
python
{ "resource": "" }
q36338
create_return_url
train
def create_return_url(base, query, **kwargs): """ Add a query string plus extra parameters to a base URL which may contain a query part already. :param base: redirect_uri may contain a query part, no fragment allowed. :param query: Old query part as a string :param kwargs: extra query parameter...
python
{ "resource": "" }
q36339
Entity._issuer
train
def _issuer(self, entityid=None): """ Return an Issuer instance """ if entityid: if isinstance(entityid, Issuer): return entityid else: return Issuer(text=entityid, format=NAMEID_FORMAT_ENTITY) else: return Issuer(text=self.conf...
python
{ "resource": "" }
q36340
Entity.apply_binding
train
def apply_binding(self, binding, msg_str, destination="", relay_state="", response=False, sign=False, **kwargs): """ Construct the necessary HTTP arguments dependent on Binding :param binding: Which binding to use :param msg_str: The return message as a string (XML...
python
{ "resource": "" }
q36341
Entity._message
train
def _message(self, request_cls, destination=None, message_id=0, consent=None, extensions=None, sign=False, sign_prepare=False, nsprefix=None, sign_alg=None, digest_alg=None, **kwargs): """ Some parameters appear in all requests so simplify by doing it in one pla...
python
{ "resource": "" }
q36342
Entity._add_info
train
def _add_info(self, msg, **kwargs): """ Add information to a SAML message. If the attribute is not part of what's defined in the SAML standard add it as an extension. :param msg: :param kwargs: :return: """ args, extensions = self._filter_args(msg, **kwa...
python
{ "resource": "" }
q36343
Entity.has_encrypt_cert_in_metadata
train
def has_encrypt_cert_in_metadata(self, sp_entity_id): """ Verifies if the metadata contains encryption certificates. :param sp_entity_id: Entity ID for the calling service provider. :return: True if encrypt cert exists in metadata, otherwise False. """ if sp_entity_id is not Non...
python
{ "resource": "" }
q36344
Entity._encrypt_assertion
train
def _encrypt_assertion(self, encrypt_cert, sp_entity_id, response, node_xpath=None): """ Encryption of assertions. :param encrypt_cert: Certificate to be used for encryption. :param sp_entity_id: Entity ID for the calling service provider. :param response: A s...
python
{ "resource": "" }
q36345
Entity._status_response
train
def _status_response(self, response_class, issuer, status, sign=False, sign_alg=None, digest_alg=None, **kwargs): """ Create a StatusResponse. :param response_class: Which subclass of StatusResponse that should be used :param issuer:...
python
{ "resource": "" }
q36346
Entity._parse_request
train
def _parse_request(self, enc_request, request_cls, service, binding): """Parse a Request :param enc_request: The request in its transport format :param request_cls: The type of requests I expect :param service: :param binding: Which binding that was used to transport the message...
python
{ "resource": "" }
q36347
Entity.create_error_response
train
def create_error_response(self, in_response_to, destination, info, sign=False, issuer=None, sign_alg=None, digest_alg=None, **kwargs): """ Create a error response. :param in_response_to: The identifier of the message this is a response ...
python
{ "resource": "" }
q36348
Entity.create_logout_request
train
def create_logout_request(self, destination, issuer_entity_id, subject_id=None, name_id=None, reason=None, expire=None, message_id=0, consent=None, extensions=None, sign=False, session_indexes=None, s...
python
{ "resource": "" }
q36349
Entity.create_logout_response
train
def create_logout_response(self, request, bindings=None, status=None, sign=False, issuer=None, sign_alg=None, digest_alg=None): """ Create a LogoutResponse. :param request: The request this is a response to :param bindings: Which bin...
python
{ "resource": "" }
q36350
Entity.create_artifact_resolve
train
def create_artifact_resolve(self, artifact, destination, sessid, consent=None, extensions=None, sign=False, sign_alg=None, digest_alg=None): """ Create a ArtifactResolve request :param artifact: :param destination: ...
python
{ "resource": "" }
q36351
Entity._parse_response
train
def _parse_response(self, xmlstr, response_cls, service, binding, outstanding_certs=None, **kwargs): """ Deal with a Response :param xmlstr: The response as a xml string :param response_cls: What type of response it is :param binding: What type of binding this me...
python
{ "resource": "" }
q36352
Entity.artifact2destination
train
def artifact2destination(self, artifact, descriptor): """ Translate an artifact into a receiver location :param artifact: The Base64 encoded SAML artifact :return: """ _art = base64.b64decode(artifact) assert _art[:2] == ARTIFACT_TYPECODE try: ...
python
{ "resource": "" }
q36353
Saml2Client.prepare_for_authenticate
train
def prepare_for_authenticate( self, entityid=None, relay_state="", binding=saml2.BINDING_HTTP_REDIRECT, vorg="", nameid_format=None, scoping=None, consent=None, extensions=None, sign=None, response_binding=saml2.BINDING_HTTP_POST, **kwargs): """ Makes all necessar...
python
{ "resource": "" }
q36354
Saml2Client.prepare_for_negotiated_authenticate
train
def prepare_for_negotiated_authenticate( self, entityid=None, relay_state="", binding=None, vorg="", nameid_format=None, scoping=None, consent=None, extensions=None, sign=None, response_binding=saml2.BINDING_HTTP_POST, **kwargs): """ Makes all necessary preparations for an au...
python
{ "resource": "" }
q36355
Saml2Client.is_logged_in
train
def is_logged_in(self, name_id): """ Check if user is in the cache :param name_id: The identifier of the subject """ identity = self.users.get_identity(name_id)[0] return bool(identity)
python
{ "resource": "" }
q36356
Saml2Client.handle_logout_response
train
def handle_logout_response(self, response, sign_alg=None, digest_alg=None): """ handles a Logout response :param response: A response.Response instance :return: 4-tuple of (session_id of the last sent logout request, response message, response headers and message) """ ...
python
{ "resource": "" }
q36357
Saml2Client.do_attribute_query
train
def do_attribute_query(self, entityid, subject_id, attribute=None, sp_name_qualifier=None, name_qualifier=None, nameid_format=None, real_id=None, consent=None, extensions=None, sign=False, binding=BINDING_SOAP, n...
python
{ "resource": "" }
q36358
before
train
def before(point): """ True if point datetime specification is before now. NOTE: If point is specified it is supposed to be in local time. Not UTC/GMT !! This is because that is what gmtime() expects. """ if not point: return True if isinstance(point, six.string_types): point =...
python
{ "resource": "" }
q36359
Client.phase2
train
def phase2(self, authn_request, rc_url, idp_entity_id, headers=None, sign=False, **kwargs): """ Doing the second phase of the ECP conversation, the conversation with the IdP happens. :param authn_request: The AuthenticationRequest :param rc_url: The assertion cons...
python
{ "resource": "" }
q36360
Client.operation
train
def operation(self, url, idp_entity_id, op, **opargs): """ This is the method that should be used by someone that wants to authenticate using SAML ECP :param url: The page that access is sought for :param idp_entity_id: The entity ID of the IdP that should be used fo...
python
{ "resource": "" }
q36361
Cache.subjects
train
def subjects(self): """ Return identifiers for all the subjects that are in the cache. :return: list of subject identifiers """ subj = [i["subject_id"] for i in self._cache.find()] return list(set(subj))
python
{ "resource": "" }
q36362
Cache.set
train
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 entit...
python
{ "resource": "" }
q36363
create_class_from_xml_string
train
def create_class_from_xml_string(target_class, xml_string): """Creates an instance of the target class from a string. :param target_class: The class which will be instantiated and populated with the contents of the XML. This class must have a c_tag and a c_namespace class variable. :param x...
python
{ "resource": "" }
q36364
create_class_from_element_tree
train
def create_class_from_element_tree(target_class, tree, namespace=None, tag=None): """Instantiates the class and populates members according to the tree. Note: Only use this function with classes that have c_namespace and c_tag class members. :param target_class: The ...
python
{ "resource": "" }
q36365
element_to_extension_element
train
def element_to_extension_element(element): """ Convert an element into a extension element :param element: The element instance :return: An extension element instance """ exel = ExtensionElement(element.c_tag, element.c_namespace, text=element.text) exel.attrib...
python
{ "resource": "" }
q36366
extension_element_to_element
train
def extension_element_to_element(extension_element, translation_functions, namespace=None): """ Convert an extension element to a normal element. In order to do this you need to have an idea of what type of element it is. Or rather which module it belongs to. :param ext...
python
{ "resource": "" }
q36367
extension_elements_to_elements
train
def extension_elements_to_elements(extension_elements, schemas): """ Create a list of elements each one matching one of the given extension elements. This is of course dependent on the access to schemas that describe the extension elements. :param extension_elements: The list of extension elements ...
python
{ "resource": "" }
q36368
ExtensionElement.loadd
train
def loadd(self, ava): """ expects a special set of keys """ if "attributes" in ava: for key, val in ava["attributes"].items(): self.attributes[key] = val try: self.tag = ava["tag"] except KeyError: if not self.tag: rai...
python
{ "resource": "" }
q36369
ExtensionContainer.find_extensions
train
def find_extensions(self, tag=None, namespace=None): """Searches extension elements for child nodes with the desired name. Returns a list of extension elements within this object whose tag and/or namespace match those passed in. To find all extensions in a particular namespace, specify ...
python
{ "resource": "" }
q36370
ExtensionContainer.extensions_as_elements
train
def extensions_as_elements(self, tag, schema): """ Return extensions that has the given tag and belongs to the given schema as native elements of that schema. :param tag: The tag of the element :param schema: Which schema the element should originate from :return: a list of nati...
python
{ "resource": "" }
q36371
SamlBase.register_prefix
train
def register_prefix(self, nspair): """ Register with ElementTree a set of namespaces :param nspair: A dictionary of prefixes and uris to use when constructing the text representation. :return: """ for prefix, uri in nspair.items(): try: ...
python
{ "resource": "" }
q36372
SamlBase.get_xml_string_with_self_contained_assertion_within_encrypted_assertion
train
def get_xml_string_with_self_contained_assertion_within_encrypted_assertion( self, assertion_tag): """ Makes a encrypted assertion only containing self contained namespaces. :param assertion_tag: Tag for the assertion to be transformed. :return: A new samlp.Resonse in string...
python
{ "resource": "" }
q36373
SamlBase.to_string
train
def to_string(self, nspair=None): """Converts the Saml object to a string containing XML. :param nspair: A dictionary of prefixes and uris to use when constructing the text representation. :return: String representation of the object """ if not nspair and self.c_ns_p...
python
{ "resource": "" }
q36374
SamlBase.keys
train
def keys(self): """ Return all the keys that represent possible attributes and children. :return: list of keys """ keys = ['text'] keys.extend([n for (n, t, r) in self.c_attributes.values()]) keys.extend([v[0] for v in self.c_children.values()]) return ke...
python
{ "resource": "" }
q36375
SamlBase.children_with_values
train
def children_with_values(self): """ Returns all children that has values :return: Possibly empty list of children. """ childs = [] for attribute in self._get_all_c_children_with_order(): member = getattr(self, attribute) if member is None or member == []:...
python
{ "resource": "" }
q36376
SamlBase.set_text
train
def set_text(self, val, base64encode=False): """ Sets the text property of this instance. :param val: The value of the text property :param base64encode: Whether the value should be base64encoded :return: The instance """ # print("set_text: %s" % (val,)) if isin...
python
{ "resource": "" }
q36377
SamlBase.child_class
train
def child_class(self, child): """ Return the class a child element should be an instance of :param child: The name of the child element :return: The class """ for prop, klassdef in self.c_children.values(): if child == prop: if isinstance(klassdef, li...
python
{ "resource": "" }
q36378
SamlBase.child_cardinality
train
def child_cardinality(self, child): """ Return the cardinality of a child element :param child: The name of the child element :return: The cardinality as a 2-tuple (min, max). The max value is either a number or the string "unbounded". The min value is always a number. ...
python
{ "resource": "" }
q36379
Cache.reset
train
def reset(self, subject_id, entity_id): """ Scrap the assertions received from a IdP or an AA about a special subject. :param subject_id: The subjects identifier :param entity_id: The identifier of the entity_id of the assertion :return: """ if not self._cache.se...
python
{ "resource": "" }
q36380
Population.add_information_about_person
train
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""" session_info = dict(session_info) name_id = session_info["name_id"] issuer = session_info.pop("issuer") ...
python
{ "resource": "" }
q36381
AuthnBroker.add
train
def add(self, spec, method, level=0, authn_authority="", reference=None): """ Adds a new authentication method. Assumes not more than one authentication method per AuthnContext specification. :param spec: What the authentication endpoint offers in the form of an Auth...
python
{ "resource": "" }
q36382
AuthnBroker.pick
train
def pick(self, req_authn_context=None): """ Given the authentication context find zero or more places where the user could be sent next. Ordered according to security level. :param req_authn_context: The requested context as an RequestedAuthnContext instance :return:...
python
{ "resource": "" }
q36383
load_pem_private_key
train
def load_pem_private_key(data, password): """Load RSA PEM certificate.""" key = _serialization.load_pem_private_key( data, password, _backends.default_backend()) return key
python
{ "resource": "" }
q36384
key_sign
train
def key_sign(rsakey, message, digest): """Sign the given message with the RSA key.""" padding = _asymmetric.padding.PKCS1v15() signature = rsakey.sign(message, padding, digest) return signature
python
{ "resource": "" }
q36385
key_verify
train
def key_verify(rsakey, signature, message, digest): """Verify the given signature with the RSA key.""" padding = _asymmetric.padding.PKCS1v15() if isinstance(rsakey, _asymmetric.rsa.RSAPrivateKey): rsakey = rsakey.public_key() try: rsakey.verify(signature, message, padding, digest) ...
python
{ "resource": "" }
q36386
Request.subject_id
train
def subject_id(self): """ The name of the subject can be in either of BaseID, NameID or EncryptedID :return: The identifier if there is one """ if "subject" in self.message.keys(): _subj = self.message.subject if "base_id" in _subj.keys() and _subj.base_...
python
{ "resource": "" }
q36387
to_dict
train
def to_dict(_dict, onts, mdb_safe=False): """ Convert a pysaml2 SAML2 message class instance into a basic dictionary format. The export interface. :param _dict: The pysaml2 metadata instance :param onts: List of schemas to use for the conversion :return: The converted information """ ...
python
{ "resource": "" }
q36388
_kwa
train
def _kwa(val, onts, mdb_safe=False): """ Key word argument conversion :param val: A dictionary :param onts: dictionary with schemas to use in the conversion schema namespase is the key in the dictionary :return: A converted dictionary """ if not mdb_safe: return dict([(k, fr...
python
{ "resource": "" }
q36389
SSO.redirect
train
def redirect(self): """ This is the HTTP-redirect endpoint """ logger.info("--- In SSO Redirect ---") saml_msg = self.unpack_redirect() try: _key = saml_msg["key"] saml_msg = IDP.ticket[_key] self.req_info = saml_msg["req_info"] del IDP.t...
python
{ "resource": "" }
q36390
SSO.post
train
def post(self): """ The HTTP-Post endpoint """ logger.info("--- In SSO POST ---") saml_msg = self.unpack_either() self.req_info = IDP.parse_authn_request( saml_msg["SAMLRequest"], BINDING_HTTP_POST) _req = self.req_info.message if self.user: ...
python
{ "resource": "" }
q36391
code
train
def code(item): """ Turn a NameID class instance into a quoted string of comma separated attribute,value pairs. The attribute names are replaced with digits. Depends on knowledge on the specific order of the attributes for the class that is used. :param item: The class instance :return: A q...
python
{ "resource": "" }
q36392
code_binary
train
def code_binary(item): """ Return a binary 'code' suitable for hashing. """ code_str = code(item) if isinstance(code_str, six.string_types): return code_str.encode('utf-8') return code_str
python
{ "resource": "" }
q36393
IdentDB.remove_remote
train
def remove_remote(self, name_id): """ Remove a NameID to userID mapping :param name_id: NameID instance """ _cn = code(name_id) _id = self.db[name_id.text] try: vals = self.db[_id].split(" ") vals.remove(_cn) self.db[_id] = " "...
python
{ "resource": "" }
q36394
IdentDB.find_nameid
train
def find_nameid(self, userid, **kwargs): """ Find a set of NameID's that matches the search criteria. :param userid: User id :param kwargs: The search filter a set of attribute/value pairs :return: a list of NameID instances """ res = [] try: ...
python
{ "resource": "" }
q36395
IdentDB.construct_nameid
train
def construct_nameid(self, userid, local_policy=None, sp_name_qualifier=None, name_id_policy=None, name_qualifier=""): """ Returns a name_id for the object. How the name_id is constructed depends on the context. :param local_policy: The policy t...
python
{ "resource": "" }
q36396
IdentDB.find_local_id
train
def find_local_id(self, name_id): """ Only find persistent IDs :param name_id: :return: """ try: return self.db[name_id.text] except KeyError: logger.debug("name: %s", name_id.text) #logger.debug("id sub keys: %s", self.subkey...
python
{ "resource": "" }
q36397
IdentDB.handle_manage_name_id_request
train
def handle_manage_name_id_request(self, name_id, new_id=None, new_encrypted_id="", terminate=""): """ Requests from the SP is about the SPProvidedID attribute. So this is about adding,replacing and removing said attribute. :param name_id: NameID ins...
python
{ "resource": "" }
q36398
Server.init_config
train
def init_config(self, stype="idp"): """ Remaining init of the server configuration :param stype: The type of Server ("idp"/"aa") """ if stype == "aa": return # subject information is stored in a database # default database is in memory which is OK in some se...
python
{ "resource": "" }
q36399
Server.parse_authn_request
train
def parse_authn_request(self, enc_request, binding=BINDING_HTTP_REDIRECT): """Parse a Authentication Request :param enc_request: The request in its transport format :param binding: Which binding that was used to transport the message to this entity. :return: A request instan...
python
{ "resource": "" }