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

    Constructors
    Constructor
    Description
    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 on VaadinService.getCurrent().
    SecuredRouterLink(String text, Class<? extends com.vaadin.flow.component.Component> navigationTarget, SecuredVisibility.Requirement requirement)
    Builds a secured router link with SecuredVisibilityMode.HIDE and 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 Type
    Method
    Description
     
    protected void
    onAttach(com.vaadin.flow.component.AttachEvent attachEvent)
     
    final void
    Re-runs the visibility check against the current subject.
     
    afterNavigation, getHighlightAction, getHighlightCondition, getHref, getQueryParameters, setHighlightAction, setHighlightCondition, setQueryParameters, setRoute, setRoute, setRoute, setRoute, setRoute, setRoute

    Methods 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, setVisible

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface com.vaadin.flow.component.AttachNotifier

    addAttachListener

    Methods inherited from interface com.vaadin.flow.component.BlurNotifier

    addBlurListener

    Methods inherited from interface com.vaadin.flow.component.DetachNotifier

    addDetachListener

    Methods inherited from interface com.vaadin.flow.component.Focusable

    addFocusShortcut, blur, focus, focus, getTabIndex, setTabIndex

    Methods inherited from interface com.vaadin.flow.component.FocusNotifier

    addFocusListener

    Methods inherited from interface com.vaadin.flow.component.HasComponents

    add, add, add, addComponentAsFirst, addComponentAtIndex, bindChildren, getChildren, getComponentAt, getComponentCount, indexOf, remove, remove, removeAll, replace

    Methods inherited from interface com.vaadin.flow.component.HasEnabled

    bindEnabled, isEnabled, setEnabled

    Methods inherited from interface com.vaadin.flow.component.HasStyle

    addClassName, addClassNames, bindClassName, bindClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassName

    Methods 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 with SecuredVisibilityMode.HIDE and SPI-backed view lookup.
      Parameters:
      text - link label; non-null
      navigationTarget - Vaadin route target; non-null
      requirement - 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-null
      navigationTarget - non-null
      requirement - non-null
      mode - 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-null
      navigationTarget - non-null
      requirement - non-null
      mode - non-null
      viewSupplier - 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 on VaadinService.getCurrent().
      Parameters:
      router - explicit router; non-null
      text - non-null
      navigationTarget - non-null
      requirement - non-null
      mode - non-null
      viewSupplier - non-null
  • Method Details

    • onAttach

      protected void onAttach(com.vaadin.flow.component.AttachEvent attachEvent)
      Overrides:
      onAttach in class com.vaadin.flow.component.Component
    • refresh

      public final void refresh()
      Re-runs the visibility check against the current subject.
    • requirement

      public final SecuredVisibility.Requirement requirement()
      Returns:
      the requirement this link was constructed with
    • mode

      public final SecuredVisibilityMode mode()
      Returns:
      the visibility mode this link uses on denial