Package MySTARS

Class User

java.lang.Object
MySTARS.User
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
Admin, Student

public class User
extends java.lang.Object
implements java.io.Serializable
The superclass of all User classes in the application.
Since:
2020-11-1
Version:
1.0
Author:
Jia Hui, Bhargav
See Also:
Serialized Form
  • Field Summary

    Fields 
    Modifier and Type Field Description
    private AccessLevel accessLevel
    The AccessLevel of each User.
    private byte[] password
    The encrypted password of each user.
    private static long serialVersionUID
    The unique ID of the class for Serialisation.
    private java.lang.String username
    The username associated with each network User.
  • Constructor Summary

    Constructors 
    Modifier Constructor Description
    protected User​(java.lang.String username, java.lang.String password, AccessLevel accessLevel)
    Initialiser for the User Class with a new username, password and AccessLevel.
    protected User​(java.lang.String username, AccessLevel accessLevel)
    Initialiser for the User Class with a default password and a new username and AccessLevel.
  • Method Summary

    Modifier and Type Method Description
    protected boolean changeAccessLevel​(AccessLevel accessLevel)
    Changes the AccessLevel for the User.
    boolean changePassword()
    Changes the password for a User.
    boolean checkPassword​(java.lang.String input)
    Checks if the password entered by the User is the correct password.
    private java.lang.String decryptPassword()
    Decrypts the password stored as byte data, using the Base 64 encoding scheme as specified in RFC 4648 and RFC 2045.
    private byte[] encryptPassword​(java.lang.String rawString)
    Encrypts the raw password string using the Base64 encoding scheme as specified in RFC 4648 and RFC 2045.
    AccessLevel getAccessLevel()
    Getter method that retireves the AccessLevel of the User.
    java.lang.String getUsername()
    Getter method that retrieves the Username of the User.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • User

      protected User​(java.lang.String username, java.lang.String password, AccessLevel accessLevel)
      Initialiser for the User Class with a new username, password and AccessLevel.
      Parameters:
      username - The username of the User.
      password - The password of the User.
      accessLevel - The AccessLevel of the user.
    • User

      protected User​(java.lang.String username, AccessLevel accessLevel)
      Initialiser for the User Class with a default password and a new username and AccessLevel.
      Parameters:
      username - The username of the User.
      accessLevel - The AccessLevel of the user.
  • Method Details

    • changePassword

      public boolean changePassword()
      Changes the password for a User.
      Returns:
      true if password is successfully changed.
    • encryptPassword

      private byte[] encryptPassword​(java.lang.String rawString)
      Encrypts the raw password string using the Base64 encoding scheme as specified in RFC 4648 and RFC 2045.
      Parameters:
      rawString - the raw password string
      Returns:
      the encoded bytes
    • decryptPassword

      private java.lang.String decryptPassword()
      Decrypts the password stored as byte data, using the Base 64 encoding scheme as specified in RFC 4648 and RFC 2045.
      Returns:
      the raw password string
    • checkPassword

      public boolean checkPassword​(java.lang.String input)
      Checks if the password entered by the User is the correct password.
      Parameters:
      input - the password entered by the User.
      Returns:
      true if the password is correct.
    • changeAccessLevel

      protected boolean changeAccessLevel​(AccessLevel accessLevel)
      Changes the AccessLevel for the User.
      Parameters:
      accessLevel - The new AccessLevel
      Returns:
      true once AccessLevel has been changed.
    • getUsername

      public java.lang.String getUsername()
      Getter method that retrieves the Username of the User.
      Returns:
      The username as a String.
    • getAccessLevel

      public AccessLevel getAccessLevel()
      Getter method that retireves the AccessLevel of the User.
      Returns:
      the AccessLevel of the User.