Class AuthWrapper
java.lang.Object
io.mindspice.simplypages.editing.AuthWrapper
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> TExecutesactionwhen authorized, otherwise executesunauthorizedHandler.static StringrequireForCreate(Supplier<Boolean> authCheck, Supplier<String> action) Authorization wrapper for create operations with default unauthorized modal.static StringrequireForDelete(Supplier<Boolean> authCheck, Supplier<String> action) Authorization wrapper for delete operations with default unauthorized modal.static StringrequireForEdit(Supplier<Boolean> authCheck, Supplier<String> action) Authorization wrapper for edit operations with default unauthorized modal.static StringAuthorization wrapper for edit operations with custom error text.
-
Constructor Details
-
AuthWrapper
public AuthWrapper()
-
-
Method Details
-
require
public static <T> T require(Supplier<Boolean> authCheck, Supplier<T> action, Supplier<T> unauthorizedHandler) Executesactionwhen authorized, otherwise executesunauthorizedHandler.- Type Parameters:
T- Return type of the action- Parameters:
authCheck- Supplier that returns true if action is authorizedaction- Action to perform if authorizedunauthorizedHandler- Response to return if not authorized- Returns:
- Result of action if authorized, otherwise result of unauthorizedHandler
-
requireForEdit
Authorization wrapper for edit operations with default unauthorized modal.- Parameters:
authCheck- Supplier that returns true if edit is authorizedaction- 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 authorizedaction- Action to perform if authorizederrorMessage- Custom error message to display if unauthorized- Returns:
- Result of action if authorized, otherwise modal with custom error
-
requireForDelete
Authorization wrapper for delete operations with default unauthorized modal.- Parameters:
authCheck- Supplier that returns true if delete is authorizedaction- Action to perform if authorized- Returns:
- Result of action if authorized, otherwise unauthorized modal
-
requireForCreate
Authorization wrapper for create operations with default unauthorized modal.- Parameters:
authCheck- Supplier that returns true if create is authorizedaction- Action to perform if authorized- Returns:
- Result of action if authorized, otherwise unauthorized modal
-