Package com.articulate.sigma
Class PasswordService
java.lang.Object
com.articulate.sigma.PasswordService
- All Implemented Interfaces:
EventListener,javax.servlet.ServletContextListener
@WebListener
public final class PasswordService
extends Object
implements javax.servlet.ServletContextListener
A class that encrypts a string and checks it against another stored
encrypted string, in order to validate a user login.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionThe working utility to add a user to the DBbooleanauthenticate(String username, String pass) Take a user name and an encrypted password and compare it to an existing collection of users with encrypted passwords.voidchangeUserPassword(String username, String newPassword) voidchangeUserRole(String id) voidcontextDestroyed(javax.servlet.ServletContextEvent servletContextEvent) voidcontextInitialized(javax.servlet.ServletContextEvent servletContextEvent) voidCreates an admin user using the console for user inputvoidcreateUser(String user) Creates a new user with role uservoiddeleteUser(String uname) Encrypts a string with a deterministic algorithm.Return a list of all admin users' email addresses.static PasswordServicevoidlogin()voidmailModerator(User user) Sends the moderator an email requesting a user to be registered a Sigma accountstatic voidCommand line entry pointvoidvoidregister()Command line initiated method for registering a Sigma user with role guest.static voidshowHelp()booleanuserExists(String username) userIDs()
-
Field Details
-
JDBC_CREATE_DB
-
JDBC_ACCESS_DB
-
INITIAL_ADMIN_USER
- See Also:
-
conn
-
-
Constructor Details
-
PasswordService
public PasswordService()Create an instance of PasswordService
-
-
Method Details
-
contextInitialized
public void contextInitialized(javax.servlet.ServletContextEvent servletContextEvent) - Specified by:
contextInitializedin interfacejavax.servlet.ServletContextListener
-
contextDestroyed
public void contextDestroyed(javax.servlet.ServletContextEvent servletContextEvent) - Specified by:
contextDestroyedin interfacejavax.servlet.ServletContextListener
-
encrypt
Encrypts a string with a deterministic algorithm. Thanks to https://howtodoinjava.com/security/how-to-generate-secure-password-hash-md5-sha-pbkdf2-bcrypt-examples/ -
getInstance
-
authenticate
Take a user name and an encrypted password and compare it to an existing collection of users with encrypted passwords. -
userExists
-
userIDs
-
deleteUser
-
login
public void login() -
mailModerator
Sends the moderator an email requesting a user to be registered a Sigma account- Parameters:
user- the user information to register an account for
-
register
public void register()Command line initiated method for registering a Sigma user with role guest. -
onlineRegister
-
addUser
The working utility to add a user to the DB- Parameters:
login- the user namep- user password (will be encrypted)e- user emailrole- user role- Returns:
- an instance of the user to add to the DB
-
getAdminEmails
Return a list of all admin users' email addresses. -
createAdmin
public void createAdmin()Creates an admin user using the console for user input -
createUser
Creates a new user with role user- Parameters:
user- the user name
-
changeUserRole
-
changeUserPassword
-
showHelp
public static void showHelp() -
main
Command line entry point- Parameters:
args- given command line arguments
-