Class VaadinSecurity


  • public 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 current Authentication is available in all request threads (through SecurityContextHolder and in all threads that are currently accessing the UI.

    See Also:
    Expression-Based Access Control
    • Constructor Detail

      • VaadinSecurity

        public VaadinSecurity()
    • Method Detail

      • 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 (through SecurityContextHolder and in all threads that are currently accessing the UI.
        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 (through SecurityContextHolder and in all threads that are currently accessing the UI.
        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
      • getAuthentication

        public static org.springframework.security.core.Authentication getAuthentication()
        Returns the current Authentication. The authentication is available in all request threads (through SecurityContextHolder and in all threads that are currently accessing the UI.
        Returns:
        the current Authentication