Construct the JWKS document (served at /jwks).
        :type context: satosa.context.Context
        :rtype: oic.utils.http_util.Response

        :param context: the current context
        :return: HTTP response to the client
165323
def jwks(self, context):
        
        return Response(json.dumps(self.provider.jwks), content="application/json")
25989
private String getBearerToken(HttpConnectionInterceptorContext context) {
        final AtomicReference<String> iamTokenResponse = new AtomicReference<String>();
        boolean result = super.requestCookie(context, iamServerUrl, iamTokenRequestBody,
                "application/x-www-form-urlencoded", "application/json",
                new StoreBearerCallable(iamTokenResponse));
        if (result) {
            return iamTokenResponse.get();
        } else {
            return null;
        }
    }
624655
def render_to_response(self, context):
        ""
        return http.HttpResponse(
            self.render_template(context),
            content_type=self.mimetype)
975154
def render_to_response(self, context, indent=None):
        ""
        return self.get_json_response(self.convert_context_to_json(context, indent=indent))
645311
def make_request_with_headers(context):
    
    headers = row_table(context)
    requests.get(context.mock_url, headers=headers)
437914
def as_json(context):
    """"""
    info = {
        'info': cgi.escape(pprint.pformat(context.context)),
    }
    return Response(content_type='application/json', body=json.dumps(info))
629698
def do_response(self, response_args=None, request=None, **kwargs):
        

        links = [Link(href=h, rel=OIC_ISSUER) for h in kwargs['hrefs']]

        _response = JRD(subject=kwargs['subject'], links=links)

        info = {
            'response': _response.to_json(),
            'http_headers': [('Content-type', 'application/json')]
        }

        return info
828901
def response_hook(self, response, **kwargs) -> HTMLResponse:
        
        if not response.encoding:
            response.encoding = DEFAULT_ENCODING
        return HTMLResponse._from_response(response, self)
201713
def auth(context, request):
    

    if ploneapi.user.is_anonymous():
        request.response.setStatus(401)
        request.response.setHeader('WWW-Authenticate',
                                   'basic realm="JSONAPI AUTH"', 1)

    logger.info("*** BASIC AUTHENTICATE ***")
    return {}
1256327
def context(src):
    
    try:
        yield
    except Exception:
        etype, err, tb = sys.exc_info()
        msg = 'An error occurred with source id=%s. Error: %s'
        msg %= (src.source_id, err)
        raise_(etype, msg, tb)
1177115
def render_to_response(self, context, **response_kwargs):
        
        # is this a select2 format response?
        if self.request.GET.get('_format', 'html') == 'select2':

            results = []
            for obj in context['object_list']:
                result = None
                if hasattr(obj, 'as_select2'):
                    result = obj.as_select2()

                if not result:
                    result = dict(id=obj.pk, text="%s" % obj)

                results.append(result)

            json_data = dict(results=results, err='nil', more=context['page_obj'].has_next())
            return JsonResponse(json_data)
        # otherwise, return normally
        else:
            return super(SmartListView, self).render_to_response(context)
700891
def _get_tls_context(self) -> ssl.SSLContext:
        
        if self.tls_context is not None:
            context = self.tls_context
        else:
            # SERVER_AUTH is what we want for a client side socket
            context = ssl.create_default_context(ssl.Purpose.SERVER_AUTH)
            context.check_hostname = bool(self.validate_certs)
            if self.validate_certs:
                context.verify_mode = ssl.CERT_REQUIRED
            else:
                context.verify_mode = ssl.CERT_NONE

            if self.cert_bundle is not None:
                context.load_verify_locations(cafile=self.cert_bundle)

            if self.client_cert is not None:
                context.load_cert_chain(self.client_cert, keyfile=self.client_key)

        return context
287909
def build_response(headers: Headers, key: str) -> None:
    
    headers["Upgrade"] = "websocket"
    headers["Connection"] = "Upgrade"
    headers["Sec-WebSocket-Accept"] = accept(key)
44453
def _handle_authn_request(self, context):
        
        request = urlencode(context.request)
        satosa_logging(logger, logging.DEBUG, "Authn req from client: {}".format(request),
                       context.state)

        try:
            authn_req = self.provider.parse_authentication_request(request)
        except InvalidAuthenticationRequest as e:
            satosa_logging(logger, logging.ERROR, "Error in authn req: {}".format(str(e)),
                           context.state)
            error_url = e.to_error_url()

            if error_url:
                return SeeOther(error_url)
            else:
                return BadRequest("Something went wrong: {}".format(str(e)))

        client_id = authn_req["client_id"]
        context.state[self.name] = {"oidc_request": request}
        subject_type = self.provider.clients[client_id].get("subject_type", "pairwise")
        client_name = self.provider.clients[client_id].get("client_name")
        if client_name:
            # TODO should process client names for all languages, see OIDC Registration, Section 2.1
            requester_name = [{"lang": "en", "text": client_name}]
        else:
            requester_name = None
        internal_req = InternalData(
            subject_type=subject_type,
            requester=client_id,
            requester_name=requester_name,
        )

        internal_req.attributes = self.converter.to_internal_filter(
            "openid", self._get_approved_attributes(self.provider.configuration_information["claims_supported"],
                                                    authn_req))
        return internal_req
1049158
def renderHTTP(self, context):
        
        request = IRequest(context)
        if request.isSecure():
            renderer = self.wrappedResource
        else:
            renderer = _SecureWrapper(self.urlGenerator, self.wrappedResource)
        return renderer.renderHTTP(context)
85628
def render_json_response(self, context, status=200):
        
        json_context = json.dumps(context, cls=self.json_encoder_class)

        return HttpResponse(json_context,
                            content_type=self.get_content_type(),
                            status=status)
232907
def build_context context
      # Skip if no format defined
      return unless @format[:context].is_a? Hash

      # Call the instance's method to get hash context
      return unless context.is_a? Hash

      # Build each context part
      return @format[:context].collect do |key, format|
        sprintf(format, context[key])
      end.join

    rescue KeyError, ArgumentError => ex
      return "[context: #{ex.message}]"
    end