Exemple #1
0
def post_handler(environ):

    query = ht.parse_post_request(environ)

    timestamp = ht.convert_int(ht.get_required(query, 'timestamp'), 'timestamp')
    node_name = ht.get_required(query, 'node_name')
    group_id = ht.get_required(query, 'group_id')
    owner_id = ht.get_required(query, 'owner_id')
    new_size = ht.convert_int(ht.get_optional(query, 'new_size'), 'new_size')
    public_key_hash = ht.get_required(query, 'public_key_hash')
    signature = ht.get_required(query, 'signature')

    conn = db.connect(config.db_path)
    try:
        c = db.cursor(conn)
        
        db.change_max_post_size(c,
                timestamp, node_name, group_id, owner_id, new_size,
                public_key_hash, signature)
        db.commit(conn)

        raise ht.ok_json({'status' : 'ok'})

    except ex.SqueakException as e:
        raise ht.convert_squeak_exception(e)

    finally:
        db.close(conn)
Exemple #2
0
def delete_handler(environ):

    query = ht.parse_post_request(environ)

    timestamp = ht.convert_int(ht.get_required(query, 'timestamp'), 'timestamp')
    node_name = ht.get_required(query, 'node_name')
    user_id = ht.get_required(query, 'user_id')
    from_user_key_hash = ht.get_required(query, 'from_user_key_hash')
    public_key_hash = ht.get_required(query, 'public_key_hash')
    signature = ht.get_required(query, 'signature')
    
    conn = db.connect(config.db_path)
    try:
        c = db.cursor(conn)
        db.delete_message_access(c,
                timestamp, node_name, user_id, from_user_key_hash, public_key_hash, signature)
        db.commit(conn)

        raise ht.ok_json({'status' : 'ok'})

    except ex.SqueakException as e:
        raise ht.convert_squeak_exception(e)

    finally:
        db.close(conn)
Exemple #3
0
def post_handler(environ):

    query = ht.parse_post_request(environ)

    timestamp = ht.convert_int(ht.get_required(query, "timestamp"), "timestamp")
    node_name = ht.get_required(query, "node_name")
    group_id = ht.get_required(query, "group_id")
    owner_id = ht.get_required(query, "owner_id")
    key_use = ht.get_required(query, "key_use")
    key_type = ht.get_optional(query, "key_type")
    pub_key = ht.get_optional(query, "pub_key")
    public_key_hash = ht.get_required(query, "public_key_hash")
    signature = ht.get_required(query, "signature")

    conn = db.connect(config.db_path)
    try:
        c = db.cursor(conn)
        db.change_group_key(
            c, timestamp, node_name, group_id, owner_id, key_use, key_type, pub_key, public_key_hash, signature
        )
        db.commit(conn)

        raise ht.ok_json({"status": "ok"})

    except ex.SqueakException as e:
        raise ht.convert_squeak_exception(e)

    finally:
        db.close(conn)
Exemple #4
0
def delete_handler(environ):

    query = ht.parse_post_request(environ)

    timestamp = ht.convert_int(ht.get_required(query, 'timestamp'), 'timestamp')
    node_name = ht.get_required(query, 'node_name')
    group_id = ht.get_required(query, 'group_id')
    owner_id = ht.get_required(query, 'owner_id')
    post_id = ht.get_required(query, 'post_id')
    delete_signature = ht.get_optional(query, 'delete_signature')
    proof_of_work = ht.get_optional(query, 'proof_of_work')

    conn = db.connect(config.db_path)
    try:
        c = db.cursor(conn)
        db.delete_post(c, timestamp, node_name, group_id, owner_id, post_id, proof_of_work, delete_signature)
        db.commit(conn)

        raise ht.ok_json({'status' : 'ok'})

    except ex.SqueakException as e:
        raise ht.convert_squeak_exception(e)

    finally:
        db.close(conn)
