Class VaadinSecurity
java.lang.Object
de.codecamp.vaadin.security.spring.access.VaadinSecurity
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:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncheck()Returnsoperationsthat allow to check for certain access of the currentAuthentication.check(org.springframework.security.core.Authentication authentication) Check for access by querying the methods of the returnedVaadinSecurityExpressionOperations.static org.springframework.security.core.AuthenticationDeprecated.static booleanReturns whether the currentAuthenticationhas access based on the given security expression.static booleanhasAccess(org.springframework.security.core.Authentication authentication, String securityExpression) Returns whether the givenAuthenticationhas access based on the specified Spring security expression.static booleanhasAccessTo(Class<? extends com.vaadin.flow.component.Component> navigationTarget) Returns whether the currentAuthenticationhas access to the given navigation target.static booleanhasAccessTo(String routePath) Returns whether the currentAuthenticationhas access to the given route path.
-
Constructor Details
-
VaadinSecurity
public VaadinSecurity()
-
-
Method Details
-
check
Returnsoperationsthat allow to check for certain access of the currentAuthentication. The available operations are the same as in the expressions.The
Authenticationis available in all request threads (Vaadin request or otherwise) and in all threads where thecurrent Vaadin sessionis 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 returnedVaadinSecurityExpressionOperations. The available operations are the same as in the expressions.- Parameters:
authentication- the authentication to be tested- Returns:
- the security operations
-
hasAccess
Returns whether the currentAuthenticationhas access based on the given security expression.The
Authenticationis available in all request threads (Vaadin request or otherwise) and in all threads where thecurrent Vaadin sessionis 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 givenAuthenticationhas access based on the specified Spring security expression.- Parameters:
authentication- the authentication to be testedsecurityExpression- 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 currentAuthenticationhas 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
Returns whether the currentAuthenticationhas 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.just useSecurityContextHolder.getContext().getAuthentication()Returns the currentAuthentication, if available. TheAuthenticationis available in all request threads (Vaadin request or otherwise) and in all threads where thecurrent Vaadin sessionis available.- Returns:
- the current
Authenticationif available, null otherwise
-
SecurityContextHolder.getContext().getAuthentication()