java.lang.Object
de.codecamp.vaadin.security.spring.access.VaadinSecurity

public final class VaadinSecurity extends Object
Utility class to programmatically evaluate Spring Security expressions (see hasAccess(String)) or call operations available to those expressions directly (see check()).

The Authentication is available in all request threads (Vaadin request or otherwise) and in all threads where the current Vaadin session is available.

See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns operations that allow to check for certain access of the current Authentication.
    check(org.springframework.security.core.Authentication authentication)
    Check for access by querying the methods of the returned VaadinSecurityExpressionOperations.
    static org.springframework.security.core.Authentication
    Deprecated.
    just use SecurityContextHolder.getContext().getAuthentication()
    static boolean
    hasAccess(String securityExpression)
    Returns whether the current Authentication has access based on the given security expression.
    static boolean
    hasAccess(org.springframework.security.core.Authentication authentication, String securityExpression)
    Returns whether the given Authentication has access based on the specified Spring security expression.
    static boolean
    hasAccessTo(Class<? extends com.vaadin.flow.component.Component> navigationTarget)
    Returns whether the current Authentication has access to the given navigation target.
    static boolean
    hasAccessTo(String routePath)
    Returns whether the current Authentication has access to the given route path.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • check

      public static VaadinSecurityExpressionOperations check()
      Returns operations that allow to check for certain access of the current Authentication. The available operations are the same as in the expressions.

      The Authentication is available in all request threads (Vaadin request or otherwise) and in all threads where the current Vaadin session is available.

      Returns:
      the security operations
    • check

      public static VaadinSecurityExpressionOperations check(org.springframework.security.core.Authentication authentication)
      Check for access by querying the methods of the returned VaadinSecurityExpressionOperations. The available operations are the same as in the expressions.
      Parameters:
      authentication - the authentication to be tested
      Returns:
      the security operations
    • hasAccess

      public static boolean hasAccess(String securityExpression)
      Returns whether the current Authentication has access based on the given security expression.

      The Authentication is available in all request threads (Vaadin request or otherwise) and in all threads where the current Vaadin session is available.

      Parameters:
      securityExpression - the Spring Security expression
      Returns:
      whether the current security context has access
      See Also:
      • SecurityContextHolder.getContext()
    • hasAccess

      public static boolean hasAccess(org.springframework.security.core.Authentication authentication, String securityExpression)
      Returns whether the given Authentication has access based on the specified Spring security expression.
      Parameters:
      authentication - the authentication to be tested
      securityExpression - the Spring Security expression
      Returns:
      whether the current security context has access
    • hasAccessTo

      public static boolean hasAccessTo(Class<? extends com.vaadin.flow.component.Component> navigationTarget)
      Returns whether the current Authentication has access to the given navigation target.
      Parameters:
      navigationTarget - the navigation targets to be checked for access
      Returns:
      whether the current security context has access
      See Also:
      • SecurityContextHolder.getContext()
    • hasAccessTo

      public static boolean hasAccessTo(String routePath)
      Returns whether the current Authentication has access to the given route path.
      Parameters:
      routePath - the route path to be checked for access
      Returns:
      whether the current security context has access
      See Also:
      • SecurityContextHolder.getContext()
    • getAuthentication

      @Deprecated public static org.springframework.security.core.Authentication getAuthentication()
      Deprecated.
      just use SecurityContextHolder.getContext().getAuthentication()
      Returns the current Authentication, if available. The Authentication is available in all request threads (Vaadin request or otherwise) and in all threads where the current Vaadin session is available.
      Returns:
      the current Authentication if available, null otherwise