Package org.kendar.sync.lib.model
Class ServerSettings
java.lang.Object
org.kendar.sync.lib.model.ServerSettings
Represents the server settings.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classRepresents a backup folder.static classRepresents a user in the system. -
Constructor Summary
ConstructorsConstructorDescriptionServerSettings(int port, int webPort, int maxPacketSize, int maxConnections, List<ServerSettings.User> users, List<ServerSettings.BackupFolder> backupFolders) Creates a new server settings object. -
Method Summary
Modifier and TypeMethodDescriptionauthenticate(String username, String password) Authenticates a user.intintintgetPort()getUserFolder(String userId, String folderName) Checks if a user has access to a backup folder.getUsers()intstatic ServerSettingsLoads the server settings from a file.voidSaves the server settings to a file.voidsetBackupFolders(List<ServerSettings.BackupFolder> backupFolders) voidsetMaxConnections(int maxConnections) voidsetMaxPacketSize(int maxPacketSize) voidsetPort(int port) voidsetUsers(List<ServerSettings.User> users) voidsetWebPort(int webPort)
-
Constructor Details
-
ServerSettings
public ServerSettings() -
ServerSettings
public ServerSettings(int port, int webPort, int maxPacketSize, int maxConnections, List<ServerSettings.User> users, List<ServerSettings.BackupFolder> backupFolders) Creates a new server settings object.- Parameters:
port- The listening port of the servermaxPacketSize- The maximum packet sizemaxConnections- The maximum parallel TCP connections for a single sessionusers- The list of usersbackupFolders- The list of backup folders
-
-
Method Details
-
load
Loads the server settings from a file.- Parameters:
filePath- The path to the settings file- Returns:
- The server settings
- Throws:
IOException- If an I/O error occurs
-
save
Saves the server settings to a file.- Parameters:
filePath- The path to the settings file- Throws:
IOException- If an I/O error occurs
-
authenticate
Authenticates a user.- Parameters:
username- The usernamepassword- The password- Returns:
- The user if authentication is successful, or empty if not
-
getUserFolder
Checks if a user has access to a backup folder.- Parameters:
userId- The user IDfolderName- The virtual folder name- Returns:
- The backup folder if the user has access, or empty if not
-
getWebPort
public int getWebPort() -
setWebPort
public void setWebPort(int webPort) -
getPort
public int getPort() -
setPort
public void setPort(int port) -
getMaxPacketSize
public int getMaxPacketSize() -
setMaxPacketSize
public void setMaxPacketSize(int maxPacketSize) -
getMaxConnections
public int getMaxConnections() -
setMaxConnections
public void setMaxConnections(int maxConnections) -
getUsers
-
setUsers
-
getBackupFolders
-
setBackupFolders
-