Class Auth

java.lang.Object
no.ntnu.principes.util.Auth

public class Auth extends Object
Manages authentication state throughout the application using the singleton pattern. Stores the currently authenticated profile and provides access to authentication status.
  • Property Summary

    Properties
    Type
    Property
    Description
    javafx.beans.property.ObjectProperty<Profile>
    Gets the observable profile property.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new Auth instance with the member repository from the database manager.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    authenticate(Long profileId)
    Authenticates a user with the specified profile ID.
    void
    Authenticates a user with the specified profile.
    void
    Logs out the current user by clearing profile data and authentication state.
    static Auth
    Gets the singleton instance of Auth, creating it if necessary.
    Gets the currently authenticated profile.
    boolean
    Checks if a user is currently authenticated.
    javafx.beans.property.BooleanProperty
    Gets the observable authentication state property.
    javafx.beans.property.ObjectProperty<Profile>
    Gets the observable profile property.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Property Details

  • Constructor Details

    • Auth

      public Auth()
      Creates a new Auth instance with the member repository from the database manager.
  • Method Details

    • getInstance

      public static Auth getInstance()
      Gets the singleton instance of Auth, creating it if necessary.
      Returns:
      The single Auth instance for the application
    • authenticate

      public void authenticate(Profile profile)
      Authenticates a user with the specified profile.
      Parameters:
      profile - The profile to authenticate with
    • authenticate

      public void authenticate(Long profileId)
      Authenticates a user with the specified profile ID.
      Parameters:
      profileId - The ID of the profile to authenticate with
      Throws:
      IllegalArgumentException - If no profile exists with the given ID
    • deauthenticate

      public void deauthenticate()
      Logs out the current user by clearing profile data and authentication state.
    • isAuthenticatedProperty

      public javafx.beans.property.BooleanProperty isAuthenticatedProperty()
      Gets the observable authentication state property.
      Returns:
      Property indicating whether a user is authenticated
    • isAuthenticated

      public boolean isAuthenticated()
      Checks if a user is currently authenticated.
      Returns:
      True if a user is authenticated, false otherwise
    • profileProperty

      public javafx.beans.property.ObjectProperty<Profile> profileProperty()
      Gets the observable profile property.
      Returns:
      Property containing the currently authenticated profile
      See Also:
    • getProfile

      public Profile getProfile()
      Gets the currently authenticated profile.
      Returns:
      The authenticated profile or null if no user is authenticated