Class PropertiesAuthenticator

java.lang.Object
com.thecoderscorner.menu.auth.PropertiesAuthenticator
All Implemented Interfaces:
MenuAuthenticator

public class PropertiesAuthenticator extends Object implements MenuAuthenticator
Stores authentication to a properties file and then validates against the stored values. By default, there are no authentication pairs stored, and the secure passcode is "1234" NOTE: This is only suited to very simple use cases where the level of security required is not particularly high and the file system of the device is completely secured. The authentication UUIDs are stored PLAIN TEXT.
  • Constructor Details

    • PropertiesAuthenticator

      public PropertiesAuthenticator(String location)
    • PropertiesAuthenticator

      public PropertiesAuthenticator(String location, DialogManager dialogManager)
  • Method Details

    • setDialogManager

      public void setDialogManager(DialogManager dialogManager)
    • authenticate

      public boolean authenticate(String user, UUID uuid)
      Description copied from interface: MenuAuthenticator
      Check if the user and UUID pair can connect to this board.
      Specified by:
      authenticate in interface MenuAuthenticator
      Parameters:
      user - the user to check for
      uuid - the UUID to check for
      Returns:
      true if the user and UUID are allowed, otherwise false
    • addAuthentication

      public CompletableFuture<Boolean> addAuthentication(String user, UUID uuid, boolean needsApproval)
      Adds an authentication token to the store, it assumes that all appropriate permission from the user has been sought.
      Specified by:
      addAuthentication in interface MenuAuthenticator
      Parameters:
      user - the user to add
      uuid - the uuid associated with the user
      needsApproval - true if this is being added from a remote connection and needs approval, otherwise false.
      Returns:
      a future that can be tracked to indicate if the authentication was accepted
    • removeAuthentication

      public void removeAuthentication(String user)
      Description copied from interface: MenuAuthenticator
      Remove the authentication for the given user
      Specified by:
      removeAuthentication in interface MenuAuthenticator
      Parameters:
      user - the user to remove
    • doesPasscodeMatch

      public boolean doesPasscodeMatch(String passcode)
      Description copied from interface: MenuAuthenticator
      Checks if the provided passcode matches with the security passcode and returns false if it does not match.
      Specified by:
      doesPasscodeMatch in interface MenuAuthenticator
      Parameters:
      passcode - the passcode to check
      Returns:
      true if matching, otherwise false
    • managementCapabilities

      public MenuAuthenticator.ManagementCapabilities managementCapabilities()
      Description copied from interface: MenuAuthenticator
      Indicates how this authenticator can be edited, some don't support any, some remove only.
      Specified by:
      managementCapabilities in interface MenuAuthenticator
      Returns:
      how the authenticator can be managed
    • getAllNames

      public List<String> getAllNames()
      Description copied from interface: MenuAuthenticator
      Gets a list of all apps/users stored in the system
      Specified by:
      getAllNames in interface MenuAuthenticator
      Returns:
      the list of users