Class UserController

java.lang.Object
org.noise_planet.noisemodelling.webserver.UserController

public class UserController extends Object
Handle users management Adapted from tutorial material from javalin-auth-example Do not add SQL queries in this class
  • Field Details

  • Constructor Details

  • Method Details

    • login

      public void login(io.javalin.http.Context ctx)
    • index

      public void index(io.javalin.http.Context ctx) throws SQLException
      Throws:
      SQLException
    • logout

      public void logout(io.javalin.http.Context ctx)
    • doLogin

      public void doLogin(io.javalin.http.Context ctx)
    • doRegister

      public void doRegister(io.javalin.http.Context ctx)
      Post method of register page
      Parameters:
      ctx - Context
    • createQRCodeImage

      public static String createQRCodeImage(URI totpUri) throws IOException
      Throws:
      IOException
    • formatTotpSecret

      public static String formatTotpSecret(String totpSecret)
      Format totp secret using block 4 of chars to be more readable for the user
      Parameters:
      totpSecret - totpSecret string (multiple of 4
      Returns:
      formated totpSecret
    • readMessagesArg

      public List<String> readMessagesArg(io.javalin.http.Context ctx)
    • register

      public void register(io.javalin.http.Context ctx)
      Display register page
      Parameters:
      ctx - Context
    • about

      public void about(io.javalin.http.Context ctx)
      Render user list HTML page
      Parameters:
      ctx - web context
    • users

      public void users(io.javalin.http.Context ctx)
      Render user list HTML page
      Parameters:
      ctx - web context
    • userEdit

      public void userEdit(io.javalin.http.Context ctx)
      Render user edit HTML page
      Parameters:
      ctx - web context
    • memoryStatsStreamOnConnect

      public void memoryStatsStreamOnConnect(io.javalin.websocket.WsConnectContext ctx)
      Handles WebSocket connection for memory stats streaming.
      Parameters:
      ctx - the WebSocket connect context
    • memoryStatsStreamOnClose

      public void memoryStatsStreamOnClose(io.javalin.websocket.WsCloseContext wsCloseContext)
      Handles WebSocket disconnection for memory stats streaming.
      Parameters:
      wsCloseContext - the WebSocket close context
    • getDatabaseFile

      @NotNull public File getDatabaseFile(User user)
      Retrieves the database file associated with the specified user.
      Parameters:
      user - The user for whom the database file is being retrieved.
      Returns:
      A File instance representing the user's database file.
    • getDatabaseFile

      public static File getDatabaseFile(int userId, String workingDirectory)
      Retrieves the database file associated with the specified user.
      Parameters:
      userId - The identifier of the user for whom the database file is being retrieved.
      workingDirectory - The working directory where the database file is located.
      Returns:
      A File instance representing the user's database file.