Class SecuredRouterLink
java.lang.Object
com.vaadin.flow.component.Component
com.vaadin.flow.router.RouterLink
com.svenruppert.jsentinel.components.SecuredRouterLink
- All Implemented Interfaces:
com.vaadin.flow.component.AttachNotifier, com.vaadin.flow.component.BlurNotifier<com.vaadin.flow.router.RouterLink>, com.vaadin.flow.component.DetachNotifier, com.vaadin.flow.component.Focusable<com.vaadin.flow.router.RouterLink>, com.vaadin.flow.component.FocusNotifier<com.vaadin.flow.router.RouterLink>, com.vaadin.flow.component.HasComponents, com.vaadin.flow.component.HasElement, com.vaadin.flow.component.HasEnabled, com.vaadin.flow.component.HasStyle, com.vaadin.flow.component.HasText, com.vaadin.flow.router.AfterNavigationObserver, com.vaadin.flow.router.internal.AfterNavigationHandler, Serializable
@ExperimentalJSentinelApi
public class SecuredRouterLink
extends com.vaadin.flow.router.RouterLink
RouterLink subclass that hides or disables itself when the
current subject does not satisfy the supplied
SecuredVisibility.Requirement. Defaults to
SecuredVisibilityMode.HIDE — navigation affordances that
the user can't follow should disappear, not linger as dead links.
Authoritative protection of the target route stays with the
AuthorizationListener pipeline. This component is a UI
affordance — a hidden link is not a security boundary.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.vaadin.flow.component.BlurNotifier
com.vaadin.flow.component.BlurNotifier.BlurEvent<C>Nested classes/interfaces inherited from interface com.vaadin.flow.component.FocusNotifier
com.vaadin.flow.component.FocusNotifier.FocusEvent<C>Nested classes/interfaces inherited from interface com.vaadin.flow.component.HasText
com.vaadin.flow.component.HasText.WhiteSpace -
Constructor Summary
ConstructorsConstructorDescriptionSecuredRouterLink(com.vaadin.flow.router.Router router, String text, Class<? extends com.vaadin.flow.component.Component> navigationTarget, SecuredVisibility.Requirement requirement, SecuredVisibilityMode mode, Supplier<Optional<SecuredVisibility.JSentinelView>> viewSupplier) Router-explicit constructor — for headless tests or routing setups where the router isn't bound onVaadinService.getCurrent().SecuredRouterLink(String text, Class<? extends com.vaadin.flow.component.Component> navigationTarget, SecuredVisibility.Requirement requirement) Builds a secured router link withSecuredVisibilityMode.HIDEand SPI-backed view lookup.SecuredRouterLink(String text, Class<? extends com.vaadin.flow.component.Component> navigationTarget, SecuredVisibility.Requirement requirement, SecuredVisibilityMode mode) Builds a secured router link with a custom mode and SPI-backed view lookup.SecuredRouterLink(String text, Class<? extends com.vaadin.flow.component.Component> navigationTarget, SecuredVisibility.Requirement requirement, SecuredVisibilityMode mode, Supplier<Optional<SecuredVisibility.JSentinelView>> viewSupplier) Full constructor. -
Method Summary
Modifier and TypeMethodDescriptionfinal SecuredVisibilityModemode()protected voidonAttach(com.vaadin.flow.component.AttachEvent attachEvent) final voidrefresh()Re-runs the visibility check against the current subject.Methods inherited from class com.vaadin.flow.router.RouterLink
afterNavigation, getHighlightAction, getHighlightCondition, getHref, getQueryParameters, setHighlightAction, setHighlightCondition, setQueryParameters, setRoute, setRoute, setRoute, setRoute, setRoute, setRouteMethods inherited from class com.vaadin.flow.component.Component
addListener, bindVisible, findAncestor, fireEvent, from, get, getChildren, getElement, getEventBus, getId, getListeners, getLocale, getParent, getTestId, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onDetach, onEnabledStateChanged, removeFromParent, scrollIntoView, scrollIntoView, set, setElement, setId, setTestId, setVisibleMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.vaadin.flow.component.AttachNotifier
addAttachListenerMethods inherited from interface com.vaadin.flow.component.BlurNotifier
addBlurListenerMethods inherited from interface com.vaadin.flow.component.DetachNotifier
addDetachListenerMethods inherited from interface com.vaadin.flow.component.Focusable
addFocusShortcut, blur, focus, focus, getTabIndex, setTabIndexMethods inherited from interface com.vaadin.flow.component.FocusNotifier
addFocusListenerMethods inherited from interface com.vaadin.flow.component.HasComponents
add, add, add, addComponentAsFirst, addComponentAtIndex, bindChildren, getChildren, getComponentAt, getComponentCount, indexOf, remove, remove, removeAll, replaceMethods inherited from interface com.vaadin.flow.component.HasEnabled
bindEnabled, isEnabled, setEnabledMethods inherited from interface com.vaadin.flow.component.HasStyle
addClassName, addClassNames, bindClassName, bindClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassNameMethods inherited from interface com.vaadin.flow.component.HasText
bindText, getText, getWhiteSpace, setText, setWhiteSpace
-
Constructor Details
-
SecuredRouterLink
public SecuredRouterLink(String text, Class<? extends com.vaadin.flow.component.Component> navigationTarget, SecuredVisibility.Requirement requirement) Builds a secured router link withSecuredVisibilityMode.HIDEand SPI-backed view lookup.- Parameters:
text- link label; non-nullnavigationTarget- Vaadin route target; non-nullrequirement- what the link requires; non-null
-
SecuredRouterLink
public SecuredRouterLink(String text, Class<? extends com.vaadin.flow.component.Component> navigationTarget, SecuredVisibility.Requirement requirement, SecuredVisibilityMode mode) Builds a secured router link with a custom mode and SPI-backed view lookup.- Parameters:
text- non-nullnavigationTarget- non-nullrequirement- non-nullmode- non-null
-
SecuredRouterLink
public SecuredRouterLink(String text, Class<? extends com.vaadin.flow.component.Component> navigationTarget, SecuredVisibility.Requirement requirement, SecuredVisibilityMode mode, Supplier<Optional<SecuredVisibility.JSentinelView>> viewSupplier) Full constructor.- Parameters:
text- non-nullnavigationTarget- non-nullrequirement- non-nullmode- non-nullviewSupplier- non-null
-
SecuredRouterLink
public SecuredRouterLink(com.vaadin.flow.router.Router router, String text, Class<? extends com.vaadin.flow.component.Component> navigationTarget, SecuredVisibility.Requirement requirement, SecuredVisibilityMode mode, Supplier<Optional<SecuredVisibility.JSentinelView>> viewSupplier) Router-explicit constructor — for headless tests or routing setups where the router isn't bound onVaadinService.getCurrent().- Parameters:
router- explicit router; non-nulltext- non-nullnavigationTarget- non-nullrequirement- non-nullmode- non-nullviewSupplier- non-null
-
-
Method Details
-
onAttach
protected void onAttach(com.vaadin.flow.component.AttachEvent attachEvent) - Overrides:
onAttachin classcom.vaadin.flow.component.Component
-
refresh
public final void refresh()Re-runs the visibility check against the current subject. -
requirement
- Returns:
- the requirement this link was constructed with
-
mode
- Returns:
- the visibility mode this link uses on denial
-