Class ServerSettings

java.lang.Object
org.kendar.sync.lib.model.ServerSettings

public class ServerSettings extends Object
Represents the server settings.
  • 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 server
      maxPacketSize - The maximum packet size
      maxConnections - The maximum parallel TCP connections for a single session
      users - The list of users
      backupFolders - The list of backup folders
  • Method Details

    • load

      public static ServerSettings load(String filePath) throws IOException
      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

      public void save(String filePath) throws IOException
      Saves the server settings to a file.
      Parameters:
      filePath - The path to the settings file
      Throws:
      IOException - If an I/O error occurs
    • authenticate

      public Optional<ServerSettings.User> authenticate(String username, String password)
      Authenticates a user.
      Parameters:
      username - The username
      password - The password
      Returns:
      The user if authentication is successful, or empty if not
    • getUserFolder

      public Optional<ServerSettings.BackupFolder> getUserFolder(String userId, String folderName)
      Checks if a user has access to a backup folder.
      Parameters:
      userId - The user ID
      folderName - 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

      public List<ServerSettings.User> getUsers()
    • setUsers

      public void setUsers(List<ServerSettings.User> users)
    • getBackupFolders

      public List<ServerSettings.BackupFolder> getBackupFolders()
    • setBackupFolders

      public void setBackupFolders(List<ServerSettings.BackupFolder> backupFolders)