Class BasicPasswordManager

java.lang.Object
net.strokkur.passwordwhitelist.data.BasicPasswordManager
All Implemented Interfaces:
PasswordManager, PasswordStore

@NullMarked public class BasicPasswordManager extends Object implements PasswordStore, PasswordManager
  • Constructor Details

    • BasicPasswordManager

      public BasicPasswordManager(Path path)
  • Method Details

    • reload

      public void reload() throws IOException
      Description copied from interface: PasswordStore
      Reload the password from disk.
      Specified by:
      reload in interface PasswordManager
      Specified by:
      reload in interface PasswordStore
      Throws:
      IOException - if an exception occurs while reading the file
    • getCurrentPassword

      public @Nullable String getCurrentPassword()
      Description copied from interface: PasswordStore
      Get the current password.
      Specified by:
      getCurrentPassword in interface PasswordStore
      Returns:
      password, or null if none set
    • checkPassword

      public boolean checkPassword(String input)
      Description copied from interface: PasswordStore
      Check whether the input password is correct.
      Specified by:
      checkPassword in interface PasswordStore
      Parameters:
      input - the input password
      Returns:
      if the input matches the password, or true if no password is set
    • setNewPassword

      public void setNewPassword(@Nullable String password) throws IOException
      Description copied from interface: PasswordStore
      Set a new password and write it to disk.
      Specified by:
      setNewPassword in interface PasswordStore
      Parameters:
      password - the new password, or null to unset the password
      Throws:
      IOException - if an exception occurs while writing to the file
    • isPasswordEnabled

      public boolean isPasswordEnabled()
      Description copied from interface: PasswordManager
      Get whether a password is required to join the server.
      Specified by:
      isPasswordEnabled in interface PasswordManager
      Returns:
      whether a password is required
    • setPasswordEnabled

      public void setPasswordEnabled(boolean value) throws IOException
      Description copied from interface: PasswordManager
      Set the password requirement.
      Specified by:
      setPasswordEnabled in interface PasswordManager
      Parameters:
      value - whether the password should be required
      Throws:
      IOException - if an exception occurs while saving the file