Package MySTARS
Class User
java.lang.Object
MySTARS.User
- All Implemented Interfaces:
java.io.Serializable
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 AccessLevelaccessLevelTheAccessLevelof each User.private byte[]passwordThe encrypted password of each user.private static longserialVersionUIDThe unique ID of the class for Serialisation.private java.lang.StringusernameThe username associated with each network User. -
Constructor Summary
Constructors Modifier Constructor Description protectedUser(java.lang.String username, java.lang.String password, AccessLevel accessLevel)Initialiser for the User Class with a new username, password andAccessLevel.protectedUser(java.lang.String username, AccessLevel accessLevel)Initialiser for the User Class with a default password and a new username andAccessLevel. -
Method Summary
Modifier and Type Method Description protected booleanchangeAccessLevel(AccessLevel accessLevel)Changes theAccessLevelfor the User.booleanchangePassword()Changes the password for a User.booleancheckPassword(java.lang.String input)Checks if the password entered by the User is the correct password.private java.lang.StringdecryptPassword()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.AccessLevelgetAccessLevel()Getter method that retireves the AccessLevel of the User.java.lang.StringgetUsername()Getter method that retrieves the Username of the User.
-
Field Details
-
serialVersionUID
private static final long serialVersionUIDThe unique ID of the class for Serialisation.- See Also:
- Constant Field Values
-
username
private java.lang.String usernameThe username associated with each network User. -
accessLevel
TheAccessLevelof each User. -
password
private byte[] passwordThe encrypted password of each user.
-
-
Constructor Details
-
User
Initialiser for the User Class with a new username, password andAccessLevel.- Parameters:
username- The username of the User.password- The password of the User.accessLevel- The AccessLevel of the user.
-
User
Initialiser for the User Class with a default password and a new username andAccessLevel.- 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:
trueif 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:
trueif the password is correct.
-
changeAccessLevel
Changes theAccessLevelfor the User.- Parameters:
accessLevel- The new AccessLevel- Returns:
trueonce 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
Getter method that retireves the AccessLevel of the User.- Returns:
- the AccessLevel of the User.
-