Move the assertion to within a encrypted_assertion
    :param response: The response with one assertion
    :return: The response but now with the assertion within an
        encrypted_assertion.
185445
def pre_encrypt_assertion(response):
    
    assertion = response.assertion
    response.assertion = None
    response.encrypted_assertion = EncryptedAssertion()
    if assertion is not None:
        if isinstance(assertion, list):
            response.encrypted_assertion.add_extension_elements(assertion)
        else:
            response.encrypted_assertion.add_extension_element(assertion)
    return response
392048
def _UpdateEtag(self, response):
    
    etag = response.headers.get('etag', self.etag)
    etag_updated = self.etag != etag
    self.etag = etag
    return etag_updated
1046288
def validate_response(public_key_server, status_code, body_bytes, headers):
    

    head_bytes = _generate_response_head_bytes(status_code, headers)
    bytes_signed = head_bytes + body_bytes
    signer = PKCS1_v1_5.pkcs1_15.new(public_key_server)
    digest = SHA256.new()
    digest.update(bytes_signed)
    signer.verify(digest, base64.b64decode(headers[_HEADER_SERVER_SIGNATURE]))
578452
def authenticate(self, req_data, identifier: Optional[str]=None,
                     signature: Optional[str]=None, threshold: Optional[int] = None,
                     verifier: Verifier=DidVerifier):
        
        to_serialize = {k: v for k, v in req_data.items()
                        if k not in self.excluded_from_signing}
        if req_data.get(f.SIG.nm) is None and \
                req_data.get(f.SIGS.nm) is None and \
                signature is None:
            raise MissingSignature
        if req_data.get(f.IDENTIFIER.nm) and (req_data.get(f.SIG.nm) or
                                              signature):
            try:
                # if not identifier:
                identifier = identifier or self._extract_identifier(req_data)

                # if not signature:
                signature = signature or self._extract_signature(req_data)

                signatures = {identifier: signature}
            except Exception as ex:
                if ex in (MissingSignature, EmptySignature, MissingIdentifier,
                          EmptyIdentifier):
                    ex = ex(req_data.get(f.IDENTIFIER.nm), req_data.get(f.SIG.nm))
                raise ex
        else:
            signatures = req_data.get(f.SIGS.nm, None)
        return self.authenticate_multi(to_serialize, signatures=signatures,
                                       threshold=threshold, verifier=verifier)
422373
def get_xml_string_with_self_contained_assertion_within_encrypted_assertion(
            self, assertion_tag):
        
        prefix_map = self.get_prefix_map(
            [self.encrypted_assertion._to_element_tree().find(assertion_tag)])

        tree = self._to_element_tree()

        self.set_prefixes(
            tree.find(
                self.encrypted_assertion._to_element_tree().tag).find(
                assertion_tag), prefix_map)

        return ElementTree.tostring(tree, encoding="UTF-8").decode('utf-8')
1183008
def assertion(func):
    """"""
    func = assertionmethod(func)
    setattr(AssertionBuilder, func.__name__, func)
    return func
972712
def _handle_response(response):
        

        if not str(response.status_code).startswith('2'):
            raise KucoinAPIException(response)
        try:
            res = response.json()

            if 'code' in res and res['code'] != "200000":
                raise KucoinAPIException(response)

            if 'success' in res and not res['success']:
                raise KucoinAPIException(response)

            # by default return full response
            # if it's a normal response we have a data attribute, return that
            if 'data' in res:
                res = res['data']
            return res
        except ValueError:
            raise KucoinRequestException('Invalid Response: %s' % response.text)
329059
def _deserialize(self, response):
        
        # Hacking response with initial status_code
        previous_status = response.status_code
        response.status_code = self.initial_status_code
        resource = self.get_outputs(response)
        response.status_code = previous_status

        # Hack for Storage or SQL, to workaround the bug in the Python generator
        if resource is None:
            previous_status = response.status_code
            for status_code_to_test in [200, 201]:
                try:
                    response.status_code = status_code_to_test
                    resource = self.get_outputs(response)
                except ClientException:
                    pass
                else:
                    return resource
                finally:
                    response.status_code = previous_status
        return resource
1124449
def swaggerize_response(response, op):
    
    response_spec = get_response_spec(response.status_int, op)
    bravado_core.response.validate_response(
        response_spec, op, PyramidSwaggerResponse(response))
1185591
def process_response(self, request, response):
        
        process = False

        # Don't do anything for unsecure requests, unless DEBUG is on
        if not self.allow_http and not request.is_secure():
            return response

        if response.status_code == UNAUTHORIZED:
            pass
        elif response.status_code == FOUND:
            location = urllib_parse.urlparse(response['Location'])
            if location.path != settings.LOGIN_URL:
                # If it wasn't a redirect to the login page, we don't touch it.
                return response
            elif not self.is_agent_a_robot(request):
                # We don't touch requests made in order to be shown to humans.
                return response

        realm = getattr(settings, 'BASIC_AUTH_REALM', request.META.get('HTTP_HOST', 'restricted'))
        
        if response.status_code == FOUND:
            response = self.unauthorized_view(request)

        authenticate = response.get('WWW-Authenticate', None)
        if authenticate:
            authenticate = 'Basic realm="%s", %s' % (realm, authenticate)
        else:
            authenticate = 'Basic realm="%s"' % realm
        response['WWW-Authenticate'] = authenticate

        return response
42289
public int verify(Request request, Response response) {
		String authValue = request.getHeaders().getValues("Authorization");
		log.debug("Auth header value is: "+ authValue);
		if (authValue == null) {
			return Verifier.RESULT_MISSING;
		}
		String[] tokenValues = authValue.split(" ");
		if (tokenValues.length < 2) {
			return Verifier.RESULT_MISSING;
		}

		if (!"Bearer".equals(tokenValues[0])) {
			return Verifier.RESULT_INVALID;
		}
		String token = tokenValues[1];

		log.debug("Token: "+ token);
		return checkToken(token);
	}
995720
def _wrap_response(self, status=None, **kwargs):
        
        kwargs['status'] = status if status is not None else self._status.OK
        return kwargs
688270
def normalize_response(response, request=None):
    
    if isinstance(response, Response):
        return response
    if request is not None and not isinstance(request, Request):
        request = normalize_request(request)

    for normalizer in RESPONSE_NORMALIZERS:
        try:
            return normalizer(response, request=request)
        except TypeError:
            continue

    raise ValueError("Unable to normalize the provided response")
1276732
def sign_assertion(self, statement, **kwargs):
        
        return self.sign_statement(
                statement, class_name(saml.Assertion()), **kwargs)
1146983
def _raise_or_extract(self, response):
        

        try:
            data = response.json()
        except ValueError:
            raise JoeException("The server responded with an unexpected format ({}). Is the API url correct?". format(response.status_code))

        try:
            if response.ok:
                return data['data']
            else:
                error = data['errors'][0]
                raise ApiError(error)
        except (KeyError, TypeError):
            raise JoeException("Unexpected data ({}). Is the API url correct?". format(response.status_code))
701136
def _validation(response):
    
    h = hashlib.sha256(response.key_authorization.encode("utf-8"))
    return b64encode(h.digest()).decode()
464370
def sign_assertion_using_xmlsec(self, statement, **kwargs):
        
        return self.sign_statement(
                statement, class_name(saml.Assertion()), **kwargs)