Class Passwords


  • public class Passwords
    extends java.lang.Object
    This is a file to investigate issues with passwords in programming. This should never be used in a production system.
    Author:
    cpresser
    • Constructor Summary

      Constructors 
      Constructor Description
      Passwords​(java.lang.String filename)
      Construct a password object for user authentication.
    • Method Summary

      Modifier and Type Method Description
      boolean addUser​(java.lang.String user, char[] password)
      Add a user to the password file.
      boolean authenticateUser​(java.lang.String user, char[] password)
      Check if a user exists in the password file with the given password.
      boolean isUser​(java.lang.String user)
      Check if the user exists in the password file.
      boolean removeUser​(java.lang.String user)
      Remove a user from the password file.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Passwords

        public Passwords​(java.lang.String filename)
        Construct a password object for user authentication.
        Parameters:
        filename - The name of the password file.
    • Method Detail

      • authenticateUser

        public boolean authenticateUser​(java.lang.String user,
                                        char[] password)
        Check if a user exists in the password file with the given password.
        Parameters:
        user - String containing a user name.
        password - character array containing a password
        Returns:
        true if the user name is in the password file, with the correct password, false otherwise.
      • addUser

        public boolean addUser​(java.lang.String user,
                               char[] password)
        Add a user to the password file.
        Parameters:
        user - String containing a user name.
        password - character array containing a password
        Returns:
        true if the user does not exist in the file and is successfully added, false otherwise.
      • removeUser

        public boolean removeUser​(java.lang.String user)
        Remove a user from the password file.
        Parameters:
        user - String containing a user name.
        Returns:
        true if the user is in the file and was removed, false otherwise.
      • isUser

        public boolean isUser​(java.lang.String user)
        Check if the user exists in the password file.
        Parameters:
        user - String containing a user name.
        Returns:
        true if the user exists.