diff --git a/app/src/main/java/lightcontainer/storage/User.java b/app/src/main/java/lightcontainer/storage/User.java new file mode 100644 index 0000000..1623703 --- /dev/null +++ b/app/src/main/java/lightcontainer/storage/User.java @@ -0,0 +1,72 @@ +package lightcontainer.storage; + +import java.util.Map; +import java.util.Set; + +/** + * User represents a user of the system. + * + * @author Maximilien LEDOUX + * @version 1.0 + * @since 1.0 + */ +public class User { + + private final String Name; + private final String password; + private final String aesKey; + private final Map files; + + public User(String Name, String password, String aesKey, Map files) { + this.Name = Name; + this.password = password; + this.aesKey = aesKey; + this.files = files; + } + + public String getName() { + return Name; + } + + public String getPassword() { + return password; + } + + public String getAesKey() { + return aesKey; + } + + public Set> getFilesIterator() { + return files.entrySet(); + } + + public File getFile(String fileName) { + return this.files.get(fileName); + } + + /** + * @param file The file to add. + * @return False if a file with the same name already exists. Otherwise, adds the file and returns true. + */ + public boolean addFile(File file) { + if (this.files.containsKey(file.getName())) { + return false; + } else { + this.files.put(file.getName(), file); + return true; + } + } + + /** + * @param fileName The name of the file to delete. + * @return True if the file was deleted. False otherwise. + */ + public boolean deleteFile(String fileName) { + if (this.files.containsKey(fileName)) { + this.files.remove(fileName); + return true; + } else { + return false; + } + } +}