src/fedoidcmsg/entity.py
def add_sms_spec_to_request(self, req, federation='', loes=None,
                                context='', url=''):
        """
        Add signed metadata statements to the request

        :param req: The request so far
        :param federation: If only signed metadata statements from a specific
            set of federations should be included this is the set.
        :param loes: - not used -
        :param context: What kind of request/response it is: 'registration',
            'discovery' or 'response'. The later being registration response.
        :param url: Just for testing !!
        :return: A possibly augmented request.
        """
        # fetch the signed metadata statement collection

        if federation:
            if not isinstance(federation, list):
                federation = [federation]

        if not url:
            url = "{}/getms/{}/{}".format(self.mds_service, context,
                                          quote_plus(self.entity_id))

        http_resp = self.httpcli(method='GET', url=url, verify=self.verify_ssl)

        if http_resp.status_code >= 400:
            raise ConnectionError('HTTP Error: {}'.format(http_resp.text))

        # verify signature on response
        msg = JsonWebToken().from_jwt(http_resp.text,
                                      keyjar=self.jwks_bundle[self.mds_owner])

        if msg['iss'] != self.mds_owner:
            raise KeyError('Wrong iss')

        if federation:
            _ms = dict(
                [(fo, _ms) for fo, _ms in msg.items() if fo in federation])
        else:
            _ms = msg.extra()
            try:
                del _ms['kid']
            except KeyError:
                pass

        _sms = {}
        _smsu = {}
        for fo, item in _ms.items():
            if item.startswith('https://') or item.startswith('http://'):
                _smsu[fo] = item
            else:
                _sms[fo] = item

        if _sms:
            req.update({'metadata_statements': _sms})
        if _smsu:
            req.update({'metadata_statement_uris': _smsu})

        return req
def add_sms_spec_to_request(self, req, federation='', loes=None,
                                context='', url=''):
        """
        Add signed metadata statements to the request

        :param req: The request so far
        :param federation: If only signed metadata statements from a specific
            set of federations should be included this is the set.
        :param loes: - not used -
        :param context: What kind of request/response it is: 'registration',
            'discovery' or 'response'. The later being registration response.
        :param url: Just for testing !!
        :return: A possibly augmented request.
        """
        # fetch the signed metadata statement collection

        if federation:
            if not isinstance(federation, list):
                federation = [federation]

        if not url:
            url = "{}/getms/{}/{}".format(self.mds_service, context,
                                          quote_plus(self.entity_id))

        http_resp = self.httpcli(method='GET', url=url, verify=self.verify_ssl)

        if http_resp.status_code >= 400:
            raise ConnectionError('HTTP Error: {}'.format(http_resp.text))

        # verify signature on response
        msg = JsonWebToken().from_jwt(http_resp.text,
                                      keyjar=self.jwks_bundle[self.mds_owner])

        if msg['iss'] != self.mds_owner:
            raise KeyError('Wrong iss')

        if federation:
            _ms = dict(
                [(fo, _ms) for fo, _ms in msg.items() if fo in federation])
        else:
            _ms = msg.extra()
            try:
                del _ms['kid']
            except KeyError:
                pass

        _sms = {}
        _smsu = {}
        for fo, item in _ms.items():
            if item.startswith('https://') or item.startswith('http://'):
                _smsu[fo] = item
            else:
                _sms[fo] = item

        if _sms:
            req.update({'metadata_statements': _sms})
        if _smsu:
            req.update({'metadata_statement_uris': _smsu})

        return req
Add signed metadata statements to the request

        :param req: The request so far
        :param federation: If only signed metadata statements from a specific
            set of federations should be included this is the set.
        :param loes: - not used -
        :param context: What kind of request/response it is: 'registration',
            'discovery' or 'response'. The later being registration response.
        :param url: Just for testing !!
        :return: A possibly augmented request.