def post_handler(environ): query = ht.parse_post_request(environ) cookies = ht.parse_cookies(environ) user_id = ht.get_required_cookie(cookies, "user_id") session_id = ht.get_required_cookie(cookies, "session_id") group_id = ht.get_required(query, "group_id") owner_id = ht.get_required(query, "owner_id") node_name = ht.get_required(query, "node_name") key_use = ht.get_required(query, "key_use") public_key_hash = ht.get_required(query, "public_key_hash") conn = db.connect(config.db_path) try: c = db.cursor(conn) db.assign_local_group_key(c, user_id, session_id, group_id, owner_id, node_name, key_use, public_key_hash) db.commit(conn) raise ht.ok_json({"status": "ok"}) except ex.SqueakException as e: raise ht.convert_squeak_exception(e) finally: db.close(conn)
def delete_handler(environ): query = ht.parse_post_request(environ) cookies = ht.parse_cookies(environ) user_id = ht.get_required_cookie(cookies, 'user_id') session_id = ht.get_required_cookie(cookies, 'session_id') to_user = ht.get_required(query, 'to_user') node_name = ht.get_required(query, 'node_name') from_user_key_hash = ht.get_required(query, 'from_user_key_hash') conn = db.connect(config.db_path) try: c = db.cursor(conn) db.delete_local_message_access(c, user_id, session_id, to_user, node_name, from_user_key_hash) db.commit(conn) raise ht.ok_json({'status' : 'ok'}) except ex.SqueakException as e: raise ht.convert_squeak_exception(e) finally: db.close(conn)
def post_handler(environ): query = ht.parse_post_request(environ) cookies = ht.parse_cookies(environ) user_id = ht.get_required_cookie(cookies, 'user_id') session_id = ht.get_required_cookie(cookies, 'session_id') node_name = ht.get_required(query, 'node_name') 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') passphrase = ht.get_optional(query, 'passphrase') conn = db.connect(config.db_path) try: c = db.cursor(conn) resp = db.change_message_quota(c, user_id, session_id, node_name, new_size, when_space_exhausted, public_key_hash, passphrase) db.commit(conn) raise ht.ok_json({'status' : 'ok', 'resp' : resp}) except ex.SqueakException as e: raise ht.convert_squeak_exception(e) finally: db.close(conn)
def post_handler(environ): query = ht.parse_post_request(environ) cookies = ht.parse_cookies(environ) user_id = ht.get_required_cookie(cookies, 'user_id') session_id = ht.get_required_cookie(cookies, 'session_id') node_name = ht.get_required(query, 'node_name') url = ht.get_required(query, 'url') real_node_name = ht.get_required(query, 'real_node_name') fingerprint = ht.get_optional(query, 'fingerprint') conn = db.connect(config.db_path) try: c = db.cursor(conn) db.set_node_addr(c, user_id, session_id, node_name, url, real_node_name, fingerprint) db.commit(conn) raise ht.ok_json({'status' : 'ok'}) except ex.SqueakException as e: raise ht.convert_squeak_exception(e) finally: db.close(conn)
def get_handler(environ): query = ht.parse_get_request(environ) cookies = ht.parse_cookies(environ) user_id = ht.get_required_cookie(cookies, "user_id") session_id = ht.get_required_cookie(cookies, "session_id") node_name = ht.get_required(query, "node_name") group_id = ht.get_required(query, "group_id") key_use = ht.get_required(query, "key_use") public_key_hash = ht.get_required(query, "public_key_hash") passphrase = ht.get_optional(query, "passphrase") conn = db.connect(config.db_path) try: c = db.cursor(conn) resp = db.read_group_key(c, user_id, session_id, node_name, group_id, key_use, public_key_hash, passphrase) raise ht.ok_json({"status": "ok", "resp": resp}) except ex.SqueakException as e: raise ht.convert_squeak_exception(e) finally: db.close(conn)
def delete_handler(environ): query = ht.parse_post_request(environ) cookies = ht.parse_cookies(environ) user_id = ht.get_required_cookie(cookies, 'user_id') session_id = ht.get_required_cookie(cookies, 'session_id') group_id = ht.get_required(query, 'group_id') owner_id = ht.get_required(query, 'owner_id') node_name = ht.get_required(query, 'node_name') use = ht.get_required(query, 'use') conn = db.connect(config.db_path) try: c = db.cursor(conn) db.delete_local_group_access(c, user_id, session_id, group_id, owner_id, node_name, use) db.commit(conn) raise ht.ok_json({'status' : 'ok'}) except ex.SqueakException as e: raise ht.convert_squeak_exception(e) finally: db.close(conn)
def delete_handler(environ): query = ht.parse_post_request(environ) cookies = ht.parse_cookies(environ) user_id = ht.get_required_cookie(cookies, 'user_id') session_id = ht.get_required_cookie(cookies, 'session_id') other_user_id = ht.get_required(query, 'other_user_id') node_name = ht.get_required(query, 'node_name') public_key_hash = ht.get_required(query, 'public_key_hash') conn = db.connect(config.db_path) try: c = db.cursor(conn) db.delete_other_user_key(c, user_id, session_id, other_user_id, node_name, public_key_hash) db.commit(conn) raise ht.ok_json({'status' : 'ok'}) except ex.SqueakException as e: raise ht.convert_squeak_exception(e) finally: db.close(conn)
def get_handler(environ): query = ht.parse_get_request(environ) cookies = ht.parse_cookies(environ) user_id = ht.get_required_cookie(cookies, 'user_id') session_id = ht.get_required_cookie(cookies, 'session_id') node_name = ht.get_required(query, 'node_name') message_id = ht.get_required(query, 'message_id') public_key_hash = ht.get_required(query, 'public_key_hash') passphrase = ht.get_optional(query, 'passphrase') to_key_passphrase = ht.get_optional(query, 'to_key_passphrase') decrypt_message = ht.convert_bool(ht.get_optional(query, 'decrypt_message'), 'decrypt_message') conn = db.connect(config.db_path) try: c = db.cursor(conn) resp, validation = db.read_message(c, user_id, session_id, node_name, message_id, public_key_hash, passphrase, to_key_passphrase, decrypt_message) raise ht.ok_json({'status' : 'ok', 'resp' : resp, 'validation' : validation}) except ex.SqueakException as e: raise ht.convert_squeak_exception(e) finally: db.close(conn)
def get_handler(environ): query = ht.parse_get_request(environ) cookies = ht.parse_cookies(environ) user_id = ht.get_required_cookie(cookies, 'user_id') session_id = ht.get_required_cookie(cookies, 'session_id') node_name = ht.get_required(query, 'node_name') to_user = ht.get_required(query, 'to_user') from_user_key_hash = ht.get_required(query, 'from_user_key_hash') passphrase = ht.get_optional(query, 'passphrase') conn = db.connect(config.db_path) try: c = db.cursor(conn) resp = db.read_max_message_size(c, user_id, session_id, node_name, to_user, from_user_key_hash, passphrase) raise ht.ok_json({'status' : 'ok', 'resp' : resp}) except ex.SqueakException as e: raise ht.convert_squeak_exception(e) finally: db.close(conn)
def post_handler(environ): query = ht.parse_post_request(environ) cookies = ht.parse_cookies(environ) user_id = ht.get_required_cookie(cookies, 'user_id') session_id = ht.get_required_cookie(cookies, 'session_id') key_type = ht.get_required(query, 'key_type') public_key = ht.get_required(query, 'public_key') revoke_date = ht.get_optional(query, 'revoke_date') conn = db.connect(config.db_path) try: c = db.cursor(conn) public_key_hash = db.import_public_key(c, user_id, session_id, key_type, public_key, revoke_date) db.commit(conn) raise ht.ok_json({'status' : 'ok', 'public_key_hash' : public_key_hash}) except ex.SqueakException as e: raise ht.convert_squeak_exception(e) finally: db.close(conn)
def post_handler(environ): query = ht.parse_post_request(environ) cookies = ht.parse_cookies(environ) user_id = ht.get_required_cookie(cookies, 'user_id') session_id = ht.get_required_cookie(cookies, 'session_id') public_key_hash = ht.get_required(query, 'public_key_hash') passphrase = ht.get_required(query, 'passphrase') expire_time = ht.convert_int(ht.get_optional(query, 'expire_time'), 'expire_time') conn = db.connect(config.db_path) try: c = db.cursor(conn) db.cache_passphrase(c, user_id, session_id, public_key_hash, passphrase, expire_time) db.commit(conn) raise ht.ok_json({'status' : 'ok'}) except ex.SqueakException as e: raise ht.convert_squeak_exception(e) finally: db.close(conn)
def post_handler(environ): query = ht.parse_post_request(environ) cookies = ht.parse_cookies(environ) user_id = ht.get_required_cookie(cookies, 'user_id') session_id = ht.get_required_cookie(cookies, 'session_id') node_name = ht.get_required(query, 'node_name') group_id = ht.get_required(query, 'group_id') use = ht.get_required(query, 'use') access = ht.get_required(query, 'access') public_key_hash = ht.get_required(query, 'public_key_hash') passphrase = ht.get_optional(query, 'passphrase') conn = db.connect(config.db_path) try: c = db.cursor(conn) resp = db.change_group_access(c, user_id, session_id, node_name, group_id, use, access, public_key_hash, passphrase) db.commit(conn) raise ht.ok_json({'status' : 'ok', 'resp' : resp}) except ex.SqueakException as e: raise ht.convert_squeak_exception(e) finally: db.close(conn)
def get_handler(environ): query = ht.parse_get_request(environ) cookies = ht.parse_cookies(environ) user_id = ht.get_required_cookie(cookies, 'user_id') session_id = ht.get_required_cookie(cookies, 'session_id') 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') passphrase = ht.get_optional(query, 'passphrase') decrypt_post = ht.convert_bool(ht.get_optional(query, 'decrypt_post'), 'decrypt_post') conn = db.connect(config.db_path) try: c = db.cursor(conn) resp, validation = db.read_post(c, user_id, session_id, node_name, group_id, owner_id, post_id, passphrase, decrypt_post) raise ht.ok_json({'status' : 'ok', 'resp' : resp, 'validation' : validation}) except ex.SqueakException as e: raise ht.convert_squeak_exception(e) finally: db.close(conn)
def get_handler(environ): query = ht.parse_get_request(environ) cookies = ht.parse_cookies(environ) user_id = ht.get_required_cookie(cookies, 'user_id') session_id = ht.get_required_cookie(cookies, 'session_id') node_name = ht.get_required(query, 'node_name') group_id = ht.get_required(query, 'group_id') owner_id = ht.get_required(query, 'owner_id') passphrase = ht.get_required(query, 'passphrase') conn = db.connect(config.db_path) try: c = db.cursor(conn) resp = db.read_group_quota(c, user_id, session_id, node_name, group_id, owner_id, passphrase) raise ht.ok_json({'status' : 'ok', 'resp' : resp}) except ex.SqueakException as e: raise ht.convert_squeak_exception(e) finally: db.close(conn)
def get_handler(environ): query = ht.parse_get_request(environ) cookies = ht.parse_cookies(environ) user_id = ht.get_required_cookie(cookies, 'user_id') session_id = ht.get_required_cookie(cookies, 'session_id') node_name = ht.get_required(query, 'node_name') group_id = ht.get_required(query, 'group_id') owner_id = ht.get_required(query, 'owner_id') start_time = ht.convert_int(ht.get_optional(query, 'start_time'), 'start_time') end_time = ht.convert_int(ht.get_optional(query, 'end_time'), 'end_time') max_records = ht.convert_int(ht.get_optional(query, 'max_records'), 'max_records') order = ht.get_optional(query, 'order') passphrase = ht.get_optional(query, 'passphrase') conn = db.connect(config.db_path) try: c = db.cursor(conn) resp = db.read_post_list(c, user_id, session_id, node_name, group_id, owner_id, start_time, end_time, max_records, order, passphrase) raise ht.ok_json({'status' : 'ok', 'resp' : resp}) except ex.SqueakException as e: raise ht.convert_squeak_exception(e) finally: db.close(conn)
def post_handler(environ): query = ht.parse_post_request(environ) cookies = ht.parse_cookies(environ) user_id = ht.get_required_cookie(cookies, 'user_id') session_id = ht.get_required_cookie(cookies, 'session_id') method = ht.get_required(query, 'method') password = ht.get_optional(query, 'password') public_key_hash = ht.get_optional(query, 'public_key_hash') conn = db.connect(config.db_path) try: c = db.cursor(conn) db.set_password(c, user_id, session_id, method, password, public_key_hash) db.commit(conn) raise ht.ok_json({'status' : 'ok'}) except ex.SqueakException as e: raise ht.convert_squeak_exception(e) finally: db.close(conn)
def get_handler(environ): cookies = ht.parse_cookies(environ) user_id = ht.get_required_cookie(cookies, 'user_id') session_id = ht.get_required_cookie(cookies, 'session_id') conn = db.connect(config.db_path) try: c = db.cursor(conn) addrs = db.list_node_addr(c, user_id, session_id) raise ht.ok_json({'status' : 'ok', 'addrs' : addrs}) except ex.SqueakException as e: raise ht.convert_squeak_exception(e) finally: db.close(conn)
def get_handler(environ): query = ht.parse_get_request(environ) cookies = ht.parse_cookies(environ) user_id = ht.get_required_cookie(cookies, 'user_id') session_id = ht.get_required_cookie(cookies, 'session_id') conn = db.connect(config.db_path) try: c = db.cursor(conn) params = db.get_password() raise ht.ok_json({'status' : 'ok', 'params' : params}) except ex.SqueakException as e: raise ht.convert_squeak_exception(e) finally: db.close(conn)
def post_handler(environ): query = ht.parse_post_request(environ) cookies = ht.parse_cookies(environ) user_id = ht.get_required_cookie(cookies, 'user_id') session_id = ht.get_required_cookie(cookies, 'session_id') node_name = ht.get_required(query, 'node_name') group_id = ht.get_required(query, 'group_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_hash = ht.get_optional(query, 'posting_key_hash') reading_key_hash = ht.get_optional(query, 'reading_key_hash') delete_key_hash = ht.get_optional(query, 'delete_key_hash') 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') passphrase = ht.get_optional(query, 'passphrase') conn = db.connect(config.db_path) try: c = db.cursor(conn) resp = db.create_group(c, user_id, session_id, node_name, group_id, post_access, read_access, delete_access, posting_key_hash, reading_key_hash, delete_key_hash, quota_allocated, when_space_exhausted, max_post_size, public_key_hash, passphrase) db.commit(conn) raise ht.ok_json({'status' : 'ok', 'resp' : resp}) except ex.SqueakException as e: raise ht.convert_squeak_exception(e) finally: db.close(conn)
def get_handler(environ): cookies = ht.parse_cookies(environ) user_id = ht.get_required_cookie(cookies, 'user_id') session_id = ht.get_required_cookie(cookies, 'session_id') conn = db.connect(config.db_path) try: c = db.cursor(conn) db.sign_out(c, user_id, session_id) db.commit(conn) cookies = ['user_id', 'session_id'] raise ht.ok_json({'status' : 'ok'}).clear_cookies(cookies) except ex.SqueakException as e: raise ht.convert_squeak_exception(e) finally: db.close(conn)
def post_handler(environ): query = ht.parse_post_request(environ) cookies = ht.parse_cookies(environ) user_id = ht.get_required_cookie(cookies, 'user_id') session_id = ht.get_required_cookie(cookies, 'session_id') 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_key_hash = ht.get_optional(query, 'from_user_key_hash') message = ht.get_required(query, 'message') passphrase = ht.get_optional(query, 'passphrase') force_encryption = ht.convert_bool(ht.get_optional(query, 'force_encryption'), 'force_encryption') conn = db.connect(config.db_path) try: c = db.cursor(conn) resp, local_gen = db.send_message(c, user_id, session_id, node_name, to_user, to_user_key_hash, from_user_key_hash, message, passphrase, force_encryption) (message_id, timestamp, message_hash, from_signature, proof_of_work) = local_gen db.commit(conn) raise ht.ok_json({'status' : 'ok', 'resp' : resp, 'message_id' : message_id, 'timestamp' : timestamp, 'message_hash' : message_hash, 'from_signature' : from_signature, 'proof_of_work' : proof_of_work}) except ex.SqueakException as e: raise ht.convert_squeak_exception(e) finally: db.close(conn)
def get_handler(environ): query = ht.parse_get_request(environ) cookies = ht.parse_cookies(environ) user_id = ht.get_required_cookie(cookies, 'user_id') session_id = ht.get_required_cookie(cookies, 'session_id') public_key_hash = ht.get_required(query, 'public_key_hash') conn = db.connect(config.db_path) try: c = db.cursor(conn) key = db.read_public_key(c, user_id, session_id, public_key_hash) raise ht.ok_json({'status' : 'ok', 'key' : key}) except ex.SqueakException as e: raise ht.convert_squeak_exception(e) finally: db.close(conn)
def get_handler(environ): query = ht.parse_get_request(environ) cookies = ht.parse_cookies(environ) user_id = ht.get_required_cookie(cookies, 'user_id') session_id = ht.get_required_cookie(cookies, 'session_id') node_name = ht.get_optional(query, 'node_name') conn = db.connect(config.db_path) try: c = db.cursor(conn) keys = db.list_user_keys(c, user_id, session_id, node_name) raise ht.ok_json({'status' : 'ok', 'keys' : keys}) except ex.SqueakException as e: raise ht.convert_squeak_exception(e) finally: db.close(conn)
def post_handler(environ): query = ht.parse_post_request(environ) cookies = ht.parse_cookies(environ) user_id = ht.get_required_cookie(cookies, 'user_id') session_id = ht.get_required_cookie(cookies, 'session_id') node_name = ht.get_required(query, 'node_name') group_id = ht.get_required(query, 'group_id') owner_id = ht.get_required(query, 'owner_id') data = ht.get_required(query, 'data') passphrase = ht.get_optional(query, 'passphrase') force_encryption = ht.convert_bool(ht.get_optional(query, 'force_encryption'), 'force_encryption') conn = db.connect(config.db_path) try: c = db.cursor(conn) resp, local_gen = db.make_post(c, user_id, session_id, node_name, group_id, owner_id, data, passphrase, force_encryption) (post_id, timestamp, data_hash, post_signature, proof_of_work) = local_gen db.commit(conn) raise ht.ok_json({'status' : 'ok', 'resp' : resp, 'post_id' : post_id, 'timestamp' : timestamp, 'data_hash' : data_hash, 'post_signature' : post_signature, 'proof_of_work' : proof_of_work}) except ex.SqueakException as e: raise ht.convert_squeak_exception(e) finally: db.close(conn)
def get_handler(environ): query = ht.parse_get_request(environ) cookies = ht.parse_cookies(environ) user_id = ht.get_required_cookie(cookies, 'user_id') session_id = ht.get_required_cookie(cookies, 'session_id') node_name = ht.get_required(query, 'node_name') user_class = ht.get_optional(query, 'user_class') conn = db.connect(config.db_path) try: c = db.cursor(conn) resp = db.read_quota_available(c, user_id, session_id, node_name, user_class) raise ht.ok_json({'status' : 'ok', 'resp' : resp}) except ex.SqueakException as e: raise ht.convert_squeak_exception(e) finally: db.close(conn)
def post_handler(environ): query = ht.parse_post_request(environ) cookies = ht.parse_cookies(environ) user_id = ht.get_required_cookie(cookies, 'user_id') session_id = ht.get_required_cookie(cookies, 'session_id') public_key_hash = ht.get_required(query, 'public_key_hash') plaintext = ht.get_required(query, 'plaintext') conn = db.connect(config.db_path) try: c = db.cursor(conn) ciphertext = db.encrypt(c, user_id, session_id, public_key_hash, plaintext) raise ht.ok_json({'status' : 'ok', 'ciphertext' : ciphertext}) except ex.SqueakException as e: raise ht.convert_squeak_exception(e) finally: db.close(conn)
def post_handler(environ): query = ht.parse_post_request(environ) cookies = ht.parse_cookies(environ) user_id = ht.get_required_cookie(cookies, "user_id") session_id = ht.get_required_cookie(cookies, "session_id") public_key_hash = ht.get_required(query, "public_key_hash") ciphertext = ht.get_required(query, "ciphertext") passphrase = ht.get_optional(query, "passphrase") conn = db.connect(config.db_path) try: c = db.cursor(conn) plaintext = db.decrypt(c, user_id, session_id, public_key_hash, ciphertext, passphrase) raise ht.ok_json({"status": "ok", "plaintext": plaintext}) except ex.SqueakException as e: raise ht.convert_squeak_exception(e) finally: db.close(conn)
def post_handler(environ): query = ht.parse_post_request(environ) cookies = ht.parse_cookies(environ) user_id = ht.get_required_cookie(cookies, 'user_id') session_id = ht.get_required_cookie(cookies, 'session_id') node_name = ht.get_required(query, 'node_name') public_key_hash = ht.get_required(query, 'public_key_hash') 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') 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) resp = db.create_user(c, user_id, session_id, node_name, public_key_hash, default_message_access, when_mail_exhausted, quota_size, mail_quota_size, max_message_size, user_class, auth_token) db.commit(conn) raise ht.ok_json({'status' : 'ok', 'resp' : resp}) except ex.SqueakException as e: raise ht.convert_squeak_exception(e) finally: db.close(conn)
def post_handler(environ): query = ht.parse_post_request(environ) cookies = ht.parse_cookies(environ) user_id = ht.get_required_cookie(cookies, "user_id") session_id = ht.get_required_cookie(cookies, "session_id") public_key_hash = ht.get_required(query, "public_key_hash") data = ht.get_required(query, "data") passphrase = ht.get_optional(query, "passphrase") conn = db.connect(config.db_path) try: c = db.cursor(conn) signature = db.sign(c, user_id, session_id, public_key_hash, data, passphrase) raise ht.ok_json({"status": "ok", "signature": signature}) except ex.SqueakException as e: raise ht.convert_squeak_exception(e) finally: db.close(conn)
def post_handler(environ): query = ht.parse_post_request(environ) cookies = ht.parse_cookies(environ) user_id = ht.get_required_cookie(cookies, 'user_id') session_id = ht.get_required_cookie(cookies, 'session_id') public_key_hash = ht.get_required(query, 'public_key_hash') data = ht.get_required(query, 'data') signature = ht.get_required(query, 'signature') conn = db.connect(config.db_path) try: c = db.cursor(conn) valid = db.verify_signature(c, user_id, session_id, public_key_hash, data, signature) raise ht.ok_json({'status' : 'ok', 'valid' : valid}) except ex.SqueakException as e: raise ht.convert_squeak_exception(e) finally: db.close(conn)