Logo Search packages:      
Sourcecode: python-openid version File versions

def openid::consumer::consumer::GenericConsumer::_negotiateAssociation (   self,
  endpoint 
) [private]

Make association requests to the server, attempting to
create a new association.

@returns: a new association object

@rtype: openid.association.Association

@raises Exception: errors that the fetcher might raise. These are
    intended to be propagated up to the library's entrance point.

Definition at line 1082 of file consumer.py.

01082                                              :
        """Make association requests to the server, attempting to
        create a new association.

        @returns: a new association object

        @rtype: openid.association.Association

        @raises Exception: errors that the fetcher might raise. These are
            intended to be propagated up to the library's entrance point.
        """
        # Get our preferred session/association type from the negotiatior.
        assoc_type, session_type = self.negotiator.getAllowedType()

        try:
            assoc = self._requestAssociation(
                endpoint, assoc_type, session_type)
        except ServerError, why:
            # Any error message whose code is not 'unsupported-type'
            # should be considered a total failure.
            if why.error_code != 'unsupported-type' or \
                   why.message.isOpenID1():
                oidutil.log(
                    'Server error when requesting an association from %r: %s'
                    % (endpoint.server_url, why.error_text))
                return None

            # The server didn't like the association/session type
            # that we sent, and it sent us back a message that
            # might tell us how to handle it.
            oidutil.log(
                'Unsupported association type %s: %s' % (assoc_type,
                                                         why.error_text,))

            # Extract the session_type and assoc_type from the
            # error message
            assoc_type = why.message.getArg(OPENID_NS, 'assoc_type')
            session_type = why.message.getArg(OPENID_NS, 'session_type')

            if assoc_type is None or session_type is None:
                oidutil.log('Server responded with unsupported association '
                            'session but did not supply a fallback.')
                return None
            elif not self.negotiator.isAllowed(assoc_type, session_type):
                fmt = ('Server sent unsupported session/association type: '
                       'session_type=%s, assoc_type=%s')
                oidutil.log(fmt % (session_type, assoc_type))
                return None
            else:
                # Attempt to create an association from the assoc_type
                # and session_type that the server told us it
                # supported.
                try:
                    assoc = self._requestAssociation(
                        endpoint, assoc_type, session_type)
                except ServerError, why:
                    # Do not keep trying, since it rejected the
                    # association type that it told us to use.
                    oidutil.log('Server %s refused its suggested association '
                                'type: session_type=%s, assoc_type=%s'
                                % (endpoint.server_url, session_type,
                                   assoc_type))
                    return None
                else:
                    return assoc
        else:
            return assoc

    def _requestAssociation(self, endpoint, assoc_type, session_type):


Generated by  Doxygen 1.6.0   Back to index