Class JKSecurityWebController

java.lang.Object
com.jk.web.faces.controllers.JKWebController
com.jk.webstack.security.controllers.JKSecurityWebController
All Implemented Interfaces:
Serializable

@Named("securityController") @RequestScoped public class JKSecurityWebController extends JKWebController
This class is responsible for managing security-related operations in a web application.

It is used for tasks such as changing passwords and checking user roles.

This class extends the JKWebController class for web functionality.

Version:
1.0
Author:
Dr. Jalal H. Kiswani
See Also:
  • Constructor Details

    • JKSecurityWebController

      public JKSecurityWebController()
  • Method Details

    • getMessage

      public String getMessage()
      This method get the error message related to authentication.
      Returns:
      the error message or null if no error occurred.
    • getUser

      public User getUser()
      This method get the currently logged-in user.
      Returns:
      the User object representing the logged-in user or null if not logged in.
    • getUserName

      public String getUserName()
      This method get the user name of the currently logged-in user.
      Overrides:
      getUserName in class JKWebController
      Returns:
      the user name of the currently logged-in user.
    • isUserLoggedIn

      public boolean isUserLoggedIn()
      This method check if a user is logged in.
      Returns:
      true, if a user is logged in, false otherwise.
    • getService

      protected SecurityService getService()
      This method get the SecurityService instance.
      Returns:
      the SecurityService instance for managing security-related tasks.
    • getCurrentPassword

      public String getCurrentPassword()
      This method gets the current user password.
      Returns:
      the current user password.
    • setCurrentPassword

      public void setCurrentPassword(String currentPassword)
      This method sets the current user password.
      Parameters:
      currentPassword - Specifies the new current user password.
    • getNewPassword

      public String getNewPassword()
      This method gets the new user password.
      Returns:
      the new user password.
    • setNewPassword

      public void setNewPassword(String newPassword)
      This method sets the new user password.
      Parameters:
      newPassword - Specifies the new user password.
    • changePassword

      public String changePassword()
      This method changes the user's password.
      Returns:
      a message indicating the result of the password change.
    • isAdmin

      public boolean isAdmin()
      This method check if the current user is an administrator.
      Returns:
      true, if the current user is an administrator, false otherwise.
    • isAuthorized

      public boolean isAuthorized(String role)
      This method check if the current user is authorized with the given role.
      Parameters:
      role - Specifies the role to check authorization for.
      Returns:
      true, if the user is authorized for the given role, false otherwise.