def encodeToKVForm(self):
        """Encode a response in key-value colon/newline format.

        This is a machine-readable format used to respond to messages which
        came directly from the consumer and not through the user agent.

        @see: OpenID Specs,
           U{Key-Value Colon/Newline format<http://openid.net/specs.bml#keyvalue>}

        @returntype: str
        """
        return kvform.dictToKV(self.fields)
    def encodeToKVForm(self):
        """Encode a response in key-value colon/newline format.

        This is a machine-readable format used to respond to messages which
        came directly from the consumer and not through the user agent.

        @see: OpenID Specs,
           U{Key-Value Colon/Newline format<http://openid.net/specs.bml#keyvalue>}

        @returntype: str
        """
        return kvform.dictToKV(self.fields)
Example #3
0
    def runTest(self):
        # Convert KVForm to dict
        d = kvform.kvToDict(self.kvform)

        # make sure it parses to expected dict
        self.failUnlessEqual(self.dict, d)

        # Check to make sure we got the expected number of warnings
        self.checkWarnings(self.expected_warnings)

        # Convert back to KVForm and round-trip back to dict to make
        # sure that *** dict -> kv -> dict is identity. ***
        kv = kvform.dictToKV(d)
        d2 = kvform.kvToDict(kv)
        self.failUnlessEqual(d, d2)
Example #4
0
    def runTest(self):
        # Convert KVForm to dict
        d = kvform.kvToDict(self.kvform)

        # make sure it parses to expected dict
        self.failUnlessEqual(self.dict, d)

        # Check to make sure we got the expected number of warnings
        self.checkWarnings(self.expected_warnings)

        # Convert back to KVForm and round-trip back to dict to make
        # sure that *** dict -> kv -> dict is identity. ***
        kv = kvform.dictToKV(d)
        d2 = kvform.kvToDict(kv)
        self.failUnlessEqual(d, d2)
Example #5
0
    def runTest(self):
        for kv_data, result, expected_warnings in kvdict_cases:
            # Convert KVForm to dict
            with LogCapture() as logbook:
                d = kvform.kvToDict(kv_data)

            # make sure it parses to expected dict
            self.assertEqual(d, result)

            # Check to make sure we got the expected number of warnings
            self.assertEqual(len(logbook.records), expected_warnings)

            # Convert back to KVForm and round-trip back to dict to make
            # sure that *** dict -> kv -> dict is identity. ***
            kv = kvform.dictToKV(d)
            d2 = kvform.kvToDict(kv)
            self.assertEqual(d, d2)
Example #6
0
    def runTest(self):
        for kv_data, result, expected_warnings in kvdict_cases:
            # Convert KVForm to dict
            with LogCapture() as logbook:
                d = kvform.kvToDict(kv_data)

            # make sure it parses to expected dict
            self.assertEqual(d, result)

            # Check to make sure we got the expected number of warnings
            self.assertEqual(len(logbook.records), expected_warnings)

            # Convert back to KVForm and round-trip back to dict to make
            # sure that *** dict -> kv -> dict is identity. ***
            kv = kvform.dictToKV(d)
            d2 = kvform.kvToDict(kv)
            self.assertEqual(d, d2)
Example #7
0
def associate(qs, assoc_secret, assoc_handle):
    """Do the server's half of the associate call, using the given
    secret and handle."""
    q = parseQuery(qs)
    assert q['openid.mode'] == 'associate'
    assert q['openid.assoc_type'] == 'HMAC-SHA1'
    reply_dict = {
        'assoc_type':'HMAC-SHA1',
        'assoc_handle':assoc_handle,
        'expires_in':'600',
        }

    if q.get('openid.session_type') == 'DH-SHA1':
        assert len(q) == 6 or len(q) == 4
        session = DiffieHellmanServerSession.fromQuery(q)
        reply_dict['session_type'] = 'DH-SHA1'
    else:
        assert len(q) == 2
        session = PlainTextServerSession.fromQuery(q)

    reply_dict.update(session.answer(assoc_secret))
    return kvform.dictToKV(reply_dict)
Example #8
0
 def toKVForm(self):
     """Generate a KVForm string that contains the parameters in
     this message. This will fail if the message contains arguments
     outside of the 'openid.' prefix.
     """
     return kvform.dictToKV(self.toArgs())
Example #9
0
 def _accept(request):
     """ Accept response """
     return HttpResponse(dictToKV({'mode': 'accept'}))
Example #10
0
 def _reject(request, error):
     """ Reject response """
     return HttpResponse(dictToKV({'mode': 'reject', 'reason': error}))
Example #11
0
 def toKVForm(self):
     """Generate a KVForm string that contains the parameters in
     this message. This will fail if the message contains arguments
     outside of the 'openid.' prefix.
     """
     return kvform.dictToKV(self.toArgs())
Example #12
0
 def _accept(request):
     """ Accept response """
     return HttpResponse(dictToKV({'mode': 'accept'}))
Example #13
0
 def _reject(request, error):
     """ Reject response """
     return HttpResponse(dictToKV({'mode': 'reject', 'reason': error}))