Exemple #5
0
def post_handler(environ):

    query = ht.parse_post_request(environ)

    timestamp = ht.convert_int(ht.get_required(query, "timestamp"), "timestamp")
    node_name = ht.get_required(query, "node_name")
    group_id = ht.get_required(query, "group_id")
    owner_id = ht.get_required(query, "owner_id")
    new_size = ht.convert_int(ht.get_required(query, "new_size"), "new_size")
    when_space_exhausted = ht.get_required(query, "when_space_exhausted")

    public_key_hash = ht.get_required(query, "public_key_hash")
    signature = ht.get_required(query, "signature")

    conn = db.connect(config.db_path)
    try:
        c = db.cursor(conn)
        db.change_group_quota(
            c, timestamp, node_name, group_id, owner_id, new_size, when_space_exhausted, public_key_hash, signature
        )
        db.commit(conn)

        raise ht.ok_json({"status": "ok"})

    except ex.SqueakException as e:
        raise ht.convert_squeak_exception(e)

    finally:
        db.close(conn)
Exemple #6
0
def post_handler(environ):

    query = ht.parse_post_request(environ)

    timestamp = ht.convert_int(ht.get_required(query, 'timestamp'), 'timestamp')
    node_name = ht.get_required(query, 'node_name')
    user_id = ht.get_required(query, 'user_id')
    new_size = ht.convert_int(ht.get_required(query, 'new_size'), 'new_size')
    when_space_exhausted = ht.get_required(query, 'when_space_exhausted')

    public_key_hash = ht.get_required(query, 'public_key_hash')
    signature = ht.get_required(query, 'signature')

    conn = db.connect(config.db_path)
    try:
        c = db.cursor(conn)
        db.change_message_quota(c,
                timestamp, node_name, user_id, new_size, when_space_exhausted,
                public_key_hash, signature)
        db.commit(conn)

        raise ht.ok_json({'status' : 'ok'})

    except ex.SqueakException as e:
        raise ht.convert_squeak_exception(e)

    finally:
        db.close(conn)
Exemple #7
0
def post_handler(environ):

    query = ht.parse_post_request(environ)

    timestamp = ht.convert_int(ht.get_required(query, 'timestamp'), 'timestamp')
    node_name = ht.get_required(query, 'node_name')
    group_id = ht.get_required(query, 'group_id')
    owner_id = ht.get_required(query, 'owner_id')
    post_access = ht.get_required(query, 'post_access')
    read_access = ht.get_required(query, 'read_access')
    delete_access = ht.get_required(query, 'delete_access')
    posting_key_type = ht.get_optional(query, 'posting_key_type')
    posting_pub_key = ht.get_optional(query, 'posting_pub_key')
    reading_key_type = ht.get_optional(query, 'reading_key_type')
    reading_pub_key = ht.get_optional(query, 'reading_pub_key')
    delete_key_type = ht.get_optional(query, 'delete_key_type')
    delete_pub_key = ht.get_optional(query, 'delete_pub_key')
    quota_allocated = ht.convert_int(ht.get_required(query, 'quota_allocated'), 'quota_allocated')
    when_space_exhausted = ht.get_required(query, 'when_space_exhausted')
    max_post_size = ht.convert_int(ht.get_optional(query, 'max_post_size'), 'max_post_size')

    public_key_hash = ht.get_required(query, 'public_key_hash')
    signature = ht.get_required(query, 'signature')

    conn = db.connect(config.db_path)
    try:
        c = db.cursor(conn)
        row = (timestamp, group_id, owner_id,
               post_access, read_access, delete_access,
               posting_key_type, posting_pub_key,
               reading_key_type, reading_pub_key,
               delete_key_type, delete_pub_key,
               quota_allocated, when_space_exhausted,
               max_post_size)
        db.create_group(c, row, node_name, public_key_hash, signature)
        db.commit(conn)

        raise ht.ok_json({'status' : 'ok'})

    except ex.SqueakException as e:
        raise ht.convert_squeak_exception(e)

    finally:
        db.close(conn)
