Class Passwords
- java.lang.Object
-
- Passwords
-
public class Passwords extends java.lang.ObjectThis 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 booleanaddUser(java.lang.String user, char[] password)Add a user to the password file.booleanauthenticateUser(java.lang.String user, char[] password)Check if a user exists in the password file with the given password.booleanisUser(java.lang.String user)Check if the user exists in the password file.booleanremoveUser(java.lang.String user)Remove a user from 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.
-
-