Package org.genesys.blocks.security
Class SecurityContextUtil
java.lang.Object
org.genesys.blocks.security.SecurityContextUtil
The Class SecurityContextUtil.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleananyoneHasPermission(Object targetDomainObject, Object permission) Check if ROLE_EVERYONE has permission on target object.static <T extends AclSid>
TGets the current principal (User or OAuthClient).static <T extends BasicUser<?>>
TgetMe()Gets the me.static StringGets the OAuth Client ID of the current authentication object.static StringGets 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 booleanChecks for role.
-
Constructor Details
-
SecurityContextUtil
public SecurityContextUtil()
-
-
Method Details
-
getUsername
Gets the username.- Returns:
- the username
-
getMe
Gets the me.- Type Parameters:
T- the generic type- Returns:
- current user
-
getCurrentUser
Gets the current principal (User or OAuthClient).- Type Parameters:
T- the generic type- Returns:
- the current security principal
-
hasRole
Checks for role.- Parameters:
role- the role- Returns:
- true, if successful
-
hasAnyRole
Checks if any role is granted.- Parameters:
roles- the roles- Returns:
- true, if successful
-
hasAuthority
Check if authority is granted.- Parameters:
authorityName- the authority name- Returns:
- true, if successful
-
hasPermission
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
Check if ROLE_EVERYONE has permission on target object.- Parameters:
targetDomainObject- the target domain objectpermission- the permission- Returns:
- true, if successful
-
getOAuthClientId
Gets the OAuth Client ID of the current authentication object.- Returns:
- the OAuth client ID
-