Class CurrentUser

java.lang.Object
com.jbstrap.core.CurrentUser

public class CurrentUser extends Object

The class containing the data of the currently logged in user

If the application requires other/more information about the user, above those listed in this class, then a POJO class has to be made, that is a descendant of this class. a descendant of this class.he framework only builds on the information that is in this class, so the descendant class doesn't have any effect on the application itself.

If a custom user class is made, then at the login the custom class has to be instantiated, and given to the JBStrap framework, as the logged in user. For more information about the login implementation, see: AuthenticationInterface

Since:
4.0
Author:
JBStrap
See Also:
  • Field Details

    • uuid

      protected String uuid
    • userName

      protected String userName
    • name

      protected String name
    • telephoneNumber

      protected String telephoneNumber
    • email

      protected String email
    • roles

      protected List<Role> roles
    • currentRole

      protected Role currentRole
  • Constructor Details

    • CurrentUser

      public CurrentUser()
  • Method Details

    • setUuid

      public CurrentUser setUuid(String uuid)
      Sets the user's UUID
      Parameters:
      uuid - The user's UUID
      Returns:
      The user data
    • getUuid

      public String getUuid()
      Gets the user's UUID
      Returns:
      The user's UUID
    • setUserName

      public CurrentUser setUserName(String userName)
      Sets the user name
      Parameters:
      userName - The user name
      Returns:
      The user data
    • getUserName

      public String getUserName()
      Gets the user name
      Returns:
      The user name
    • setName

      public CurrentUser setName(String name)
      Sets the user's full name
      Parameters:
      name - The user's full name
      Returns:
      The user data
    • getName

      public String getName()
      Gets the user's full name
      Returns:
      The user's full name
    • getEmail

      public String getEmail()
      Gets the user's e-mail address
      Returns:
      The user's e-mail address
    • setEmail

      public CurrentUser setEmail(String email)
      Sets the user's e-mail address
      Parameters:
      email - The user's e-mail address
      Returns:
      The user data
    • getTelephoneNumber

      public String getTelephoneNumber()
      Gets the user's telephone number
      Returns:
      The user's telephone number
    • setTelephoneNumber

      public CurrentUser setTelephoneNumber(String telephoneNumber)
      Sets the user's telephone number
      Parameters:
      telephoneNumber - The user's telephone number
      Returns:
      The user data
    • getRoles

      public List<Role> getRoles()
      Gets the user's roles
      Returns:
      A list of the roles the user has or null, if there aren't any roles assigned to the user
    • setRoles

      public CurrentUser setRoles(List<Role> roles)
      Sets the user's roles. If this method is used, the previously assigned roles will be lost
      Parameters:
      roles - List of the user roles
      Returns:
      The user data
    • addRole

      public CurrentUser addRole(Role role)
      Adds the specified role to the user
      Parameters:
      role - The user role to be assigned
      Returns:
      The user data
    • addRoles

      public CurrentUser addRoles(Role... roles)
      Adds multiple roles to the user
      Parameters:
      roles - The user roles to be assigned
      Returns:
      The user data
    • addRoles

      public CurrentUser addRoles(List<Role> roles)
      Adds the specified list of roles to the user
      Parameters:
      roles - The list of roles to be added
      Returns:
      The user data
    • toString

      public String toString()
      Returns a string representation of the user data
      Overrides:
      toString in class Object
    • getCurrentRole

      public Role getCurrentRole()
      Gets the user's current role
      Returns:
      The user's current role
    • setCurrentRole

      public CurrentUser setCurrentRole(Role currentRole)

      Sets the user's current role

      A user can only have one active role. If the user has multiple roles, this method can be used to set the currently active user role so that the role can function properly

      Parameters:
      currentRole - The user's current role
      Returns:
      The user data
    • copy

      public CurrentUser copy()