Kereta Yarsi Indonesia
Loading...
Searching...
No Matches
controller.UserController Class Reference
Inheritance diagram for controller.UserController:
controller.Controller model.UserDAO

Public Member Functions

boolean createUser (User user)
 
User getUser (int userID)
 
User getUserByUsername (String username)
 
boolean updateUser (User user)
 
boolean deleteUser (int userID)
 
boolean register (User user)
 
boolean login (String username, String password)
 
User loginAndGetUser (String username, String password)
 
boolean register (String username, String password)
 
void manageUsers (User user)
 
- Public Member Functions inherited from controller.Controller
void setFirstStuff (String stasiunAsal, String stasiunAkhir, Date tanggalPergi, Date tanggalPulang)
 
int countFoundTrain (String stasiunAwal, String stasiunAkhir, Date tanggal)
 
ResultSet findSpecificTrain (String stasiunAwal, String stasiunAkhir, Date tanggal)
 
ResultSet findAll (String table)
 
ResultSet findWhere (String table, String columnName, Object keyword)
 
ResultSet executeQuery (String sql)
 
ResultSet executeQuery (String sql, Object... values)
 
boolean executeUpdate (String sql, Object... values)
 
boolean insert (String table, boolean withID, Object... value)
 
void errorMessage (String title, String message) throws HeadlessException
 
void warningMessage (String message) throws HeadlessException
 
void infoMessage (String message) throws HeadlessException
 
String[] getColumnName (String table)
 
int getColumnCount (String table)
 
int getRowCount (String table)
 
boolean checkForDatabase (String database) throws SQLException
 
int getRowCountWhere (String table, String columnName, String keyword)
 
boolean hasWhitespace (String str)
 
boolean hasSpecialChar (String str)
 
boolean hasUpperCase (String str)
 
byte[] generateKey (int keyLength)
 
String hashPassword (String str)
 
boolean createUser (User user)
 
User getUser (int userID)
 
User getUserByUsername (String username)
 
boolean updateUser (User user)
 
boolean deleteUser (int userID)
 
boolean register (User user)
 
boolean login (String username, String password)
 

Static Public Member Functions

static synchronized UserController getInstance ()
 
- Static Public Member Functions inherited from controller.Controller
static synchronized Controller getInstance ()
 
static synchronized Session getSession ()
 
static byte[] generateSalt (int saltIteration)
 
static String encryptPBKDF2 (String password, byte[] salt)
 
static boolean verifyPassword (String inputPassword, String storedPassword, byte[] salt)
 
static DefaultTableModel buildTableModel (ResultSet rs) throws SQLException
 
static Statement getSt ()
 
static void setSt (Statement aSt)
 
static ResultSet getRs ()
 
static void setRs (ResultSet aRs)
 
static PreparedStatement getPs ()
 
static void setPs (PreparedStatement aPs)
 

Additional Inherited Members

- Public Attributes inherited from controller.Controller
boolean response = false
 
Session session = Session.getInstance()
 
- Static Public Attributes inherited from controller.Controller
static Statement st
 
static ResultSet rs
 
static PreparedStatement ps
 
- Protected Member Functions inherited from controller.Controller
 Controller (DatabaseConnector databaseConnector)
 
- Static Protected Attributes inherited from controller.Controller
static DatabaseConnector databaseConnector
 
static Connection con
 
static String sql
 

Detailed Description

Controller class for managing operations related to users. Implements the UserDAO interface to provide methods for user management.

This class uses the singleton pattern to ensure that only one instance of the controller exists.

Example usage:

UserController controller = UserController.getInstance();
boolean isLogin = controller.login("myworld", "theworld213");
See also
model.UserDAO
model.User
model.Admin
model.DatabaseConnector
Version
1.0
Author
Muhammad Rizal Anditama Nugraha

Member Function Documentation

◆ createUser()

boolean controller.UserController.createUser ( User  user)
inline

Creates a new user in the database.

Parameters
userthe User object representing the user to create
Returns
true if user creation was successful, false otherwise

Implements model.UserDAO.

◆ deleteUser()

boolean controller.UserController.deleteUser ( int  userID)
inline

Deletes a user from the database by user ID.

Parameters
userIDthe ID of the user to delete
Returns
true if user deletion was successful, false otherwise

Implements model.UserDAO.

◆ getInstance()

static synchronized UserController controller.UserController.getInstance ( )
inlinestatic

Returns the single instance of UserController. If no instance exists, it creates one using the provided DatabaseConnector.

Returns
the singleton instance of UserController

Reimplemented from controller.Controller.

◆ getUser()

User controller.UserController.getUser ( int  userID)
inline

Retrieves a user from the database by user ID.

Parameters
userIDthe ID of the user to retrieve
Returns
a User object if found, otherwise null

Implements model.UserDAO.

◆ getUserByUsername()

User controller.UserController.getUserByUsername ( String  username)
inline

Retrieves a user from the database by username.

Parameters
usernamethe username of the user to retrieve
Returns
a User object if found, otherwise null

Implements model.UserDAO.

◆ login()

boolean controller.UserController.login ( String  username,
String  password 
)
inline

Authenticates a user login based on username and password.

Parameters
usernamethe username of the user attempting to log in
passwordthe password of the user attempting to log in
Returns
true if login is successful, false otherwise

Implements model.UserDAO.

◆ loginAndGetUser()

User controller.UserController.loginAndGetUser ( String  username,
String  password 
)
inline

Performs user login and retrieves the User object if successful.

Parameters
usernamethe username of the user attempting to log in
passwordthe password of the user attempting to log in
Returns
the User object if login is successful, otherwise null

◆ manageUsers()

void controller.UserController.manageUsers ( User  user)
inline

Manages users based on the role of the provided User object.

Parameters
userthe User object whose role determines the actions allowed

◆ register() [1/2]

boolean controller.UserController.register ( String  username,
String  password 
)
inline

Registers a new user in the database with the provided username and password. Automatically generates a salt for password encryption.

Parameters
usernamethe username of the user to register
passwordthe password of the user to register
Returns
true if user registration was successful, false otherwise

◆ register() [2/2]

boolean controller.UserController.register ( User  user)
inline

Registers a new user in the database.

Parameters
userthe User object representing the user to register
Returns
true if user registration was successful, false otherwise

Implements model.UserDAO.

◆ updateUser()

boolean controller.UserController.updateUser ( User  user)
inline

Updates an existing user in the database.

Parameters
userthe User object representing the updated user information
Returns
true if user update was successful, false otherwise

Implements model.UserDAO.


The documentation for this class was generated from the following file: