Class AuthHelper

java.lang.Object
org.rapidcontext.app.model.AuthHelper

public class AuthHelper extends Object
Helper methods for handling authentication tokens.
  • Method Details

    • createLoginToken

      public static String createLoginToken(User user, long expiry)
      Creates a login token for a user. The token contains the user id, an expiry timestamp and a validation signature.
      Parameters:
      user - the user to create the token for
      expiry - the expiry timestamp (in millis)
      Returns:
      the login token
    • validateLoginToken

      public static User validateLoginToken(String token)
      Validates a login token. This method supports both the new JWT format and the legacy auth token format.
      Parameters:
      token - the login token
      Returns:
      the authenticated user
      Throws:
      SecurityException - if the token is invalid or expired
    • createProcToken

      public static String createProcToken(Session session, String appId, String procId)
      Creates a procedure call token. The token contains the session id, the app identifier and the procedure identifier. This can be used to later validate the origin of procedure calls.
      Parameters:
      session - the user session
      appId - the app identifier
      procId - the procedure identifier
      Returns:
      the procedure token
    • validateProcToken

      public static String validateProcToken(String token, String procId)
      Validates a procedure call token.
      Parameters:
      token - the procedure call token
      procId - the expected procedure identifier
      Returns:
      the app identifier from the token
      Throws:
      SecurityException - if the token is invalid or expired