java.lang.Object
de.codecamp.vaadin.security.spring.access.route.RouteAccessConfiguration
All Implemented Interfaces:
Serializable

public final class RouteAccessConfiguration extends Object implements Serializable
Allows to dynamically set the access rules for certain routes, navigation targets and parent layouts. This will override rules defined on navigation targets and parent layouts directly via SecuredAccess.

This is essentially the security counterpart for RouteConfiguration. As such, there's an application and a session scope, where the session scope can also see rules from the application scope. Both scopes consider SecuredAccess annotations on navigation targets and parent layouts when they have not been overriden.

See Also:
  • Method Details

    • forApplicationScope

      public static RouteAccessConfiguration forApplicationScope()
      Returns a configurator for application scoped access rules. This requires that VaadinServlet.getCurrent() is populated.
      Returns:
      configurator for application scoped access rules
    • forSessionScope

      public static RouteAccessConfiguration forSessionScope()
      Returns a configurator for session scoped access rules. This requires that VaadinSession.getCurrent() is populated.

      The session scope also returns access rules from the application scope.

      Returns:
      configurator for session scoped routes
    • setAccessRule

      public void setAccessRule(Class<? extends com.vaadin.flow.component.Component> targetOrLayout, AccessRule accessRule)
      Sets the access rule for the given navigation target or parent layout.

      Setting an access rule for a path will take precedence over access rules set for the target class.

      Parameters:
      targetOrLayout - the navigation target or parent layout
      accessRule - the access rule
    • removeAccessRule

      public void removeAccessRule(Class<? extends com.vaadin.flow.component.Component> targetOrLayout)
      Removes the access rule for the given navigation target or parent layout.
      Parameters:
      targetOrLayout - the navigation target or parent layout
    • getAccessRule

      public Optional<AccessRule> getAccessRule(Class<?> targetOrLayout)
      Returns the effective access rule for the given navigation target or parent layout.
      Parameters:
      targetOrLayout - the navigation target or parent layout
      Returns:
      the effective access rule for the navigation target or parent layout
    • getRegisteredAccessRulesForTargetsAndLayouts

      public Map<String,AccessRule> getRegisteredAccessRulesForTargetsAndLayouts()
      Returns all access rules registered for navigation targets or parent layouts.
      Returns:
      all access rules registered for navigation targets or parent layouts
    • setAccessRule

      public void setAccessRule(String routePath, AccessRule accessRule)
      Sets the access rule for the given route path.

      Setting an access rule for a path will take precedence over access rules set for the target class. Whether access rules for parent layouts are considered is still determined by AccessRule.checkLayout().

      Parameters:
      routePath - the route path
      accessRule - the access rule
    • removeAccessRule

      public void removeAccessRule(String routePath)
      Removes the access rule for the given route path.
      Parameters:
      routePath - the route path
    • getAccessRule

      public Optional<AccessRule> getAccessRule(String routePath)
      Returns the effective access rule for the given route path.
      Parameters:
      routePath - the route path
      Returns:
      the effective access rule for the given route path
    • getRegisteredAccessRulesForPaths

      public Map<String,AccessRule> getRegisteredAccessRulesForPaths()
      Returns all access rules registered route paths.
      Returns:
      all access rules registered route paths