Class VaadinSecurity
- java.lang.Object
-
- de.codecamp.vaadin.security.spring.access.VaadinSecurity
-
public class VaadinSecurity extends Object
Utility class to programmatically evaluate Spring Security expressions (seehasAccess(String)), or call operations available to those expressions directly (seecheck()).The current
Authenticationis available in all request threads (throughSecurityContextHolderand in all threads that are currentlyaccessing the UI.- See Also:
- Expression-Based Access Control
-
-
Constructor Summary
Constructors Constructor Description VaadinSecurity()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static VaadinSecurityExpressionOperationscheck()Returnsoperationsthat allow to check for certain access of the currentAuthentication.static VaadinSecurityExpressionOperationscheck(org.springframework.security.core.Authentication authentication)Check for access by querying the methods of the returnedVaadinSecurityExpressionOperations.static org.springframework.security.core.AuthenticationgetAuthentication()Returns the currentAuthentication.static booleanhasAccess(String securityExpression)Returns 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.
-
-
-
Method Detail
-
check
public static VaadinSecurityExpressionOperations check()
Returnsoperationsthat allow to check for certain access of the currentAuthentication. The available operations are the same as in the expressions. The authentication is available in all request threads (throughSecurityContextHolderand in all threads that are currentlyaccessing 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 returnedVaadinSecurityExpressionOperations. 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 currentAuthenticationhas access based on the given security expression. The authentication is available in all request threads (throughSecurityContextHolderand in all threads that are currentlyaccessing 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 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
-
getAuthentication
public static org.springframework.security.core.Authentication getAuthentication()
Returns the currentAuthentication. The authentication is available in all request threads (throughSecurityContextHolderand in all threads that are currentlyaccessing the UI.- Returns:
- the current
Authentication
-
-