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 AccessLevel
accessLevel
TheAccessLevel
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 andAccessLevel
.protected
User(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 boolean
changeAccessLevel(AccessLevel accessLevel)
Changes theAccessLevel
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.
-
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
TheAccessLevel
of 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:
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
Changes theAccessLevel
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
Getter method that retireves the AccessLevel of the User.- Returns:
- the AccessLevel of the User.
-