Exemplo n.º 1
0
def register(request):
    output = ""
    username = request.GET.get("username")
    passphrase = request.GET.get("passphrase")

    if not username or not passphrase:
        return HttpResponse("No username/passphrase")

    output += "<p>Generating Key</p>"
    rpc = RPCCommunication()
    rpc.loadUser(username, passphrase)

    registeruser = rpc.registerUser()
    output += "<p>Register User: %s</p>" % registeruser
    if not registeruser:
        return HttpResponse("Username already taken")

    output += "<p>Register Key: %s</p>" % rpc.registerKey()

    request.session["username"] = username
    request.session["passphrase"] = passphrase
    request.session["rsa"] = rpc.exportKey()

    output += "<p>Registered User: '******' with passphrase '%s'</p>" % (username, passphrase)

    return HttpResponse(output)
Exemplo n.º 2
0
from rpccommunication import RPCCommunication

rpc = RPCCommunication()
rpc.loadUser("username", "passphrase")

print rpc.getUser("username")
print rpc.registerUser()
print rpc.getUser("username")
print rpc.registerKey()
print rpc.addData("somehash", "123")
poll = rpc.poll()
print poll #should print False
if not poll:
  poll = ''
poll += "abc:somehash\n"
print rpc.updateFile(poll)
print rpc.getData("somehash")
print rpc.removeData("somehash")
print rpc.getData("somehash") #should print False
print rpc.poll()

raw_input("Press enter to quit\n")