Annotation Interface ForbidsUser
@Documented
@Target({TYPE,CONSTRUCTOR,METHOD,ANNOTATION_TYPE,PACKAGE})
@Retention(RUNTIME)
@Inherited
public @interface ForbidsUser
Indicates that a handler method, class, package, or payload should not be invoked or processed if a user is
currently authenticated.
This annotation acts as a negative filter for message handling based on user presence.
Useful for restricting certain behavior to unauthenticated flows only — such as registration, public APIs, or guest access paths.
- See Also:
-
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionboolean
Determines whether an exception should be thrown when the authorization check fails.
-
Element Details
-
throwIfUnauthorized
boolean throwIfUnauthorizedDetermines whether an exception should be thrown when the authorization check fails.If
true
(the default), anUnauthorizedException
will be thrown when a user is present.If
false
, the annotated handler or message will be silently skipped instead.This opt-out strategy is useful for conditionally invoked handlers where fallback behavior is preferred.
- Default:
true
-