Class UsernamePasswordOnFile

  • All Implemented Interfaces:
    AuthenticationMechanismInterface

    public class UsernamePasswordOnFile
    extends UsernamePasswordMechanism
    Example of an authentication method that returns ok when username and password is defined in the 'USER.db' file.
     E.g.
     "
     ...
     niber rebin
     kalle:ellak
     erik=kire
     ...
     "
      
    The username-password pairs can be specified in various manners in terms of delimitation and works successfully when using hyphens such as white space, colon, or equals as delimiter between usernames and passwords.
    • Constructor Detail

      • UsernamePasswordOnFile

        public UsernamePasswordOnFile()
        Constructs a new UsernamePasswordOnFile instance.
    • Method Detail

      • authenticate

        public UsernamePasswordMechanism.UsernamePasswordMechanismResponse authenticate​(java.lang.String username,
                                                                                        java.lang.String password)
        The authentication call which checks the database which is populated during initialization.
        Specified by:
        authenticate in class UsernamePasswordMechanism
        Parameters:
        username - The username.
        password - The password.
        Returns:
        A UsernamePasswordMechanismResponse object containing status codes and if needed an error message.
      • testConnect

        protected boolean testConnect()
        According to abstract class this must be implemented.
        Specified by:
        testConnect in class UsernamePasswordMechanism
        Returns:
        Always true since this authentication method does not need to test any connection or allocation of necessary resources.
      • needsReloading

        public boolean needsReloading​(java.lang.String transactionKey)