From 49fe7fb7e7fd70ae465d5e1443fb050e6a84023d Mon Sep 17 00:00:00 2001 From: Maximilien LEDOUX Date: Sat, 5 Mar 2022 17:08:36 +0100 Subject: [PATCH] =?UTF-8?q?Syst=C3=A8me=20de=20synchronisation=20de=20l'in?= =?UTF-8?q?formation=20entre=20FileFrontEnd<>StorBackEnd=20->=20impl=C3=A9?= =?UTF-8?q?mentation=20de=20User?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/lightcontainer/storage/User.java | 72 +++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 app/src/main/java/lightcontainer/storage/User.java 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; + } + } +}