Exemplo n.º 1
0
 def _setUpDH(self):
     sess, args = \
                 self.consumer._createAssociateRequest(self.server_url)
     server_sess = DiffieHellmanServerSession.fromQuery(args)
     server_resp = server_sess.answer(self.secret)
     server_resp['assoc_type'] = 'HMAC-SHA1'
     server_resp['assoc_handle'] = 'handle'
     server_resp['expires_in'] = '1000'
     server_resp['session_type'] = 'DH-SHA1'
     return sess, server_resp
Exemplo n.º 2
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)