Package org.genesys.blocks.security
Class SecurityContextUtil
- java.lang.Object
-
- org.genesys.blocks.security.SecurityContextUtil
-
public class SecurityContextUtil extends Object
The Class SecurityContextUtil.
-
-
Field Summary
Fields Modifier and Type Field Description static org.slf4j.LoggerLOGThe Constant LOG.
-
Constructor Summary
Constructors Constructor Description SecurityContextUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleananyoneHasPermission(Object targetDomainObject, Object permission)Check if ROLE_EVERYONE has permission on target object.static <T extends AclSid>
TgetCurrentUser()Gets the current principal (User or OAuthClient).static <T extends BasicUser<?>>
TgetMe()Gets the me.static StringgetOAuthClientId()Gets the OAuth Client ID of the current authentication object.static StringgetUsername()Gets the username.static booleanhasAnyRole(String... roles)Checks if any role is granted.static booleanhasAuthority(String authorityName)Check if authority is granted.static booleanhasPermission(Object targetDomainObject, Object permission)Checks for permission.static booleanhasPermission(org.springframework.security.core.Authentication auth, Object targetDomainObject, Object permission)Checks for permission.static booleanhasRole(String role)Checks for role.
-
-
-
Method Detail
-
getUsername
public static String getUsername()
Gets the username.- Returns:
- the username
-
getMe
public static <T extends BasicUser<?>> T getMe()
Gets the me.- Type Parameters:
T- the generic type- Returns:
- current user
-
getCurrentUser
public static <T extends AclSid> T getCurrentUser()
Gets the current principal (User or OAuthClient).- Type Parameters:
T- the generic type- Returns:
- the current security principal
-
hasRole
public static boolean hasRole(String role)
Checks for role.- Parameters:
role- the role- Returns:
- true, if successful
-
hasAnyRole
public static boolean hasAnyRole(String... roles)
Checks if any role is granted.- Parameters:
roles- the roles- Returns:
- true, if successful
-
hasAuthority
public static boolean hasAuthority(String authorityName)
Check if authority is granted.- Parameters:
authorityName- the authority name- Returns:
- true, if successful
-
hasPermission
public static boolean hasPermission(Object targetDomainObject, Object permission)
Checks for permission.- Parameters:
targetDomainObject- the target domain objectpermission- the permission- Returns:
- true, if successful
-
hasPermission
public static boolean hasPermission(org.springframework.security.core.Authentication auth, Object targetDomainObject, Object permission)Checks for permission.- Parameters:
auth- authentication objecttargetDomainObject- the target domain objectpermission- the permission- Returns:
- true, if successful
-
anyoneHasPermission
public static boolean anyoneHasPermission(Object targetDomainObject, Object permission)
Check if ROLE_EVERYONE has permission on target object.- Parameters:
targetDomainObject- the target domain objectpermission- the permission- Returns:
- true, if successful
-
getOAuthClientId
public static String getOAuthClientId()
Gets the OAuth Client ID of the current authentication object.- Returns:
- the OAuth client ID
-
-