Package com.skava.auth.helper
Class AccessControlHelper
java.lang.Object
com.skava.auth.helper.AccessControlHelper
This class hold the set of methods for role and privilege based access control using the authorization component of
skava framework.
- Author:
- Infosys Equinox
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
hasAccessForOpenRole
(Long userId, com.skava.core.auth.AuthTokenHandler authTokenHandler) This method will validate Request userId with Auth token userIdstatic boolean
hasBusinessAccessByBusinessIds
(String[] businessIds, String privilege, com.skava.core.auth.AuthTokenHandler authTokenHandler) This method return the accessibility result of business by list of business identifiers.static boolean
hasBusinessAccessForProtectedClientRole
(Iterator<ClientRoleVO> clientRoles, String privilege, com.skava.core.auth.AuthTokenHandler authTokenHandler) This method return the accessibility result of client's protected role.static boolean
hasBusinessAccessForProtectedClientRoles
(Collection<ClientRolesVO> clientRoles, String privilege, com.skava.core.auth.AuthTokenHandler authTokenHandler) This method return the accessibility result of client's protected role.static boolean
hasBusinessAccessForProtectedRole
(Iterator<UserRoleVO> userRoles, String privilege, com.skava.core.auth.AuthTokenHandler authTokenHandler) This method return the accessibility result of user's protected role.static boolean
hasBusinessAccessForProtectedRoles
(Collection<UserRolesVO> userRoles, String privilege, com.skava.core.auth.AuthTokenHandler authTokenHandler) This method return the accessibility result of user's protected role.static boolean
hasPersmissionToUpdateRoles
(Set<UserRole> existingUserRoles, Set<UserRoleVO> requestUserRoles, com.skava.core.auth.AuthTokenHandler authTokenHandler, Long userId) This method will validate the auth token user has access to update rolesstatic boolean
hasSelfAccess
(Long userIdFromToken, Long userId) This method return the accessibility result of self access.static boolean
hasSelfClientAccess
(String clientIdFromToken, String clientId) This method return the accessibility result of self access.static boolean
hasTokenOpenRole
(com.skava.core.auth.AuthTokenHandler authTokenHandler) This method will validate the auth token roles has open rolestatic boolean
isInstanceRole
(String roleName) static boolean
isOpenRole
(String roleName) static void
preAuthorize
(Long userId, Long collectionId, Set<UserRole> existingUserRoles, Set<UserRoleVO> requestUserRoles, com.skava.core.auth.AuthTokenHandler authTokenHandler, org.springframework.context.MessageSource messageSource) static void
preAuthorize
(Long userId, Long collectionId, Set<UserRole> existingUserRoles, Set<UserRoleVO> requestUserRoles, com.skava.core.auth.AuthTokenHandler authTokenHandler, org.springframework.context.MessageSource messageSource, boolean skipSelfAcccess) static void
preAuthorizeClient
(String clientId, Long collectionId, Set<ClientRole> existingClientRoles, Set<ClientRoleVO> requestClientRoles, com.skava.core.auth.AuthTokenHandler authTokenHandler, org.springframework.context.MessageSource messageSource) static void
preAuthorizeInstanceRole
(com.skava.core.auth.AuthTokenHandler authTokenHandler, org.springframework.context.MessageSource messageSource) static void
setInstanceRoles
(String superAdminRoleName)
-
Field Details
-
PRIVILEGE_FOR_UPDATE_USER_ROLES
- See Also:
-
PRIVILEGE_FOR_DELETE_USER_ROLES
- See Also:
-
PRIVILEGE_FOR_VIEW_USER_ROLES
- See Also:
-
PRIVILEGE_FOR_UPDATE_CLIENT_ROLES
- See Also:
-
PRIVILEGE_FOR_DELETE_CLIENT_ROLES
- See Also:
-
PRIVILEGE_FOR_VIEW_CLIENT_ROLES
- See Also:
-
PRIVILEGE_FOR_CREATE_SESSION
- See Also:
-
-
Method Details
-
setInstanceRoles
-
isInstanceRole
-
isOpenRole
-
hasBusinessAccessForProtectedRole
public static boolean hasBusinessAccessForProtectedRole(Iterator<UserRoleVO> userRoles, String privilege, com.skava.core.auth.AuthTokenHandler authTokenHandler) This method return the accessibility result of user's protected role.- Parameters:
userRoles
- aIterator
ofUserRoleVO
objects.privilege
- aString
object.authTokenHandler
- aAuthTokenHandler
object.- Returns:
- a
Boolean
object. Hold the result of access validation.
-
hasBusinessAccessForProtectedClientRole
public static boolean hasBusinessAccessForProtectedClientRole(Iterator<ClientRoleVO> clientRoles, String privilege, com.skava.core.auth.AuthTokenHandler authTokenHandler) This method return the accessibility result of client's protected role.- Parameters:
clientRoles
- aIterator
ofClientRoleVO
objects.privilege
- aString
object.authTokenHandler
- aAuthTokenHandler
object.- Returns:
- a
Boolean
object. Hold the result of access validation.
-
hasBusinessAccessForProtectedRoles
public static boolean hasBusinessAccessForProtectedRoles(Collection<UserRolesVO> userRoles, String privilege, com.skava.core.auth.AuthTokenHandler authTokenHandler) This method return the accessibility result of user's protected role.- Parameters:
userRoles
- aCollection
ofUserRolesVO
objects.privilege
- aString
object.authTokenHandler
- aAuthTokenHandler
object.- Returns:
- a
Boolean
object. Hold the result of access validation.
-
hasBusinessAccessForProtectedClientRoles
public static boolean hasBusinessAccessForProtectedClientRoles(Collection<ClientRolesVO> clientRoles, String privilege, com.skava.core.auth.AuthTokenHandler authTokenHandler) This method return the accessibility result of client's protected role.- Parameters:
clientRoles
- aCollection
ofClientRolesVO
objects.privilege
- aString
object.authTokenHandler
- aAuthTokenHandler
object.- Returns:
- a
Boolean
object. Hold the result of access validation.
-
hasSelfAccess
This method return the accessibility result of self access. -
hasSelfClientAccess
This method return the accessibility result of self access. -
hasBusinessAccessByBusinessIds
public static boolean hasBusinessAccessByBusinessIds(String[] businessIds, String privilege, com.skava.core.auth.AuthTokenHandler authTokenHandler) This method return the accessibility result of business by list of business identifiers. -
preAuthorizeInstanceRole
public static void preAuthorizeInstanceRole(com.skava.core.auth.AuthTokenHandler authTokenHandler, org.springframework.context.MessageSource messageSource) -
hasAccessForOpenRole
public static boolean hasAccessForOpenRole(Long userId, com.skava.core.auth.AuthTokenHandler authTokenHandler) This method will validate Request userId with Auth token userId -
hasTokenOpenRole
public static boolean hasTokenOpenRole(com.skava.core.auth.AuthTokenHandler authTokenHandler) This method will validate the auth token roles has open role- Parameters:
authTokenHandler
- aAuthTokenHandler
object.- Returns:
- a
Boolean
object. Hold the result of access validation.
-
hasPersmissionToUpdateRoles
public static boolean hasPersmissionToUpdateRoles(Set<UserRole> existingUserRoles, Set<UserRoleVO> requestUserRoles, com.skava.core.auth.AuthTokenHandler authTokenHandler, Long userId) This method will validate the auth token user has access to update roles -
preAuthorize
public static void preAuthorize(Long userId, Long collectionId, Set<UserRole> existingUserRoles, Set<UserRoleVO> requestUserRoles, com.skava.core.auth.AuthTokenHandler authTokenHandler, org.springframework.context.MessageSource messageSource, boolean skipSelfAcccess) - Parameters:
userId
- aLong
object.collectionId
- aLong
object.existingUserRoles
- aSet
ofUserRole
objects. which holds the existing roles of the user.requestUserRoles
- aSet
ofUserRoleVO
objects.authTokenHandler
- aAuthTokenHandler
object.messageSource
- aMessageSource
object.skipSelfAcccess
- a boolean object
-
preAuthorizeClient
public static void preAuthorizeClient(String clientId, Long collectionId, Set<ClientRole> existingClientRoles, Set<ClientRoleVO> requestClientRoles, com.skava.core.auth.AuthTokenHandler authTokenHandler, org.springframework.context.MessageSource messageSource) - Parameters:
clientId
- aString
object.collectionId
- aLong
object.existingClientRoles
- aSet
ofClientRole
objects. which holds the existing roles of the client.requestClientRoles
- aSet
ofClientRoleVO
objects.authTokenHandler
- aAuthTokenHandler
object.messageSource
- aMessageSource
object.
-
preAuthorize
-