2.1.1. CreateUser

Implement this class definition and function:

class User

Represents a user of the Dropbox system.

You are free to add fields to the User class by changing the definition of the initializer function __init__.

create_user(username: str, password: str) User

Returns an instance of an User that includes all necessary data the client program needs to operate on behalf of the user identified by username and password. However, raises a util.DropboxError in the following circumstances:

  • If a user with the same username already exists

  • If username is the empty string

Notes:

  • Usernames are case sensitive.

  • Usernames do not need to remain confidential to the adversary.

  • Assuming that this operation properly enforces the aforementioned checks on username, you should assume that each user has a unique username and that usernames are non-empty strings. However, multiple users may choose the same password.

  • You must not restrict users’ choice of username and password (i.e. in terms of characters or length).

  • You should assume passwords have a medium amount of entropy (specifically, enough entropy for use with crypto.PasswordKDF). However, the adversary may possess a rainbow table of common passwords.

Parameters:
  • username (str) – The username of the user

  • password (str) – The password of the user

Returns:

A User instance corresponding to the user identified by username

Return type:

User

Raises:

DropboxError – if an error case occurred