Class RequestPoster

java.lang.Object
net.minheur.potoflux.login.RequestPoster

public class RequestPoster extends Object
This posts all requests to the SQL database.
  • Constructor Details

    • RequestPoster

      public RequestPoster()
  • Method Details

    • login

      public static String login(String email, String password) throws IOException
      Asks for a token, from an email and a password
      Parameters:
      email - id of the account
      password - password associated
      Returns:
      the database's response
      Throws:
      IOException - if the server couldn't be reached
    • checkToken

      public static String checkToken(String token) throws IOException, InvalidTokenException
      Checks if a token exists
      Parameters:
      token - token to check
      Returns:
      the database's response
      Throws:
      IOException - if the server couldn't be reached
      InvalidTokenException - if the token has invalid format
    • getInfos

      public static String getInfos(String token) throws IOException, InvalidTokenException
      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 reached
      InvalidTokenException - 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 token
      email - of the new user
      password - of the new user
      firstName - of the new user
      lastName - of the new user
      perms - of the new user
      rank - of the new user
      Returns:
      the database's response
      Throws:
      IOException - if the server couldn't be reached
      InvalidTokenException - if the admin's token has invalid format
    • rmUser

      public static String rmUser(String token, String email) throws InvalidTokenException, IOException
      Removal of an account by and admin
      Parameters:
      token - of the admin
      email - of the targeted account
      Returns:
      the database's response
      Throws:
      IOException - if the server couldn't be reached
      InvalidTokenException - 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 account
      password - for the account
      firstName - of the user
      lastName - of the user
      Returns:
      the database's response
      Throws:
      IOException - if the server couldn't be reached
    • listUsers

      public static String listUsers(String token) throws InvalidTokenException, IOException
      Lists all users UUIDs
      Parameters:
      token - of the admin
      Returns:
      the database's response
      Throws:
      IOException - if the server couldn't be reached
      InvalidTokenException - 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 admin
      userUuid - of the account to get specific specs
      Returns:
      the database's response
      Throws:
      IOException - if the server couldn't be reached
      InvalidTokenException - 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 admin
      targetUuid - to modify the account of
      newEmail - of the account, of null if unchanged
      newFirstName - of the account, of null if unchanged
      newLastName - of the account, of null if unchanged
      newRank - of the account, of 0 if unchanged
      perms - of the account, of null if unchanged
      Returns:
      the database's response
      Throws:
      IOException - if the server couldn't be reached
      InvalidTokenException - 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 admin
      targetUuid - to change the password of
      newPassword - for the account
      Returns:
      the database's response
      Throws:
      IOException - if the server couldn't be reached
      InvalidTokenException - 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 admin
      targetUuid - that will be locked or unlocked
      newState - weather the account will now be locked or not
      Returns:
      the database's response
      Throws:
      IOException - if the server couldn't be reached
      InvalidTokenException - 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 admin
      newState - weather the account self-creation is now allowed or not
      Returns:
      the database's response
      Throws:
      IOException - if the server couldn't be reached
      InvalidTokenException - if the admin's token has invalid format
    • rmToken

      public static void rmToken(String token) throws IOException
      Remove a token from the database active tokens
      Parameters:
      token - to be removed
      Throws:
      IOException - if the server couldn't be reached
    • getNotifications

      public static String getNotifications(String token) throws IOException, InvalidTokenException
      Throws:
      IOException
      InvalidTokenException
    • isAccountCreationEnabled

      public static String isAccountCreationEnabled() throws IOException
      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()