Exemple #1
0
def loadRPC(request):
    username = request.session.get("username")
    passphrase = request.session.get("passphrase")
    rsa = request.session.get("rsa")

    if not username or not passphrase or not rsa:
        raise Exception("Not logged in")

    rpc = RPCCommunication()
    rpc.loadKey(username, passphrase, rsa)
    return rpc
Exemple #2
0
def login(request):
    username = request.GET.get("username")
    passphrase = request.GET.get("passphrase")

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

    rpc = RPCCommunication()
    try:
        rpc.loadUser(username, passphrase, existing=True)
    except:
        return HttpResponse("Invalid username or passphrase")

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

    return HttpResponse("Logged in successfully '%s'" % request.session.get("username"))
Exemple #3
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)
Exemple #4
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")