Exemple #8
0
def post_handler(environ):

    query = ht.parse_post_request(environ)

    timestamp = ht.convert_int(ht.get_required(query, 'timestamp'), 'timestamp')
    node_name = ht.get_required(query, 'node_name')
    to_user = ht.get_required(query, 'to_user')
    to_user_key_hash = ht.get_optional(query, 'to_user_key_hash')
    from_user = ht.get_optional(query, 'from_user')
    from_user_key_hash = ht.get_optional(query, 'from_user_key_hash')
    message_hash = ht.get_required(query, 'message_hash')

    message = ht.get_required(query, 'message')
    message_id = ht.get_required(query, 'message_id')

    from_signature = ht.get_optional(query, 'from_signature')
    proof_of_work = ht.get_optional(query, 'proof_of_work')

    conn = db.connect(config.db_path)
    try:
        c = db.cursor(conn)
        db.add_message(c,
                       (message_id, timestamp, 
                        to_user, to_user_key_hash,
                        from_user, from_user_key_hash,
                        message, message_hash,
                        from_signature, proof_of_work, None),
                       node_name)
        db.commit(conn)

        raise ht.ok_json({'status' : 'ok'})

    except ex.SqueakException as e:
        raise ht.convert_squeak_exception(e)

    finally:
        db.close(conn)
Exemple #9
0
def post_handler(environ):

    query = ht.parse_post_request(environ)

    node_name = ht.get_required(query, 'node_name')
    user_id = ht.get_required(query, 'user_id')
    key_type = ht.get_required(query, 'key_type')
    public_key = ht.get_required(query, 'public_key')
    public_key_hash = ht.get_required(query, 'public_key_hash')
    revoke_date = ht.convert_int(ht.get_optional(query, 'revoke_date'), 'revoke_date')
    default_message_access = ht.get_required(query, 'default_message_access')
    when_mail_exhausted = ht.get_required(query, 'when_mail_exhausted')
    quota_size = ht.convert_int(ht.get_required(query, 'quota_size'), 'quota_size')
    mail_quota_size = ht.convert_int(ht.get_required(query, 'mail_quota_size'), 'mail_quota_size')
    max_message_size = ht.convert_int(ht.get_optional(query, 'max_message_size'), 'max_message_size')

    # TODO: figure these out
    user_class = ht.get_optional(query, 'user_class')
    auth_token = ht.get_optional(query, 'auth_token')

    conn = db.connect(config.db_path)
    try:
        c = db.cursor(conn)
        db.create_user(c, node_name,
                       user_id, key_type, public_key, public_key_hash, revoke_date,
                       default_message_access, when_mail_exhausted,
                       db.root_quota_id, quota_size, mail_quota_size,
                       max_message_size)
        db.commit(conn)

        raise ht.ok_json({'status' : 'ok'})

    except ex.SqueakException as e:
        raise ht.convert_squeak_exception(e)

    finally:
        db.close(conn)
Exemple #10
0
def post_handler(environ):

    query = ht.parse_post_request(environ)

    timestamp = ht.convert_int(ht.get_required(query, "timestamp"), "timestamp")
    node_name = ht.get_required(query, "node_name")
    user_id = ht.get_required(query, "user_id")
    new_size = ht.convert_int(ht.get_optional(query, "new_size"), "new_size")
    public_key_hash = ht.get_required(query, "public_key_hash")
    signature = ht.get_required(query, "signature")

    conn = db.connect(config.db_path)
    try:
        c = db.cursor(conn)
        db.change_max_message_size(c, timestamp, node_name, user_id, new_size, public_key_hash, signature)
        db.commit(conn)

        raise ht.ok_json({"status": "ok"})

    except ex.SqueakException as e:
        raise ht.convert_squeak_exception(e)

    finally:
        db.close(conn)
#!/usr/bin/python
# Run this script as user: www-data

import os
import server_path
import squeakspace.server.db_sqlite3 as db
import config

try:
    os.remove(config.db_path)
except OSError:
    pass

conn = db.connect(config.db_path)
c = db.cursor(conn)
db.make_db(c, config.total_quota)
db.commit(conn)
db.close(conn)