Class SecurityUtil

java.lang.Object
org.zkoss.spring.security.SecurityUtil

public class SecurityUtil extends Object
Utility class for ZK spring security.
Author:
henrichen
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static org.springframework.security.core.Authentication
    Return the current Authentication object.
    static Object
    Return the evaluated result per the given property of the current Authentication object.
    static boolean
    isAccessible(String hasPermission, Object domainObject)
    Return true if the current Authentication has one of the specified permissions to the presented domain object instance.
    static boolean
    isAllGranted(String authorities)
    Return true if the authenticated principal is granted ALL of the roles specified in authorities.
    static boolean
    isAnyGranted(String authorities)
    Return true if the authenticated principal is granted ANY of the roles specified in authorities.
    static boolean
    isNoneGranted(String authorities)
    Return true if the authenticated principal is granted NONE of the roles specified in authorities.

    Methods inherited from class java.lang.Object

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

    • SecurityUtil

      public SecurityUtil()
  • Method Details

    • isAccessible

      public static boolean isAccessible(String hasPermission, Object domainObject)
      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 of BasePermission.
      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

      public static boolean isNoneGranted(String authorities)
      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

      public static boolean isAllGranted(String authorities)
      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

      public static boolean isAnyGranted(String authorities)
      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 Authentication object retrieved from SecurityContextHolder or null
    • getAuthentication

      public static Object getAuthentication(String property)
      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.