Package net.minheur.potoflux.login
Class RequestPoster
java.lang.Object
net.minheur.potoflux.login.RequestPoster
This posts all requests to the SQL database.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringaddUser(String token, String email, String password, String firstName, String lastName, String[] perms, int rank) Creation of a user by an adminstatic StringcheckToken(String token) Checks if a token existsstatic StringcreateAccount(String email, String password, String firstName, String lastName) Account self-creation posterstatic StringGet infos about your own account with your tokenstatic StringgetNotifications(String token) static StringgetUserInfos(String token, String userUuid) Get infos for a specified userstatic StringGets if the account self-creation is allowedstatic StringLists all users UUIDsstatic StringlockAccountCreation(String token, boolean newState) Disable or enable account self-creationstatic StringLock or unlock a user's accountstatic StringAsks for a token, from an email and a passwordstatic StringmdUserInfos(String token, String targetUuid, @Nullable String newEmail, @Nullable String newFirstName, @Nullable String newLastName, int newRank, @Nullable String[] perms) Modify an accountstatic StringmdUserPassword(String token, String targetUuid, String newPassword) Modify an account's passwordstatic voidRemove a token from the database active tokensstatic StringRemoval of an account by and adminstatic void
-
Constructor Details
-
RequestPoster
public RequestPoster()
-
-
Method Details
-
login
Asks for a token, from an email and a password- Parameters:
email- id of the accountpassword- password associated- Returns:
- the database's response
- Throws:
IOException- if the server couldn't be reached
-
checkToken
Checks if a token exists- Parameters:
token- token to check- Returns:
- the database's response
- Throws:
IOException- if the server couldn't be reachedInvalidTokenException- if the token has invalid format
-
getInfos
Get infos about your own account with your token- Parameters:
token- associated with your account- Returns:
- the database's response
- Throws:
IOException- if the server couldn't be reachedInvalidTokenException- if the token has invalid format
-
addUser
public static String addUser(String token, String email, String password, String firstName, String lastName, String[] perms, int rank) throws InvalidTokenException, IOException Creation of a user by an admin- Parameters:
token- the admin's tokenemail- of the new userpassword- of the new userfirstName- of the new userlastName- of the new userperms- of the new userrank- of the new user- Returns:
- the database's response
- Throws:
IOException- if the server couldn't be reachedInvalidTokenException- if the admin's token has invalid format
-
rmUser
Removal of an account by and admin- Parameters:
token- of the adminemail- of the targeted account- Returns:
- the database's response
- Throws:
IOException- if the server couldn't be reachedInvalidTokenException- if the admin's token has invalid format
-
createAccount
public static String createAccount(String email, String password, String firstName, String lastName) throws IOException Account self-creation poster- Parameters:
email- of the accountpassword- for the accountfirstName- of the userlastName- of the user- Returns:
- the database's response
- Throws:
IOException- if the server couldn't be reached
-
listUsers
Lists all users UUIDs- Parameters:
token- of the admin- Returns:
- the database's response
- Throws:
IOException- if the server couldn't be reachedInvalidTokenException- if the admin's token has invalid format
-
getUserInfos
public static String getUserInfos(String token, String userUuid) throws InvalidTokenException, IOException Get infos for a specified user- Parameters:
token- of the adminuserUuid- of the account to get specific specs- Returns:
- the database's response
- Throws:
IOException- if the server couldn't be reachedInvalidTokenException- if the admin's token has invalid format
-
mdUserInfos
public static String mdUserInfos(String token, String targetUuid, @Nullable @Nullable String newEmail, @Nullable @Nullable String newFirstName, @Nullable @Nullable String newLastName, int newRank, @Nullable @Nullable String[] perms) throws InvalidTokenException, IOException Modify an account- Parameters:
token- of the admintargetUuid- to modify the account ofnewEmail- of the account, ofnullif unchangednewFirstName- of the account, ofnullif unchangednewLastName- of the account, ofnullif unchangednewRank- of the account, of0if unchangedperms- of the account, ofnullif unchanged- Returns:
- the database's response
- Throws:
IOException- if the server couldn't be reachedInvalidTokenException- if the admin's token has invalid format
-
mdUserPassword
public static String mdUserPassword(String token, String targetUuid, String newPassword) throws InvalidTokenException, IOException Modify an account's password- Parameters:
token- of the admintargetUuid- to change the password ofnewPassword- for the account- Returns:
- the database's response
- Throws:
IOException- if the server couldn't be reachedInvalidTokenException- if the admin's token has invalid format
-
lockUser
public static String lockUser(String token, String targetUuid, boolean newState) throws InvalidTokenException, IOException Lock or unlock a user's account- Parameters:
token- of the admintargetUuid- that will be locked or unlockednewState- weather the account will now be locked or not- Returns:
- the database's response
- Throws:
IOException- if the server couldn't be reachedInvalidTokenException- if the admin's token has invalid format
-
lockAccountCreation
public static String lockAccountCreation(String token, boolean newState) throws InvalidTokenException, IOException Disable or enable account self-creation- Parameters:
token- of the adminnewState- weather the account self-creation is now allowed or not- Returns:
- the database's response
- Throws:
IOException- if the server couldn't be reachedInvalidTokenException- if the admin's token has invalid format
-
rmToken
Remove a token from the database active tokens- Parameters:
token- to be removed- Throws:
IOException- if the server couldn't be reached
-
getNotifications
- Throws:
IOExceptionInvalidTokenException
-
isAccountCreationEnabled
Gets if the account self-creation is allowed- Returns:
- the database's response
- Throws:
IOException- if the server couldn't be reached
-
warmupTls
public static void warmupTls()
-