Exemplo n.º 1
0
def error_status_factory(info):
    if isinstance(info, Exception):
        try:
            exc_val = EXCEPTION2STATUS[info.__class__]
        except KeyError:
            exc_val = samlp.STATUS_AUTHN_FAILED
        try:
            msg = info.args[0]
        except IndexError:
            msg = "%s" % info
        status = samlp.Status(
            status_message=samlp.StatusMessage(text=msg),
            status_code=samlp.StatusCode(
                value=samlp.STATUS_RESPONDER,
                status_code=samlp.StatusCode(
                    value=exc_val)))
    else:
        (errcode, text) = info
        status = samlp.Status(
            status_message=samlp.StatusMessage(text=text),
            status_code=samlp.StatusCode(
                value=samlp.STATUS_RESPONDER,
                status_code=samlp.StatusCode(value=errcode)))
        
    return status
Exemplo n.º 2
0
 def testAccessors(self):
     """Test for Status accessors"""
     self.status.status_code = samlp.StatusCode()
     self.status.status_message = samlp.StatusMessage()
     self.status.status_detail = samlp.StatusDetail()
     new_status = samlp.status_from_string(self.status.to_string())
     assert isinstance(new_status.status_code, samlp.StatusCode)
     assert isinstance(new_status.status_message, samlp.StatusMessage)
     assert isinstance(new_status.status_detail, samlp.StatusDetail)
Exemplo n.º 3
0
def test_nsprefix():
    status_message = samlp.StatusMessage()
    status_message.text = "OK"

    txt = "%s" % status_message

    assert "ns0:StatusMessage" in txt

    status_message.register_prefix({
        "saml2": saml.NAMESPACE,
        "saml2p": samlp.NAMESPACE
    })

    txt = "%s" % status_message

    assert "saml2p:StatusMessage" in txt
Exemplo n.º 4
0
    def make_logout_response(self,
                             idp_entity_id,
                             request_id,
                             status_code,
                             binding=BINDING_HTTP_REDIRECT):
        """ 
        XXX There were issues with an explicit closing tag on 
        StatusCode. Check wether we still need this. XXX
        Constructs a LogoutResponse

        :param idp_entity_id: The entityid of the IdP that want to do the
            logout
        :param request_id: The Id of the request we are replying to
        :param status_code: The status code of the response
        :param binding: The type of binding that will be used for the response
        :return: A LogoutResponse instance
        """
        srvs = self.metadata.single_logout_service(idp_entity_id, binding,
                                                   "idpsso")

        destination = destinations(srvs)[0]
        logger.info("destination to provider: %s" % destination)

        status = samlp.Status(
            status_code=samlp.StatusCode(value=status_code, text='\n'),
            status_message=samlp.StatusMessage(text='logout success'))

        response = samlp.LogoutResponse(
            id=sid(),
            version=VERSION,
            issue_instant=instant(),
            destination=destination,
            issuer=saml.Issuer(text=self.config.entityid,
                               format=saml.NAMEID_FORMAT_ENTITY),
            in_response_to=request_id,
            status=status,
        )

        return response, destination
Exemplo n.º 5
0
def status_message_factory(message, code, fro=samlp.STATUS_RESPONDER):
    return samlp.Status(status_message=samlp.StatusMessage(text=message),
                        status_code=samlp.StatusCode(
                            value=fro,
                            status_code=samlp.StatusCode(value=code)))
Exemplo n.º 6
0
 def setup_class(self):
     self.status_message = samlp.StatusMessage()