예제 #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
    else:
        (exc_val, msg) = info

    if msg:
        status_msg = samlp.StatusMessage(text=msg)
    else:
        status_msg = None

    status = samlp.Status(
        status_message=status_msg,
        status_code=samlp.StatusCode(
            value=samlp.STATUS_RESPONDER,
            status_code=samlp.StatusCode(
                value=exc_val)))
    return status
예제 #2
0
    def create_logout_response(self,
                               idp_entity_id,
                               request_id,
                               status_code,
                               binding=BINDING_HTTP_REDIRECT):
        """ 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_services(idp_entity_id,
                                                    "idpsso",
                                                    binding=binding)
        destination = destinations(srvs)[0]

        status = samlp.Status(status_code=samlp.StatusCode(value=status_code))

        return destination, self._message(LogoutResponse,
                                          destination,
                                          in_response_to=request_id,
                                          status=status)
예제 #3
0
    def make_logout_response(self,
                             idp_entity_id,
                             request_id,
                             status_code,
                             binding=BINDING_HTTP_REDIRECT):
        """ 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
        """

        destination = self.config.single_logout_services(
            idp_entity_id, binding)[0]

        status = samlp.Status(status_code=samlp.StatusCode(value=status_code))

        response = samlp.LogoutResponse(
            id=sid(),
            version=VERSION,
            issue_instant=instant(),
            destination=destination,
            issuer=self._issuer(),
            in_response_to=request_id,
            status=status,
        )

        return response, destination
예제 #4
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)
예제 #5
0
 def testAccessors(self):
     """Test for StatusCode accessors"""
     self.status_code.value = samlp.STATUS_RESPONDER
     self.status_code.status_code = samlp.StatusCode(
         value=samlp.STATUS_REQUEST_DENIED)
     print self.status_code.__dict__
     new_status_code = samlp.status_code_from_string(self.status_code.to_string())
     assert new_status_code.value == samlp.STATUS_RESPONDER
     assert new_status_code.status_code.value == \
                              samlp.STATUS_REQUEST_DENIED
예제 #6
0
 def createLogoutResponse(self, logout_request_id, status_code):
     now = saml2.utils.getDateAndTime(time.time())
     self.response = samlp.LogoutResponse(id=saml2.utils.createID(),
                                          version=saml2.V2,
                                          issue_instant=now,
                                          in_response_to=logout_request_id)
     self.response.issuer = saml.Issuer(text=self.config.get('issuer_name'))
     self.response.status = samlp.Status()
     self.response.status.status_code = samlp.StatusCode(status_code)
     self.response.signature = self._get_signature()
     return self.response
예제 #7
0
def error_status_factory(info):
    if isinstance(info, Exception):
        try:
            exc_val = EXCEPTION2STATUS[info.__class__]
        except KeyError:
            exc_val = samlp.STATUS_AUTHN_FAILED
        msg = info.args[0]
        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
예제 #8
0
파일: idp.py 프로젝트: weiqiLee/keystone
    def _create_status(self):
        """Create an object that represents a SAML Status.

        <ns0:Status xmlns:ns0="urn:oasis:names:tc:SAML:2.0:protocol">
            <ns0:StatusCode
              Value="urn:oasis:names:tc:SAML:2.0:status:Success" />
        </ns0:Status>

        :returns: XML <Status> object

        """
        status = samlp.Status()
        status_code = samlp.StatusCode()
        status_code.value = samlp.STATUS_SUCCESS
        status_code.set_text('')
        status.status_code = status_code
        return status
예제 #9
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
예제 #10
0
파일: s_utils.py 프로젝트: dolph/pysaml2
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)))
예제 #11
0
파일: s_utils.py 프로젝트: dolph/pysaml2
def success_status_factory():
    return samlp.Status(status_code=samlp.StatusCode(
        value=samlp.STATUS_SUCCESS))
예제 #12
0
 def setup_class(self):
     self.status_code = samlp.StatusCode()