'Create a response. A layer of indirection.
:param in_response_to: The session identifier of the request
:param consumer_url: The URL which should receive the response
:param sp_entity_id: The entity identifier of the SP
:param identity: A dictionary with attributes and values that are
expected to be the bases for the assertion in the response.
:param name_id: The identifier of the subject
:param status: The status of the response
:param authn: A dictionary containing information about the
authn context.
:param issuer: The issuer of the response
:param sign_assertion: Whether the assertion should be signed or not
:param sign_response: Whether the response should be signed or not
:param best_effort: Even if not the SPs demands can be met send a
response.
:return: A response instance'

def _authn_response(self, in_response_to, consumer_url, sp_entity_id, identity=None, name_id=None, status=None, authn=None, issuer=None, policy=None, sign_assertion=False, sign_response=False, best_effort=False, encrypt_assertion=False, encrypt_cert=None, authn_statement=None):

    to_sign = []
    args = {}
    _issuer = self._issuer(issuer)
    ast = Assertion(identity)
    ast.acs = self.config.getattr('attribute_converters', 'idp')
    if (policy is None):
        policy = Policy()
    try:
        ast.apply_policy(sp_entity_id, policy, self.metadata)
    except MissingValue as exc:
        if (not best_effort):
            return self.create_error_response(in_response_to, consumer_url, exc, sign_response)
    if authn:
        authn_args = dict([(AUTHN_DICT_MAP[k], v) for (k, v) in authn.items() if (k in AUTHN_DICT_MAP)])
        assertion = ast.construct(sp_entity_id, in_response_to, consumer_url, name_id, self.config.attribute_converters, policy, issuer=_issuer, **authn_args)
    elif authn_statement:
        assertion = ast.construct(sp_entity_id, in_response_to, consumer_url, name_id, self.config.attribute_converters, policy, issuer=_issuer, authn_statem=authn_statement)
    else:
        assertion = ast.construct(sp_entity_id, in_response_to, consumer_url, name_id, self.config.attribute_converters, policy, issuer=_issuer)
    if ((sign_assertion is not None) and sign_assertion):
        assertion.signature = pre_signature_part(assertion.id, self.sec.my_cert, 1)
        to_sign = [(class_name(assertion), assertion.id)]
    args['assertion'] = assertion
    if (self.support_AssertionIDRequest() or self.support_AuthnQuery()):
        self.session_db.store_assertion(assertion, to_sign)
    return self._response(in_response_to, consumer_url, status, issuer, sign_response, to_sign, encrypt_assertion=encrypt_assertion, encrypt_cert=encrypt_cert, **args)
