Package org.zkoss.spring.security
Class SecurityUtil
java.lang.Object
org.zkoss.spring.security.SecurityUtil
Utility class for ZK spring security.
- Author:
- henrichen
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic org.springframework.security.core.AuthenticationReturn the current Authentication object.static ObjectgetAuthentication(String property) Return the evaluated result per the given property of the current Authentication object.static booleanisAccessible(String hasPermission, Object domainObject) Return true if the current Authentication has one of the specified permissions to the presented domain object instance.static booleanisAllGranted(String authorities) Return true if the authenticated principal is granted ALL of the roles specified in authorities.static booleanisAnyGranted(String authorities) Return true if the authenticated principal is granted ANY of the roles specified in authorities.static booleanisNoneGranted(String authorities) Return true if the authenticated principal is granted NONE of the roles specified in authorities.
-
Constructor Details
-
SecurityUtil
public SecurityUtil()
-
-
Method Details
-
isAccessible
Return true if the current Authentication has one of the specified permissions to the presented domain object instance.- Parameters:
hasPermission- A comma separated list of integers, each representing a required bit mask permission from a subclass ofBasePermission.domainObject- The actual domain object instance for which permissions are being evaluated.- Returns:
- true if current Authentication has one of the specified permission to the presented domain object instance.
-
isNoneGranted
Return true if the authenticated principal is granted NONE of the roles specified in authorities.- Parameters:
authorities- A comma separated list of roles which the user must have been granted NONE.- Returns:
- true if the authenticated principal is granted authorities of NONE the specified roles.
-
isAllGranted
Return true if the authenticated principal is granted ALL of the roles specified in authorities.- Parameters:
authorities- A comma separated list of roles which the user must have been granted ALL.- Returns:
- true true if the authenticated principal is granted authorities of ALL the specified roles.
-
isAnyGranted
Return true if the authenticated principal is granted ANY of the roles specified in authorities.- Parameters:
authorities- A comma separated list of roles which the user must have been granted ANY.- Returns:
- true true if the authenticated principal is granted authorities of ALL the specified roles.
-
getAuthentication
public static org.springframework.security.core.Authentication getAuthentication()Return the current Authentication object.- Returns:
- the current
Authenticationobject retrieved fromSecurityContextHolderor null
-
getAuthentication
Return the evaluated result per the given property of the current Authentication object.- Parameters:
property- Property of the Authentication object which would be evaluated. Supports nested properties. For example if the principal object is an instance of UserDetails, the property "principal.username" will return the username. Alternatively, using "name" will call getName method on the Authentication object directly.- Returns:
- the evaluated result of the current Authentication object per the given property.
-