servers module

StorageServer and PublicKeyServer implementations.

Note

Do not change any code in this file!

class servers.PublicKeyServer

Bases: object

Simple implementation of a public key server.

Exposes the put_public_key and get_public_key functions as defined in the specification.

Your Client class will be initialized with a PublicKeyServer object, through which you will access these methods.

Note

Do not modify this class! None of your changes will be used when we grade your implementation.

get_public_key(username)

Get the public key associated with username.

Parameters:username (str) – The username to lookup the public key of.
Returns:The RSA key object containing the public key, or None if the user does not have a key registered with the PublicKeyServer.
put_public_key(username, pubkey)

Set the public key for your username.

Note

Must only be called once!

Note

Students should use base_client.BaseClient.generate_public_key_pair() instead of calling this directly.

Parameters:
  • username (str) – Your client’s username
  • pubkey (An RSA key object) – Your RSA public key
class servers.StorageServer

Bases: object

Simple implementation of a storage server using a key-value store.

Exposes the get, put, and delete functions as defined in the specification.

Your Client class will be initialized with a StorageServer object, through which you will access these methods.

Note

Do not modify this class! None of your changes will be used when we grade your implementation.

delete(id)

Deletes the given id from the server.

Parameters:id (str) – The id to delete
get(id)

Retrieves the value stored at id

Parameters:id (str) – The id to get
Returns:The value, or None if id does not exist in the store
Return type:str or None
put(id, value)

Stores value at id

Parameters:
  • id (str) – The id to store value at
  • value (str) – The value to store
Returns:

True, if the put succeeded

Raises:

TypeError – If id or value are not strings