Système de synchronisation de l'information entre FileFrontEnd<>StorBackEnd -> implémentation de User
This commit is contained in:
parent
28fded5763
commit
49fe7fb7e7
72
app/src/main/java/lightcontainer/storage/User.java
Normal file
72
app/src/main/java/lightcontainer/storage/User.java
Normal file
@ -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 <m.ledoux@student.helmo.be>
|
||||
* @version 1.0
|
||||
* @since 1.0
|
||||
*/
|
||||
public class User {
|
||||
|
||||
private final String Name;
|
||||
private final String password;
|
||||
private final String aesKey;
|
||||
private final Map<String, File> files;
|
||||
|
||||
public User(String Name, String password, String aesKey, Map<String, File> 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<Map.Entry<String, File>> 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;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user