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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleancheckPassword(String input) Check whether the input password is correct.@Nullable StringGet the current password.booleanGet whether a password is required to join the server.voidreload()Reload the password from disk.voidsetNewPassword(@Nullable String password) Set a new password and write it to disk.voidsetPasswordEnabled(boolean value) Set the password requirement.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.strokkur.passwordwhitelist.data.PasswordManager
disablePassword, enablePassword
-
Constructor Details
-
BasicPasswordManager
-
-
Method Details
-
reload
Description copied from interface:PasswordStoreReload the password from disk.- Specified by:
reloadin interfacePasswordManager- Specified by:
reloadin interfacePasswordStore- Throws:
IOException- if an exception occurs while reading the file
-
getCurrentPassword
Description copied from interface:PasswordStoreGet the current password.- Specified by:
getCurrentPasswordin interfacePasswordStore- Returns:
- password, or
nullif none set
-
checkPassword
Description copied from interface:PasswordStoreCheck whether the input password is correct.- Specified by:
checkPasswordin interfacePasswordStore- Parameters:
input- the input password- Returns:
- if the input matches the password, or
trueif no password is set
-
setNewPassword
Description copied from interface:PasswordStoreSet a new password and write it to disk.- Specified by:
setNewPasswordin interfacePasswordStore- Parameters:
password- the new password, ornullto unset the password- Throws:
IOException- if an exception occurs while writing to the file
-
isPasswordEnabled
public boolean isPasswordEnabled()Description copied from interface:PasswordManagerGet whether a password is required to join the server.- Specified by:
isPasswordEnabledin interfacePasswordManager- Returns:
- whether a password is required
-
setPasswordEnabled
Description copied from interface:PasswordManagerSet the password requirement.- Specified by:
setPasswordEnabledin interfacePasswordManager- Parameters:
value- whether the password should be required- Throws:
IOException- if an exception occurs while saving the file
-