Class AuthWrapper

java.lang.Object
io.mindspice.simplypages.editing.AuthWrapper

public class AuthWrapper extends Object
Small utility for wrapping edit actions with authorization checks.

Framework boundary: this class only gates execution and returns fallback UI content. It does not authenticate users or enforce transport-layer protections.

Mutability and thread-safety: stateless utility methods; thread-safe.

  • Constructor Details

    • AuthWrapper

      public AuthWrapper()
  • Method Details

    • require

      public static <T> T require(Supplier<Boolean> authCheck, Supplier<T> action, Supplier<T> unauthorizedHandler)
      Executes action when authorized, otherwise executes unauthorizedHandler.
      Type Parameters:
      T - Return type of the action
      Parameters:
      authCheck - Supplier that returns true if action is authorized
      action - Action to perform if authorized
      unauthorizedHandler - Response to return if not authorized
      Returns:
      Result of action if authorized, otherwise result of unauthorizedHandler
    • requireForEdit

      public static String requireForEdit(Supplier<Boolean> authCheck, Supplier<String> action)
      Authorization wrapper for edit operations with default unauthorized modal.
      Parameters:
      authCheck - Supplier that returns true if edit is authorized
      action - Action to perform if authorized (typically returns Modal HTML)
      Returns:
      Result of action if authorized, otherwise unauthorized modal
    • requireForEdit

      public static String requireForEdit(Supplier<Boolean> authCheck, Supplier<String> action, String errorMessage)
      Authorization wrapper for edit operations with custom error text.
      Parameters:
      authCheck - Supplier that returns true if edit is authorized
      action - Action to perform if authorized
      errorMessage - Custom error message to display if unauthorized
      Returns:
      Result of action if authorized, otherwise modal with custom error
    • requireForDelete

      public static String requireForDelete(Supplier<Boolean> authCheck, Supplier<String> action)
      Authorization wrapper for delete operations with default unauthorized modal.
      Parameters:
      authCheck - Supplier that returns true if delete is authorized
      action - Action to perform if authorized
      Returns:
      Result of action if authorized, otherwise unauthorized modal
    • requireForCreate

      public static String requireForCreate(Supplier<Boolean> authCheck, Supplier<String> action)
      Authorization wrapper for create operations with default unauthorized modal.
      Parameters:
      authCheck - Supplier that returns true if create is authorized
      action - Action to perform if authorized
      Returns:
      Result of action if authorized, otherwise unauthorized modal